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WyC,IAAA,CAAAL,EAAAM,KAAAN,EAAXpC,YAAW0C,IAAAL,SAAAC,GAAApC,EAAA6C,G,uGArBsB,GAqItB,SAASC,IACpB,MAAO,CACHC,IAAK,0BACLC,WAAYzE,EACZ0E,SC9ImB,ugBDgJ3B,C,uDE7IO,MAAeC,EAClB,WAAAjG,GACIkG,EAAAlF,EAASqC,OAAO,eAAeC,KAAK,KAChCpD,KAAKiG,qBACLjG,KAAKkG,cACLlG,KAAKmG,gBACLnG,KAAKoG,qBACL,EAAAC,EAAAC,KAAclD,KAAK,KACfpD,KAAKuG,eAGjB,CAEA,iBAAAH,GAA2B,CAC3B,kBAAAH,GAA4B,E,+CCXjB,MAAMO,UAA2CT,EAAAU,EAC5D,SAAAF,GACIG,EAAAC,EAAOC,MAAM,uBAAyBC,IAClCA,EAAIC,kBAAkBnB,EAAAgB,IAE9B,CAEA,WAAAT,GACA,CAEA,aAAAC,GACA,ECfgC,IAAIK,C","sources":["webpack:///../common/ts/apps/delivery/services/ProductionTimeEstimate.ts","webpack:///../common/ts/apps/delivery/components/ProductProductionTime/ProductProductionTime.ts","webpack:///../common/ts/apps/delivery/components/ProductProductionTime/ProductProductionTime.html.ts","webpack:///../common/ts/core/utils/IntegrationExtra.ts","webpack:///../common/integrations/ts/SharedProductComponents.ts","webpack:///./integrations/ts/SharedProductComponents.ts"],"sourcesContent":["import {Http} from '../../../core/services/Http';\nimport {Services} from '../../../core/services/Services';\nimport {SimplePromise} from '../../../core/utils/SimplePromise';\n\nexport interface InitialProductionTime {\n    material_id: number;\n    quantity: number;\n    size: number | null;\n    standard?: number;\n    rush?: number;\n    message?: string;\n}\n\nexport default class ProductionTimeEstimate {\n    constructor(private initial?: InitialProductionTime) {}\n\n    getEstimate(material: number, quantity: number, size: number | null) {\n        const initial = this.initial;\n        this.initial = null;\n        if (initial && initial.material_id === material && initial.quantity === quantity && initial.size === size) {\n            return SimplePromise.resolve({\n                data: {\n                    standard: initial.standard,\n                    rush: initial.rush,\n                    message: initial.message\n                }\n            });\n        }\n        return Services.get<Http>('$http').request({\n            method: 'GET',\n            url: '/delivery/api/get-production-times-basic/',\n            params: {\n                material,\n                quantity,\n                size\n            }\n        });\n    }\n}\n","import VueComponent, {data, method} from '../../../../core/adapters/VueComponent';\nimport {html} from './ProductProductionTime.html';\nimport {Services} from '../../../../core/services/Services';\nimport ProductionTimeEstimate from '../../services/ProductionTimeEstimate';\n\nclass ProductProductionTimeController extends VueComponent {\n    private estimates: ProductionTimeEstimate;\n    private estimateTimeout: ReturnType<typeof setTimeout> | null = null;\n    private estimatePending = false;\n    private estimateQueued = false;\n    private lastEstimateAt = -Infinity;\n    private destroyed = false;\n\n    @data()\n    standard: number;\n\n    @data()\n    rush: number;\n\n    @data()\n    message: string;\n\n    @data()\n    loaded: boolean;\n\n    @data()\n    backordered: boolean;\n\n    // Do not store the product service in the data. There is some odd bug\n    // that bricks the component and prevents it from updating the html.\n    // @data()\n    // product_service;\n\n    constructor(componet) {\n        super(componet);\n\n        let product_service: any;\n        this.once('$destroy', () => {\n            this.destroyed = true;\n            if (this.estimateTimeout !== null) {\n                clearTimeout(this.estimateTimeout);\n            }\n            for (const event of ['change:material', 'change:quantity', 'change:width', 'change:height']) {\n                product_service?.configured?.unbindWithContext(event, this);\n            }\n        }, this);\n\n        Services.waitOn('product-service-loaded').then(() => {\n            if (this.destroyed) {\n                return;\n            }\n            product_service = Services.get('ProductService');\n            this.estimates = new ProductionTimeEstimate(product_service.initial_production_time);\n            product_service.configured.bind('change:material', this.updateTimes.bind(this), this);\n            product_service.configured.bind('change:quantity', this.updateTimes.bind(this), this);\n            product_service.configured.bind('change:width', this.updateTimes.bind(this), this);\n            product_service.configured.bind('change:height', this.updateTimes.bind(this), this);\n\n            this.backordered = product_service.configured.material?.backordered;\n            product_service.configured.bind('change:material', () => {\n                this.backordered = product_service.configured.material?.backordered;\n            }, this);\n            this.requestTimes();\n        });\n    }\n\n    @method()\n    updateTimes() {\n        if (this.destroyed) {\n            return;\n        }\n        this.estimateQueued = true;\n        this.requestTimes();\n    }\n\n    private requestTimes() {\n        if (this.destroyed || this.estimatePending || this.estimateTimeout !== null) {\n            return;\n        }\n        // Keep a fixed deadline so continuous changes cannot postpone the next estimate.\n        const remaining = 500 - (Date.now() - this.lastEstimateAt);\n        if (remaining > 0) {\n            this.estimateTimeout = setTimeout(() => {\n                this.estimateTimeout = null;\n                this.requestTimes();\n            }, remaining);\n            return;\n        }\n        this.estimateQueued = false;\n        let product_service: any = Services.get('ProductService');\n        if (!product_service.configured.material || !product_service.configured.quantity) {\n            return;\n        }\n\n        // Sanity check\n        if (product_service.configured.quantity > 500000) {\n            this.message = 'Please contact customer service for a production time estimate.';\n            return;\n        }\n\n        let size = null;\n        if (product_service.configured.width && product_service.configured.height) {\n            size = product_service.configured.width * product_service.configured.height;\n        }\n\n        const material = product_service.configured.material.id;\n        this.lastEstimateAt = Date.now();\n        this.estimatePending = true;\n        this.estimates.getEstimate(material, product_service.configured.quantity, size).then((response) => {\n            // Show completed samples while editing continues, but never for a different material.\n            if (!this.destroyed && product_service.configured.material?.id === material\n                && product_service.configured.quantity > 0 && product_service.configured.quantity <= 500000) {\n                this.message = response.data.message;\n                this.standard = response.data.standard;\n                this.rush = response.data.rush;\n            }\n            this.finishEstimate();\n        }, () => this.finishEstimate());\n    }\n\n    private finishEstimate() {\n        this.estimatePending = false;\n        if (this.estimateQueued) {\n            this.requestTimes();\n        }\n    }\n\n    @method()\n    hidden() {\n        if (!Services.isRegistered('ProductService')) {\n            return false;\n        }\n\n        let product_service: any = Services.get('ProductService');\n        return !product_service.configured?.material;\n    }\n}\n\nexport default function ProductProductionTime() {\n    return {\n        tag: 'product-production-time',\n        controller: ProductProductionTimeController,\n        template: html\n    }\n}\n","export const html:string = `\n<div class=\"pill pill-rounded pill-lg\" :class=\"{'pill-green': !backordered, 'pill-warning': backordered}\" v-if=\"!hidden()\">\n    <span v-if=\"message\">\n        {{ message }}\n    </span>\n    <span v-if=\"backordered\">\n        Out of stock\n    </span>\n    <span v-if=\"!backordered && !message && rush != standard\">\n        Ships in {{ rush }} to {{ standard }} days\n    </span>\n    <span v-if=\"!backordered && !message && rush == standard\">\n        Ships within {{ standard }} days\n    </span>\n</div>\n`;","import {Services} from '../services/Services';\nimport {yieldThread} from './utils';\n\nexport abstract class IntegrationExtra {\n    constructor() {\n        Services.waitOn('loaded-core').then(() => {\n            this.setupGlobalModules();\n            this.setupModels();\n            this.setupServices();\n            this.configureServices();\n            yieldThread().then(() => {\n                this.setupApps();\n            })\n        })\n    }\n\n    configureServices(): void {};\n    setupGlobalModules(): void {};\n\n    abstract setupModels(): void;\n    abstract setupServices(): void;\n    abstract setupApps(): void;\n}","import VueApp from '../../ts/core/adapters/VueApp';\nimport {IntegrationExtra} from '../../ts/core/utils/IntegrationExtra';\nimport ProductProductionTime from '../../ts/apps/delivery/components/ProductProductionTime/ProductProductionTime';\nimport ProductTabGroup from '../../ts/apps/products_shared/apps/ProductTabGroup';\n\n\nexport default class SharedProductComponentsIntegration extends IntegrationExtra {\n    setupApps(): void {\n        VueApp.mount('#production-time-app', (app) => {\n            app.registerComponent(ProductProductionTime);\n        });\n    }\n\n    setupModels(): void {\n    }\n\n    setupServices(): void {\n    }\n}\n","import SharedProductComponentsIntegration from '../../../common/integrations/ts/SharedProductComponents';\n\nconst shared_products_integration = new SharedProductComponentsIntegration();"],"names":["ProductionTimeEstimate","constructor","initial","this","getEstimate","material","quantity","size","material_id","SimplePromise","yY","resolve","data","standard","rush","message","Services","x","get","request","method","url","params","ProductProductionTimeController","VueComponent","Ay","_classSuper","componet","product_service","super","estimates","__runInitializers","_instanceExtraInitializers","estimateTimeout","estimatePending","estimateQueued","lastEstimateAt","destroyed","_standard_initializers","_standard_extraInitializers","_rush_initializers","_rush_extraInitializers","_message_initializers","loaded","_message_extraInitializers","_loaded_initializers","backordered","_loaded_extraInitializers","_backordered_initializers","once","clearTimeout","event","configured","unbindWithContext","waitOn","then","initial_production_time","bind","updateTimes","requestTimes","remaining","Date","now","setTimeout","width","height","id","response","finishEstimate","hidden","isRegistered","p","EJ","__esDecorate","_a","_updateTimes_decorators","kind","name","static","private","access","has","obj","metadata","_metadata","_hidden_decorators","_standard_decorators","set","value","_rush_decorators","_message_decorators","_loaded_decorators","_backordered_decorators","_backordered_extraInitializers","ProductProductionTime","tag","controller","template","IntegrationExtra","_services_Services__WEBPACK_IMPORTED_MODULE_0__","setupGlobalModules","setupModels","setupServices","configureServices","_utils__WEBPACK_IMPORTED_MODULE_1__","E","setupApps","SharedProductComponentsIntegration","T","VueApp","A","mount","app","registerComponent"],"sourceRoot":""}