import{_ as G,d as X,u as H,c as K,i as Q}from"./index-M_JNBppB.js";import{g as Y,b as Z,d as E}from"./visualList-DPlD0s0I.js";import{C as V}from"./scrollerText.vue_vue_type_style_index_0_scoped_7d906a56_lang-C5dFT_KQ.js";import{d as g}from"./indexedDB-BD3Nu2zn.js";import{r as t,l as ee,w as T,j as ae,ay as te,ax as oe,X as ne,B as $,D as O,W as N,u as B,M as le,a7 as se,z as C,y as ue,n as re}from"./vue-BJk78QHK.js";/* empty css                   */import{P as q,q as ce}from"./element-3_pOinej.js";import"./threejs-BafxXW5-.js";import"./utils-YI6ye1sf.js";import"./vxe-Dx3zSILm.js";import"./runAnimation-C0hyQ0Cy.js";const ie={__name:"preview3",props:{isScreenshot:{type:Boolean,default:!1}},setup(ve){const{getImgUrl:D}=H(),r=oe(),s=te(),f=t("preview"),l=t(null),y=t(!1),h=t(""),k=t(1e4),S=t([]),u=t([]),o=t([]),m=t(1920),d=t(1080),z=t(0),x=t(""),c=t(""),L=t(""),M=t(""),R=t(""),p=ee({type:"",modeltype:"",dataB:"",dataE:"",important:"",content:""}),b=t(null),I=t(!1),_=t(!1),J=t(!0);t("center center");const w=t(1),j=t(null);T(()=>p,e=>{const a=Q(e.dataB,e.dataE);a?e.type==="1"?(p.content,re(()=>{I.value=!0,_.value=!1})):(I.value=!1,_.value=!0):(I.value=!1,_.value=!1)},{deep:!0}),T(h,(e,a)=>{if(e){const n=document.getElementById("animateBox");if(!n)return;n.className+=` ${e}`,l.value&&clearInterval(l.value),l.value=null,l.value=setInterval(()=>{F(e)},k.value)}else l.value&&clearInterval(l.value),l.value=null}),ae(()=>{f.value=s.query.mode||"",r.commit("setMode","preview"),x.value=s.query.name,c.value=s.query.kanbanId,L.value=s.query.status,M.value=s.query.type,R.value=s.query.modeltype,c.value&&A(c.value),U().then(()=>{const e=q.service({lock:!0,text:"资源加载中...",background:"rgba(0, 0, 0, 0.7)"});s.query.isScreenshot==="true"&&J.value?g.getItem("canvasData").then(n=>{n&&(u.value=JSON.parse(n),g.getItem("canvasStyle").then(v=>{o.value=JSON.parse(v),i()}))}):c.value&&x.value!==""?(W(c.value),e.close()):g.getItem("canvasData").then(n=>{n&&(u.value=JSON.parse(n),g.getItem("canvasStyle").then(v=>{o.value=JSON.parse(v),r.commit("setComponentData",u.value),r.commit("setCanvasStyle",o.value),i(),e.close()}))})}),window.addEventListener("resize",i)}),ne(()=>{window.removeEventListener("resize",i),b.value&&clearInterval(b.value),l.value&&clearInterval(l.value)});function U(){return new Promise(e=>{document.readyState==="complete"?e():window.addEventListener("load",e)})}async function W(e){const a=q.service({lock:!0,text:"",background:"rgba(0, 0, 0, 0.7)"}),n=f.value=="template"?await Y({_id:e}):await Z({_id:e});n.code===200?(u.value=n.data[0].canvasData,o.value=n.data[0].canvasStyle,r.commit("setComponentData",u.value),r.commit("setCanvasStyle",o.value),i()):ce({type:"error",message:n.msg}),a.close()}function i(){m.value=o.value.width,d.value=o.value.height,m.value,d.value,P()}function P(){const e=X(u.value);w.value=document.documentElement.clientWidth/o.value.width,S.value=e}function A(e){f.value!="template"&&(setTimeout(()=>{E({_id:e}).then(a=>{if(a.code===200){if(!a.data.showanimated)return;Object.assign(p,a.data),y.value=a.data.showanimated,setTimeout(()=>{h.value=a.data.animated,k.value=Number.parseInt(a.data.animatedTime)},500)}})},5e3),b.value=setInterval(()=>{E({_id:e}).then(a=>{a.code===200&&(Object.assign(p,a.data),y.value=a.data.showanimated,setTimeout(()=>{h.value=a.data.animated,k.value=Number.parseInt(a.data.animatedTime)},1e3))})},2e4))}function F(e){if(!y.value){const n=document.getElementById("animateBox");n.className,n.className=n.className.replace(` ${e}`,"");return}const a=document.getElementById("animateBox");a.className=a.className.replace(` ${e}`,""),setTimeout(()=>{a.className+=` ${e}`},100),setTimeout(()=>{a.className=a.className.replace(` ${e}`,"")},3e3)}return(e,a)=>(C(),$("div",{id:"container",key:z.value,class:"bg no-select",style:N({background:o.value.url?`url(${B(D)(o.value.url)})`:o.value.backgroundColor,"background-size":o.value.url?"100% 100%":"","background-repeat":o.value.url?"no-repeat":"",width:`${m.value}px`,height:`${d.value}px`,position:"relative",transform:`scale(${w.value},${w.value})`,transformOrigin:"left top"})},[O("div",{class:"canvas-container",style:N({width:m.value,height:d.value,position:"relative"})},[O("div",{ref_key:"screenshots",ref:j,class:"canvas",style:N({...B(K)(o.value),background:o.value.url?`url(${B(D)(o.value.url)})`:o.value.backgroundColor,"background-size":o.value.url?"100% 100%":"","background-repeat":o.value.url?"no-repeat":"","transform-style":"preserve-3d"})},[(C(!0),$(le,null,se(S.value,(n,v)=>(C(),ue(V,{"component-data":S.value,key:v,config:n},null,8,["component-data","config"]))),128))],4)],4)],4))}},_e=G(ie,[["__scopeId","data-v-2f904ee6"]]);export{_e as default};
