{"version":3,"sources":["webpack:///../WCC.UI/App/builders/entityAdapterBuilder.ts","webpack:///../WCC.UI/App/components/attachments/image/image.html?c732","webpack:///../WCC.UI/App/components/attachments/image/image.scss?c1c0","webpack:///../WCC.UI/App/components/attachments/image/image.ts","webpack:///../WCC.UI/App/webpack/runtime/htmlExposer.js","webpack:///../WCC.UI/App/components/attachments/image/image.scss","webpack:///../WCC.UI/App/components/attachments/image/image.html"],"names":["wccEntityAdapterBuilder","constructor","createBindings","adapter","config","_","each","realField","adaptedFieldName","this","bindFields","adaptedField","ko","isWritableObservable","subscribe","getUpdater","addLazyBinding","source","target","updater","subscription","init","undefined","_subscription","dispose","getSubscriptionsCount","observable","value","content","expose","__esModule","default","api","module","i","options","exports","locals","WCCImageVM","configOrImage","data","info","effects","imageRaw","loadedRaw","crossoriginRaw","isCoverModeOrCoverRatioRaw","icon","isLoaded","isFailed","WCCImage","loaded","crossorigin","src","flattenComputed","width","height","constructedImage","link","image","cover","isCoverModeOrCoverRatio","isCoverMode","mapSingle","isNumber","file","pluck","ratio","strictComputed","AttachmentsHelpers","getRatio","isHEIC","toLowerCase","indexOf","isExists","isNotNull","isValid","pureComputed","isPlaceholderShown","isImageShown","isCoverShown","imageExists","fromPromise","ImageHelpers","checkIfImageExists","register","applyBindingsToNode","element","__decorate","injectable","__param","inject","wccModules","componentConfig","componentData","componentInfo","system","SystemHelpers","html","getTemplatesAndResources","forEach","node","document","head","appendChild","___CSS_LOADER_API_IMPORT___","push"],"mappings":"kJAIA,cAqEA,MAAMA,EAA0B,IArE1B,MACFC,eAOAC,eAAkBC,EAAYC,GAC1BC,EAAED,GAAQE,KAAK,CAACC,EAAWC,IACvBC,KAAKC,WAAYP,EAAgBK,GAAmBD,IAQ5DG,WAAcC,EAA6BJ,GAMvC,OALIK,EAAGC,qBAAqBN,IACxBI,EAAaG,UAAUL,KAAKM,WAAWR,IAE3CE,KAAKO,eAAeT,EAAWI,GAExBF,KASHO,eAAkBC,EAAuBC,GAC7C,MA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AEJvC,EAAQ2C,SAASrC,IACTpC,EAAGC,qBAAqB+B,IACxBA,EAAUI,IACf,CAACvC,KAAKuC,WAETpC,EAAG0E,oBAAoB7C,EAAK8C,QAAS,CACjC,QAAW9E,KAAK4C,IAAIsB,YAEpB,IAAO,CACH,aAAa,OA3GRrC,EAAUkD,EAAA,CAD9BC,cAoBQC,EAAA,EAAAC,YAAOC,IAAWC,kBAClBH,EAAA,EAAAC,YAAOC,IAAWE,gBAClBJ,EAAA,EAAAC,YAAOC,IAAWG,gBAClBL,EAAA,EAAAC,YAAOC,IAAWlD,WAtBNJ,gB,yLC9BrB,WAOC,KAPD,aACI,MAAM0D,EAAS,EAAQ,mCAAkBC,cAEzC,OAAO,SAAUC,GACbF,EAAOG,yBAAyBD,GAC3BE,SAAQ,SAAUC,GAAQC,SAASC,KAAKC,YAAYH,QAEhE,+B,sKCLDjE,EADkC,EAAQ,wDAChCqE,EAA4B,IAE9BC,KAAK,CAACzE,EAAOC,EAAI,glBAAilB,KAE1mBD,EAAOG,QAAUA,G,sHCHjBH,EAAOG,QAFI","file":"229.55817b45d50b61fc9232.js","sourcesContent":["import { Observable, Subscribable, Subscription } from 'knockout';\r\n\r\ntype BindingsConfig = { [P in keyof T]?: T[P] extends Subscribable ? Subscribable : never }\r\n\r\nexport class WCCEntityAdapterBuilder {\r\n constructor() { }\r\n\r\n /**\r\n * Creates multiple bindings from config\r\n * shortcut for multiple bindFields calls\r\n * @param config\r\n */\r\n createBindings(adapter: T, config: BindingsConfig) {\r\n _(config).each((realField, adaptedFieldName: any) =>\r\n this.bindFields((adapter as any)[adaptedFieldName], realField as any));\r\n }\r\n\r\n /**\r\n * Binds two fields \r\n * @param adaptedField field from entity we want to get\r\n * @param realField field from entity we write adapter for\r\n */\r\n bindFields(adaptedField: Observable, realField: Observable) {\r\n if (ko.isWritableObservable(realField))\r\n adaptedField.subscribe(this.getUpdater(realField));\r\n\r\n this.addLazyBinding(realField, adaptedField);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Updates target from source only when target is awake\r\n * Allows to subscribe to source notifications only when we really need it\r\n * @param source observable we read from\r\n * @param target observable we write to\r\n */\r\n private addLazyBinding(source: Observable, target: Observable) {\r\n const updater = this.getUpdater(target);\r\n let subscription: Subscription | undefined;\r\n\r\n function init() {\r\n subscription = source.subscribe(updater);\r\n updater(source());\r\n }\r\n\r\n target.subscribe(init, undefined, 'awake');\r\n\r\n target.subscribe(() => {\r\n subscription?.dispose();\r\n subscription = undefined;\r\n }, undefined, 'asleep');\r\n\r\n if (target.getSubscriptionsCount() > 0)\r\n init();\r\n }\r\n\r\n /**\r\n * creates function which will update observable \r\n * and can be used as subscribe callback in compatible observable\r\n * performs update only if new value is different from current one\r\n * @param observable\r\n */\r\n private getUpdater(observable: Observable) {\r\n return (value: T) => {\r\n const currentValue = observable();\r\n\r\n if (currentValue !== value)\r\n observable(value);\r\n }\r\n }\r\n}\r\n\r\nconst wccEntityAdapterBuilder = new WCCEntityAdapterBuilder;\r\n\r\nexport default wccEntityAdapterBuilder;","define([\n \"!!../../../../node_modules/html-loader/dist/cjs.js??ref--26-1!./image.html\", \n \"!../../../webpack/runtime/htmlExposer.js\"], function (content, expose) {\n content = content.__esModule ? content.default : content;\n expose(content);\n return content;\n });","var api = require(\"!../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\");\n var content = require(\"!!../../../../node_modules/css-loader/dist/cjs.js!../../../../node_modules/sass-loader/dist/cjs.js!./image.scss\");\n\n content = content.__esModule ? content.default : content;\n\n if (typeof content === 'string') {\n content = [[module.id, content, '']];\n }\n\nvar options = {};\n\noptions.insert = \"head\";\noptions.singleton = false;\n\nvar update = api(content, options);\n\n\n\nmodule.exports = content.locals || {};","import wccEntityAdapterBuilder from 'builders/entityAdapterBuilder';\r\nimport { wccModules } from 'enums/wccModules';\r\nimport { AttachmentsHelpers } from 'helpers/attachments';\r\nimport { ImageHelpers } from 'helpers/images';\r\nimport { inject, injectable } from 'inversify';\r\nimport { Subscribable, SubscribableOrNullableValue } from 'knockout';\r\nimport { EffectsContainer } from 'mixins/withEffects';\r\nimport WCCImage from 'models/attachments/image';\r\nimport UserFile from 'models/userFile';\r\nimport './image.html';\r\nimport './image.scss';\r\n\r\nexport interface WCCImageVMConfig {\r\n image: SubscribableOrNullableValue\r\n\r\n src: SubscribableOrNullableValue\r\n width: SubscribableOrNullableValue\r\n height: SubscribableOrNullableValue\r\n\r\n loaded: SubscribableOrNullableValue\r\n crossorigin: SubscribableOrNullableValue\r\n cover: SubscribableOrNullableValue\r\n}\r\n\r\nexport interface WCCImageVMData {\r\n loaded: SubscribableOrNullableValue\r\n crossorigin: SubscribableOrNullableValue\r\n}\r\n\n@injectable()\nexport default class WCCImageVM {\n icon = 'fal fa-image';\n\n isLoaded = ko.observable(false);\n isFailed = ko.observable(false);\n\n file: Subscribable\n src: Subscribable\n crossorigin: Subscribable\n\n width: Subscribable\n height: Subscribable\n ratio: Subscribable \n\n isPlaceholderShown: Subscribable\n isImageShown: Subscribable\n isCoverShown: Subscribable\n\n constructor(\r\n @inject(wccModules.componentConfig) configOrImage: WCCImageVMConfig | WCCImage,\r\n @inject(wccModules.componentData) data: WCCImageVMData,\r\n @inject(wccModules.componentInfo) info: ko.components.ComponentInfo,\r\n @inject(wccModules.effects) effects: EffectsContainer\r\n ) {\r\n let imageRaw: SubscribableOrNullableValue\r\n let loadedRaw: SubscribableOrNullableValue\r\n let crossoriginRaw: SubscribableOrNullableValue\r\n let isCoverModeOrCoverRatioRaw: SubscribableOrNullableValue\r\n\r\n if (configOrImage instanceof WCCImage) {\r\n imageRaw = configOrImage;\r\n loadedRaw = data.loaded;\r\n crossoriginRaw = data.crossorigin;\r\n } else {\r\n if (configOrImage.src != undefined) {\r\n const src = ko.flattenComputed(configOrImage.src);\n const width = ko.flattenComputed(configOrImage.width);\n const height = ko.flattenComputed(configOrImage.height);\r\n\r\n const constructedImage = new WCCImage();\n\n wccEntityAdapterBuilder.createBindings(constructedImage, {\n link: src,\n width: width,\n height: height\n });\r\n\r\n imageRaw = constructedImage;\r\n } else {\r\n imageRaw = configOrImage.image;\r\n }\r\n\r\n loadedRaw = configOrImage.loaded;\r\n crossoriginRaw = configOrImage.crossorigin;\r\n isCoverModeOrCoverRatioRaw = configOrImage.cover;\r\n }\r\n\r\n const image = ko.flattenComputed(imageRaw);\r\n\r\n this.crossorigin = ko.flattenComputed(crossoriginRaw);\r\n\r\n const isCoverModeOrCoverRatio = ko.flattenComputed(isCoverModeOrCoverRatioRaw, false);\r\n const isCoverMode = isCoverModeOrCoverRatio.mapSingle(isCoverModeOrCoverRatio => _.isNumber(isCoverModeOrCoverRatio) ? true : isCoverModeOrCoverRatio);\r\n\r\n this.file = image.pluck('lqFile');\n this.src = this.file.pluck('link');\n\n this.width = image.pluck('width', 0);\n this.height = image.pluck('height', 0);\n\n this.ratio = ko.strictComputed((width, height, isCoverModeOrCoverRatio) => {\n return AttachmentsHelpers.getRatio(width, height, isCoverModeOrCoverRatio);\n }, [this.width, this.height, isCoverModeOrCoverRatio]);\n\n const isHEIC = this.src.mapSingle(src => {\n if (src != undefined)\n return src.toLowerCase().indexOf('.heic') !== -1;\n\n return false;\n });\n\n const isExists = this.src.isNotNull();\n const isValid = ko.pureComputed(() => isExists() && !isHEIC());\n\n this.isPlaceholderShown = ko.pureComputed(() => !isValid() || !this.isLoaded() || this.isFailed());\n this.isImageShown = ko.pureComputed(() => isValid() && !isCoverMode());\n this.isCoverShown = ko.pureComputed(() => isValid() && isCoverMode());\n\n const imageExists = ko.fromPromise(src => {\n if (src != undefined)\n return ImageHelpers.checkIfImageExists(src);\n }, [this.src], false);\n\n effects.register(imageExists => {\n this.isLoaded(imageExists);\n this.isFailed(!imageExists);\n }, [imageExists]);\n\n effects.register(isLoaded => {\n if (ko.isWritableObservable(loadedRaw))\r\n loadedRaw(isLoaded);\r\n }, [this.isLoaded]);\n\n ko.applyBindingsToNode(info.element, {\n 'visible': this.src.isNotNull(),\n\n 'css': {\n 'wcc-image': true\n }\n });\n }\r\n}","define(function () {\r\n const system = require('helpers/system').SystemHelpers;\r\n\r\n return function (html) {\r\n system.getTemplatesAndResources(html)\r\n .forEach(function (node) { document.head.appendChild(node) });\r\n }\r\n});","// Imports\nvar ___CSS_LOADER_API_IMPORT___ = require(\"../../../../node_modules/css-loader/dist/runtime/api.js\");\nexports = ___CSS_LOADER_API_IMPORT___(false);\n// Module\nexports.push([module.id, \".wcc-image{display:block;border-radius:4px;overflow:hidden;transform:scale(1);transition:transform ease-in-out 250ms}@media(hover: hover){.wcc-image:hover{transform:scale(0.95)}}.wcc-image--natural .wcc-image__content{width:auto;height:auto}.wcc-image__body{position:relative}.wcc-image__content{display:block;width:100%;height:auto}.wcc-image__cover{position:absolute;top:0;left:0;right:0;bottom:0;background-size:cover;background-repeat:no-repeat;background-position:50%}.wcc-image__icon{position:relative}.wcc-image__icon>.wcc-fluid-icon{position:absolute;top:0;right:0;bottom:0;left:0}\", \"\"]);\n// Exports\nmodule.exports = exports;\n","// Module\nvar code = \"\";\n// Exports\nmodule.exports = code;"],"sourceRoot":""}