import{aI as J,b7 as Q,b6 as X,aE as b,b3 as Z,aH as u,ad as K,bJ as c,aB as f,bq as s,aC as V,aD as p,r as Y,bt as T,Q as ee,bh as l,ax as A,b9 as i,aG as m,bi as ae,aS as te,aZ as ne,ak as oe}from"./index-Dg4NaXsE.js";/* empty css             *//* empty css                  *//* empty css               */const se={key:0,class:"workspace-3d-toolbar"},le={class:"hint"},re=["src"],ce={key:1,class:"workspace-3d-mask"},ie=1800,de=4,ue=18e3,fe=J({__name:"Workspace3D",props:{host:{default:void 0},scope:{default:"Platform"},token:{default:""},readOnly:{type:Boolean,default:!1},embedUi:{type:Boolean,default:!1},canvasOnly:{type:Boolean,default:!1},hideToolbar:{type:Boolean,default:!1}},emits:["pick","select","ready"],setup(o,{expose:M,emit:R}){const n=o,h=R,_=l(),O=l(),y=l(!1),v=l("正在连接 webVRender ..."),w=l(null),g=l([]),r=l(""),d=A(()=>n.host??"localhost:8223"??"localhost:8223"),z=A(()=>{const a=new URLSearchParams;return a.set("scope",n.scope??"Platform"),n.token&&a.set("token",n.token),a.set("ro",n.readOnly?"1":"0"),n.canvasOnly?a.set("ui","canvas-only"):n.embedUi&&a.set("ui","embed"),`http://${d.value}/?${a.toString()}`});let k=null,E=0;function F(){return`http://${d.value}`}function B(a){return new Promise(e=>setTimeout(e,a))}function P(){return n.canvasOnly||n.embedUi}function H(){return n.canvasOnly?"/declareCanvasOnly":n.embedUi?"/declareEmbedUi":null}async function D(a){try{return(await fetch(`${F()}${a}`,{method:"GET",cache:"no-store",credentials:"omit",signal:AbortSignal.timeout(ie)})).ok}catch{return!1}}async function I(){const a=H();if(a){for(let e=0;e<de;e++){if(await D(a))return;await B(80*(e+1))}console.warn(`[Workspace3D] ${a} 未成功，将依赖 SimpleLite 默认 canvas-only 模式`)}}async function G(a=1e4){const e=Date.now()+a;let t=60;for(;Date.now()<e;){if(await D("/vrenderReady"))return!0;await B(t),t=Math.min(t+40,280)}return!1}function S(){k!=null&&(clearTimeout(k),k=null)}function N(a){S(),k=setTimeout(()=>{a!==E||y.value||(v.value=`连接超时 (http://${d.value})，请确认 SimpleLite 已启动`)},ue)}function L(a){const e=z.value;if(!a)return e;const t=e.includes("?")?"&":"?";return`${e}${t}_=${Date.now()}`}async function x(a=!1){const e=++E;if(y.value=!1,v.value=`正在连接 webVRender (http://${d.value}) ...`,N(e),P())I(),r.value=L(a||!!r.value);else{if(v.value="正在等待 SimpleLite webVRender 就绪 ...",await G(),e!==E)return;r.value=L(a||!!r.value)}}function q(){y.value=!0,S(),h("ready")}function C(a){if(!_.value||a.source!==_.value.contentWindow)return;const e=a.data;if(!(!e||typeof e!="object")){if(e.type==="workspace.pick"&&e.payload&&typeof e.payload.x=="number")w.value=e.payload,h("pick",e.payload);else if(e.type==="workspace.select"&&Array.isArray(e.payload))g.value=e.payload,h("select",e.payload);else if(e.type==="workspace.shortcut"&&e.payload&&typeof e.payload=="object"){const t=e.payload.action;(t==="undo"||t==="redo"||t==="delete")&&window.dispatchEvent(new CustomEvent("workspace-shortcut",{detail:{action:t}}))}}}function W(){x(!0)}function $(){const a=O.value;a&&(document.fullscreenElement?document.exitFullscreen():a.requestFullscreen())}return Q(()=>{window.addEventListener("message",C),x(!1)}),X(()=>{window.removeEventListener("message",C),S()}),M({reload:W,enterFullscreen:$}),(a,e)=>{const t=K,U=Y,j=ee;return i(),b("div",{class:Z(["workspace-3d-wrap",{"workspace-3d--canvas-only":o.canvasOnly||o.hideToolbar}])},[o.canvasOnly||o.hideToolbar?p("",!0):(i(),b("div",se,[u(t,{type:o.readOnly?"info":"success",effect:"dark",size:"small"},{default:c(()=>[m(s(o.readOnly?"只读":"可交互"),1)]),_:1},8,["type"]),f("span",le,"webVRender · http://"+s(d.value)+" · scope="+s(o.scope),1),e[2]||(e[2]=f("div",{class:"spacer"},null,-1)),w.value?(i(),V(t,{key:0,type:"warning",size:"small"},{default:c(()=>[m(" Pick ("+s(w.value.x.toFixed(0))+", "+s(w.value.y.toFixed(0))+") ",1)]),_:1})):p("",!0),g.value.length?(i(),V(t,{key:1,type:"primary",size:"small"},{default:c(()=>[m(" Selected: "+s(g.value.length),1)]),_:1})):p("",!0),u(U,{size:"small",icon:T(ae),onClick:W},{default:c(()=>[...e[0]||(e[0]=[m("重载",-1)])]),_:1},8,["icon"]),u(U,{size:"small",icon:T(te),onClick:$},{default:c(()=>[...e[1]||(e[1]=[m("全屏",-1)])]),_:1},8,["icon"])])),f("div",{ref_key:"frameWrap",ref:O,class:"workspace-3d-frame"},[r.value?(i(),b("iframe",{key:0,ref_key:"frame",ref:_,src:r.value,class:"workspace-3d-iframe",allow:"fullscreen",onLoad:q},null,40,re)):p("",!0),y.value?p("",!0):(i(),b("div",ce,[u(j,{class:"is-loading",size:"32"},{default:c(()=>[u(T(ne))]),_:1}),f("span",null,s(v.value),1),e[3]||(e[3]=f("span",{class:"muted"},"如长时间未加载，请确认 SimpleLite 已以 Web-Enabled 模式启动且 8223 端口可达。",-1))]))],512)],2)}}}),we=oe(fe,[["__scopeId","data-v-17efa15d"]]);export{we as W};
