import{r as e,h as i}from"./p-BIwHMk6j.js";import{G as t,R as r,b as l}from"./p-D5qhls4G.js";import{g as o}from"./p-Bcm94u_z.js";import{n as s}from"./p-ooVD-6_a.js";const n=["pdf","edit","view"];var c=function(e,i,t,r){var l,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,r);else for(var n=e.length-1;n>=0;n--)(l=e[n])&&(s=(o<3?l(s):o>3?l(i,t,s):l(i,t))||s);return o>3&&s&&Object.defineProperty(i,t,s),s};const a=class{constructor(t){e(this,t),this.fileTypes=["view","contents","download"],this.renderLiveDocs=e=>{if(!this.isLiveDocsAvailable(e))return i("limebb-live-docs-info",null);if(!this.platform.isFeatureEnabled("useOfficeFilePreview"))return i("limebb-empty-state",{value:"Preview of this file type will be available soon",icon:{name:"attention",color:"rgb(var(--color-blue-light))"}});const t=this.getLiveDocsUrl(e);return i("iframe",{src:t,frameBorder:0,marginHeight:0,marginWidth:0})},this.renderFileViewer=e=>{const t=e.filename,r=this.getFileUrl(e);return r?i("limel-file-viewer",{filename:t,url:r,allowFullscreen:!0,allowOpenInNewTab:!0}):this.renderNotFound()},this.renderUnsupported=e=>i("limel-file-viewer",{filename:e.filename,url:void 0,allowFullscreen:!0,allowOpenInNewTab:!0}),this.renderNotFound=()=>[i("section",{class:"not-found"},i("limel-icon",{name:"error",size:"large"}),i("h2",null,this.translator.get("webclient.not-found")),i("p",null,this.translator.get("webclient.no-files-attached",{object:this.getDescriptive(this.limeobject)})))]}render(){const e=this.getFile();if(!e)return this.renderNotFound();const i=o(e.extension);return(0,{fileViewer:this.renderFileViewer,browser:this.renderFileViewer,sharepoint:this.renderLiveDocs,unsupported:this.renderUnsupported}[i])(e)}getLiveDocsUrl(e){let i=[...this.fileTypes];return this.platform.isFeatureEnabled("useOfficeFilePreview")&&(i=["pdf",...i]),i.filter(this.isLiveDocsType).map((i=>e.getUrl(i))).find(Boolean)}getFileUrl(e){return this.fileTypes.filter(s(this.isLiveDocsType)).map((i=>e.getUrl(i))).find(Boolean)}getFile(){const e=this.fileProperty;if(e)return this.limeobject.getFile(e.name)}isLiveDocsAvailable(e){return n.some((i=>e.getUrl(i)))}isLiveDocsType(e){return n.includes(e)}getDescriptive(e){var i;return(null==e?void 0:e.descriptive)||(null===(i=this.limetype)||void 0===i?void 0:i.localname.singular)||this.translator.get("object")}get fileProperty(){if(this.limeobject){if(this.property){const e=this.limeobject.getLimetype().getProperty(this.property);if("file"===e.type)return e}return Object.values(this.limeobject.getLimetype().properties).find((e=>"file"===e.type))}}get translator(){return this.platform.get(l.Translate)}};c([t()],a.prototype,"limeobject",void 0),c([r()],a.prototype,"limetype",void 0),a.style=".not-found{display:flex;flex-direction:column;height:100%;align-items:center;justify-content:center;line-height:1rem;color:rgb(var(--contrast-1100))}.not-found limel-icon{color:rgb(var(--color-red-default))}iframe{height:100%;width:100%}";export{a as limebb_limeobject_file_viewer}