import{Q as B}from"./quill.snow-C-zgzNLy.js";import{h as C}from"./hrmManagement-B9P5L2Nz.js";import{_ as q,d as A,c as H,o as u,g as o,w as n,at as D,f as E,F as k,j as K,e as S,i as U,t as z,k as _,T as F,m as V,af as M,a9 as N}from"./app-D7zH3Nl5.js";import{B as O}from"./useFlexGapSupport-CpBR-RD-.js";import{_ as P,T as Q}from"./index-BUzTR6QN.js";import{a as j,_ as x}from"./index-Cv7zOydE.js";import{_ as W}from"./index-DZxk72Vu.js";const G=A({props:{labelTitle:{default:""},editorHeight:{default:"auto"},descriptionLableTitle:{default:"description"},letterheadTemplates:{default:[]},users:{default:[]},appreciation:{default:{}},rules:{default:{}},letterheadTemplateId:{default:void 0},userId:{default:void 0},required:{default:!1},isLetterHeadTemplate:{default:!1},renderListItem:{default:["employee_keys","other_keys"]}},emits:["contentUpdated"],setup(e,{emit:c}){const{letterHeadUser:v,letterHeadAppreciation:T,setLetterHeadTemplateValues:g,selectedLetterHeadFields:$,resetSelectformOption:m,templateDescription:d,reSetListOfKeys:f}=C(),s=_(null),r=_("");_("");const h=_("selected_letterhead_field_title_0");let t=null;F(()=>{t=new B(s.value,{theme:"snow",placeholder:"Write something...",modules:{toolbar:[[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],["bold","italic","underline","strike"],["image","video"],[{list:"ordered"},{list:"bullet"},{list:"check"}],[{script:"sub"},{script:"super"}],[{color:[]},{background:[]}],[{align:[]}]],table:!0}}),t.on("text-change",()=>{r.value=t.root.innerHTML,c("contentUpdated",r.value)})});const b=a=>{g();const l=t.getSelection(!0);var i=M(m.value,["name",a]);if(i!=null&&i.value!=null&&i.value!=""&&!e.isLetterHeadTemplate)var w=l.length>0?`${i.value}`:`${i.value}`;else var w=l.length>0?`##${a}##`:`##${a}##`;t.deleteText(l.index,l.length),t.insertText(l.index,w)},p=()=>{v.value={},v.value=M(e.users,{xid:e.userId}),T.value=e.appreciation,L()},L=()=>{var a=t.root.innerHTML;g(),N(m.value,(l,i)=>{l.value!=null&&l.value!=""&&(a=a.replaceAll(`##${l.name}##`,l.value))}),r.value=a,s.value!=null&&(t.root.innerHTML=a)},I=a=>{a==""?(t.root.innerHTML=a,t.history.clear()):(t.root.innerHTML="",t.clipboard.dangerouslyPasteHTML(0,a))},y=()=>{e.renderListItem.length>0&&f(e.renderListItem);var a=M(e.letterheadTemplates,{xid:e.letterheadTemplateId});d.value=a&&a.description?a.description:"",s.value!=null&&(t.root.innerHTML=d.value,p())};return V(()=>e.letterheadTemplateId,(a,l)=>{y()}),V(()=>e.userId,(a,l)=>{y()}),{descriptionContent:r,textEditor:s,selectedLetterHeadFields:$,insertFormText:b,setHTML:I,reSetTemplate:y,letterHeadAppreciation:T,activeKey:h}}}),J={ref:"textEditor",class:"quill-editor"};function R(e,c,v,T,g,$){const m=W,d=j,f=x,s=O,r=P,h=Q;return u(),H(k,null,[o(f,{gutter:16},{default:n(()=>[o(d,{xs:24,sm:24,md:24,lg:24},{default:n(()=>[o(m,{label:e.labelTitle!=""?e.labelTitle:e.$t("generate.description"),name:e.descriptionLableTitle,help:e.rules&&e.rules[e.descriptionLableTitle]?e.rules[e.descriptionLableTitle].message:null,validateStatus:e.rules&&e.rules[e.descriptionLableTitle]?"error":null,class:D({required:e.required})},{default:n(()=>[E("div",J,null,512)]),_:1},8,["label","name","help","validateStatus","class"])]),_:1})]),_:1}),o(h,{activeKey:e.activeKey,"onUpdate:activeKey":c[0]||(c[0]=t=>e.activeKey=t)},{default:n(()=>[(u(!0),H(k,null,K(e.selectedLetterHeadFields,(t,b)=>(u(),S(r,{key:"selected_letterhead_field_title_"+b,tab:t.title},{default:n(()=>[o(f,{gutter:16,class:"mb-20"},{default:n(()=>[(u(!0),H(k,null,K(t.values,(p,L)=>(u(),S(d,{xs:24,sm:24,md:24,lg:12,key:"letterhead_field_value_"+L},{default:n(()=>[o(s,{onClick:I=>e.insertFormText(p.name),type:"link",style:{padding:"0px","font-size":"smaller"}},{default:n(()=>[U(z(p.name),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:2},1024)]),_:2},1032,["tab"]))),128))]),_:1},8,["activeKey"])],64)}const ne=q(G,[["render",R]]);export{ne as L};
