document.addEventListener("alpine:init",()=>{Alpine.data("bbfsGenerator",()=>({nomor:"",type:"2D",dataType:["2D","3D","4D","5D","6D"],hasilKom:[],hasilPre:[],pesanError:"",init(){setTimeout(()=>{NiceSelect.bind(document.getElementById("type"),{onChange:e=>{this.type=e.at().value}})})},validNumber(){let e=this.nomor.match(/\d/gm);this.nomor=e?e.join(""):""},clear(){this.hasilKom=[],this.hasilPre=[],this.nomor=""},proses(){this.hasilKom=[],this.hasilPre=[],this.pesanError="";let e=parseInt(this.type.match(/\d/gm).join(""));switch(!0){case this.nomor=="":this.pesanError="Silahkan masukkan nomor bbfs yang ingin di generate.";break;case this.nomor.length==1:this.pesanError="Silahkan masukkan nomor bbfs minimal 2 angka.";break;case this.nomor.length<e:this.hasilKom=[this.nomor],this.hasilPre=[this.nomor];break;default:this.hasilKom=generateBBFS(this.nomor,e),this.hasilPre=generatePermutations(this.nomor,e);break}},copyToClipboard(e){let t=e.join("*");navigator.clipboard.writeText(t).then(()=>{Toast("Berhasil disalin ke clipboard.","success")}).catch(()=>{Toast("Gagal disalin ke clipboard.","error")})}}))});