import{k as e}from"./vendor-element-plus.js?ver=3.1.10";import{aQ as t,W as a,X as o,a8 as n,ab as i,a5 as l,J as d,a9 as s,aa as p,a0 as u,_ as r}from"./vendor.js?ver=3.1.10";import{_ as c,I as m}from"./fc-bits-ui.js?ver=3.1.10";const _={name:"photo_widget",components:{Icons:m},props:{modelValue:{type:String,default:""},value:{type:String,default:""},btn_mode:{type:Boolean,default:()=>!1},btn_text:{type:String,default:()=>"Upload"},btn_type:{type:String,default:()=>"default"},btn_class:{type:String,default:()=>""},hide_upload_icon:{type:Boolean,default:()=>!1},only_icon:{type:Boolean,default:()=>!1}},emits:["update:modelValue","input","changed","update:value"],data:()=>({app_ready:!1}),computed:{displayValue(){return this.modelValue||this.value||""}},methods:{initUploader(){var e;const t=null==(e=null==window?void 0:window.wp)?void 0:e.media,a=null==t?void 0:t.editor;if(!(a&&"function"==typeof a.open&&t&&t.model&&t.view))return console.warn("PhotoWidget: wp.media.editor is not available. Ensure wp_enqueue_media() is called on the page."),!1;const o=a.send.attachment;a.send.attachment=(e,t)=>{if(t&&t.url){const e=t.url;this.$emit("update:modelValue",e),this.$emit("update:value",e),this.$emit("input",e),this.$emit("changed",e)}a.send.attachment=o};const n=window.wpActiveEditor;window.wpActiveEditor="photo_widget",a.open();const i=a.frame;return i&&"function"==typeof i.on?i.on("close",()=>{window.wpActiveEditor=n}):window.wpActiveEditor=n,!1},getThumb:e=>e.url},mounted(){this.app_ready=!0}},y={class:"fluentcrm_photo_card"},f={key:0,class:"fluentcrm_photo_holder"},h=["src"],w={key:0,class:"icon"};const v=c(_,[["render",function(c,m,_,v,g,b){const k=t("Icons"),V=e;return a(),o("div",y,[g.app_ready?(a(),o("div",f,[b.displayValue&&!_.btn_mode?(a(),o("img",{key:0,src:b.displayValue},null,8,h)):n("",!0),i(V,{size:"small",onClick:b.initUploader,type:_.btn_type,class:u(_.btn_class)},{default:l(()=>[!_.hide_upload_icon||_.only_icon?(a(),o("span",w,[i(k,{"icon-name":"simple-upload"})])):n("",!0),_.only_icon?n("",!0):(a(),o(d,{key:1},[s(p(_.btn_text),1)],64))],void 0),_:1},8,["onClick","type","class"]),r(c.$slots,"after")])):n("",!0)])}]]);export{v as P};
