@ehfuse/taskbox 0.11.3 → 0.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ use chrome, FireFox or Internet Explorer 11`)}var r=e("safe-buffer"),t=e("random
76
76
 
77
77
  `).trim()}function Oc(e){return jd(e)?qd(e):e}function Lf(e){let d=QG(Nf(e)).trim(),u=qd(d);return u.trim()?/<(?!\/?(p|br|span)(\s|>|\/))[a-z]/i.test(d)||/<span[^>]*style=/i.test(d)?d:u:""}var ZG=new Set(["P","DIV","UL","OL","H1","H2","H3","H4","BLOCKQUOTE","PRE"]);function QG(e){if(typeof DOMParser>"u")return e;let d=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),u=d.body.firstElementChild;if(!u)return e;let l=null;for(let n of Array.from(u.childNodes)){if(n.nodeType===Node.ELEMENT_NODE&&ZG.has(n.tagName)){l=null;continue}l||(l=d.createElement("p"),u.insertBefore(l,n)),l.appendChild(n)}for(let n of Array.from(u.querySelectorAll(":scope > p")))!n.textContent?.replace(/\u00a0/g," ").trim()&&!n.querySelector("br, img")&&n.remove();return u.innerHTML}function xz(e){let d=l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return e.split(`
78
78
  `).map(l=>`<p>${l?d(l):"<br>"}</p>`).join("")}var nl=require("react/jsx-runtime"),JG={left:[["heading"],["bold","italic","strike","underline"],["link","bgcolor","code"],["bulletList","numberList"]],right:[]},zf=(0,Lo.forwardRef)(function({defaultHtml:d="",placeholder:u,alwaysExpanded:l=!1,autoFocus:n=!1,minHeight:a=44,maxHeight:r=280,onChange:t,onSubmit:o,onFiles:c,footer:i,variant:s="bare"},h){let f=(0,Lo.useRef)(null),[m,b]=(0,Lo.useState)(!1),[g,w]=(0,Lo.useState)(()=>!!qd(d).trim()),S=vz(),O=l||m||g;(0,Lo.useImperativeHandle)(h,()=>({getComment:()=>Lf(f.current?.getHtml()??""),clear:()=>{f.current?.setHtml(""),w(!1)},focus:()=>f.current?.focus()})),(0,Lo.useLayoutEffect)(()=>{if(!n)return;let z=requestAnimationFrame(()=>f.current?.focus());return()=>cancelAnimationFrame(z)},[n]);let M=z=>{let P=Array.from(z??[]);return P.length===0||!c?!1:(c(P),!0)};return(0,nl.jsxs)(Hd.Box,{...S.handlers,onKeyDownCapture:z=>{S.handlers.onKeyDownCapture(z),!z.defaultPrevented&&z.key==="Enter"&&(z.ctrlKey||z.metaKey)&&!z.nativeEvent.isComposing&&(z.preventDefault(),z.stopPropagation(),o?.())},onFocusCapture:()=>b(!0),onBlurCapture:z=>{z.currentTarget.contains(z.relatedTarget)||b(!1)},onPasteCapture:z=>{M(z.clipboardData?.files)&&(z.preventDefault(),z.stopPropagation())},onDropCapture:z=>{M(z.dataTransfer?.files)&&(z.preventDefault(),z.stopPropagation())},sx:{position:"relative",bgcolor:"#ffffff",...s==="boxed"?{border:"1px solid",borderColor:m?"primary.main":"#dedddb",boxShadow:m?z=>`0 0 0 1px ${z.palette.primary.main}`:"none",borderRadius:"8px",transition:"border-color 120ms"}:{},"& .ehfuse-editor, & .ehfuse-editor-wrapper, & .ehfuse-editor-container":{border:"none !important",boxShadow:"none !important",borderRadius:0},"& .ehfuse-toolbar":{display:O?void 0:"none !important",background:"transparent",borderBottom:"1px solid #ececea"},"& .ehfuse-editor-content":{maxHeight:r,overflowY:"auto",fontSize:15,lineHeight:1.6},"& .ehfuse-editor-content > p:first-of-type":{mt:0},"& .ehfuse-editor-content > p:last-of-type":{mb:0},"& .ehfuse-editor-content.ehfuse-editor-empty::before":s==="boxed"?{top:"10px",left:"12px"}:{top:"12px",left:"16px"}},children:[(0,nl.jsx)(wz.EhfuseEditor,{ref:f,defaultValue:d||"<p></p>",autoHeight:!0,showToolbar:!0,toolbarOptions:JG,locale:ca(),minHeight:O?Math.max(a,64):a,placeholder:u,contentStyle:{padding:s==="boxed"?"10px 12px":"12px 16px"},onChange:z=>{let P=Lf(z);w(!!P),t?.(P)}}),S.popper,i&&O?(0,nl.jsx)(Hd.Box,{sx:{display:"flex",alignItems:"center",px:1,pb:.75},children:i}):null]})});function Tz({html:e}){let{openExternalUrl:d,mentionCandidates:u}=ot(),l=(0,Lo.useRef)(null),n=Nf(e),a=(u??[]).map(r=>r.name).filter(r=>r.trim().length>=2);return(0,Lo.useLayoutEffect)(()=>{let r=l.current;if(!r)return;r.innerHTML=n;let t=[...new Set(a)].sort((h,f)=>f.length-h.length);if(t.length===0||!n.includes("@"))return;let o=h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`(^|[^A-Za-z0-9._%+-])(@(?:${t.map(o).join("|")}))`,"g"),i=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),s=[];for(;i.nextNode();){let h=i.currentNode;h.data.includes("@")&&!h.parentElement?.closest("a, code")&&s.push(h)}for(let h of s){let f=h.data,m=document.createDocumentFragment(),b=0;for(let g of f.matchAll(c)){let w=(g.index??0)+g[1].length;w>b&&m.append(f.slice(b,w));let S=document.createElement("span");S.className="taskbox-mention",S.textContent=g[2],m.append(S),b=w+g[2].length}b!==0&&(b<f.length&&m.append(f.slice(b)),h.replaceWith(m))}},[n,a.join("|")]),(0,nl.jsx)(Hd.Box,{ref:l,onClickCapture:r=>{let t=r.target?.closest?.("a[href]");t&&(r.preventDefault(),r.stopPropagation(),d?d(t.href):window.open(t.href,"_blank","noopener,noreferrer"))},sx:{fontSize:15,lineHeight:1.6,wordBreak:"break-word","& p":{m:0},"& ul, & ol":{pl:"1.5em",my:.25},"& li > p":{m:0},"& h1, & h2, & h3, & h4":{fontSize:"1.05em",fontWeight:700,m:0},"& blockquote":{m:0,pl:1.5,borderLeft:"3px solid #dedddb",color:"text.secondary"},"& code":{fontFamily:"monospace",fontSize:"0.9em",bgcolor:"#f1f5f9",px:.5,borderRadius:.5},"& pre":{m:0,p:1,bgcolor:"#f1f5f9",borderRadius:1,overflowX:"auto"},"& a[href]":{color:"#2563eb",textDecoration:"none",cursor:"pointer","&:hover":{textDecoration:"underline"}},"& .taskbox-mention":{color:"#2563eb",fontWeight:600}}})}var Pz=require("@ehfuse/mui-confirm-action");var jf=require("@mui/material");var rl=require("react/jsx-runtime"),eU=/https?:\/\/[^\s<>"']+/g;function tU(e){let d=e,u="";for(;;){let l=d.slice(-1);if(l===")"&&(d.match(/\(/g)??[]).length<(d.match(/\)/g)??[]).length){d=d.slice(0,-1),u=l+u;continue}if(".,;:!?]}".includes(l)&&l!==""){d=d.slice(0,-1),u=l+u;continue}break}return[d,u]}var nU=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Ff(e,d,u="m"){let l=[...new Set(d.filter(t=>t.trim().length>=2))].sort((t,o)=>o.length-t.length);if(l.length===0||!e.includes("@"))return[e];let n=new RegExp(`(^|[^A-Za-z0-9._%+-])(@(?:${l.map(nU).join("|")}))`,"g"),a=[],r=0;for(let t of e.matchAll(n)){let o=(t.index??0)+t[1].length;o>r&&a.push(e.slice(r,o)),a.push((0,rl.jsx)(jf.Box,{component:"span",sx:{color:"#2563eb",fontWeight:600},children:t[2]},`${u}-${o}`)),r=o+t[2].length}return r<e.length&&a.push(e.slice(r)),a}function qf({text:e}){let{openExternalUrl:d,mentionCandidates:u}=ot(),l=(u??[]).map(t=>t.name),n=t=>{d?d(t):window.open(t,"_blank","noopener,noreferrer")},a=[],r=0;for(let t of e.matchAll(eU)){let o=t.index??0,[c,i]=tU(t[0]);o>r&&a.push(...Ff(e.slice(r,o),l,`m${r}`)),a.push((0,rl.jsx)(jf.Box,{component:"a",href:c,onClick:s=>{s.preventDefault(),s.stopPropagation(),n(c)},sx:{color:"#2563eb",textDecoration:"underline",wordBreak:"break-all",cursor:"pointer"},children:c},`${o}-${c}`)),i&&a.push(i),r=o+t[0].length}return r<e.length&&a.push(...Ff(e.slice(r),l,`m${r}`)),(0,rl.jsx)(rl.Fragment,{children:a})}Ce();var Ie=require("react/jsx-runtime"),rU=5;function Sz({kind:e,reactions:d,myAccountSeq:u,onToggle:l}){ue();let n=d??[],a=u>0&&n.some(c=>c.account_seq===u),r=e==="like"?I("section.reactLike"):I("section.reactAck"),t=n.length===0?r:(0,Ie.jsx)(Xe.Box,{sx:{whiteSpace:"pre-line",fontSize:12},children:n.map(c=>`${c.name} \xB7 ${c.time}`).join(`
