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EAAiBC,EAAMF,aAAI,EAAJA,EAAMS,QAC7DuF,IACFD,EAAYC,EAEhB,CAEA,GAAIhG,aAAI,EAAJA,EAAM1B,MAAO,CACf,IAAI2H,EAA+B5F,EAAgBH,EAAMF,aAAI,EAAJA,EAAM1B,OAC3D2H,IACFF,EAAYE,EAEhB,CAEA,KAAKjG,aAAI,EAAJA,EAAM1B,UAAU0B,aAAI,EAAJA,EAAMS,QAAQ,CAEjC,IAAIyF,EAAgCxF,EAAWR,GAC3CgG,IACFH,EAAYG,EAEhB,CAEAH,EAAYA,EAAUhI,SAASyB,KAAKQ,EAAKjC,UAAYyC,EAAeN,EAAMF,EAC5E,CAGFzC,SAAS4I,KAAKC,oBAAoBlG,EAAMP,GACxCpC,SAAS4I,KAAK9G,iBAAiBa,EAAMP,EAAmB,GGlR1D,GArBW0E,EAAgB,GAD5BlD,GACYkD,G,0UCAE,IAAMgC,EAAN,MACb,WAAA/B,GAEA,CAEA,MAAA9C,GAAU,GALS6E,EAAW,GAD/BlF,GACoBkF,E","sources":["webpack://hayppgroup.commerce.web/./ClientApp/shared/scripts/easyfy.core.ts","webpack://hayppgroup.commerce.web/./ClientApp/shared/scripts/easyfy.utils.ts","webpack://hayppgroup.commerce.web/./ClientApp/shared/scripts/easyfy.decorators.ts","webpack://hayppgroup.commerce.web/./ClientApp/web/scripts/modules/socialmedia-share.ts","webpack://hayppgroup.commerce.web/./ClientApp/web/scripts/pages/article.ts"],"sourcesContent":["// exemple\n// element('.about'); //
\n// element('[data-action=\"top-nav\"]'); //
\n//export const element = (query: string) => document.querySelector(query);\nexport const element = (query: string) => document.querySelector(query);\n\nexport const elements = (query: string) => document.querySelectorAll(query);\n\nexport const elementsOf = (element: Element | HTMLElement, query: string) => element.querySelector(query);\n\n// exemple\n// elementContains(document.querySelector('head'), document.querySelector('title')); // true\n// elementContains(document.querySelector('body'), document.querySelector('body')); // false\nexport const elementContains = (parent: Element, child: Element) => parent !== child && parent.contains(child);\n\nexport const on = (action: string | Element, type: string, callback: Function, ref?: object, meta?: object) => {\n docReady(() => {\n type.split(' ').forEach(function (t) {\n (action instanceof Element ? action : element(action)).addEventListener(\n t,\n (e) => {\n try {\n callback.call(e.target, e, ref ?? null, meta ?? null);\n } catch (err) { }\n },\n { once: false, passive: true }\n );\n });\n });\n};\n\nexport const one = (action: string | Element, type: string, callback: Function) => {\n docReady(() => {\n type.split(' ').forEach(function (e) {\n (action instanceof Element ? action : element(action)).addEventListener(e, callback, { once: true });\n });\n });\n};\n\nexport const event = (action: string, type: string, callback: EventListener | EventListenerObject) => {\n docReady(() => {\n element(`[data-event=\"${action}\"]`)?.addEventListener(type, callback, false);\n });\n};\n\nexport const events = (action: string, type: string, callback: EventListener | EventListenerObject) => {\n docReady(() => {\n elements(`[data-event=\"${action}\"]`)?.forEach((item) => {\n item.addEventListener(type, callback, false);\n });\n });\n};\n\nexport const action = (action: string, type: string, callback: EventListener | EventListenerObject) => {\n docReady(() => {\n element(`[data-action=\"${action}\"]`)?.addEventListener(type, callback, false);\n });\n};\n\nexport const actions = (action: string, type: string, callback: EventListener | EventListenerObject | Function) => {\n docReady(() => {\n elements(`[data-action=\"${action}\"]`)?.forEach((el) => el?.addEventListener(type, callback, false));\n });\n};\n\nexport const bind = (action: string, type: string, callback: EventListener | EventListenerObject) => {\n docReady(() => {\n elements(action || '')?.forEach((item) => {\n type.split(' ').forEach(t => {\n item.addEventListener(t, callback, false);\n });\n });\n });\n};\n\nexport const off = (action: string | Element | HTMLElement | Array, type: string, callback: EventListener | EventListenerObject) => {\n if (action instanceof String || action instanceof Element || action instanceof HTMLElement) {\n (action instanceof Element || action instanceof HTMLElement ? action : element(action)).removeEventListener(type, callback, false);\n }\n\n if (action instanceof Array) {\n for (let x of action) {\n let item: any = x;\n (item instanceof Element || item instanceof HTMLElement ? item : element(item)).removeEventListener(type, callback, false);\n }\n }\n};\n\nexport const offAll = (action: string, type: string, callback: EventListener | EventListenerObject) => {\n elements(action).forEach((item) => {\n item.removeEventListener(type, callback, false);\n });\n};\n\nexport interface IEventChain {\n target: string;\n type: string;\n events: Array;\n}\n\nexport interface IEventChainItem {\n action?: string;\n event?: string;\n callback?: Function;\n}\n\nexport const eventChain = (arg: IEventChain) => {\n bind(arg.target, arg.type, (e) => {\n const target: any = e.target;\n let eventTarget = target?.attributes['data-action']?.value ?? target?.attributes['data-event']?.value;\n\n if (!eventTarget) eventTarget = target.parentNode?.attributes['data-action']?.value ?? target.parentNode?.attributes['data-event']?.value;\n\n if (!eventTarget) return;\n\n const item: any = arg.events.find(({ action, event }) => (action ?? event).includes(eventTarget));\n if (item?.callback) item.callback(e);\n });\n};\n\nexport const getBlazorEditMode = () => {\n if (!window.isAdminModeEnabled) {\n return false;\n }\n if (window.isEditModeEnabled !== undefined) {\n // Return value to avoid parsing cookies constantly\n return window.isEditModeEnabled;\n }\n const cookies = document.cookie.split(\";\");\n const editModeCookie = cookies.find(cookie => cookie.trim().startsWith(\"_AdminEditMode\"));\n window.isEditModeEnabled = editModeCookie?.split(\"=\")[1].toLowerCase() === \"true\";\n return window.isEditModeEnabled;\n}\n\n\n// Need to wait for blazor\n\nexport const docReady = (callback?: Function, context?: Object | string | number | boolean) => {\n\n let blazorFinishedLoadingEventRegistered: boolean = true;\n\n // Method to trigger window events\n if (!window.EasyfyMethods) {\n window.EasyfyMethods = {};\n window.EasyfyMethods.triggerWindowEvent = (eventName, eventData) => {\n if (eventName) {\n let event = new CustomEvent(eventName, {\n detail: eventData\n });\n window.dispatchEvent(event);\n }\n }\n }\n\n if (getBlazorEditMode()) {\n blazorFinishedLoadingEventRegistered = false;\n }\n\n // The public function name defaults to window.docReady\n // but you can pass in your own object and own function name and those will be used\n // if you want to put them in a different namespace\n // funcName = funcName || \"docReady\";\n // baseObj = baseObj || window;\n let readyList = [];\n let readyFired = false;\n let readyEventHandlersInstalled = false;\n\n // call this when the document is ready\n // this function protects itself against being called more than once\n const ready = () => {\n const readyBody = () => {\n if (!readyFired) {\n // this must be set to true before we start calling callbacks\n readyFired = true;\n for (var i = 0; i < readyList.length; i++) {\n // if a callback here happens to add new ready handlers,\n // the docReady() function will see that it already fired\n // and will schedule the callback to run right after\n // this event loop finishes so all handlers will still execute\n // in order and no new ones will be added to the readyList\n // while we are processing the list\n readyList[i].fn.call(window, readyList[i].ctx);\n // allow any closures held by these functions to free\n }\n readyList = [];\n }\n }\n if (getBlazorEditMode() && !window.blazorFinishedLoading) {\n if (!blazorFinishedLoadingEventRegistered) {\n blazorFinishedLoadingEventRegistered = true;\n window.addEventListener('blazorFinishedLoading', () => {\n window.blazorFinishedLoading = true;\n readyBody();\n }, false);\n }\n }\n else {\n readyBody();\n }\n\n };\n\n const readyStateChange = () => {\n if (document.readyState === 'complete') {\n ready();\n }\n };\n\n // This is the one public interface\n // docReady(fn, context);\n // the context argument is optional - if present, it will be passed\n // as an argument to the callback\n\n if (typeof callback !== 'function') {\n throw new TypeError('callback for docReady(fn) must be a function');\n }\n // if ready has already fired, then just schedule the callback\n // to fire asynchronously, but right away\n if (readyFired) {\n setTimeout(function () {\n callback(context);\n }, 1);\n return;\n } else {\n // add the function and context to the list\n readyList.push({ fn: callback, ctx: context });\n }\n // if document already ready to go, schedule the ready function to run\n if (document.readyState === 'complete') {\n setTimeout(ready, 1);\n } else if (!readyEventHandlersInstalled) {\n // otherwise if we don't have event handlers installed, install them\n if (document.addEventListener) {\n // first choice is DOMContentLoaded event\n document.addEventListener('DOMContentLoaded', ready, false);\n // backup is window load event\n window.addEventListener('load', ready, false);\n }\n readyEventHandlersInstalled = true;\n }\n};\n\nexport interface IEvent {\n type: string;\n event?: IEventItem;\n events?: Array;\n}\n\nexport interface IEventItem {\n action?: string;\n event?: string;\n callback?: Function;\n}\n\ninterface IGlobalEventItem {\n type: string;\n action?: string;\n event?: string;\n callback?: Array;\n}\n\n// Global event\nexport let globalEventList: Array = [];\n\nexport const globalEvent = (event: IEvent) => {\n event.type.split(' ').forEach((type) => {\n if (event.event) event.events = [...(event.events ?? []), ...[event.event]];\n\n if (event.events) {\n for (let item of event.events) {\n let foundItem;\n\n if (item?.action) {\n let actionFound: IGlobalEventItem = globalFindAction(type, item?.action);\n if (actionFound) {\n foundItem = actionFound;\n }\n }\n\n if (item?.event) {\n let eventFound: IGlobalEventItem = globalFindEvent(type, item?.event);\n if (eventFound) {\n foundItem = eventFound;\n }\n }\n\n if (!item?.event && !item?.action) {\n // check global state.\n let globalFound: IGlobalEventItem = globalFind(type);\n if (globalFound) {\n foundItem = globalFound;\n }\n }\n\n foundItem ? foundItem.callback.push(item.callback) : globalEventAdd(type, item);\n }\n }\n\n document.body.removeEventListener(type, globalEventHandler);\n document.body.addEventListener(type, globalEventHandler);\n });\n};\n\nexport const debounce = (func, wait) => {\n let timeout;\n\n return function executedFunction(...args) {\n const later = () => {\n clearTimeout(timeout);\n func(...args);\n };\n\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n };\n};\n\nconst globalEventHandler = (e) => {\n const target: any = e.target;\n\n // check action\n let eventTarget = globalGetTargetAction(target);\n if (eventTarget) {\n const item: IGlobalEventItem = globalFindAction(e.type, eventTarget);\n if (item?.callback) {\n globalEventInvokeCallback(item?.callback, e);\n }\n return;\n }\n\n // check event\n eventTarget = globalGetTargetEvent(target);\n if (eventTarget) {\n const item: IGlobalEventItem = globalFindEvent(e.type, eventTarget);\n if (item?.callback) {\n globalEventInvokeCallback(item?.callback, e);\n }\n return;\n }\n\n // check event\n const item = globalMatchType(e.type);\n if (item?.callback) {\n globalEventInvokeCallback(item?.callback, e);\n return;\n }\n};\n\nconst globalEventInvokeCallback = (cbs: Array, e: any) => {\n for (let item of cbs) {\n item?.call(null, e);\n }\n};\n\nconst globalEventAdd = (type: string, item: IEventItem): void => {\n globalEventList.push({\n type: type,\n action: item?.action,\n event: item?.event,\n callback: [item?.callback],\n });\n};\n\nconst globalFind = (itemType: string): IGlobalEventItem => {\n return globalEventList.find(({ type, action, event }) => type === itemType && !action && !event);\n};\n\nconst globalFindEvent = (itemType: string, eventType: string): IGlobalEventItem => globalEventList.find(({ type, event }) => type === itemType && (event ?? '') === (eventType ?? ''));\n\nconst globalFindAction = (itemType: string, actionType: string): IGlobalEventItem => globalEventList.find(({ type, action }) => type === itemType && (action ?? '') === (actionType ?? ''));\n\nconst globalMatchType = (itemType: string): IGlobalEventItem => globalEventList.find(({ type, action, event }) => type === itemType && !action && !event);\n\nconst globalGetTargetAction = (target) => globalGetTarget(target, 'data-action');\n\nconst globalGetTargetEvent = (target) => globalGetTarget(target, 'data-event');\n\nconst globalGetTarget = (target, dataTarget: string) => {\n let eventTarget = target?.attributes[dataTarget]?.value;\n if (!eventTarget) eventTarget = target.parentNode?.attributes[dataTarget]?.value;\n return eventTarget;\n};","import { element, elements } from './easyfy.core';\n/*import mobileDetect from 'mobile-detect';*/\n\nexport interface Attribute {\n name: string;\n value: string;\n}\n\n/*export const detector = new mobileDetect(window.navigator.userAgent);*/\n\n// exemple\n// findKey(\n// {\n// barney: { age: 36, active: true },\n// fred: { age: 40, active: false },\n// pebbles: { age: 1, active: true }\n// },\n// o => o['active']\n// ); // 'barney\nexport const findKey = (obj: any, fn: any) => Object.keys(obj).find((key) => fn(obj[key], key, obj));\n\n// exemple\n// findLast([1, 2, 3, 4], n => n % 2 === 1); // 3\nexport const findLast = (arr: Array, fn: any) => arr.filter(fn).pop();\n\n// exemple\n// all([4, 2, 3], x => x > 1); // true\n// all([1, 2, 3]); // true\nexport const all = (arr: Array, fn = Boolean) => arr.every(fn);\n\n// exemple\n// allEqual([1, 2, 3, 4, 5, 6]); // false\n// allEqual([1, 1, 1, 1]); // true\nexport const allEqual = (arr: Array) => arr.every((val) => val === arr[0]);\n\n// exemple\n// arrayToHtmlList('#myListID', 'li' ,['item 1', 'item 2']);\nexport const arrayToHtmlList = (selector: string, elementType: string, arr: Array) => ((el) => ((el = document.querySelector(selector)), (el.innerHTML += arr.map((item) => `<${elementType}>${item}`).join(''))))();\n\n// exemple\n//hasClass(document.querySelector('p.special'), 'special'); // true\nexport const hasClass = (el: HTMLElement, className: string) => el?.classList?.contains(className);\n\n// exemple\n// isBrowserTabFocused(); // true\nexport const isBrowserTabFocused = () => !document.hidden;\n\n// exemple\n// isNil(null); // true\n// isNil(undefined); // true\nexport const isNil = (val: any) => val === undefined || val === null;\n\n// exemple\n// isNull(null); // true\nexport const isNull = (val: any) => val === null;\n\n// exemple\n// isNumber('1'); // false\n// isNumber(1); // true\nfunction isNumber(n: any) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n}\n\n// exemple\n// isObject([1, 2, 3, 4]); // true\n// isObject([]); // true\n// isObject(['Hello!']); // true\n// isObject({ a: 1 }); // true\n// isObject({}); // true\n// isObject(true); // false\nexport const isObject = (obj: any) => obj === Object(obj);\n\n// exemple\n// isObjectLike({}); // true\n// isObjectLike([1, 2, 3]); // true\n// isObjectLike(x => x); // false\n// isObjectLike(null); // false\nexport const isObjectLike = (val: any) => val !== null && typeof val === 'object';\n\n// exemple\n// isPlainObject({ a: 1 }); // true\n// isPlainObject(new Map()); // false\n// export const isPlainObject = (val: any) =>\n// !!val && typeof val === \"object\" && val.export && constructor === Object;\n\n// exemple\n// isString('10'); // true\nexport const isString = (val: any) => typeof val === 'string';\n\n// exemple\n// isUndefined(undefined); // true\nexport const isUndefined = (val: any) => val === undefined;\n\n// exemple\n// parse string into boolean\nexport const parseToBoolean = (val: string) => isString(val) && val?.toLowerCase() === 'true';\n\n// exemple\n// isValidJSON('{\"name\":\"Adam\",\"age\":20}'); // true\n// isValidJSON('{\"name\":\"Adam\",age:\"20\"}'); // false\n// isValidJSON(null); // true\nexport const isValidJSON = (str: string) => {\n try {\n JSON.parse(str);\n return true;\n } catch (e) {\n return false;\n }\n};\n\nexport const replaceHtml = (element: HTMLElement, html: string) => {\n if (element?.outerHTML) {\n element.outerHTML = html;\n }\n else {\n let tmpElement = document.createElement(\"div\");\n tmpElement.innerHTML = html;\n element?.parentNode?.replaceChild(tmpElement, element);\n }\n};\n\n// exemple\n// matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }); // true\n// matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }); // false\nexport const matches = (obj: any, source: any) => Object.keys(source).every((key) => obj.hasOwnProperty(key) && obj[key] === source[key]);\n\n// exemple\n// randomHexColorCode(); // \"#e34155\"\nexport const randomHexColorCode = () => {\n let n = (Math.random() * 0xfffff * 1000000).toString(16);\n return '#' + n.slice(0, 6);\n};\n\n// exemple\n// redirect('https://google.com');\nexport const redirect = (url, asLink = true) => (asLink ? (window.location.href = url) : window.location.replace(url));\n\n// exemple\n// scrollToTop();\nexport const scrollToTop = () => {\n const c = document.documentElement.scrollTop || document.body.scrollTop;\n if (c > 0) {\n window.requestAnimationFrame(scrollToTop);\n window.scrollTo(0, c - c / 8);\n }\n};\n\n// exemple\n// setStyle('p', 'font-size', '20px');\nexport const setStyle = (selector: string, ruleName: string, val: string) => (element(selector).style[ruleName] = val);\n\n// exemple\n// getStyle('p', 'font-size');\nexport const getStyle = (selector: string, ruleName: string) => element(selector).style[ruleName];\n\n// exemple\n// show(...document.querySelectorAll(\"img\")); // Shows all elements on the page\nexport const showAll = (el: Array, displayType?: string) => [...el].forEach((e) => (e.style.display = displayType || 'block'));\n\n// exemple\n// hide(document.querySelectorAll('img')); // Hides all elements on the page\nexport const hideAll = (el: Array | NodeListOf) => el.forEach((e) => (e.style.display = 'none'));\n\nexport const show = (selector: string | Element, displayType?: string) => showAll([selector instanceof Element ? selector : element(selector)], displayType);\n\nexport const hide = (selector: string | Element) => hideAll([selector instanceof Element ? selector : element(selector)]);\n\nexport const toggleShow = (selector: string, displayType?: string) => {\n const el = element(selector);\n visible(el) ? hideAll([el]) : showAll([el], displayType);\n};\n\nexport const removeCss = (el: HTMLElement | Element | Array | NodeListOf, className: string | Array) => {\n if (Array.isArray(el) || el instanceof NodeList) {\n el.forEach((element) => {\n Array.isArray(className) ? element?.classList?.remove(...className) : element?.classList?.remove(className);\n });\n } else {\n Array.isArray(className) ? (el as HTMLElement | Element)?.classList?.remove(...className) : (el as HTMLElement | Element)?.classList?.remove(className);\n return el;\n }\n};\n\nexport const addCss = (el: HTMLElement | Element, className: string | Array) => {\n if (Array.isArray(className)) {\n el?.classList?.add(...className);\n return el;\n }\n\n el?.classList?.add(className);\n return el;\n};\n\n// exemple\n// async function sleepyWork() {\n// console.log(\"I'm going to sleep for 1 second.\");\n// await sleep(1000);\n// console.log('I woke up after 1 second.');\n// }\nexport const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport const visible = (element: HTMLElement): boolean => {\n return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);\n};\n\n// exemple\n// smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar\n// smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class of fooBar\nexport const smoothScroll = (element: any) =>\n document.querySelector(element).scrollIntoView({\n behavior: 'smooth',\n });\n\n// exemple\n// splitLines('This\\nis a\\nmultiline\\nstring.\\n'); // ['This', 'is a', 'multiline', 'string.' , '']\nexport const splitLines = (str: string) => str.split(/\\r?\\n/);\n\n// exemple\n// stripHTMLTags('

