<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">;(function ($, w) {
	'use strict';
	if (!w.jQuery) {
		throw 'funMain: jQuery not found';
	}
	w.funMain = {
		isDemo: typeof funBase == "undefined",
		form: $('#demo-wheel-form'),

		config: {
			campaigns: typeof funBase != "undefined" ? funBase.config.campaigns : [
				{
					segmentsForSpin: [],
					arrSegmentsList: [],
				}
			],
			theWheel: [],
			arrsp: [],
			strarr: "",
			wheelSpinning: false,
			audio : new Audio('https://cdn.dfikir.com/shared/spinsound.mp3'),
			cookieExpiredDay: 1
		},

		init: function () {
			var self = this;

			df_modal.init();
			funMain.eventListener();
			

			if (funMain.isDemo) {
				self.demoInputStateUpdate();
				self.createDemoCampaigns();

				$.each(funMain.config.campaigns, function (index, campaign) {
					if (funMain.isDemo) {
						var setIntervalCount = 0;
						var intervalId = null;
						if (setIntervalCount &lt; 3) {
							intervalId = setInterval(function () {
								setIntervalCount++;
								funMain.whell.start(campaign, index);
								if (setIntervalCount &gt;= 3) {
									clearInterval(intervalId);
								}
							}, 700);
						}
						
						funMain.popup.init(campaign, index);
						funMain.scratch.init(campaign, index);
						funMain.gift.init(campaign, index);
						funMain.whell.init(campaign, index);
						
						funMain.setCustomCss(campaign);
					}
	
					/*if (campaign.active &amp;&amp; !funMain.isDemo) {
						$.post('https://functionality.dfikir.com/scripts/count', {'shop': funBase.config.shopUrl}).promise().done(function () {
							funMain.popup.init(campaign, index);
							funMain.scratch.init(campaign, index);
							funMain.gift.init(campaign, index);
							funMain.whell.init(campaign, index);
						});
					}*/
				});
			} else {
				funMain.localStorage.init();
				self.preview.init();

				self.targeting.init();

				$.each(funMain.config.campaigns, function (index, campaign) {
					let topbar = localStorage.getItem("dfFunTimer_" + campaign.id + 'Init');

					if (topbar &amp;&amp; funMain.visible) {
						funMain.helpers.topBarBuild(campaign);
					}
				});
				/*$.post('https://functionality.dfikir.com/scripts/count', {'shop': funBase.config.shopUrl}).promise().done(function () {
					
				});*/
			}
		},

		setCustomCss: function(campaign) {
			var customCss = campaign.customCss;
			if (customCss) {
				var style = document.createElement('style');
				style.textContent = customCss;
				document.head.appendChild(style);
			}
		},

		targeting: {
			init: function() {
				this.starting();
			},

			starting: function () {
				var self = this;

				$.each(funMain.config.campaigns, function (index, campaign) {
					if (!funMain.localStorage.isShown('dfFunShown_' + campaign.id)) {
						self.isValidViewCondition(campaign, index);
					}
				});
			},
		
			initCampaignComponents: function (campaign, index) {
				if (!funMain.localStorage.isShown('dfFunShown_' + campaign.id)) {
					funMain.popup.init(campaign, index);
					funMain.scratch.init(campaign, index);
					funMain.gift.init(campaign, index);
					funMain.whell.init(campaign, index);

					if (funMain.visible(campaign)) {
						funMain.setCustomCss(campaign);
					}
				}
			},
		
			isValidViewCondition: function (campaign, index) {
				var self = this;
			
				if (self.viewTarget(campaign) &amp;&amp; self.langTarget(campaign) &amp;&amp; self.paramTarget(campaign) &amp;&amp; self.deviceTarget(campaign)) {
					var viewCondition = campaign.viewCondition;
			
					if (viewCondition == 'userExit') {
						setTimeout(function () {
							self.userTarget.exitIntent(function () {
								self.initCampaignComponents(campaign, index);
							});
						}, 3500);
					} else if (viewCondition == 'afterScrolling' &amp;&amp; campaign.afterScrolling) {
						self.userTarget.afterScrolling(function () {
							self.initCampaignComponents(campaign, index);
						}, parseFloat(campaign.afterScrolling), parseFloat(campaign.wheelDelayTime));
					} else if (viewCondition == 'elementClicking' &amp;&amp; campaign.elementClicking) {
						self.userTarget.elementClicking(function () {
							self.initCampaignComponents(campaign, index);
						}, campaign.elementClicking, parseFloat(campaign.wheelDelayTime));
					} else {
						setTimeout(() =&gt; {
							self.initCampaignComponents(campaign, index);
						}, parseFloat(campaign.wheelDelayTime));
					}
				}
			},
			
		
			viewTarget: function (campaign) {
				var currentPage = window.location.pathname;
			
				if (campaign.viewPage == 'home' &amp;&amp; currentPage === '/') {
					return true;
				}
			
				if (campaign.viewPage == 'customPages' &amp;&amp; campaign.viewPagesUrl ) {
					var urls = campaign.viewPagesUrl.split(',');
			
					for (var i = 0; i &lt; urls.length; i++) {
						var url = urls[i].trim();
			
						if (url.includes('*')) {
							var normalizedUrl = url.replace('*', '');
							if (currentPage.startsWith(normalizedUrl) || currentPage.endsWith(normalizedUrl)) {
								return true;
							}
						} else {
							if (currentPage === url) {
								return true;
							}
						}
					}
			
					return false;
				}

				return true;
			},

			userTarget: {
				exitIntent: function (callback) {
					function addEvent(obj, evt, fn) {
						if (obj.addEventListener) {
							obj.addEventListener(evt, fn, false);
						} else if (obj.attachEvent) {
							obj.attachEvent("on" + evt, fn);
						}
					}
		
					addEvent(document, 'mouseout', function (evt) {
						evt = evt ? evt : window.event;
						var from = evt.relatedTarget || evt.toElement;
						if (!from || from.nodeName == "HTML") {
							callback();
						}
					});
				},
		
				afterScrolling: function (callback, scrollValue, stValue) {
					var scrolled = false; 

					var scrollHandler = function () {
						if (!scrolled &amp;&amp; window.scrollY &gt; scrollValue) {
							scrolled = true; 
							callback();
						}
					};
		
					window.addEventListener('scroll', scrollHandler);
				},
		
				elementClicking: function (callback, element, stValue) {
					$(document).on('click', element, function () {
						setTimeout(callback, stValue);
					});
				},
			},

			langTarget: function(campaign) {
				var locale = (navigator &amp;&amp; navigator.language) || "tr";

				if (campaign.browserLanguage &amp;&amp; campaign.browserLanguage != 'all') {
					var langs = campaign.browserLanguage.split(',');
					return langs.some(function (lang) {
						return locale === lang.trim();
					});
				}

				return true;
			},

			paramTarget: function (campaign) {
				var currentPage = window.location.search;
			
				if (campaign.trafficSource) {
					var params = campaign.trafficSource.split(',');

					for (var i = 0; i &lt; params.length; i++) {
						var param = params[i].trim();
			
						if (param.includes('*')) {
							var normalizedParam = param.replace('*', '');
							if (currentPage.includes(normalizedParam)) {
								return true;
							}
						} else {
							if (currentPage.includes(param)) {
								return true;
							}
						}
					}
			
					return false;
				}

				return true;
			},
			

			deviceTarget: function(campaign) {
				var isDesktop = window.matchMedia("(min-width: 1200px)").matches;
				var isMobileTablet = window.matchMedia("(max-width: 1199px)").matches;
			
				if (campaign.isShowDesktop &amp;&amp; !campaign.isShowMobileTablet &amp;&amp; isDesktop) {
					return true;
				} else if (campaign.isShowMobileTablet &amp;&amp; !campaign.isShowDesktop &amp;&amp; isMobileTablet) {
					return true;
				} else if ((campaign.isShowDesktop &amp;&amp; campaign.isShowMobileTablet) || (!campaign.isShowDesktop &amp;&amp; !campaign.isShowMobileTablet)) {
					return true;
				} else {
					return false;
				}
			},
		},

		preview: {
			init: function() {
				this.start();
				this.events();
			},

			start: function() {
				var url = new URL(window.location.href);
				var isPrevParam = url.searchParams.get('dfPreview');
				var campaignIdParam = url.searchParams.get('id');
				var campaignIdLs = localStorage.getItem('df_previewCampaignId');

				if (!campaignIdParam) {
					campaignIdParam = campaignIdLs
				}

				if ((isPrevParam &amp;&amp; campaignIdParam) || campaignIdLs) {
					$.each(funMain.config.campaigns, function (index, campaign) {
						if (campaign.id == campaignIdParam) {
							funMain.popup.init(campaign, index);
							funMain.scratch.init(campaign, index);
							funMain.gift.init(campaign, index);
							funMain.whell.init(campaign, index);

							funMain.preview.buildHtml(campaign);

							funMain.setCustomCss(campaign);

							console.log('Demo...')
						}
					});

					if (!campaignIdLs) {
						localStorage.setItem('df_previewCampaignId', campaignIdParam.toString());
					}
				}
			},

			buildHtml: function(campaign) {
				var html = `
				&lt;div class="df-preview-bar"&gt;
					&lt;div class="df-container"&gt;
						&lt;div class="df-row"&gt;
							&lt;div class="df-col"&gt;
								&lt;div class="df-preview-bar-content"&gt;
									&lt;div class="df-t"&gt;${campaign.name}&lt;/div&gt;
									&lt;div class="df-v"&gt;${campaign.active == 1 ? 'Aktif' : 'Pasif'}&lt;/div&gt;
								&lt;/div&gt;
							&lt;/div&gt;
							&lt;div class="df-col-auto"&gt;
								&lt;a href="javascript:void(0)" class="df-btn df-btn-primary" data-selector="df-close-preview" data-campaign-id="${campaign.id}"&gt;Ã–nizlemeyi SonlandÄ±r&lt;/a&gt;
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
				&lt;/div&gt;
				&lt;style&gt;
					.df-preview-bar {
						background: #eee;
						position: fixed;
						bottom: 0;
						left: 0;
						z-index: 999999;
						width: 100%;
						padding: 10px 0;
					}

					.df-preview-bar-content .df-t {
						font-size: 14px;
						font-weight: 500;
						margin-bottom: 6px;
						line-height: 16px;
					}
				&lt;/style&gt;
				`;

				$('body').append(html);
			},

			resetPreview: function(elm) {
				localStorage.removeItem('df_previewCampaignId');
				window.location.href = window.location.origin;
			},

			events: function() {
				var self = this;
				$(document).on('click', '[data-selector="df-close-preview"]', function() {
					self.resetPreview($(this))
				});
			},
		},

		whell: {
			init: function (campaign, index) {
				this.events();
				this.wheelLoad(campaign, index)
			},

			start: function (campaign, index) {
				var self = this;

				if (campaign.type == 'wheel' &amp;&amp; funMain.visible(campaign)) {
					funMain.segments.push(campaign);

					var whellConfig = {
						'numSegments': campaign.arrSegmentsList.length,
						'outerRadius': 265,
						'innerRadius': 60,
						'textFontSize': 18,
						'textMargin': 0,
						'segments': campaign.arrSegmentsList,
						'wheelTextColor': campaign.wheelTextColor,
						'WheelStrokeColor': campaign.wheelBorderColor,
						'WheelStrokeWidth': "4",
						'animation': {
							'type': 'spinToStop',
							'duration': 5,
							'spins': 8,
							'callbackFinished': winresult,
							'callbackAfter': self.animafter,
							'callbackSound': self.playSpinSound,
						},
					}

					self.buildHtml(campaign, index);

					if (!funMain.isDemo) {
						$('body').addClass('fun-modal-active');

						var modalConfig = {
							target: 'df-modal-wheel-modal',
							overlay: true,
							mode: 'custom'
						};
						df_modal.openModal(modalConfig);

						funMain.localStorage.set('dfFunShown_' + campaign.id)
					}

					funMain.config.theWheel = new Luckywheel(whellConfig);

					function newsletterWinResult() {
						$('.wheel-modal .wheel-coupon, .wheel-modal .wheel-information').removeClass('df-d-none')
						$('.wheel-modal .wheel-newsletter-container').addClass('df-d-none')
					}

					function winresult(selectedSegment) {
						$(".spin_pin").rotate(0);
						$('[data-selector="wheel-result"]').removeClass('df-d-none');
						$('[data-selector="wheel-function"]').remove();

						if (selectedSegment.IsCouponCode == "true" || selectedSegment.IsCouponCode == "1") {
							$('.wheel-modal [data-selector="wheel-result"] .wheel-title .t').text(selectedSegment.winresult);
							$('.wheel-modal .wheel-coupon span').empty().text(selectedSegment.CouponCode)

							funMain.helpers.winningGeneral();

							if ($('.wheel-modal .wheel-newsletter-container').length) {
								$('.wheel-modal .wheel-newsletter-container').removeClass('df-d-none')

								if (!funMain.isDemo) {
									$(document).on('click', '[data-selector="wheel-newsletter-save"]', function (e) {
										e.preventDefault();
										funMain.newsletter.save($(this), newsletterWinResult)
									})
								}

							} else {
								$('.wheel-modal .wheel-coupon, .wheel-modal .wheel-information').removeClass('df-d-none')
							}

							funMain.helpers.topBarBuild(campaign);
						}
						else {
							$('.wheel-modal [data-selector="wheel-result"] .wheel-title .t').text(selectedSegment.winresult);
							$('.wheel-modal [data-selector="wheel-result"] .wheel-information').remove();
						}
					}
				}
			},

			buildHtml: function (item, index) {
				var self = this;
				var isModalLight = funMain.helpers.wc_hex_is_light(item.modalBgColor);
				var modalBgColorType = isModalLight ? 'wheel-modal-light' : 'wheel-modal-dark';
				var zIndex = 700 + index;

				$('.wheel-modal, .df-modal-wheel-terms-modal').remove();

				var html = '';
				html += `
					&lt;div class="wheel-modal df-modal-wheel-modal df-modal-container df-modal-${item.modalViewType} df-modal-${item.modalViewSize}${funMain.isDemo ? ' active' : ''}" data-df-campaign-index="${index}" data-df-campaign-id="${item.id}" data-overlay-class=".df-modal-wheel-modal-overlay" style="z-index: ${zIndex}"&gt;
				`;

				html += `
						&lt;div class="df-modal-dialog"&gt;
							&lt;div class="df-modal-content ${modalBgColorType}" style="${item.modalBgType === 'image' ? `background-repeat: no-repeat;background-size:${item.isBgImageFit ? 'auto' : 'cover'};background-image: url(https://functionality.dfikir.com/uploads/${item.modalBgImage ? item.modalBgImage.replace('/uploads/', '') : ''})` : `background-color: ${item.modalBgColor}` }"&gt;
								&lt;div class="df-container-fluid"&gt;
									&lt;div class="df-row df-align-items-center"&gt;
										&lt;div class="df-col-12 df-col-xl-auto"&gt;
											&lt;div class="spin_wheel_section"&gt;
												&lt;div class="spin_pin"&gt;&lt;/div&gt;
												&lt;div class="the_wheel"&gt;
													&lt;div class="wheel_inner"&gt;
														&lt;div class="wheel-center-image" style="background-color: ${item.wheelBorderColor}"&gt;
															${item.wheelCenterImage ? `&lt;img src="https://functionality.dfikir.com/uploads/${item.wheelCenterImage.replace('/uploads/', '')}" alt=""&gt;` : ''}
														&lt;/div&gt;
														&lt;canvas id="canvas" width="500" height="500"&gt;
															&lt;p&gt;Sorry, your browser doesn't support canvas. Please try again.&lt;/p&gt;
														&lt;/canvas&gt;
													&lt;/div&gt;
												&lt;/div&gt;
											&lt;/div&gt;
										&lt;/div&gt;
										&lt;div class="df-col-12 df-col-xl"&gt;
											&lt;div class="wheel-modal-content" data-selector="wheel-function"&gt;
												${item.logo ? `&lt;div class="whell-logo"&gt;&lt;img src="https://functionality.dfikir.com/uploads/${item.logo ? item.logo.replace('/uploads/', '') : ''}" alt=""&gt;&lt;/div&gt;` : ''}
												&lt;div class="wheel-title"&gt;
													&lt;div class="t"&gt;${item.modalTitle}&lt;/div&gt;
													&lt;div class="v"&gt;${item.modalDescription}&lt;/div&gt;
												&lt;/div&gt;
												&lt;div class="wheel-button"&gt;
													&lt;a class="df-btn df-btn-primary df-mx-auto" id="spin_button" data-selector="spin-wheel-btn" href="javascript:void(0);"&gt;Ã‡arkÄ± Ã‡evir&lt;/a&gt;
												&lt;/div&gt;
											&lt;/div&gt;
											&lt;div class="wheel-modal-content df-d-none" data-selector="wheel-result"&gt;
												${item.logo ? `&lt;div class="whell-logo"&gt;&lt;img src="https://functionality.dfikir.com/uploads/${item.logo}" alt=""&gt;&lt;/div&gt;` : ''}
												&lt;div class="wheel-title"&gt;
													&lt;div class="t"&gt;{Ã§ark sonuÃ§ metni}&lt;/div&gt;
												&lt;/div&gt;
												&lt;div class="wheel-coupon df-d-none"&gt;
													&lt;span id="code-to-copy"&gt;{code}&lt;/span&gt;
													&lt;a href="javascript:void(0)" id="copy-button"&gt;Kopyala&lt;/a&gt;
												&lt;/div&gt;
												${item.isCouponLimited ? `&lt;div class="wheel-information df-d-none"&gt;Kupon kodunu &lt;b&gt;${item.couponLimit}&lt;/b&gt; dakika iÃ§inde kullanmanÄ±z gerekmektedir.&lt;/div&gt;` : ''}
												${item.newsletterRequired ? `
													&lt;div class="wheel-newsletter-container" data-selector="wheel-newsletter"&gt;
														&lt;div class="wheel-newsletter"&gt;
															&lt;form data-selector="df-newsletter-form"&gt;
																&lt;div class="df-row"&gt;
																	&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="text" class="df-form-control" name="fun_fullname" placeholder="Ad ve Soyad *" required&gt;&lt;/div&gt;
																	&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="email" class="df-form-control" name="fun_email" placeholder="E-mail *" required&gt;&lt;/div&gt;
																	&lt;div class="df-col-12"&gt;&lt;input type="email" class="df-form-control" name="fun_phone" placeholder="Telefon *" required&gt;&lt;/div&gt;
																&lt;/div&gt;
															&lt;/form&gt;
														&lt;/div&gt;
														${item.termsAndConditionText ? `
															&lt;div class="wheel-terms"&gt;
																&lt;div class="df-form-group checkbox-custom mb-0"&gt;
																	&lt;input type="checkbox" class="form-check-input" id="wheelTerms"&gt;
																	&lt;label class="form-check-label" for="wheelTerms"&gt;&lt;a href="javascript:void(0)" class="df-modal" data-target="df-modal-wheel-terms-modal" data-mode="custom" data-overlay="true"&gt;Åžartlar ve KoÅŸullarÄ±&lt;/a&gt;&amp;nbsp;kabul ediyorum.&lt;/label&gt;
																&lt;/div&gt;
															&lt;/div&gt;
														` : ''}
														&lt;div class="wheel-button"&gt;
															&lt;a href="javascript:void(0)" class="df-btn df-btn-primary" data-selector="wheel-newsletter-save"&gt;Kaydol ve Hediyeyi GÃ¶r&lt;/a&gt;
														&lt;/div&gt;
													&lt;/div&gt;
												` : ''}
											&lt;/div&gt;
										&lt;/div&gt;
									&lt;/div&gt;
								&lt;/div&gt;
								${!funMain.isDemo ? `&lt;a href="javascript:void(0)" class="df-modal-close" data-selector="df-modal-close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;` : `&lt;a href="javascript:void(0)" class="close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;`}
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
					
					&lt;div class="df-modal-wheel-terms-modal df-modal-container" style="z-index: ${zIndex + 1}"&gt;
						&lt;div class="df-modal-dialog" role="document"&gt;
							&lt;div class="df-modal-content"&gt;
								&lt;div class="df-modal-header"&gt;
									&lt;div class="df-modal-title"&gt;Åžartlar ve KoÅŸullar&lt;/div&gt;
								&lt;/div&gt;
								&lt;div class="df-modal-body"&gt;${item.termsAndConditionText}&lt;/div&gt;
								&lt;div class="df-modal-footer"&gt;
									&lt;a href="javascript:void(0)" class="df-btn df-btn-gray df-modal-close"&gt;Kapat&lt;/a&gt;
								&lt;/div&gt;
							&lt;/div&gt;
						&lt;/div&gt;
						${!funMain.isDemo ? `&lt;a href="javascript:void(0)" class="df-modal-close" data-selector="df-modal-close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;` : `&lt;a href="javascript:void(0)" class="close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;`}
					&lt;/div&gt;
    			`;

				if (funMain.isDemo) {
					$('.design-preview-container').append(html);
				} else {
					$('body').append(html);
				}
			},

			wheelLoad: function (campaign, index) {
				funMain.whell.start(campaign, index);
			},

			playSpinSound: function() {
				$(".wheel-modal .spin_pin").rotate(-20);
				funMain.config.audio.pause();
				funMain.config.audio.currentTime = 0;
				funMain.config.audio.play();
			},

			wheelSpinning: function () {
				if (funMain.config.wheelSpinning == true) {
					return;
				}

				$('.wheel-modal [data-selector="spin-wheel-btn"]').addClass('btn-loading').attr('disabled');

				funMain.config.theWheel.animation.spins = 8;
				var c = funMain.config.arrsp.splice(funMain.config.arrsp.length * Math.random() | 0, 1)[0];
				funMain.config.theWheel.animation.stopAngle = funMain.config.theWheel.getRandomForSegment(c);
				if (funMain.config.arrsp.length == 0) {
					funMain.config.arrsp = funMain.config.strarr.split('|');
				}
				funMain.config.theWheel.startAnimation();


				funMain.config.wheelSpinning = true;
			},

			animafter: function() {
				$(".wheel-modal .spin_pin").rotate(-20);
			},

			events: function () {
				var self = this;

				if (!funMain.isDemo){
					$(document).on('click', '[data-selector="spin-wheel-btn"]', function (e) {
						e.preventDefault();
						self.wheelSpinning($(this));
					})
				}
			},
		},

		scratch: {
			init: function(campaign, index) {
				this.start(campaign, index);
			},

			start: function(campaign, index) {
				var self = this;

				if (campaign.type == 'scratch' &amp;&amp; funMain.visible(campaign)) {
					self.buildHtml(campaign, index);

					if (!funMain.isDemo) {
						$('body').addClass('fun-modal-active');

						var config = {
							target: 'df-modal-scratch-modal',
							overlay: true,
							mode: 'custom'
						};
						df_modal.openModal(config)

						funMain.localStorage.set('dfFunShown_' + campaign.id)
					}

					if (!funMain.isDemo &amp;&amp; campaign.newsletterRequired) {
						$(document).on('click', '[data-selector="scratch-open-btn"]', function (e) {
							e.preventDefault();
							funMain.newsletter.save($(this), self.openScratch(campaign, index))
						})
					}
				}
			},

			buildHtml(item, index) {
				const isModalLight = funMain.helpers.wc_hex_is_light(item.modalBgColor);
				const modalBgColorType = isModalLight ? 'wheel-modal-light' : 'wheel-modal-dark';
				const zIndex = 700 + index;
			
				$('.scratch-modal, .df-modal-scratch-terms-modal').remove();
			
				const modalStyle = item.modalBgType === 'image'
					? `background-repeat: no-repeat; background-size: ${item.isBgImageFit ? 'auto' : 'cover'}; background-image: url(${item.modalBgImage});`
					: `background-color: ${item.modalBgColor};`;
			
				let html = `
					&lt;div class="scratch-modal df-modal-scratch-modal df-modal-container df-modal-${item.modalViewType} df-modal-${item.modalViewSize} ${funMain.isDemo ? 'active' : ''}" 
						data-df-campaign-index="${index}" 
						data-df-campaign-id="${item.id}" 
						data-overlay-class=".df-modal-scratch-modal-overlay" 
						style="z-index: ${zIndex};"&gt;
						&lt;div class="df-modal-dialog"&gt;
							&lt;div class="df-modal-content ${modalBgColorType}" id="scratch-modal-content" style="${modalStyle}"&gt;
								&lt;div class="wheel-modal-content"&gt;
									${item.logo ? `&lt;div class="whell-logo"&gt;&lt;img src="https://functionality.dfikir.com/uploads/${item.logo}" alt=""&gt;&lt;/div&gt;` : ''}
									&lt;div class="wheel-title"&gt;
										&lt;div class="t"&gt;${item.modalTitle}&lt;/div&gt;
										&lt;div class="v"&gt;${item.modalDescription}&lt;/div&gt;
									&lt;/div&gt;
									&lt;div id="scratch" class="${funMain.isDemo ? 'scratch-demo' : ''}"&gt;
										${!item.newsletterRequired ? `
											&lt;div class="wheel-title" data-target-screen="3-4"&gt;
												&lt;div class="t"&gt;{sonuÃ§ metni}&lt;/div&gt;
											&lt;/div&gt;` : ''}
										${item.newsletterRequired ? this.buildNewsletterSection(item) : ''}
										&lt;div class="wheel-coupon df-d-none gamify-result-after-show" data-target-screen="3"&gt;
											&lt;span id="code-to-copy"&gt;&lt;/span&gt;
											&lt;a href="javascript:void(0)" id="copy-button"&gt;Kopyala&lt;/a&gt;
										&lt;/div&gt;
										${item.isCouponLimited ? `
											&lt;div class="wheel-information df-d-none gamify-result-after-show" data-target-screen="3"&gt;
												Kupon kodunu &lt;b&gt;${item.couponLimit}&lt;/b&gt; dakika iÃ§inde kullanmanÄ±z gerekmektedir.
											&lt;/div&gt;` : ''}
									&lt;/div&gt;
								&lt;/div&gt;
								${!funMain.isDemo ? `&lt;a href="javascript:void(0)" class="df-modal-close" data-selector="df-modal-close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;` : ''}
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
					${this.buildTermsModal(item, zIndex)}
				`;
			
				if (funMain.isDemo) {
					$('.design-preview-container').append(html);
				} else {
					$('body').append(html);
				}
			
				if (!funMain.isDemo &amp;&amp; !item.newsletterRequired) {
					this.openScratch(item);
				}
			
				this.initializeScratch(item);
			},
			
			buildNewsletterSection(item) {
				return `
					&lt;div class="wheel-title" data-target-screen="2"&gt;
						&lt;div class="t df-d-none gamify-result-after-show"&gt;{sonuÃ§ metni}&lt;/div&gt;
						&lt;div class="v"&gt;Kupon kodunuzu gÃ¶rmek iÃ§in ad soyad ve e-posta bilgilerini doldurmalÄ±sÄ±nÄ±z.&lt;/div&gt;
					&lt;/div&gt;
					&lt;div class="wheel-newsletter gamify-result-after-hide" data-target-screen="2"&gt;
						&lt;form data-selector="df-newsletter-form"&gt;
							&lt;div class="df-row"&gt;
								&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="text" class="df-form-control" name="fun_fullname" placeholder="Ad ve Soyad *" required&gt;&lt;/div&gt;
								&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="email" class="df-form-control" name="fun_email" placeholder="E-mail *" required&gt;&lt;/div&gt;
								&lt;div class="df-col-12"&gt;&lt;input type="text" class="df-form-control" name="fun_phone" placeholder="Telefon *" required&gt;&lt;/div&gt;
							&lt;/div&gt;
						&lt;/form&gt;
					&lt;/div&gt;
					${item.termsAndConditionText ? `
						&lt;div class="wheel-terms gamify-result-after-hide" data-target-screen="2"&gt;
							&lt;div class="df-form-group checkbox-custom mb-0"&gt;
								&lt;input type="checkbox" class="form-check-input" id="scratchTerms"&gt;
								&lt;label class="form-check-label" for="scratchTerms"&gt;
									&lt;a href="javascript:void(0)" class="df-modal" data-target="df-modal-scratch-terms-modal" data-mode="custom" data-overlay="true"&gt;Åžartlar ve KoÅŸullarÄ±&lt;/a&gt;&amp;nbsp;kabul ediyorum.
								&lt;/label&gt;
							&lt;/div&gt;
						&lt;/div&gt;` : ''}
					&lt;div class="wheel-button gamify-result-after-hide" data-target-screen="2"&gt;
						&lt;a class="df-btn df-btn-primary" data-selector="scratch-open-btn" href="javascript:void(0);"&gt;Hediyeyi GÃ¶r&lt;/a&gt;
					&lt;/div&gt;
				`;
			},
			
			buildTermsModal(item, zIndex) {
				return `
					&lt;div class="df-modal-scratch-terms-modal df-modal-container" style="z-index: ${zIndex + 1};"&gt;
						&lt;div class="df-modal-dialog" role="document"&gt;
							&lt;div class="df-modal-content"&gt;
								&lt;div class="df-modal-header"&gt;
									&lt;div class="df-modal-title"&gt;Åžartlar ve KoÅŸullar&lt;/div&gt;
								&lt;/div&gt;
								&lt;div class="df-modal-body"&gt;${item.termsAndConditionText}&lt;/div&gt;
								&lt;div class="df-modal-footer"&gt;
									&lt;a href="javascript:void(0)" class="df-btn df-btn-gray df-modal-close"&gt;Kapat&lt;/a&gt;
								&lt;/div&gt;
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
				`;
			},
			
			initializeScratch(item) {
				const containerEl = document.getElementById('scratch');
				const overlayImgUrl = 'https://cdn.dfikir.com/shared/img/gift/gray-bg.png';
				const brushImgUrl = 'https://cdn.dfikir.com/shared/img/gift/brush1.png';
				const revealPercent = 50;
			
				function onReveal() {
					containerEl.classList.add('revealed');
					if (navigator.userAgent.indexOf("Edge") &gt; -1) {
						document.getElementsByTagName('canvas')[0].style.width = '100%';
					}
					if (!item.newsletterRequired) {
						funMain.helpers.winningGeneral();
						funMain.helpers.topBarBuild(item);
					}
				}
			
				if (ScratchIt.isSupported()) {
					ScratchIt(containerEl, overlayImgUrl, brushImgUrl, onReveal, revealPercent);
				}
			},

			openScratch: function (campaign, index) {
				$('.scratch-modal .wheel-terms').find('.wheel-error-msg').remove();
				if (campaign.termsAndConditionText &amp;&amp; !$('#scratchTerms').is(':checked')) {
					$('.scratch-modal .wheel-terms').append('&lt;div class="text-danger mt-1 wheel-error-msg"&gt;LÃ¼tfen sÃ¶zleÅŸmeyi kabul ediniz.&lt;/div&gt;')
					return;
				}

				funMain.segments.push(campaign);

				var arrspLength = funMain.config.arrsp.length;
				var randomIndex = Math.floor(Math.random() * arrspLength);
				var selectedSegmentIndex = funMain.config.arrsp[randomIndex] - 1;
				var selectedSegment = campaign.arrSegmentsList[selectedSegmentIndex];

				$('#scratch .wheel-title .t').text(selectedSegment.winresult);
				if (selectedSegment.IsCouponCode == "true" || selectedSegment.IsCouponCode == "1") {
					$('#scratch .wheel-coupon span').text(selectedSegment.CouponCode)

					$('.scratch-modal').find('.gamify-result-after-show').removeClass('df-d-none')
					$('.scratch-modal').find('.gamify-result-after-hide').addClass('df-d-none');


					funMain.helpers.winningGeneral();
					funMain.helpers.topBarBuild(campaign);
				}
				else {
					$('#scratch .wheel-information' ).addClass('df-d-none');
				}
			},
		},

		gift: {
			init: function(campaign, index) {
				this.start(campaign, index);
			},

			start: function(campaign, index) {
				var self = this;
				if (campaign.type == 'giftFinder' &amp;&amp; funMain.visible(campaign)) {

					funMain.segments.push(campaign);

					self.buildHtml(campaign, index);

					if (!funMain.isDemo) {
						$('body').addClass('fun-modal-active');

						var modalConfig = {
							target: 'df-modal-gift-finder-modal',
							overlay: true,
							mode: 'custom'
						};

						df_modal.openModal(modalConfig);

						funMain.localStorage.set('dfFunShown_' + campaign.id)
					}

					if (!funMain.isDemo) {
						if (campaign.newsletterRequired) {
							$('[data-selector="gift-finder-newsletter-btn"]').each(function() {
								var $this = $(this);
								$this.on('click', function(e) {
									e.preventDefault();
									function callback() {
										self.openGift(campaign, index, $this.attr('data-segment-index'), true)
									};
									funMain.newsletter.save($this, callback)
								});
							});
						}

						$('[data-selector="gift-finder-open-gift"]').each(function() {
							var $this = $(this);
							$this.on('click', function(e) {
								e.preventDefault();
								self.openGift(campaign, index, $(this).attr('data-segment-index'))
							});
						});
					}
				}
			},

			buildHtml(item, index) {
				const modalBgColorType = funMain.helpers.wc_hex_is_light(item.modalBgColor) ? 'wheel-modal-light' : 'wheel-modal-dark';
				const zIndex = 900 + index;
			
				// Eski modal elementlerini kaldÄ±r
				$('.gift-finder-modal, .df-modal-gift-finder-terms-modal').remove();
			
				// Modal iÃ§eriÄŸi oluÅŸturma
				const modalContentStyle = item.modalBgType === 'image'
					? `background-repeat: no-repeat; background-size: ${item.isBgImageFit ? 'auto' : 'cover'}; background-image: url(https://functionality.dfikir.com/uploads/${item.modalBgImage?.replace('/uploads/', '') || ''});`
					: `background-color: ${item.modalBgColor};`;
			
				const logoHtml = item.logo
					? `&lt;div class="whell-logo"&gt;&lt;img src="https://functionality.dfikir.com/uploads/${item.logo.replace('/uploads/', '')}" alt=""&gt;&lt;/div&gt;`
					: '';
			
				const newsletterHtml = item.newsletterRequired ? this.buildNewsletterSection(item) : '';
				const couponHtml = this.buildCouponSection(item);
				const giftListHtml = this.buildGiftList(item);
			
				const closeButton = !funMain.isDemo
					? `&lt;a href="javascript:void(0)" class="df-modal-close" data-selector="df-modal-close"&gt;
							&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt;
								&lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt;
							&lt;/svg&gt;
					   &lt;/a&gt;`
					: '';
			
				const termsHtml = this.buildTermsModal(item, zIndex);
			
				const html = `
					&lt;div class="gift-finder-modal df-modal-gift-finder-modal df-modal-container df-modal-${item.modalViewSize} df-modal-${item.modalViewType} ${funMain.isDemo ? 'active' : ''}" 
						data-df-campaign-index="${index}" 
						data-df-campaign-id="${item.id}" 
						data-overlay-class=".df-modal-gift-finder-modal-overlay" 
						style="z-index: ${zIndex};"&gt;
						&lt;div class="df-modal-dialog"&gt;
							&lt;div class="df-modal-content ${modalBgColorType}" id="gift-finder-modal-content" style="${modalContentStyle}"&gt;
								&lt;div class="wheel-modal-content df-text-center"&gt;
									${logoHtml}
									&lt;div class="wheel-title"&gt;
										&lt;div class="t"&gt;${item.modalTitle}&lt;/div&gt;
										&lt;div class="v"&gt;${item.modalDescription}&lt;/div&gt;
									&lt;/div&gt;
									&lt;div class="gift-finder-container"&gt;
										${newsletterHtml}
										${couponHtml}
										${giftListHtml}
									&lt;/div&gt;
								&lt;/div&gt;
								${closeButton}
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
					${termsHtml}
				`;
			
				// Modal ekleme
				if (funMain.isDemo) {
					$('.design-preview-container').append(html);
				} else {
					$('body').append(html);
				}
			},
			
			buildNewsletterSection(item) {
				return `
					&lt;div class="wheel-title df-d-none gamify-result-after-show" data-target-screen="2"&gt;
						&lt;div class="t"&gt;&lt;/div&gt;
						&lt;div class="v"&gt;Kupon kodunuzu gÃ¶rmek iÃ§in ad soyad ve e-posta bilgilerini doldurmalÄ±sÄ±nÄ±z.&lt;/div&gt;
					&lt;/div&gt;
					&lt;div class="wheel-newsletter df-d-none gamify-result-after-show" data-target-screen="2"&gt;
						&lt;form data-selector="df-newsletter-form"&gt;
							&lt;div class="df-row"&gt;
								&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="text" class="df-form-control" name="fun_fullname" placeholder="Ad ve Soyad *" required&gt;&lt;/div&gt;
								&lt;div class="df-col-12 df-mb-2"&gt;&lt;input type="email" class="df-form-control" name="fun_email" placeholder="E-mail *" required&gt;&lt;/div&gt;
								&lt;div class="df-col-12"&gt;&lt;input type="text" class="df-form-control" name="fun_phone" placeholder="Telefon *" required&gt;&lt;/div&gt;
							&lt;/div&gt;
						&lt;/form&gt;
					&lt;/div&gt;
					${item.termsAndConditionText ? `
						&lt;div class="wheel-terms df-d-none gamify-result-after-show" data-target-screen="2"&gt;
							&lt;div class="df-form-group checkbox-custom mb-0"&gt;
								&lt;input type="checkbox" class="form-check-input" id="giftFinderTerms"&gt;
								&lt;label class="form-check-label" for="giftFinderTerms"&gt;
									&lt;a href="javascript:void(0)" class="df-modal" data-target="df-modal-gift-finder-terms-modal" data-mode="custom" data-overlay="true"&gt;Åžartlar ve KoÅŸullarÄ±&lt;/a&gt;&amp;nbsp;kabul ediyorum.
								&lt;/label&gt;
							&lt;/div&gt;
						&lt;/div&gt;` : ''}
					&lt;div class="wheel-button df-d-none gamify-result-after-show" data-target-screen="2"&gt;
						&lt;a class="df-btn df-btn-primary" data-selector="gift-finder-newsletter-btn" href="javascript:void(0);"&gt;Hediyeyi GÃ¶r&lt;/a&gt;
					&lt;/div&gt;
				`;
			},
			
			buildCouponSection(item) {
				return `
					&lt;div class="wheel-title"&gt;
						&lt;div class="t"&gt;&lt;/div&gt;
					&lt;/div&gt;
					&lt;div class="wheel-coupon df-d-none gamify-result-after-show gamify-result-newsletter-condition" data-target-screen="3"&gt;
						&lt;span id="code-to-copy"&gt;&lt;/span&gt;
						&lt;a href="javascript:void(0)" id="copy-button"&gt;Kopyala&lt;/a&gt;
					&lt;/div&gt;
					${item.isCouponLimited ? `
						&lt;div class="wheel-information df-d-none gamify-result-after-show gamify-result-newsletter-condition" data-target-screen="3"&gt;
							Kupon kodunu &lt;b&gt;${item.couponLimit}&lt;/b&gt; dakika iÃ§inde kullanmanÄ±z gerekmektedir.
						&lt;/div&gt;` : ''}
				`;
			},
			
			buildGiftList(item) {
				let giftListHtml = `&lt;div class="gift-finder-list gamify-result-after-hide" data-target-screen="1"&gt;`;
				item.arrSegmentsList.forEach((segmentItem, segmentIndex) =&gt; {
					giftListHtml += `
						&lt;div class="gift-finder-list-item"&gt;
							&lt;a href="javascript:void(0)" data-segment-index="${segmentIndex}" data-selector="gift-finder-open-gift"&gt;
								&lt;img src="https://functionality.dfikir.com/uploads/${item.wheelCenterImage?.replace('/uploads/', '') || ''}" /&gt;
							&lt;/a&gt;
						&lt;/div&gt;
					`;
				});
				giftListHtml += `&lt;/div&gt;`;
				return giftListHtml;
			},
			
			buildTermsModal(item, zIndex) {
				return `
					&lt;div class="df-modal-gift-finder-terms-modal df-modal-container" style="z-index: ${zIndex + 1};"&gt;
						&lt;div class="df-modal-dialog" role="document"&gt;
							&lt;div class="df-modal-content"&gt;
								&lt;div class="df-modal-header"&gt;
									&lt;div class="df-modal-title"&gt;Åžartlar ve KoÅŸullar&lt;/div&gt;
								&lt;/div&gt;
								&lt;div class="df-modal-body"&gt;${item.termsAndConditionText}&lt;/div&gt;
								&lt;div class="df-modal-footer"&gt;
									&lt;a href="javascript:void(0)" class="df-btn df-btn-gray df-modal-close"&gt;Kapat&lt;/a&gt;
								&lt;/div&gt;
							&lt;/div&gt;
						&lt;/div&gt;
					&lt;/div&gt;
				`;
			},			

			openGift: function (campaign, index, selectedIndex, isCallback) {
				$('.gift-finder-modal .wheel-terms').find('.wheel-error-msg').remove();
				if (campaign.termsAndConditionText &amp;&amp; !$('#giftFinderTerms').is(':checked')) {
					$('.gift-finder-modal .wheel-terms').append('&lt;div class="text-danger mt-1 wheel-error-msg"&gt;LÃ¼tfen sÃ¶zleÅŸmeyi kabul ediniz.&lt;/div&gt;')
					return;
				}

				var selectedSegment = campaign.arrSegmentsList[selectedIndex];

				$('.gift-finder-container .wheel-title .t').text(selectedSegment.winresult);

				if (selectedSegment.IsCouponCode == "true" || selectedSegment.IsCouponCode == "1") {
					$('.gift-finder-container .wheel-coupon span').text(selectedSegment.CouponCode)

					$('.gift-finder-modal').find('.gamify-result-after-show:not(.gamify-result-newsletter-condition)').removeClass('df-d-none')
					$('.gift-finder-modal').find('.gamify-result-after-hide').addClass('df-d-none');
					$('.gift-finder-modal').find('[data-selector="gift-finder-newsletter-btn"]').attr('data-segment-index', selectedIndex)

					if (campaign.newsletterRequired &amp;&amp; !isCallback) {

					} else {
						$('.gift-finder-container .wheel-title .v').remove();
						$('.gift-finder-container .wheel-newsletter').remove();
						$('.gift-finder-container [data-selector="gift-finder-newsletter-btn"]').remove();

						$('.gift-finder-modal').find('.gamify-result-newsletter-condition').removeClass('df-d-none')
						
						funMain.helpers.winningGeneral();
						
						funMain.helpers.topBarBuild(campaign);
					}
				}
				else {
					$('.gift-finder-modal .wheel-information' ).addClass('df-d-none');
				}
			},
		},

		popup: {
			init: function(campaign, index) {
				var self = this;
				if (campaign.type == 'popup' &amp;&amp; funMain.visible(campaign)) {
					self.buildHtml(campaign, index);

					funMain.localStorage.set('dfFunShown_' + campaign.id)
				}
			},

			buildHtml: function (item, index) {
				var self = this;
				var zIndex = 700 + index;

				if (funMain.isDemo) {
					return;
				} 

				var zIndex = 700 + index;
				var popupHtml = item.popupHtml.replace('onClick', 'oldEvent');
				
				var html = `
					&lt;div class="df-custom-popup" data-df-campaign-index="${index}" data-df-campaign-id="${item.id}" style="z-index: ${zIndex}"&gt;
						${popupHtml}

						&lt;style&gt;
							.u-popup-container {
								position: fixed !important;
							}
							.df-custom-popup {
								z-index: 701;
								position: fixed;
								inset: 0;
								margin: auto;
								overflow-x: auto;
							}
							.u-popup-main {
								overflow-x: auto;
							}
						&lt;/style&gt;
					&lt;/div&gt;
					
					&lt;div class="df-modal-wheel-terms-modal df-modal-container" style="z-index: ${zIndex + 1}"&gt;
						&lt;div class="df-modal-dialog" role="document"&gt;
							&lt;div class="df-modal-content"&gt;
								&lt;div class="df-modal-header"&gt;
									&lt;div class="df-modal-title"&gt;Åžartlar ve KoÅŸullar&lt;/div&gt;
								&lt;/div&gt;
								&lt;div class="df-modal-body"&gt;${item.termsAndConditionText}&lt;/div&gt;
								&lt;div class="df-modal-footer"&gt;
									&lt;a href="javascript:void(0)" class="df-btn df-btn-gray df-modal-close"&gt;Kapat&lt;/a&gt;
								&lt;/div&gt;
							&lt;/div&gt;
						&lt;/div&gt;
						${!funMain.isDemo ? `&lt;a href="javascript:void(0)" class="df-modal-close" data-selector="df-modal-close"&gt;&lt;svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"&gt; &lt;path fill-rule="evenodd" clip-rule="evenodd" d="M19.7123 11.2271L20.773 12.2877L17.0607 16.0001L20.773 19.7124L19.7123 20.773L16 17.0607L12.2877 20.773L11.227 19.7124L14.9393 16.0001L11.227 12.2877L12.2877 11.2271L16 14.9394L19.7123 11.2271Z" fill="#222222"/&gt; &lt;/svg&gt;&lt;/a&gt;` : ``}
					&lt;/div&gt;
    			`;

				$('body').append(html);

				$('[data-df-campaign-id="'+ item.id +'"]').find('form').after('&lt;p style="padding:16px 10px; font-size:14px; display:none;" class="popup-after-msg"&gt;'+ item.modalDescription +'&lt;/p&gt;')
				
				$('body').addClass('fun-modal-active');
			},
		},

		newsletter: {
			save: function (elm, callback) {
				var form = elm.closest('.df-custom-popup, .df-modal-container');
				var email = $(form).find('input[name="fun_email"], input[name="email"]');
				var name = $(form).find('input[name="fun_fullname"], input[name="name"]');
				var phone = $(form).find('input[name="fun_phone"], input[name="phone"]');

				var campaignId = elm.closest('[data-df-campaign-id]').attr('data-df-campaign-id')
				var err=0;
				if (email.length &amp;&amp; !funMain.helpers.checkEmail(email.val())) {
					err++;
				}

				if (name.length &amp;&amp; !name.val()) {
					err++;
				}

				if (phone.length &amp;&amp; !phone.val()) {
					err++;
				}

				if (err &gt; 0) {
					iziToast.error({
						iconUrl: 'https://cdn.dfikir.com/shared/img/icons/alert-warning.svg',
						title: 'Hata',
						message: 'LÃ¼tfen tÃ¼m alanlarÄ± doÄŸru ÅŸekilde doldurunuz.',
					});
					return false;
				} else {
					if (funMain.isDemo) {
						callback();
					} else {
						var data = {
							"email": email.val(),
							"name": name.val(),
							"surname": name.val(),
							"phone": phone.val()
						};
						$.post('https://functionality.dfikir.com/lead/create/' + campaignId , JSON.stringify({lead: data})).promise().done(function(res) {
							if (res.status) {
								callback();
							} else {
								iziToast.error({
									iconUrl: 'https://cdn.dfikir.com/shared/img/icons/alert-warning.svg',
									title: 'Hata',
									message: res.message,
								});
							}
						});
					}
				}

			},
		},

		segments: {
			push: function (campaign) {
				var segno = 1;
				
				if (funMain.isDemo) {
					campaign.segmentsForSpin = [];
					campaign.arrSegmentsList = [];
				}
 
				funMain.config.theWheel = [];
				funMain.config.arrsp = [];

				var segments = campaign.arrSegmentsList;

				if (funMain.isDemo) {
					var form = funMain.form;
					$(form).find('.gift-segment-item').each(function (i, item) {
						var v = parseInt($(item).find('.hdnGravity').val());
						var rang = v / 10;
						var cntrec = Math.round(rang);

						for (var p = 0; p &lt; cntrec; p++) {
							funMain.config.arrsp.push(segno);
						}
						segno++;

						campaign.segmentsForSpin.push($(item).find('.gift-name-input').val());
						var isCouponCode = $(item).find('.gift-is-coupon-input').is(':checked') ? 'true' : 'false';
						segments.push({
							fillStyle: $(item).find('.gift-bg-input').val(),
							text: $(item).find('.gift-name-input').val(),
							winresult: $(item).find('.gift-result-input').val(),
							IsCouponCode: isCouponCode,
							CouponCode: $(item).find('.gift-coupon-code-input').val()
						});
					});
				} else {
					campaign.arrSegmentsList.forEach(function (item) {
						var v = parseInt(item.gravity);
						var rang = v / 10;
						var cntrec = Math.round(rang);

						for (var p = 0; p &lt; cntrec; p++) {
							funMain.config.arrsp.push(segno);
						}
						segno++;
					});
				}

				funMain.config.strarr = funMain.config.arrsp.join('|');
			},
		},

		helpers: {
			
			winningGeneral: function () {
				var wrapper = document.querySelector("body");
				var i = 149;
				while (i &gt; -1) {
					var newDiv = document.createElement("div");
					newDiv.className = `confetti-${i}`;
					wrapper.appendChild(newDiv);
					i--;
				}
				setTimeout(function() {
					$.each($('body').find('[class^="confetti-"]'), function(i,item) {
						$(item).remove();
					})
				}, 12000);
			},
	
			wc_hex_is_light: function(color) {
				const hex = color.replace('#', '');
				const c_r = parseInt(hex.substr(0, 2), 16);
				const c_g = parseInt(hex.substr(2, 2), 16);
				const c_b = parseInt(hex.substr(4, 2), 16);
				const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
				return brightness &gt; 155;
			},
	
			checkEmail: function (email) {
				if (!email) {
					return false;
				}
				var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,8})?$/;
				return emailReg.test(email);
			},
	
			topBarBuild: function (campaign) {
				if (!funMain.isDemo &amp;&amp; campaign.isCouponLimited &amp;&amp; campaign.couponLimit) {
					$('.wheel-top-bar').remove();
					var html = '&lt;div class="wheel-top-bar" data-id="'+ campaign.id +'" style="background-color: '+ campaign.topbarBgColor +'; color: '+ campaign.topbarTextColor +'"&gt;Hediye Ã§ekini kullanmak iÃ§in kalan sÃ¼re &lt;span class="wheel-timer"&gt;&lt;/span&gt;&lt;/div&gt;'
					$('body').prepend(html);
					this.timer(campaign)
				}
			},
	
			timer: function (campaign) {
				if (!campaign.isCouponLimited || !campaign.couponLimit) {
					return;
				}

				var minutes = parseInt(campaign.couponLimit);
				var seconds = 0;
				
				let storedCountdown = localStorage.getItem("dfFunTimer_" + campaign.id + 'Init');
				if (storedCountdown) {
					var storedCountdownArray = storedCountdown.split(':');
					minutes = parseInt(storedCountdownArray[0]);
					seconds = parseInt(storedCountdownArray[1]);
				}

				var timer = setInterval(function() {
					seconds--;
					if (seconds &lt; 0) {
						minutes--;
						seconds = 59;
					}

					if (seconds &lt; 10) {
						seconds = '0' + seconds
					}

					if (minutes &lt; 0) {
						clearInterval(timer);
						$('.wheel-top-bar[data-id="'+ campaign.id +'"]').remove();
					} else {
						funMain.localStorage.set('dfFunTimer_' + campaign.id, minutes + ':' + seconds)
						//localStorage.setItem("dfFunTimer_" + campaign.id, minutes + ':' + seconds);

						$('.wheel-top-bar[data-id="'+ campaign.id +'"] .wheel-timer').html(minutes + ':' + seconds);
					}
				}, 1000);
			},	
		},

		localStorage: {
			init: function() {
				this.localStorageReset();
			},

			localStorageReset: function () {
				let now = new Date().getTime();
				for (let key in localStorage) {
					if (!localStorage.hasOwnProperty(key)) continue;

					if (key.endsWith('Init_expire')) {
						let itemExpireTime = parseInt(localStorage.getItem(key));
						if (now &gt; itemExpireTime) {
							let initKey = key.replace('_expire', '');
							localStorage.removeItem(initKey);
							localStorage.removeItem(key);
						}
					}
				}
			},

			set: function(name, value) {
				var expireTime = 1 * 24 * 60 * 60 * 1000;
				var now = new Date().getTime();
				if (!value) {
					value = 'true';
				}
				localStorage.setItem(name + 'Init', value);
				localStorage.setItem(name + 'Init_expire', (now + expireTime).toString());
			},

			get: function(name, type) {
				var ls = localStorage.getItem(name + 'Init');
				if (type == 'expire') {
					ls = localStorage.getItem(name + 'Init_expire');
				}
				return ls;
			},

			isShown: function(name) {
				var lsItem = localStorage.getItem(name + 'Init');

				if (lsItem) {
					return true;
				}

				return false;
			},
		},

		visible: function(campaign) {
			var url = new URL(window.location.href);
			var isPrevParam = url.searchParams.get('dfPreview');
			var campaignIdParam = url.searchParams.get('id');
			var campaignIdLs = localStorage.getItem('df_previewCampaignId');

			if (!campaignIdParam) {
				campaignIdParam = campaignIdLs
			}
			var isPreview = (isPrevParam &amp;&amp; campaignIdParam) || campaignIdLs;

			if (campaign.active || isPreview || funMain.isDemo) {
				return true;
			}

			return false;
		},

		changeHtml: function (campaign, index) {
			var self = this;
			if (campaign.type != 'popup') {
				var isModalLight = funMain.helpers.wc_hex_is_light(campaign.modalBgColor);
				var modalBgColorType = 'wheel-modal-dark';
				if (isModalLight) {
					modalBgColorType = 'wheel-modal-light'
				}

				var htmlContent = $('.df-modal-container');

				var modal = $(htmlContent)
				modal.find('.df-modal-content').removeClass('.wheel-modal-dark, .wheel-modal-light').addClass(modalBgColorType);
				if (campaign.modalBgType == 'image') {
					modal.find('.df-modal-content').attr('style', 'background-repeat: no-repeat;background-size:'+ (campaign.isBgImageFit ? 'auto' : 'cover') +';background-image: url(https://functionality.dfikir.com/uploads/' + campaign.modalBgImage + ')')
				} else {
					modal.find('.df-modal-content').attr('style', 'background-color: ' + campaign.modalBgColor + '');
				}
				modal.removeClass('df-modal-xs df-modal-sm df-modal-xl df-modal-xxl').addClass('df-modal-' + campaign.modalViewSize)
				modal.removeClass('df-modal-lightbox df-modal-slide-in df-modal-fullscreen df-modal-left-bottom df-modal-center-bottom df-modal-right-bottom').addClass('df-modal-' + campaign.modalViewType)
			}
		},

		demoInputStateUpdate: function () {
			var campaign = funMain.config.campaigns[0];
			$.each(funMain.form.find('input, select, textarea'), function (i, item) {
				if ($(this).val() !== '') {
					if ($(item).attr('type') == 'file') {
						var file = $(item)[0].files[0];
						var reader = new FileReader();
						reader.onloadend = function(){
							campaign[$(item).attr('name')] = reader.result;
						}
						if(file){
							reader.readAsDataURL(file);
						}
					} else if ($(item).attr('type') == 'checkbox') {
						campaign[$(item).attr('name')] = $(item).is(':checked');
					} else {
						campaign[$(item).attr('name')] = $(item).val();
					}

					if ($(item).attr('name') == 'newsletterRequired') {
						if ($(item).is(':checked')) {
							$('[data-gamified-screen="2"]').removeClass('df-d-none')
						} else {
							$('[data-gamified-screen="2"]').addClass('df-d-none')
						}
					}
				}
			})
		},

		createDemoCampaigns: function() {
			var data = funMain.config.campaigns[0];
			$('form .form-group .form-control').each(function() {
				var input = $(this);
				var name = input.attr('name');
				var value = input.val();
				if (input.attr('type') == 'file') {
					if (input[0].files[0]) {
						console.log('input[0].files[0] ' + input[0].files[0])
						data[name] = input[0].files[0];
					} else {
						data[name] = input.attr('value');
					}

				} else if (input.attr('type') == 'checkbox') {
					data[name] =  input.is(':checked');
				} else {
					data[name] = value;
				}
			});
		},

		closeModal: function(elm, type) {
			if (type == 'popup') {
				elm.closest('.df-custom-popup').remove();
			}
		},

		eventListener: function () {
			var self = this;

			$(document).on('input change', '#demo-wheel-form [data-dynamic-update="true"]', function (e) {
				self.demoInputStateUpdate();
				setTimeout(function () {
					$.each(funMain.config.campaigns, function (index, campaign) {
						funMain.whell.start(campaign, index);
						funMain.scratch.init(campaign, index);
						funMain.gift.init(campaign, index);
						funMain.changeHtml(campaign, index);
					})
				}, 1000);
			})

			$(document).on('shown.bs.tab', '#nav-design-tab', function (e) {
				funMain.scratch.init();
				funMain.whell.start();
				$.each(funMain.config.campaigns, function (index, campaign) {
					funMain.whell.start(campaign, index);
					funMain.scratch.init(campaign, index);
				})
			})

			$(document).on('click', '#copy-button', function (e) {
				try {
					navigator.clipboard.writeText($(this).closest('.wheel-coupon').find('#code-to-copy').text());
					$(this).addClass('active');
					setTimeout(() =&gt; {
						$(this).removeClass('active');
					}, 3000);
				} catch (err) {
					alert('Kod kopyalanamadÄ±: ', err);
				}
			})

			$(document).on('click', '.u-close-button', function (e) {
				e.preventDefault();
				self.closeModal($(this), 'popup');
			})

			$(document).on('click', '.u-popup-container button[type="submit"]', function (e) {
				e.preventDefault();
				var elm = $(this);
				function callback() {
					elm.closest('.u-popup-container').find('.popup-after-msg').show();
					elm.closest('.u-popup-container').find('form').hide();
				};
				funMain.newsletter.save($(this), callback)
			})
		}
	}
})(jQuery, window);

$(function () {
	funMain.init();
});

$.fn.rotate = function (degrees) {
	$(this).css({
		'-webkit-transform': 'rotate(' + degrees + 'deg)',
		'-moz-transform': 'rotate(' + degrees + 'deg)',
		'-ms-transform': 'rotate(' + degrees + 'deg)',
		'transform': 'rotate(' + degrees + 'deg)'
	});
	return $(this);
};</pre></body></html>