{"version":3,"sources":["webpack:///D:/a/1/s/src/app/core/pipes/truncate/truncate.shared.pipe.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/components/cartButton/cart-button.shared.module.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/components/cartButton/index.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/components/cartLocationButton/cart-location-button.shared.module.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/components/cartLocationButton/index.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/directives/cart-directives.shared.module.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/directives/index.ts","webpack:///D:/a/1/s/src/app/core/modules/cart/directives/cart-popup.shared.directive.ts","webpack:///D:/a/1/s/src/app/core/pipes/truncate/truncate.pipe.module.ts","webpack:///D:/a/1/s/src/app/core/pipes/truncate/index.ts"],"names":["TruncatePipe","value","startAt","limit","ellipsis","completeWords","Number","isInteger","length","substr","lastIndexOf","newValue","notAllowedLastChars","includes","CartButtonModule","CartLocationButtonModule","CartDirectivesModule","CartPopupDirective","_renderer2","_elementRef","_cartPopupService","_offset","_resizeTimeoutTrigger","mode","top","left","opacity","this","clearTimeout","setTimeout","_setElementsCoords","_elem","nativeElement","tempMode","getAttribute","_isMobile","console","warn","setTargetCoords","_calculatePopupPosition","window","innerWidth","offset","_unsetPopupPositionStyles","target","getTargetCoords","width","clientWidth","height","TruncatePipeModule"],"mappings":"gJAQO,Y,MAAMA,EACT,UAAUC,EAAeC,EAAkB,EAAGC,EAAgB,GAAIC,EAAmB,MAAOC,GAAyB,GACjH,GAAqB,iBAAVJ,GAAuC,iBAAVE,EAAoB,OAAOF,EAMnE,KAJKK,OAAOC,UAAUL,IAAYA,EAAU,KACxCA,EAAU,GAGVD,EAAMO,QAAUL,EAAO,OAAOF,GAEZ,IAAlBI,IACAF,EAAQF,EAAMQ,OAAOP,EAASC,GAAOO,YAAY,MAGrD,IAAIC,EAAmBV,EAAMQ,OAAOP,EAASC,GAC7C,MAAMS,EAAgC,CAAC,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KAAKY,2BAIL,YACJ,OAAOC,OAAOC,WAAa,IAGvB,4BACJd,KAAKH,IAAM,KACXG,KAAKF,KAAO,KACM,UAAdE,KAAKJ,OACAI,KAAKQ,cACNR,KAAKD,QAAU,MAMnB,0BACJC,KAAKN,QAAUM,KAAKP,kBAAkBsB,OAEtCb,WAAW,KACP,GAAIF,KAAKQ,YACL,OAAOR,KAAKgB,4BAGhB,MAAMC,EAAqBjB,KAAKP,kBAAkByB,kBAClD,IAAKD,EACD,OAAOjB,KAAKgB,4BAKhBhB,KAAKF,KAAO,GAAImB,EAAOnB,KAAOmB,EAAOE,MAAQnB,KAAKN,QAAWM,KAAKI,MAAMgB,cAKxEpB,KAAKH,IAAM,GAAGoB,EAAOpB,IAAMoB,EAAOI,OAASrB,KAAKN,UAC9B,UAAdM,KAAKJ,MAAqBI,KAAKQ,aAC/BN,WAAW,KACPF,KAAKD,QAAU,KAChB,KAER,I,6CAxGET,GAAkB,gC,uBAAlBA,EAAkB,mE,MAAA,K,mIAAlB,sBAAgB,Q,2EAAtB,I,4DCSA,Y,MAAMgC,G,8BAAAA,I,oDAAAA,M,GAAN,GChBP","file":"x","sourcesContent":["/*\r\n    Change long texts to something shorter.\r\n    i.e. 'Aaaaaaaa' -> 'Aaaa...'\r\n    {{ someStringHere | truncate: 0 : 82 : '...' : false }}\r\n*/\r\nimport { Pipe, PipeTransform } from '@angular/core';\r\n\r\n@Pipe({ name: 'truncate' })\r\nexport class TruncatePipe implements PipeTransform {\r\n    transform(value: string, startAt: number = 0, limit: number = 82, ellipsis: string = '...', completeWords: boolean = false): any {\r\n        if (typeof value !== 'string' || typeof limit !== 'number') return value;\r\n\r\n        if (!Number.isInteger(startAt) || startAt < 0) {\r\n            startAt = 0;\r\n        }\r\n\r\n        if (value.length <= limit) return value;\r\n\r\n        if (completeWords === true) {\r\n            limit = value.substr(startAt, limit).lastIndexOf(' ');\r\n        }\r\n\r\n        let newValue: string = value.substr(startAt, limit);\r\n        const notAllowedLastChars: string[] = [',', ' ', '.'];\r\n        while (notAllowedLastChars.includes(newValue[newValue.length - 1])) {\r\n            newValue = newValue.substr(0, newValue.length - 1);\r\n        }\r\n\r\n        return `${newValue}${value.length > limit && ellipsis ? ellipsis : ''}`;\r\n\r\n    }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { CartDirectivesModule } from '../../directives';\r\n\r\nimport { ButtonsModule } from '@shared/core/components/buttons';\r\nimport { BadgesModule } from '@shared/core/components/badges';\r\n\r\nimport { CartButtonComponent } from './cart-button.shared.component';\r\n\r\n@NgModule({\r\n    declarations: [\r\n        CartButtonComponent\r\n    ],\r\n    imports: [\r\n        CommonModule,\r\n        ButtonsModule,\r\n        BadgesModule,\r\n        CartDirectivesModule,\r\n    ],\r\n    exports: [\r\n        CartButtonComponent\r\n    ],\r\n    providers: [],\r\n})\r\nexport class CartButtonModule { }\r\n","export * from './cart-button.shared.module';\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { TruncatePipeModule } from '@shared/core/pipes/truncate';\r\nimport { LinkModule } from '@shared/core/components/link';\r\n\r\nimport { CartLocationButtonComponent } from './cart-location-button.shared.component';\r\n\r\n@NgModule({\r\n    declarations: [\r\n        CartLocationButtonComponent\r\n    ],\r\n    imports: [\r\n        CommonModule,\r\n        TruncatePipeModule,\r\n        LinkModule,\r\n    ],\r\n    exports: [\r\n        CartLocationButtonComponent\r\n    ],\r\n    providers: [],\r\n})\r\nexport class CartLocationButtonModule { }\r\n","export * from './cart-location-button.shared.module';\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { CartIndicatorDirective } from './cart-indicator.shared.directive';\r\nimport { CartPopupDirective } from './cart-popup.shared.directive';\r\n\r\n@NgModule({\r\n    declarations: [\r\n        CartIndicatorDirective,\r\n        CartPopupDirective,\r\n    ],\r\n    imports: [CommonModule],\r\n    exports: [\r\n        CartIndicatorDirective,\r\n        CartPopupDirective,\r\n    ],\r\n    providers: [],\r\n})\r\nexport class CartDirectivesModule { }\r\n","export * from './cart-directives.shared.module';\r\n","import { Directive, ElementRef, AfterViewInit, OnInit, Renderer2, HostBinding, ViewChild, HostListener } from '@angular/core';\r\n\r\nimport { CartPopupService } from '../cart-popup.shared.service';\r\n\r\n@Directive({\r\n    selector: '[directive-cart-popup]',\r\n})\r\nexport class CartPopupDirective implements OnInit, AfterViewInit {\r\n    private _elem: HTMLElement;\r\n    private _offset: number = 0;\r\n    private _resizeTimeoutTrigger: number = null;\r\n    public mode: 'target' | 'popup' = 'target';\r\n\r\n    @HostBinding('style.top.px') public top: string = null;\r\n    @HostBinding('style.left.px') public left: string = null;\r\n    @HostBinding('style.opacity') public opacity: string = null;\r\n\r\n    @ViewChild('indicator', { static: true }) public indicator: ElementRef;\r\n    @HostListener('window:resize') public onWindowResize(): void {\r\n        if (this._resizeTimeoutTrigger) {\r\n            clearTimeout(this._resizeTimeoutTrigger);\r\n            this._resizeTimeoutTrigger = null;\r\n        }\r\n\r\n        setTimeout(() => {\r\n            this._setElementsCoords();\r\n        }, 200);\r\n    }\r\n\r\n    constructor(\r\n        private _renderer2: Renderer2,\r\n        private _elementRef: ElementRef,\r\n        private _cartPopupService: CartPopupService,\r\n    ) { }\r\n\r\n    ngOnInit(): void {\r\n        this._elem = this._elementRef.nativeElement;\r\n\r\n        const tempMode = this._elem.getAttribute('directive-cart-popup');\r\n        if (tempMode === 'popup') {\r\n            this.mode = 'popup';\r\n            if (!this._isMobile()) {\r\n                this.opacity = '0';\r\n            }\r\n        } else if (tempMode === 'target' || '') {\r\n            this.mode = 'target';\r\n        } else {\r\n            this.mode = null;\r\n            return console.warn('Invalid mode provided id directive-cart-popup. Should be \"popup\" or \"target\". Is: ', tempMode, ' Element: ', this._elem);\r\n        }\r\n    }\r\n\r\n    ngAfterViewInit(): void {\r\n        this._setElementsCoords();\r\n    }\r\n\r\n    private _setElementsCoords(): void {\r\n        if (!this.mode) return;\r\n\r\n        if (this.mode === 'target') {\r\n            /* Find cart button */\r\n            this._cartPopupService.setTargetCoords(this._elem);\r\n        }\r\n\r\n        if (this.mode === 'popup') {\r\n            /* Based on cart button, calculate popup position */\r\n            this._calculatePopupPosition();\r\n        }\r\n    }\r\n\r\n    private _isMobile(): boolean {\r\n        return window.innerWidth < 768;\r\n    }\r\n\r\n    private _unsetPopupPositionStyles(): void {\r\n        this.top = null;\r\n        this.left = null;\r\n        if (this.mode === 'popup') {\r\n            if (!this._isMobile()) {\r\n                this.opacity = '0';\r\n            }\r\n        }\r\n        return;\r\n    }\r\n\r\n    private _calculatePopupPosition(): void {\r\n        this._offset = this._cartPopupService.offset;\r\n\r\n        setTimeout(() => {\r\n            if (this._isMobile()) {\r\n                return this._unsetPopupPositionStyles();\r\n            }\r\n\r\n            const target: ClientRect = this._cartPopupService.getTargetCoords();\r\n            if (!target) {\r\n                return this._unsetPopupPositionStyles();\r\n            }\r\n\r\n            // const stickToRight: boolean = (target.left + this._elem.clientWidth + this._offset) < window.innerWidth;\r\n            // if (stickToRight) {\r\n            this.left = `${(target.left + target.width + this._offset) - this._elem.clientWidth}`;\r\n            // } else {\r\n            //    this.left = `${target.left - this._offset}`;\r\n            // }\r\n\r\n            this.top = `${target.top + target.height + this._offset}`;\r\n            if (this.mode === 'popup' && !this._isMobile()) {\r\n                setTimeout(() => {\r\n                    this.opacity = '1';\r\n                }, 10);\r\n            }\r\n        }, 0);\r\n\r\n    }\r\n}\r\n","import { NgModule } from '@angular/core';\r\n\r\nimport { TruncatePipe } from './truncate.shared.pipe';\r\n\r\nconst toExport: any[] = [\r\n    TruncatePipe\r\n];\r\n\r\n@NgModule({\r\n    declarations: [\r\n        ...toExport,\r\n    ],\r\n    exports: [\r\n        ...toExport,\r\n    ],\r\n})\r\nexport class TruncatePipeModule { }\r\n","export * from './truncate.pipe.module';\r\n"]}