class BloggerScript{constructor(t){this.config=t||{}}err(t){return console.log(t),t}createRT(t){let e="",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=s.length;for(let i=0;i{0!=t[s]&&"object"!=typeof t.type?e.searchParams.set(s,t[s]):"object"==typeof t.type&&"alt"==s?e.searchParams.set(s,t[s]):"object"!=typeof t.type||"comments"!=t.type.name||"start-index"!=s&&"max-results"!=s||e.searchParams.set(s,t[s])}),e}resizeImage(t,e=!1){if(!e)return t;let s=/\/(s|w|h)\d{1,4}-((w|s|h)(\d{1,4})+-)?(c{1,2}|p-k-no-nu|rw)/gi,r=/\=(s|w|h)\d{1,4}-((w|s|h)(\d{1,4})+-)?(c{1,2}|p-k-no-nu|rw)/gi,i=/(\/(w|h|s)\d{1,4}\/)/gi,n=/(\=(w|h|s)\d{1,4})$/gi,o=/\-(rw)$/.test(e);return i.test(t)&&(t=t.replace(i,"/s72-c/")),n.test(t)&&(t=t.replace(n,"=s72-c")),o&&(t=t.replace(/\.(gif|jpe?g|tiff?|png|bmp)$/,".webp")),t.match(s)?t.replace(s,`/${e}`):t.match(r)?t.replace(r,`=${e}`):t}shuffle(t){var e,s,r=t.length;if(0===r)return[];for(;--r;)e=Math.floor(Math.random()*(r+1)),s=t[r],t[r]=t[e],t[e]=s;return t}shuffle2(t,e){return Math.floor(Math.random()*(e-t))+t}sort(t,e){if("Update"==e||"Added"==e){let s="Update"==e?"updated":"published";t=t.sort(function(t,e){return t[s]e[s]?1:0}).reverse()}else"A-Z"!=e&&"Z-A"!=e||(t=t.sort((t,e)=>t.title.localeCompare(e.title,void 0,{numeric:!0})),"Z-A"==e&&(t=t.reverse()));return t}xhr(t,e=this.err){let s=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");s.onreadystatechange=function(){if(4==this.readyState&&200==this.status||304==this.status){let t=this.responseText,s=JSON.parse(t.substring(t.indexOf("{"),t.lastIndexOf("}")+1));e&&e(s)}else 4==this.readyState&&e&&e({})},s.open("GET",t,!0),s.send()}xhr2(t,e=this.err){let s=document.createElement("script"),r="xhr2"+this.createRT(7);return window[r]=function(t){return e(t)},s.src=`${t}&callback=window.${r}`,s.onerror=function(t){console.log(t),e({})},s.async=!0,(document.body||document.getElementsByTagName("body")[0]).appendChild(s)}getXHRtype(t){return new URL(t).hostname==document.location.hostname?"xhr":"xhr2"}get config(){return this._config}set config(t){"_config"in this||(this._config={host:document.location.hostname,feed:"default",type:"posts",alt:"json-in-script","max-results":10,"start-index":1,category:!1,label:!1,q:!1,orderby:"published"});for(const e in t)Object.hasOwnProperty.call(t,e)&&("jumlah"==e?(this._config["max-results"]=t[e],this._config[e]=t[e]):this._config[e]=t[e])}getId(t){return t.split("post-")[1]||t.split("page-")[1]}getAuthor(t){let e={};return"name"in t&&(e.name=t.name.$t),"uri"in t&&(e.uri=t.uri.$t),"gd$image"in t&&"src"in t.gd$image&&-1==t.gd$image.src.indexOf("https://img1.blogblog.com/")?e.image=this.resizeImage(t.gd$image.src,this._config.sizeImage):e.image=this._config.noImage?this.resizeImage(this._config.noImage,this._config.sizeImage):"",e}getDefault(t){let e=["published","updated","content","summary","title"],s={};return e.forEach(e=>{e in t&&(s[e]=t[e].$t,"published"==e&&(s.date=this.getTime(t[e].$t)))}),s}getImage(t){let e=this._config.noImage?this.resizeImage(this._config.noImage,this._config.sizeImage):"";if("media$thumbnail"in t)return this.resizeImage(t.media$thumbnail.url,this._config.sizeImage);if("content"in t){let s=t.content.$t,r=s.indexOf(""alternate"==t.rel).href,i.image=this.getImage(r),"category"in r&&(i.label=r.category.map(t=>t.term)),"author"in r&&(i.author=this.getAuthor(r.author[0])),"thr$total"in r&&(i.comments_count=r.thr$total.$t),e.push(i)}return e}run(t){let e=this.createURL().href,s=this.getXHRtype(e);this[s](e,e=>(t||this.err)(this.getFeed(e)))}}class BloggerRandom extends BloggerScript{constructor(t={}){super(t),this.config={"max-results":0}}getTotalResults(t){let e=t.feed.openSearch$totalResults.$t,s=this.config.jumlah;return s?e=e{let r=this.getTotalResults(e);if(0==r)return this.config={"max-results":0,"start-index":1},(t||this.err)([]);this[s](r,e=>{this.config={"max-results":0,"start-index":1},(t||this.err)(this.getItems(e))})})}}class BloggerRelated extends BloggerScript{constructor(t={}){super(t)}run(t){let e=0,s=document.location.pathname,r=this.config.label,i=this.config.jumlah,n=new Array;if("object"==typeof r)r.forEach((r,o,h)=>{this._config.label=r;let a=this.createURL().href,l=this.getXHRtype(a);this[l](a,r=>{let o=this.getFeed(r);if(o.forEach(t=>!n.some(e=>e.id==t.id)&&n.push(t)),e++,e==h.length){let e=n.map(t=>new URL(t.link).pathname==s).indexOf(!0);n.splice(e,1),n=this.shuffle(n).slice(0,i),(t||this.err)(n)}})});else if("string"==typeof r){let e=this.createURL().href,s=this.getXHRtype(e);this[s](e,e=>{(t||this.err)(this.getFeed(e))})}else(t||this.err)([])}}class BloggerSitemap extends BloggerScript{constructor(t){super(t),this.config={"max-results":150,"total-get":0},this.posts=[]}alphaSort(t){let e=new Array,s=new Array,r="";0!=t.length&&this.sort(t,"A-Z").forEach(t=>{let s=t.title.charAt(0).toLowerCase();-1==r.indexOf(s)?(r+=s,e[s]=[t]):e[s].push(t)});for(const t in e)if(Object.hasOwnProperty.call(e,t)){const r=e[t];s.push({id:t,items:r})}return s}get posts(){return this._posts}set posts(t){"_posts"in this||(this._posts=new Array),Array.prototype.push.apply(this._posts,t)}resetPosts(){"_posts"in this&&(this._posts=new Array)}run(t){let e=this.createURL().href,s=this.getXHRtype(e),r=()=>{this.config={"max-results":150,"start-index":1,"total-get":0},this.resetPosts()};this.config["total-get"]++,this[s](e,e=>{if(e&&e.feed&&e.feed.entry){let s=e.feed.openSearch$totalResults.$t||0,i=e.feed.entry;this.posts=this.getFeed(e),i.length>=this.config["max-results"]?(this.config["start-index"]+=this.config["max-results"],this.config.firstContent&&1==this.config["total-get"]&&(t||this.err)({totalPosts:s,posts:this.posts,completed:!1}),this.run(t||this.err)):((t||this.err)({totalPosts:s,totalGet:this.config["total-get"],posts:this.posts,completed:!0}),r())}else(t||this.err)({totalPosts:this.posts.length,totalGet:this.config["total-get"],posts:this.posts,completed:!0}),r()})}}class BloggerComments extends BloggerScript{constructor(t){super(t),this.config={type:"comments"!=this.config.type&&"comments"!=this.config.type.name?"comments":this.config.type,"max-results":this.config.jumlah?this.config.jumlah:500}}getComments(t){let e=new Array;if(t.feed&&t.feed.entry)for(let s=0;s"alternate"==t.rel).href,"author"in r&&(i.author=this.getAuthor(r.author[0])),e.push(i)}return e}getPostInfo(t,e){if(0!=t.length){let s=0,r=0,i=this.config.type,n=this.config.feed,o=new Array;t.forEach(t=>"post-id"in t&&"post-source"in t&&!(t["post-id"]in o)&&(o[t["post-id"]]=!0,s++));for(const h in o)if(Object.hasOwnProperty.call(o,h)){this.config={type:{name:"posts",id:h},feed:"summary"};let a=this.createURL().href,l=this.getXHRtype(a);this[l](a,a=>{a&&"entry"in a&&(o[h]=this.getFeed(a)),r++,r==s&&(t=t.map(t=>(t["post-info"]="post-id"in t&&o[t["post-id"]][0]||!1,t)),this.config={type:i,feed:n},(e||this.err)(t))})}}else(e||this.err)(t)}run(t){let e=this.createURL().href,s=this.getXHRtype(e);this[s](e,e=>(t||this.err)(this.getComments(e)))}}