import{c as E}from"./CrosswordsForm-42c89fee.js";import{e as m,u as F}from"./AppLayout-0a5a7f0f.js";import{q as a,u as o,D as g,v as d,y,J as w,X as x,F as h,E as p,_ as k,x as f,z as C,aa as _,C as T,G as L}from"./vue-0d7ee8e8.js";import{_ as O}from"./_plugin-vue_export-helper-b15b4a05.js";import{m as j,a as H}from"./inertia-d4e795d3.js";import{R as M}from"./recaptcha-v3-f0e7cd4f.js";import{s as q,a as B}from"./arrow-up-a-z-solid-68a9dbc8.js";const W="/build/assets/arrow-down-wide-short-solid-8a0a9a79.svg",A="/build/assets/arrow-up-wide-short-solid-2d1d1344.svg",D={methods:{detectMobile(){var s=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(s=!0)}(navigator.userAgent||navigator.vendor||window.opera),s}}},I={props:{crossForm:Object,onlyButton:{type:Boolean,default:!1},length:{type:Number,default:null}},computed:{placeholders(){return this.$page.props.placeholders},allLength(){return this.$page.props.allLength},hasTop(){return this.$page.props.hasTop}},mounted(){this.setFilterText(),this.filterHeight=this.$refs.filter.clientHeight,this.filterShow=!1},created(){m.on("updateFilterText",s=>{this.filterText=s}),m.on("closeOtherFilters",s=>{this.onlyButton&&this.filterShow&&this.length!==s&&(this.filterShow=!1)})},data(){return{filterText:this.$page.props.placeholders["answers-filter-all"],filterShow:!0,letters:this.allLength,filterHeight:0}},methods:{setFilterText(s){s!==void 0&&s!==0?this.filterText=s+" "+this.placeholders["answers-filter-letters"]:this.crossForm.pattern.length!==0?this.filterText=this.crossForm.pattern.length+" "+this.placeholders["answers-filter-letters"]:this.filterText=this.placeholders["answers-filter-all"]},toggleFilter(){m.emit("closeOtherFilters",this.length),this.filterShow=!this.filterShow},setFilter(s,t){this.crossForm.$refs.mobile.letters=[];let e=decodeURI(location.pathname.split("/")[2]),n="";if(this.filterText=t,m.emit("updateFilterText",t),this.toggleFilter(),s!=="top"&&s!=="")for(var r=0;r<s;r++)n+="_";axios.post(this.route("crosswords.question.ajax",e),{filter:s,pattern:n}).then(({data:i})=>{m.emit("updateData",i)}).catch(function(i){console.log(i)})}}},z=["innerHTML"],R=["id","innerHTML"],P=d("svg",{class:"-mr-1 h-5 w-5 text-black",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},[d("path",{"fill-rule":"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z","clip-rule":"evenodd"})],-1),N=[P],U={ref:"filter",class:"absolute right-0 z-[90] w-56 mt-2 origin-top-right rounded-md bg-[#EDF2F7] border border-gray-500 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none",role:"menu","aria-orientation":"vertical","aria-labelledby":"menu-button",tabindex:"-1"},J={class:"py-1",role:"none"},K=["innerHTML"],V={class:"grid grid-cols-4 gap-2 px-2"},G=["onClick"],Q=["innerHTML"],X=["innerHTML"];function Y(s,t,e,n,r,i){return a(),o("div",{class:y(e.onlyButton?"z-[90] absolute right-0 pr-2 top-0 bottom-0 flex items-center border-l border-l-gray-500":"mb-2 md:w-1/3 md:-top-9 md:absolute md:right-0")},[e.onlyButton?g("",!0):(a(),o("label",{key:0,class:"block",innerHTML:i.placeholders["answers-filter-label"]},null,8,z)),d("div",{class:y(e.onlyButton?"":"relative text-left")},[d("div",null,[d("button",{type:"button",onClick:t[0]||(t[0]=(...u)=>i.toggleFilter&&i.toggleFilter(...u)),class:y(e.onlyButton?"flex items-center":"bg-[#EDF2F7] border-gray-500 border inline-flex w-full gap-x-1.5 rounded-md text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"),id:"menu-button","aria-expanded":"true","aria-haspopup":"true"},[e.onlyButton?g("",!0):(a(),o("span",{key:0,id:e.onlyButton?"":"lengthFilterText",class:"px-3 py-2",innerHTML:r.filterText},null,8,R)),d("div",{class:y(["px-1",e.onlyButton?"":"absolute right-2 py-2 border-l border-l-gray-500"])},N,2)],2)]),w(d("div",U,[d("div",J,[d("span",{class:"text-black text-sm font-bold p-2",innerHTML:i.placeholders["answers-filter-sublabel"]},null,8,K),d("div",V,[(a(!0),o(h,null,p(i.allLength,u=>(a(),o("a",{href:"#",class:"text-gray-700 border border-gray-500 inline-block bg-white py-2 text-center text-sm hover:bg-teal-500 hover:no-underline hover:text-white hover:font-semibold",role:"menuitem",tabindex:"-1",id:"menu-item-0",onClick:k(l=>i.setFilter(u,u+" "+i.placeholders["answers-filter-letters"]),["prevent"])},f(u),9,G))),256))])]),d("a",{href:"#",class:"text-black font-bold block px-2 py-1 text-sm",role:"menuitem",tabindex:"-1",onClick:t[1]||(t[1]=k(u=>i.setFilter("",i.placeholders["answers-filter-all"]),["prevent"])),innerHTML:i.placeholders["answers-filter-all-label"]},null,8,Q),w(d("a",{href:"#",class:"text-black font-bold block px-2 py-1 text-sm",role:"menuitem",tabindex:"-1",onClick:t[2]||(t[2]=k(u=>i.setFilter("top",i.placeholders["answers-filter-top"]),["prevent"])),innerHTML:i.placeholders["answers-filter-top-label"]},null,8,X),[[x,i.hasTop]])],512),[[x,r.filterShow]])],2)],2)}const Z=O(I,[["render",Y]]),$={mixins:[D],components:{LengthFilter:Z},props:{results:{type:Object,required:!0},strings:{type:Object,required:!0},length:{type:String,required:!0},sortedByLength:{type:Boolean,required:!0},answers:{type:Boolean,required:!0},answersByFilter:{type:Boolean,default:!1},pageEntry:{type:Object,required:!0},template:{type:String,required:!0},buttons:{type:Array,required:!0},entriesAsc:{type:Boolean,required:!0},siteKey:{type:String,required:!0},savedWords:{type:Object,required:!0},savedWordsCount:{type:Number,required:!0},editFormStrings:{type:Object,required:!0},regex:{type:String,required:!0},showAdsData:{type:Object,required:!0},total:{type:Number,required:!0},menuIcon:{type:HTMLElement},crossForm:{type:Object,default:null},zIndex:{type:Number,default:1}},data(){return{items:{},itemsCount:0,keys:[],displayed:0,csrf:document.querySelector('meta[name="csrf-token"]').getAttribute("content"),mdHidden:window.innerWidth<768,mdBlock:window.innerWidth>=768,favoriteShow:!0}},mounted(){if(this.keys=Object.keys(this.results),this.itemsCount=this.keys.length,this.itemsCount<300)this.displayed=this.itemsCount,this.items=this.results;else{this.displayed=300;for(let s=0;s<this.displayed;s++)this.items[this.keys[s]]=this.results[this.keys[s]]}},updated(){this.adType==="adpushup"&&this.triggerAdpushupAds()},watch:{results:function(){if(this.keys=Object.keys(this.results),this.itemsCount=this.keys.length,this.itemsCount<300)this.displayed=this.itemsCount,this.items=this.results;else{this.displayed=300;for(let s=0;s<this.displayed;s++)this.items[this.keys[s]]=this.results[this.keys[s]]}},entriesAsc(s){if(console.log("Watching"),this.length==="all"){let t=(e,n)=>e.localeCompare(n);s||(t=(e,n)=>n.localeCompare(e)),this.items={},this.keys=Object.keys(this.results).sort(t);for(let e=0;e<this.displayed;e++)this.items[this.keys[e]]=this.results[this.keys[e]]}}},computed:{...j(F,["adType"]),hasMore(){return this.itemsCount>this.displayed}},methods:{...H(F,["triggerAdpushupAds"]),loadMore(){if(this.itemsCount<this.displayed+300)this.displayed=this.itemsCount,this.items=this.results;else{for(let s=this.displayed;s<this.displayed+300;s++)this.items[this.keys[s]]=this.results[this.keys[s]];this.displayed+=300}},showEditForm(s,t,e){var n=s.target.closest(".index-table-row"),r=`<div>
                <form
                        method="post"
                        action="/crossword/suggestion/edit"
                        class="edit-form js-edit-form"

                    >
                        <input type="hidden" name="_token" value="${this.csrf}" />
                        <h2
                            class="text-xl font-bold mb-3"
                        >${this.editFormStrings["entry-edit-form-title"]}</h2>
                        <div class="mb-3">
                            <label class="label">
                                <span
                                    class="font-bold"
                                >${this.editFormStrings["entry-edit-form-action-label"]}</span>
                                <input
                                    type="hidden"
                                    name="g-recaptcha-response"
                                />
                            </label>
                            <div class="relative w-full">
                                <select class="js-change-form-action" data-topic="${t}" data-word="${e}"
                                >
                                    <option
                                        value="edit"
                                        selected
                                    >${this.editFormStrings["entry-edit-form-edit-action"]}</option>
                                    <option
                                        value="remove"
                                    >${this.editFormStrings["entry-edit-form-remove-action"]}</option>
                                    <option
                                        value="suggest"
                                    >${this.editFormStrings["entry-edit-form-suggest-action"]}</option>
                                </select>
                                <div
                                    class="pointer-events-none absolute inset-y-0 right-0 flex items-center justify-between px-2 text-gray-700"
                                >
                                    <svg
                                        class="fill-current h-4 w-4"
                                        xmlns="http://www.w3.org/2000/svg"
                                        viewBox="0 0 20 20"
                                    >
                                        <path
                                            d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
                                        />
                                    </svg>
                                </div>
                            </div>
                        </div>
                        <div class="fields">
                            <div class="mb-3">
                                <label class="label">${this.editFormStrings["entry-edit-form-topic-label"]}</label>
                                <input class="input" name="topic" type="text" value="${t}" readonly>
                            </div>
                            <div class="mb-3">
                                <label
                                    class="label"
                                >${this.editFormStrings["entry-edit-form-wrong-entry-label"]}</label>
                                <input
                                    class="input"
                                    name="wrong_entry"
                                    type="text"
                                    value="${e}"
                                    readonly
                                />
                            </div>
                            <div class="mb-3">
                                <label
                                    class="label"
                                >${this.editFormStrings["entry-edit-form-right-entry-label"]}</label>
                                <input
                                    class="input"
                                    name="right_entry"
                                    type="text"
                                    pattern="[${this.regex}]+"
                                    required
                                />
                            </div>
                            <div class="mb-3">
                                <label
                                    class="label"
                                >${this.editFormStrings["entry-edit-form-optional-comment-label"]}</label>
                                <textarea
                                    class="input"
                                    name="comments"
                                    rows="5"
                                ></textarea>
                            </div>
                        </div>
                        <div class="flex items-center justify-between">
                            <button
                                class="button"
                                type="submit"
                            >${this.editFormStrings.send}</button>
                            <button
                                type="button"
                                class="js-hide-edit-form-btn bg-gray-300 rounded rounded-sm py-2 px-4 font-bold ml-auto"

                                data-entry="${e}"
                            >${this.editFormStrings.cancel}</button>
                        </div>
                </form>
            </div>`;n.insertAdjacentHTML("afterend",r),document.querySelector(`.edit-button[data-entry="${e}"]`).classList.add("hidden")},showOptionsList(s,t,e){m.emit("menuIcon",s.target);var n=s.target;if(document.querySelectorAll(".menu-box2").forEach(i=>{i.dataset.word!==e&&i.remove()}),document.querySelector(`.menu-box2[data-word="${e}"]`)===null){var r=`<div class="menu-box2 mr-8" data-word="${e}"><div class="`+this.getListStyle(e)+`">
                            <div
                                class="option js-save-word"
                                data-category="${this.favorite?"favorite-synonyms":"synonyms"}"
                                data-topic="${t}"
                                data-value="${e}"
                            >`+this.getIconAndText(t,e)+`</div>
                            <div class="option">
                                <a href="${this.route("saved.words")}">
                                <div class="icon icon-list-ul me-2"></div>${this.buttons[1]}</a>
                            </div>
                        </div></div>`;n.insertAdjacentHTML("afterEnd",r)}else document.querySelector(`.menu-box2[data-word="${e}"]`).remove()},getIconAndText(s,t){var e=this.strings["crosswords-topic"].replace("<letters>",s);for(let[n,r]of Object.entries(this.savedWords))if(r.topic===e&&r.word===t)return'<div class="icon icon-trash me-2"></div>'+this.buttons[2];return'<div class="icon icon-heart me-2"></div>'+this.buttons[0]},getMenuIcon(s,t){var e=this.strings["crosswords-topic"].replace("<letters>",s);for(let[n,r]of Object.entries(this.savedWords))if(r.topic===e&&r.word===t)return"show-options-list icon icon-heart-solid index-table-wildcard mr-0";return"show-options-list icon icon-heart mr-0"},getListStyle(s,t){var e=this.strings["crosswords-topic"].replace("<letters>",s);for(let[n,r]of Object.entries(this.savedWords))if(r.topic===e&&r.word===t)return"options-list flex flex-wrap-reverse";return"options-list"},calculate(s,t){if(this.$refs[s][0].getBoundingClientRect().y<0)return 22.5;var e=this.$refs.tableRow[0].getBoundingClientRect(),n=this.$refs.tableRow.filter((u,l)=>l<=t),r=0;n.forEach(function(u){r+=u.clientHeight}),e.y<0?e=Math.abs(e.y)+e.height:e=0;var i=this.$refs.lengthFilter.filterHeight-r+e+22.5;return i>22.5?i:22.5}}},ee=["innerHTML"],te={key:0,class:"index-table-cell relative flex"},se=["href","title"],re={key:0,class:"index-table-cell relative flex"},ie=["href","title"],ne=["onClick","data-topic","data-entry"],ae=["href","title"],oe={key:0,class:"text-sm font-semibold border border-black border-[1.5px] rounded-[1.5px] w-7 text-center bg-white"},le={key:1,class:"text-sm font-semibold border border-black border-[1.5px] rounded-[1.5px] w-7 text-center bg-white"},de=["onClick"],ce=["onClick","data-topic","data-entry"],ue={key:0,class:"index-table-row"},he=["innerHTML"],me={key:0,class:"index-table-row index-table-cell text-center"},ge=["aria-label","innerHTML"];function be(s,t,e,n,r,i){const u=C("LengthFilter");return a(),o("div",null,[w(d("div",{class:y(["index-table-head index-table-head-plain sticky top-0",s.route().current("crosswords.question")&&r.mdHidden?"z-[1]":""]),style:_(s.route().current("crosswords.question")&&r.mdHidden?"":"overflow: visible; z-index:"+e.zIndex+";")},[d("div",{class:"index-table-head-cell crossword-table-head-cell text-base",style:_(s.route().current("crosswords.question")&&r.mdHidden?"overflow: visible; padding-right:40px;":"")},[d("div",{class:y(s.route().current("crosswords.question")&&r.mdHidden?"":"flex flex-wrap items-baseline justify-center"),innerHTML:e.template},null,10,ee),e.crossForm&&r.mdHidden?(a(),T(u,{key:0,crossForm:e.crossForm,"only-button":!0,length:e.length,ref:"lengthFilter"},null,8,["crossForm","length"])):g("",!0)],4)],6),[[x,e.sortedByLength]]),(a(!0),o(h,null,p(r.items,(l,c,v)=>(a(),o(h,null,[d("div",{ref_for:!0,ref:"tableRow",class:y(["index-table-row",l.isFavorite===!0?"bg-[#EBFFE7]":v%2!==0?"alice-blue-bg":""])},[e.answersByFilter?(a(),o("div",te,[d("a",{class:"link font-bold",href:s.route("crosswords.answer",c.toLowerCase().trim()),title:e.strings["crosswords-alt-text"].replace("|letters|",c).replace("|length|",l.answerLength)},f(c.toUpperCase()),9,se)])):(a(),o(h,{key:1},[e.answers?(a(),o("div",re,[d("a",{class:"link font-bold mr-auto",href:s.route("crosswords.answer",c.toLowerCase().trim()),title:e.strings["crosswords-answer-alt-text"].replace("|letters|",c.toLowerCase()).replace("|length|",l.answerLength)},f(l.altAnswer.toUpperCase()),9,ie),r.mdHidden?(a(),o("button",{key:0,class:"edit-button",onClick:b=>i.showEditForm(b,e.answers?e.pageEntry.text:c,e.answers?c:e.pageEntry.word),"data-topic":e.answers?e.pageEntry.text:c,"data-entry":e.answers?c:e.pageEntry.word,"aria-label":"edit"},null,8,ne)):g("",!0)])):(a(),o("a",{key:1,class:"index-table-cell link font-bold",href:l.url.toLowerCase(),title:e.strings["crosswords-answer-alt-text"].replace("|letters|",c).replace("|length|",e.pageEntry.answerLength)},f(c),9,ae))],64)),r.mdBlock?(a(),o("div",{key:2,class:y([e.answers&&!e.answersByFilter?"justify-end":"justify-between","index-table-cell table-cell-length md:flex hidden items-center relative"])},[e.answersByFilter?(a(),o(h,{key:0},[L(f(l.length),1)],64)):(a(),o(h,{key:1},[e.answers?(a(),o(h,{key:1},[e.length==="all"?(a(),o("div",oe,f(l.length),1)):(a(),o("div",le,f(e.length),1))],64)):(a(),o(h,{key:0},[e.length==="all"?(a(),o(h,{key:0},[L(f(l.length),1)],64)):(a(),o(h,{key:1},[L(f(e.length),1)],64))],64)),r.favoriteShow&&e.answers?(a(),o("div",{key:2,onClick:b=>i.showOptionsList(b,e.answers?e.pageEntry.text:c,e.answers?c:e.pageEntry.word),class:y(i.getMenuIcon(e.answers?e.pageEntry.text:c,e.answers?c:e.pageEntry.word))},null,10,de)):g("",!0),d("button",{class:"edit-button",onClick:b=>i.showEditForm(b,e.answers?e.pageEntry.text:c,e.answers?c:e.pageEntry.word),"data-topic":e.answers?e.pageEntry.text:c,"data-entry":e.answers?c:e.pageEntry.word,"aria-label":"edit"},null,8,ce)],64))],2)):g("",!0)],2),(a(!0),o(h,null,p(e.showAdsData,(b,S)=>(a(),o(h,null,[b.codes&&b.codes.code&&b.index===v&&b.key===e.length&&(b.desktopOnly&&!s.detectMobile()||b.mobileOnly&&s.detectMobile())?(a(),o("div",ue,[d("div",{ref_for:!0,ref:`adInTable${S}`,innerHTML:b.codes.code,style:_([{"min-height":"330px",display:"flex","justify-content":"center","align-items":"center"},e.crossForm&&b.mobileOnly&&r.mdHidden&&this.$refs.lengthFilter.filterShow?"margin-top:"+i.calculate(`adInTable${S}`,v)+"px;padding:0;":""]),class:"index-table-cell py-5 text-center"},null,12,he)])):g("",!0)],64))),256))],64))),256)),i.hasMore?(a(),o("div",me,[d("button",{class:"button",onClick:t[0]||(t[0]=(...l)=>i.loadMore&&i.loadMore(...l)),"aria-label":s.button,innerHTML:s.button},null,8,ge)])):g("",!0)])}const fe=O($,[["render",be]]),ye={props:{entriesData:{type:[Object,Array],default:{}},paginationData:{type:[Object,Array],default:{}},buttons:{type:[Object,Array],default:{}},answers:{type:Boolean,default:!0},answersByFilter:{type:Boolean,default:!1},filterData:{type:String,default:""},pageEntryData:{type:[Object,Array],required:!1},strings:{type:Object,required:!0},editFormStrings:{type:Object,required:!0},siteKey:{type:String,required:!0},regex:{type:String,required:!0},disableRecaptcha:{type:Boolean,required:!0},crossForm:{type:Object,default:null}},mixins:[E],components:{TableSegment:fe},data(){return{entries:this.entriesData,pagination:this.paginationData,filter:this.filterData,pageEntry:this.pageEntryData?this.pageEntryData:{},filtered:{},sorted:{},pattern:[],icons:{alpha:{down:q,up:B},amount:{up:A,down:W}},sortOrder:{by:"length",asc:!0},savedWords:{},savedWordsCount:0,showAdsData:[],menuIcon:null,mdBlock:window.innerWidth>=768}},computed:{...j(F,["ads"]),variousEntries(){let s=0;return Object.entries(this.filtered).forEach(t=>{s+=Object.keys(t[1]).length}),s>1},sortableQuestion(){return this.answersByFilter&&this.variousEntries||!this.answers&&this.variousEntries},sortableAnswer(){return!this.answersByFilter&&this.answers&&this.variousEntries},variousLengths(){return Object.keys(this.filtered).length>1},sortableLength(){return this.variousLengths},sortedByLength(){return this.sortOrder.by==="length"},sortEntryIcon(){return this.getSortIcon("entry","alpha")},sortLengthIcon(){return this.getSortIcon("length","amount")},entriesAsc(){return this.sortOrder.by==="entry"&&this.sortOrder.asc===!0}},created(){var s=this;this.answers&&m.on("filtered",t=>{this.pattern=t.map(e=>e===""?".":e),this.filterResults()}),m.on("menuIcon",t=>{this.menuIcon=t}),m.on("savedWords",t=>{this.savedWords=t}),m.on("savedWordsCount",t=>{this.savedWordsCount=t;const e=document.getElementById("savedWordsCounter");e&&(e.innerHTML="("+this.savedWordsCount+")");const n=document.getElementById("wordCounter");n&&(n.innerHTML="("+this.savedWordsCount+")")}),s.updateSavedWords()},watch:{ads(){this.sort()}},mounted(){var s=this;document.body.addEventListener("change",function(t){if(t.target.classList.contains("js-change-form-action")){var e=t.target.value,n=t.target.dataset.topic,r=t.target.dataset.word,i=t.target.closest(".edit-form"),u=i.querySelector(".fields");switch(e){case"edit":u.innerHTML=`
                            <div class="mb-3">
                                <label class="label">${s.editFormStrings["entry-edit-form-topic-label"]}</label>
                                <input class="input" name="topic" type="text" value="${n}" readonly>
                            </div>
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-wrong-entry-label"]}
                                </label>
                                <input class="input" name="wrong_entry" type="text" value='${r}' readonly>
                            </div>
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-right-entry-label"]}
                                </label>
                                <input class="input" name="right_entry" type="text" pattern="[${s.regex}]+" required>
                            </div>
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-optional-comment-label"]}
                                </label>
                                <textarea class="input" name="comments" rows="5"></textarea>
                            </div>`,i.setAttribute("action","/crossword/suggestion/edit");break;case"remove":u.innerHTML=`
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-comment-label"]}
                                </label>
                                <input class="hidden" name="question" type="text" value='${n}' readonly>
                                <input class="hidden" name="word" type="text" value='${r}' readonly>
                                <textarea class="input comment-remove" name="comment" rows="5" required></textarea>
                            </div>`,i.setAttribute("action","/crossword/suggestion/remove"),document.querySelectorAll(".comment-remove").forEach(function(l){l.addEventListener("input",function(){this.value=this.value.trimStart()})});break;case"suggest":u.innerHTML=`
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-new-entry-label"]}
                                </label>
                                <input type="text" class="hidden" name="question" value='${n}' required>
                                <input class="input" name="answer" type="text" pattern="[${s.regex},]+" required>
                            </div>
                            <div class="mb-3">
                                <label class="label">
                                    ${s.editFormStrings["entry-edit-form-optional-comment-label"]}
                                </label>
                                <textarea class="input" name="comment" rows="5"></textarea>
                            </div>`,i.setAttribute("action","/crossword/suggestion");break}}}),document.body.addEventListener("submit",function(t){if(t.target.classList.contains("js-edit-form")){t.preventDefault(),document.querySelectorAll(".editFormErrors").forEach(r=>{r.remove()});var e=t.target;if(!s.disableRecaptcha)M.load(s.siteKey).then(r=>{r.execute("word").then(i=>{var u=i,l=new FormData(e);l.set("g-recaptcha-response",u),s.formSubmit(e,l)})});else{var n=new FormData(e);s.formSubmit(e,n)}}}),document.body.addEventListener("click",function(t){if(t.target.classList.contains("js-save-word")){var e=t.target.dataset.value,n=t.target.dataset.topic;s.saveWord(n,e)}else if(t.target.classList.contains("js-hide-edit-form-btn")){var r=t.target.dataset.entry;t.target.closest("form").closest("div").remove(),document.querySelector(`.edit-button[data-entry="${r}"]`).classList.remove("hidden")}}),m.on("updateData",t=>{console.log(t),this.filtered=[],this.entries=[],this.pagination=t.pagination,this.filter=t.filter,this.pageEntry=t.pageEntry,this.filtered=t.entries,this.sort(),t.filter?this.sortBy("entry","asc"):this.sortBy("length","asc")}),this.answers?(this.filter!==""&&(this.pattern=this.filter.replace("ß","ẞ").toUpperCase().replace("_",".").split("")),this.filterResults()):(this.filtered=this.entries,this.sort())},methods:{updateSavedWords(){localStorage.words&&(this.savedWords=JSON.parse(localStorage.words),this.savedWordsCount=Object.keys(this.savedWords).length)},filterResults(){if(this.pattern.length===0)this.filtered=this.entries;else{let s=new RegExp(`^${this.pattern.join("")}$`,"g"),t={};typeof this.entries[this.pattern.length]<"u"&&(t=this.entries[this.pattern.length]),this.entries[this.pattern.length]!==void 0&&Object.keys(this.entries[this.pattern.length]).filter(e=>s.test(e)).forEach(e=>{t[e]=this.entries[this.pattern.length][e]}),Object.entries(t).length===0?this.filtered={}:this.filtered={[this.pattern.length]:t}}this.sort()},getSortIcon(s,t){return this.sortOrder.by===s&&this.sortOrder.asc===!1?this.icons[t].down:this.icons[t].up},sortBy(s,t=!1){this.sortOrder.by===s&&!t?this.sortOrder.asc=!this.sortOrder.asc:this.sortOrder={by:s,asc:!0},this.sort()},sort(){if(this.sortOrder.by==="length"){this.sorted={};let t=(e,n)=>e-n;this.sortOrder.asc||(t=(e,n)=>n-e),Object.keys(this.filtered).sort(t).forEach(e=>{this.sorted[`_${e}`]=this.filtered[e]})}if(this.sortOrder.by==="entry"){this.sorted={all:{}};let t={};Object.entries(this.filtered).forEach(n=>{Object.keys(n[1]).forEach(r=>{t[r]=n[1][r]})});let e=(n,r)=>n.localeCompare(r);this.sortOrder.asc||(e=(n,r)=>r.localeCompare(n)),Object.keys(t).sort(e).forEach(n=>{this.sorted.all[n]=t[n]})}var s=0;this.showAdsData=Object.create(Object.getPrototypeOf(this.showAdsData),{}),Object.keys(this.sorted).forEach(t=>{Object.keys(this.sorted[t]).forEach((e,n)=>{this.paginationData.total>7&&s===3&&this.showAdsData.push({codes:this.ads&&this.ads!==!1?{code:this.ads.ad4_code,mcode:this.ads.ad4_mobile_code}:!1,key:t.replace("_",""),index:n,mobileOnly:!0,desktopOnly:!0}),s++})})},toPage(s){var t=new URLSearchParams(window.location.search);t.has("page")?t.set("page",s):t.append("page",s),window.location.search=t},getUrl(){return document.getElementById("question")?this.strings["no-crossword-search-results"].replace("slug_replace",this.generateSlug(document.getElementById("question").value)):""},formSubmit(s,t){axios.post(s.getAttribute("action"),t).then(({data:e})=>{s.insertAdjacentHTML("beforebegin",`<div class="p-3 mt-2 rounded bg-teal-200 text-teal-800 mb-3 editFormErrors">${e.message}</div>`)}).catch(function(e){s.insertAdjacentHTML("beforebegin",`<div class="p-3 mt-2 rounded bg-red-200 text-red-800 mb-3 editFormErrors">${e.response.data.message}</div>`)})},saveWord(s,t){var e=this.strings["crosswords-topic"].replace("<letters>",s),n=document.querySelector(".option[data-value='"+t+"']");for(let[r,i]of Object.entries(this.savedWords))if(i.topic===e&&i.word===t){this.removeWord(r),n.innerHTML='<div class="icon icon-heart me-2"></div>'+this.buttons[0],document.querySelector(`.menu-box2[data-word="${t}"]`).remove(),this.menuIcon.setAttribute("class","show-options-list icon icon-heart ml-auto"),this.menuIcon.classList.remove("index-table-wildcard");return}e.replace("<length>",t.length),this.savedWords[this.savedWordsCount]={topic:e,word:t,category:"crossword",hasLink:!0,entry:s},this.savedWordsCount++,m.emit("savedWords",this.savedWords),m.emit("savedWordsCount",this.savedWordsCount),localStorage.setItem("words",JSON.stringify(this.savedWords)),document.cookie="countSavedWord="+this.savedWordsCount,n.innerHTML='<div class="icon icon-trash me-2"></div>'+this.buttons[2],document.querySelector(`.menu-box2[data-word="${t}"]`).remove(),this.menuIcon.setAttribute("class","show-options-list icon icon-heart-solid ml-auto"),this.menuIcon.classList.add("index-table-wildcard")},removeWord(s){var t={};for(let[e,n]of Object.entries(this.savedWords))e!==s&&(t[Object.keys(t).length]=n);this.savedWords=t,this.savedWordsCount--,m.emit("savedWords",this.savedWords),m.emit("savedWordsCount",this.savedWordsCount),localStorage.setItem("words",JSON.stringify(this.savedWords)),document.cookie="countSavedWord="+this.savedWordsCount}}},pe={key:0,ref:"table",id:"anchor-link-to-table",class:"data-table index-table crossword-table"},ve={class:"index-table-head"},we={class:"index-table-head-cell flex",style:{"min-width":"105px"}},xe=["innerHTML"],ke=["src"],_e={class:"index-table-head-cell flex",style:{"min-width":"125px"}},Le=["innerHTML"],Fe=["src"],Oe={class:"index-table-row--pagination"},Se={key:0,class:"index-table-cell",colspan:"3"},Ce={class:"text-center sm:justify-center block md:flex"},Te=["innerHTML","aria-label"],je=["innerHTML","aria-label"],Ee=["innerHTML","aria-label","onClickOnce"],He=["innerHTML","aria-label"],Me=["innerHTML","aria-label","onClickOnce"],qe=["innerHTML","aria-label"],Be=["innerHTML","aria-label"],We=["innerHTML"];function Ae(s,t,e,n,r,i){const u=C("TableSegment");return Object.entries(this.filtered).length>0?(a(),o("div",pe,[d("div",ve,[d("div",we,[d("span",{innerHTML:e.strings.answer},null,8,xe),w(d("button",{type:"button",class:"ml-auto",onClick:t[0]||(t[0]=l=>i.sortBy("entry")),"aria-label":"sort"},[d("img",{src:i.sortEntryIcon,width:"23.63",height:"20.8",alt:"sort"},null,8,ke)],512),[[x,i.sortableAnswer]])]),d("div",_e,[d("span",{innerHTML:e.strings.length},null,8,Le),w(d("button",{type:"button",class:"ml-auto","aria-label":"sort",onClick:t[1]||(t[1]=l=>i.sortBy("length"))},[d("img",{src:i.sortLengthIcon,width:"23.63",height:"20.8",alt:"sort"},null,8,Fe)],512),[[x,i.sortableLength]])])]),(a(!0),o(h,null,p(r.sorted,(l,c,v)=>(a(),T(u,{key:c,results:l,strings:e.strings,length:c.replace("_",""),"sorted-by-length":i.sortedByLength,answers:e.answers,"answers-by-filter":e.answersByFilter,"page-entry":r.pageEntry,template:e.strings.hasOwnProperty("answers-table-sub-headline")?Object.entries(l).length>1?e.strings["answers-table-sub-headline-with-multiple-answers"].replaceAll("<amount of letters>",c.replace("_","")).replaceAll("<amount of answers>",Object.entries(l).length):e.strings["answers-table-sub-headline"].replaceAll("<amount of letters>",c.replace("_","")).replaceAll("<amount of answers>",Object.entries(l).length):c.replace("_","")+" "+e.strings.letters,buttons:e.buttons,"entries-asc":i.entriesAsc,"site-key":e.siteKey,"saved-words":r.savedWords,"saved-words-count":r.savedWordsCount,"edit-form-strings":e.editFormStrings,regex:e.regex,"show-ads-data":r.showAdsData,total:r.pagination.total,"menu-icon":r.menuIcon,"cross-form":e.crossForm,"z-index":Object.entries(r.sorted).length-v},null,8,["results","strings","length","sorted-by-length","answers","answers-by-filter","page-entry","template","buttons","entries-asc","site-key","saved-words","saved-words-count","edit-form-strings","regex","show-ads-data","total","menu-icon","cross-form","z-index"]))),128)),d("div",Oe,[e.buttons!==null&&r.pagination.last_page>1?(a(),o("div",Se,[d("div",Ce,[r.pagination.current_page>1?(a(),o("button",{key:0,class:"px-2 border hover:bg-teal-500",innerHTML:e.buttons[3],"aria-label":e.buttons[3],onClickOnce:t[2]||(t[2]=l=>i.toPage(1))},null,40,Te)):g("",!0),r.pagination.current_page>1?(a(),o("button",{key:1,class:"px-2 border hover:bg-teal-500",innerHTML:e.buttons[4],"aria-label":e.buttons[4],onClickOnce:t[3]||(t[3]=l=>i.toPage(r.pagination.current_page-1))},null,40,je)):g("",!0),(a(),o(h,null,p([2,1],l=>(a(),o(h,null,[r.pagination.current_page-l>0?(a(),o("button",{key:0,class:"px-2 border hover:bg-teal-500",innerHTML:r.pagination.current_page-l,"aria-label":r.pagination.current_page-l,onClickOnce:c=>i.toPage(r.pagination.current_page-l)},null,40,Ee)):g("",!0)],64))),64)),d("button",{class:"px-2 border bg-teal-500",innerHTML:r.pagination.current_page,"aria-label":r.pagination.current_page},null,8,He),(a(),o(h,null,p(2,l=>(a(),o(h,null,[r.pagination.current_page+l<=r.pagination.last_page?(a(),o("button",{key:0,class:"px-2 border hover:bg-teal-500",innerHTML:r.pagination.current_page+l,"aria-label":r.pagination.current_page+l,onClickOnce:c=>i.toPage(r.pagination.current_page+l)},null,40,Me)):g("",!0)],64))),64)),r.pagination.current_page!==r.pagination.last_page?(a(),o("button",{key:2,class:"px-2 border hover:bg-teal-500",innerHTML:e.buttons[5],"aria-label":e.buttons[5],onClickOnce:t[4]||(t[4]=l=>i.toPage(r.pagination.current_page+1))},null,40,qe)):g("",!0),r.pagination.current_page!==r.pagination.last_page?(a(),o("button",{key:3,class:"px-2 border hover:bg-teal-500",innerHTML:e.buttons[6],"aria-label":e.buttons[6],onClickOnce:t[5]||(t[5]=l=>i.toPage(r.pagination.last_page))},null,40,Be)):g("",!0)])])):g("",!0)])],512)):(a(),o("div",{key:1,innerHTML:i.getUrl()},null,8,We))}const Je=O(ye,[["render",Ae]]);export{Je as C,Z as L};