import{d as E,f as b,ac as B,r as I,e as c,D as S,w as C,h as D,cT as L,Z as F,c as h,E as g,m as r,a as i,s as M,cU as T,B as U,o as _}from"./index-ff703318.js";const W={class:"w-full h-full relative"},A={class:"loading"},N=U('<span class="loading-text-words">内</span><span class="loading-text-words">容</span><span class="loading-text-words">正</span><span class="loading-text-words">在</span><span class="loading-text-words">加</span><span class="loading-text-words">载</span><span class="loading-text-words">中</span>',7),V=[N],G=["src"],O=E({__name:"index",setup(j){const v=b(),l=B(),n=I(!1),u=c(()=>l.iframeUrl),o=S(),m=c(()=>o.theme==="dark");function w(){const e=document.getElementById("iframe");e!=null&&e.addEventListener||e==null||e.attachEvent("onload",d),e==null||e.addEventListener("load",d,!0)}const p=c(()=>o.theme);C(p,e=>{s({type:"theme",data:e})}),D(()=>{if(!u.value)return v.push("/");n.value=!0,w(),window.addEventListener("message",f)});async function f(e){const{type:t,data:a}=e.data;t==="theme"&&o.setTheme(a==="dark"?"dark":"light"),t==="chat"&&x(a)}function x(e){L({prompt:e}).then(t=>{const{code:a,data:k}=t;a===200&&s({type:"chat",data:y(k)})})}function y(e){const t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e.replace(t,"")}function s(e){document.getElementById("iframe").contentWindow.postMessage(e,"*")}function d(){s({type:"theme",data:p.value});const e=T();e&&s({type:"token",data:e}),n.value=!1}return F(()=>{l.updateIframeUrl("");const e=document.getElementById("iframe");e==null||e.removeEventListener("load",d),window.removeEventListener("message",f)}),(e,t)=>(_(),h("div",W,[n.value?(_(),h("div",{key:0,class:g(["main-container absolute left-0 right-0 bottom-0 top-0 backdrop-blur",[r(m)?"dark:bg-black/20":"bg-white/80"]])},[i("div",A,[i("div",{class:g(["loading-text ",r(m)?"text-[#fff]":"text-[#000]"]),id:"loading-text"},V,2)])],2)):M("",!0),i("iframe",{id:"iframe",src:r(u),style:{width:"100%",height:"100%",border:"none"}},null,8,G)]))}});export{O as default};