lorem ipsum

'); // 'lorem ipsum'\nexport const stripHTMLTags = (str: string) => str.replace(/<[^>]*>/g, '');\n\n// exemple\n// sum(1, 2, 3, 4); // 10\n// sum(...[1, 2, 3, 4]); // 10\nexport const sum = (...arr: any) => [...arr].reduce((acc, val) => acc + val, 0);\n\n// exemple\n// timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms\nexport const timeTaken = (callback: any) => {\n console.time(\"timeTaken\");\n const r = callback();\n console.timeEnd(\"timeTaken\");\n return r;\n};\n\n// exemple\n// toCurrency(123456.789, \"EUR\"); // €123,456.79 | currency: Euro | currencyLangFormat: Local\n// toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)\n// toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi\n// toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local\n// toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish\nexport const toCurrency = (n: any, curr: any, languageFormat = undefined) =>\n Intl.NumberFormat(languageFormat, {\n style: 'currency',\n currency: curr,\n }).format(n);\n\n// exemple\n// toDecimalMark(12305030388.9087); // \"12,305,030,388.909\"\n// toDecimalMark(12305030388.9087, \"en-us\"); // \"12,305,030,388.909\"\nexport const toDecimalMark = (num: any, languageFormat = undefined) => num.toLocaleString(languageFormat);\n\n// exemple\n// toggleClass('p.special', 'special'); // The paragraph will not have the 'special' class anymore\nexport const toggleClass = (selector: string | HTMLElement, className: any, force?: boolean) => {\n //if (selector instanceof String) easyfyCore.element(selector as string).classList.toggle(className);\n\n if (selector instanceof HTMLElement) selector.classList.toggle(className, force);\n};\n\nexport const debounce = any>(func: F, waitFor: number) => {\n let timeout;\n\n return (...args: Parameters): Promise> =>\n new Promise((resolve) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(() => resolve(func(...args)), waitFor);\n });\n};\n\nexport const isFunction = (f: Function) => {\n return f && {}.toString.call(f) === '[object Function]';\n};\n\nexport const Id = (len: number) => {\n return '_' + Math.random().toString(36).substr(2, len);\n};\n\nexport const toggleClassBySelector = (selector: string, className: string, toggle: boolean) => {\n let els = elements(selector);\n els.forEach((item) => {\n if (toggle) {\n addCss(item, className);\n } else {\n removeCss(item, className);\n }\n });\n};\n\nexport const setAttributes = (element: HTMLElement, attributes: Array): HTMLElement | Element => {\n attributes.forEach((item) => {\n if (item?.name && item?.value) {\n element.setAttribute(item.name, item.value);\n }\n });\n return element;\n};\n\nexport const offset = (element: HTMLElement): { top: number; left: number } => {\n const rect = element.getBoundingClientRect(),\n scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,\n scrollTop = window.pageYOffset || document.documentElement.scrollTop;\n return { top: rect.top + scrollTop, left: rect.left + scrollLeft };\n};\n\nexport const winHeight = () => window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\nexport const winWidth = () => window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\nexport const isMobile = () => window.innerWidth <= 768 ? true : false;\n\nexport const isBetweenDates = (startDate: Date, endDate: Date, checkDate: Date) => {\n if (checkDate > startDate && checkDate < endDate) {\n return true;\n }\n return false;\n};\n\n//todo: support other short date string formats other then 2020-01-01\nexport const getDate = (date: string) => {\n if (date !== \"\") {\n var d = date.split(\"-\");\n if (d.length == 3) {\n return new Date(parseInt(d[0]), parseInt(d[1]) - 1, parseInt(d[2]));\n }\n }\n return new Date();\n};\nexport const getSelectedValue = (select: HTMLSelectElement) => {\n if (select) {\n const selectedOption = select.options[select.selectedIndex];\n return { text: selectedOption.text, value: selectedOption.value };\n }\n return;\n};\n\nexport const removeHash = () => {\n var scrollV, scrollH, loc = window.location;\n if (\"pushState\" in history) {\n history.pushState(\"\", document.title, loc.pathname + loc.search);\n } else {\n // Prevent scrolling by storing the page's current scroll offset\n scrollV = document.body.scrollTop;\n scrollH = document.body.scrollLeft;\n\n loc.hash = \"\";\n\n // Restore the scroll offset, should be flicker free\n document.body.scrollTop = scrollV;\n document.body.scrollLeft = scrollH;\n }\n};","import { docReady, event as eventHandler, events as eventsHandler, action as actionHandler, actions as actionsHandler, bind as bindHandler } from './easyfy.core';\nimport { Id } from './easyfy.utils';\n\nexport interface Idependencies {\n func: { new(...args: any[]): {} };\n data?: any;\n}\n\ninterface IActionEvent {\n target: string;\n type: string;\n meta?: object;\n}\n\ninterface IInjectorDependencies {\n name: string;\n func: object;\n}\n\ninterface IInjector {\n dependencies: {\n [key: string]: IInjectorDependencies;\n };\n resolveOnload: Array;\n resolve: (depends: Array, ctor: any, cb: Function) => void;\n}\n\nexport const invoke = function (ctor: T): void {\n let newClass: Object;\n\n const readyAfter = () => {\n // call class function onInit\n try {\n ctor?.prototype?.onInit?.apply(newClass);\n } catch (error) {\n console.log('Invoke onInit error', error);\n }\n };\n\n const init = (resolves?: Array) => {\n try {\n newClass = new ctor(...(resolves || []));\n } catch (err) {\n console.log('Error ', err);\n }\n\n if (ctor.prototype.hasOwnProperty('onInit')) {\n // Use the handy event callback\n docReady(readyAfter);\n }\n };\n\n const depends = ctor['depends'];\n depends\n ? injector.resolve(ctor['depends'], ctor, (resolves) => {\n delete ctor['depends'];\n init(resolves);\n })\n : init();\n};\n\n\nconst injector: IInjector = {\n dependencies: {},\n resolveOnload: [],\n resolve: function (depends: Array, ctor: any, cb?: Function): void {\n depends.forEach((item) => {\n const id = Id(10);\n injector.dependencies[id] = { name: id, func: new item.func(item.data || {}) };\n if (injector.dependencies[id].func.hasOwnProperty('loaded')) {\n injector.resolveOnload.push(id);\n }\n });\n\n if (injector.resolveOnload.length > 0) {\n injector.resolveOnload.forEach((item, index) => {\n if (injector.dependencies[item].func.hasOwnProperty('loaded')) {\n const dependencyItem = injector.dependencies[item].func;\n\n let loadedVal = dependencyItem['loaded'];\n Object.defineProperty(dependencyItem, 'loaded', {\n get: () => {\n return loadedVal;\n },\n set: function (val) {\n if (val !== loadedVal) {\n if (val) {\n if (dependencyItem) {\n injector.resolveOnload.splice(index, 1);\n delete dependencyItem['loaded'];\n\n if (injector.resolveOnload.length === 0 && cb) {\n let dependencyFunc: Array = [];\n for (const key in injector.dependencies) {\n if (injector.dependencies.hasOwnProperty(key)) {\n const item = injector.dependencies[key];\n dependencyFunc.push(item.func);\n }\n }\n cb.call(this, dependencyFunc);\n }\n }\n }\n }\n\n loadedVal = val;\n },\n enumerable: true,\n configurable: true,\n });\n }\n });\n } else {\n cb?.call(this);\n }\n },\n};\n\ntype InferValue = Desc extends { get(): any; value: any } ? never : Desc extends { value: infer T } ? Record : Desc extends { get(): infer T } ? Record : never;\n\ntype DefineProperty = Desc extends { writable: any; set(val: any): any }\n ? never\n : Desc extends { writable: any; get(): any }\n ? never\n : Desc extends { writable: false }\n ? Readonly>\n : Desc extends { writable: true }\n ? InferValue\n : Readonly>;\n\nfunction defineProperty(obj: Obj, prop: Key, val: PDesc): asserts obj is Obj & DefineProperty {\n Object.defineProperty(obj, prop, val);\n}\n\ndefineProperty(Object.prototype, 'watch', {\n enumerable: false,\n configurable: true,\n writable: false,\n value(this: any, prop, handler) {\n let oldval: any = this[prop],\n newval: any = oldval,\n getter = function () {\n return newval;\n },\n setter = function (this: any, val) {\n oldval = newval;\n return (newval = handler.call(this, prop, oldval, val));\n };\n\n if (delete this[prop]) {\n // can't watch constants\n Object.defineProperty(this, prop, {\n get: getter,\n set: setter,\n enumerable: true,\n configurable: true,\n });\n }\n },\n});\n\nexport const event = (event: IActionEvent) => {\n return (_target: any, _key: string, descriptor: PropertyDescriptor) => {\n eventHandler(event.target, event.type, actionEventHelper(descriptor, event.meta).value);\n };\n};\n\nexport const events = (event: IActionEvent) => {\n return (_target: any, _key: string, descriptor: PropertyDescriptor) => {\n eventsHandler(event.target, event.type, actionEventHelper(descriptor, event.meta).value);\n };\n};\n\nexport const action = (event: IActionEvent) => {\n return (_target: any, _key: string, descriptor: PropertyDescriptor) => {\n actionHandler(event.target, event.type, actionEventHelper(descriptor, event.meta).value);\n };\n};\n\nexport const actions = (event: IActionEvent) => {\n return (_target: any, _key: string, descriptor: PropertyDescriptor) => {\n actionsHandler(event.target, event.type, actionEventHelper(descriptor, event.meta).value);\n };\n};\n\nexport const bind = (event: IActionEvent) => {\n return (_target: any, _key: string, descriptor: PropertyDescriptor) => {\n bindHandler(event.target, event.type, actionEventHelper(descriptor, event.meta).value);\n };\n};\n\nconst actionEventHelper = (descriptor: PropertyDescriptor, meta?: object) => {\n const decorated: Function = descriptor.value;\n descriptor.value = function (event: Event) {\n if (event?.preventDefault) event?.preventDefault();\n\n return decorated.apply(this, [...Array.from(arguments), meta]);\n };\n return descriptor;\n};","import { invoke } from '@shared/easyfy.decorators';\nimport { globalEvent } from '@shared/easyfy.core';\n\n@invoke\nexport class SocialMediaShare {\n constructor() {}\n\n onInit() {\n globalEvent({\n type: 'click',\n events: [\n {\n action: 'copy-link',\n callback: this.copyLinkToClipboard,\n },\n {\n action: 'share-to',\n callback: this.shareLink,\n },\n {\n event: 'close-dialog',\n callback: this.closeDialog,\n },\n ],\n });\n }\n private shareLink = (e) => {\n const element = e?.target as HTMLElement;\n const media = element?.dataset?.media;\n\n const currentUrl = window.location.href;\n let mediaLink = '';\n switch (media) {\n case 'facebook':\n mediaLink = `https://www.facebook.com/sharer/sharer.php?u=${currentUrl}`;\n break;\n case 'linkedin':\n mediaLink = `https://www.linkedin.com/shareArticle?mini=true&url=${currentUrl}&source=LinkedIn`;\n break;\n case 'x':\n mediaLink = `https://twitter.com/intent/tweet?url=${currentUrl}`;\n break;\n default:\n break;\n }\n if (mediaLink) {\n window.open(mediaLink, '_blank');\n }\n };\n\n private copyLinkToClipboard = () => {\n const currentUrl = window.location.href;\n this.copyContent(currentUrl);\n };\n\n private copyContent = async (text) => {\n try {\n await navigator.clipboard.writeText(text);\n const dialog = document.getElementById('copied-to-clipboard-dialog') as HTMLDialogElement;\n\n dialog?.show();\n\n setTimeout(() => {\n dialog?.close();\n }, 2900);\n } catch (err) {\n console.error('Failed to copy: ', err);\n }\n };\n\n private closeDialog = (e) => {\n const element = e.target as HTMLElement;\n const dialog = element.closest('#copied-to-clipboard-dialog') as HTMLDialogElement;\n dialog?.removeAttribute('open');\n };\n}\n","import { invoke } from '@shared/easyfy.decorators';\nimport { SocialMediaShare } from '@clientWebModules/socialmedia-share';\n\n@invoke\nexport default class ArticleList {\n constructor() {\n SocialMediaShare;\n }\n\n onInit() {}\n}\n"],"names":["getBlazorEditMode","window","isAdminModeEnabled","undefined","isEditModeEnabled","editModeCookie","document","cookie","split","find","trim","startsWith","toLowerCase","docReady","callback","context","blazorFinishedLoadingEventRegistered","EasyfyMethods","triggerWindowEvent","eventName","eventData","event","CustomEvent","detail","dispatchEvent","readyList","readyFired","readyEventHandlersInstalled","ready","readyBody","i","length","fn","call","ctx","blazorFinishedLoading","addEventListener","TypeError","setTimeout","push","readyState","globalEventList","globalEventHandler","e","target","eventTarget","globalGetTargetAction","item","globalFindAction","type","globalEventInvokeCallback","globalGetTargetEvent","globalFindEvent","globalMatchType","cbs","globalEventAdd","action","globalFind","itemType","eventType","actionType","globalGetTarget","dataTarget","attributes","value","parentNode","invoke","ctor","newClass","readyAfter","prototype","onInit","apply","error","init","resolves","err","hasOwnProperty","injector","resolve","dependencies","resolveOnload","depends","cb","forEach","id","len","Math","random","toString","substr","name","func","data","index","dependencyItem","loadedVal","Object","defineProperty","get","set","val","splice","dependencyFunc","key","this","enumerable","configurable","obj","prop","writable","handler","oldval","newval","getter","setter","SocialMediaShare","constructor","shareLink","element","media","dataset","currentUrl","location","href","mediaLink","open","copyLinkToClipboard","copyContent","text","navigator","clipboard","writeText","dialog","getElementById","show","close","console","closeDialog","closest","removeAttribute","events","foundItem","actionFound","eventFound","globalFound","body","removeEventListener","ArticleList"],"sourceRoot":""}