import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { Directive, ElementRef, Inject, InjectionToken, Input, Optional, SkipSelf, } from '@angular/core';
import { Subject } from 'rxjs';
import { R_DRAG_PARENT } from '../drag-parent';
/**
 * Injection token that can be used to reference instances of `RDragHandle`. It serves as
 * alternative token to the actual `RDragHandle` class which could cause unnecessary
 * retention of the class and its directive metadata.
 */
export const R_DRAG_HANDLE = new InjectionToken('RDragHandle');
/** Handle that can be used to drag a RDrag instance. */
export class RDragHandle {
    constructor(element, parentDrag) {
        this.element = element;
        /** Emits when the state of the handle has changed. */
        this._stateChanges = new Subject();
        this._disabled = false;
        this._parentDrag = parentDrag;
    }
    /** Whether starting to drag through this handle is disabled. */
    get disabled() { return this._disabled; }
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value);
        this._stateChanges.next(this);
    }
    ngOnDestroy() {
        this._stateChanges.complete();
    }
}
RDragHandle.decorators = [
    { type: Directive, args: [{
                selector: '[rDragHandle]',
                host: {
                    'class': 'r-drag-handle'
                },
                providers: [{ provide: R_DRAG_HANDLE, useExisting: RDragHandle }],
            },] }
];
RDragHandle.ctorParameters = () => [
    { type: ElementRef },
    { type: undefined, decorators: [{ type: Inject, args: [R_DRAG_PARENT,] }, { type: Optional }, { type: SkipSelf }] }
];
RDragHandle.propDecorators = {
    disabled: [{ type: Input, args: ['rDragHandleDisabled',] }]
};
//# sourceMappingURL=drag-handle.js.map