import { NgModule , ModuleWithProviders , NgZone } from '@angular/core' ; import { SkyhookDndService } from './connector.service' ; import { DndDirective , DragSourceDirective , DropTargetDirective , DragPreviewDirective } from './dnd.directive' ; import { DRAG_DROP_BACKEND , DRAG_DROP_BACKEND_OPTIONS , DRAG_DROP_BACKEND_DEBUG_MODE , DRAG_DROP_MANAGER , DRAG_DROP_GLOBAL_CONTEXT } from './tokens' ; import { createDragDropManager , BackendFactory , DragDropManager } from 'dnd-core' ; import { invariant } from './internal/invariant' ; ignore export function unpackBackendForEs5Users ( backendOrModule ) { let backend = backendOrModule ; if ( typeof backend === 'object' && typeof backend . default === 'function' ) { backend = backend . default ; } invariant ( typeof backend === 'function' , 'Expected the backend to be a function or an ES6 module exporting a default function. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs-drag-drop-context.html' ) ; return backend ; } ignore export function managerFactory ( backendFactory , zone , context , backendOptions ? , debugMode ? ) { backendFactory = unpackBackendForEs5Users ( backendFactory ) ; return zone . runOutsideAngular ( ( ) => createDragDropManager ( backendFactory , context , backendOptions , debugMode ) ) ; } ignore declare var global ; ignore export function getGlobalContext ( ) { return typeof global !== 'undefined' ? global : ( window as any ) ; } /** Use this for providing plain backends to  SkyhookDndModule .  export interface BackendInput { /** A plain backend, for example the HTML5Backend. */ backend : BackendFactory ; options ? : any ; debug ? : boolean ; } /**
 * Use this for providing backends that need configuring before use to  SkyhookDndModule .
 *
 * For use with the MultiBackend:
 *
 * ```typescript
 * import { createDefaultMultiBackend } from '@angular-skyhook/multi-backend';
 * // ...
 * SkyhookDndModule.forRoot({ backendFactory: createDefaultMultiBackend })
 * ```
 *
 * or with the TouchBackend by itself:
 *
 * ```typescript
 * export function createTouchBackend() {
 *     return TouchBackend({ enableMouseEvents: false });
 * }
 * // ...
 * SkyhookDndModule.forRoot({ backendFactory: createTouchBackend })
 * ```
 *
 * You have to do this to retain AOT compatibility.
  export interface BackendFactoryInput { /** See above. */ backendFactory : ( ) => BackendFactory ; debug ? : boolean ; } ignore const EXPORTS = [ DndDirective , DragSourceDirective , DropTargetDirective , DragPreviewDirective , ] ; @ NgModule ( { declarations : EXPORTS , exports : EXPORTS , } ) export class SkyhookDndModule { static forRoot ( backendOrBackendFactory ) { return { ngModule : SkyhookDndModule , providers : [ { provide : DRAG_DROP_BACKEND , useValue : ( backendOrBackendFactory as BackendInput ) . backend , useFactory : ( backendOrBackendFactory as BackendFactoryInput ) . backendFactory , } , { provide : DRAG_DROP_BACKEND_OPTIONS , useValue : ( backendOrBackendFactory as BackendInput ) . options , } , { provide : DRAG_DROP_BACKEND_DEBUG_MODE , useValue : backendOrBackendFactory . debug , } , { provide : DRAG_DROP_GLOBAL_CONTEXT , useFactory : getGlobalContext , } , { provide : DRAG_DROP_MANAGER , useFactory : managerFactory , deps : [ DRAG_DROP_BACKEND , NgZone , DRAG_DROP_GLOBAL_CONTEXT , DRAG_DROP_BACKEND_OPTIONS , DRAG_DROP_BACKEND_DEBUG_MODE , ] , } , SkyhookDndService , ] } ; } }