import{a_ as o,ay as l,di as g,dj as m,dk as h}from"./index-8fb4d12a-1720452812367.js";const c=e=>{if(e===null)return null;const r=Object.assign({},e);return Object.keys(r).forEach(i=>r[i]=typeof e[i]=="object"?c(e[i]):e[i]),Array.isArray(e)?(r.length=e.length,Array.from(r)):r},f=o("catch-store",{state:()=>({bookVersionList:[],musicTypeList:[],subjectList:[],musicInstrumentList:[],subjectInstruemnts:[],musicTagTree:[]}),getters:{getBookVersion(){return this.bookVersionList},getMusicCategories(){return this.musicTypeList},getMusicInstruments(){return this.musicInstrumentList},getAllMusicCategories(){return[{name:"全部",id:null},...this.musicTypeList]},getSubjectList(){return this.subjectList},getSubjectAllList(){return[{name:"全部",id:null},...this.subjectList]},getEnableSubjects(){const e=[];return this.subjectList.forEach(r=>{if(r.enableFlag){const{instruments:i,...t}=r;if(i&&i.length>0){const n=[];i==null||i.forEach(s=>{s.enableFlag&&n.push(s)}),n.length>0&&e.push({...t,instruments:n})}}}),e},getSubjectInstruments(){return[{name:"全部",id:null,label:"全部",value:null},...this.subjectInstruemnts]},getMusicTagTree(){return this.musicTagTree}},actions:{setBookVersion(e){this.bookVersionList=e},setMusicCategories(e){this.musicTypeList=e},setSubjects(e){this.subjectList=e},setSubjectInstruemnts(e){this.subjectInstruemnts=e},setMusicInstruments(e){this.musicInstrumentList=e},setMusicTagTree(e){this.musicTagTree=e},async getSubjects(){try{if(this.getSubjectList&&this.getSubjectList.length>0)return Promise.resolve();const{data:e}=await l({delFlag:0,page:1,rows:999}),r=e||[],i=[];return r.forEach(t=>{if(t.instruments&&t.instruments.length>0){t.value=t.id,t.label=t.name,t.instruments.forEach(s=>{s.label=s.name,s.value=s.id});const n={value:t.id,label:t.name,id:t.id,name:t.name,instruments:[]};t.instruments&&(t.instruments.length==1?(n.value=t.instruments[0].id,n.label=t.instruments[0].name,n.id=t.id,n.name=t.name):t.instruments.length>1&&t.instruments.forEach(s=>{s.label=s.name,s.value=s.id,n.instruments.push({label:s.name,value:s.id,id:s.id,name:s.name})})),i.push(n)}}),this.setSubjects(r.filter(t=>t.instruments&&t.instruments.length>0)||0),this.setSubjectInstruemnts(i||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},getEnableSingleAllSubjects(e){e=e||[];const r=[];this.getSubjectList.forEach(t=>{const n=c(t);Array.isArray(n.instruments)&&n.instruments.forEach(s=>{e.includes(s.id)&&(s.enableFlag=!0,n.enableFlag=!0)}),r.push(n)});const i=[];return r.forEach(t=>{if(t.enableFlag){const{instruments:n,...s}=t,u=[];n==null||n.forEach(a=>{a.enableFlag&&u.push(a)}),u.length>0&&i.push({...s,instruments:u})}}),i},async getMusicSheetCategory(e=!1){try{if(this.getMusicCategories&&this.getMusicCategories.length>0&&!e)return Promise.resolve();const{data:r}=await g({enable:!0,page:1,rows:999});return this.setMusicCategories(r.rows||[]),Promise.resolve()}catch(r){return Promise.reject(r)}},async getMusicInstrument(){try{if(this.getMusicInstruments&&this.getMusicInstruments.length>0)return Promise.resolve();const{data:e}=await m({enableFlag:!0});return console.log(e,"data"),this.setMusicInstruments(e||[]),Promise.resolve()}catch(e){return Promise.reject(e)}},async getMusicTagTreeApi(){try{if(this.getMusicTagTree&&this.getMusicTagTree.length>0)return Promise.resolve();const{data:e}=await h(),r=e||[];return this.setMusicTagTree(r||[]),Promise.resolve()}catch(e){return Promise.reject(e)}}}});export{c as d,f as u};
