import{a0 as k,a1 as z,u as L,d as N,r as f,w as R,h as T,a as p,i as y,j as w,S as D,E as I,M as O,U as X,B as A,k as b,o as U,l as $,a2 as q,m as j,n as V,p as W,q as H,v as Y,x as G,y as J,z as K,C as Q,D as Z,c as ee}from"./App.948dcab3.js";import"./lib-flexible.08f197e6.js";/* empty css              */import{P as te}from"./index.74ae2283.js";function de(){import("data:text/javascript,")}const ae="_container_1fh7z_1",se="_musicSheet_1fh7z_4",ne="_btn_1fh7z_11",oe="_btnCont_1fh7z_18";var h={container:ae,musicSheet:se,btn:ne,btnCont:oe};window.OffscreenCanvas||(window.OffscreenCanvas=class{constructor(t,s){return this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=s,this.canvas.convertToBlob=()=>new Promise(e=>{this.canvas.toBlob(e)}),this.canvas}});const re=k.offscreen();function ce(c){return new Promise((t,s)=>{const e=new FileReader;e.onloadend=()=>t(e.result),e.readAsDataURL(c)})}async function M(c,t,s){const e=new OffscreenCanvas(t,s),o=e.getContext("2d");o.fillStyle="#FFFFFF";const r=await z.fromString(o,c,re);r.resize(t*2,s*2,"xMidYMid meet"),await r.start();const S=await e.convertToBlob();return await ce(S)}const m=L();console.log(m,"search");const ie=async(c,t)=>{const s=await H(c);let e=f("");const o=Y(s);e.value=G(o.parsedXML,{title:t.musicSheetName});const r=Number(m["part-index"])||0;return e.value=J(e.value,r),e},le=c=>{const t=f("loading"),s=f({}),e=f({});return U(async()=>{t.value="loading";try{const o=await $.get(`/open/music/sheet/detail/${m.id}`,{prefix:"/api-website"});s.value=o.data,w.partIndex=0,t.value="success"}catch(o){t.value="error",console.log(o)}}),[t,s,e]};var ue=N({name:"ColexiuWebSite",setup(){const c=f(!0),t=f(!1),s=f(""),[e,o,r]=le(m.id),S=new q(650,884);R(e,async()=>{if(e.value==="success"&&o.value.xmlFileUrl){const a=await ie(o.value.xmlFileUrl,o.value);s.value=a.value}}),T();const x=async a=>{if(a)for(const d of a.Drawer.Backends){const{state:i,width:n,height:l}=d.ctx,{x:u,y:v}=i.scale,g=new XMLSerializer().serializeToString(d.ctx.svg);return await M(g,n/u,l/v)}},C=async a=>{if(a){const d=[];if(a.Drawer.Backends.length>0){for(let i=0,n=a.Drawer.Backends.length;i<n;i++){const l=a.Drawer.Backends[i],{state:u,width:v,height:g}=l.ctx,{x:B,y:E}=u.scale,F=new XMLSerializer().serializeToString(l.ctx.svg);d.push(await M(F,v/B,g/E))}return d}}},_=async a=>{if(window.parent){const n=m.pageType==="multiple"?await C(a):await x(a);console.log(n,"img"),window.parent.postMessage(n,"*")}j.osmd=a;const d=V(a);c.value=!1;const i=(n,l,u=!0)=>{const v=K(n);w.evaluatings={...w.evaluatings,[v.measureIndex]:{...v,...Q(l.score),score:l.score,dontTransition:u}}};if(r.value.userMeasureScore){for(const n in r.value.userMeasureScore)if(Object.prototype.hasOwnProperty.call(r.value.userMeasureScore,n)){const l=r.value.userMeasureScore[n];for(const u of d)if(l.measureRenderIndex==u.noteElement.sourceMeasure.MeasureNumberXML-1)if(!u.noteElement.tie)i(u,l);else for(const v of u.noteElement.tie.notes){const g=W(v);!g||i(g,l,v!==u.noteElement.tie.StartNote)}}}},P=()=>{t.value=!0,c.value=!1};return()=>{var i,n;const a=c.value||e.value==="loading",d=t.value||e.value==="error";return p("div",{class:[y.container,b.sett.eyeProtection&&"eyeProtection",b.sett.camera&&"openCamera"]},[p("div",{id:"colexiu-detail-music-sheet",class:[y.musicSheet,h.musicSheet],style:{paddingLeft:w.isSpecialShapedScreen?w.notchHeight/2+"px":"auto"}},[a&&!d&&p(D,{class:y.skeleton,rowWidth:"80%",title:!0,row:15},null),d&&p(I,null,null),s.value&&p(O,{score:s.value,opotions:{drawTitle:!1,drawComposer:!1,drawLyricist:!1,drawMetronomeMarks:!0,drawMeasureNumbers:!0},EngravingRules:m.pageType==="multiple"?{PageFormat:S}:{},onRerender:_,onRenderError:P},null)]),((i=r.value)==null?void 0:i.videoFilePath)&&((n=r.value)==null?void 0:n.expire)===0?p(te,X(r.value,{btnClass:h.btn,popupClass:h.popup}),{default:()=>[p(A,{class:h.btnCont},{default:()=>[p("img",{src:ReplayIcon},null)]})]}):null])}}});Z();ee(ue).mount("#app");export{de as __vite_legacy_guard};
