import{n as r}from"./plugin-vue2_normalizer.000ba15c.js";const l={data(){return{searchOpen:!1,search:"",results:[],timeout:null}},computed:{isSearching(){return this.search.trim()!==""}},watch:{search:function(t){this.results=null,this.loading=!0,this.getResults(),this.arrowNavigation={identifier:null,index:-1}}},mounted(){document.addEventListener("keydown",this.handleKeydown),window.eventBus.$on("openSearch",()=>{this.openSearch()})},destroyed(){this.timeout&&clearTimeout(this.timeout)},methods:{getResults(){this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(()=>{if(!this.search){this.loading=!1;return}this.results=null,window.axios.get(this.route("search",{query:this.search})).then(t=>{this.loading=!1,this.totalResults=t.data.total,t.data.total?this.results=t.data.results:this.results=null})},300)},handleKeydown(t){this.isNotInputElement(t)&&t.keyCode===191&&(t.preventDefault(),t.stopPropagation(),this.openSearch()),t.keyCode===27&&this.closeSearch(),this.isNotInputElement(t)&&(t.ctrlKey||t.metaKey||this.$page.props.auth.user.keyboard_shortcuts&&(t.key==="c"&&this.$inertia.visit(this.route("sites.index",{create:!0})),t.key==="p"&&this.$inertia.visit(this.route("profile.index"))))},openSearch(){this.searchOpen=!0,this.$nextTick(()=>{this.$refs.search&&this.$refs.search.focus()})},closeSearch(){this.search="",this.searchOpen=!1,this.$refs.search&&this.$refs.search.blur()},isNotInputElement(t){const s=t.target.tagName;return Boolean(s!=="INPUT"&&s!=="TEXTAREA"&&t.target.id!=="code-editor"&&!t.target.classList.contains("form-textarea"))}}};var o=function(){var s=this,e=s._self._c;return s.searchOpen?e("div",{staticClass:"w-full h-screen fixed inset-0 bg-backdrop bf-blur z-40 flex items-center flex-col"},[e("div",{directives:[{name:"click-outside",rawName:"v-click-outside",value:s.closeSearch,expression:"closeSearch"}],staticClass:"w-full max-w-4xl p-8 space-y-4"},[e("input",{directives:[{name:"model",rawName:"v-model",value:s.search,expression:"search"}],ref:"search",staticClass:"w-full h-12 px-4 rounded bg-surface-1 shadow-md",attrs:{type:"text",placeholder:s.__("Type to search anything...")},domProps:{value:s.search},on:{input:function(a){a.target.composing||(s.search=a.target.value)}}}),e("Transition",{attrs:{"enter-active-class":"transition ease-in-out transform duration-fast","leave-active-class":"transition ease-in-out transform duration-fast","enter-class":"-translate-y-4 opacity-0 scale-95","enter-to-class":"translate-y-0 opacity-100 scale-100","leave-class":"translate-y-0 opacity-100 scale-100","leave-to-class":"translate-y-4 opacity-0 scale-95",mode:"out-in"}},[s.isSearching?e("div",{key:"results",staticClass:"rounded bg-surface-1 shadow-md overflow-hidden"},s._l(s.results,function(a){return e("ul",{staticClass:"flex flex-col divide-y divide-low-emphasis"},[e("li",{staticClass:"px-4 py-2 bg-surface-2"},[e("h3",{staticClass:"text-small font-medium"},[s._v(s._s(a.label)+" ("+s._s(a.total)+")")])]),s._l(a.results,function(i){return e("li",[e("inertia-link",{staticClass:"px-4 py-3 block text-small",attrs:{href:i.route},on:{click:s.closeSearch}},[s._v(" "+s._s(i.name)+" ")])],1)})],2)}),0):e("div",{key:"hints",staticClass:"rounded bg-surface-1 shadow-md p-4"},[e("ul",{staticClass:"flex flex-col space-y-3"},[e("li",[e("h3",{staticClass:"text-small font-medium"},[s._v(s._s(s.__("All helpful key shortcuts")))])]),e("li",{staticClass:"space-x-2 text-small"},[e("code",{staticClass:"rounded px-2 py-1 monospace border border-low-emphasis shadow-sm"},[s._v("/")]),e("span",[s._v(s._s(s.__("Open search")))])]),e("li",{staticClass:"space-x-2 text-small"},[e("code",{staticClass:"rounded px-2 py-1 monospace border border-low-emphasis shadow-sm"},[s._v("c")]),e("span",[s._v(s._s(s.__("Create site")))])]),e("li",{staticClass:"space-x-2 text-small"},[e("code",{staticClass:"rounded px-2 py-1 monospace border border-low-emphasis shadow-sm"},[s._v("p")]),e("span",[s._v(s._s(s.__("Goto profile")))])])])])])],1)]):s._e()},c=[],n=r(l,o,c,!1,null,null,null,null);const u=n.exports;export{u as default};
