import{e as g,A as f,a as w}from"./AppLayout-0a5a7f0f.js";import{F as k}from"./Feedback-c61d8668.js";import{S as x}from"./SearchForm-98563f72.js";import{_ as v}from"./_plugin-vue_export-helper-b15b4a05.js";import{q as i,u as l,D as h,F as b,E as _,x as p,v as d,z as m,C as L,A as y}from"./vue-0d7ee8e8.js";import"./inertia-11bf9011.js";import"./@inertiajs/core-9c117dfe.js";import"./axios-dd1c8fc2.js";import"./recaptcha-v3-f0e7cd4f.js";import"./qs-0fed5bc1.js";import"./get-intrinsic-20bd36cc.js";import"./object-inspect-747fc63f.js";import"./nprogress-f6c1521f.js";import"./lodash.isequal-390c7467.js";import"./inertia-d4e795d3.js";import"./preload-helper-f61836a9.js";import"./userActivity-e849d9de.js";import"./fingerprint-374ab551.js";import"./sliders-solid-8621afe8.js";import"./circle-xmark-solid-011b00e2.js";import"./lodash-76c7a0c0.js";import"./voiceInput-82d46348.js";const O={props:{results:{type:Object,required:!1},paginate:{type:Number,default:200},topic:{type:String,required:!0},button:{type:String,required:!0},buttons:{type:Array,required:!0},url:{type:Object,required:!0}},data(){return{items:{},itemsCount:0,keys:[],displayed:0}},mounted(){if(isNaN(this.paginate)&&(this.paginate=200),this.keys=Object.values(this.results),this.itemsCount=this.keys.length,this.itemsCount<this.paginate)this.displayed=this.itemsCount,this.items=this.results;else{this.displayed=this.paginate;for(let t=0;t<this.displayed;t++)this.items[this.keys[t]]=this.results[this.keys[t]]}},computed:{hasMore(){return this.itemsCount>this.displayed}},methods:{loadMore(){if(this.itemsCount<this.displayed+this.paginate)this.displayed=this.itemsCount,this.items=this.results;else{for(let t=this.displayed;t<this.displayed+this.paginate;t++)this.items[this.keys[t]]=this.results[this.keys[t]];this.displayed+=this.paginate}},showOptionsList(t,s,e){var n=t.target;if(document.querySelectorAll(".menu-box2").forEach(a=>{a.dataset.word!==e&&a.remove()}),document.querySelector(`.menu-box2[data-word="${e}"]`)===null){var r=`<div class="menu-box2" data-word="${e}"><div class="options-list"> <div class="option js-save-word" data-key="${s}" data-value="${e}" ><div class="icon icon-trash me-2"></div>${this.buttons[2]}</div> </div></div>`;n.insertAdjacentHTML("afterEnd",r)}else document.querySelector(`.menu-box2[data-word="${e}"]`).remove()},urlencode(t){return t=t+"",encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/~/g,"%7E").replace(/%20/g,"+")}}},C=["innerHTML"],j=["href","textContent","data-category"],A=["href","textContent","data-category"],W=["textContent","data-category"],q=["onClick"],M={class:"index-table-row"},E={key:0,class:"index-table-cell text-center"},T=["innerHTML","aria-label"];function H(t,s,e,n,r,a){return i(),l("div",null,[Object.entries(this.results).length>0?(i(),l("div",{key:0,class:"index-table-head index-table-head-cell",innerHTML:e.topic},null,8,C)):h("",!0),(i(!0),l(b,null,_(r.items,(o,u)=>(i(),l("div",{class:"index-table-row index-table-cell flex relative",key:o.word},[o.hasLink&&(o.category==="synonym"||o.category==="antonym"||o.category==="picture")?(i(),l("a",{key:0,href:`${e.url[o.category]}/${a.urlencode(o.word)}`,textContent:p(o.word),"data-category":o.category},null,8,j)):h("",!0),o.hasLink&&o.category!=="synonym"&&o.category!=="antonym"&&o.category!=="picture"?(i(),l("a",{key:1,href:`${e.url[o.category]}/${o.word}`,textContent:p(o.word),"data-category":o.category},null,8,A)):h("",!0),o.hasLink?h("",!0):(i(),l("span",{key:2,textContent:p(o.word),"data-category":o.category},null,8,W)),d("div",{onClick:c=>a.showOptionsList(c,u,o.word),class:"show-options-list icon icon-heart-solid index-table-wildcard ml-auto"},null,8,q)]))),128)),d("div",M,[a.hasMore?(i(),l("div",E,[d("button",{class:"button",onClick:s[0]||(s[0]=(...o)=>a.loadMore&&a.loadMore(...o)),innerHTML:e.button,"aria-label":e.button},null,8,T)])):h("",!0)])])}const N=v(O,[["render",H]]),F={props:{results:{type:Object,required:!0},paginate:{type:Number,default:200},strings:{type:Object,required:!0},buttons:{type:Array,required:!0},url:{type:Object,required:!0},placeholders:Object},components:{TableSegment:N},data(){return{displayedResults:{},countSavedWord:Object.entries(this.results).length}},created(){var t=this;axios.post("/saved-words",{_token:document.querySelector('meta[name="csrf-token"]').getAttribute("content"),data:JSON.stringify(this.results)}).then(({data:s})=>{localStorage.setItem("words",JSON.stringify(s)),g.emit("countSavedWord",Object.entries(s).length),document.cookie="countSavedWord="+Object.entries(s).length,t.buildResults(s)}).catch(function(s){t.buildResults(t.results)}),g.on("countSavedWord",s=>{this.countSavedWord=s;const e=document.getElementById("savedWordsCounter");e&&(e.innerHTML="("+this.countSavedWord+")");const n=document.getElementById("wordCounter");n&&(n.innerHTML="("+this.countSavedWord+")")})},mounted(){var t=this;document.body.addEventListener("click",function(s){if(s.target.classList.contains("js-save-word")){var e=s.target.dataset.value,n=s.target.dataset.key,r=s.target.closest(".index-table-row");t.removeWord(n,e,r)}}),this.countSavedWord>0?(document.querySelectorAll(".has-favorite-words").forEach(s=>{s.classList.remove("hidden")}),document.querySelectorAll(".no-favorite-words").forEach(s=>{s.classList.add("hidden")})):(document.querySelectorAll(".has-favorite-words").forEach(s=>{s.classList.add("hidden")}),document.querySelectorAll(".no-favorite-words").forEach(s=>{s.classList.remove("hidden")}))},watch:{countSavedWord:{immediate:!0,handler:function(){this.countSavedWord>0?(document.querySelectorAll(".has-favorite-words").forEach(t=>{t.classList.remove("hidden")}),document.querySelectorAll(".no-favorite-words").forEach(t=>{t.classList.add("hidden")})):(document.querySelectorAll(".has-favorite-words").forEach(t=>{t.classList.add("hidden")}),document.querySelectorAll(".no-favorite-words").forEach(t=>{t.classList.remove("hidden")}))}}},methods:{buildResults(t){var s={};for(let[n,r]of Object.entries(t)){var e={};s[r.topic]!==void 0?(e=s[r.topic],e[Object.keys(s[r.topic]).length]={word:r.word,hasLink:r.hasLink,category:r.category}):e[0]={word:r.word,hasLink:r.hasLink,category:r.category},s[r.topic]=e}this.displayedResults=s},removeWord(t,s,e){var n={};for(let[r,a]of Object.entries(JSON.parse(localStorage.words)))a.word!==s&&(n[Object.keys(n).length]=a);localStorage.setItem("words",JSON.stringify(n)),g.emit("countSavedWord",Object.entries(n).length),e.remove(),this.buildResults(n)}}},$={key:0,ref:"table",class:"table index-table"},B=d("div",{class:"fixed top-0 hidden"},null,-1),R=["innerHTML"];function I(t,s,e,n,r,a){const o=m("TableSegment");return r.countSavedWord>0?(i(),l("div",$,[B,(i(!0),l(b,null,_(r.displayedResults,(u,c)=>(i(),L(o,{key:c,results:u,topic:c,button:e.strings.button,buttons:e.buttons,url:e.url},null,8,["results","topic","button","buttons","url"]))),128))],512)):(i(),l("div",{key:1,class:"lg:p-3",innerHTML:e.placeholders["no-saved-words-found-text"]},null,8,R))}const J=v(F,[["render",I]]),P={layout:f,components:{SavedWords:J,AppLayout:f,Ads:w,Feedback:k,SearchForm:x},props:{tableStrings:Object,buttons:Array,placeholders:Object,strings:Object,lengths:Array,allPartOfSpeech:Array,regex:String,url:Object},computed:{locale(){return this.$page.props.layoutData.locale}},methods:{getSavedWords(){return localStorage.words!==void 0&&localStorage.words!==null?JSON.parse(localStorage.words):{}}}},D={class:"section"},V={class:"heading flex items-center"},z=d("div",{class:"icon icon-heart-solid index-table-wildcard mr-2"},null,-1),U=["innerHTML"],G=d("div",{id:"wordCounter",class:"ml-1 inline-block"},null,-1),K={class:"columns"},Q={class:"column-of-2 order-1"},X={class:"column-of-2 md:pl-4 order-2 md:order-2"},Y={class:"mx-auto mb-6"},Z=["innerHTML"],ee={class:"order-2 has-favorite-words hidden"},te={class:"py-6"};function se(t,s,e,n,r,a){const o=m("SavedWords",!0),u=m("SearchForm"),c=m("Ads"),S=m("Feedback");return i(),l("section",D,[d("h1",V,[z,d("span",{innerHTML:e.placeholders.title},null,8,U),G]),d("div",K,[d("div",Q,[y(o,{results:a.getSavedWords(),url:e.url,strings:e.tableStrings,buttons:e.buttons,placeholders:e.placeholders},null,8,["results","url","strings","buttons","placeholders"])]),d("div",X,[d("div",Y,[y(u,{terms:{},lengths:e.lengths,strings:e.strings,buttons:e.buttons,allPartOfSpeech:e.allPartOfSpeech,locale:a.locale,regex:e.regex},null,8,["lengths","strings","buttons","allPartOfSpeech","locale","regex"])])]),d("div",{class:"lg:p-3 saved-word-text has-favorite-words hidden",innerHTML:e.placeholders["saved-words-found-text"]},null,8,Z),d("div",ee,[d("div",te,[y(c,{"ad-key":"ad3"})]),y(S)])])])}const Le=v(P,[["render",se]]);export{Le as default};