79
- `)}),o=e==="like"?"#e5484d":"#2f80ed";return(0,Ie.jsx)(Xe.Tooltip,{title:t,arrow:!0,enterDelay:300,disableInteractive:!0,slotProps:{transition:{timeout:0}},children:(0,Ie.jsxs)(Xe.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.commentReaction",{label:r}),onClick:l,sx:{color:a?o:"#c9c8c5",p:.5},children:e==="like"?a?(0,Ie.jsx)(Iz.default,{sx:{fontSize:16}}):(0,Ie.jsx)(Bz.default,{sx:{fontSize:16}}):a?(0,Ie.jsx)(Oz.default,{sx:{fontSize:16}}):(0,Ie.jsx)(Az.default,{sx:{fontSize:16}})}),n.length>0?(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:12,color:a?o:"#9a9a97",ml:-.25},children:n.length}):null]})})}function Gf({taskSeq:e,comments:d,currentUserName:u="",myAccountSeq:l=0,avatarSrcByName:n,onUpdate:a,onRemove:r,onToggleReaction:t,onPreview:o,onDownload:c}){ue();let[i,s]=(0,Oo.useState)(null),h=(0,Oo.useRef)(null),[f,m]=(0,Oo.useState)(null),b=Sn(),[g,w]=(0,Oo.useState)(null),S=(p,y)=>{navigator.clipboard.writeText(y).then(()=>{w(p),setTimeout(()=>w(x=>x===p?null:x),1500)})},[O,M]=(0,Oo.useState)(!1),z=Math.max(0,d.length-rU),P=z>0&&!O,D=i?Math.min(i.index,z):z,F=d.map((p,y)=>({comment:p,index:y})).slice(P?D:0),W=Ss(),j=(p,y)=>{if(o){o(p,y&&y.length>1?y:void 0);return}window.open(W(p.uuid??""),"_blank","noopener,noreferrer")},C=p=>{if(c){c(p);return}window.open(W(p.uuid??"",{download:!0}),"_blank","noopener,noreferrer")},B=ot().slots?.avatar,R=Id();return(0,Ie.jsxs)(Xe.Box,{className:"taskbox-comments",sx:{px:2,pb:2,display:"flex",flexDirection:"column",gap:.25},children:[(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[R.showIcon?(0,Ie.jsx)($i,{sx:{fontSize:18,display:"block",color:R.color}}):null,(0,Ie.jsxs)(Xe.Box,{sx:{fontSize:_d,fontWeight:R.fontWeight,color:R.color},children:[I("section.comments"),d.length>0?` (${d.length})`:""]}),z>0&&(!P||D>0)?(0,Ie.jsx)(Xe.Box,{role:"button",tabIndex:0,onClick:()=>M(p=>!p),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),M(y=>!y))},sx:{ml:"auto",flexShrink:0,cursor:"pointer",fontSize:14.5,color:"#5b87d6","&:hover":{textDecoration:"underline"}},children:P?I("section.showOlder",{keepFrom:D}):I("section.hideOlder")}):null]}),d.length===0?(0,Ie.jsx)(Xe.Box,{sx:{mt:1,fontSize:14.5,color:"#9a9a97"},children:I("section.noComments")}):null,(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexDirection:"column",gap:1,mt:1},children:F.map(({comment:p,index:y})=>{let x=!!u&&p.author===u,k=(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:14.5,fontWeight:700,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.author}),T=p.external?(0,Ie.jsx)(Xe.Box,{component:"span",sx:{flexShrink:0,px:.6,fontSize:11.5,fontWeight:500,lineHeight:"18px",color:"#d9730d",bgcolor:"#fdf0e6",borderRadius:"4px",whiteSpace:"nowrap"},children:I("section.merchant")}):null;return(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start","&:hover .taskbox-comment-actions":{opacity:1,pointerEvents:"auto"},"&:not(:last-child)":{borderBottom:"1px dashed #e0dfdc",pb:1}},children:[(()=>{let _=n?.get(p.author)??"";return B?(0,Ie.jsx)(Xe.Box,{sx:{display:"inline-flex",flexShrink:0},children:(0,Ie.jsx)(B,{name:p.author,src:_||void 0,size:44})}):(0,Ie.jsx)(Xe.Box,{sx:{display:"inline-flex",flexShrink:0},children:(0,Ie.jsx)(Ur,{src:_,name:p.author,avatarSx:{width:44,height:44,fontSize:20,borderRadius:"50%",...Gi[0]},iconFontSize:24})})})(),(0,Ie.jsxs)(Xe.Box,{sx:{flex:1,minWidth:0},children:[b?(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0},children:[k,T]}):null,(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0,position:"relative"},children:[b?null:k,b?null:T,(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:12.5,color:"#9a9a97",flexShrink:0,whiteSpace:"nowrap"},children:p.time}),x?(0,Ie.jsx)(Xe.Box,{sx:{ml:"auto"}}):(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.25,ml:"auto",flexShrink:0},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.copyComment"),onClick:()=>S(y,Oc(p.text)),sx:{color:g===y?"#2f9e5b":"#9a9a97",p:.5},children:g===y?(0,Ie.jsx)(Vf.default,{sx:{fontSize:15}}):(0,Ie.jsx)(Wf.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Sz,{kind:"like",reactions:p.likes,myAccountSeq:l,onToggle:()=>t?.(e,y,"like")}),(0,Ie.jsx)(Sz,{kind:"ack",reactions:p.acks,myAccountSeq:l,onToggle:()=>t?.(e,y,"ack")})]}),x?(0,Ie.jsxs)(Xe.Box,{className:"taskbox-comment-actions",sx:{display:"flex",alignItems:"center",gap:.25,position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",pointerEvents:b?"auto":"none",backgroundColor:"var(--taskbox-comment-bg, #fff)",opacity:b?1:0,transition:"opacity 0.15s"},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.copyComment"),onClick:()=>S(y,Oc(p.text)),sx:{color:g===y?"#2f9e5b":"#9a9a97"},children:g===y?(0,Ie.jsx)(Vf.default,{sx:{fontSize:15}}):(0,Ie.jsx)(Wf.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.editComment"),onClick:()=>s({index:y,text:p.text,attachments:[...p.attachments??[]],files:[]}),sx:{color:"#9a9a97"},children:(0,Ie.jsx)(_z.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.deleteComment"),onClick:_=>m({anchorEl:_.currentTarget,index:y}),sx:{color:"#9a9a97"},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:15}})})]}):null]}),i?.index===y?(0,Ie.jsxs)(Xe.Box,{sx:{mt:.5},children:[(0,Ie.jsx)(zf,{defaultHtml:jd(p.text)?p.text:xz(p.text),alwaysExpanded:!0,autoFocus:!0,variant:"boxed",minHeight:56,onChange:_=>s(N=>N&&{...N,text:_})}),(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:.75,mt:.75},children:[i.attachments.map((_,N)=>{let H=()=>s({...i,attachments:i.attachments.filter((V,U)=>U!==N)});return Ac(_.name)&&_.uuid?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:W(_.uuid,{thumb:"md"}),alt:_.name,title:_.name,loading:"lazy",sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:H,sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`kept-${_.uuid}-${N}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:_.name,onDelete:H,sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`kept-${_.uuid??_.name}-${N}`)}),i.files.map((_,N)=>{let H=()=>s({...i,files:i.files.filter((V,U)=>U!==N)});return Ac(_.name)?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:URL.createObjectURL(_),alt:_.name,title:I("section.newFile",{name:_.name}),onLoad:V=>URL.revokeObjectURL(V.target.src),sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"2px solid #2f80ed",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:H,sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`new-${_.name}-${N}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:I("section.newFile",{name:_.name}),onDelete:H,sx:{fontSize:14,height:26,bgcolor:"#eef4ff"}},`new-${_.name}-${N}`)}),(0,Ie.jsx)(Xe.Tooltip,{title:I("section.addAttachment"),arrow:!0,children:(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.addAttachment"),onClick:()=>h.current?.click(),sx:{ml:"auto",color:"#2f80ed"},children:(0,Ie.jsx)(Ez.default,{sx:{fontSize:20}})})})]}),(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:.75,mt:.5},children:[(0,Ie.jsx)(Xe.Button,{size:"small",color:"inherit",onClick:()=>s(null),children:I("common.cancel")}),(0,Ie.jsx)(Xe.Button,{size:"small",variant:"contained",disabled:!i.text.trim()&&i.attachments.length===0&&i.files.length===0,onClick:()=>{a(e,y,i.text,{attachments:i.attachments,files:i.files}),s(null)},children:I("common.save")})]}),(0,Ie.jsx)(Xe.Box,{component:"input",type:"file",multiple:!0,ref:h,sx:{display:"none"},onChange:_=>{let N=Array.from(_.target.files??[]);N.length>0&&s({...i,files:[...i.files,...N].slice(0,10)}),_.target.value=""}})]}):(0,Ie.jsxs)(Xe.Box,{children:[p.text?jd(p.text)?(0,Ie.jsx)(Tz,{html:p.text}):(0,Ie.jsx)(Xe.Box,{sx:{fontSize:15,whiteSpace:"pre-wrap"},children:(0,Ie.jsx)(qf,{text:p.text})}):null,(p.attachments??[]).length>0?(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:.75},children:(p.attachments??[]).map((_,N)=>{let H=!!_.uuid,V=Ac(_.name),U=(p.attachments??[]).filter(G=>!!G.uuid&&Ac(G.name));if(V&&H)return(0,Ie.jsx)(Xe.Box,{component:"img",src:W(_.uuid??"",{thumb:"md"}),alt:_.name,title:I("section.viewLarge",{name:_.name}),loading:"lazy",onClick:()=>j(_,U),sx:{width:96,height:96,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",cursor:"pointer",bgcolor:"#f8fafc"}},`${_.name}-${N}`);let L=Ed(_.name);return(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:`${_.name} (${Rf(_.size)})`,clickable:H,onClick:H?()=>L?j(_):C(_):void 0,title:H?I("section.fileAction",{name:_.name,value:L?I("section.preview"):I("section.download")}):_.name,sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`${_.name}-${N}`)})}):null]})]})]},`${p.time}-${y}`)})}),(0,Ie.jsx)(Pz.ConfirmActionPopper,{open:!!f,anchorEl:f?.anchorEl??null,title:I("section.deleteCommentConfirm"),confirmText:I("common.delete"),onCancel:()=>m(null),onConfirm:()=>{f&&(r(e,f.index),s(null)),m(null)}})]})}function Ac(e){return/\.(png|jpe?g|gif|webp|bmp|svg|heic|heif)$/i.test(String(e??"").trim())}function Uf({onSubmit:e,rows:d=2}){ue();let[u,l]=(0,Oo.useState)(""),n=Df({value:u,setValue:l}),[a,r]=(0,Oo.useState)([]),[t,o]=(0,Oo.useState)(!1),c=(0,Oo.useRef)(null),i=(0,Oo.useRef)(null),h=Sn()||d===1,f=O=>{let M=Array.from(O??[]);M.length!==0&&r(z=>[...z,...M].slice(0,10))},m=(0,Oo.useRef)(null),[b,g]=(0,Oo.useState)(""),w=()=>{let O=h?u.trim():(m.current?.getComment()??"").trim();!O&&a.length===0||(e(O,a.length>0?a:void 0),l(""),m.current?.clear(),g(""),r([]))},S=(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.attachFile"),onClick:()=>c.current?.click(),sx:{color:"#9a9a97"},children:(0,Ie.jsx)(ss.default,{sx:{fontSize:20}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.attachImage"),onClick:()=>i.current?.click(),sx:{color:"#9a9a97"},children:(0,Ie.jsx)(Mz.default,{sx:{fontSize:20}})})]});return(0,Ie.jsxs)(Xe.Box,{children:[a.length>0?(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:1.5,px:2,pt:2},children:a.map((O,M)=>Ac(O.name)?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:URL.createObjectURL(O),alt:O.name,title:O.name,onLoad:z=>URL.revokeObjectURL(z.target.src),sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:()=>r(z=>z.filter((P,D)=>D!==M)),sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`${O.name}-${M}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:`${O.name} (${Rf(O.size)})`,onDelete:()=>r(z=>z.filter((P,D)=>D!==M)),sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`${O.name}-${M}`))}):null,(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative",display:"flex"},onDragOver:O=>{Array.from(O.dataTransfer?.types??[]).includes("Files")&&(O.preventDefault(),o(!0))},onDragLeave:O=>{O.currentTarget.contains(O.relatedTarget)||o(!1)},onDrop:O=>{Array.from(O.dataTransfer?.types??[]).includes("Files")&&(O.preventDefault(),o(!1),f(O.dataTransfer?.files??null))},children:[t?(0,Ie.jsxs)(Xe.Box,{sx:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",gap:.75,borderRadius:1,border:"2px dashed #2f80ed",bgcolor:"rgba(47,128,237,0.08)",color:"#2f80ed",fontSize:14,fontWeight:600,pointerEvents:"none"},children:[(0,Ie.jsx)(ss.default,{sx:{fontSize:18}}),I("section.dropToAttach")]}):null,h?(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Cz.TextField,{value:u,placeholder:I("section.commentPlaceholder"),onChange:O=>l(O.target.value),inputRef:n.inputRef,onSelect:n.onSelectionChange,onKeyDown:O=>{n.onKeyDown(O)},onPaste:O=>{Array.from(O.clipboardData?.files??[]).length!==0&&(O.preventDefault(),f(O.clipboardData.files))},fullWidth:!0,multiline:!0,minRows:h?1:d,maxRows:3,sx:{"& .MuiInputBase-root":{pl:2,pr:h?15:6.5,pb:h?void 0:5,borderRadius:0},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}),n.popper,(0,Ie.jsxs)(Xe.Box,{sx:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:.25},children:[S,(0,Ie.jsx)(Xe.IconButton,{"aria-label":I("section.postComment"),disabled:!u.trim()&&a.length===0,onClick:w,sx:{color:"#2563eb","&.Mui-disabled":{color:"#c9c8c5"}},children:(0,Ie.jsx)(Hf.default,{sx:{fontSize:22}})})]})]}):(0,Ie.jsx)(Xe.Box,{sx:{flex:1,minWidth:0},children:(0,Ie.jsx)(zf,{ref:m,placeholder:I("section.commentPlaceholder"),alwaysExpanded:a.length>0,onChange:g,onSubmit:w,onFiles:O=>r(M=>[...M,...O].slice(0,10)),footer:(0,Ie.jsxs)(Ie.Fragment,{children:[S,(0,Ie.jsx)(Xe.Box,{sx:{flex:1}}),(0,Ie.jsx)(Xe.IconButton,{"aria-label":I("section.postComment"),disabled:!b&&a.length===0,onClick:w,sx:{color:"#2563eb","&.Mui-disabled":{color:"#c9c8c5"}},children:(0,Ie.jsx)(Hf.default,{sx:{fontSize:22}})})]})})})]}),(0,Ie.jsx)(Xe.Box,{component:"input",ref:c,type:"file",multiple:!0,onChange:O=>{f(O.target.files),O.target.value=""},sx:{display:"none"}}),(0,Ie.jsx)(Xe.Box,{component:"input",ref:i,type:"file",accept:"image/*",multiple:!0,onChange:O=>{f(O.target.files),O.target.value=""},sx:{display:"none"}})]})}var il=require("react"),Wn=require("@mui/material"),Hz=v(require("@mui/icons-material/Close"),1),Wz=v(require("@mui/icons-material/ArrowBack"),1),Vz=v(require("@mui/icons-material/ContentCopyOutlined"),1),Gz=v(require("@mui/icons-material/ShareOutlined"),1),Uz=v(require("@mui/icons-material/HistoryOutlined"),1),$z=v(require("@mui/icons-material/Print"),1);var Kz=require("@ehfuse/mui-confirm-action");var Ao=require("@mui/material"),Lz=require("@ehfuse/mui-form-dialog"),zz=require("@ehfuse/overlay-scrollbar");Ce();var Rz=require("react"),Dz=require("@ehfuse/forma");function ol({taskSeq:e,items:d,loading:u,onLoad:l}){let n={activity:(0,Dz.useModal)({modalId:Pt("taskbox-task-activity")})},a=n.activity.isOpen;return(0,Rz.useEffect)(()=>{a&&e>0&&!d&&l?.(e)},[a,e,d,l]),{modals:n,items:d,loading:u,openDialog:()=>n.activity.open()}}var ho=require("react/jsx-runtime"),oU={get created(){return I("activity.created")},get completed(){return I("activity.completed")},get uncompleted(){return I("activity.uncompleted")},get returned(){return I("activity.returned")},get confirm_requested(){return I("activity.confirmRequested")},get acked(){return I("activity.acked")},get claimed(){return I("activity.claimed")},get bug_verified(){return I("activity.bugVerified")},get bug_reopened(){return I("activity.bugReopened")}};function Nz(e){return String(e??"").trim()||I("common.none")}function iU(e){if(e.kind!=="field")return oU[String(e.kind)]??I("activity.changed");let d=String(e.field_label??e.field??"").trim()||I("activity.field"),u=String(e.old_value??"").trim(),l=String(e.new_value??"").trim();return!u&&l?I("activity.fieldSet",{label:d,after:l}):u&&!l?I("activity.fieldCleared",{label:d}):I("activity.fieldChanged",{label:d,value:Nz(u),value2:Nz(l)})}function Mc({controller:e}){ue();let d=Sn(),{items:u,loading:l}=e,n=e.modals.activity,a=(0,ho.jsx)(Ao.Box,{sx:{height:d?"100%":420,minHeight:0},children:(0,ho.jsx)(zz.OverlayScrollbar,{style:{height:"100%"},contentStyle:{minWidth:0},thumb:{width:6},children:(0,ho.jsxs)(Ao.Box,{sx:{px:2,pt:2,display:"flex",flexDirection:"column",gap:1,"&::after":{content:'""',flexShrink:0,height:16}},children:[l&&!u?(0,ho.jsxs)(Ao.Box,{sx:{display:"flex",alignItems:"center",gap:1,color:"#9a9a97",fontSize:14.5},children:[(0,ho.jsx)(Ao.CircularProgress,{size:14,thickness:5,sx:{color:"#9a9a97"}}),I("common.loading")]}):null,u&&u.length===0?(0,ho.jsx)(Ao.Box,{sx:{fontSize:14.5,color:"#9a9a97"},children:I("activity.empty")}):null,(u??[]).map(r=>(0,ho.jsxs)(Ao.Box,{sx:{display:"flex",flexDirection:d?"column":"row",gap:d?.25:1,alignItems:d?"stretch":"baseline",minWidth:0,flexShrink:0,...d?{pb:1,borderBottom:"1px solid #ededeb","&:last-of-type":{borderBottom:"none",pb:0}}:{}},children:[(0,ho.jsx)(Ao.Box,{sx:{flexShrink:0,...d?{}:{width:"10.5em"},whiteSpace:"nowrap",fontSize:13.5,color:"#9a9a97",lineHeight:1.5},children:xo(r.acted_time)}),(0,ho.jsxs)(Ao.Box,{sx:{minWidth:0,fontSize:14.5,color:"#37352f",lineHeight:1.5},children:[(0,ho.jsx)(Ao.Box,{component:"span",sx:{fontWeight:500},children:String(r.actor_name??"").trim()||I("dialog.noName")}),(0,ho.jsx)(Ao.Box,{component:"span",sx:{ml:.5},children:iU(r)})]})]},r.seq))]})})});return(0,ho.jsx)(Lz.FormDialog,{open:n.isOpen,onClose:n.close,maxWidth:"sm",fullScreen:d,mobilePresentation:d?"slide":"dialog",contentPaddingX:0,contentTopPadding:0,contentBottomPadding:0,sectionsPaddingTop:0,sectionContentPaddingTop:0,sx:d?{DialogContent:{pb:0,"& .os-content > div":{height:"100%",boxSizing:"border-box",paddingBottom:0,marginBottom:0},"& .FormSection-content, & .section-content":{height:"100%",paddingBottom:0,marginBottom:0}}}:void 0,title:u&&u.length>0?I("activity.titleWithCount",{count:u.length}):I("activity.title"),locale:Mt(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-task-activity",sections:[{id:"task-activity",showTitle:!1,children:a}],scrollPastLastSection:!1,actions:{showCancelButton:!1,right:(0,ho.jsx)(Ao.Button,{variant:"contained",onClick:n.close,children:I("common.close")})}})}var Wd=require("@ehfuse/alerts");var Fz=e=>e?e.replace(/<(script|style)[\s\S]*?<\/\1>/gi,"").replace(/<br\s*\/?>/gi,`
79
+ `)}),o=e==="like"?"#e5484d":"#2f80ed";return(0,Ie.jsx)(Xe.Tooltip,{title:t,arrow:!0,enterDelay:300,disableInteractive:!0,slotProps:{transition:{timeout:0}},children:(0,Ie.jsxs)(Xe.Box,{sx:{display:"inline-flex",alignItems:"center"},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.commentReaction",{label:r}),onClick:l,sx:{color:a?o:"#c9c8c5",p:.5,"&:hover":{color:a?o:"#787774"}},children:e==="like"?a?(0,Ie.jsx)(Iz.default,{sx:{fontSize:16}}):(0,Ie.jsx)(Bz.default,{sx:{fontSize:16}}):a?(0,Ie.jsx)(Oz.default,{sx:{fontSize:16}}):(0,Ie.jsx)(Az.default,{sx:{fontSize:16}})}),n.length>0?(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:12,color:a?o:"#9a9a97",ml:-.25},children:n.length}):null]})})}function Gf({taskSeq:e,comments:d,currentUserName:u="",myAccountSeq:l=0,avatarSrcByName:n,onUpdate:a,onRemove:r,onToggleReaction:t,onPreview:o,onDownload:c}){ue();let[i,s]=(0,Oo.useState)(null),h=(0,Oo.useRef)(null),[f,m]=(0,Oo.useState)(null),b=Sn(),[g,w]=(0,Oo.useState)(null),S=(p,y)=>{navigator.clipboard.writeText(y).then(()=>{w(p),setTimeout(()=>w(x=>x===p?null:x),1500)})},[O,M]=(0,Oo.useState)(!1),z=Math.max(0,d.length-rU),P=z>0&&!O,D=i?Math.min(i.index,z):z,F=d.map((p,y)=>({comment:p,index:y})).slice(P?D:0),W=Ss(),j=(p,y)=>{if(o){o(p,y&&y.length>1?y:void 0);return}window.open(W(p.uuid??""),"_blank","noopener,noreferrer")},C=p=>{if(c){c(p);return}window.open(W(p.uuid??"",{download:!0}),"_blank","noopener,noreferrer")},B=ot().slots?.avatar,R=Id();return(0,Ie.jsxs)(Xe.Box,{className:"taskbox-comments",sx:{px:2,pb:2,display:"flex",flexDirection:"column",gap:.25},children:[(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[R.showIcon?(0,Ie.jsx)($i,{sx:{fontSize:18,display:"block",color:R.color}}):null,(0,Ie.jsxs)(Xe.Box,{sx:{fontSize:_d,fontWeight:R.fontWeight,color:R.color},children:[I("section.comments"),d.length>0?` (${d.length})`:""]}),z>0&&(!P||D>0)?(0,Ie.jsx)(Xe.Box,{role:"button",tabIndex:0,onClick:()=>M(p=>!p),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),M(y=>!y))},sx:{ml:"auto",flexShrink:0,cursor:"pointer",fontSize:14.5,color:"#5b87d6","&:hover":{textDecoration:"underline"}},children:P?I("section.showOlder",{keepFrom:D}):I("section.hideOlder")}):null]}),d.length===0?(0,Ie.jsx)(Xe.Box,{sx:{mt:1,fontSize:14.5,color:"#9a9a97"},children:I("section.noComments")}):null,(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexDirection:"column",gap:1,mt:1},children:F.map(({comment:p,index:y})=>{let x=!!u&&p.author===u,k=(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:14.5,fontWeight:700,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.author}),T=p.external?(0,Ie.jsx)(Xe.Box,{component:"span",sx:{flexShrink:0,px:.6,fontSize:11.5,fontWeight:500,lineHeight:"18px",color:"#d9730d",bgcolor:"#fdf0e6",borderRadius:"4px",whiteSpace:"nowrap"},children:I("section.merchant")}):null;return(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",gap:1.5,alignItems:"flex-start","&:hover .taskbox-comment-actions":{opacity:1,pointerEvents:"auto"},"&:not(:last-child)":{borderBottom:"1px dashed #e0dfdc",pb:1}},children:[(()=>{let _=n?.get(p.author)??"";return B?(0,Ie.jsx)(Xe.Box,{sx:{display:"inline-flex",flexShrink:0},children:(0,Ie.jsx)(B,{name:p.author,src:_||void 0,size:44})}):(0,Ie.jsx)(Xe.Box,{sx:{display:"inline-flex",flexShrink:0},children:(0,Ie.jsx)(Ur,{src:_,name:p.author,avatarSx:{width:44,height:44,fontSize:20,borderRadius:"50%",...Gi[0]},iconFontSize:24})})})(),(0,Ie.jsxs)(Xe.Box,{sx:{flex:1,minWidth:0},children:[b?(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0},children:[k,T]}):null,(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0,position:"relative"},children:[b?null:k,b?null:T,(0,Ie.jsx)(Xe.Box,{component:"span",sx:{fontSize:12.5,color:"#9a9a97",flexShrink:0,whiteSpace:"nowrap"},children:p.time}),x?(0,Ie.jsx)(Xe.Box,{sx:{ml:"auto"}}):(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",alignItems:"center",gap:.25,ml:"auto",flexShrink:0},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.copyComment"),onClick:()=>S(y,Oc(p.text)),sx:{color:g===y?"#2f9e5b":"#9a9a97",p:.5,"&:hover":{color:"#37352f"}},children:g===y?(0,Ie.jsx)(Vf.default,{sx:{fontSize:15}}):(0,Ie.jsx)(Wf.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Sz,{kind:"like",reactions:p.likes,myAccountSeq:l,onToggle:()=>t?.(e,y,"like")}),(0,Ie.jsx)(Sz,{kind:"ack",reactions:p.acks,myAccountSeq:l,onToggle:()=>t?.(e,y,"ack")})]}),x?(0,Ie.jsxs)(Xe.Box,{className:"taskbox-comment-actions",sx:{display:"flex",alignItems:"center",gap:.25,position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",pointerEvents:b?"auto":"none",backgroundColor:"var(--taskbox-comment-bg, #fff)",opacity:b?1:0,transition:"opacity 0.15s"},children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.copyComment"),onClick:()=>S(y,Oc(p.text)),sx:{color:g===y?"#2f9e5b":"#9a9a97","&:hover":{color:"#37352f"}},children:g===y?(0,Ie.jsx)(Vf.default,{sx:{fontSize:15}}):(0,Ie.jsx)(Wf.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.editComment"),onClick:()=>s({index:y,text:p.text,attachments:[...p.attachments??[]],files:[]}),sx:{color:"#9a9a97","&:hover":{color:"#37352f"}},children:(0,Ie.jsx)(_z.default,{sx:{fontSize:15}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.deleteComment"),onClick:_=>m({anchorEl:_.currentTarget,index:y}),sx:{color:"#9a9a97","&:hover":{color:"#37352f"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:15}})})]}):null]}),i?.index===y?(0,Ie.jsxs)(Xe.Box,{sx:{mt:.5},children:[(0,Ie.jsx)(zf,{defaultHtml:jd(p.text)?p.text:xz(p.text),alwaysExpanded:!0,autoFocus:!0,variant:"boxed",minHeight:56,onChange:_=>s(N=>N&&{...N,text:_})}),(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:.75,mt:.75},children:[i.attachments.map((_,N)=>{let H=()=>s({...i,attachments:i.attachments.filter((V,U)=>U!==N)});return Ac(_.name)&&_.uuid?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:W(_.uuid,{thumb:"md"}),alt:_.name,title:_.name,loading:"lazy",sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:H,sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`kept-${_.uuid}-${N}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:_.name,onDelete:H,sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`kept-${_.uuid??_.name}-${N}`)}),i.files.map((_,N)=>{let H=()=>s({...i,files:i.files.filter((V,U)=>U!==N)});return Ac(_.name)?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:URL.createObjectURL(_),alt:_.name,title:I("section.newFile",{name:_.name}),onLoad:V=>URL.revokeObjectURL(V.target.src),sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"2px solid #2f80ed",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:H,sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`new-${_.name}-${N}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:I("section.newFile",{name:_.name}),onDelete:H,sx:{fontSize:14,height:26,bgcolor:"#eef4ff"}},`new-${_.name}-${N}`)}),(0,Ie.jsx)(Xe.Tooltip,{title:I("section.addAttachment"),arrow:!0,children:(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.addAttachment"),onClick:()=>h.current?.click(),sx:{ml:"auto",color:"#2f80ed"},children:(0,Ie.jsx)(Ez.default,{sx:{fontSize:20}})})})]}),(0,Ie.jsxs)(Xe.Box,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:.75,mt:.5},children:[(0,Ie.jsx)(Xe.Button,{size:"small",color:"inherit",onClick:()=>s(null),children:I("common.cancel")}),(0,Ie.jsx)(Xe.Button,{size:"small",variant:"contained",disabled:!i.text.trim()&&i.attachments.length===0&&i.files.length===0,onClick:()=>{a(e,y,i.text,{attachments:i.attachments,files:i.files}),s(null)},children:I("common.save")})]}),(0,Ie.jsx)(Xe.Box,{component:"input",type:"file",multiple:!0,ref:h,sx:{display:"none"},onChange:_=>{let N=Array.from(_.target.files??[]);N.length>0&&s({...i,files:[...i.files,...N].slice(0,10)}),_.target.value=""}})]}):(0,Ie.jsxs)(Xe.Box,{children:[p.text?jd(p.text)?(0,Ie.jsx)(Tz,{html:p.text}):(0,Ie.jsx)(Xe.Box,{sx:{fontSize:15,whiteSpace:"pre-wrap"},children:(0,Ie.jsx)(qf,{text:p.text})}):null,(p.attachments??[]).length>0?(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:.75},children:(p.attachments??[]).map((_,N)=>{let H=!!_.uuid,V=Ac(_.name),U=(p.attachments??[]).filter(G=>!!G.uuid&&Ac(G.name));if(V&&H)return(0,Ie.jsx)(Xe.Box,{component:"img",src:W(_.uuid??"",{thumb:"md"}),alt:_.name,title:I("section.viewLarge",{name:_.name}),loading:"lazy",onClick:()=>j(_,U),sx:{width:96,height:96,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",cursor:"pointer",bgcolor:"#f8fafc"}},`${_.name}-${N}`);let L=Ed(_.name);return(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:`${_.name} (${Rf(_.size)})`,clickable:H,onClick:H?()=>L?j(_):C(_):void 0,title:H?I("section.fileAction",{name:_.name,value:L?I("section.preview"):I("section.download")}):_.name,sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`${_.name}-${N}`)})}):null]})]})]},`${p.time}-${y}`)})}),(0,Ie.jsx)(Pz.ConfirmActionPopper,{open:!!f,anchorEl:f?.anchorEl??null,title:I("section.deleteCommentConfirm"),confirmText:I("common.delete"),onCancel:()=>m(null),onConfirm:()=>{f&&(r(e,f.index),s(null)),m(null)}})]})}function Ac(e){return/\.(png|jpe?g|gif|webp|bmp|svg|heic|heif)$/i.test(String(e??"").trim())}function Uf({onSubmit:e,rows:d=2}){ue();let[u,l]=(0,Oo.useState)(""),n=Df({value:u,setValue:l}),[a,r]=(0,Oo.useState)([]),[t,o]=(0,Oo.useState)(!1),c=(0,Oo.useRef)(null),i=(0,Oo.useRef)(null),h=Sn()||d===1,f=O=>{let M=Array.from(O??[]);M.length!==0&&r(z=>[...z,...M].slice(0,10))},m=(0,Oo.useRef)(null),[b,g]=(0,Oo.useState)(""),w=()=>{let O=h?u.trim():(m.current?.getComment()??"").trim();!O&&a.length===0||(e(O,a.length>0?a:void 0),l(""),m.current?.clear(),g(""),r([]))},S=(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.attachFile"),onClick:()=>c.current?.click(),sx:{color:"#9a9a97","&:hover":{color:"#37352f"}},children:(0,Ie.jsx)(ss.default,{sx:{fontSize:20}})}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.attachImage"),onClick:()=>i.current?.click(),sx:{color:"#9a9a97","&:hover":{color:"#37352f"}},children:(0,Ie.jsx)(Mz.default,{sx:{fontSize:20}})})]});return(0,Ie.jsxs)(Xe.Box,{children:[a.length>0?(0,Ie.jsx)(Xe.Box,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:1.5,px:2,pt:2},children:a.map((O,M)=>Ac(O.name)?(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative"},children:[(0,Ie.jsx)(Xe.Box,{component:"img",src:URL.createObjectURL(O),alt:O.name,title:O.name,onLoad:z=>URL.revokeObjectURL(z.target.src),sx:{width:72,height:72,objectFit:"cover",borderRadius:1,border:"1px solid #e6e6e3",display:"block"}}),(0,Ie.jsx)(Xe.IconButton,{size:"small","aria-label":I("section.removeAttachment"),onClick:()=>r(z=>z.filter((P,D)=>D!==M)),sx:{position:"absolute",top:-6,right:-6,p:.25,bgcolor:"#ffffff",border:"1px solid #e6e6e3","&:hover":{bgcolor:"#f1f5f9"}},children:(0,Ie.jsx)(Ec.default,{sx:{fontSize:14}})})]},`${O.name}-${M}`):(0,Ie.jsx)(Xe.Chip,{size:"small",icon:(0,Ie.jsx)(ss.default,{sx:{fontSize:14}}),label:`${O.name} (${Rf(O.size)})`,onDelete:()=>r(z=>z.filter((P,D)=>D!==M)),sx:{fontSize:14,height:26,bgcolor:"#f1f5f9"}},`${O.name}-${M}`))}):null,(0,Ie.jsxs)(Xe.Box,{sx:{position:"relative",display:"flex"},onDragOver:O=>{Array.from(O.dataTransfer?.types??[]).includes("Files")&&(O.preventDefault(),o(!0))},onDragLeave:O=>{O.currentTarget.contains(O.relatedTarget)||o(!1)},onDrop:O=>{Array.from(O.dataTransfer?.types??[]).includes("Files")&&(O.preventDefault(),o(!1),f(O.dataTransfer?.files??null))},children:[t?(0,Ie.jsxs)(Xe.Box,{sx:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",gap:.75,borderRadius:1,border:"2px dashed #2f80ed",bgcolor:"rgba(47,128,237,0.08)",color:"#2f80ed",fontSize:14,fontWeight:600,pointerEvents:"none"},children:[(0,Ie.jsx)(ss.default,{sx:{fontSize:18}}),I("section.dropToAttach")]}):null,h?(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Cz.TextField,{value:u,placeholder:I("section.commentPlaceholder"),onChange:O=>l(O.target.value),inputRef:n.inputRef,onSelect:n.onSelectionChange,onKeyDown:O=>{n.onKeyDown(O)},onPaste:O=>{Array.from(O.clipboardData?.files??[]).length!==0&&(O.preventDefault(),f(O.clipboardData.files))},fullWidth:!0,multiline:!0,minRows:h?1:d,maxRows:3,sx:{"& .MuiInputBase-root":{pl:2,pr:h?15:6.5,pb:h?void 0:5,borderRadius:0},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}),n.popper,(0,Ie.jsxs)(Xe.Box,{sx:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:.25},children:[S,(0,Ie.jsx)(Xe.IconButton,{"aria-label":I("section.postComment"),disabled:!u.trim()&&a.length===0,onClick:w,sx:{color:"#2563eb","&.Mui-disabled":{color:"#c9c8c5"}},children:(0,Ie.jsx)(Hf.default,{sx:{fontSize:22}})})]})]}):(0,Ie.jsx)(Xe.Box,{sx:{flex:1,minWidth:0},children:(0,Ie.jsx)(zf,{ref:m,placeholder:I("section.commentPlaceholder"),alwaysExpanded:a.length>0,onChange:g,onSubmit:w,onFiles:O=>r(M=>[...M,...O].slice(0,10)),footer:(0,Ie.jsxs)(Ie.Fragment,{children:[S,(0,Ie.jsx)(Xe.Box,{sx:{flex:1}}),(0,Ie.jsx)(Xe.IconButton,{"aria-label":I("section.postComment"),disabled:!b&&a.length===0,onClick:w,sx:{color:"#2563eb","&.Mui-disabled":{color:"#c9c8c5"}},children:(0,Ie.jsx)(Hf.default,{sx:{fontSize:22}})})]})})})]}),(0,Ie.jsx)(Xe.Box,{component:"input",ref:c,type:"file",multiple:!0,onChange:O=>{f(O.target.files),O.target.value=""},sx:{display:"none"}}),(0,Ie.jsx)(Xe.Box,{component:"input",ref:i,type:"file",accept:"image/*",multiple:!0,onChange:O=>{f(O.target.files),O.target.value=""},sx:{display:"none"}})]})}var il=require("react"),Wn=require("@mui/material"),Hz=v(require("@mui/icons-material/Close"),1),Wz=v(require("@mui/icons-material/ArrowBack"),1),Vz=v(require("@mui/icons-material/ContentCopyOutlined"),1),Gz=v(require("@mui/icons-material/ShareOutlined"),1),Uz=v(require("@mui/icons-material/HistoryOutlined"),1),$z=v(require("@mui/icons-material/Print"),1);var Kz=require("@ehfuse/mui-confirm-action");var Ao=require("@mui/material"),Lz=require("@ehfuse/mui-form-dialog"),zz=require("@ehfuse/overlay-scrollbar");Ce();var Rz=require("react"),Dz=require("@ehfuse/forma");function ol({taskSeq:e,items:d,loading:u,onLoad:l}){let n={activity:(0,Dz.useModal)({modalId:Pt("taskbox-task-activity")})},a=n.activity.isOpen;return(0,Rz.useEffect)(()=>{a&&e>0&&!d&&l?.(e)},[a,e,d,l]),{modals:n,items:d,loading:u,openDialog:()=>n.activity.open()}}var ho=require("react/jsx-runtime"),oU={get created(){return I("activity.created")},get completed(){return I("activity.completed")},get uncompleted(){return I("activity.uncompleted")},get returned(){return I("activity.returned")},get confirm_requested(){return I("activity.confirmRequested")},get acked(){return I("activity.acked")},get claimed(){return I("activity.claimed")},get bug_verified(){return I("activity.bugVerified")},get bug_reopened(){return I("activity.bugReopened")}};function Nz(e){return String(e??"").trim()||I("common.none")}function iU(e){if(e.kind!=="field")return oU[String(e.kind)]??I("activity.changed");let d=String(e.field_label??e.field??"").trim()||I("activity.field"),u=String(e.old_value??"").trim(),l=String(e.new_value??"").trim();return!u&&l?I("activity.fieldSet",{label:d,after:l}):u&&!l?I("activity.fieldCleared",{label:d}):I("activity.fieldChanged",{label:d,value:Nz(u),value2:Nz(l)})}function Mc({controller:e}){ue();let d=Sn(),{items:u,loading:l}=e,n=e.modals.activity,a=(0,ho.jsx)(Ao.Box,{sx:{height:d?"100%":420,minHeight:0},children:(0,ho.jsx)(zz.OverlayScrollbar,{style:{height:"100%"},contentStyle:{minWidth:0},thumb:{width:6},children:(0,ho.jsxs)(Ao.Box,{sx:{px:2,pt:2,display:"flex",flexDirection:"column",gap:1,"&::after":{content:'""',flexShrink:0,height:16}},children:[l&&!u?(0,ho.jsxs)(Ao.Box,{sx:{display:"flex",alignItems:"center",gap:1,color:"#9a9a97",fontSize:14.5},children:[(0,ho.jsx)(Ao.CircularProgress,{size:14,thickness:5,sx:{color:"#9a9a97"}}),I("common.loading")]}):null,u&&u.length===0?(0,ho.jsx)(Ao.Box,{sx:{fontSize:14.5,color:"#9a9a97"},children:I("activity.empty")}):null,(u??[]).map(r=>(0,ho.jsxs)(Ao.Box,{sx:{display:"flex",flexDirection:d?"column":"row",gap:d?.25:1,alignItems:d?"stretch":"baseline",minWidth:0,flexShrink:0,...d?{pb:1,borderBottom:"1px solid #ededeb","&:last-of-type":{borderBottom:"none",pb:0}}:{}},children:[(0,ho.jsx)(Ao.Box,{sx:{flexShrink:0,...d?{}:{width:"10.5em"},whiteSpace:"nowrap",fontSize:13.5,color:"#9a9a97",lineHeight:1.5},children:xo(r.acted_time)}),(0,ho.jsxs)(Ao.Box,{sx:{minWidth:0,fontSize:14.5,color:"#37352f",lineHeight:1.5},children:[(0,ho.jsx)(Ao.Box,{component:"span",sx:{fontWeight:500},children:String(r.actor_name??"").trim()||I("dialog.noName")}),(0,ho.jsx)(Ao.Box,{component:"span",sx:{ml:.5},children:iU(r)})]})]},r.seq))]})})});return(0,ho.jsx)(Lz.FormDialog,{open:n.isOpen,onClose:n.close,maxWidth:"sm",fullScreen:d,mobilePresentation:d?"slide":"dialog",contentPaddingX:0,contentTopPadding:0,contentBottomPadding:0,sectionsPaddingTop:0,sectionContentPaddingTop:0,sx:d?{DialogContent:{pb:0,"& .os-content > div":{height:"100%",boxSizing:"border-box",paddingBottom:0,marginBottom:0},"& .FormSection-content, & .section-content":{height:"100%",paddingBottom:0,marginBottom:0}}}:void 0,title:u&&u.length>0?I("activity.titleWithCount",{count:u.length}):I("activity.title"),locale:Mt(),tabs:{visible:!1},titleIcons:{delete:{visible:!1}},fontScale:{enabled:!0},fontScaleKey:"taskbox-task-activity",sections:[{id:"task-activity",showTitle:!1,children:a}],scrollPastLastSection:!1,actions:{showCancelButton:!1,right:(0,ho.jsx)(Ao.Button,{variant:"contained",onClick:n.close,children:I("common.close")})}})}var Wd=require("@ehfuse/alerts");var Fz=e=>e?e.replace(/<(script|style)[\s\S]*?<\/\1>/gi,"").replace(/<br\s*\/?>/gi,`
80
80
  `).replace(/<\/(p|div|li|h[1-6]|tr)>/gi,`
81
81
  `).replace(/<[^>]+>/g,"").replace(/&nbsp;/gi," ").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,'"').replace(/&#39;/gi,"'").replace(/&amp;/gi,"&").replace(/\n{3,}/g,`
82
82