module.exports = "(function(e,t,a){var n=a(5894),r=a(1148),s=a(3684),c=a(9404),u=a(5077),o=a(8737),h=a(5035),i=a(4727).Promise,p=a(6103);function g(e){return-1!==[h.changeState.APPLIED,h.changeState.TIMED_OUT,h.changeState.IGNORED].indexOf(e)}function d(e){return-1!==[h.changeState.UNAPPLIED,h.changeState.IGNORED].indexOf(e)}function l(e,t,a){void 0===a&&(a=!1);var r=!0;return e&&n.each(e,(function(e){var n=t[e].status,s=a?d(n):g(n);r=r&&s})),r}function f(e){var t={};return n.forOwn(e,(function(e){t[e.id]={status:h.changeState.UNAPPLIED,error:null}})),t}function S(e){var t={},a=n.cloneDeep(e);return n.each(a,(function(e){t[e.id]=[]})),n.each(a,(function(e){n.each(e.dependencies,(function(a){t[a]&&t[a].push(e.id)}))})),n.each(a,(function(e){e.dependencies=t[e.id]})),a.reverse()}t.constants=a(1540),t.enums=h,t.store={},t.create=function(e,a){return a=a||p.generate(),t.store[a]={applyDeferred:null,changeObjects:[],changeSet:e,changeStatusMap:f(e),id:a,status:h.changeApplierState.UNAPPLIED,startTime:null,undoChangeSet:S(e),undoDeferred:null},{apply:n.partial(t.apply,a),cancel:n.partial(t.cancel,a),undo:n.partial(t.undo,a)}},t.apply=function(e){if(t.store[e].status!==h.changeApplierState.UNAPPLIED)throw new Error(\"Cannot apply changeset that is currently applying or undoing\");return t.store[e].startTime=Date.now(),t.store[e].status=h.changeApplierState.APPLYING,t.store[e].applyDeferred=u(),t.applyReadyChanges(e),t.store[e].applyDeferred},t.cancel=function(e){n.each(t.store[e].changeObjects,(function(e){e.cancel&&e.cancel()})),t.store[e].applyDeferred&&t.store[e].applyDeferred.reject(t.store[e].changeStatusMap),t.store[e].changeObjects=[]},t.identifyChildrenWithChangeData=function(e){var t=o.childrenOf(e);return n.filter(t,s.hasData)},t.undo=function(e,a){if(t.store[e].status!==h.changeApplierState.UNDOING)return t.store[e].status=h.changeApplierState.UNDOING,t.store[e].undoChangeId=a,t.cancel(e),t.store[e].undoDeferred=u(),t.undoReadyChanges(e),t.store[e].undoDeferred},t.applyReadyChanges=function(e){var a=!0;n.each(t.store[e].changeSet,(function(a){var n=t.store[e].changeStatusMap[a.id].status,r=l(a.dependencies,t.store[e].changeStatusMap);n!==h.changeState.UNAPPLIED||r?n===h.changeState.BLOCKED&&r&&(t.store[e].changeStatusMap[a.id].status=h.changeState.UNAPPLIED):t.store[e].changeStatusMap[a.id].status=h.changeState.BLOCKED})),n.each(t.store[e].changeSet,(function(r){var s=t.store[e].changeStatusMap[r.id].status;if(g(s)||(a=!1),s===h.changeState.UNAPPLIED&&l(r.dependencies,t.store[e].changeStatusMap)){var c=n.partial(t.reapplyReadyChanges,e);t.applyChange(e,r).then(c,c)}})),a&&(t.store[e].status=h.changeApplierState.APPLIED,t.store[e].applyDeferred.resolve(t.store[e].changeStatusMap))},t.reapplyReadyChanges=function(e){t.applyReadyChanges(e)},t.undoReadyChanges=function(e){var a=!0;n.each(t.store[e].undoChangeSet,(function(r){t.store[e].changeStatusMap[r.id].status===h.changeState.BLOCKED&&(t.store[e].changeStatusMap[r.id].status=h.changeState.UNAPPLIED);var s=t.store[e].changeStatusMap[r.id].status;if(s!==h.changeState.UNAPPLIED&&s!==h.changeState.IGNORED&&(a=!1),[h.changeState.APPLYING,h.changeState.APPLIED,h.changeState.TIMED_OUT].indexOf(s)>-1&&l(r.dependencies,t.store[e].changeStatusMap,!0)){var c=n.partial(t.reundoReadyChanges,e);t.undoChange(e,r).then(c,c)}var u=t.store[e].changeStatusMap[r.id].status;if(r.id===t.store[e].undoChangeId&&d(u))return a=!0,!1})),a&&(t.store[e].status=h.changeApplierState.UNAPPLIED,t.store[e].undoDeferred.resolve(t.store[e].changeStatusMap))},t.reundoReadyChanges=function(e){t.store[e].status===h.changeApplierState.UNDOING&&t.undoReadyChanges(e)},t.applyChange=function(e,a){t.store[e].changeStatusMap[a.id].status=h.changeState.APPLYING;var n=r.create(a,null,c.now());return t.store[e].changeObjects.push(n),n.apply().then((function(){t.store[e].changeStatusMap[a.id].status=h.changeState.APPLIED}),(function(n){t.store[e].changeStatusMap[a.id]={status:h.changeState.TIMED_OUT,error:n}}))},t.undoChange=function(e,a){t.store[e].changeStatusMap[a.id].status=h.changeState.UNDOING;var n=r.create(a,null,c.now());return(n.undo?n.undo():i.resolve()).then((function(n){t.store[e].changeStatusMap[a.id].status=n}))},t.cleanup=function(){n.each(t.store,(function(e){n.each(e.changeObjects,(function(e){e.cancel&&e.cancel()}))})),t.store={}}})";