"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),q=require("./resources/zv-vr-select.svg.js"),b=require("./resources/zv-return.svg.js"),G=require("./resources/zv-add.svg.js"),W=require("./resources/zv-reduce.svg.js"),Y=require("./resources/zv-play.svg.js"),F=require("./resources/zv-pause.svg.js"),U=require("./resources/zv-refresh.svg.js"),_=require("hls.js"),h=require("lodash"),a=p=>(e.pushScopeId("data-v-96f96666"),p=p(),e.popScopeId(),p),$={class:"vr-scene-wrap"},Z={id:"panorama",class:"vr-scene"},K={id:"panorama-video-wrap",class:"vr-scene-main"},Q={key:1,class:"vr-scene-controls"},X=a(()=>e.createElementVNode("img",{src:q.default,alt:""},null,-1)),x=a(()=>e.createElementVNode("img",{src:b.default,alt:""},null,-1)),ee=[x],oe=a(()=>e.createElementVNode("img",{src:b.default,alt:""},null,-1)),te=[oe],ne=a(()=>e.createElementVNode("img",{src:b.default,alt:""},null,-1)),ce=[ne],se=a(()=>e.createElementVNode("img",{src:b.default,alt:""},null,-1)),ie=[se],ae=a(()=>e.createElementVNode("img",{src:G.default,alt:""},null,-1)),le=[ae],re=a(()=>e.createElementVNode("img",{src:W.default,alt:""},null,-1)),ue=[re],de=a(()=>e.createElementVNode("img",{src:Y.default,alt:""},null,-1)),ve=[de],pe=a(()=>e.createElementVNode("img",{src:F.default,alt:""},null,-1)),we=[pe],me=a(()=>e.createElementVNode("img",{src:U.default,alt:""},null,-1)),fe=[me],Se={class:"scene-list"},Ve=["onClick"],he=["src"],be={class:"label"},ye=["autoplay","loop","volume"],ke=["src"],ge={key:3,class:"mouse-tip"},_e=e.createStaticVNode('<div class="icon-wrap" data-v-96f96666><div class="left" data-v-96f96666><i class="iconfont zv-drop-down" data-v-96f96666></i></div><i class="iconfont zv-mouse" data-v-96f96666></i><div class="right" data-v-96f96666><i class="iconfont zv-drop-down" data-v-96f96666></i></div></div><p class="title" data-v-96f96666>左右拖动   更多精彩</p>',2),Ee=[_e],He=e.defineComponent({name:"zv-scene-vr"}),Oe=e.defineComponent({...He,props:{basicOption:{},sources:{},useEvents:{},uuid:{},isPreview:{type:Boolean},disableDrag:{type:Boolean}},emits:["on-scene-loaded","on-scene-scenechange","on-scene-zooming","on-scene-hotClick"],setup(p,{emit:O}){const t=p,w=O,l=e.ref(),r=e.ref({src:"",autoplay:!0,loop:!0,volume:50}),d=e.ref(null),J=e.ref(t.basicOption.default.firstScene),v=e.ref(J.value),n=e.computed(()=>{try{return t.basicOption.scenes[v.value]}catch{return null}}),E={bylineLabel:"来自 %s",noPanoramaError:"未指定全景图像。",fileAccessError:"The file %s could not be accessed.",malformedURLError:"全景URL无法访问。",iOS8WebGLError:"Due to iOS 8's broken WebGL implementation, only progressive encoded JPEGs work for your device (this panorama uses standard encoding).",genericWebGLError:"您的浏览器没有显示此全景图所需的WebGL支持。",textureSizeError:"This panorama is too big for your device! It's %spx wide, but your device only supports images up to %spx wide. Try another device. (If you're the author, try scaling down the image.)",unknownError:"未知错误。检查开发人员控制台。"},B=()=>{const o=t.basicOption;window.SHJSceneVrViewer=window.pannellum.viewer("panorama",{...o,default:Object.assign(h.cloneDeep(o.default),{firstScene:v.value}),strings:E})},C=()=>{const o=()=>{const i=document.getElementById("panorama-video-wrap");i.innerHTML=`
            <video
                id="panorama-video"
                autoplay
                class="video-js vjs-default-skin vr-scene vjs-big-play-centered"
                preload="none"
                style="width:100%;height:100%;"
                crossorigin="anonymous"
            >
            </video>
        `};d.value&&(d.value.dispose(),d.value=null,o()),d.value||o();const c=document.getElementById("panorama-video"),s=t.basicOption;if(d.value=window.videojs(c,{loop:!0,autoplay:!0,plugins:{pannellum:{...t.basicOption,default:Object.assign(h.cloneDeep(s.default),{firstScene:v.value}),strings:E}}}),window.SHJSceneVrViewer=d.value.pnlmViewer,n.value.sceneType==="video"&&(c.src=n.value.panorama),n.value.sceneType==="hls")if(_.isSupported()){const i=new _;i.loadSource(n.value.panorama),i.attachMedia(c),i.on(_.Events.MANIFEST_PARSED,()=>{c.play()})}else c.canPlayType("application/vnd.apple.mpegurl")&&(c.src=n.value.panorama)},y=()=>{if(window.pannellum&&t.basicOption){window.SHJSceneVrViewer&&(window.SHJSceneVrViewer.destroy(),window.SHJSceneVrViewer=null),n.value.sceneType==="image"?B():C();try{t.basicOption.scenes[window.SHJSceneVrViewer.getScene()]&&(r.value=t.basicOption.default.audio,l.value&&r.value&&(window.SHJSceneVrViewer.audio=l,l.value.src=r.value.src,setTimeout(()=>{l.value&&(f.value=l.value.paused)},500)))}catch{}window.SHJSceneVrViewer.on("load",()=>{w("on-scene-loaded",n.value),window.SHJParseEvent(t.useEvents,"on-scene-loaded",n.value)}),!t.isPreview||t.basicOption.default.autoRotate===0?window.SHJSceneVrViewer.stopAutoRotate():window.SHJSceneVrViewer.startAutoRotate();try{window.SHJSceneVrViewer&&async function(){for(const o in t.basicOption.scenes)Object.prototype.hasOwnProperty.call(t.basicOption.scenes,o)&&t.basicOption.scenes[o].hotSpots.forEach(async s=>{await setTimeout(()=>{s.draggable=!t.isPreview&&!t.disableDrag,window.SHJSceneVrViewer.removeHotSpot(s.id,o),window.SHJSceneVrViewer.addHotSpot(s,o)},100)})}()}catch{}window.SHJSceneVrViewer.on("scenechange",o=>{const c=document.getElementsByTagName("video");if(h.isArray(c)&&c.length>0&&c.forEach(s=>{s&&s.pause()}),n.value){const s=n.value.sceneType;v.value=o;const i=n.value.sceneType;setTimeout(()=>{(i!=="image"||s!=="image"&&i==="image")&&y(),S.value=v.value,w("on-scene-scenechange",n.value),window.SHJParseEvent(t.useEvents,"on-scene-scenechange",n.value)}),t.isPreview?window.SHJSceneVrViewer.startAutoRotate():window.SHJSceneVrViewer.stopAutoRotate()}else v.value=t.basicOption.default.firstScene,e.nextTick(()=>{y(),w("on-scene-scenechange",n.value),window.SHJParseEvent(t.useEvents,"on-scene-scenechange",n.value)})}),window.SHJSceneVrViewer.on("zoomchange",h.debounce(o=>{w("on-scene-zooming",n.value),window.SHJParseEvent(t.useEvents,"on-scene-zooming",n.value)},300)),window.SHJSceneVrViewer.on("hot-click",o=>{w("on-scene-hotClick",o),window.SHJParseEvent(t.useEvents,"on-scene-hotClick",o)})}},S=e.ref(t.basicOption.default.firstScene),N=e.computed(()=>{const o=[];if(t.basicOption){const c=t.basicOption.scenes;for(const s in c)if(Object.prototype.hasOwnProperty.call(c,s)){const i=c[s];o.push({label:i.label,value:s,thumbnail:i.cover})}}return o.sort((c,s)=>{const i=parseInt(c.value.replace("scene","")),u=parseInt(s.value.replace("scene",""));return i-u})});e.watch(()=>t.basicOption.default,()=>{t.isPreview?window.SHJSceneVrViewer.startAutoRotate():window.SHJSceneVrViewer.stopAutoRotate()},{deep:!0});const T=o=>{window.SHJSceneVrViewer&&S.value!==o&&(S.value=o,window.SHJSceneVrViewer.isLoaded()&&(window.SHJSceneVrViewer.loadScene(o),t.isPreview?window.SHJSceneVrViewer.startAutoRotate():window.SHJSceneVrViewer.stopAutoRotate()))},k=e.ref(),m=e.ref(!0),P=()=>{m.value?k.value.style.bottom="-999px":k.value.style.bottom="80px",m.value=!m.value};e.onMounted(()=>{t.basicOption&&(t.basicOption.default.controls===void 0&&(t.basicOption.default.controls=n.value.controls),t.basicOption.default.audio===void 0&&(t.basicOption.default.audio=n.value.audio)),y(),M()});const R=()=>{window.SHJSceneVrViewer.setPitch(window.SHJSceneVrViewer.getPitch()+10)},z=()=>{window.SHJSceneVrViewer.setPitch(window.SHJSceneVrViewer.getPitch()-10)},A=()=>{window.SHJSceneVrViewer.setYaw(window.SHJSceneVrViewer.getYaw()-10)},D=()=>{window.SHJSceneVrViewer.setYaw(window.SHJSceneVrViewer.getYaw()+10)},L=()=>{window.SHJSceneVrViewer.setHfov(window.SHJSceneVrViewer.getHfov()-10)},I=()=>{window.SHJSceneVrViewer.setHfov(window.SHJSceneVrViewer.getHfov()+10)},f=e.ref(!1),H=o=>{l.value&&(o==="play"?(l.value.play(),f.value=!1):(l.value.pause(),f.value=!0))},j=()=>{window.SHJSceneVrViewer.startAutoRotate()};let g;const V=e.ref(!1),M=()=>{t.basicOption.default.controls?V.value=t.basicOption.default.controls.mouseTipShow:V.value=!0,g&&clearTimeout(g),g=setTimeout(()=>{V.value=!1},3500)};return(o,c)=>{const s=e.resolveComponent("el-tooltip"),i=e.resolveComponent("el-scrollbar");return e.openBlock(),e.createElementBlock("div",$,[n.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.withDirectives(e.createElementVNode("div",Z,null,512),[[e.vShow,n.value.sceneType==="image"]]),e.withDirectives(e.createElementVNode("div",K,null,512),[[e.vShow,n.value.sceneType!=="image"]])],64)):e.createCommentVNode("",!0),o.basicOption.default.controls?(e.openBlock(),e.createElementBlock("div",Q,[o.basicOption.default.controls.scene?(e.openBlock(),e.createElementBlock("div",{key:0,class:"btn-icon left",style:e.normalizeStyle({borderColor:m.value?"#ff7d00":"#ffffff3d"}),onClick:P},[e.createVNode(s,{content:"场景选择"},{default:e.withCtx(()=>[X]),_:1})],4)):e.createCommentVNode("",!0),o.basicOption.default.controls.left?(e.openBlock(),e.createElementBlock("div",{key:1,class:"btn-icon left",onClick:A},ee)):e.createCommentVNode("",!0),o.basicOption.default.controls.right?(e.openBlock(),e.createElementBlock("div",{key:2,class:"btn-icon right",onClick:D},te)):e.createCommentVNode("",!0),o.basicOption.default.controls.top?(e.openBlock(),e.createElementBlock("div",{key:3,class:"btn-icon up",onClick:R},ce)):e.createCommentVNode("",!0),o.basicOption.default.controls.bottom?(e.openBlock(),e.createElementBlock("div",{key:4,class:"btn-icon down",onClick:z},ie)):e.createCommentVNode("",!0),o.basicOption.default.controls.magnify?(e.openBlock(),e.createElementBlock("div",{key:5,class:"btn-icon",onClick:L},le)):e.createCommentVNode("",!0),o.basicOption.default.controls.shrink?(e.openBlock(),e.createElementBlock("div",{key:6,class:"btn-icon",onClick:I},ue)):e.createCommentVNode("",!0),f.value&&r.value.src&&o.basicOption.default.audio?(e.openBlock(),e.createElementBlock("div",{key:7,class:"btn-icon",onClick:c[0]||(c[0]=u=>H("play"))},ve)):e.createCommentVNode("",!0),!f.value&&r.value.src&&o.basicOption.default.audio?(e.openBlock(),e.createElementBlock("div",{key:8,class:"btn-icon",onClick:c[1]||(c[1]=u=>H("pause"))},we)):e.createCommentVNode("",!0),o.basicOption.default.controls.rotate?(e.openBlock(),e.createElementBlock("div",{key:9,class:"btn-icon",onClick:j},fe)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),o.basicOption.default.controls?(e.openBlock(),e.createElementBlock("div",{key:2,ref_key:"sceneMenuRef",ref:k,class:"scene-menu",style:e.normalizeStyle({bottom:m.value&&o.basicOption.default.controls.scene?"80px":"-9999999999999px"})},[e.createVNode(i,null,{default:e.withCtx(()=>[e.createElementVNode("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,u=>(e.openBlock(),e.createElementBlock("div",{key:u.value,class:"scene-item",style:e.normalizeStyle({borderColor:S.value===u.value?"#ff7d00":"#fff"}),onClick:Je=>T(u.value)},[e.createElementVNode("img",{class:"thumbnail",src:u.thumbnail},null,8,he),e.createElementVNode("p",be,e.toDisplayString(u.label),1)],12,Ve))),128))])]),_:1})],4)):e.createCommentVNode("",!0),e.createElementVNode("audio",{ref_key:"audioRef",ref:l,autoplay:r.value.autoplay,loop:r.value.loop,volume:r.value.volume},[e.createElementVNode("source",{src:r.value.src},null,8,ke)],8,ye),V.value?(e.openBlock(),e.createElementBlock("div",ge,Ee)):e.createCommentVNode("",!0)])}}});exports.default=Oe;
