{"version":3,"file":"bespunky-angular-cdk-navigables-camera.mjs","sources":["../../../../libs/angular-cdk/navigables/camera/src/shared/view-bounds.ts","../../../../libs/angular-cdk/navigables/camera/src/core/camera.ts","../../../../libs/angular-cdk/navigables/camera/src/bespunky-angular-cdk-navigables-camera.ts"],"sourcesContent":["import { ViewPort } from './view-port';\n\nexport class ViewBounds\n{\n    public readonly left  : number;\n    public readonly top   : number;\n    public readonly right : number;\n    public readonly bottom: number;\n\n    public readonly width : number;\n    public readonly height: number;\n    \n    public readonly aspectRatio: number;\n\n    public readonly screenCenterX: number;\n    public readonly screenCenterY: number;\n\n    constructor(\n        public readonly viewPort   : ViewPort,\n        public readonly viewCenterX: number,\n        public readonly viewCenterY: number\n    )\n    {\n        this.left   = viewCenterX - viewPort.width  / 2;\n        this.top    = viewCenterY - viewPort.height / 2;\n        this.width  = viewPort.width;\n        this.height = viewPort.height;\n        this.right  = this.left + this.width;\n        this.bottom = this.top  + this.height;\n\n        this.aspectRatio = this.width / this.height;\n\n        this.screenCenterX = viewPort.width  / 2;\n        this.screenCenterY = viewPort.height / 2;\n    }\n}","import { BehaviorSubject, combineLatest, Observable, Subject        } from 'rxjs';\nimport { map, pairwise, shareReplay, startWith, tap, withLatestFrom } from 'rxjs/operators';\nimport { ElementRef, Injectable                                     } from '@angular/core';\nimport { Property                                                   } from '@bespunky/typescript-utils';\nimport { Destroyable                                                } from '@bespunky/angular-zen/core';\n\nimport { ViewPort   } from '../shared/view-port';\nimport { ViewBounds } from '../shared/view-bounds';\n\nfunction constrainLowerBound(center: number, lower: number | null, halfViewPort: number): { center: number; constrained: boolean; }\n{\n    if (lower !== null && center - halfViewPort < lower) return { center: lower + halfViewPort, constrained: true };\n\n    return { center, constrained: false };\n}\n\nfunction constrainUpperBound(center: number, upper: number | null, halfViewPort: number): { center: number; constrained: boolean; }\n{\n    if (upper !== null && center + halfViewPort > upper) return { center: upper - halfViewPort, constrained: true };\n\n    return { center, constrained: false };\n}\n\n/**\n * Applies a pipeline map on values emitted from the view center source observable which are out of the\n * specified position bounds, in order to keep them in bounds.\n *\n * @param {Observable<ViewPort>} viewPort The observable that emits the current viewport.\n * @param {(Observable<number | null>)} lowerBound The observable that emits the lower bound of the view bounds. If `null` is emitted,\n * values will have no lower bound.\n * @param {(Observable<number | null>)} upperBound The observable that emits the upper bound of the view bounds. If `null` is emitted,\n * values will have no upper bound.\n * @param {Property<ViewPort, number>} viewPortLengthKey The key which holds the width or height of the view port\n * according to what the calling code is filtering (x position or y position).\n * @return {(centerSource: Observable<number>) => Observable<number>} An observable which emits the source emitted value only\n * if it is withing the specified bounds.\n */\nfunction keepPositionInRange(\n    viewPort         : Observable<ViewPort>,\n    lowerBound       : Observable<number | null>,\n    upperBound       : Observable<number | null>,\n    viewPortLengthKey: Property<ViewPort, number>,\n): (centerSource: Observable<number>) => Observable<{ center: number, constrained: boolean }>\n{\n    return (centerSource: Observable<number>) => centerSource.pipe(\n        pairwise(),\n        map(([prevCenter, currCenter]) => ({\n            center   : currCenter,\n            direction: Math.sign(currCenter - prevCenter)\n        })),\n        withLatestFrom(viewPort, lowerBound, upperBound),\n        map(([{ center, direction }, viewPort, lower, upper]) =>\n        {\n            // Calculate half the viewport size so it can be added/subtracted from the position (which refers to the center of the view bounds)\n            const halfViewPort = viewPort[viewPortLengthKey] / 2;\n\n            // If bounds exist, use them to determine if the value is in range. If it is not, return a new value sitting on the bounds exactly.\n            if      (direction === -1) return constrainLowerBound(center, lower, halfViewPort);\n            else if (direction ===  1) return constrainUpperBound(center, upper, halfViewPort);\n\n            // No bounds or value is in range. Use the new center as-is.\n            return { center, constrained: false };\n        })\n    );\n}\n\nexport type PanAxis = 'x' | 'y' | 'both';\n\n@Injectable()\nexport abstract class Camera<TItem> extends Destroyable\n{\n    private readonly zoomLevelInput  : Subject<number> = new Subject();\n    private readonly viewCenterXInput: Subject<number> = new Subject();\n    private readonly viewCenterYInput: Subject<number> = new Subject();\n    \n    public readonly zoomFactor   : BehaviorSubject<number>  = new BehaviorSubject(1.06);\n    public readonly panAxisOnZoom: BehaviorSubject<PanAxis> = new BehaviorSubject('x' as PanAxis);\n    \n    public readonly leftBound  : BehaviorSubject<number | null> = new BehaviorSubject(null as number | null);\n    public readonly rightBound : BehaviorSubject<number | null> = new BehaviorSubject(null as number | null);\n    public readonly topBound   : BehaviorSubject<number | null> = new BehaviorSubject(null as number | null);\n    public readonly bottomBound: BehaviorSubject<number | null> = new BehaviorSubject(null as number | null);\n    \n    protected readonly horizontalBoundReached: Subject<number> = new Subject();\n    protected readonly verticalBoundReached  : Subject<number> = new Subject();\n    \n    /**\n     * A zoom dependant value to use as a unit for sizing elements on the screen.\n     *\n     * @type {Observable<number>}\n     */\n    public readonly viewPort   : Observable<ViewPort>;\n    public readonly zoomLevel  : Observable<number>;\n    public readonly sizeUnit   : Observable<number>;\n    public readonly viewCenterX: Observable<number>;\n    public readonly viewCenterY: Observable<number>;\n    public readonly viewBounds : Observable<ViewBounds>;\n    \n    private _currentViewBounds: ViewBounds = new ViewBounds({ width: 0, height: 0 }, 0, 0);\n    public get currentViewBounds(): ViewBounds { return this._currentViewBounds; }\n\n    private _currentZoomLevel = 0;\n    public get currentZoomLevel(): number { return this._currentZoomLevel; }\n\n    constructor(protected element: ElementRef)\n    {\n        super();\n        \n        this.viewPort    = this.viewPortFeed();\n        this.zoomLevel   = this.zoomLevelFeed();\n        this.sizeUnit    = this.sizeUnitFeed();\n        this.viewCenterX = this.viewCenterXFeed();\n        this.viewCenterY = this.viewCenterYFeed();\n        this.viewBounds  = this.viewBoundsFeed();\n    }\n    \n    protected viewPortFeed(): Observable<ViewPort>\n    {\n        return new Observable<ViewPort>(observer =>\n        {\n            const element: HTMLElement = this.element.nativeElement;\n            const resize = new ResizeObserver(([{ contentRect: { width, height } }]) => observer.next({ width, height }));\n            \n            observer.next({ width: element.clientWidth, height: element.clientHeight });\n\n            resize.observe(element)\n        \n            return () => resize.disconnect();\n        });\n    }\n\n    protected zoomLevelFeed(): Observable<number>\n    {\n        return this.zoomLevelInput.pipe(\n            startWith(0),\n            tap(zoomLevel => this._currentZoomLevel = zoomLevel)\n        );\n    }\n    \n    protected sizeUnitFeed(): Observable<number>\n    {\n        return combineLatest([this.zoomFactor, this.zoomLevel]).pipe(\n            map(([zoomFactor, zoomLevel]) => zoomFactor ** zoomLevel)\n        );\n    }\n\n    protected viewCenterXFeed(): Observable<number>\n    {\n        return this.viewCenterXInput.pipe(\n            startWith(0),\n            keepPositionInRange(this.viewPort, this.leftBound, this.rightBound, 'width'),\n            tap(({ center, constrained }) => constrained ? this.horizontalBoundReached.next(center) : null),\n            map(({ center }) => center)\n        );\n    }\n\n    protected viewCenterYFeed(): Observable<number>\n    {\n        return this.viewCenterYInput.pipe(\n            startWith(0),\n            keepPositionInRange(this.viewPort, this.topBound, this.bottomBound, 'height'),\n            tap(({ center, constrained }) => constrained ? this.verticalBoundReached.next(center) : null),\n            map(({ center }) => center)\n        );\n    }\n\n    protected viewBoundsFeed(): Observable<ViewBounds>\n    {\n        return combineLatest([this.viewPort, this.viewCenterX, this.viewCenterY]).pipe(\n            map(([viewPort, viewCenterX, viewCenterY]) => new ViewBounds(viewPort, viewCenterX, viewCenterY)),\n            tap(viewBounds => this._currentViewBounds = viewBounds),\n            shareReplay(1)\n        );\n    }\n    \n    protected abstract panToItem(item: TItem): void;\n    protected abstract zoomOnItem(item: TItem, amount: number): void;\n    \n    public panTo(item: TItem)                         : void;\n    public panTo(positionX: number, positionY: number): void;\n    public panTo(arg1: number | TItem, arg2?: number) : void\n    {\n        if (typeof arg1 === 'number')\n        {\n            if (typeof arg2 !== 'number') throw new Error(`Expected numeric y view position (got ${typeof arg2}). Provide a numeric y value or use another overload.`);\n            \n            this.panToPosition(arg1, arg2)\n        }\n        else this.panToItem(arg1);\n    }\n\n    public panToX(position: number): void\n    {\n        this.viewCenterXInput.next(position);\n    }\n    \n    public panToY(position: number): void\n    {\n        this.viewCenterYInput.next(position);\n    }\n    \n    public zoomOn(item: TItem, amount: number)                         : void;\n    public zoomOn(positionX: number, positionY: number, amount: number): void;\n    public zoomOn(arg1: number | TItem, arg2: number, arg3?: number)   : void\n    {\n        if (typeof arg1 === 'number')\n        {\n            if (typeof arg2 !== 'number') throw new Error(`Expected numeric y view position (got ${typeof arg2}). Provide a numeric y value or use another overload.`);\n            if (typeof arg3 !== 'number') throw new Error(`Expected numeric zoom amount (got ${typeof arg3}).`);\n\n            this.zoomOnPosition(arg1, arg2, arg3);\n        }\n        else this.zoomOnItem(arg1, arg2);   \n    }\n\n    public panX(amount: number): void\n    {\n        this.viewCenterXInput.next(this.currentViewBounds.viewCenterX + amount);\n    }\n\n    public panY(amount: number): void\n    {\n        this.viewCenterYInput.next(this.currentViewBounds.viewCenterY + amount);\n    }\n\n    public pan(amountX: number, amountY: number): void\n    {\n        this.panX(amountX);\n        this.panY(amountY);\n    }\n    \n    protected panToPosition(positionX: number, positionY: number): void\n    {\n        this.panToX(positionX);\n        this.panToY(positionY);\n    }\n\n    public zoom(amount: number): void\n    {\n        this.zoomLevelInput.next(this.currentZoomLevel + amount);\n    }\n\n    public setZoom(zoomLevel: number): void\n    {\n        this.zoomLevelInput.next(zoomLevel);\n    }\n\n    protected zoomOnPosition(positionX: number, positionY: number, amount: number): void\n    {\n        this.zoom(amount);\n\n        const zoomedBy          = this.calculateZoomChangeInPixels(amount);\n        const zoomedViewCenterX = this.calculateViewCenterZoomedToPosition(this.currentViewBounds.viewCenterX, positionX, zoomedBy);\n        const zoomedViewCenterY = this.calculateViewCenterZoomedToPosition(this.currentViewBounds.viewCenterY, positionY, zoomedBy);\n        const axis              = this.panAxisOnZoom.value;\n        \n        if      (axis === 'both') this.panToPosition(zoomedViewCenterX, zoomedViewCenterY);\n        else if (axis === 'x')    this.panToX(zoomedViewCenterX);\n        else                      this.panToY(zoomedViewCenterY);\n    }\n    \n    private calculateZoomChangeInPixels(amount: number): number\n    {\n        const zoomingOut = Math.sign(amount) < 0;\n        let   zoomFactor = this.zoomFactor.value;\n        \n        // When zooming out, flip the factor to shrink instead of grow\n        if (zoomingOut) zoomFactor = 1 / zoomFactor;\n        \n        // Multiply the factor (in pixels) by the zoom amount to get the increase/decrease in pixels (AKA `zoomedBy`)\n        return zoomFactor * Math.abs(amount);\n    }\n\n    /**\n     *\n     *\n     * @private\n     * @param {number} currentViewCenter The current center position of the viewbox relative to the complete drawing.\n     * @param {number} position\n     * @param {number} zoomedBy\n     * @returns {number}\n     */\n    private calculateViewCenterZoomedToPosition(currentViewCenter: number, position: number, zoomedBy: number): number\n    {\n        /** The idea is to:\n         * 1. Calculate the current distance between the position and the viewCenter, so the same distance could be applied later-on.\n         * 2. Calculate where the pixel that was under the position will be AFTER zooming.\n         *    This will be the position multiplied by the factor.\n         *    If the image grew by 15%, the pixel under the position did the same.\n         * 3. Subtract the current distance from the new position to receive the new viewCenter.\n         */\n\n        /** The distance between the position and the center before zooming. This should be kept after zoom. */\n        const deltaPositionToCenter = position - currentViewCenter;\n        /** The new position of the pixel under the specified point AFTER zooming. */\n        const newPosition           = position * zoomedBy;\n        // The new center be relative to the new position after zooming\n        return newPosition - deltaPositionToCenter;\n    }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MAEa,UAAU,CAAA;AAenB,IAAA,WAAA,CACoB,QAAqB,EACrB,WAAmB,EACnB,WAAmB,EAAA;AAFnB,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAa;AACrB,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAQ;AACnB,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAQ;QAGnC,IAAI,CAAC,IAAI,GAAK,WAAW,GAAG,QAAQ,CAAC,KAAK,GAAI,CAAC,CAAC;QAChD,IAAI,CAAC,GAAG,GAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AAChD,QAAA,IAAI,CAAC,KAAK,GAAI,QAAQ,CAAC,KAAK,CAAC;AAC7B,QAAA,IAA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