import{d as N,s as O,U as f,Q as I,P as E,bD as H,a3 as V,V as x,S as A,i as o,N as y,R as K,aT as j,$ as M}from"./index.7994470a.js";import{S as P}from"./index.6449f9de.js";import{T as U}from"./index.0262b810.js";import"./index.889feca1.js";import{T as z,a as w}from"./index.a28173c9.js";import{C as B}from"./index.0f4f72db.js";import{c as J}from"./index.9eb2b8e9.js";import{c as $}from"./index.926ca9c5.js";import{S as D}from"./select-tag.e373e423.js";import{g as L}from"./music.d2ae34a8.js";import{S as Q}from"./select-subject.cc64fd7c.js";import{a as h,S as b}from"./hooks.04c1f931.js";function W(s){return{all:s=s||new Map,on:function(r,c){var t=s.get(r);t?t.push(c):s.set(r,[c])},off:function(r,c){var t=s.get(r);t&&(c?t.splice(t.indexOf(c)>>>0,1):s.set(r,[]))},emit:function(r,c){var t=s.get(r);t&&t.slice().map(function(i){i(c)}),(t=s.get("*"))&&t.slice().map(function(i){i(r,c)})}}}const q="_search_ngdof_1",F="_sticky_ngdof_9",G="_title_ngdof_15",X="_keywords_ngdof_21",Y="_content_ngdof_28",Z="_searchKeyword_ngdof_38",ee="_remove_ngdof_46",oe="_label_ngdof_49";var u={search:q,sticky:F,title:G,keywords:X,content:Y,searchKeyword:Z,remove:ee,label:oe};function te(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!M(s)}const p=W(),k=f();var se=N({name:"MusicSearchHeader",setup(){if(!h(b.SEARCH).id){const e=O.user.data,n=e.subjectId?Number(e.subjectId.split(",")[0]):"",m=e.subjectName?e.subjectName.split(",")[0]:"";n&&h(b.SEARCH,JSON.stringify({id:n,name:m}),"set")}const r=f();localStorage.setItem("behaviorId",L());const c=I(),t=E(),i=f(""),v=f(""),g=f(!1),l=J("music-search",[]),d=f("songe");H(()=>{var n,m;const e=h(b.SEARCH);if(a.name=e.name||"\u5168\u90E8\u58F0\u90E8",a.id=e.id,t.path==="/music-songbook/search"){i.value="",v.value="",d.value="songe";try{(m=(n=k.value)==null?void 0:n.resetTags)==null||m.call(n)}catch(T){console.log(T)}}return!0}),V(d,e=>{p.emit("changeTab",e)});const S=e=>{i.value=e;const n=l.value.indexOf(e);n>-1&&l.value.splice(n,1),e&&(l.value.unshift(e),l.value.length=Math.min(l.value.length,5)),p.emit("search",e)},C=(e,n="")=>{const m=Object.values(e).flat().filter(Boolean).join(",");v.value=m,p.emit("confirm",e),g.value=!1},R=e=>{a.name=e.name,a.id=e.id,h(b.SEARCH,JSON.stringify({id:e.id,name:e.name}),"set"),p.emit("confirmSubject",a),a.show=!1};x(()=>{});const _=h(b.SEARCH),a=A({show:!1,name:_.name||"\u5168\u90E8\u58F0\u90E8",id:_.id||""});return()=>o("div",{class:u.search},[o(P,{class:u.sticky},{default:()=>[o(B,{modelValue:i.value,ref:r,onSearch:S,onClick:()=>{t.path==="/music-songbook"&&c.push({path:"/music-songbook/search"})}},{left:()=>o("div",{class:u.label,onClick:()=>a.show=!0},[a.name,o(y,{classPrefix:"iconfont",name:"down",size:12,color:"#333"},null)])}),t.path==="/music-songbook/search"&&o(z,{color:"var(--van-primary)",background:"transparent",lineWidth:20,shrink:!0,active:d.value,"onUpdate:active":e=>d.value=e,onChange:e=>d.value=e},{default:()=>[o(w,{title:"\u5355\u66F2",name:"songe"},null),o(w,{title:"\u4E13\u8F91",name:"album"},null)]})]}),l.value.length>0&&t.path==="/music-songbook/search"&&o("div",{class:$(u.keywords,"van-hairline--bottom")},[o("div",{class:u.content},[l.value.map(e=>o(U,{round:!0,class:u.searchKeyword,key:e,onClick:()=>S(e)},te(e)?e:{default:()=>[e]}))]),o(y,{class:u.remove,name:"delete-o",onClick:()=>l.value=[]},null)]),o(K,null,null),o(j,{show:g.value,round:!0,closeable:!0,position:"bottom",style:{height:"60%"},teleport:"body","onUpdate:show":e=>g.value=e},{default:()=>[o(D,{ref:k,onConfirm:C,onCancel:()=>{}},null)]}),o(j,{show:a.show,position:"bottom",round:!0,closeable:!0,"safe-area-inset-bottom":!0,onClose:()=>a.show=!1,onClosed:()=>a.show=!1},{default:()=>[o(Q,{searchParams:a,onComfirm:R},null)]})])}}),pe=Object.freeze(Object.defineProperty({__proto__:null,mitter:p,default:se},Symbol.toStringTag,{value:"Module"}));export{pe as h,p as m,u as s};
