1const minimize_svg='<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 14H10M10 14V20M10 14L3 21M20 10H14M14 10V4M14 10L21 3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',expand_svg='<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 10L21 3M21 3H15M21 3V9M10 14L3 21M3 21H9M3 21L3 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';function scrollToWelcomeSection(){let e=document.getElementById("welcome-ribblr"),t=20,n=e.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:n-t,behavior:"smooth"})}function countDownTimer(){var e,s,o,t=0,n=!1;document.querySelector("#homepage_countdown")!==null&&(dow>=0&&(dow<10?(e=new Date,s=0,dow==s&&e.getUTCHours()>=start_hour&&(n=!0,e.setUTCDate(e.getUTCDate()+1),e.setUTCHours(end_hour,0,0,0),t=e.getTime()),dow+1==s&&e.getUTCHours()<end_hour&&(n=!0,e.setUTCHours(end_hour,0,0,0),t=e.getTime())):(n=!0,t=Date.UTC(end_year,end_month,end_day,end_hour))),n&&(o=new Countdown({cont:document.querySelector("#homepage_countdown"),date:t,outputTranslation:{hour:"Hours",minute:"Minutes",second:"Seconds"},endCallback:null,outputFormat:"hour|minute|second"}),o&&t>0&&o.start()))}$(document).on("click","[id^=pattern-]",function(e){if(typeof which=="undefined"||updateQ=="undefined"||which!=="explore")return!0;const t=$(this).find("a").attr("href");e.preventDefault(),e.stopPropagation();var n=this.id.match(/\d+/);saveEvent("pattern-"+n[0],"event_click",""),t&&(window.location.href=t)}),$(document).on("click","sl-button.fyp-buybtn",function(e){if(user_id>0){{const t=$(this);if(t.data("free")===1){if(e.preventDefault(),e.stopPropagation(),t.prop("loading"))return;const n=t.data("itemid");saveEvent("pattern-"+n,"event_click",""),t.prop("loading",!0),$.ajax({type:"POST",cache:!1,url:"/db_api2",data:{magic:"O4d@",pattern_id:n,bundle:t.data("bundle")||"",cmd:"micro_free_limit"}}).done(function(e){String(e)==="0"?notify(plus_lvl>0?{duration:3500,icon:"<img class='ribbot-icon' src='"+storage_url+"/ribbot/positions/ribbot-wizard.png'>",title:"Ribbot says: you shall pass!",message:'Unlimited freebies with your Ribblr+. <a href="/mypatterns?sort=new"><u>View library</u></a>'}:{title:"Added to your library!",message:'<a href="/mypatterns?sort=new"><u>View library</u></a>'}):String(e)==="1"&¬ify({title:"Free patterns limit reached",message:"Please wait 24 hours to claim more patterns."})}).always(function(){t.prop("loading",!1)});return}const n=$(this).attr("href");if(n&&n.indexOf("/checkout")===0){e.preventDefault();const t=new URL(n,window.location.origin),s=t.searchParams.get("item_id");saveEvent("pattern-"+s,"event_click",""),window.location.href=n}}}else e.preventDefault(),openRegistrationDialog("getpattern"),$("#registrationDialog").prop("open",!0)});function getIgnoredPatterns(){try{const t=localStorage.getItem("foryou_ignore")||"[]",e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}function setIgnoredPatterns(e){try{return Array.isArray(e)&&e.length>500&&e.splice(0,100),localStorage.setItem("foryou_ignore",JSON.stringify(e)),!0}catch{}try{return localStorage.removeItem("foryou"),localStorage.removeItem("foryou_offset"),localStorage.removeItem("foryou_scroll"),localStorage.removeItem("search"),localStorage.removeItem("search_offset"),localStorage.removeItem("search_scroll"),localStorage.setItem("foryou_ignore",JSON.stringify(e)),!0}catch{}return!1}function removeIgnoredPattern(e){try{const n=getIgnoredPatterns().map(String),t=n.indexOf(String(e));if(t!==-1){const e=getIgnoredPatterns();return e.splice(t,1),setIgnoredPatterns(e)}}catch{}return!1}function showHideUndo(e,t,n){try{notify(e)}catch{n();return}const o=$(".sl-toast-stack"),s=o.find("sl-alert.alert").first();if(!s.length){n();return}const a=new MutationObserver(function(){o.find(s).length||i()});function i(){a.disconnect(),s.off(".hideUndo"),n()}a.observe(o.get(0),{childList:!0}),s.one("sl-after-hide.hideUndo",i),s.on("click.hideUndo",".alert-btn",function(e){if(e.preventDefault(),e.stopPropagation(),!t()){
1s.find(".alert-title").text("Couldn't save Undo"),s.find(".alert-text").remove(),s.find(".alert-message").append('<div class="alert-text">Please try again.</div>');return}i(),s.find(".alert-title").text("Undo complete."),s.find(".alert-text").remove(),s.find(".alert-btn").remove(),setTimeout(function(){s.prop("open",!1)},1500)})}$(document).on("click","sl-card.foryou-item .fyp-dismiss:not(.continue-project-dismiss)",function(e){e.preventDefault(),e.stopPropagation();const t=$(this).data("patid");if(t==null||String(t)==="")return;const n=getIgnoredPatterns(),i=String(t);if(n.map(String).includes(i)||n.push(t),!setIgnoredPatterns(n)){notify({title:"Couldn't hide pattern",message:"Please try again. Your preference could not be saved."});return}const o=$(this).closest("sl-card.foryou-item"),s=$('<div class="fyp-undo-anchor" style="display:none"></div>');s.insertBefore(o);const a=o.detach();showHideUndo({duration:3500,title:"Pattern ignored",message:"",btn_txt:"Undo"},function(){return!!removeIgnoredPattern(t)&&(s.replaceWith(a),!0)},function(){s.remove()})});function getIgnoredContinueProjects(){try{const t=typeof user_id!="undefined"&&user_id>0?user_id:"guest",n=localStorage.getItem("continue_projects_ignore_"+t)||"[]",e=JSON.parse(n);return Array.isArray(e)?e.map(function(e){return e&&typeof e=="object"?{patid:String(e.patid||""),dismissed_at:+e.dismissed_at||0,progress_at_dismiss:+e.progress_at_dismiss||0}:{patid:String(e||""),dismissed_at:0,progress_at_dismiss:0}}).filter(function(e){return e.patid.length>0}):[]}catch{return[]}}function setIgnoredContinueProjects(e){try{const t=typeof user_id!="undefined"&&user_id>0?user_id:"guest";return localStorage.setItem("continue_projects_ignore_"+t,JSON.stringify(e)),!0}catch{return!1}}function removeIgnoredContinueProject(e){try{const t=String(e||""),n=getIgnoredContinueProjects().filter(function(e){return e.patid!==t});return setIgnoredContinueProjects(n)}catch{return!1}}function getContinueProjectProgress(e){const t=+e.data("progress");return Number.isFinite(t)?t:0}function shouldHideContinueProject(e,t,n){const s=+e.dismissed_at||0,o=+e.progress_at_dismiss||0,i=60*24*60*60*1e3;return!(!s||n-s>=i)&&!(t>=o+10)}function applyContinueProjectIgnores(e){const s=getIgnoredContinueProjects(),o={},t={},a=Date.now(),r=$(e||document),n=r.find(".continue-projects");if(!n.length)return;s.forEach(function(e){o[e.patid]=e,t[e.patid]=e}),n.find('.pattern-item[id^="pattern-"]').each(function(){const n=String(this.id||"").match(/\d+/),s=n?String(n[0]):"",e=o[s],i=getContinueProjectProgress($(this));e&&shouldHideContinueProject(e,i,a)?$(this).remove():e&&delete t[s]});const i=Object.keys(t).map(function(e){return t[e]});JSON.stringify(s)!==JSON.stringify(i)&&setIgnoredContinueProjects(i),n.find('.pattern-item[id^="pattern-"]').length||n.remove()}$(document).on("click",".continue-project-dismiss",function(e){e.preventDefault(),e.stopPropagation();const t=String($(this).data("patid")||"");if(!t.length)return;const n=$(this).closest('.pattern-item[id^="pattern-"]'),s=$(this).closest(".continue-projects");if(!n.length||!s.length)return;const c=getContinueProjectProgress(n),r=getIgnoredContinueProjects().filter(function(e){return e.patid!==t});if(r.push({patid:t,dismissed_at:Date.now(),progress_at_dismiss:c}),!setIgnoredContinueProjects(r)){notify({title:"Couldn't hide project",message:"Please try again. Your preference could not be saved."});return}const o=$('<div class="continue-project-section-anchor" style="display:none"></div>'),i=$('<div class="continue-project-card-anchor" style="display:none"></div>');o.insertBefore(s),i.insertBefore(n);const l=n.detach();let a=null;s.find('.pattern-item[id^="pattern-"]').length||(a=s.detach()),showHideUndo({duration:6500,title:"Removed from section",message:"",btn_txt:"Undo"},function(){return!!removeIgnoredContinueProject(t)&&(a&&o.replaceWith(a),i.replaceWith(l),!0)},function(){o.remove(),i.remove()})});function saveEvent(e,t,n){if(typeof updateQ=="undefined")return;const s=Math.floor(Date.now()/1e3);updateQ.push({id:e,event:t,stamp:s,src:n})}function update_recommend_event(){if(updateQ?.length==0)return;if(user==0){updateQ=[];return}let e=JSON.stringify(updateQ);
1updateQ=[],$.ajax({type:"POST",cache:!1,url:"/db_api_no2",dataType:"json",data:{magic:"15e@",cmd:"update_recommend_event",data:e}}).done(function(){console.log(e)}).fail(function(e){console.log(e)})}function watchSeen(e){var t=$(e),n={root:null,rootMargin:"0px",threshold:.5},s=new IntersectionObserver(function(e,t){e.forEach(function(e){if(e.isIntersecting){let n=e.target.id;if(which=="foryou"){let n=$(e.target).find(".view_img"),t=n.attr("src");t&&t.endsWith("_")&&(t=t.slice(0,-1),n.attr("src",t))}console.log("Seen id="+n),t.unobserve(e.target),(which=="foryou"||which=="explore")&&saveEvent(n,"event_seen",which)}})},n);t.each(function(){s.observe(this)})}function getVpat(e,t,n){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_patterns",which:"vpat",user_id:user,list_offset:0,list_limit:4}}).done(function(s){t(e,n,s,4,4,null)}).fail(function(e){console.log(e)})}function getRecommendations(e,t,n,s,o){let i=200;if(t==="home"&&typeof which!="undefined"&&which==="explore")try{const t=localStorage.getItem("foryou_ignore")||"[]",e=JSON.parse(t),n=Array.isArray(e)?Math.min(200,e.length):0;i=Math.min(400,i+n)}catch{}$.ajax({type:"POST",cache:!1,url:e==="get_materials_recommend"?"/db_api_mat":"/db_api_no2",dataType:"json",data:{magic:"15e@",cmd:e,user_id:user,date_start_4u:o,limit:i,seed:lastSeed}}).done(function(e){n(t,s,e,i,8,null),watchSeen(".update_seen")}).fail(function(e){console.log(e)})}let lastTapTime=0,lastTapX=0,lastTapY=0,lastTapScrollTop=0,touchMoved=!1,activeStartX=0,activeStartY=0,activeStartScrollTop=0,touchTimeout,recentDoubleTapUntil=0;function getForyouScrollTop(e){const t=$(e).closest(".for_you_list");return t.length?t[0].scrollTop||0:$(window).scrollTop()||document.documentElement.scrollTop||0}$(document).on("touchstart",".foryou-item .pat_img",function(e){try{const t=e.originalEvent?.touches?.[0]||e.touches?.[0];t&&(activeStartX=t.clientX,activeStartY=t.clientY),activeStartScrollTop=getForyouScrollTop(this),touchMoved=!1}catch{}}),$(document).on("touchmove",".foryou-item .pat_img",function(e){try{const t=e.originalEvent?.touches?.[0]||e.touches?.[0];if(!t)return;const n=Math.abs(t.clientX-activeStartX),s=Math.abs(t.clientY-activeStartY);(n>10||s>10)&&(touchMoved=!0)}catch{}}),$(document).on("click touchend",".foryou-item .pat_img",function(e){if(user_id<=0)return;const d=220,o=10,s=$(this),t=getForyouScrollTop(this);if(e.type==="click"){e.detail===2&&(e.preventDefault(),toggleWishlistFromImage(s,e));return}const i=Date.now(),a=e.originalEvent?.changedTouches?.[0]||e.changedTouches?.[0],n=a?.clientX??activeStartX,r=a?.clientY??activeStartY,u=Math.abs(t-activeStartScrollTop);if(touchMoved||u>o){lastTapTime=0,lastTapX=0,lastTapY=0,lastTapScrollTop=0,touchMoved=!1,clearTimeout(touchTimeout);return}const c=i-lastTapTime,h=c>0&&c<d,m=lastTapTime&&Math.abs(t-lastTapScrollTop)>o;let l=!0;if(lastTapTime){const e=Math.abs(n-lastTapX),t=Math.abs(r-lastTapY);l=e<=20&&t<=20}if(h&&l&&!touchMoved&&!m){e.preventDefault(),toggleWishlistFromImage(s,e),lastTapTime=0,lastTapX=0,lastTapY=0,lastTapScrollTop=0,touchMoved=!1,clearTimeout(touchTimeout);return}lastTapTime=i,lastTapX=n,lastTapY=r,lastTapScrollTop=t,touchMoved=!1,clearTimeout(touchTimeout),touchTimeout=setTimeout(()=>{lastTapTime=0,touchMoved=!1,lastTapScrollTop=0},300)});function toggleWishlistFromImage(e,t){const s=e.data("patid"),n=e.closest("sl-card").find(".fyp-savebtn"),o=n.find(".fyp-icon");typeof window.triggerAppHapticForTarget=="function"?window.triggerAppHapticForTarget(n[0],"selection"):typeof triggerAppHaptic=="function"&&triggerAppHaptic("selection"),o.hasClass("saved")?(o.removeClass("saved"),n.html(` 2 <div class="fyp-icon" slot="prefix"> 3 ${add_to_wishlist_svg} 4 </div> 5 Save 6 `),updateWishlist(t,null,s,1,"pattern")):(o.addClass("saved"),n.html(` 7 <div class="fyp-icon saved" slot="prefix"> 8 ${remove_wishlist_svg} 9 </div> 10 Saved 11 `),updateWishlist(t,null,s,0,"pattern"),saveEvent("pattern-"+s,"event_wish","")),recentDoubleTapUntil=Date.now()+300}lastSeed=Math.floor(Math.random()*1e6),$(document).ready(function(){const _=performance.getEntriesByType("navigation")[0];if(_&&_.type==="back_forward")try{const e=localStorage.getItem("lastSeed");if(e!==null){const t=parseInt(e,10);Number.isNaN(t)||(lastSeed=t)}}catch{}else try{localStorage.setItem("lastSeed",lastSeed.toString())}catch{}applyContinueProjectIgnores("#home-content"),typeof window.fill_placeholders!="function"&&(window.fill_placeholders=function(e,t){try{$(e).removeClass("empty")}catch{}let n="";for(let s=0;s<t;s++){const o=typeof e=="string"&&e.startsWith(".")?e.substring(1):"list";n+=` 12 <sl-card class="pattern-item loader-contain fill-${o}"> 13 <div class="loader-img preloader-item" slot="image"> 14 <div class="loader-img-abs"></div> 15 </div> 16 <sl-skeleton class="loader-text" effect="sheen"></sl-skeleton> 17 <sl-skeleton class="loader-text3" effect="sheen"></sl-skeleton> 18 <sl-skeleton class="loader-text2" effect="sheen" style="display:none;"></sl-skeleton> 19 </sl-card>`}try{$(e).append(n).fadeIn()}catch{}});function j(){document.documentElement.style.setProperty("--vhForYou",`${window.innerHeight*.01}px`)}const o=8e3,t=350,e=new Map;let c=null,b=0;function S(){e.clear();const t=$('.foryou-item .fyp-card-img[data-story="1"]');t.each(function(){const t=this,s=t.id||"fyp-card-"+Math.random();t.id||(t.id=s);let n=[];try{const e=t.getAttribute("data-images")||"[]";n=JSON.parse(e)||[]}catch{n=[]}if(Array.isArray(n)&&n.length>=3){e.set(s,{images:n,idx:0,timer:null,animTO:null});const o=$(t).find(".story-bar");o.removeClass("filled active")}}),T(),h()}function T(){const s=$(".for_you_list");if(s.data("stories-bound"))return;const o=s[0];if(o){let e=!1;const t=()=>{if(e)return;e=!0,requestAnimationFrame(()=>
19{e=!1,b=Date.now(),h()})};o.addEventListener("scroll",t,{passive:!0})}$(window).on("resize",w(h,100));let t=0;function n(){const e=Date.now();return lastTapTime&&e-lastTapTime<250||e<recentDoubleTapUntil}function e(e,t){const s=t.getBoundingClientRect();let o=e.changedTouches&&e.changedTouches[0]?.clientX||e.touches&&e.touches[0]?.clientX||e.clientX;if(typeof o!="number")return{left:!1,right:!1,center:!0};const n=o-s.left,i=s.width*.2,a=s.width*.8;return{left:n<=i,right:n>=a,center:n>i&&n<a}}$(document).on("touchend",".foryou-item .story-right, .foryou-item .story-left",function(s){t=Date.now();const o=$(this).closest(".fyp-card-img")[0];if(!o)return;if(n())return;const i=e(s,o);$(this).hasClass("story-right")?i.right&&(s.stopPropagation(),l(o)):i.left&&(s.stopPropagation(),u(o))}),$(document).on("click",".foryou-item .story-right, .foryou-item .story-left",function(s){if(Date.now()-t<500)return;const o=$(this).closest(".fyp-card-img")[0];if(!o)return;if(n())return;const i=e(s,o);$(this).hasClass("story-right")?i.right&&(s.stopPropagation(),l(o)):i.left&&(s.stopPropagation(),u(o))}),$(document).on("touchend",".foryou-item .fyp-card-img",function(s){if(t=Date.now(),$(s.target).closest(".fyp-dismiss, .fyp-shop, .foryou-actions, a, .fyp-savebtn").length)return;const o=this;if(n())return;const i=e(s,o);i.left?(s.stopPropagation(),u(o)):i.right&&(s.stopPropagation(),l(o))}),$(document).on("click",".foryou-item .fyp-card-img",function(s){if(Date.now()-t<500)return;if($(s.target).closest(".fyp-dismiss, .fyp-shop, .foryou-actions, a, .fyp-savebtn").length)return;const o=this;if(n())return;const i=e(s,o);if(i.left)s.stopPropagation(),u(o);else if(i.right)s.stopPropagation(),l(o);else if(s.detail===2){const e=$(this).find("img.pat_img").first();e.length&&toggleWishlistFromImage(e,s)}}),$(document).on("touchstart",".foryou-item .fyp-card-img",function(t){if(user_id<=0)return;const s=e(t,this);if(!s.center)return;const n=t.originalEvent?.touches?.[0]||t.touches?.[0];n&&(activeStartX=n.clientX,activeStartY=n.clientY),activeStartScrollTop=getForyouScrollTop(this),touchMoved=!1}),$(document).on("touchmove",".foryou-item .fyp-card-img",function(e){const t=e.originalEvent?.touches?.[0]||e.touches?.[0];if(!t)return;const n=Math.abs(t.clientX-activeStartX),s=Math.abs(t.clientY-activeStartY);(n>10||s>10)&&(touchMoved=!0)}),$(document).on("touchend",".foryou-item .fyp-card-img",function(t){if(user_id<=0)return;const m=e(t,this);if(!m.center)return;const a=$(this).find("img.pat_img").first();if(!a.length)return;const h=220,i=10,n=getForyouScrollTop(this),r=Date.now(),c=t.originalEvent?.changedTouches?.[0]||t.changedTouches?.[0],o=c?.clientX??activeStartX,s=c?.clientY??activeStartY,u=Math.abs(n-activeStartScrollTop);if(touchMoved||u>i){lastTapTime=0,lastTapX=0,lastTapY=0,lastTapScrollTop=0,touchMoved=!1,clearTimeout(touchTimeout);return}const l=r-lastTapTime,d=l>0&&l<h,f=Math.abs(o-lastTapX),p=Math.abs(s-lastTapY),g=f<=20&&p<=20,v=lastTapTime&&Math.abs(n-lastTapScrollTop)>i;if(d&&g&&!touchMoved&&!v){toggleWishlistFromImage(a,t),lastTapTime=0,lastTapX=0,lastTapY=0,lastTapScrollTop=0,touchMoved=!1,clearTimeout(touchTimeout);return}lastTapTime=r,lastTapX=o,lastTapY=s,lastTapScrollTop=n,touchMoved=!1,clearTimeout(touchTimeout),touchTimeout=setTimeout(()=>{lastTapTime=0,touchMoved=!1,lastTapScrollTop=0},300)}),s.data("stories-bound",!0)}function w(e,t){let n;return function(){const s=this,o=arguments;clearTimeout(n),n=setTimeout(()=>e.apply(s,o),t)}}function h(){const s=window.innerHeight*.5;let e=null;$(".foryou-item").each(function(){const t=this.getBoundingClientRect();if(t.top>=0&&t.top<=s)return e=$(this),!1});const t=e&&e.length?e.find('.fyp-card-img[data-story="1"]')[0]:null,n=t?t.id:null;if(n===c)return;if(c){const e=document.getElementById(c);e&&d(e)}c=n,t&&x(t)}const n=new Map,f=[],M=32;function O(e){if(f.push(e),f.length>M){const e=f.shift();e&&n.has(e)&&n.delete(e)}}function r(e,t={idle:!1}){if(!e)return Promise.resolve();if(n.has(e))return n.get(e);const s=new Image;s.decoding="async",s.loading="lazy";let o;const i=()=>s.decode?(s.src=e,s.decode().catch(()=>{})):new Promise(t=>{s.onload=t,s.onerror=t,s.src=e}),a=t.idle||Date.now()-b<100;return a&&"requestIdleCallback"in window?o=new Promise(e=>{requestIdleCallback(()=>{i().then(e).catch(e)},{timeout:300})}):o=i(),n.set(e,o),O(e),o}function i(n,s){const c=n.id;if(!e.has(c))return;const o=e.get(c);o.idx=Math.max(0,Math.min(s,o.images.length-1));const i=$(n).find("img.pat_img")[0],d=i&&i.src&&i.src.endsWith("_")?"_":"",r=o.idx,l=(o.images[r]||"")+d;i&&l&&(i.src=l);const a=$(n).find(".story-bar");a.removeClass("active filled");const u=a.find("span");u.each(function(){this.style.transition="none",this.style.width="0%"}),a.each(function(e){if(e<r){$(this).addClass("filled");const e=$(this).find("span")[0];e&&(e.style.transition="none",e.style.width="100%")}}),o.animTO&&(clearTimeout(o.animTO),o.animTO=null),o.animTO=setTimeout(()=>{$(a[r])?.addClass("active");const e=$(a[r]).find("span")[0];e&&(e.style.transition="none",e.style.width="0%",void e.offsetWidth,e.style.transition="width 8s linear",e.style.width="100%")},t)}function x(n){if(!n)return;const l=n.id,a=e.get(l);if(!a)return;d(n),i(n,a.idx);const u=(a.idx+1)%a.images.length,c=$(n).find("img.pat_img")[0],h=c&&c.src&&c.src.endsWith("_")?"_":"";r((a.images[u]||"")+h,{idle:!0}),a.timer=setTimeout(()=>s(n,!0),o+t)}function d(t){if(!t)return;const s=t.id,n=e.get(s);if(!n)return;n.timer&&(clearTimeout(n.timer),n.timer=null),n.animTO&&(clearTimeout(n.animTO),n.animTO=null),$(t).find(".story-bar span").each(function(){this.style.transition="none"})}function s(n,a=!1){const d=n.id,c=e.get(d);if(!c)return;const l=(c.idx+1)%c.images.length;if(i(n,l),a){const e=$(n).find("img.pat_img")[0],i=e&&e.src&&e.src.endsWith("_")?"_":"",a=(l+1)%c.images.length;r((c.images[a]||"")+i,{idle:!0}),c.timer=setTimeout(()=>s(n,!0),o+t)}}function D(n,a=!1){const c=n.id,r=e.get(c);if(!r)return;const l=(r.idx-1+r.images.length)%r.images.length;i(n,l),a&&(r.timer=setTimeout(()=>s(n,!0),o+t))}function l(n){if(!n)return;const u=n.id,a=e.get(u);if(!a)return;d(n);const l=(a.idx+1)%a.images.length;i(n,l);const c=$(n).find("img.pat_img")[0],h=c&&c.src&&c.src.endsWith("_")?"_":"",m=(l+1)%a.images.length;r((a.images[m]||"")+h,{idle:!0}),a.timer=setTimeout(()=>s(n,!0),o+t)}function u(n){if(!n)return;const u=n.id,a=e.get(u);if(!a)return;d(n);const l=(a.idx-1+a.images.length)%a.images.length;i(n,l);const c=$(n).find("img.pat_img")[0],h=c&&c.src&&c.src.endsWith("_")?"_":"",m=(l+1)%a.images.length;r((a.images[m]||"")+h,{idle:!0}),a.timer=setTimeout(()=>s(n,!0),o+t)}
19$(document).on("click",".readmore-link",function(){let e=$(this).data("id");$("#introtext-"+e).hasClass("expand")?($("#introtext-"+e).removeClass("expand"),$(this).text("Show More")):($("#introtext-"+e).addClass("expand"),$(this).text("Show Less"))}),setInterval(update_recommend_event,5e3),$(document).on("click",".tab",function(){let e=$(this).data("tab");$(".tab").removeClass("selected"),$(this).addClass("selected"),loadContent(e,0)});function m(){if(!pageReady){const e=setTimeout(m,100);return}if(typeof page_ajax_info.onsale!="undefined"&&page_ajax_info.onsale.length&&(list_offset=0,updatePatObg("home_sale",".more-sale-list",page_ajax_info.onsale,8,10,null),page_ajax_info.onsale=[]),typeof page_ajax_info.community!="undefined"&&Object.keys(page_ajax_info.community).length){$(".community_posts").html(page_ajax_info.community.posts),z(200);let e=page_ajax_info.community.testers;const t="/t/testing-zone-how-to-test-guidelines";e=e.filter(e=>e.indexOf(t)===-1),user_id==0&&(e=e.map(e=>e.replace(/href="https:\/\/meet/g,'data-ref="https://meet'))),$(".community_testers .testers-body").html(e),k(200),page_ajax_info.community.msgs!=0?(page_ajax_info.community.msgs==-1?($("#community_msg").text("1"),$("#community_msg2").text("1")):($("#community_msg").text(page_ajax_info.community.msgs),$("#community_msg2").text(page_ajax_info.community.msgs)),$("#community_msg").css("display","block"),$("#community_msg2").css("display","block")):($("#community_msg").css("display","none"),$("#community_msg2").css("display","none")),page_ajax_info.community=[]}}$(document).on("click",".fyp-showmore",function(){let e=$(this).data("patid");const t=$(this);$.ajax({type:"POST",cache:!1,url:"/db_api_no2",data:{magic:"15e@",cmd:"fetch_pat_intro",patId:e}}).done(function(t){$(`#pattern-${e} .introtext`).html(removeQuotes(t,!1))}).fail(function(e){console.error(e)}),$.ajax({type:"POST",cache:!1,url:"/db_api_no2",dataType:"json",data:{magic:"15e@",cmd:"fetch_mat_list",patId:e}}).done(function(n){$(`#mat-list-${e}`).html(n),$(`#pat-img${e}`).addClass("details"),$(`#pattern-${e}`).addClass("details"),$("body").addClass("foryou-details-open"),t.find(".fyp-icon").html(minimize_svg),t.addClass("fyp-showless").removeClass("fyp-showmore")}).fail(function(e){console.error(e)}),$.ajax({type:"POST",cache:!1,url:"/db_api_no2",data:{magic:"15e@",cmd:"fetch_smart_match",patId:e}}).done(function(t){let n=$(`#smart-match-${e}`);n.html(replace2CDN(t)),typeof initSmartMatch=="function"&&initSmartMatch(n.find(".smart-match-section"))}).fail(function(e){console.error(e)})}),$(document).on("click",".fyp-showless",function(){let e=$(this).data("patid");const t=$(this);$(`#mat-list-${e}`).html(""),$(`#smart-match-${e}`).html(""),$(`#pat-img${e}`).removeClass("details"),$(`#pattern-${e}`).removeClass("details"),$(".foryou-item.details").length||$("body").removeClass("foryou-details-open"),t.find(".fyp-icon").html(expand_svg),t.addClass("fyp-showmore").removeClass("fyp-showless")}),window.fetchGems=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_admin_info",offset:0,limit:4,which:"gems"}}).done(function(e){patterns=e,updatePatObg("gems",".all_patterns_list_gems",e,4,4,null),$("li").each(function(){var e=$
19(this).attr("id");$(this).find('a[href^="/pattern/"]').attr("href","javascript:claim("+e+")")})}).fail(function(e){console.log(e)})};var g,y,p=!1;window.fetchCommunity=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_home4u",user_id,art_type:art_type_sess,which:"community",mobile}}).done(function(e){page_ajax_info.community=e,p=!0,m()}).fail(function(e){console.log(e)})},window.fetchMsgs=function(){if(p||user_id==0)return;$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_home4u",which:"getmsg",user_id,art_type:0,mobile:0}}).done(function(e){e!=null&&(p=!0,e==0?($("#community_msg").css("display","none"),$("#community_msg2").css("display","none")):(e==-1&&(e=1),$("#community_msg").text(e),$("#community_msg2").text(e),$("#community_msg").css("display","block"),$("#community_msg2").css("display","block")))}).fail(function(e){console.log(e)})},window.fetchSaleWishlist=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_sale_wishlist",user_id,limit:12}}).done(function(e){list_offset=0,e?.length>0?updatePatObg("following",".wishlist-sale-list",e,12,12,null):$(".wishlist-sale").remove()}).fail(function(e){console.log(e)})},window.fetchSaleYarnWishlist=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_mat",dataType:"json",data:{magic:"15e@",cmd:"get_sale_yarn_wishlist",limit:12}}).done(function(e){list_offset=0,Array.isArray(e)&&e.length>0?updateMatObg("following",".yarn-sale-list",e,12,12,null):$(".yarn-sale").remove()}).fail(function(e){console.log(e),$(".yarn-sale").remove()})},window.fetchTrendingWishlist=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_trending_wishlist",user_id,limit:12}}).done(function(e){list_offset=0,e?.length>0?updatePatObg("following",".trending-fav-list",e,12,12,null):$(".trending-fav").remove()}).fail(function(e){console.log(e)})},window.fetchLatestFav=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_latest_faves",user_id,limit:12}}).done(function(e){list_offset=0,e?.length>0?updatePatObg("following",".new-follow-list",e,12,12,null):$(".new-following").remove()}).fail(function(e){console.log(e)})},window.fetchLatestMakers=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_makes_fav",user_id,limit:12}}).done(function(e){list_offset=0,e?.length>0?updateMakesObg("following",".new-makers-list",e,12,12,null):$(".new-makers").remove()}).fail(function(e){console.log(e)})},window.fetchOnSale=function(){$.ajax({type:"POST",cache:!1,url:"/db_api_no",dataType:"json",data:{magic:"15e@",cmd:"get_home4u",which:"onsale",user_id,art_type:art_type_sess,mobile}}).done(function(e){page_ajax_info.onsale=e,m()}).fail(function(e){console.log(e)})},window.loadContent=function(e){itemsCopy=[];const n=new URLSearchParams(window.location.search).get("flash_yarn_preview")==="1";let t="";switch(e){case"explore":t="/home";break;default:t=`/home?which=${e}`,e==="sale"&&n&&(t+="&flash_yarn_preview=1");break}if(!history.state){const e=new URLSearchParams(window.location.search).get("which")||"home";history.replaceState({page:e},"",window.location.href)}window.location.pathname+window.location.search!==t&&history.pushState({page:e},"",t);const s={which:e};e==="sale"&&n&&(s.flash_yarn_preview="1"),$.ajax({url:`/home-content`,type:"GET",data:s,success:function(t){let n=$(t),s=replace2CDN(n.html());switch(which=e,$("#home-content").html(s),applyContinueProjectIgnores("#home-content"),$("body").removeClass("has-for-you"),e){case"following":fill_placeholders(".new-follow-list",12),fill_placeholders(".wishlist-sale-list",12),fill_placeholders(".yarn-sale-list",12),fill_placeholders(".trending-fav-list",12),fill_placeholders(".new-makers-list",12);break;case"foryou":$("body").addClass("has-for-you"),$("html, body").animate({scrollTop:0},200),fill_placeholders(".for_you_list",5),setTimeout(function(){$(".for_you_list").css("scroll-snap-type","y mandatory")},2e3);break;case"sale":fill_placeholders(".more-sale-list",10);break;case"explore":default:fill_placeholders(".all_patterns_list",8),fill_placeholders(".all_patterns_list_gems",4),(typeof yarnSalesEnabled=="undefined"||yarnSalesEnabled)&&fill_placeholders(".all_materials_list",4);break}try{localStorage.setItem("homeTab",e)}catch{}C(e),typeof window.updateHeaderGemWalletVisibility=="function"&&window.updateHeaderGemWalletVisibility(),window.addEventListener("resize",j),j()},error:function(){$("#home-content").html("<p>Error loading content.</p>")}})};function C(e){switch(E(),clrWithinFlags(),e){case"explore":$("body").removeClass("has-for-you"),getRecommendations("get_patterns_recommend","home",updatePatObg,".all_patterns_list",date_start_4u),(typeof yarnSalesEnabled=="undefined"||yarnSalesEnabled)&&getRecommendations("get_materials_recommend","home",updateMatObg,".all_materials_list",date_start_4u),getVpat("vpatHome",updatePatObg,".vPatterns_t
19wo"),fetchCommunity(),fetchGems(),(typeof yarnSalesEnabled=="undefined"||yarnSalesEnabled)&&typeof window.initExploreUnboxingTiles=="function"&&window.initExploreUnboxingTiles(),countDownTimer();break;case"sale":$("body").removeClass("has-for-you"),bigSaleOn||fetchOnSale(),fetchMsgs(),countDownTimer();break;case"foryou":$("body").addClass("has-for-you"),getRecommendations("get_patterns_recommend","foryou",updatePatObg,".for_you_list",date_start_4u),fetchMsgs(),setTimeout(function(){$(".for_you_list").css("scroll-snap-type","y mandatory"),setTimeout(S,250)},2e3);break;case"following":$("body").removeClass("has-for-you"),fetchLatestFav(),fetchLatestMakers(),fetchSaleWishlist(),fetchSaleYarnWishlist(),fetchTrendingWishlist(),fetchMsgs();break}console.debug("Reinitialized scripts for page: "+e)}function E(){for(let e in cntDnTimer)cntDnTimer.hasOwnProperty(e)&&e!="cntDnTop"&&(clearInterval(cntDnTimer[e]),delete cntDnTimer[e])}let N=new URLSearchParams(window.location.search);const A=typeof user_id!="undefined"&&user_id>0,v=A?["foryou","following","explore","sale"]:["foryou","explore","sale"];let a="";try{a=localStorage.getItem("homeTab")||""}catch{}v.indexOf(a)===-1&&(a=typeof which!="undefined"&&v.indexOf(which)!==-1?which:"explore"),history.replaceState({page:a},"",window.location.href),window.loadContent(a),window.addEventListener("popstate",function(e){if(e.state&&e.state.page){let{page:t}=e.state;window.loadContent(t)}else{let e=new URLSearchParams(window.location.search),t=e.get("which")||"home";this.window.loadContent(t)}}),$(document).on("click",".fyp-savebtn",function(e){if(e.preventDefault(),user_id>0){const n=$(this),t=$(this).data("patid"),s=n.find(".fyp-icon");typeof window.triggerAppHapticForTarget=="function"?window.triggerAppHapticForTarget(this,"selection"):typeof triggerAppHaptic=="function"&&triggerAppHaptic("selection"),s.hasClass("saved")?(s.removeClass("saved"),n.html(` 20 <div class="fyp-icon" slot="prefix"> 21 ${add_to_wishlist_svg} 22 </div> 23 Save 24 `),console.log(`Pattern ${t} unsaved.`),updateWishlist(e,null,t,1,"pattern")):(s.addClass("saved"),n.html(` 25 <div class="fyp-icon saved" slot="prefix"> 26 ${remove_wishlist_svg} 27 </div> 28 Saved 29 `),console.log(`Pattern ${t} saved.`),updateWishlist(e,null,t,0,"pattern"),saveEvent("pattern-"+t,"event_wish",""))}else openRegistrationDialog("getpattern"),$("#registrationDialog").prop("open",!0)}),$(document).on("click","[id^=follow_store]",function(){var t=parseInt(this.id.match(/\d+/));let n=$(`#follow_store${t} .follow_text`),s=n.html().trim().toLowerCase()=="follow"?1:0;F(t,s)});function F(e,t){$.ajax({cache:!1,url:"/db_api",type:"post",data:{magic:"O4d@",id:e,onoff:t,which:0,cmd:"update_favorite"}}).done(function(){let s=$("#follow_store"+e);if(!s?.length)return;let o=s.find(".follow_text"),i=s.find(".follow_icon");t==1?(o.html("Following"),i.html(check_svg)):(o.html("Follow"),i.html(plus_svg))}).fail(function(){})}$(document).on("click",".sign-banner-btn",function(){$("#registrationDialog").prop("open",!0)}),y=$(window).width()>1024?2:1;function z(){$(".topics-list").lightSlider({item:y,slideMove:1,speed:600,auto:!0,pause:5e3,loop:!0,controls:!1,pager:!0,enableTouch:!0,enableDrag:!0,mode:"slide"})}g=$(window).width()>1400?4:$(window).width()>1024?3:1;function k(){$("#testerSlider").lightSlider({item:g,slideMove:1,speed:600,auto:!0,pause:7500,loop:!0,controls:!1,pager:!0,enableTouch:!0,enableDrag:!0,mode:"slide"})}}),$(window).on("beforeunload",update_recommend_event);var lastSeed,tabsArr=["foryou","following","explore","sale"],tabsIndex=0,Xstart=0,Ystart=0,Xend=0,Yend=0;const Xmin=100,Ymax=50
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.