import{u as p}from"../admin/js/admin.js";import{c as s,r as g,o as w,n as x,e as f,w as _,q as i,t as h,v as u,k as l}from"./purify.es-C5Nd4Mfd.js";const E={class:"extension-page-host"},y={key:0,class:"text-center py-12 text-gray-400"},k={key:1,class:"text-center py-12"},T=["id","data-extension","data-page"],C={__name:"ExtensionPageHost",setup(z){const d=p(),e=s(()=>d.params.extension||""),a=s(()=>d.params.page||""),c=s(()=>`zc-ext-mount--${e.value}--${a.value}`),n=g("waiting");let o=null;function r(){e.value&&(n.value="waiting",window.dispatchEvent(new CustomEvent("zenochatbot:ext:mount",{detail:{extension:e.value,page:a.value,mountId:c.value}})),clearTimeout(o),o=setTimeout(()=>{n.value==="waiting"&&(n.value="failed")},4e3))}function m(v){var t;((t=v.detail)==null?void 0:t.extension)===e.value&&(n.value="mounted",clearTimeout(o))}return w(()=>{window.addEventListener("zenochatbot:ext:mounted",m),x(r)}),f(()=>{window.removeEventListener("zenochatbot:ext:mounted",m),clearTimeout(o),window.dispatchEvent(new CustomEvent("zenochatbot:ext:unmount",{detail:{extension:e.value}}))}),_([e,a],()=>{x(r)}),(v,t)=>(l(),i("div",E,[n.value==="waiting"?(l(),i("div",y,t[0]||(t[0]=[u("div",{class:"animate-pulse"},"Loading extension...",-1)]))):n.value==="failed"?(l(),i("div",k,t[1]||(t[1]=[u("p",{class:"text-gray-500"},"Extension failed to load. Please refresh the page.",-1)]))):h("",!0),u("div",{id:c.value,"data-extension":e.value,"data-page":a.value},null,8,T)]))}};export{C as default};
