@fynd-design-engineering/fynd-one-v2 3.3.35 → 3.3.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../bin/live-reload.js", "../../src/accordians/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "import { isElementAccessExpression } from \"typescript\";\n\n// Type definitions\ninterface GSAPElement extends HTMLElement {\n gsapAnimation?: { kill(): void };\n}\n\ndocument.addEventListener(\"DOMContentLoaded\", (): void => {\n const faqWrappers: NodeListOf<HTMLElement> = document.querySelectorAll('[fynd-faq-element=\"wrapper\"]');\n\n faqWrappers.forEach((wrapper: HTMLElement): void => {\n const toggle: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"toggle\"]');\n const content: GSAPElement | null = wrapper.querySelector('[fynd-faq-element=\"content\"]');\n const contentInner: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"content-inner\"]');\n const xLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn('Required FAQ elements not found in wrapper');\n return;\n }\n\n const groupContainer: HTMLElement | null = wrapper.closest(\"[fynd-faq-group]\");\n const groupName: string | null = groupContainer?.getAttribute(\"fynd-faq-group\") || null;\n\n // Get the FAQ type - either \"one-at-a-time\" or \"multiple-at-a-time\"\n const faqType: string = groupContainer?.getAttribute(\"fynd-faq-type\") || \"one-at-a-time\";\n\n if (wrapper.getAttribute(\"fynd-faq-initialopen\") === \"true\") {\n gsap.set(content, { height: \"auto\", overflow: \"hidden\" });\n gsap.set(contentInner, { opacity: 1 });\n gsap.set(xLine, { rotation: 180 });\n gsap.set(yLine, { rotation: 270 });\n toggle.setAttribute(\"data-state\", \"open\");\n\n // openening the accordion\n // console.log(\"this accordion is open\", wrapper);\n // if (window.innerWidth < 992) {\n // setTimeout(() => {\n // scrollToAccordion(wrapper);\n // }, 200);\n // }\n\n updateFaqGroupImage(wrapper, groupName); // image\n updateFaqGroupText(wrapper, groupName); // text\n updateFaqGroupButton(wrapper, groupName); // button\n updateFaqGroupVideo(wrapper, groupName); // \u2705 video (sets loop+autoplay and tries to play)\n } else {\n gsap.set(content, { height: 0 });\n gsap.set(contentInner, { opacity: 0 });\n gsap.set(xLine, { rotation: 0 });\n gsap.set(yLine, { rotation: 0 });\n toggle.setAttribute(\"data-state\", \"closed\");\n }\n\n let isAnimating: boolean = false;\n toggle.addEventListener(\"click\", (): void => {\n if (isAnimating) return;\n isAnimating = true;\n const isOpen: boolean = toggle.getAttribute(\"data-state\") === \"open\";\n\n // For \"one-at-a-time\" type, check if this is the last open FAQ\n if (faqType === \"one-at-a-time\" && groupContainer) {\n const openFAQs: NodeListOf<HTMLElement> = groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n\n if (isOpen && openFAQs.length === 1) {\n // Don't allow closing the last open FAQ in \"one-at-a-time\" mode\n isAnimating = false;\n return;\n }\n }\n\n if (isOpen) {\n closeAccordion(wrapper, (): void => {\n isAnimating = false;\n });\n } else {\n if (faqType === \"one-at-a-time\" && groupContainer) {\n closeOtherAccordions(groupContainer);\n }\n openAccordion(wrapper, groupName, (): void => {\n isAnimating = false;\n });\n }\n });\n });\n\n // Initialize ratio heights on page load\n handleRatioHeights();\n\n // \u2705 Set up viewport-based autoplay/pause for all video targets\n initFaqVideoAutoplayObserver();\n\n setTimeout(playAllFaqVideos, 500);\n});\n\n// Handle window resize\nwindow.addEventListener(\"resize\", (): void => {\n handleRatioHeights();\n});\n\n// Function to handle ratio heights for FAQ image targets and tabgroups\nfunction handleRatioHeights(): void {\n // Run only if viewport width is >= 992px\n if (window.innerWidth < 992) return;\n\n // Find all FAQ image targets\n const imageTargets: NodeListOf<HTMLElement> = document.querySelectorAll('[fynd-faq-image-target]');\n \n imageTargets.forEach((imageTarget: HTMLElement): void => {\n const wrapper: HTMLElement | null = imageTarget.parentElement;\n if (!wrapper) return;\n const ratioHeight: string | null = wrapper.getAttribute(\"ratio-height\");\n if (ratioHeight !== \"true\") return;\n wrapper.style.height = \"auto\";\n requestAnimationFrame((): void => {\n const renderedHeight: number = wrapper.offsetHeight;\n wrapper.style.height = `${renderedHeight}px`;\n });\n });\n\n // Handle tab groups\n const tabGroups: NodeListOf<HTMLElement> = document.querySelectorAll('[fynd-faq-tabgroup][ratio-height=\"true\"]');\n tabGroups.forEach((tabGroup: HTMLElement): void => {\n tabGroup.style.height = \"auto\";\n requestAnimationFrame((): void => {\n const renderedHeight: number = tabGroup.offsetHeight;\n tabGroup.style.height = `${renderedHeight}px`;\n });\n });\n}\n\nfunction openAccordion(wrapper: HTMLElement, groupName: string | null, callback?: () => void): void {\n const toggle: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"toggle\"]');\n const content: GSAPElement | null = wrapper.querySelector('[fynd-faq-element=\"content\"]');\n const contentInner: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"content-inner\"]');\n const xLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn('Required elements not found for opening accordion');\n return;\n }\n\n if (content.gsapAnimation) {\n content.gsapAnimation.kill();\n }\n\n const timeline = gsap.timeline({ onComplete: (): void => callback && callback() });\n\n gsap.set(content, { height: \"auto\", visibility: \"hidden\", opacity: 0 });\n const height: number = content.offsetHeight;\n gsap.set(content, { height: 0, visibility: \"visible\", opacity: 1 });\n\n timeline.to(xLine, { rotation: 180, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(yLine, { rotation: 270, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(\n content,\n {\n height,\n duration: 0.5,\n ease: \"power3.inOut\",\n clearProps: \"height\",\n onComplete: (): void => {\n (content as HTMLElement).style.height = \"auto\";\n },\n },\n 0\n );\n timeline.to(contentInner, { opacity: 1, duration: 0.4, ease: \"power2.out\" }, \"-=0.35\");\n\n content.gsapAnimation = timeline;\n toggle.setAttribute(\"data-state\", \"open\");\n // scroll to the accordion on tablet and below\n // console.log(\"this accordion is open\", wrapper);\n if (window.innerWidth < 992) {\n setTimeout(() => {\n scrollToAccordion(wrapper);\n }, 600);\n }\n\n const icon: HTMLElement | null = toggle.querySelector('[fynd-faq-element=\"chevron\"]');\n if (icon) gsap.to(icon, { rotation: 180, duration: 0.4, ease: \"back.out(1.7)\" });\n\n // Update group-level UIs\n updateFaqGroupImage(wrapper, groupName);\n updateFaqGroupText(wrapper, groupName);\n updateFaqGroupButton(wrapper, groupName);\n updateFaqGroupVideo(wrapper, groupName); // \u2705 ensures autoplay on change\n}\n\nfunction closeAccordion(wrapper: HTMLElement, callback?: () => void): void {\n const toggle: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"toggle\"]');\n const content: GSAPElement | null = wrapper.querySelector('[fynd-faq-element=\"content\"]');\n const contentInner: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"content-inner\"]');\n const xLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null = toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn('Required elements not found for closing accordion');\n return;\n }\n\n if (content.gsapAnimation) content.gsapAnimation.kill();\n\n const height: number = content.offsetHeight;\n (content as HTMLElement).style.height = `${height}px`;\n\n const timeline = gsap.timeline({ onComplete: (): void => callback && callback() });\n\n timeline.to(xLine, { rotation: 0, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(yLine, { rotation: 0, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(contentInner, { opacity: 0, duration: 0.3, ease: \"power2.in\" }, 0);\n timeline.to(content, { height: 0, duration: 0.4, ease: \"power3.inOut\" }, \"-=0.25\");\n\n content.gsapAnimation = timeline;\n toggle.setAttribute(\"data-state\", \"closed\");\n\n const icon: HTMLElement | null = toggle.querySelector('[fynd-faq-element=\"chevron\"]');\n if (icon) gsap.to(icon, { rotation: 0, duration: 0.4, ease: \"back.out(1.7)\" });\n}\n\n// Function to close all other accordions in the same group\nfunction closeOtherAccordions(groupContainer: HTMLElement): void {\n const openFAQs: NodeListOf<HTMLElement> = groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n openFAQs.forEach((openToggle: HTMLElement): void => {\n const wrapper: HTMLElement | null = openToggle.closest('[fynd-faq-element=\"wrapper\"]');\n if (wrapper) closeAccordion(wrapper);\n });\n}\n\n// Function to update the group image\nfunction updateFaqGroupImage(wrapper: HTMLElement, groupName: string | null): void {\n if (!groupName) return;\n const groupImage: HTMLImageElement | null = document.querySelector(\n `[fynd-faq-image-target=\"${groupName}\"]`\n );\n if (!groupImage) return;\n\n const imageSource: HTMLImageElement | null = wrapper.querySelector(\"[fynd-faq-image-source]\");\n if (!imageSource) return;\n\n const newSrc: string | null = imageSource.getAttribute(\"src\");\n const newSrcset: string | null = imageSource.getAttribute(\"srcset\");\n\n if (newSrc) groupImage.setAttribute(\"src\", newSrc);\n if (newSrcset) groupImage.setAttribute(\"srcset\", \"\");\n // removing srcset for now\n}\n\n// Function to update the group text\nfunction updateFaqGroupText(wrapper: HTMLElement, groupName: string | null): void {\n if (!groupName) return;\n const groupText: HTMLElement | null = document.querySelector(\n `[fynd-faq-text-target=\"${groupName}\"]`\n );\n if (!groupText) return;\n\n const textSource: HTMLElement | null = wrapper.querySelector(\"[fynd-faq-text-source]\");\n if (!textSource) return;\n\n groupText.textContent = textSource.textContent;\n}\n\n// Function to update the group button\nfunction updateFaqGroupButton(wrapper: HTMLElement, groupName: string | null): void {\n if (!groupName) return;\n\n const buttonTextTarget: HTMLElement | null = document.querySelector(\n `[fynd-faq-button-text-target=\"${groupName}\"]`\n );\n const buttonLinkTarget: HTMLElement | null = document.querySelector(\n `[fynd-faq-button-link-target=\"${groupName}\"]`\n );\n\n const linkSource: HTMLAnchorElement | null = wrapper.querySelector(\"[fynd-faq-link-source]\");\n if (!linkSource) return;\n\n if (buttonTextTarget) buttonTextTarget.textContent = linkSource.textContent;\n\n if (buttonLinkTarget) {\n for (let i = 0; i < linkSource.attributes.length; i++) {\n const attr = linkSource.attributes[i];\n buttonLinkTarget.setAttribute(attr.name, attr.value);\n }\n }\n}\n\n// \u2705 Always-loop + autoplay video updater\nfunction updateFaqGroupVideo(wrapper: HTMLElement, groupName: string | null): void {\n if (!groupName) return;\n\n const groupVideo: HTMLVideoElement | null = document.querySelector(\n `[fynd-faq-video-target=\"${groupName}\"]`\n );\n if (!groupVideo) return;\n const groupVideoWrapper: HTMLElement | null = wrapper.querySelector(`[fynd-faq-video]`);\n if (!groupVideoWrapper) return;\n const groupImageWrapper: HTMLElement | null = wrapper.querySelector(`[fynd-faq-image]`);\n if (!groupImageWrapper) return;\n \n\n const sourceVideo: HTMLVideoElement | null = wrapper.querySelector(\"[fynd-faq-video-source]\");\n if (!sourceVideo) {\n groupVideo.style.display = \"none\";\n if(window.innerWidth < 992){\n groupVideoWrapper.style.display = \"none\";\n groupImageWrapper.style.display = \"block\";\n }\n return;\n }\n else{\n // groupVideo.style.display = \"block\";\n if(window.innerWidth < 992){\n groupVideoWrapper.style.display = \"block\";\n groupImageWrapper.style.display = \"none\";\n sourceVideo.setAttribute(\"loop\", \"\");\n sourceVideo.setAttribute(\"autoplay\", \"\");\n sourceVideo.setAttribute(\"muted\", \"\"); \n sourceVideo.setAttribute(\"playsinline\", \"\");\n autoplayVideo(sourceVideo);\n }\n }\n\n const sourceEl: HTMLSourceElement | null = sourceVideo.querySelector(\"source\");\n const newSrc: string | null = sourceEl?.getAttribute(\"src\") || null;\n const newType: string | null = sourceEl?.getAttribute(\"type\") || null;\n\n if (newSrc && newSrc.trim() !== \"\") {\n let targetSourceEl: HTMLSourceElement | null = groupVideo.querySelector(\"source\");\n if (!targetSourceEl) {\n targetSourceEl = document.createElement(\"source\");\n groupVideo.appendChild(targetSourceEl);\n }\n\n targetSourceEl.setAttribute(\"src\", newSrc);\n targetSourceEl.setAttribute(\"type\", newType || \"video/mp4\");\n\n // \u2705 Force desired playback behavior\n groupVideo.setAttribute(\"loop\", \"\");\n groupVideo.setAttribute(\"autoplay\", \"\");\n groupVideo.setAttribute(\"muted\", \"\"); // required for autoplay on most browsers\n groupVideo.setAttribute(\"playsinline\", \"\"); // iOS inline autoplay\n\n if(window.innerWidth < 992){\n sourceVideo.setAttribute(\"loop\", \"\");\n sourceVideo.setAttribute(\"autoplay\", \"\");\n sourceVideo.setAttribute(\"muted\", \"\"); \n sourceVideo.setAttribute(\"playsinline\", \"\");\n sourceVideo.play();\n }\n\n // Apply new source\n try { groupVideo.load(); } catch (e) { /* no-op */ }\n\n // Try to autoplay immediately\n autoplayVideo(groupVideo);\n\n groupVideo.style.display = \"block\";\n } else {\n groupVideo.style.display = \"none\";\n const targetSourceEl: HTMLSourceElement | null = groupVideo.querySelector(\"source\");\n if (targetSourceEl) {\n targetSourceEl.removeAttribute(\"src\");\n targetSourceEl.removeAttribute(\"type\");\n try { groupVideo.load(); } catch (e) { /* no-op */ }\n }\n }\n}\n\n// \uD83D\uDD38 Robust autoplay helper (handles Promise and race conditions)\nfunction autoplayVideo(video: HTMLVideoElement): void {\n // If not in DOM or hidden, defer to IntersectionObserver\n if (!video.isConnected || video.style.display === \"none\") return;\n\n // Some browsers need a tiny delay after .load()\n requestAnimationFrame(() => {\n const playPromise = video.play();\n if (playPromise && typeof (playPromise as Promise<void>).catch === \"function\") {\n (playPromise as Promise<void>).catch(() => {\n // If autoplay fails (rare with muted+playsinline), we silently ignore.\n });\n }\n });\n}\n\n// \uD83D\uDD38 Observe visibility to autoplay on entering viewport (and pause when out)\nfunction initFaqVideoAutoplayObserver(): void {\n const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll('[fynd-faq-video-target]');\n if (!videos.length) return;\n\n const io = new IntersectionObserver((entries) => {\n entries.forEach((entry) => {\n const video = entry.target as HTMLVideoElement;\n // Only act if video has a valid source set\n const hasSrc = !!video.querySelector('source[src]');\n if (!hasSrc || video.style.display === \"none\") return;\n\n if (entry.isIntersecting && entry.intersectionRatio >= 0.5) {\n // Ensure autoplay attributes are present (defensive)\n video.setAttribute(\"autoplay\", \"\");\n video.setAttribute(\"muted\", \"\");\n video.setAttribute(\"playsinline\", \"\");\n video.setAttribute(\"loop\", \"\");\n autoplayVideo(video);\n } else {\n // Pause when scrolled out to save resources\n try { video.pause(); } catch (e) { /* no-op */ }\n }\n });\n }, { threshold: [0, 0.5, 1] });\n\n videos.forEach((v) => io.observe(v));\n}\n\n// Function to ensure at least one FAQ is open in \"one-at-a-time\" mode\nfunction ensureOneFaqOpen(groupContainer: HTMLElement | null): void {\n if (!groupContainer) return;\n\n const faqType: string = groupContainer.getAttribute(\"fynd-faq-type\") || \"one-at-a-time\";\n if (faqType !== \"one-at-a-time\") return;\n\n const openFAQs: NodeListOf<HTMLElement> = groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n\n if (openFAQs.length === 0) {\n const firstFaq: HTMLElement | null = groupContainer.querySelector('[fynd-faq-element=\"wrapper\"]');\n if (firstFaq) {\n const firstToggle: HTMLElement | null = firstFaq.querySelector('[fynd-faq-element=\"toggle\"]');\n if (firstToggle) {\n const groupName: string | null = groupContainer.getAttribute(\"fynd-faq-group\");\n openAccordion(firstFaq, groupName);\n }\n }\n }\n}\n\n// 1) include mobile sources in the global kickstart\nasync function playAllFaqVideos(): Promise<void> {\n const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll(\n 'video[fynd-faq-video-target], video.fynd-faq-video-target, video[data-fynd-faq-video-target], video[fynd-faq-video-source]'\n );\n for (const v of videos) {\n const hasSrc = !!v.src || v.querySelector('source[src]');\n if (!hasSrc) continue;\n v.setAttribute('muted', '');\n v.setAttribute('playsinline', '');\n v.setAttribute('autoplay', '');\n v.setAttribute('loop', '');\n v.preload = 'auto';\n v.muted = true;\n try { await v.play(); } catch {}\n }\n}\n\n\n// Function to scroll smoothly to the \"scroll-trigger\" element inside the wrapper\nfunction scrollToAccordion(wrapper: HTMLElement): void {\n if (!wrapper) return;\n\n const scrollTarget: HTMLElement | null = wrapper.querySelector('[fynd-faq-element=\"scroll-trigger\"]');\n\n if (!scrollTarget) {\n console.warn('No element with [fynd-faq-element=\"scroll-trigger\"] found inside the wrapper:', wrapper);\n return;\n }\n\n // Smooth scroll to the element\n scrollTarget.scrollIntoView({\n behavior: 'smooth',\n // block: 'center',\n });\n}"],
|
|
5
|
-
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACHA,WAAS,iBAAiB,oBAAoB,MAAY;AACxD,UAAM,cAAuC,SAAS,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "import { isElementAccessExpression } from \"typescript\";\n\n// Type definitions\ninterface GSAPElement extends HTMLElement {\n gsapAnimation?: { kill(): void };\n}\n\ndocument.addEventListener(\"DOMContentLoaded\", (): void => {\n const faqWrappers: NodeListOf<HTMLElement> = document.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"]'\n );\n\n faqWrappers.forEach((wrapper: HTMLElement): void => {\n const toggle: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"toggle\"]'\n );\n const content: GSAPElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content\"]'\n );\n const contentInner: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content-inner\"]'\n );\n const xLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn(\"Required FAQ elements not found in wrapper\");\n return;\n }\n\n const groupContainer: HTMLElement | null =\n wrapper.closest(\"[fynd-faq-group]\");\n const groupName: string | null =\n groupContainer?.getAttribute(\"fynd-faq-group\") || null;\n\n // Get the FAQ type - either \"one-at-a-time\" or \"multiple-at-a-time\"\n const faqType: string =\n groupContainer?.getAttribute(\"fynd-faq-type\") || \"one-at-a-time\";\n\n if (wrapper.getAttribute(\"fynd-faq-initialopen\") === \"true\") {\n gsap.set(content, { height: \"auto\", overflow: \"hidden\" });\n gsap.set(contentInner, { opacity: 1 });\n gsap.set(xLine, { rotation: 180 });\n gsap.set(yLine, { rotation: 270 });\n toggle.setAttribute(\"data-state\", \"open\");\n\n // openening the accordion\n // console.log(\"this accordion is open\", wrapper);\n // if (window.innerWidth < 992) {\n // setTimeout(() => {\n // scrollToAccordion(wrapper);\n // }, 200);\n // }\n\n updateFaqGroupImage(wrapper, groupName); // image\n updateFaqGroupText(wrapper, groupName); // text\n updateFaqGroupButton(wrapper, groupName); // button\n updateFaqGroupVideo(wrapper, groupName); // \u2705 video (sets loop+autoplay and tries to play)\n } else {\n gsap.set(content, { height: 0 });\n gsap.set(contentInner, { opacity: 0 });\n gsap.set(xLine, { rotation: 0 });\n gsap.set(yLine, { rotation: 0 });\n toggle.setAttribute(\"data-state\", \"closed\");\n }\n\n let isAnimating: boolean = false;\n toggle.addEventListener(\"click\", (): void => {\n if (isAnimating) return;\n isAnimating = true;\n const isOpen: boolean = toggle.getAttribute(\"data-state\") === \"open\";\n\n // For \"one-at-a-time\" type, check if this is the last open FAQ\n if (faqType === \"one-at-a-time\" && groupContainer) {\n const openFAQs: NodeListOf<HTMLElement> =\n groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n\n if (isOpen && openFAQs.length === 1) {\n // Don't allow closing the last open FAQ in \"one-at-a-time\" mode\n isAnimating = false;\n return;\n }\n }\n\n if (isOpen) {\n closeAccordion(wrapper, (): void => {\n isAnimating = false;\n });\n } else {\n if (faqType === \"one-at-a-time\" && groupContainer) {\n closeOtherAccordions(groupContainer);\n }\n openAccordion(wrapper, groupName, (): void => {\n isAnimating = false;\n });\n }\n });\n });\n\n // Initialize ratio heights on page load\n handleRatioHeights();\n\n // \u2705 Set up viewport-based autoplay/pause for all video targets\n initFaqVideoAutoplayObserver();\n\n setTimeout(playAllFaqVideos, 500);\n});\n\n// Handle window resize\nwindow.addEventListener(\"resize\", (): void => {\n handleRatioHeights();\n});\n\n// Function to handle ratio heights for FAQ image targets and tabgroups\nfunction handleRatioHeights(): void {\n // Run only if viewport width is >= 992px\n if (window.innerWidth < 992) return;\n\n // Find all FAQ image targets\n const imageTargets: NodeListOf<HTMLElement> = document.querySelectorAll(\n \"[fynd-faq-image-target]\"\n );\n\n imageTargets.forEach((imageTarget: HTMLElement): void => {\n const wrapper: HTMLElement | null = imageTarget.parentElement;\n if (!wrapper) return;\n const ratioHeight: string | null = wrapper.getAttribute(\"ratio-height\");\n if (ratioHeight !== \"true\") return;\n wrapper.style.height = \"auto\";\n requestAnimationFrame((): void => {\n const renderedHeight: number = wrapper.offsetHeight;\n wrapper.style.height = `${renderedHeight}px`;\n });\n });\n\n // Handle tab groups\n const tabGroups: NodeListOf<HTMLElement> = document.querySelectorAll(\n '[fynd-faq-tabgroup][ratio-height=\"true\"]'\n );\n tabGroups.forEach((tabGroup: HTMLElement): void => {\n tabGroup.style.height = \"auto\";\n requestAnimationFrame((): void => {\n const renderedHeight: number = tabGroup.offsetHeight;\n tabGroup.style.height = `${renderedHeight}px`;\n });\n });\n}\n\nfunction openAccordion(\n wrapper: HTMLElement,\n groupName: string | null,\n callback?: () => void\n): void {\n const toggle: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"toggle\"]'\n );\n const content: GSAPElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content\"]'\n );\n const contentInner: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content-inner\"]'\n );\n const xLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn(\"Required elements not found for opening accordion\");\n return;\n }\n\n if (content.gsapAnimation) {\n content.gsapAnimation.kill();\n }\n\n const timeline = gsap.timeline({\n onComplete: (): void => callback && callback(),\n });\n\n gsap.set(content, { height: \"auto\", visibility: \"hidden\", opacity: 0 });\n const height: number = content.offsetHeight;\n gsap.set(content, { height: 0, visibility: \"visible\", opacity: 1 });\n\n timeline.to(xLine, { rotation: 180, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(yLine, { rotation: 270, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(\n content,\n {\n height,\n duration: 0.5,\n ease: \"power3.inOut\",\n clearProps: \"height\",\n onComplete: (): void => {\n (content as HTMLElement).style.height = \"auto\";\n },\n },\n 0\n );\n timeline.to(\n contentInner,\n { opacity: 1, duration: 0.4, ease: \"power2.out\" },\n \"-=0.35\"\n );\n\n content.gsapAnimation = timeline;\n toggle.setAttribute(\"data-state\", \"open\");\n // scroll to the accordion on tablet and below\n // console.log(\"this accordion is open\", wrapper);\n if (window.innerWidth < 992) {\n setTimeout(() => {\n scrollToAccordion(wrapper);\n }, 600);\n }\n\n const icon: HTMLElement | null = toggle.querySelector(\n '[fynd-faq-element=\"chevron\"]'\n );\n if (icon)\n gsap.to(icon, { rotation: 180, duration: 0.4, ease: \"back.out(1.7)\" });\n\n // Update group-level UIs\n updateFaqGroupImage(wrapper, groupName);\n updateFaqGroupText(wrapper, groupName);\n updateFaqGroupButton(wrapper, groupName);\n updateFaqGroupVideo(wrapper, groupName); // \u2705 ensures autoplay on change\n}\n\nfunction closeAccordion(wrapper: HTMLElement, callback?: () => void): void {\n const toggle: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"toggle\"]'\n );\n const content: GSAPElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content\"]'\n );\n const contentInner: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"content-inner\"]'\n );\n const xLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"x-line\"]') || null;\n const yLine: HTMLElement | null =\n toggle?.querySelector('[fynd-faq-element=\"y-line\"]') || null;\n\n if (!toggle || !content || !contentInner || !xLine || !yLine) {\n console.warn(\"Required elements not found for closing accordion\");\n return;\n }\n\n if (content.gsapAnimation) content.gsapAnimation.kill();\n\n const height: number = content.offsetHeight;\n (content as HTMLElement).style.height = `${height}px`;\n\n const timeline = gsap.timeline({\n onComplete: (): void => callback && callback(),\n });\n\n timeline.to(xLine, { rotation: 0, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(yLine, { rotation: 0, duration: 0.4, ease: \"power2.inOut\" }, 0);\n timeline.to(\n contentInner,\n { opacity: 0, duration: 0.3, ease: \"power2.in\" },\n 0\n );\n timeline.to(\n content,\n { height: 0, duration: 0.4, ease: \"power3.inOut\" },\n \"-=0.25\"\n );\n\n content.gsapAnimation = timeline;\n toggle.setAttribute(\"data-state\", \"closed\");\n\n const icon: HTMLElement | null = toggle.querySelector(\n '[fynd-faq-element=\"chevron\"]'\n );\n if (icon)\n gsap.to(icon, { rotation: 0, duration: 0.4, ease: \"back.out(1.7)\" });\n}\n\n// Function to close all other accordions in the same group\nfunction closeOtherAccordions(groupContainer: HTMLElement): void {\n const openFAQs: NodeListOf<HTMLElement> = groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n openFAQs.forEach((openToggle: HTMLElement): void => {\n const wrapper: HTMLElement | null = openToggle.closest(\n '[fynd-faq-element=\"wrapper\"]'\n );\n if (wrapper) closeAccordion(wrapper);\n });\n}\n\n// Function to update the group image\nfunction updateFaqGroupImage(\n wrapper: HTMLElement,\n groupName: string | null\n): void {\n if (!groupName) return;\n const groupImage: HTMLImageElement | null = document.querySelector(\n `[fynd-faq-image-target=\"${groupName}\"]`\n );\n if (!groupImage) return;\n\n const imageSource: HTMLImageElement | null = wrapper.querySelector(\n \"[fynd-faq-image-source]\"\n );\n if (!imageSource) return;\n\n const newSrc: string | null = imageSource.getAttribute(\"src\");\n const newSrcset: string | null = imageSource.getAttribute(\"srcset\");\n\n if (newSrc) groupImage.setAttribute(\"src\", newSrc);\n if (newSrcset) groupImage.setAttribute(\"srcset\", \"\");\n // removing srcset for now\n}\n\n// Function to update the group text\nfunction updateFaqGroupText(\n wrapper: HTMLElement,\n groupName: string | null\n): void {\n if (!groupName) return;\n const groupText: HTMLElement | null = document.querySelector(\n `[fynd-faq-text-target=\"${groupName}\"]`\n );\n if (!groupText) return;\n\n const textSource: HTMLElement | null = wrapper.querySelector(\n \"[fynd-faq-text-source]\"\n );\n if (!textSource) return;\n\n groupText.textContent = textSource.textContent;\n}\n\n// Function to update the group button\nfunction updateFaqGroupButton(\n wrapper: HTMLElement,\n groupName: string | null\n): void {\n if (!groupName) return;\n\n const buttonTextTarget: HTMLElement | null = document.querySelector(\n `[fynd-faq-button-text-target=\"${groupName}\"]`\n );\n const buttonLinkTarget: HTMLElement | null = document.querySelector(\n `[fynd-faq-button-link-target=\"${groupName}\"]`\n );\n\n const linkSource: HTMLAnchorElement | null = wrapper.querySelector(\n \"[fynd-faq-link-source]\"\n );\n if (!linkSource) return;\n\n if (buttonTextTarget) buttonTextTarget.textContent = linkSource.textContent;\n\n if (buttonLinkTarget) {\n for (let i = 0; i < linkSource.attributes.length; i++) {\n const attr = linkSource.attributes[i];\n buttonLinkTarget.setAttribute(attr.name, attr.value);\n }\n }\n}\n\n// \u2705 Always-loop + autoplay video updater (mobile: show video if set, else image)\nfunction updateFaqGroupVideo(\n wrapper: HTMLElement,\n groupName: string | null\n): void {\n if (!groupName) return;\n\n const groupVideo: HTMLVideoElement | null = document.querySelector(\n `[fynd-faq-video-target=\"${groupName}\"]`\n );\n if (!groupVideo) return;\n\n const groupVideoWrapper: HTMLElement | null =\n wrapper.querySelector(`[fynd-faq-video]`);\n const groupImageWrapper: HTMLElement | null =\n wrapper.querySelector(`[fynd-faq-image]`);\n\n const sourceVideo: HTMLVideoElement | null = wrapper.querySelector(\n \"[fynd-faq-video-source]\"\n );\n const mobile = window.innerWidth < 992;\n\n // Determine if a valid video is set on the *source* inside the wrapper\n const sourceEl: HTMLSourceElement | null =\n sourceVideo?.querySelector(\"source\") || null;\n const newSrc: string = (sourceEl?.getAttribute(\"src\") || \"\").trim();\n const newType: string = (\n sourceEl?.getAttribute(\"type\") || \"video/mp4\"\n ).trim();\n const hasVideo: boolean = !!sourceVideo && !!sourceEl && newSrc !== \"\";\n\n // \uD83D\uDD38 Mobile-only visibility: show video wrapper if video exists, else show image\n if (mobile) {\n if (groupVideoWrapper)\n groupVideoWrapper.style.display = hasVideo ? \"block\" : \"none\";\n if (groupImageWrapper)\n groupImageWrapper.style.display = hasVideo ? \"none\" : \"block\";\n }\n\n // If no video configured, hide the group target video and clean up\n if (!hasVideo) {\n groupVideo.style.display = \"none\";\n const targetSourceEl: HTMLSourceElement | null =\n groupVideo.querySelector(\"source\");\n if (targetSourceEl) {\n targetSourceEl.removeAttribute(\"src\");\n targetSourceEl.removeAttribute(\"type\");\n try {\n groupVideo.load();\n } catch {}\n }\n return;\n }\n\n // We have a valid video: ensure attributes + update the *group* video target\n let targetSourceEl: HTMLSourceElement | null =\n groupVideo.querySelector(\"source\");\n if (!targetSourceEl) {\n targetSourceEl = document.createElement(\"source\");\n groupVideo.appendChild(targetSourceEl);\n }\n\n targetSourceEl.setAttribute(\"src\", newSrc);\n targetSourceEl.setAttribute(\"type\", newType);\n\n groupVideo.setAttribute(\"loop\", \"\");\n groupVideo.setAttribute(\"autoplay\", \"\");\n groupVideo.setAttribute(\"muted\", \"\");\n groupVideo.setAttribute(\"playsinline\", \"\");\n\n // Mobile: also prep the inline source video for autoplay\n if (mobile && sourceVideo) {\n sourceVideo.setAttribute(\"loop\", \"\");\n sourceVideo.setAttribute(\"autoplay\", \"\");\n sourceVideo.setAttribute(\"muted\", \"\");\n sourceVideo.setAttribute(\"playsinline\", \"\");\n autoplayVideo(sourceVideo);\n }\n\n try {\n groupVideo.load();\n } catch {}\n autoplayVideo(groupVideo);\n groupVideo.style.display = \"block\";\n}\n\n// \uD83D\uDD38 Robust autoplay helper (handles Promise and race conditions)\nfunction autoplayVideo(video: HTMLVideoElement): void {\n // If not in DOM or hidden, defer to IntersectionObserver\n if (!video.isConnected || video.style.display === \"none\") return;\n\n // Some browsers need a tiny delay after .load()\n requestAnimationFrame(() => {\n const playPromise = video.play();\n if (\n playPromise &&\n typeof (playPromise as Promise<void>).catch === \"function\"\n ) {\n (playPromise as Promise<void>).catch(() => {\n // If autoplay fails (rare with muted+playsinline), we silently ignore.\n });\n }\n });\n}\n\n// \uD83D\uDD38 Observe visibility to autoplay on entering viewport (and pause when out)\nfunction initFaqVideoAutoplayObserver(): void {\n const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll(\n \"[fynd-faq-video-target]\"\n );\n if (!videos.length) return;\n\n const io = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n const video = entry.target as HTMLVideoElement;\n // Only act if video has a valid source set\n const hasSrc = !!video.querySelector(\"source[src]\");\n if (!hasSrc || video.style.display === \"none\") return;\n\n if (entry.isIntersecting && entry.intersectionRatio >= 0.5) {\n // Ensure autoplay attributes are present (defensive)\n video.setAttribute(\"autoplay\", \"\");\n video.setAttribute(\"muted\", \"\");\n video.setAttribute(\"playsinline\", \"\");\n video.setAttribute(\"loop\", \"\");\n autoplayVideo(video);\n } else {\n // Pause when scrolled out to save resources\n try {\n video.pause();\n } catch (e) {\n /* no-op */\n }\n }\n });\n },\n { threshold: [0, 0.5, 1] }\n );\n\n videos.forEach((v) => io.observe(v));\n}\n\n// Function to ensure at least one FAQ is open in \"one-at-a-time\" mode\nfunction ensureOneFaqOpen(groupContainer: HTMLElement | null): void {\n if (!groupContainer) return;\n\n const faqType: string =\n groupContainer.getAttribute(\"fynd-faq-type\") || \"one-at-a-time\";\n if (faqType !== \"one-at-a-time\") return;\n\n const openFAQs: NodeListOf<HTMLElement> = groupContainer.querySelectorAll(\n '[fynd-faq-element=\"wrapper\"] [data-state=\"open\"]'\n );\n\n if (openFAQs.length === 0) {\n const firstFaq: HTMLElement | null = groupContainer.querySelector(\n '[fynd-faq-element=\"wrapper\"]'\n );\n if (firstFaq) {\n const firstToggle: HTMLElement | null = firstFaq.querySelector(\n '[fynd-faq-element=\"toggle\"]'\n );\n if (firstToggle) {\n const groupName: string | null =\n groupContainer.getAttribute(\"fynd-faq-group\");\n openAccordion(firstFaq, groupName);\n }\n }\n }\n}\n\n// 1) include mobile sources in the global kickstart\nasync function playAllFaqVideos(): Promise<void> {\n const videos: NodeListOf<HTMLVideoElement> = document.querySelectorAll(\n \"video[fynd-faq-video-target], video.fynd-faq-video-target, video[data-fynd-faq-video-target], video[fynd-faq-video-source]\"\n );\n for (const v of videos) {\n const hasSrc = !!v.src || v.querySelector(\"source[src]\");\n if (!hasSrc) continue;\n v.setAttribute(\"muted\", \"\");\n v.setAttribute(\"playsinline\", \"\");\n v.setAttribute(\"autoplay\", \"\");\n v.setAttribute(\"loop\", \"\");\n v.preload = \"auto\";\n v.muted = true;\n try {\n await v.play();\n } catch {}\n }\n}\n\n// Function to scroll smoothly to the \"scroll-trigger\" element inside the wrapper\nfunction scrollToAccordion(wrapper: HTMLElement): void {\n if (!wrapper) return;\n\n const scrollTarget: HTMLElement | null = wrapper.querySelector(\n '[fynd-faq-element=\"scroll-trigger\"]'\n );\n\n if (!scrollTarget) {\n console.warn(\n 'No element with [fynd-faq-element=\"scroll-trigger\"] found inside the wrapper:',\n wrapper\n );\n return;\n }\n\n // Smooth scroll to the element\n scrollTarget.scrollIntoView({\n behavior: \"smooth\",\n // block: 'center',\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACHA,WAAS,iBAAiB,oBAAoB,MAAY;AACxD,UAAM,cAAuC,SAAS;AAAA,MACpD;AAAA,IACF;AAEA,gBAAY,QAAQ,CAAC,YAA+B;AAClD,YAAM,SAA6B,QAAQ;AAAA,QACzC;AAAA,MACF;AACA,YAAM,UAA8B,QAAQ;AAAA,QAC1C;AAAA,MACF;AACA,YAAM,eAAmC,QAAQ;AAAA,QAC/C;AAAA,MACF;AACA,YAAM,QACJ,QAAQ,cAAc,6BAA6B,KAAK;AAC1D,YAAM,QACJ,QAAQ,cAAc,6BAA6B,KAAK;AAE1D,UAAI,CAAC,UAAU,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO;AAC5D,gBAAQ,KAAK,4CAA4C;AACzD;AAAA,MACF;AAEA,YAAM,iBACJ,QAAQ,QAAQ,kBAAkB;AACpC,YAAM,YACJ,gBAAgB,aAAa,gBAAgB,KAAK;AAGp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GAAG,QAAQ,CAAC,CAAC;AAAA,EACrC;AAgCA,iBAAe,mBAAkC;AAC/C,UAAM,SAAuC,SAAS;AAAA,MACpD;AAAA,IACF;AACA,eAAW,KAAK,QAAQ;AACtB,YAAM,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,aAAa;AACvD,UAAI,CAAC,OAAQ;AACb,QAAE,aAAa,SAAS,EAAE;AAC1B,QAAE,aAAa,eAAe,EAAE;AAChC,QAAE,aAAa,YAAY,EAAE;AAC7B,QAAE,aAAa,QAAQ,EAAE;AACzB,QAAE,UAAU;AACZ,QAAE,QAAQ;AACV,UAAI;AACF,cAAM,EAAE,KAAK;AAAA,MACf,QAAQ;AAAA,MAAC;AAAA,IACX;AAAA,EACF;AAGA,WAAS,kBAAkB,SAA4B;AACrD,QAAI,CAAC,QAAS;AAEd,UAAM,eAAmC,QAAQ;AAAA,MAC/C;AAAA,IACF;AAEA,QAAI,CAAC,cAAc;AACjB,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AACA;AAAA,IACF;AAGA,iBAAa,eAAe;AAAA,MAC1B,UAAU;AAAA;AAAA,IAEZ,CAAC;AAAA,EACH;",
|
|
6
|
+
"names": ["targetSourceEl"]
|
|
7
7
|
}
|
package/dist/filters/konnect.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{document.addEventListener("DOMContentLoaded",()=>{let
|
|
1
|
+
"use strict";(()=>{function u(t){let e=new URLSearchParams(window.location.search).get(t);return e?e.trim():null}function l(){return u("tag_equal")}window.getTagEqualFromURL=l;document.addEventListener("DOMContentLoaded",()=>{console.log("%csrc/filters/konnect.ts:2 working","color: #007acc;");let t=document.querySelectorAll("[konnect-filter-element]");if(t.length===0)return;setTimeout(d,200);let e=l();setInterval(()=>{let n=l();n!==e&&(console.log("tag_equal changed:",n),e=n,a())},100);let o=document.getElementById("konnect-filter");o&&o.addEventListener("change",()=>{console.log("Select changed \u2192 URL tag_equal is:",l())}),t.forEach(n=>{n.addEventListener("click",()=>{console.log("konnect-filter-element clicked:",n),n.getAttribute("konnect-filter-element")==="primary"?(setTimeout(a,100),document.querySelectorAll('[konnect-filter-element="secondary"]').forEach((c,s)=>{s==0?(c.click(),c.setAttribute("konnect-filter-active","true")):c.setAttribute("konnect-filter-active","false")})):setTimeout(f,100)})})});function f(){let t=new URLSearchParams(window.location.search).get("nest-tag_equal"),e=document.querySelectorAll('[konnect-filter-element="secondary"]');if(!t){e.forEach((n,r)=>{n.setAttribute("konnect-filter-active",r==0?"true":"false")});return}let o=t.trim().toLowerCase();e.length!==0&&e.forEach(n=>{let r=n.querySelector("[fs-list-value]");if(!r)return;r.getAttribute("fs-list-value")?.trim().toLowerCase()===o?(n.setAttribute("konnect-filter-active","true"),e[0].setAttribute("konnect-filter-active","false")):n.setAttribute("konnect-filter-active","false")})}function a(){let t=l(),e=document.getElementById("konnect-filter");if(!e){console.warn("Select element with id 'konnect-filter' not found.");return}t?Array.from(e.options).find(n=>n.value===t)?(e.value=t,console.log(`Selected option: ${t}`),m(t)):console.warn(`No matching option found for value: ${t}`):console.log("No 'tag_equal' parameter in URL.")}function d(){let t=l(),e=document.getElementById("konnect-filter");if(!e){console.warn("Select element with id 'konnect-filter' not found.");return}t?Array.from(e.options).find(n=>n.value===t)?(e.value=t,console.log(`Selected from URL param: ${t}`)):(console.warn(`No matching option found for value: ${t}. Defaulting to Marketplaces.`),e.value="Marketplaces"):(e.value="Marketplaces",console.log("No tag_equal param found. Defaulted to Marketplaces."))}function m(t){let e=document.getElementById("secondary-filter");e&&(t!=="Marketplaces"?e.style.display="none":e.style.display="flex")}})();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../bin/live-reload.js", "../../src/filters/konnect.ts"],
|
|
4
|
-
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "
|
|
5
|
-
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;
|
|
4
|
+
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "// ---- global helpers ----\nfunction getQueryParam(name: string): string | null {\n const val = new URLSearchParams(window.location.search).get(name);\n return val ? val.trim() : null;\n}\n\nfunction getTagEqualFromURL(): string | null {\n return getQueryParam(\"tag_equal\");\n}\n\n// expose globally if you want to inspect it in the console\n// @ts-ignore\n(window as any).getTagEqualFromURL = getTagEqualFromURL;\n\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n console.log(\"%csrc/filters/konnect.ts:2 working\", \"color: #007acc;\");\n const elements = document.querySelectorAll<HTMLElement>(\n \"[konnect-filter-element]\"\n );\n if (elements.length === 0) return;\n setTimeout(updateMobileSelectOnLoad, 200);\n\n // watch tag_equal every 100 ms\n let lastTagEqual = getTagEqualFromURL();\n setInterval(() => {\n const current = getTagEqualFromURL();\n if (current !== lastTagEqual) {\n console.log(\"tag_equal changed:\", current);\n lastTagEqual = current;\n updateMobileSelect(); // re-sync the select whenever the URL changes\n }\n }, 100);\n\n // log the URL param whenever user changes select\n const select = document.getElementById(\n \"konnect-filter\"\n ) as HTMLSelectElement | null;\n if (select) {\n select.addEventListener(\"change\", () => {\n console.log(\"Select changed \u2192 URL tag_equal is:\", getTagEqualFromURL());\n });\n }\n\n elements.forEach((el) => {\n el.addEventListener(\"click\", () => {\n console.log(\"konnect-filter-element clicked:\", el);\n const type = el.getAttribute(\"konnect-filter-element\");\n if (type === \"primary\") {\n setTimeout(updateMobileSelect, 100);\n const items = document.querySelectorAll<HTMLElement>(\n '[konnect-filter-element=\"secondary\"]'\n );\n items.forEach((el, index) => {\n if (index == 0) {\n el.click();\n el.setAttribute(\"konnect-filter-active\", \"true\");\n } else {\n el.setAttribute(\"konnect-filter-active\", \"false\");\n }\n });\n } else {\n setTimeout(updateSecondaryFilterTabs, 100);\n }\n });\n });\n});\n\nfunction updateSecondaryFilterTabs(): void {\n const raw = new URLSearchParams(window.location.search).get(\"nest-tag_equal\");\n const items = document.querySelectorAll<HTMLElement>(\n '[konnect-filter-element=\"secondary\"]'\n );\n if (!raw) {\n items.forEach((el, index) => {\n el.setAttribute(\"konnect-filter-active\", index == 0 ? \"true\" : \"false\");\n });\n return;\n }\n const target = raw.trim().toLowerCase();\n if (items.length === 0) return;\n\n items.forEach((el) => {\n const input = el.querySelector<HTMLInputElement>(\"[fs-list-value]\");\n if (!input) return;\n const valFromAttr = input\n .getAttribute(\"fs-list-value\")\n ?.trim()\n .toLowerCase();\n if (valFromAttr === target) {\n el.setAttribute(\"konnect-filter-active\", \"true\");\n items[0].setAttribute(\"konnect-filter-active\", \"false\");\n } else {\n el.setAttribute(\"konnect-filter-active\", \"false\");\n }\n });\n}\n\nfunction updateMobileSelect(): void {\n const raw = getTagEqualFromURL();\n const select = document.getElementById(\n \"konnect-filter\"\n ) as HTMLSelectElement | null;\n if (!select) {\n console.warn(\"Select element with id 'konnect-filter' not found.\");\n return;\n }\n\n if (raw) {\n const matchedOption = Array.from(select.options).find(\n (option) => option.value === raw\n );\n if (matchedOption) {\n select.value = raw;\n console.log(`Selected option: ${raw}`);\n toggleSecondaryFilter(raw);\n } else {\n console.warn(`No matching option found for value: ${raw}`);\n }\n } else {\n console.log(\"No 'tag_equal' parameter in URL.\");\n }\n}\n\nfunction updateMobileSelectOnLoad(): void {\n const raw = getTagEqualFromURL();\n const select = document.getElementById(\n \"konnect-filter\"\n ) as HTMLSelectElement | null;\n if (!select) {\n console.warn(\"Select element with id 'konnect-filter' not found.\");\n return;\n }\n\n if (raw) {\n const matchedOption = Array.from(select.options).find(\n (option) => option.value === raw\n );\n if (matchedOption) {\n select.value = raw;\n console.log(`Selected from URL param: ${raw}`);\n } else {\n console.warn(\n `No matching option found for value: ${raw}. Defaulting to Marketplaces.`\n );\n select.value = \"Marketplaces\";\n }\n } else {\n select.value = \"Marketplaces\";\n console.log(\"No tag_equal param found. Defaulted to Marketplaces.\");\n }\n}\n\nfunction toggleSecondaryFilter(raw: string | null): void {\n const div = document.getElementById(\"secondary-filter\") as HTMLElement | null;\n if (!div) return;\n if (raw !== \"Marketplaces\") {\n div.style.display = \"none\";\n } else {\n div.style.display = \"flex\";\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACTA,WAAS,cAAc,MAA6B;AAClD,UAAM,MAAM,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,IAAI;AAChE,WAAO,MAAM,IAAI,KAAK,IAAI;AAAA,EAC5B;AAEA,WAAS,qBAAoC;AAC3C,WAAO,cAAc,WAAW;AAAA,EAClC;AAIA,EAAC,OAAe,qBAAqB;AAErC,WAAS,iBAAiB,oBAAoB,MAAM;AAClD,YAAQ,IAAI,sCAAsC,iBAAiB;AACnE,UAAM,WAAW,SAAS;AAAA,MACxB;AAAA,IACF;AACA,QAAI,SAAS,WAAW,EAAG;AAC3B,eAAW,0BAA0B,GAAG;AAGxC,QAAI,eAAe,mBAAmB;AACtC,gBAAY,MAAM;AAChB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;AACL,gBAAQ;AAAA,UACN,uCAAuC,GAAG;AAAA,QAC5C;AACA,eAAO,QAAQ;AAAA,MACjB;AAAA,IACF,OAAO;AACL,aAAO,QAAQ;AACf,cAAQ,IAAI,sDAAsD;AAAA,IACpE;AAAA,EACF;AAEA,WAAS,sBAAsB,KAA0B;AACvD,UAAM,MAAM,SAAS,eAAe,kBAAkB;AACtD,QAAI,CAAC,IAAK;AACV,QAAI,QAAQ,gBAAgB;AAC1B,UAAI,MAAM,UAAU;AAAA,IACtB,OAAO;AACL,UAAI,MAAM,UAAU;AAAA,IACtB;AAAA,EACF;",
|
|
6
6
|
"names": ["el"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../bin/live-reload.js", "../../src/global/geolocation/main.ts", "../../src/global/geolocation/geolocation-cached.ts", "../../src/global/animation/toggle-banner.ts", "../../src/utils/cookies.ts", "../../src/global/screen-type.ts", "../../src/navigation/country-detection/main.ts", "../../src/navigation/initialization.ts"],
|
|
4
|
-
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "// Define the type for returned geolocation data\n// Remider for adding Fallback: ipinfo.io (HTTPS, requires token)\nexport type GeoData = {\n ip: string;\n country: string;\n region: string;\n city: string;\n latitude: number;\n longitude: number;\n isp: string;\n timezone: string;\n };\n \n // Exported function that can be reused anywhere\n export async function getGeolocation(): Promise<GeoData | null> {\n try {\n const response = await fetch(\"https://ipwho.is/\");\n if (!response.ok) {\n throw new Error(\"Failed to fetch geolocation\");\n }\n \n const data = await response.json();\n \n if (data.success === false) {\n console.error(\"Geolocation lookup failed:\", data.message);\n return null;\n }\n \n return {\n ip: data.ip,\n country: data.country,\n region: data.region,\n city: data.city,\n latitude: data.latitude,\n longitude: data.longitude,\n isp: data.connection?.isp || \"\",\n timezone: data.timezone?.id || \"\"\n };\n } catch (error) {\n console.error(\"Error fetching geolocation:\", error);\n return null;\n }\n }\n\n //used in /src/navigation/initialization.ts for displaying ip banner", "import { GeoData, getGeolocation } from \"./main\";\n\nconst GEO_CACHE_KEY = \"geo:data:v1\";\nconst GEO_COOKIE_KEY = \"geo_country\";\nconst GEO_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\n\ntype Cached<T> = { data: T; expiresAt: number };\n\n// --- Cookie helpers ---\nfunction setCookie(name: string, value: string, maxAgeSec: number) {\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; Max-Age=${maxAgeSec}; Path=/; SameSite=Lax; Secure`;\n}\n\nfunction getCookie(name: string): string | null {\n const key = `${encodeURIComponent(name)}=`;\n const parts = document.cookie.split(\"; \");\n for (const p of parts) {\n if (p.startsWith(key)) return decodeURIComponent(p.slice(key.length));\n }\n return null;\n}\n\nfunction clearCookie(name: string) {\n document.cookie = `${encodeURIComponent(name)}=; Max-Age=0; Path=/; SameSite=Lax; Secure`;\n}\n\n// --- LocalStorage helpers ---\nfunction readCache<T>(key: string): T | null {\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Cached<T>;\n if (!parsed?.expiresAt || Date.now() > parsed.expiresAt) {\n localStorage.removeItem(key);\n return null;\n }\n return parsed.data;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n}\n\nfunction writeCache<T>(key: string, data: T, ttlMs: number) {\n const payload: Cached<T> = { data, expiresAt: Date.now() + ttlMs };\n try {\n localStorage.setItem(key, JSON.stringify(payload));\n } catch {\n // ignore quota errors\n }\n}\n\n// --- Public API ---\nexport async function getGeolocationCached(options?: {\n forceRefresh?: boolean;\n}): Promise<GeoData | null> {\n if (typeof window === \"undefined\") return null;\n\n const forceRefresh = options?.forceRefresh ?? false;\n\n if (!forceRefresh) {\n const cached = readCache<GeoData>(GEO_CACHE_KEY);\n if (cached) {\n (window as any).__GEO = cached;\n if (!getCookie(GEO_COOKIE_KEY)) {\n setCookie(GEO_COOKIE_KEY, cached.country ?? \"\", Math.floor(GEO_TTL_MS / 1000));\n }\n return cached;\n }\n }\n\n const fresh = await getGeolocation();\n if (!fresh) return null;\n\n writeCache(GEO_CACHE_KEY, fresh, GEO_TTL_MS);\n setCookie(GEO_COOKIE_KEY, fresh.country ?? \"\", Math.floor(GEO_TTL_MS / 1000));\n (window as any).__GEO = fresh;\n return fresh;\n}\n\nexport function getGeoCountryFromCookie(): string | null {\n return getCookie(GEO_COOKIE_KEY);\n}\n\nexport function clearGeolocationCache() {\n try {\n localStorage.removeItem(GEO_CACHE_KEY);\n } catch {}\n clearCookie(GEO_COOKIE_KEY);\n if (typeof window !== \"undefined\") {\n (window as any).__GEO = undefined;\n }\n}", "// toggleBanner.ts\n// Utility functions to open/close a banner using GSAP with optional target height.\n\nexport function openBanner(\n mainSelector: string,\n innerSelector: string,\n targetHeight: string | number = \"auto\" // default stays \"auto\"\n) {\n const w = (window as any) || {};\n const gsap = w.gsap as any;\n if (!gsap) {\n console.warn(\"GSAP not found on window. Did you include it globally?\");\n return;\n }\n\n const mainEl = document.querySelector<HTMLElement>(mainSelector);\n const innerEl = document.querySelector<HTMLElement>(innerSelector);\n\n if (!mainEl || !innerEl) {\n console.warn(\"openBanner: Element(s) not found for selectors:\", {\n mainSelector,\n innerSelector,\n });\n return;\n }\n\n // Ensure clean start\n gsap.set(mainEl, { height: 0, overflow: \"hidden\" });\n gsap.set(innerEl, { opacity: 0 });\n\n const tl = gsap.timeline();\n\n // Animate main from height: 0 -> targetHeight\n tl.to(mainEl, {\n height: targetHeight,\n duration: 0.5,\n ease: \"power2.out\",\n });\n\n // After 0.2s, fade inner to 1\n tl.to(\n innerEl,\n {\n opacity: 1,\n duration: 0.3,\n ease: \"power1.out\",\n },\n 0.2\n );\n\n return tl;\n}\n\nexport function closeBanner(\n mainSelector: string,\n innerSelector: string,\n targetHeight: string | number = 0 // default collapse fully\n) {\n const w = (window as any) || {};\n const gsap = w.gsap as any;\n if (!gsap) {\n console.warn(\"GSAP not found on window. Did you include it globally?\");\n return;\n }\n\n const mainEl = document.querySelector<HTMLElement>(mainSelector);\n const innerEl = document.querySelector<HTMLElement>(innerSelector);\n\n if (!mainEl || !innerEl) {\n console.warn(\"closeBanner: Element(s) not found for selectors:\", {\n mainSelector,\n innerSelector,\n });\n return;\n }\n\n gsap.set(mainEl, { overflow: \"hidden\" });\n\n const tl = gsap.timeline();\n\n // Fade inner out\n tl.to(innerEl, {\n opacity: 0,\n duration: 0.25,\n ease: \"power1.out\",\n });\n\n // Collapse height to targetHeight (default 0)\n tl.to(\n mainEl,\n {\n height: targetHeight,\n duration: 0.45,\n ease: \"power2.inOut\",\n },\n 0.2\n );\n\n return tl;\n}", "export function setCookie(name: string, value: string, hours: number) {\n const date = new Date();\n date.setTime(date.getTime() + hours * 60 * 60 * 1000);\n document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`;\n }\n \n export function getCookie(name: string): string | null {\n const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));\n return match ? match[2] : null;\n }", "// screen-type.ts\n// Utility to get the current screen type\n// Breakpoints:\n// - Desktop: 992px+\n// - Tablet: 768px\u2013991px\n// - Mobile Landscape: 480px\u2013767px\n// - Mobile Portrait: under 480px\n\nexport type ScreenType = \"desktop\" | \"tablet\" | \"mobileLandscape\" | \"mobilePortrait\";\n\nexport function getScreenType(): ScreenType {\n const width = window.innerWidth;\n\n if (width >= 992) {\n return \"desktop\";\n } else if (width >= 768) {\n return \"tablet\";\n } else if (width >= 480) {\n return \"mobileLandscape\";\n } else {\n return \"mobilePortrait\";\n }\n}", "// geo.ts\nimport { getGeoCountryFromCookie, getGeolocationCached } from \"src/global/geolocation/geolocation-cached\";\nimport { GeoData } from \"src/global/geolocation/main\";\n\n/** Your banner config */\ntype CountryConfig = {\n country: string; // canonical lowercase name\n countryCode: string; // ISO-2 lowercase code (e.g., \"in\")\n url: string; // leading-slash path (e.g., \"/in\")\n tagline: string; // banner text/html\n aliases?: string[]; // optional extra names to match against\n};\n\nexport const COUNTRY_CONFIG: CountryConfig[] = [\n {\n country: \"united arab emirates\",\n aliases: [\"uae\", \"u.a.e\", \"united arab emirates\"],\n countryCode: \"ae\",\n url: \"/ae\",\n tagline: \"You're in the UAE. Welcome!\"\n },\n {\n country: \"saudi arabia\",\n aliases: [\"saudi\", \"ksa\", \"kingdom of saudi arabia\"],\n countryCode: \"sa\",\n url: \"/sa\",\n tagline: \"Hello Saudi Arabia!\"\n },\n {\n country: \"south africa\",\n aliases: [\"rsa\"],\n countryCode: \"za\",\n url: \"/za\",\n tagline: \"Hi South Africa!\"\n },\n {\n country: \"malaysia\",\n countryCode: \"my\",\n url: \"/my\",\n tagline: \"Selamat datang, Malaysia!\"\n },\n {\n country: \"indonesia\",\n aliases: [\"idn\"],\n countryCode: \"id\",\n url: \"/id\",\n tagline: \"Halo Indonesia!\"\n },\n {\n country: \"philippines\",\n aliases: [\"phl\", \"the philippines\"],\n countryCode: \"ph\",\n url: \"/ph\",\n tagline: \"Kumusta, Philippines!\"\n },\n {\n country: \"india\",\n aliases: [\"bharat\"],\n countryCode: \"in\",\n url: \"/in\",\n tagline: \"This country is India. Hi some text\"\n },\n // \uD83D\uDC47 fallback\n {\n country: \"global\",\n aliases: [\"global\", \"rest of world\", \"others\"],\n countryCode: \"global\", // keep lowercase for consistency\n url: \"/global\",\n tagline: \"This is rest of world. Hi some text\"\n }\n];\n\n/** Utility: normalize strings for comparisons */\nfunction norm(s: string | null | undefined): string {\n return (s ?? \"\").trim().toLowerCase();\n}\n\n/** Utility: ensure URL starts with a single leading slash */\nfunction toPath(path: string): string {\n const p = path.trim();\n if (!p) return \"/\";\n return p.startsWith(\"/\") ? p : `/${p}`;\n}\n\n/** Determine user's country as a *string* (might be name or code depending on your geo source) */\nexport async function getUserCountry(): Promise<string | null> {\n if (typeof window === \"undefined\") return null;\n\n // 1) Cookie fast-path\n const cookieCountry = getGeoCountryFromCookie();\n if (cookieCountry) return norm(cookieCountry);\n\n // 2) Cached or network\n const geo: GeoData | null = await getGeolocationCached();\n return norm((geo as any)?.country);\n}\n\n/** Find matching config by country *name* or *ISO-2 code* with aliases */\nfunction findCountryConfig(input: string | null): CountryConfig | null {\n const v = norm(input);\n if (!v) return null;\n\n const byCode = COUNTRY_CONFIG.find(c => norm(c.countryCode) === v);\n if (byCode) return byCode;\n\n const byName = COUNTRY_CONFIG.find(c => norm(c.country) === v);\n if (byName) return byName;\n\n const byAlias = COUNTRY_CONFIG.find(c => (c.aliases ?? []).some(a => norm(a) === v));\n if (byAlias) return byAlias;\n\n return null;\n}\n\n/** Helper to fetch the global config */\nfunction getGlobalConfig(): CountryConfig {\n const g = COUNTRY_CONFIG.find(c => c.country === \"global\");\n if (!g) throw new Error(\"[geo-banner] Global config not found in COUNTRY_CONFIG\");\n return g;\n}\n\nfunction updateBannerLink(countryCode?: string | null): void {\n if (typeof window === \"undefined\") return;\n\n const code = norm(countryCode);\n const conf =\n COUNTRY_CONFIG.find(c => norm(c.countryCode) === code) ||\n getGlobalConfig();\n\n const linkEl = document.querySelector<HTMLAnchorElement>('[fynd-banner-field=\"link\"]');\n if (linkEl) {\n const base = window.location.origin;\n linkEl.href = `${base}${toPath(conf.url)}`;\n }\n}\n\nexport function setSelectValueSafely(selectEl: HTMLSelectElement, desired: string) {\n // 1) resolve config\n const conf =\n findCountryConfig(desired) ??\n COUNTRY_CONFIG.find(c => c.country === \"global\");\n if (!conf) {\n console.warn(\"[geo-banner] No matching config for\", desired);\n return false;\n }\n const desiredCode = conf.countryCode; // assume already normalized/lowercase\n\n // 2) find matching option (normalize both sides)\n const opts = Array.from(selectEl.options);\n const opt = opts.find(o => norm(o.value) === norm(desiredCode));\n if (!opt) {\n console.warn(\"[geo-banner] No matching <option> for\", desiredCode, \"on\", selectEl);\n return false;\n }\n\n // 3) update the <select> itself (more reliable than toggling option.selected)\n const prev = selectEl.value;\n selectEl.value = opt.value;\n\n // if some browsers/frameworks didn\u2019t adopt .value, force selectedIndex too\n if (selectEl.value !== opt.value) {\n selectEl.selectedIndex = opts.indexOf(opt);\n }\n\n // 4) (optional) keep options\u2019 selected flags in sync\n opts.forEach(o => (o.selected = o === opt));\n\n // 5) fire events frameworks listen to\n if (prev !== selectEl.value) {\n selectEl.dispatchEvent(new Event(\"input\", { bubbles: true }));\n selectEl.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n console.log(\"[geo-banner] Select updated \u2192\", conf.country, \"(\", conf.countryCode, \")\");\n return true;\n}\n\n/** Update the banner content for a given countryCode (lowercase ISO-2) with global fallback */\nexport function updateBannerContent(countryCode?: string | null): void {\n if (typeof window === \"undefined\") return;\n\n const code = norm(countryCode);\n const conf =\n COUNTRY_CONFIG.find(c => norm(c.countryCode) === code) ||\n getGlobalConfig();\n // 1) Set <select fynd-banner-field=\"geoswitch\"> value (robustly)\n const selectEl =\n document.querySelector<HTMLSelectElement>('#geoswitch-select') ||\n document.querySelector<HTMLSelectElement>('[fynd-banner-field=\"geoswitch\"]');\n\n if (selectEl) {\n console.log(`country code is ${conf.countryCode}`)\n setSelectValueSafely(selectEl, conf.countryCode);\n selectEl.value = conf.countryCode; // or \"global\", etc.\n\n selectEl.dispatchEvent(new Event(\"change\", { bubbles: true }));\n } else {\n console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field=\"geoswitch\"]');\n }\n\n // // 2) Update banner text (unchanged)\n // const textEl = document.querySelector<HTMLElement>('[fynd-banner-field=\"banner-text\"]');\n // if (textEl) textEl.innerHTML = conf.tagline;\n\n // 3) Update link href (unchanged)\n const linkEl = document.querySelector<HTMLAnchorElement>('[fynd-banner-field=\"link\"]');\n if (linkEl) {\n const base = window.location.origin;\n linkEl.href = `${base}${toPath(conf.url)}`;\n }\n}\n\n/**\n * Main entry: detect country and update banner if it matches one of the configured countries.\n * Always falls back to global if no match is found.\n */\nexport async function initCountryDetection(): Promise<CountryConfig> {\n if (typeof window === \"undefined\") return getGlobalConfig();\n\n if (document.readyState === \"loading\") {\n await new Promise<void>(resolve => {\n document.addEventListener(\"DOMContentLoaded\", () => resolve(), { once: true });\n });\n }\n\n const rawCountry = await getUserCountry();\n const match = findCountryConfig(rawCountry);\n const resolved = match ?? getGlobalConfig();\n\n // Debug visibility\n console.log(\"[geo-banner] rawCountry:\", rawCountry, \"\u2192 resolved:\", resolved.countryCode);\n\n // \u2705 Always update from the resolved config (guarantees global fallback)\n updateBannerContent(resolved.countryCode);\n\n // (If you also attached the select change listener, keep that here)\n const selectEl = document.querySelector<HTMLSelectElement>('[fynd-banner-field=\"geoswitch\"]');\n if (selectEl && !(selectEl as any).__geoHandlerAttached) {\n selectEl.addEventListener(\"change\", (e) => {\n const value = (e.target as HTMLSelectElement).value;\n updateBannerLink(value); // only updates href on change\n });\n (selectEl as any).__geoHandlerAttached = true;\n }\n\n return resolved;\n}", "import { getGeolocationCached } from \"src/global/geolocation/geolocation-cached\";\nimport { closeBanner, openBanner } from \"src/global/animation/toggle-banner\";\nimport { getCookie, setCookie } from \"$utils/cookies\";\nimport { getScreenType } from \"src/global/screen-type\";\nimport { initCountryDetection } from \"./country-detection/main\";\n\n/**\n * Banner rules by route (normalized, no trailing slash).\n * Modes:\n * - { mode: \"always\" }\n * - { mode: \"country\", countries: [...] } \u2192 open if geo.country matches (case-insensitive)\n * - { mode: \"notCountry\", countries: [...] } \u2192 open if geo.country does NOT match\n * - { mode: \"predicate\", test: (geo) => boolean }\n */\nconst bannerRouteRules: Record<\n string,\n | { mode: \"always\" }\n | { mode: \"country\"; countries: string[] }\n | { mode: \"notCountry\"; countries: string[] }\n | { mode: \"predicate\"; test: (geo?: any) => boolean }\n> = {\n \"/global\": { mode: \"country\", countries: [\"India\"] },\n \"/\": { mode: \"notCountry\", countries: [\"India\"] },\n};\n\n// Elements\nconst ipBannerMain = '[fynd-navigation=\"ip-banner\"]';\nconst ipBannerInner = '[fynd-navigation=\"ip-banner-inner\"]';\nconst closeIpBanner = '[fynd-navigation=\"ip-banner-close\"]';\n\nconst announcementBar = document.querySelector('[fynd-navigation=\"announcement-bar\"]');\nconst announcementList = document.querySelector('[fynd-navigation=\"announcement-list\"]');\n\n// Global navigation state\nconst navigationData = {\n ipbanner: {\n visibility: false,\n height: { desktop: \"56px\", tablet: \"60px\", mobileLandscape: \"120px\", mobilePortrait: \"120px\" },\n },\n announcementbar: {\n visibility: true,\n height: { desktop: \"40px\", tablet: \"40px\", mobileLandscape: \"40px\", mobilePortrait: \"46px\" },\n },\n default: {\n visibility: true,\n height: { desktop: \"70px\", tablet: \"64px\", mobileLandscape: \"40px\", mobilePortrait: \"64px\" },\n },\n};\n(window as any).navigationData = navigationData;\n\n// --- Utils -------------------------------------------------------------------\n\nfunction addPx(a: string | number, b: string | number): string {\n const toNumber = (val: string | number): number => {\n if (typeof val === \"number\") return val;\n const num = parseInt(val, 10);\n return isNaN(num) ? 0 : num;\n };\n return `${toNumber(a) + toNumber(b)}px`;\n}\n\nfunction subtractPx(a: string | number, b: string | number): string {\n const toNumber = (val: string | number): number => {\n if (typeof val === \"number\") return val;\n const num = parseInt(val, 10);\n return isNaN(num) ? 0 : num;\n };\n return `${toNumber(a) - toNumber(b)}px`;\n}\n\nconst normalizePath = (p: string) => {\n try {\n const urlPath = p.split(\"?\")[0].split(\"#\")[0];\n if (urlPath === \"/\") return \"/\";\n return urlPath.replace(/\\/+$/, \"\") || \"/\";\n } catch {\n return \"/\";\n }\n};\n\n// Longest-prefix match, so \"/india/offers\" matches \"/india\"\nfunction getMatchingRule(pathname: string) {\n const path = normalizePath(pathname);\n let bestKey = \"\";\n for (const key of Object.keys(bannerRouteRules)) {\n const normKey = normalizePath(key);\n if (path === normKey || path.startsWith(normKey + \"/\")) {\n if (normKey.length > bestKey.length) bestKey = normKey;\n }\n }\n return bestKey ? { key: bestKey, rule: bannerRouteRules[bestKey] } : null;\n}\n\nfunction shouldOpenBannerForPage(pathname: string, geo?: { country?: string }) {\n const match = getMatchingRule(pathname);\n if (!match) return false;\n\n const { rule } = match;\n const visitorCountry = (geo?.country || \"\").toLowerCase();\n\n switch (rule.mode) {\n case \"always\":\n return true;\n case \"country\":\n return rule.countries.some((c) => c.toLowerCase() === visitorCountry);\n case \"notCountry\":\n return !rule.countries.some((c) => c.toLowerCase() === visitorCountry);\n case \"predicate\":\n return !!rule.test?.(geo);\n default:\n return false;\n }\n}\n\n// --- Announcement Bar --------------------------------------------------------\n\nfunction initAnnouncementBar() {\n const swiperEl = document.querySelector<HTMLElement>('[fynd-navigation=\"announcement-swiper\"]');\n\n // Initialize swiper if present\n if (swiperEl && !(swiperEl as any).__swiperInstance) {\n try {\n const Swiper = (window as any).Swiper;\n const swiper = new Swiper(swiperEl, {\n slidesPerView: 1,\n spaceBetween: 0,\n effect: \"fade\",\n fadeEffect: { crossFade: true },\n autoplay: { delay: 3000, disableOnInteraction: false },\n loop: true,\n speed: 1000,\n allowTouchMove: false,\n on: {\n init: function (this: any): void {\n if (this.slides.length <= 1 && this.autoplay && typeof this.autoplay.stop === \"function\") {\n this.autoplay.stop();\n }\n },\n },\n });\n (swiperEl as any).__swiperInstance = swiper;\n } catch (err) {\n console.warn(\"Announcement Swiper init failed:\", err);\n }\n }\n\n // Visibility & cleanup\n if (announcementBar && announcementList && announcementList.children.length > 0) {\n navigationData.announcementbar.visibility = true;\n } else {\n navigationData.announcementbar.visibility = false;\n if (announcementBar && announcementBar.parentNode) {\n if (swiperEl && (swiperEl as any).__swiperInstance) {\n (swiperEl as any).__swiperInstance.destroy(true, true);\n (swiperEl as any).__swiperInstance = undefined;\n }\n announcementBar.parentNode.removeChild(announcementBar);\n }\n }\n}\n\n// --- Desktop Dropdown Positioning -------------------------------------------\n\nfunction initDesktopDropdownMenu() {\n const selector = '[fynd-navigation=\"dropdown-container\"]';\n const el = document.querySelector<HTMLElement>(selector);\n if (!el) {\n console.warn(`initDesktopDropdownMenu: element not found: ${selector}`);\n return;\n }\n\n const screenType = getScreenType?.() ?? \"unknown\";\n\n // Not desktop \u2192 reset transform\n if (screenType !== \"desktop\") {\n el.style.transition = el.style.transition || \"transform 0.3s ease\";\n el.style.transform = \"translateY(0px)\";\n return;\n }\n\n // Compute total stacked height\n let total = navigationData.default.height?.[screenType];\n let subtractFlag = false;\n\n if (navigationData.announcementbar?.visibility) {\n const h = navigationData.announcementbar.height?.[screenType];\n total = addPx(total, h);\n total = subtractPx(total,\"46px\");\n subtractFlag= true;\n }\n\n if (navigationData.ipbanner?.visibility) {\n // Currently not offsetting desktop for IP banner\n const h = \"0px\";\n total = addPx(total, h);\n if(!subtractFlag){\n total = subtractPx(total,\"46px\");\n }\n }\n\n // Offset dropdown under nav (minus header overlap 46px)\n el.style.transform = `translateY(${total})`;\n}\n\n// --- Dynamic Spacer ----------------------------------------------------------\n\nfunction initNavigationSpacer() {\n const spacer = document.querySelector<HTMLElement>(\n '[fynd-navigation=\"spacer\"][data-wf--navigation-spacer--variant=\"dynamic\"]'\n );\n\n if (!spacer) {\n console.warn(\"initNavigationSpacer: spacer element not found\");\n return;\n }\n\n const toPx = (v?: string | number): number => {\n if (typeof v === \"number\") return v;\n if (typeof v === \"string\") {\n const n = parseFloat(v);\n return Number.isFinite(n) ? n : 0;\n }\n return 0;\n };\n\n const screenType = getScreenType?.() ?? \"desktop\";\n let total = navigationData.default.height?.[screenType];\n\n if (navigationData.announcementbar?.visibility) {\n const h = navigationData.announcementbar.height?.[screenType];\n total = addPx(total, h);\n }\n\n if (navigationData.ipbanner?.visibility) {\n const h = toPx(navigationData.ipbanner.height?.[screenType]);\n total = addPx(total, h);\n }\n\n spacer.style.height = `${total}`;\n}\n\n// --- IP Banner ---------------------------------------------------------------\n\nasync function initIpBanner() {\n const ipClosed = getCookie(\"ipBannerClosed\") === \"true\";\n if (ipClosed) {\n navigationData.ipbanner.visibility = false;\n return;\n }\n\n const geo = await getGeolocationCached();\n const path = window.location.pathname || \"/\";\n const allowByRoute = shouldOpenBannerForPage(path, geo ?? undefined);\n\n const countryReady = await initCountryDetection();\n\n if (allowByRoute && countryReady) {\n openBanner(ipBannerMain, ipBannerInner, navigationData.ipbanner.height.desktop);\n navigationData.ipbanner.visibility = true;\n\n const closeBtn = document.querySelector<HTMLElement>(closeIpBanner);\n if (closeBtn) {\n closeBtn.addEventListener(\"click\", () => {\n closeBanner(ipBannerMain, ipBannerInner);\n setCookie(\"ipBannerClosed\", \"true\", 24);\n navigationData.ipbanner.visibility = false;\n initDesktopDropdownMenu();\n initNavigationSpacer();\n });\n }\n } else {\n navigationData.ipbanner.visibility = false;\n }\n}\n\n// --- Init --------------------------------------------------------------------\n\ndocument.addEventListener(\"DOMContentLoaded\", async () => {\n await initIpBanner();\n initAnnouncementBar();\n initDesktopDropdownMenu();\n initNavigationSpacer();\n});"],
|
|
5
|
-
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACIE,iBAAsB,iBAA0C;AAC9D,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,mBAAmB;AAChD,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,6BAA6B;AAAA,MAC/C;AAEA,YAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,UAAI,KAAK,YAAY,OAAO;AAC1B,gBAAQ,MAAM,8BAA8B,KAAK,OAAO;AACxD,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,QACL,IAAI,KAAK;AAAA,QACT,SAAS,KAAK;AAAA,QACd,QAAQ,KAAK;AAAA,QACb,MAAM,KAAK;AAAA,QACX,UAAU,KAAK;AAAA,QACf,WAAW,KAAK;AAAA,QAChB,KAAK,KAAK,YAAY,OAAO;AAAA,QAC7B,UAAU,KAAK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e,SAAS,aAAa;AAErC,YAAM,WAAW,SAAS,cAA2B,aAAa;AAClE,UAAI,UAAU;AACZ,iBAAS,iBAAiB,SAAS,MAAM;AACvC,sBAAY,cAAc,aAAa;AACvC,UAAAC,WAAU,kBAAkB,QAAQ,EAAE;AACtC,yBAAe,SAAS,aAAa;AACrC,kCAAwB;AACxB,+BAAqB;AAAA,QACvB,CAAC;AAAA,MACH;AAAA,IACF,OAAO;AACL,qBAAe,SAAS,aAAa;AAAA,IACvC;AAAA,EACF;AAIA,WAAS,iBAAiB,oBAAoB,YAAY;AACxD,UAAM,aAAa;AACnB,wBAAoB;AACpB,4BAAwB;AACxB,yBAAqB;AAAA,EACvB,CAAC;",
|
|
4
|
+
"sourcesContent": ["// Only enable live reload when running on localhost\nif (\n window.location.hostname === \"localhost\" ||\n window.location.hostname === \"127.0.0.1\"\n) {\n new EventSource(`${SERVE_ORIGIN}/esbuild`).addEventListener(\"change\", () =>\n location.reload()\n );\n} else {\n // console.log(\"Live reload disabled: not running on localhost\");\n}\n", "// Define the type for returned geolocation data\n// Remider for adding Fallback: ipinfo.io (HTTPS, requires token)\nexport type GeoData = {\n ip: string;\n country: string;\n region: string;\n city: string;\n latitude: number;\n longitude: number;\n isp: string;\n timezone: string;\n };\n \n // Exported function that can be reused anywhere\n export async function getGeolocation(): Promise<GeoData | null> {\n try {\n const response = await fetch(\"https://ipwho.is/\");\n if (!response.ok) {\n throw new Error(\"Failed to fetch geolocation\");\n }\n \n const data = await response.json();\n \n if (data.success === false) {\n console.error(\"Geolocation lookup failed:\", data.message);\n return null;\n }\n \n return {\n ip: data.ip,\n country: data.country,\n region: data.region,\n city: data.city,\n latitude: data.latitude,\n longitude: data.longitude,\n isp: data.connection?.isp || \"\",\n timezone: data.timezone?.id || \"\"\n };\n } catch (error) {\n console.error(\"Error fetching geolocation:\", error);\n return null;\n }\n }\n\n //used in /src/navigation/initialization.ts for displaying ip banner", "import { GeoData, getGeolocation } from \"./main\";\n\nconst GEO_CACHE_KEY = \"geo:data:v1\";\nconst GEO_COOKIE_KEY = \"geo_country\";\nconst GEO_TTL_MS = 7 * 24 * 60 * 60 * 1000; // 7 days\n\ntype Cached<T> = { data: T; expiresAt: number };\n\n// --- Cookie helpers ---\nfunction setCookie(name: string, value: string, maxAgeSec: number) {\n document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(\n value\n )}; Max-Age=${maxAgeSec}; Path=/; SameSite=Lax; Secure`;\n}\n\nfunction getCookie(name: string): string | null {\n const key = `${encodeURIComponent(name)}=`;\n const parts = document.cookie.split(\"; \");\n for (const p of parts) {\n if (p.startsWith(key)) return decodeURIComponent(p.slice(key.length));\n }\n return null;\n}\n\nfunction clearCookie(name: string) {\n document.cookie = `${encodeURIComponent(\n name\n )}=; Max-Age=0; Path=/; SameSite=Lax; Secure`;\n}\n\n// --- LocalStorage helpers ---\nfunction readCache<T>(key: string): T | null {\n try {\n const raw = localStorage.getItem(key);\n if (!raw) return null;\n const parsed = JSON.parse(raw) as Cached<T>;\n if (!parsed?.expiresAt || Date.now() > parsed.expiresAt) {\n localStorage.removeItem(key);\n return null;\n }\n return parsed.data;\n } catch {\n localStorage.removeItem(key);\n return null;\n }\n}\n\nfunction writeCache<T>(key: string, data: T, ttlMs: number) {\n const payload: Cached<T> = { data, expiresAt: Date.now() + ttlMs };\n try {\n localStorage.setItem(key, JSON.stringify(payload));\n } catch {\n // ignore quota errors\n }\n}\n\n// --- Public API ---\nexport async function getGeolocationCached(options?: {\n forceRefresh?: boolean;\n}): Promise<GeoData | null> {\n if (typeof window === \"undefined\") return null;\n\n const forceRefresh = options?.forceRefresh ?? false;\n\n if (!forceRefresh) {\n const cached = readCache<GeoData>(GEO_CACHE_KEY);\n if (cached) {\n (window as any).__GEO = cached;\n if (!getCookie(GEO_COOKIE_KEY)) {\n setCookie(\n GEO_COOKIE_KEY,\n cached.country ?? \"\",\n Math.floor(GEO_TTL_MS / 1000)\n );\n }\n return cached;\n }\n }\n\n // \u2B07\uFE0F changed block starts here\n let geo: GeoData | null = null;\n try {\n geo = await getGeolocation();\n } catch (e) {\n console.warn(\"getGeolocation() failed; defaulting to India:\", e);\n }\n\n if (!geo) {\n // Fallback to India if the fetch failed or returned invalid data\n geo = { country: \"India\" } as GeoData;\n }\n\n writeCache(GEO_CACHE_KEY, geo, GEO_TTL_MS);\n setCookie(GEO_COOKIE_KEY, geo.country ?? \"\", Math.floor(GEO_TTL_MS / 1000));\n (window as any).__GEO = geo;\n return geo;\n // \u2B06\uFE0F changed block ends here\n}\n\nexport function getGeoCountryFromCookie(): string | null {\n return getCookie(GEO_COOKIE_KEY);\n}\n\nexport function clearGeolocationCache() {\n try {\n localStorage.removeItem(GEO_CACHE_KEY);\n } catch {}\n clearCookie(GEO_COOKIE_KEY);\n if (typeof window !== \"undefined\") {\n (window as any).__GEO = undefined;\n }\n}\n", "// toggleBanner.ts\n// Utility functions to open/close a banner using GSAP with optional target height.\n\nexport function openBanner(\n mainSelector: string,\n innerSelector: string,\n targetHeight: string | number = \"auto\" // default stays \"auto\"\n) {\n const w = (window as any) || {};\n const gsap = w.gsap as any;\n if (!gsap) {\n console.warn(\"GSAP not found on window. Did you include it globally?\");\n return;\n }\n\n const mainEl = document.querySelector<HTMLElement>(mainSelector);\n const innerEl = document.querySelector<HTMLElement>(innerSelector);\n\n if (!mainEl || !innerEl) {\n console.warn(\"openBanner: Element(s) not found for selectors:\", {\n mainSelector,\n innerSelector,\n });\n return;\n }\n\n // Ensure clean start\n gsap.set(mainEl, { height: 0, overflow: \"hidden\" });\n gsap.set(innerEl, { opacity: 0 });\n\n const tl = gsap.timeline();\n\n // Animate main from height: 0 -> targetHeight\n tl.to(mainEl, {\n height: targetHeight,\n duration: 0.5,\n ease: \"power2.out\",\n });\n\n // After 0.2s, fade inner to 1\n tl.to(\n innerEl,\n {\n opacity: 1,\n duration: 0.3,\n ease: \"power1.out\",\n },\n 0.2\n );\n\n return tl;\n}\n\nexport function closeBanner(\n mainSelector: string,\n innerSelector: string,\n targetHeight: string | number = 0 // default collapse fully\n) {\n const w = (window as any) || {};\n const gsap = w.gsap as any;\n if (!gsap) {\n console.warn(\"GSAP not found on window. Did you include it globally?\");\n return;\n }\n\n const mainEl = document.querySelector<HTMLElement>(mainSelector);\n const innerEl = document.querySelector<HTMLElement>(innerSelector);\n\n if (!mainEl || !innerEl) {\n console.warn(\"closeBanner: Element(s) not found for selectors:\", {\n mainSelector,\n innerSelector,\n });\n return;\n }\n\n gsap.set(mainEl, { overflow: \"hidden\" });\n\n const tl = gsap.timeline();\n\n // Fade inner out\n tl.to(innerEl, {\n opacity: 0,\n duration: 0.25,\n ease: \"power1.out\",\n });\n\n // Collapse height to targetHeight (default 0)\n tl.to(\n mainEl,\n {\n height: targetHeight,\n duration: 0.45,\n ease: \"power2.inOut\",\n },\n 0.2\n );\n\n return tl;\n}", "export function setCookie(name: string, value: string, hours: number) {\n const date = new Date();\n date.setTime(date.getTime() + hours * 60 * 60 * 1000);\n document.cookie = `${name}=${value}; expires=${date.toUTCString()}; path=/`;\n }\n \n export function getCookie(name: string): string | null {\n const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));\n return match ? match[2] : null;\n }", "// screen-type.ts\n// Utility to get the current screen type\n// Breakpoints:\n// - Desktop: 992px+\n// - Tablet: 768px\u2013991px\n// - Mobile Landscape: 480px\u2013767px\n// - Mobile Portrait: under 480px\n\nexport type ScreenType = \"desktop\" | \"tablet\" | \"mobileLandscape\" | \"mobilePortrait\";\n\nexport function getScreenType(): ScreenType {\n const width = window.innerWidth;\n\n if (width >= 992) {\n return \"desktop\";\n } else if (width >= 768) {\n return \"tablet\";\n } else if (width >= 480) {\n return \"mobileLandscape\";\n } else {\n return \"mobilePortrait\";\n }\n}", "// geo.ts\nimport { getGeoCountryFromCookie, getGeolocationCached } from \"src/global/geolocation/geolocation-cached\";\nimport { GeoData } from \"src/global/geolocation/main\";\n\n/** Your banner config */\ntype CountryConfig = {\n country: string; // canonical lowercase name\n countryCode: string; // ISO-2 lowercase code (e.g., \"in\")\n url: string; // leading-slash path (e.g., \"/in\")\n tagline: string; // banner text/html\n aliases?: string[]; // optional extra names to match against\n};\n\nexport const COUNTRY_CONFIG: CountryConfig[] = [\n {\n country: \"united arab emirates\",\n aliases: [\"uae\", \"u.a.e\", \"united arab emirates\"],\n countryCode: \"ae\",\n url: \"/ae\",\n tagline: \"You're in the UAE. Welcome!\"\n },\n {\n country: \"saudi arabia\",\n aliases: [\"saudi\", \"ksa\", \"kingdom of saudi arabia\"],\n countryCode: \"sa\",\n url: \"/sa\",\n tagline: \"Hello Saudi Arabia!\"\n },\n {\n country: \"south africa\",\n aliases: [\"rsa\"],\n countryCode: \"za\",\n url: \"/za\",\n tagline: \"Hi South Africa!\"\n },\n {\n country: \"malaysia\",\n countryCode: \"my\",\n url: \"/my\",\n tagline: \"Selamat datang, Malaysia!\"\n },\n {\n country: \"indonesia\",\n aliases: [\"idn\"],\n countryCode: \"id\",\n url: \"/id\",\n tagline: \"Halo Indonesia!\"\n },\n {\n country: \"philippines\",\n aliases: [\"phl\", \"the philippines\"],\n countryCode: \"ph\",\n url: \"/ph\",\n tagline: \"Kumusta, Philippines!\"\n },\n {\n country: \"india\",\n aliases: [\"bharat\"],\n countryCode: \"in\",\n url: \"/in\",\n tagline: \"This country is India. Hi some text\"\n },\n // \uD83D\uDC47 fallback\n {\n country: \"global\",\n aliases: [\"global\", \"rest of world\", \"others\"],\n countryCode: \"global\", // keep lowercase for consistency\n url: \"/global\",\n tagline: \"This is rest of world. Hi some text\"\n }\n];\n\n/** Utility: normalize strings for comparisons */\nfunction norm(s: string | null | undefined): string {\n return (s ?? \"\").trim().toLowerCase();\n}\n\n/** Utility: ensure URL starts with a single leading slash */\nfunction toPath(path: string): string {\n const p = path.trim();\n if (!p) return \"/\";\n return p.startsWith(\"/\") ? p : `/${p}`;\n}\n\n/** Determine user's country as a *string* (might be name or code depending on your geo source) */\nexport async function getUserCountry(): Promise<string | null> {\n if (typeof window === \"undefined\") return null;\n\n // 1) Cookie fast-path\n const cookieCountry = getGeoCountryFromCookie();\n if (cookieCountry) return norm(cookieCountry);\n\n // 2) Cached or network\n const geo: GeoData | null = await getGeolocationCached();\n return norm((geo as any)?.country);\n}\n\n/** Find matching config by country *name* or *ISO-2 code* with aliases */\nfunction findCountryConfig(input: string | null): CountryConfig | null {\n const v = norm(input);\n if (!v) return null;\n\n const byCode = COUNTRY_CONFIG.find(c => norm(c.countryCode) === v);\n if (byCode) return byCode;\n\n const byName = COUNTRY_CONFIG.find(c => norm(c.country) === v);\n if (byName) return byName;\n\n const byAlias = COUNTRY_CONFIG.find(c => (c.aliases ?? []).some(a => norm(a) === v));\n if (byAlias) return byAlias;\n\n return null;\n}\n\n/** Helper to fetch the global config */\nfunction getGlobalConfig(): CountryConfig {\n const g = COUNTRY_CONFIG.find(c => c.country === \"global\");\n if (!g) throw new Error(\"[geo-banner] Global config not found in COUNTRY_CONFIG\");\n return g;\n}\n\nfunction updateBannerLink(countryCode?: string | null): void {\n if (typeof window === \"undefined\") return;\n\n const code = norm(countryCode);\n const conf =\n COUNTRY_CONFIG.find(c => norm(c.countryCode) === code) ||\n getGlobalConfig();\n\n const linkEl = document.querySelector<HTMLAnchorElement>('[fynd-banner-field=\"link\"]');\n if (linkEl) {\n const base = window.location.origin;\n linkEl.href = `${base}${toPath(conf.url)}`;\n }\n}\n\nexport function setSelectValueSafely(selectEl: HTMLSelectElement, desired: string) {\n // 1) resolve config\n const conf =\n findCountryConfig(desired) ??\n COUNTRY_CONFIG.find(c => c.country === \"global\");\n if (!conf) {\n console.warn(\"[geo-banner] No matching config for\", desired);\n return false;\n }\n const desiredCode = conf.countryCode; // assume already normalized/lowercase\n\n // 2) find matching option (normalize both sides)\n const opts = Array.from(selectEl.options);\n const opt = opts.find(o => norm(o.value) === norm(desiredCode));\n if (!opt) {\n console.warn(\"[geo-banner] No matching <option> for\", desiredCode, \"on\", selectEl);\n return false;\n }\n\n // 3) update the <select> itself (more reliable than toggling option.selected)\n const prev = selectEl.value;\n selectEl.value = opt.value;\n\n // if some browsers/frameworks didn\u2019t adopt .value, force selectedIndex too\n if (selectEl.value !== opt.value) {\n selectEl.selectedIndex = opts.indexOf(opt);\n }\n\n // 4) (optional) keep options\u2019 selected flags in sync\n opts.forEach(o => (o.selected = o === opt));\n\n // 5) fire events frameworks listen to\n if (prev !== selectEl.value) {\n selectEl.dispatchEvent(new Event(\"input\", { bubbles: true }));\n selectEl.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n console.log(\"[geo-banner] Select updated \u2192\", conf.country, \"(\", conf.countryCode, \")\");\n return true;\n}\n\n/** Update the banner content for a given countryCode (lowercase ISO-2) with global fallback */\nexport function updateBannerContent(countryCode?: string | null): void {\n if (typeof window === \"undefined\") return;\n\n const code = norm(countryCode);\n const conf =\n COUNTRY_CONFIG.find(c => norm(c.countryCode) === code) ||\n getGlobalConfig();\n // 1) Set <select fynd-banner-field=\"geoswitch\"> value (robustly)\n const selectEl =\n document.querySelector<HTMLSelectElement>('#geoswitch-select') ||\n document.querySelector<HTMLSelectElement>('[fynd-banner-field=\"geoswitch\"]');\n\n if (selectEl) {\n console.log(`country code is ${conf.countryCode}`)\n setSelectValueSafely(selectEl, conf.countryCode);\n selectEl.value = conf.countryCode; // or \"global\", etc.\n\n selectEl.dispatchEvent(new Event(\"change\", { bubbles: true }));\n } else {\n console.warn('[geo-banner] Select not found: #geoswitch-select / [fynd-banner-field=\"geoswitch\"]');\n }\n\n // // 2) Update banner text (unchanged)\n // const textEl = document.querySelector<HTMLElement>('[fynd-banner-field=\"banner-text\"]');\n // if (textEl) textEl.innerHTML = conf.tagline;\n\n // 3) Update link href (unchanged)\n const linkEl = document.querySelector<HTMLAnchorElement>('[fynd-banner-field=\"link\"]');\n if (linkEl) {\n const base = window.location.origin;\n linkEl.href = `${base}${toPath(conf.url)}`;\n }\n}\n\n/**\n * Main entry: detect country and update banner if it matches one of the configured countries.\n * Always falls back to global if no match is found.\n */\nexport async function initCountryDetection(): Promise<CountryConfig> {\n if (typeof window === \"undefined\") return getGlobalConfig();\n\n if (document.readyState === \"loading\") {\n await new Promise<void>(resolve => {\n document.addEventListener(\"DOMContentLoaded\", () => resolve(), { once: true });\n });\n }\n\n const rawCountry = await getUserCountry();\n const match = findCountryConfig(rawCountry);\n const resolved = match ?? getGlobalConfig();\n\n // Debug visibility\n console.log(\"[geo-banner] rawCountry:\", rawCountry, \"\u2192 resolved:\", resolved.countryCode);\n\n // \u2705 Always update from the resolved config (guarantees global fallback)\n updateBannerContent(resolved.countryCode);\n\n // (If you also attached the select change listener, keep that here)\n const selectEl = document.querySelector<HTMLSelectElement>('[fynd-banner-field=\"geoswitch\"]');\n if (selectEl && !(selectEl as any).__geoHandlerAttached) {\n selectEl.addEventListener(\"change\", (e) => {\n const value = (e.target as HTMLSelectElement).value;\n updateBannerLink(value); // only updates href on change\n });\n (selectEl as any).__geoHandlerAttached = true;\n }\n\n return resolved;\n}", "import { getGeolocationCached } from \"src/global/geolocation/geolocation-cached\";\nimport { closeBanner, openBanner } from \"src/global/animation/toggle-banner\";\nimport { getCookie, setCookie } from \"$utils/cookies\";\nimport { getScreenType } from \"src/global/screen-type\";\nimport { initCountryDetection } from \"./country-detection/main\";\n\n/**\n * Banner rules by route (normalized, no trailing slash).\n * Modes:\n * - { mode: \"always\" }\n * - { mode: \"country\", countries: [...] } \u2192 open if geo.country matches (case-insensitive)\n * - { mode: \"notCountry\", countries: [...] } \u2192 open if geo.country does NOT match\n * - { mode: \"predicate\", test: (geo) => boolean }\n */\nconst bannerRouteRules: Record<\n string,\n | { mode: \"always\" }\n | { mode: \"country\"; countries: string[] }\n | { mode: \"notCountry\"; countries: string[] }\n | { mode: \"predicate\"; test: (geo?: any) => boolean }\n> = {\n \"/global\": { mode: \"country\", countries: [\"India\"] },\n \"/\": { mode: \"notCountry\", countries: [\"India\"] },\n};\n\n// Elements\nconst ipBannerMain = '[fynd-navigation=\"ip-banner\"]';\nconst ipBannerInner = '[fynd-navigation=\"ip-banner-inner\"]';\nconst closeIpBanner = '[fynd-navigation=\"ip-banner-close\"]';\n\nconst announcementBar = document.querySelector('[fynd-navigation=\"announcement-bar\"]');\nconst announcementList = document.querySelector('[fynd-navigation=\"announcement-list\"]');\n\n// Global navigation state\nconst navigationData = {\n ipbanner: {\n visibility: false,\n height: { desktop: \"56px\", tablet: \"60px\", mobileLandscape: \"120px\", mobilePortrait: \"120px\" },\n },\n announcementbar: {\n visibility: true,\n height: { desktop: \"40px\", tablet: \"40px\", mobileLandscape: \"40px\", mobilePortrait: \"46px\" },\n },\n default: {\n visibility: true,\n height: { desktop: \"70px\", tablet: \"64px\", mobileLandscape: \"40px\", mobilePortrait: \"64px\" },\n },\n};\n(window as any).navigationData = navigationData;\n\n// --- Utils -------------------------------------------------------------------\n\nfunction addPx(a: string | number, b: string | number): string {\n const toNumber = (val: string | number): number => {\n if (typeof val === \"number\") return val;\n const num = parseInt(val, 10);\n return isNaN(num) ? 0 : num;\n };\n return `${toNumber(a) + toNumber(b)}px`;\n}\n\nfunction subtractPx(a: string | number, b: string | number): string {\n const toNumber = (val: string | number): number => {\n if (typeof val === \"number\") return val;\n const num = parseInt(val, 10);\n return isNaN(num) ? 0 : num;\n };\n return `${toNumber(a) - toNumber(b)}px`;\n}\n\nconst normalizePath = (p: string) => {\n try {\n const urlPath = p.split(\"?\")[0].split(\"#\")[0];\n if (urlPath === \"/\") return \"/\";\n return urlPath.replace(/\\/+$/, \"\") || \"/\";\n } catch {\n return \"/\";\n }\n};\n\n// Longest-prefix match, so \"/india/offers\" matches \"/india\"\nfunction getMatchingRule(pathname: string) {\n const path = normalizePath(pathname);\n let bestKey = \"\";\n for (const key of Object.keys(bannerRouteRules)) {\n const normKey = normalizePath(key);\n if (path === normKey || path.startsWith(normKey + \"/\")) {\n if (normKey.length > bestKey.length) bestKey = normKey;\n }\n }\n return bestKey ? { key: bestKey, rule: bannerRouteRules[bestKey] } : null;\n}\n\nfunction shouldOpenBannerForPage(pathname: string, geo?: { country?: string }) {\n const match = getMatchingRule(pathname);\n if (!match) return false;\n\n const { rule } = match;\n const visitorCountry = (geo?.country || \"\").toLowerCase();\n\n switch (rule.mode) {\n case \"always\":\n return true;\n case \"country\":\n return rule.countries.some((c) => c.toLowerCase() === visitorCountry);\n case \"notCountry\":\n return !rule.countries.some((c) => c.toLowerCase() === visitorCountry);\n case \"predicate\":\n return !!rule.test?.(geo);\n default:\n return false;\n }\n}\n\n// --- Announcement Bar --------------------------------------------------------\n\nfunction initAnnouncementBar() {\n const swiperEl = document.querySelector<HTMLElement>('[fynd-navigation=\"announcement-swiper\"]');\n\n // Initialize swiper if present\n if (swiperEl && !(swiperEl as any).__swiperInstance) {\n try {\n const Swiper = (window as any).Swiper;\n const swiper = new Swiper(swiperEl, {\n slidesPerView: 1,\n spaceBetween: 0,\n effect: \"fade\",\n fadeEffect: { crossFade: true },\n autoplay: { delay: 3000, disableOnInteraction: false },\n loop: true,\n speed: 1000,\n allowTouchMove: false,\n on: {\n init: function (this: any): void {\n if (this.slides.length <= 1 && this.autoplay && typeof this.autoplay.stop === \"function\") {\n this.autoplay.stop();\n }\n },\n },\n });\n (swiperEl as any).__swiperInstance = swiper;\n } catch (err) {\n console.warn(\"Announcement Swiper init failed:\", err);\n }\n }\n\n // Visibility & cleanup\n if (announcementBar && announcementList && announcementList.children.length > 0) {\n navigationData.announcementbar.visibility = true;\n } else {\n navigationData.announcementbar.visibility = false;\n if (announcementBar && announcementBar.parentNode) {\n if (swiperEl && (swiperEl as any).__swiperInstance) {\n (swiperEl as any).__swiperInstance.destroy(true, true);\n (swiperEl as any).__swiperInstance = undefined;\n }\n announcementBar.parentNode.removeChild(announcementBar);\n }\n }\n}\n\n// --- Desktop Dropdown Positioning -------------------------------------------\n\nfunction initDesktopDropdownMenu() {\n const selector = '[fynd-navigation=\"dropdown-container\"]';\n const el = document.querySelector<HTMLElement>(selector);\n if (!el) {\n console.warn(`initDesktopDropdownMenu: element not found: ${selector}`);\n return;\n }\n\n const screenType = getScreenType?.() ?? \"unknown\";\n\n // Not desktop \u2192 reset transform\n if (screenType !== \"desktop\") {\n el.style.transition = el.style.transition || \"transform 0.3s ease\";\n el.style.transform = \"translateY(0px)\";\n return;\n }\n\n // Compute total stacked height\n let total = navigationData.default.height?.[screenType];\n let subtractFlag = false;\n\n if (navigationData.announcementbar?.visibility) {\n const h = navigationData.announcementbar.height?.[screenType];\n total = addPx(total, h);\n total = subtractPx(total,\"46px\");\n subtractFlag= true;\n }\n\n if (navigationData.ipbanner?.visibility) {\n // Currently not offsetting desktop for IP banner\n const h = \"0px\";\n total = addPx(total, h);\n if(!subtractFlag){\n total = subtractPx(total,\"46px\");\n }\n }\n\n // Offset dropdown under nav (minus header overlap 46px)\n el.style.transform = `translateY(${total})`;\n}\n\n// --- Dynamic Spacer ----------------------------------------------------------\n\nfunction initNavigationSpacer() {\n const spacer = document.querySelector<HTMLElement>(\n '[fynd-navigation=\"spacer\"][data-wf--navigation-spacer--variant=\"dynamic\"]'\n );\n\n if (!spacer) {\n console.warn(\"initNavigationSpacer: spacer element not found\");\n return;\n }\n\n const toPx = (v?: string | number): number => {\n if (typeof v === \"number\") return v;\n if (typeof v === \"string\") {\n const n = parseFloat(v);\n return Number.isFinite(n) ? n : 0;\n }\n return 0;\n };\n\n const screenType = getScreenType?.() ?? \"desktop\";\n let total = navigationData.default.height?.[screenType];\n\n if (navigationData.announcementbar?.visibility) {\n const h = navigationData.announcementbar.height?.[screenType];\n total = addPx(total, h);\n }\n\n if (navigationData.ipbanner?.visibility) {\n const h = toPx(navigationData.ipbanner.height?.[screenType]);\n total = addPx(total, h);\n }\n\n spacer.style.height = `${total}`;\n}\n\n// --- IP Banner ---------------------------------------------------------------\n\nasync function initIpBanner() {\n const ipClosed = getCookie(\"ipBannerClosed\") === \"true\";\n if (ipClosed) {\n navigationData.ipbanner.visibility = false;\n return;\n }\n\n const geo = await getGeolocationCached();\n const path = window.location.pathname || \"/\";\n const allowByRoute = shouldOpenBannerForPage(path, geo ?? undefined);\n\n const countryReady = await initCountryDetection();\n\n if (allowByRoute && countryReady) {\n openBanner(ipBannerMain, ipBannerInner, navigationData.ipbanner.height.desktop);\n navigationData.ipbanner.visibility = true;\n\n const closeBtn = document.querySelector<HTMLElement>(closeIpBanner);\n if (closeBtn) {\n closeBtn.addEventListener(\"click\", () => {\n closeBanner(ipBannerMain, ipBannerInner);\n setCookie(\"ipBannerClosed\", \"true\", 24);\n navigationData.ipbanner.visibility = false;\n initDesktopDropdownMenu();\n initNavigationSpacer();\n });\n }\n } else {\n navigationData.ipbanner.visibility = false;\n }\n}\n\n// --- Init --------------------------------------------------------------------\n\ndocument.addEventListener(\"DOMContentLoaded\", async () => {\n await initIpBanner();\n initAnnouncementBar();\n initDesktopDropdownMenu();\n initNavigationSpacer();\n});"],
|
|
5
|
+
"mappings": ";;;AACA,MACE,OAAO,SAAS,aAAa,eAC7B,OAAO,SAAS,aAAa,aAC7B;AACA,QAAI,YAAY,GAAG,uBAAY,UAAU,EAAE;AAAA,MAAiB;AAAA,MAAU,MACpE,SAAS,OAAO;AAAA,IAClB;AAAA,EACF,OAAO;AAAA,EAEP;;;ACIE,iBAAsB,iBAA0C;AAC9D,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,mBAAmB;AAChD,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,6BAA6B;AAAA,MAC/C;AAEA,YAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,UAAI,KAAK,YAAY,OAAO;AAC1B,gBAAQ,MAAM,8BAA8B,KAAK,OAAO;AACxD,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,QACL,IAAI,KAAK;AAAA,QACT,SAAS,KAAK;AAAA,QACd,QAAQ,KAAK;AAAA,QACb,MAAM,KAAK;AAAA,QACX,UAAU,KAAK;AAAA,QACf,WAAW,KAAK;AAAA,QAChB,KAAK,KAAK,YAAY,OAAO;AAAA,QAC7B,UAAU,KAAK,UAAU,MAAM;AAAA,MACjC;AAAA,IACF,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