PageSourceSearch

https://petwellhk.com/assets/Forum-qaUEpz2E.js

js petwellhk.com collected 2026-10-06 05:22:46 UTC 83,029 bytes, 62 lines download raw bytes

1import{r as n,j as e,n as Cs,q as na,p as ia}from"./react-vendor-BDHNqS4B.js";import{S as Ps,b as oa}from"./Header-BkbupWq-.js";import{S as jt}from"./skeleton-CDto_fTL.js";import{c as he,u as ye,B as z,L as Be,I as Kt,e as Ls,h as Is,i as Rs,D as st,j as We,k as rt,l as qe,m as la,X as it,n as ot,o as Es,p as at,q as Zt,r as ca,a as nt,t as Qt,s as Se,v as As,w as Yt,x as be,d as da,y as $t,z as ua,C as bs,E as ma,F as ys,G as ha,H as ga,J as fa,K as pa,g as Mt,M as Ut,N as Vt,V as Ht,O as xa,P as ka,Q as ba,R as ya,S as ja,T as va}from"./main-m_sUF2N4.js";import{T as Ts}from"./textarea-D7qsgB_p.js";import{P as Ot,a as Bt,b as Wt}from"./popover-D22i846k.js";import{T as vt,G as wa}from"./type-CVgQCqWZ.js";import{I as js}from"./image-BPGTiTmb.js";import{u as Na}from"./useSEO-CoArDrdl.js";import{u as Sa}from"./useSearchQueryFromUrl-jHjzcbFS.js";import{S as Ca,a as Pa,b as La,c as Ia,d as Ra}from"./select-fZgDq8v8.js";import{C as qt}from"./checkbox-BkyFxaQM.js";import{I as Fs}from"./image-plus--WXlfpIC.js";import{L as Ea}from"./lock-CHPI1fFl.js";import{v as _s}from"./amplify-DYDcjoow.js";import{F as zs}from"./flame-HVLv3H1b.js";import{M as Ds}from"./message-circle-B5m25ymx.js";import{H as es}from"./heart-DRwCktcb.js";import{S as Xt}from"./share-2-CCPUIaWa.js";import{S as $s}from"./search-BSw3vufk.js";import{C as Aa}from"./chevron-left-Jw0Ezjn9.js";import{P as Ta}from"./plus-D0NAkfqS.js";import{T as Fa}from"./triangle-alert-1QSShUG6.js";import"./chevron-right-CpkQxGj-.js";import"./check-DS0-tR9o.js";import"./tag-D40gy_Nl.js";import"./query-7-WHkg5t.js";import"./index-CFf87M6S.js";import"./chevron-up-Cb9C18fB.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const _a=he("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const za=he("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Da=he("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const $a=he("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
22 * @license lucide-react v0.462.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Ma=he("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
27 * @license lucide-react v0.462.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const Ua=he("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
32 * @license lucide-react v0.462.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Va=he("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
37 * @license lucide-react v0.462.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Gt=he("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}
41],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
42 * @license lucide-react v0.462.0 - ISC
43 *
44 * This source code is licensed under the ISC license.
45 * See the LICENSE file in the root directory of this source tree.
46 */const Ha=he("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
47 * @license lucide-react v0.462.0 - ISC
48 *
49 * This source code is licensed under the ISC license.
50 * See the LICENSE file in the root directory of this source tree.
51 */const Oa=he("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/**
52 * @license lucide-react v0.462.0 - ISC
53 *
54 * This source code is licensed under the ISC license.
55 * See the LICENSE file in the root directory of this source tree.
56 */const Ba=he("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]),Jt=({value:l,onChange:s,placeholder:p,disabled:g,rows:x=8,maxLength:C,onImageSelect:N,imagePreviews:v=[],onRemoveImage:h})=>{const{t:S}=ye(),U=n.useRef(null),W=n.useRef(null),[$,V]=n.useState(!1),[te,R]=n.useState(!1),[Z,ee]=n.useState(!1),[H,r]=n.useState(""),[E,se]=n.useState(""),[F,Y]=n.useState(!1),[K,ae]=n.useState(!1),je=[{name:"Black",value:"#000000"},{name:"Red",value:"#FF0000"},{name:"Green",value:"#008000"},{name:"Blue",value:"#0000FF"},{name:"Orange",value:"#FF902A"},{name:"Purple",value:"#800080"},{name:"Brown",value:"#A52A2A"},{name:"Gray",value:"#808080"}],Ce=()=>{const m=U.current;if(!m)return{start:0,end:0,text:""};const J=m.selectionStart,_=m.selectionEnd,L=l.substring(J,_);return{start:J,end:_,text:L}},A=n.useCallback((m,J)=>{const _=U.current;if(!_||g)return;const{start:L,end:q,text:pe}=Ce(),ie=l.substring(0,L),Q=l.substring(q),O=pe||"",D=ie+m+O+J+Q;s(D),setTimeout(()=>{const X=L+m.length+O.length+J.length;_.focus(),_.setSelectionRange(X,X)},0)},[l,s,g]),ge=n.useCallback(m=>{A(`[color=${m}]`,"[/color]"),V(!1)},[A]),Pe=n.useCallback(m=>{A(`[${m}]`,`[/${m}]`),R(!1)},[A]),De=n.useCallback(()=>{if(!E.trim())return;const m=E.trim().startsWith("http")?E.trim():`https://${E.trim()}`;H.trim(),A(`[url=${m}]`,"[/url]"),r(""),se(""),ee(!1)},[E,H,A]),fe=n.useCallback(m=>{const _=Array.from(m).filter(L=>L.type.startsWith("image/"));_.length>0&&N&&N(_),Y(!1)},[N]),$e=n.useCallback(m=>{m.preventDefault(),m.stopPropagation(),ae(!0)},[]),Ae=n.useCallback(m=>{m.preventDefault(),m.stopPropagation(),ae(!1)},[]),Te=n.useCallback(m=>{m.preventDefault(),m.stopPropagation(),ae(!1),m.dataTransfer.files&&m.dataTransfer.files.length>0&&fe(m.dataTransfer.files)},[fe]),P=n.useCallback(m=>{m.target.files&&m.target.files.length>0&&fe(m.target.files)},[fe]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-1.5 border border-border rounded-md bg-muted/30",children:[e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[b]","[/b]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.bold"),children:e.jsx($a,{className:"h-3.5 w-3.5"})}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[u]","[/u]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.underline"),children:e.jsx(Ba,{className:"h-3.5 w-3.5"})}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[s]","[/s]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.strikethrough"),children:e.jsx(Oa,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-0.5"}),e.jsxs(Ot,{open:te,onOpenChange:R,children:[e.jsx(Bt,{asChild:!0,children:e.jsx(z,{type:"button",variant:"ghost",size:"sm",disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.fontSize"),children:e.jsx(vt,{className:"h-3.5 w-3.5"})})}),e.jsx(Wt,{className:"w-40 p-2",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Pe("small"),className:"w-full justify-start h-8 text-xs",children:[e.jsx(vt,{className:"h-3 w-3 mr-2"}),S("forum.createPost.editor.small")]}),e.jsxs(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Pe("medium"),className:"w-full justify-start h-8 text-xs",children:[e.jsx(vt,{className:"h-4 w-4 mr-2"}),S("forum.createPost.editor.medium")]}),e.jsxs(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>Pe("large"),className:"w-full justify-start h-8 text-xs",children:[e.jsx(vt,{className:"h-5 w-5 mr-2"}),S("forum.createPost.editor.large")]})]})})]}),e.jsxs(Ot,{open:$,onOpenChange:V,children:[e.jsx(Bt,{asChild:!0,children:e.jsx(z,{type:"button",variant:"ghost",size:"sm",disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.textColor"),children:e.jsx(Va,{className:"h-3.5 w-3.5"})})}),e.jsx(Wt,{className:"w-52 p-2",children:e.jsx("div",{className:"space-y-2",children:e.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:je.map(m=>e.jsx("button",{type:"button",onClick:()=>ge(m.value),className:"h-8 w-full rounded border border-border hover:border-[#FF902A] transition-all",style:{backgroundColor:m.value},title:m.name},m.value))})})})]}),e.jsxs(Ot,{open:Z,onOpenChange:ee,children:[e.jsx(Bt,{asChild:!0,children:e.jsx(z,{type:"button",variant:"ghost",size:"sm",disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.insertLink"),children:e.jsx(Ua,{className:"h-3.5 w-3.5"})})}),e.jsx(Wt,{className:"w-80 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{htmlFor:"urlLink",className:"text-xs",children:S("forum.createPost.editor.urlLabel")}),e.jsx(Kt,{id:"urlLink",type:"text",value:E,onChange:m=>se(m.target.value),placeholder:S("forum.createPost.editor.urlPlaceholder"),className:"h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Be,{htmlFor:"urlText",className:"text-xs",children:S("forum.createPost.editor.linkTextLabel")}),e.jsx(Kt,{id:"urlText",type:"text",value:H,onChange:m=>r(m.target.value),placeholder:S("forum.createPost.editor.linkTextPlaceholder"),className:"h-8"})]}),e.jsx(z,{type:"button",onClick:De,disabled:!E.trim(),className:"w-full",size:"sm",children:S("forum.createPost.editor.insertLink")})]})})]}),e.jsx("div",{className:"w-px h-5 bg-border mx-0.5"}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>{W.current?W.current.click():Y(!0)},disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.insertImage")||"Insert Image",children:e.jsx(js,{className:"h-3.5 w-3.5"})}),e.jsx("input",{ref:W,type:"file",accept:"image/*",multiple:!0,onChange:P,className:"hidden"}),e.jsx("div",{className:"w-px h-5 bg-border mx-0.5"}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[left]","[/left]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.alignLeft"),children:e.jsx(za,{className:"h-3.5 w-3.5"})}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[center]","[/center]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.alignCenter"),children:e.jsx(_a,{className:"h-3.5 w-3.5"})}),e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:()=>A("[right]","[/right]"),disabled:g,className:"h-7 w-7 p-0",title:S("forum.createPost.editor.alignRight"),children:e.jsx(Da,{className:"h-3.5 w-3.5"})})]}),v.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 p-2 border border-border rounded-md bg-muted/30",children:v.map(m=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:m.preview,alt:"Preview",className:"h-20 w-20 object-cover rounded border border-border"}),e.jsx("button",{type:"button",onClick:()=>h==null?void 0:h(m.id),className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity text-xs",title:"Remove image",children:"×"})]},m.id))}),F&&e.jsx("div",{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 ${K?"bg-black/70":""}`,onDragOver:$e,onDragLeave:Ae,onDrop:Te,onClick:()=>Y(!1),children:e.jsxs("div",{className:`bg-card border border-border rounded-lg p-8 max-w-md w-full mx-4 ${K?"border-[#FF902A] border-2":""}`,onClick:m=>m.stopPropagation(),children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:S("forum.createPost.editor.uploadImage")||"Upload Image"}),e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center ${K?"border-[#FF902A] bg-[#FF902A]/10":"border-border hover:border-[#FF902A]/50"} transition-colors cursor-pointer`,onClick:()=>{var m;return(m=W.current)==null?void 0:m.click()},children:[e.jsx(js,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:K?S("forum.createPost.editor.dropImage")||"Drop image here":S("forum.createPost.editor.dragOrClick")||"Drag and drop image here, or click to select"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S("forum.createPost.editor.imageFormats")||"Supports: JPG, PNG, GIF, WebP"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx(z,{type:"button",variant:"outline",onClick:()=>Y(!1),className:"flex-1",children:S("forum.createPost.editor.cancel")||"Cancel"}),e.jsx(z,{type:"button",onClick:()=>{var m;return(m=W.current)==null?void 0:m.click()},className:"flex-1 bg-[#FF902A] hover:bg-[#FF7A1A]",children:S("forum.createPost.editor.selectFile")||"Select File"})]})]})}
56),e.jsx(Ts,{ref:U,value:l,onChange:m=>s(m.target.value),placeholder:p,disabled:g,rows:x,maxLength:C,className:"resize-none text-sm leading-relaxed",style:{fontFamily:'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", emoji, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif'}})]})},Wa=({open:l,onOpenChange:s,onPostCreated:p,mode:g="post"})=>{const{t:x,i18n:C}=ye(),N=Cs(),{isAuthenticated:v,userInfo:h}=Ls(),{openPanel:S}=Is(),[U,W]=n.useState(""),[$,V]=n.useState(""),[te,R]=n.useState(g==="ask-vet"?"HEALTH":"DOG"),[Z,ee]=n.useState(!1),[H,r]=n.useState("PUBLIC"),[E,se]=n.useState(!1),[F,Y]=n.useState(!1),[K,ae]=n.useState(null),[je,Ce]=n.useState(null),[A,ge]=n.useState([]);n.useEffect(()=>{l&&(R(g==="ask-vet"?"HEALTH":"DOG"),r("PUBLIC"),se(!1))},[l,g]),n.useEffect(()=>{l&&v===!1&&(s(!1),S("LANDING"))},[l,v,s,S]);const Pe=Rs(C.language),De=n.useCallback(P=>{const m=P.map(L=>({id:`${Date.now()}-${Math.random()}`,file:L,preview:URL.createObjectURL(L)}));if(ge(L=>[...L,...m]),g==="ask-vet")return;const J=C.language==="zh"?"[圖片]":"[Image]",_=m.map(()=>J).join(" ");V(L=>{const q=document.querySelector("textarea");if(q){const pe=q.selectionStart,ie=q.selectionEnd,Q=L.substring(0,pe),O=L.substring(ie),D=(Q&&!Q.endsWith(" ")&&!Q.endsWith(`
57`)?" ":"")+_+(O&&!O.startsWith(" ")&&!O.startsWith(`
58`)?" ":"");return Q+D+O}return L+(L&&!L.endsWith(" ")?" ":"")+_})},[C.language,g]),fe=n.useCallback(P=>{ge(m=>{const J=m.find(q=>q.id===P);J&&URL.revokeObjectURL(J.preview);const _=m.filter(q=>q.id!==P);if(g==="ask-vet")return _;const L=C.language==="zh"?"[圖片]":"[Image]";return V(q=>{const pe=m.findIndex(D=>D.id===P);if(pe===-1)return q;let ie=0,Q=0;for(let D=0;D<pe;D++){const X=q.indexOf(L,Q);if(X!==-1)ie++,Q=X+L.length;else break}let O=0;for(let D=0;D<=ie;D++){const X=q.indexOf(L,O);if(X!==-1&&D===ie)return q.substring(0,X)+q.substring(X+L.length).replace(/^\s+/,"");if(X!==-1)O=X+L.length;else break}return q}),_})},[C.language,g]);n.useEffect(()=>()=>{A.forEach(P=>{URL.revokeObjectURL(P.preview)})},[A]);const $e=async P=>{if(P.preventDefault(),v!==!0||!(h!=null&&h.userId)||!(h!=null&&h.email)){ae(x("auth.loginRequired")||"Please log in to create a post"),s(!1),S("LANDING");return}if(g==="ask-vet"&&!$.trim()){ae(x("forum.askVet.questionRequired"));return}if(g==="ask-vet"&&!E){ae(x("forum.askVet.disclaimerRequired"));return}ae(null),Ce(null),Y(!0);try{const m=[],J=[];if(!h.email||h.email.trim()==="")throw new Error(x("auth.emailRequired")||"Email is required to create a post");const _=await at(h.email,h.email);if(!_)throw new Error(x("forum.createPost.error")||"Failed to get user information");let L=$.trim();if(A.length>0){const Q=Date.now(),O=C.language==="zh"?"[圖片]":"[Image]",D=A.map(async(le,de)=>{try{const Me=le.file.name.split(".").pop()||"jpg",lt=`forum-images/${Q}-${_}-${de}.${Me}`;return await _s({key:lt,data:le.file,options:{contentType:le.file.type,accessLevel:"guest"}}).result,{url:Zt(lt)}}catch(Me){throw console.error("Error uploading image:",Me),new Error(`Failed to upload image: ${le.file.name}`)}}),X=await Promise.all(D);let oe=0;X.forEach(({url:le})=>{const de=L.indexOf(O,oe);de!==-1?(L=L.substring(0,de)+`[img]${le}[/img]`+L.substring(de+O.length),oe=de+`[img]${le}[/img]`.length):L=`${L}${L?`
59`:""}[img]${le}[/img]`})}const pe={title:g==="ask-vet"?(U.trim()||$.trim().split(`
60`).find(Q=>Q.trim())||x("forum.askVet.composeTitle")).slice(0,80):U.trim(),content:L,authorId:_,category:te||(g==="ask-vet"?"HEALTH":"DOG"),tags:m.length>0?m:void 0,tagIds:J.length>
600?J:void 0,location:void 0,isAnonymous:Z,asksVet:g==="ask-vet",visibility:g==="ask-vet"?H:"PUBLIC",acceptedVetDisclaimer:g==="ask-vet"?E:void 0},ie=await ca(pe);if("pendingReview"in ie){W(""),V(""),R("DOG"),ee(!1),r("PUBLIC"),se(!1),A.forEach(Q=>{URL.revokeObjectURL(Q.preview)}),ge([]),ae(null),Ce(C.language==="zh"?"系統偵測到內容可能包含敏感字眼。內容已提交人工審核,通過前不會公開顯示。":"We detected potentially sensitive wording. Your content has been submitted for manual review and will not be public until approved.");return}W(""),V(""),R("DOG"),ee(!1),r("PUBLIC"),se(!1),ae(null),Ce(null),A.forEach(Q=>{URL.revokeObjectURL(Q.preview)}),ge([]),s(!1),p&&p(),N(`/forum/${ie.id}`)}catch(m){console.error("Error creating post:",m),ae(m instanceof Error?m.message:x("forum.createPost.error"))}finally{Y(!1)}},Ae=()=>{F||(W(""),V(""),R("DOG"),ee(!1),r("PUBLIC"),se(!1),ae(null),Ce(null),A.forEach(P=>{URL.revokeObjectURL(P.preview)}),ge([]),s(!1))};if(v!==!0||!(h!=null&&h.userId))return null;const Te=!!$.trim()&&E;return e.jsx(st,{open:l,onOpenChange:Ae,children:g==="ask-vet"?e.jsxs(We,{className:"ask-vet-dialog sm:max-w-md",children:[e.jsxs(rt,{children:[e.jsx(qe,{children:x("forum.askVet.composeTitle")}),e.jsx(la,{children:x("forum.askVet.composeSubtitle")})]}),e.jsxs("form",{onSubmit:$e,className:"ask-vet-form",children:[K?e.jsx("div",{className:"bg-destructive/10 text-destructive text-sm p-3 rounded-md border border-destructive/20",children:K}):null,je?e.jsx("div",{className:"bg-amber-50 text-amber-900 text-sm p-3 rounded-md border border-amber-200",children:je}):null,e.jsx(Ts,{id:"ask-vet-content",value:$,onChange:P=>V(P.target.value),placeholder:x("forum.askVet.contentPlaceholder"),rows:6,maxLength:1e4,disabled:F,autoFocus:!0}),e.jsxs("div",{className:"ask-vet-photos",children:[A.map(P=>e.jsxs("div",{className:"ask-vet-photo",children:[e.jsx("img",{src:P.preview,alt:""}),e.jsx("button",{type:"button",onClick:()=>fe(P.id),disabled:F,"aria-label":x("common.cancel"),children:e.jsx(it,{})})]},P.id)),e.jsxs("label",{className:"ask-vet-photo-add",children:[e.jsx(Fs,{}),e.jsx("span",{children:x("forum.askVet.addPhoto")}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,hidden:!0,disabled:F,onChange:P=>{const m=Array.from(P.target.files||[]);m.length&&De(m),P.target.value=""}})]})]}),e.jsxs("div",{className:"ask-vet-toggle",role:"radiogroup","aria-label":x("forum.askVet.visibilityLabel"),children:[e.jsxs("button",{type:"button",className:H==="PUBLIC"?"is-active":"",onClick:()=>r("PUBLIC"),disabled:F,"aria-pressed":H==="PUBLIC",children:[e.jsx(wa,{}),x("forum.askVet.public")]}),e.jsxs("button",{type:"button",className:H==="PRIVATE"?"is-active":"",onClick:()=>{r("PRIVATE"),ee(!1)},disabled:F,"aria-pressed":H==="PRIVATE",children:[e.jsx(Ea,{}),x("forum.askVet.private")]})]}),e.jsx("p",{className:"ask-vet-toggle-hint",children:x(H==="PRIVATE"?"forum.askVet.privateHint":"forum.askVet.publicHint")}),H==="PUBLIC"?e.jsxs("label",{className:"ask-vet-check",children:[e.jsx(qt,{checked:Z,onCheckedChange:P=>ee(P===!0),disabled:F}),e.jsx("span",{children:x("forum.createPost.anonymousLabel")})]}):null,e.jsxs("label",{className:"ask-vet-check",children:[e.jsx(qt,{checked:E,onCheckedChange:P=>se(P===!0),disabled:F}),e.jsx("span",{children:x("forum.askVet.disclaimer")})]}),e.jsx(z,{type:"submit",className:"w-full",disabled:F||!Te,children:F?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"h-4 w-4 mr-2 animate-spin"}),x("forum.createPost.creating")]}):x("forum.askVet.submit")})]})]}):e.jsxs(We,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(rt,{children:e.jsx(qe,{children:x("forum.createPost.title")})}),e.jsxs("form",{onSubmit:$e,className:"space-y-3",children:[K&&e.jsx("div",{className:"bg-destructive/10 text-destructive text-sm p-3 rounded-md border border-destructive/20",children:K}),je&&e.jsxs("div",{className:"bg-amber-50 text-amber-900 text-sm p-3 rounded-md border border-amber-200",children:[e.jsx("div",{className:"font-semibold mb-1",children:C.language==="zh"?"內容需要審核":"C
60ontent Pending Review"}),e.jsx("div",{children:je})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_auto] gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Be,{htmlFor:"title",children:[x("forum.createPost.titleLabel")," *"]}),e.jsx(Kt,{id:"title",value:U,onChange:P=>W(P.target.value),placeholder:x("forum.createPost.titlePlaceholder"),required:!0,maxLength:200,disabled:F}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[U.length,"/200 ",x("forum.createPost.characters")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Be,{htmlFor:"category",children:[x("forum.createPost.categoryLabel")," *"]}),e.jsxs(Ca,{value:te,onValueChange:R,disabled:F,children:[e.jsx(Pa,{id:"category",className:"w-full",children:e.jsx(La,{placeholder:x("forum.createPost.categoryPlaceholder")})}),e.jsx(Ia,{children:Pe.map(P=>e.jsx(Ra,{value:P.value,children:P.label},P.value))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Be,{htmlFor:"content",children:[x("forum.createPost.contentLabel")," *"]}),e.jsx(Jt,{value:$,onChange:V,placeholder:x("forum.createPost.contentPlaceholder"),rows:16,maxLength:1e4,disabled:F,onImageSelect:De,imagePreviews:A,onRemoveImage:fe}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$.length,"/10000 ",x("forum.createPost.characters")]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qt,{id:"anonymous",checked:Z,onCheckedChange:P=>ee(P===!0),disabled:F}),e.jsx(Be,{htmlFor:"anonymous",className:"text-sm font-normal cursor-pointer",children:x("forum.createPost.anonymousLabel")}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["(",x("forum.createPost.anonymousHint"),")"]})]}),e.jsxs(Es,{children:[e.jsx(z,{type:"button",variant:"outline",onClick:Ae,disabled:F,children:x("common.cancel")}),e.jsx(z,{type:"submit",disabled:F||!U.trim()||!$.trim(),children:F?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"h-4 w-4 mr-2 animate-spin"}),x("forum.createPost.creating")]}):x("forum.createPost.submit")})]})]})]})})},qa={sm:"forum-avatar--sm",md:"forum-avatar--md",lg:"forum-avatar--lg"},vs=[{bg:"hsl(24 72% 93%)",fg:"hsl(24 70% 34%)"},{bg:"hsl(18 42% 92%)",fg:"hsl(18 48% 36%)"},{bg:"hsl(32 48% 91%)",fg:"hsl(28 46% 32%)"},{bg:"hsl(12 32% 91%)",fg:"hsl(12 38% 35%)"},{bg:"hsl(36 36% 91%)",fg:"hsl(30 40% 30%)"}],Ga=l=>{let s=0;for(let p=0;p<l.length;p+=1)s=l.charCodeAt(p)+((s<<5)-s);return vs[Math.abs(s)%vs.length]},Ge=({name:l,size:s="md",anonymous:p,team:g})=>{const x=g?"獸":(l||"?").trim().charAt(0).toUpperCase()||"?",C=g?{bg:"hsl(152 35% 90%)",fg:"hsl(152 42% 28%)"}:p?{bg:"hsl(24 10% 91%)",fg:"hsl(22 10% 38%)"}:Ga(l||"?");return e.jsx("span",{className:`forum-avatar ${qa[s]} ${p?"forum-avatar--anon":""} ${g?"forum-avatar--team":""}`,style:{background:C.bg,color:C.fg},"aria-hidden":!0,children:x})},ts=({urls:l,onOpen:s,compact:p})=>l.length?l.length===1?e.jsx("button",{type:"button",className:`forum-media forum-media--single ${p?"forum-media--compact":""}`,onClick:g=>{g.stopPropagation(),s==null||s(l[0])},children:e.jsx("img",{src:l[0],alt:"",loading:"lazy"})}):e.jsx("div",{className:`forum-media forum-media--grid forum-media--count-${Math.min(l.length,4)}`,children:l.slice(0,4).map(g=>e.jsx("button",{type:"button",className:"forum-media__tile",onClick:x=>{x.stopPropagation(),s==null||s(g)},children:e.jsx("img",{src:g,alt:"",loading:"lazy"})},g))}):null,Ee=l=>{const s=Number(l)||0;return s>=1e3?`${(s/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(s)},Ms=(l,s=180)=>{const p=nt(l||"").replace(/\s+/g," ").trim();return p.length<=s?p:`${p.slice(0,s).trim()}…`},Us=(l,s)=>{const p=[];for(const C of s||[]){if(!C)continue;const N=C.trim();N.startsWith("http")?p.push(Qt(N)):p.push(Zt(N))}const g=/\[img\](.*?)\[\/img\]/gi;let x;for(;(x=g.exec(l||""))!==null;){const C=Qt(x[1]||"");C&&p.push(C)}return[...new Set(p.filter(Boolean))].slice(0,4)},Ka=(l,s)=>{const p=(l||"").trim(),g=Ms(s,400);return!!(p&&g&&g.startsWith(p))},Qa=({post:l,authorName:s,timeAgo:p,categoryLabel:g,liked:x,liking:C,onOpen:N,onLike:v,onReply:h,onShare:S,onOpenImage:U})=>{const{i18n:W}=ye(),$=Se(l.title),V=Ms(l.content),te=!!$&&!Ka($,l.content),R=!!V&&V!==$,Z=Us(l.content,l.attachments);return e.jsxs("article",{className:"forum-feed-post",onClick:N,children:[e.jsx(Ge,{name:s,anonymous:l.isAnonymous}),e.jsxs("div",{className:"forum-feed-post__body",children:[e.jsxs("div",{className:"forum-feed-post__meta",children:[e.jsx("span",{className:"forum-feed-post__name",children:s}
60),l.isHot?e.jsx(zs,{className:"forum-feed-post__hot","aria-hidden":!0}):null,p?e.jsxs("span",{className:"forum-feed-post__time",children:["· ",p]}):null,g?e.jsx("span",{className:"forum-feed-post__cat",children:g}):null,l.asksVet?e.jsx("span",{className:`forum-vet-badge ${l.visibility==="PRIVATE"?"is-private":""}`,children:As(l.vetStatus,W.language)}):null]}),te?e.jsx("h3",{className:"forum-feed-post__title",children:$}):null,R?e.jsx("p",{className:"forum-feed-post__excerpt",children:V}):null,e.jsx(ts,{urls:Z,onOpen:U,compact:!0}),e.jsxs("div",{className:"forum-feed-post__actions",children:[e.jsxs("button",{type:"button",className:"forum-action",onClick:h,children:[e.jsx(Ds,{}),l.replies?e.jsx("span",{children:Ee(l.replies)}):null]}),e.jsxs("button",{type:"button",className:`forum-action ${x?"is-liked":""}`,onClick:v,disabled:C,children:[e.jsx(es,{className:x?"is-filled":""}),l.likes?e.jsx("span",{children:Ee(l.likes)}):null]}),e.jsx("button",{type:"button",className:"forum-action",onClick:S,children:e.jsx(Xt,{})})]})]})]})},Ya=({name:l,onClick:s})=>{const{t:p,i18n:g}=ye(),x=l||p("forum.genericUser");return e.jsxs("button",{type:"button",className:"forum-composer-prompt",onClick:s,children:[e.jsx(Ge,{name:x}),e.jsx("span",{className:"forum-composer-prompt__field",children:g.language==="zh"?"有咩想同毛孩爸媽傾?":"What's on your mind?"}),e.jsx("span",{className:"forum-composer-prompt__cta",children:p("forum.createPost.button")})]})},Xa=({reply:l,authorName:s,timeAgo:p,liked:g,liking:x,children:C,onLike:N,onReply:v,onOpenImage:h,parentAuthorName:S,parentPreview:U,onJumpToParent:W})=>{const{i18n:$}=ye(),V=Us(l.content,l.attachments),te=Yt(Se(l.content));return e.jsxs("article",{id:`reply-${l.id}`,className:"forum-thread-reply",children:[e.jsx(Ge,{name:s,size:"sm",team:!!l.isVetTeamReply}),e.jsxs("div",{className:"forum-thread-reply__body",children:[e.jsxs("div",{className:"forum-feed-post__meta",children:[e.jsx("span",{className:"forum-feed-post__name",children:s}),l.isVetTeamReply?e.jsx("span",{className:"forum-vet-badge",children:$.language==="zh"?"獸醫/護士團隊":"Vet/nurse team"}):null,p?e.jsxs("span",{className:"forum-feed-post__time",children:["· ",p]}):null]}),S&&W?e.jsx("button",{type:"button",className:"forum-thread-reply__quote",onClick:W,children:e.jsx("span",{children:U?`${S}: ${nt(U).slice(0,80)}`:S})}):null,e.jsx("div",{className:"forum-thread-reply__content",dangerouslySetInnerHTML:{__html:te}}),e.jsx(ts,{urls:V,onOpen:h,compact:!0}),e.jsxs("div",{className:"forum-feed-post__actions",children:[e.jsx("button",{type:"button",className:"forum-action",onClick:v,children:e.jsx(Ds,{})}),e.jsxs("button",{type:"button",className:`forum-action ${g?"is-liked":""}`,onClick:N,disabled:x,children:[e.jsx(es,{className:g?"is-filled":""}),l.likes?e.jsx("span",{children:Ee(l.likes)}):null]})]}),C?e.jsx("div",{className:"forum-thread-reply__children",children:C}):null]})]})},Ja=({name:l,replyToName:s,onPress:p})=>{const{t:g,i18n:x}=ye(),C=l||g("forum.genericUser"),N=s?x.language==="zh"?`回覆 ${s}…`:`Reply to ${s}…`:x.language==="zh"?"寫留言…":"Write a reply…";return e.jsx("div",{className:"forum-reply-dock",children:e.jsxs("button",{type:"button",className:"forum-reply-dock__field",onClick:p,children:[e.jsx(Ge,{name:C,size:"sm"}),e.jsx("span",{children:N})]})})},Za=({categories:l,selectedCategory:s,onCompose:p,onAskVet:g,onSelectCategory:x,isVet:C=!1,isAuthenticated:N=!1})=>{const{t:v}=ye();return e.jsx("aside",{className:"forum-rail forum-rail--nav","aria-label":v("forum.desktop.navLabel"),children:e.jsxs("div",{className:"forum-rail__sticky",children:[e.jsxs("button",{type:"button",className:"forum-rail-post",onClick:p,children:[e.jsx(Ha,{}),e.jsx("span",{children:v("forum.desktop.post")})]}),e.jsxs("button",{type:"button",className:"forum-rail-ask-vet",onClick:g,children:[e.jsx(Ps,{}),e.jsx("span",{children:v("forum.askVet.cta")})]}),e.jsx("div",{className:"forum-rail-divider"}),e.jsxs("div",{className:"forum-rail-topics",children:[e.jsx("h2",{children:v("forum.desktop.topics")}),e.jsx("button",{type:"button",className:`forum-rail-topic ${s==="all"?"is-active":""}`,onClick:()=>x("all"),children:v("forum.allCategories")}),e.jsx("button",{type:"button",className:`forum-rail-topic ${s==="ask-vet"?"is-active":""}`,onClick:()=>x("ask-vet"),children:v("forum.askVet.feed")}),N?e.jsx("button",{type:"button",className:`forum-rail-topic ${s==="my-vet"?"is-active":""}`,onClick:()=>x("my-vet"),children:v("forum.askVet.myQuestions")}):null,C?e.jsx("button",{type:"button",className:`forum-rail-topic ${s==="vet-queue"?"is-active":""}`,onClick:()=>x("vet-queue"),children:v("forum.askVet.queue")}):null,l.map(h=>e.jsx("button",{type:"button",className:`forum-rail-topic ${s===h.value?"is-active":""}`,onClick:()=>
60x(h.value),children:h.label},h.value))]})]})})},er=({searchQuery:l,onSearchChange:s,onClearSearch:p,posts:g,onOpenPost:x})=>{const{t:C,i18n:N}=ye();return e.jsx("aside",{className:"forum-rail forum-rail--discover","aria-label":C("forum.desktop.discoverLabel"),children:e.jsxs("div",{className:"forum-rail__sticky",children:[e.jsxs("div",{className:"forum-search forum-search--rail",children:[e.jsx($s,{}),e.jsx("input",{type:"search",placeholder:C("forum.searchPlaceholder"),value:l,onChange:v=>s(v.target.value)}),l?e.jsx("button",{type:"button",className:"forum-icon-btn",onClick:p,"aria-label":"Clear search",children:e.jsx(it,{})}):null]}),e.jsxs("section",{className:"forum-discover",children:[e.jsx("h2",{children:C("forum.desktop.buzzing")}),g.length===0?e.jsx("p",{className:"forum-discover__empty",children:C("forum.noContent")}):g.map(v=>{const h=Se(v.title),S=be(v,v.author,v.authorId,N.language);return e.jsxs("button",{type:"button",className:"forum-discover-item",onClick:()=>x(v),children:[e.jsxs("div",{className:"forum-discover-item__meta",children:[v.isHot?e.jsx(zs,{className:"forum-feed-post__hot","aria-hidden":!0}):null,e.jsx("span",{children:S})]}),e.jsx("div",{className:"forum-discover-item__title",children:h||C("forum.untitled")}),e.jsxs("div",{className:"forum-discover-item__stats",children:[e.jsxs("span",{children:[Ee(v.likes)," ",N.language==="zh"?"讚":"likes"]}),e.jsxs("span",{children:[Ee(v.replies)," ",C("forum.replies")]})]})]},v.id)})]})]})})},tr=({name:l,value:s,replyToName:p,submitting:g,textareaRef:x,onChange:C,onSubmit:N,onClearReplyTo:v,onOpenRichEditor:h,teamHint:S})=>{const{t:U,i18n:W}=ye(),$=l||U("forum.genericUser"),V=p?W.language==="zh"?`回覆 ${p}`:`Reply to ${p}`:U("forum.desktop.replyPlaceholder"),te=R=>{R.preventDefault(),!(!s.trim()||g)&&N()};return e.jsxs("form",{className:"forum-inline-composer",onSubmit:te,children:[e.jsx(Ge,{name:$,team:!!S}),e.jsxs("div",{className:"forum-inline-composer__body",children:[S?e.jsx("div",{className:"forum-inline-composer__team-hint",children:S}):null,p?e.jsxs("div",{className:"forum-inline-composer__replying",children:[e.jsxs("span",{children:[W.language==="zh"?"回覆":"Replying to"," ",e.jsx("strong",{children:p})]}),v?e.jsx("button",{type:"button",className:"forum-icon-btn",onClick:v,"aria-label":U("forum.desktop.clearReplyTo"),children:e.jsx(it,{})}):null]}):null,e.jsx("textarea",{ref:x,rows:3,value:s,placeholder:V,onChange:R=>C(R.target.value),onKeyDown:R=>{(R.metaKey||R.ctrlKey)&&R.key==="Enter"&&(R.preventDefault(),s.trim()&&!g&&N())}}),e.jsxs("div",{className:"forum-inline-composer__bar",children:[e.jsxs("button",{type:"button",className:"forum-inline-composer__photo",onClick:h,children:[e.jsx(Fs,{}),e.jsx("span",{children:U("forum.desktop.photo")})]}),e.jsx("button",{type:"submit",className:"forum-inline-composer__submit",disabled:!s.trim()||g,children:g?e.jsx(ot,{className:"h-4 w-4 animate-spin"}):U("forum.desktop.reply")})]})]})]})},Nt=20,tt=20,sr=30,ws=Nt*sr,Ns="https://storage.googleapis.com/gpt-engineer-file-uploads/JHL1szBw74V1hbPrOlIVhZq067C3/social-images/social-1759652520246-PetWell Logo (Instagram Post).png",ar="(min-width: 900px)",wt=()=>typeof window<"u"&&window.matchMedia(ar).matches,Ss=l=>{const s=["#2563eb","#dc2626"];let p=0;for(let g=0;g<l.length;g++)p=l.charCodeAt(g)+((p<<5)-p);return s[Math.abs(p)%s.length]},T="https://petwellhk.com",Ur=()=>{const{t:l,i18n:s}=ye(),[p,g]=na(),{postId:x}=ia(),C=Cs(),{toast:N}=da(),{isAuthenticated:v,userInfo:h}=Ls(),{openPanel:S,onAuthSuccess:U}=Is(),[W,$]=n.useState(!1),V=n.useRef(null),te=n.useRef(!1),[R,Z]=n.useState([]),[ee,H]=n.useState([]),[r,E]=n.useState(null),[se,F]=n.useState([]),[Y,K]=n.useState([]),[ae,je]=n.useState(!0),[Ce,A]=n.useState(!1),[ge,Pe]=n.useState(null),[De,fe]=n.useState(!1),[$e,Ae]=n.useState("post"),[Te,P]=n.useState(!1),[m,J]=n.useState(1),[_,L]=n.useState(1),[q,pe]=n.useState(1),[ie,Q]=n.useState(0),[O,D]=n.useState(new Set),[X,oe]=n.useState(new Set),[le,de]=n.useState(new Set),[Me,lt]=n.useState(new Set),[ue,ve]=n.useState(""),[ct,ss]=n.useState(!1),[Vs,xe]=n.useState(!1),[M,Fe]=n.useState(null),[Le,Ke]=n.useState([]),[Hs,as]=n.useState([]),[Ue,dt]=n.useState(new Set),[St,rs]=n.useState(new Set),[ns,rr]=n.useState(new Set);n.useState(new Set),n.useState(new Set);const[nr,Os]=n.useState(new Set),[ir,Bs]=n.useState(new Set),[Ws,_e]=n.useState(!1),[is,Qe]=n.useState(null),[qs,os]=n.useState(!1),ke=n.useRef(null),ut=n.useRef(null),ls=n.useRef(null),cs=n.useRef(null),Gs=n.useRef(new Map),mt=n.useRef(0),ht=n.useRef(!0),gt=n.useRef(!1),Ct=n.useRef(null),Pt=n.useRef(!1),[ft,pt]=n.useState(()=>!!p.get("post")),[Ye,Xe]=n.useState(!1),B=x||p.get("post"),ds=p.get("category");n.useEffect(()=>{if(!x&&p.get("post")){const t=p.get("post");if(!t)return;const a=new URLSearchParams(p);a.delete("post");const i=a.toString();C(`/forum/${t}${i?`?${i}`:""}`,{replace:!0})}},[]);const[Ie,xt]=Sa(),[G,we]=n.useState(ds||"all"),[Lt,or]=n.useState([]),[It,lr]=n.useState("all"),[ze,us]=n.useState("recent"),[ms,Ks]=n.useState("recent"),[cr,Qs]=n.useState([]),[hs,dr]=n.useState(!1),gs=Rs(s.language),Ys=n.useMemo(()=>{var j;if(!r)return{title:"香港寵物討論區 | 寵物論壇 | 狗狗貓貓毛孩社群 開post吹水 | PetWell 寵物台",description:"香港寵物討論區——像 LIHKG、discuss 咁樣嘅寵物版。開post、吹水、問獸醫、領養、走失協尋、健康美容飲食訓練。狗狗台、貓貓台、小動物討論,香港最活躍寵物論壇,完全免費。",keywords:"討論區,寵物討論區,香港寵物討論區,寵物論壇,香港討論區寵物,香港寵物討論,寵物台,狗狗討論區,貓貓討論區,狗狗論壇,貓貓論壇,狗狗台,貓貓台,香港寵物社群,寵物吹水,寵物開post,pet forum hong kong,寵物forum,養狗心得,養貓分享,寵物健康討論,獸醫推薦,寵物美容,領養寵物香港,走失協尋,毛孩主人,毛孩討論區,hong kong pet community,香港狗主,香港貓主,寵物交流,寵物求助,寵物飲食,狗狗訓練,寵物行為問題,寵物園地,寵物問題討論,hong kong pet forum,hk pet forum,pet discussion board hong 
60kong,寵物資訊香港,寵物社區香港,discuss 寵物,hk 寵物討論區",canonicalUrl:`${T}/forum`,ogImage:Ns,structuredData:[{"@context":"https://schema.org","@type":"DiscussionForum",name:"PetWell 香港寵物討論區 - 寵物論壇",alternateName:["香港寵物討論區","寵物討論區","寵物台","寵物論壇","香港寵物forum","香港寵物討論區論壇"],description:"香港最活躍寵物討論區。狗狗、貓貓、小動物主人分享養寵經驗、健康資訊、領養資訊,互相幫助。涵蓋獸醫推薦、走失協尋、寵物美容、行為訓練等話題。",url:`${T}/forum`,inLanguage:["zh-HK","zh-TW","en"],audience:{"@type":"Audience",audienceType:"Pet Owners",geographicArea:{"@type":"AdministrativeArea",name:"Hong Kong"}},provider:{"@type":"Organization",name:"PetWell HK",url:T,logo:`${T}/logo.png`,sameAs:["https://www.instagram.com/petwell.hk","https://www.facebook.com/petwellhk"]},about:[{"@type":"Thing",name:"狗狗"},{"@type":"Thing",name:"貓貓"},{"@type":"Thing",name:"寵物健康"},{"@type":"Thing",name:"寵物領養"},{"@type":"Thing",name:"獸醫推薦"},{"@type":"Thing",name:"寵物訓練"}]},{"@context":"https://schema.org","@type":"CollectionPage",name:"香港寵物討論區 | PetWell 寵物論壇",description:"香港最活躍寵物討論區兼論壇,涵蓋狗狗、貓貓、小動物等17個討論分類,包括健康、美容、飲食、領養、走失協尋、緊急求助。",url:`${T}/forum`,inLanguage:"zh-HK",isPartOf:{"@type":"WebSite",name:"PetWell HK",url:T}},{"@context":"https://schema.org","@type":"ItemList",name:"PetWell 寵物討論區・論壇分類",description:"香港寵物討論區/論壇涵蓋的17個寵物話題分類",numberOfItems:17,itemListElement:[{"@type":"ListItem",position:1,name:"狗狗討論",url:`${T}/forum?category=DOG`},{"@type":"ListItem",position:2,name:"貓貓討論",url:`${T}/forum?category=CAT`},{"@type":"ListItem",position:3,name:"小動物",url:`${T}/forum?category=SMALL_ANIMAL`},{"@type":"ListItem",position:4,name:"生活分享",url:`${T}/forum?category=LIFE_SHARING`},{"@type":"ListItem",position:5,name:"寵物活動",url:`${T}/forum?category=EVENTS`},{"@type":"ListItem",position:6,name:"寵物領養",url:`${T}/forum?category=ADOPTION`},{"@type":"ListItem",position:7,name:"寵物健康",url:`${T}/forum?category=HEALTH`},{"@type":"ListItem",position:8,name:"寵物美容",url:`${T}/forum?category=GROOMING`},{"@type":"ListItem",position:9,name:"寵物飲食",url:`${T}/forum?category=DIET`},{"@type":"ListItem",position:10,name:"寵物訓練",url:`${T}/forum?category=TRAINING`},{"@type":"ListItem",position:11,name:"行為問題",url:`${T}/forum?category=BEHAVIOR`},{"@type":"ListItem",position:12,name:"用品評價",url:`${T}/forum?category=PRODUCT_REVIEW`},{"@type":"ListItem",position:13,name:"寵物交易",url:`${T}/forum?category=TRADING`},{"@type":"ListItem",position:14,name:"寵物旅遊",url:`${T}/forum?category=TRAVEL`},{"@type":"ListItem",position:15,name:"寵物住宿",url:`${T}/forum?category=LODGING`},{"@type":"ListItem",position:16,name:"走失協尋",url:`${T}/forum?category=LOST_FOUND`},{"@type":"ListItem",position:17,name:"緊急求助",url:`${T}/forum?category=EMERGENCY`}]},{"@context":"https://schema.org","@type":"WebSite",name:"PetWell HK - 香港寵物討論區・寵物論壇",url:T,potentialAction:{"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${T}/forum?search={search_term_string}`},"query-input":"required name=search_term_string"}},{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"PetWell HK",item:T},{"@type":"ListItem",position:2,name:"寵物討論區 / 寵物論壇",item:`${T}/forum`}]}],faqItems:[{question:"香港邊度有寵物討論區?",answer:"PetWell HK係香港最活躍嘅寵物論壇同討論區,專為香港毛孩主人而設。你可以喺度討論狗狗、貓貓、小動物嘅健康、飲食、美容、訓練等各種話題,仲可以分享養寵心得、搵領養資訊同獸醫推薦,完全免費。"},{question:"香港寵物討論區/論壇有咩討論分類?",answer:"PetWell寵物討論區(論壇)涵蓋17個討論分類:狗狗、貓貓、小動物、生活分享、活動、領養、健康、美容、飲食、訓練、行為問題、用å“
60è©•價、交易、旅遊、住宿、走失協尋及緊急求助。係香港覆蓋範圍最廣嘅寵物討論區。"},{question:"點樣喺香港寵物討論區發帖?",answer:"喺PetWell寵物論壇,你只需免費註冊帳號即可發帖。支援文字、圖片及分類標籤,亦可選擇匿名發文。點擊「發佈帖文」按鈕,選擇分類後即可開始分享。"},{question:"點樣搵香港寵物領養資訊?",answer:"喺PetWell寵物論壇嘅「領養」分類,你可以搵到香港各地嘅寵物領養資訊,包括狗狗、貓貓同其他小動物。亦有走失協尋分類幫助尋回走失寵物。"},{question:"可以匿名喺寵物討論區/論壇發文嗎?",answer:"可以!PetWell寵物討論區(論壇)支援匿名發帖功能,讓你可以自由分享個人經歷或提問,毋需擔心個人資料外洩。適合分享敏感話題或想保護私隱的主人。"},{question:"香港寵物主人最常討論咩話題?",answer:"香港寵物主人最常討論嘅話題包括:獸醫推薦、寵物健康問題(皮膚、腸胃、骨科等)、飲食建議、美容心得、寵物友善餐廳、訓練技巧、行為問題、走失尋寵及領養資訊。"},{question:"PetWell寵物討論區同LIHKG、Threads、discuss.com.hk有咩唔同?",answer:"PetWell係香港首個專門為寵物主人而設的討論區兼論壇,所有討論分類都圍繞寵物話題,唔係綜合討論區。同連登、discuss、Threads唔同,我哋係寵物專屬:開post吹水、獸醫診所、寵物友善餐廳、領養走失協尋一應俱全,係名副其實嘅「寵物台」討論區。"},{question:"Where can I find a Hong Kong pet forum in English?",answer:"PetWell HK is Hong Kong's most active pet forum and discussion board, supporting both Traditional Chinese and English. You can find discussions on dogs, cats, small animals, pet health, grooming, adoption, lost pets, and more. Join our community at petwellhk.com/forum."}],speakableSelectors:["h1",".forum-hero-description",".faq-answer"]};const t=r.isAnonymous?"匿名用戶":be(r,r.author,r.authorId,s.language)||"用戶",a=nt(r.content).replace(/\n+/g," ").trim(),i=a.length>160?a.slice(0,157)+"…":a,u=`${T}/forum/${r.id}`,o=r.category?$t(r.category,s.language):"",d=Se(r.title),k=((j=r.postTags)==null?void 0:j.map(c=>{var y;return(y=c.tag)==null?void 0:y.name}).filter(Boolean))??[],w=["寵物討論區","寵物論壇","寵物討論","香港寵物","pet forum hong kong","PetWell","香港毛孩",...o?[o]:[],d,...k].filter(Boolean),b=[...new Set(w)].join(",");return{title:o?`${d} [${o}] | PetWell 香港寵物討論區`:`${d} | PetWell 香港寵物討論區`,description:i||`${t} 喺PetWell香港寵物討論區分享:${d}`,keywords:b,ogType:"article",ogImage:Ns,canonicalUrl:u,articlePublishedTime:r.createdAt,articleModifiedTime:r.updatedAt||r.createdAt,articleAuthor:r.isAnonymous?void 0:t,articleSection:o||void 0,articleTags:k.length>0?k:void 0,structuredData:[{"@context":"https://schema.org","@type":"DiscussionForumPosting",headline:d,text:nt(r.content),url:u,datePublished:r.createdAt,dateModified:r.updatedAt||r.createdAt,author:{"@type":"Person",name:t},interactionStatistic:[{"@type":"InteractionCounter",interactionType:"https://schema.org/LikeAction",userInteractionCount:r.likes??0},{"@type":"InteractionCounter",interactionType:"https://schema.org/CommentAction",userInteractionCount:Y.length}],commentCount:Y.length,comment:Y.slice(0,50).map(c=>{const y=be(c,c.author,c.authorId,s.language)||"用戶";return{"@type":"Comment",text:nt(c.content),datePublished:c.createdAt,author:{"@type":"Person",name:y}}})},{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"PetWell HK",item:T},{"@type":"ListItem",position:2,name:"寵物討論區 / 寵物論壇",item:`${T}/forum`},{"@type":"ListItem",position:3,name:d,item:u}]}]}},[r,Y,s.language]);Na(Ys),n.useEffect(()=>{let t=!1;return(async()=>{var u;if(!((u=r==null?void 0:r.attachments)!=null&&u.length)){as([]);return}const i=(await Promise.all(r.attachments.map(async o=>{try{return await xa(o)}catch(d){return console.error("Failed to resolve forum attachment:",o,d),""}}
60))).filter(Boolean);t||as(i)})(),()=>{t=!0}},[r]);const Ve=async(t=!1)=>{try{t&&(je(!0),H([])),Pe(null);const a={limit:ze==="hot"?ws:100,sortBy:ms};let i=[];if(G===Ht?i=(await ka()).items||[]:G===Vt?i=(await ba()).items||[]:(G===Ut?a.asksVet=!0:G!=="all"&&(a.category=G),Lt.length>0&&(a.tagIds=Lt),Ie.trim()&&(a.searchQuery=Ie.trim()),i=await ya(a)),Z(i),v&&(h!=null&&h.email))try{const u=await at(h.email,h.email),o=await ys(u,{postIds:i.map(d=>d.id)});console.log("All user interactions fetched:",{totalLikedPosts:o.likedPostIds.size,totalDislikedPosts:o.dislikedPostIds.size,likedPostIds:Array.from(o.likedPostIds),dislikedPostIds:Array.from(o.dislikedPostIds),fetchedPostIds:i.map(d=>d.id)}),D(d=>{const k=new Set(o.likedPostIds);return d.forEach(w=>{k.add(w)}),console.log("Setting likedPosts state:",{fromBatch:Array.from(o.likedPostIds),fromPrev:Array.from(d),final:Array.from(k),fetchedPostIds:i.map(w=>w.id),matchedInFetched:i.filter(w=>k.has(w.id)).map(w=>w.id)}),k}),oe(d=>{const k=new Set(o.dislikedPostIds);return d.forEach(w=>{k.add(w)}),k})}catch(u){console.error("Error checking liked posts:",u)}t&&J(1)}catch(a){Pe(l("forum.error")),console.error("Error loading forum posts:",a)}finally{je(!1)}};n.useEffect(()=>{(async()=>{try{const a=await ja(void 0,50);Qs(a)}catch(a){console.error("Error loading tags:",a)}})()},[]),n.useEffect(()=>{Ks(ze==="hot"?"hot":"recent")},[ze]);const Je=n.useRef(ds||"all");n.useEffect(()=>{if(ht.current){ht.current=!1;const t=p.get("category")||"all";Je.current=t,t!==G&&(gt.current=!0,we(t))}},[]),n.useEffect(()=>{if(!ht.current){if(gt.current){gt.current=!1;return}if(Je.current!==G){const t=new URLSearchParams(window.location.search);G!=="all"?t.set("category",G):t.delete("category"),t.delete("post"),Je.current=G;const a=t.toString();C({pathname:"/forum",search:a?`?${a}`:""},{replace:!0}),E(null),pt(!1)}}},[C,G]),n.useEffect(()=>{if(ht.current)return;const t=p.get("category")||"all";t!==Je.current&&(gt.current=!0,Je.current=t,we(t))},[p,we]),n.useEffect(()=>{Ve(!0)},[G,Lt,ms]),n.useEffect(()=>{G==="TRADING"&&(sessionStorage.getItem("trading_disclaimer_acknowledged")==="true"||os(!0))},[G]),n.useEffect(()=>{if(v!==!0){P(!1);return}let t=!1;return ua().then(a=>{t||P(!!a.isVet)}).catch(()=>{t||P(!1)}),()=>{t=!0}},[v]);const He=t=>{if(v!==!0){S("LANDING");return}Ae(t),fe(!0)};n.useEffect(()=>{const t=setTimeout(()=>{(Ie.trim()||!Ie)&&Ve(!0)},500);return()=>clearTimeout(t)},[Ie]);const Ze=n.useMemo(()=>{let t=[...R];return It!=="all"&&(t=t.filter(a=>a.tags&&a.tags.some(i=>i.toLowerCase().includes(It.toLowerCase())))),ze==="hot"&&(t=t.filter(a=>a.isHot===!0).sort((a,i)=>(i.hotScore??0)-(a.hotScore??0)).slice(0,ws)),t},[R,It,ze]),Xs=n.useMemo(()=>{const t=R.filter(i=>i.id!==(r==null?void 0:r.id)),a=t.filter(i=>i.isHot).sort((i,u)=>(u.hotScore??0)-(i.hotScore??0));return a.length>=5?a.slice(0,8):[...t].sort((i,u)=>(u.likes||0)+(u.replies||0)-((i.likes||0)+(i.replies||0))).slice(0,8)},[R,r==null?void 0:r.id]),Js=n.useMemo(()=>Math.ceil(Ze.length/Nt),[Ze.length]);n.useEffect(()=>{const t=(m-1)*Nt,a=t+Nt;if(H(Ze.slice(t,a)),r&&!Ze.find(i=>i.id===r.id)){E(null);const i=new URLSearchParams(p);i.delete("post"),g(i,{replace:!0})}},[Ze,m,r,p,g]),n.useEffect(()=>{r||pt(!1)},[r]),n.useEffect(()=>{(ft||hs)&&Xe(!1)},[ft,hs]),n.useEffect(()=>{const t=cs.current;if(!t||ft)return;mt.current=t.scrollTop;const a=()=>{if(window.innerWidth>=768){Ye&&Xe(!1),mt.current=t.scrollTop;return}const i=t.scrollTop,u=i-mt.current;i<=8?Ye&&Xe(!1):u>12?Ye||Xe(!0):u<-12&&Ye&&Xe(!1),mt.current=i};return t.addEventListener("scroll",a,{passive:!0}),()=>{t.removeEventListener("scroll",a)}},[ft,Ye]);const Zs=n.useCallback(t=>{J(t);const a=cs.current;a&&(a.scrollTop=0)},[]),Rt=n.useRef(ee),kt=n.useRef(R),Ne=n.useRef(r);n.useEffect(()=>{Rt.current=ee},[ee]),n.useEffect(()=>{kt.current=R},[R]),n.useEffect(()=>{Ne.current=r},[r]);const ce=n.useCallback(async(t,a=!1,i=1)=>{var u;if(!(a&&((u=Ne.current)==null?void 0:u.id)===t&&ke.current!==t)&&ke.current!==t){ke.current=t,A(!0);try{const o=await bs(t),d=await ma(t,100),k=[...d].sort((f,I)=>!f.createdAt||!I.createdAt?0:new Date(f.createdAt).getTime()-new Date(I.createdAt).getTime()),w=k.filter(f=>!f.parentReplyId),b=Math.max(1,Math.ceil(w.length/tt)),j=(i-1)*tt,c=j+tt,
60y=w.slice(j,c);if(ke.current===t){if(E(o),F(y),K(k),Q(d.length),pe(b),L(i),v&&(h!=null&&h.email))try{const f=await at(h.email,h.email),I=await ys(f,{postIds:[o.id],replyIds:d.map(re=>re.id)});D(re=>{const ne=new Set(I.likedPostIds);return re.forEach(me=>ne.add(me)),ne}),oe(re=>{const ne=new Set(I.dislikedPostIds);return re.forEach(me=>ne.add(me)),ne});const Oe=new Set,Re=new Set;y.forEach(re=>{I.likedReplyIds.has(re.id)&&Oe.add(re.id),I.dislikedReplyIds.has(re.id)&&Re.add(re.id)}),de(re=>{const ne=new Set(re);return y.forEach(me=>ne.delete(me.id)),Oe.forEach(me=>ne.add(me)),ne}),lt(re=>{const ne=new Set(re);return y.forEach(me=>ne.delete(me.id)),Re.forEach(me=>ne.add(me)),ne})}catch(f){console.error("Error checking like status:",f)}A(!1),ke.current=null}}catch(o){if(console.error("Error loading post detail:",o),ke.current===t){const d=Rt.current.find(k=>k.id===t)||kt.current.find(k=>k.id===t);d&&E(d),A(!1),ke.current=null}}}},[]),bt=n.useCallback((t,a)=>{r&&(L(t),ce(r.id,!1,t).then(()=>{if(a){const i=(u=0)=>{const o=document.getElementById(`reply-${a}`);o?(o.scrollIntoView({behavior:"smooth",block:"center"}),o.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{o.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3)):u<10&&setTimeout(()=>i(u+1),100)};setTimeout(()=>i(),200)}else{const i=document.querySelector("[data-replies-section]");i&&i.scrollIntoView({behavior:"smooth",block:"start"})}}))},[r,ce]),ea=n.useCallback(t=>{if(!r)return;const a=Y.length>0?Y:se;if(a.length===0){setTimeout(()=>{const o=document.getElementById(`reply-${t}`);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{o.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3))},100);return}const i=a.find(o=>o.id===t);if(!i){setTimeout(()=>{const o=document.getElementById(`reply-${t}`);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{o.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3))},100);return}if(!i.parentReplyId){const d=a.filter(k=>!k.parentReplyId).findIndex(k=>k.id===t);if(d>=0){const k=Math.floor(d/tt)+1;k===_?setTimeout(()=>{const w=document.getElementById(`reply-${t}`);w&&(w.scrollIntoView({behavior:"smooth",block:"center"}),w.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{w.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3))},100):bt(k,t)}}else{const o=k=>{const w=a.find(j=>j.id===k);if(!w||!w.parentReplyId)return k;const b=a.find(j=>j.id===w.parentReplyId);return b?b.parentReplyId?o(b.id):b.id:k},d=o(t);if(d){const w=a.filter(b=>!b.parentReplyId).findIndex(b=>b.id===d);if(w>=0){const b=Math.floor(w/tt)+1;b===_?setTimeout(()=>{const j=document.getElementById(`reply-${t}`);j&&(j.scrollIntoView({behavior:"smooth",block:"center"}),j.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{j.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3))},100):bt(b,t)}}else setTimeout(()=>{const k=document.getElementById(`reply-${t}`);k&&(k.scrollIntoView({behavior:"smooth",block:"center"}),k.classList.add("ring-2","ring-[#FF902A]","ring-offset-2","transition-all"),setTimeout(()=>{k.classList.remove("ring-2","ring-[#FF902A]","ring-offset-2")},2e3))},100)}},[r,Y,se,bt,_]),Et=n.useCallback(t=>{F([]),K([]),ve(""),Fe(null),xe(!1);const a=new URLSearchParams(p);a.delete("post");const i=a.toString();C({pathname:`/forum/${t.id}`,search:i?`?${i}`:""},{replace:!0}),A(!0),E(t),pt(!0),ce(t.id)},[p,C,ce]);n.useCallback(async t=>{if(t==null||t.preventDefault(),t==null||t.stopPropagation(),!r)return;const a=`${window.location.origin}/forum/${r.id}`,i={title:Se(r.title),text:Se(r.content).substring(0,200)+"...",url:a};try{if(navigator.share)try{await navigator.share(i),N({title:s.language==="zh"?"分享成功":"Shared",description:s.language==="zh"?"內容已分享":"Content shared successfully"});return}catch(u){if(u instanceof Error&&u.name==="AbortError")return}await navigator.clipboard.writeText(a),N({title:s.language==="zh"?"連結已複製":"Link Copied",description:s.language==="zh"?"連結已複製到剪貼板":"Link copied to clipboard"})}catch(u){if(u instanceof Error&&u.name!=="AbortError"){console.error("Error sharing:",u);try{await navigator.clipboard.writeText(a),N({title:s.language==="zh"?"連結已複製":"Link Copied",description:s.language==="zh"?"連結已複製到剪貼板":"Link copied to clipboard"})}catch(o){console.error("Error copying to clipboard:",o),N({title:s.language==="zh"?"複製失敗":"Copy Failed",description:s.language==="zh"?"無法複製連結,請手動複製":"Failed to copy link, please copy manually",variant:"destructive"})}}}},[r,s.language,N]);const fs=n.useCallback(async(t,a)=>{if(a==null||a.preventDefault(),a==null||a.stopPropagation(),!v||!(h!=null&&h.email)){N({title:s.language==="zh"?"需要登入":"Login Required",description:s.language==="zh"?"請先登入以讚好帖文":"Please log in to like posts",variant:"default"});return}if(Ue.has(t.id))return;const i=O.has(t.id),u=t.likes;dt(c=>new Set(c).add(t.id));const o=!i,d=i?Math.max(0,u-1):u+1;D(c=>{const y=new Set(c);return o?y.add(t.id):y.delete(t.id),y});const k=X.has(t.id),w=t.dislikes||0;k&&oe(c=>{const y=new Set(c);return y.delete(t.id),y});const b=k?Math.max(0,w-1):w,j=c=>
60c.id===t.id?{...c,likes:d,dislikes:b}:c;Z(c=>c.map(j)),H(c=>c.map(j)),(r==null?void 0:r.id)===t.id&&E(c=>c?{...c,likes:d,dislikes:b}:null),ha(t.id,h.email,u,w,t.replies).then(c=>{console.log("Post like result:",c),D(f=>{const I=new Set(f);return c.liked?(I.add(t.id),oe(Oe=>{const Re=new Set(Oe);return Re.delete(t.id),Re})):I.delete(t.id),I}),k&&c.liked&&oe(f=>{const I=new Set(f);return I.delete(t.id),I});const y=f=>f.id===t.id?{...f,likes:c.newLikesCount,dislikes:c.newDislikesCount}:f;Z(f=>f.map(y)),H(f=>f.map(y)),(r==null?void 0:r.id)===t.id&&E(f=>f?{...f,likes:c.newLikesCount,dislikes:c.newDislikesCount}:null)}).catch(c=>{console.error("Error toggling like:",c),D(f=>{const I=new Set(f);return i?I.add(t.id):I.delete(t.id),I});const y=f=>f.id===t.id?{...f,likes:u,dislikes:w}:f;Z(f=>f.map(y)),H(f=>f.map(y)),(r==null?void 0:r.id)===t.id&&E(f=>f?{...f,likes:u,dislikes:w}:null),k&&oe(f=>{const I=new Set(f);return I.add(t.id),I}),N({title:s.language==="zh"?"操作失敗":"Operation Failed",description:s.language==="zh"?"無法更新讚好狀態,請稍後再試":"Failed to update like status, please try again",variant:"destructive"})}).finally(()=>{dt(c=>{const y=new Set(c);return y.delete(t.id),y})})},[v,h,O,X,r,s.language,N,Ue]);n.useCallback(async(t,a)=>{if(a==null||a.preventDefault(),a==null||a.stopPropagation(),!v||!(h!=null&&h.email)){N({title:s.language==="zh"?"需要登入":"Login Required",description:s.language==="zh"?"請先登入以不喜歡帖文":"Please log in to dislike posts",variant:"default"});return}if(Ue.has(t.id))return;const i=X.has(t.id),u=O.has(t.id),o=t.dislikes||0,d=t.likes||0;dt(c=>new Set(c).add(t.id));const k=!i,w=i?Math.max(0,o-1):o+1;u&&D(c=>{const y=new Set(c);return y.delete(t.id),y}),oe(c=>{const y=new Set(c);return k?y.add(t.id):y.delete(t.id),y});const b=u?Math.max(0,d-1):d,j=c=>c.id===t.id?{...c,likes:b,dislikes:w}:c;Z(c=>c.map(j)),H(c=>c.map(j)),(r==null?void 0:r.id)===t.id&&E(c=>c?{...c,likes:b,dislikes:w}:null),ga(t.id,h.email,d,o,t.replies).then(c=>{console.log("Post dislike result:",c),oe(f=>{const I=new Set(f);return c.disliked?(I.add(t.id),D(Oe=>{const Re=new Set(Oe);return Re.delete(t.id),Re})):I.delete(t.id),I}),u&&c.disliked&&D(f=>{const I=new Set(f);return I.delete(t.id),I});const y=f=>f.id===t.id?{...f,dislikes:c.newDislikesCount,likes:c.newLikesCount}:f;Z(f=>f.map(y)),H(f=>f.map(y)),(r==null?void 0:r.id)===t.id&&E(f=>f?{...f,dislikes:c.newDislikesCount,likes:c.newLikesCount}:null)}).catch(c=>{console.error("Error toggling dislike:",c),oe(f=>{const I=new Set(f);return i?I.add(t.id):I.delete(t.id),I});const y=f=>f.id===t.id?{...f,dislikes:o,likes:d}:f;Z(f=>f.map(y)),H(f=>f.map(y)),(r==null?void 0:r.id)===t.id&&E(f=>f?{...f,dislikes:o,likes:d}:null),u&&D(f=>{const I=new Set(f);return I.add(t.id),I}),N({title:s.language==="zh"?"操作失敗":"Operation Failed",description:s.language==="zh"?"無法更新不喜歡狀態,請稍後再試":"Failed to update dislike status, please try again",variant:"destructive"})}).finally(()=>{dt(c=>{const y=new Set(c);return y.delete(t.id),y})})},[v,h,X,O,r,s.language,N,Ue]),n.useEffect(()=>{r!=null&&r.id&&window.scrollTo({top:0,behavior:"auto"})},[r==null?void 0:r.id]);const At=n.useCallback(()=>{const t=new URLSearchParams(p);t.delete("post");const a=t.toString();C({pathname:"/forum",search:a?`?${a}`:""}),E(null),F([]),K([]),pt(!1),xe(!1),Fe(null)},[C,p]),yt=n.useCallback(()=>{requestAnimationFrame(()=>{var t,a;(t=Ct.current)==null||t.focus(),(a=Ct.current)==null||a.scrollIntoView({behavior:"smooth",block:"center"})})},[]);n.useEffect(()=>{!r||!Pt.current||(Pt.current=!1,wt()?yt():xe(!0))},[r==null?void 0:r.id,yt]);const et=n.useCallback((t=null)=>{if(Fe(t),wt()){xe(!1),yt();return}xe(!0)},[yt]),Tt=n.useCallback(async()=>{if(!(!r||!(h!=null&&h.email)||!ue.trim())){ss(!0);try{const t=await at(h.email,h.email);let a=ue.trim();if(Le.length>0){const o=Date.now(),d=s.language==="zh"?"[圖片]":"[Image]",k=await Promise.all(Le.map(async(b,j)=>{const c=b.file.name.split(".").pop()||"jpg",y=`forum-images/${o}-${t}-reply-${j}.${c}`;return await _s({key:y,data:b.file,options:{contentType:b.file.type,accessLevel:"guest"}}).result,{url:Zt(y)}}));let w=0;
60k.forEach(({url:b})=>{const j=a.indexOf(d,w);j!==-1&&(a=a.substring(0,j)+`[img]${b}[/img]`+a.substring(j+d.length),w=j+`[img]${b}[/img]`.length)})}const i=await fa({content:a,postId:r.id,authorId:t,parentReplyId:(M==null?void 0:M.id)||null},h.email);if(ve(""),Fe(null),xe(!1),Le.forEach(o=>{URL.revokeObjectURL(o.preview)}),Ke([]),"pendingReview"in i){N({title:s.language==="zh"?"留言需要審核":"Reply Pending Review",description:s.language==="zh"?"系統偵測到留言可能包含敏感字眼。留言已提交人工審核,通過前不會公開顯示。":"We detected potentially sensitive wording. Your reply has been submitted for manual review and will not be public until approved."});return}await ce(r.id,!1,_);const u=await bs(r.id);Z(o=>o.map(d=>d.id===r.id?u:d)),H(o=>o.map(d=>d.id===r.id?u:d)),r.id===u.id&&E(u),N({title:s.language==="zh"?"留言成功":"Reply Posted",description:s.language==="zh"?"您的留言已發表":"Your reply has been posted"}),$(!0)}catch(t){console.error("Error creating reply:",t),N({title:s.language==="zh"?"發表失敗":"Failed to Post",description:t instanceof Error?t.message:s.language==="zh"?"無法發表留言,請稍後再試":"Failed to post reply, please try again",variant:"destructive"})}finally{ss(!1)}}},[r,h,ue,Le,M,_,ce,s.language,N]),Ft=n.useCallback((t=!1)=>{V.current={content:ue,postId:(r==null?void 0:r.id)||"",replyingTo:M,imagePreviews:[...Le]},U(()=>{const a=V.current;a&&(ve(a.content),Fe(a.replyingTo),Ke(a.imagePreviews),V.current=null),(!wt()||t)&&xe(!0),N({title:s.language==="zh"?"登入成功!":"Logged in!",description:s.language==="zh"?"您可以繼續發表留言":"You can now post your reply"})}),te.current=!0,xe(!1),S("LANDING")},[ue,r,M,Le,U,N,s.language,S]),ta=n.useCallback(()=>{if(!v){Ft();return}Tt()},[v,Ft,Tt]),_t=n.useCallback(async(t,a)=>{a==null||a.preventDefault(),a==null||a.stopPropagation();const i=`${window.location.origin}/forum/${t.id}`,u={title:Se(t.title),text:Se(t.content).substring(0,200)+"...",url:i};try{if(navigator.share)try{await navigator.share(u),N({title:s.language==="zh"?"分享成功":"Shared",description:s.language==="zh"?"內容已分享":"Content shared successfully"});return}catch(o){if(o instanceof Error&&o.name==="AbortError")return}await navigator.clipboard.writeText(i),N({title:s.language==="zh"?"連結已複製":"Link Copied",description:s.language==="zh"?"連結已複製到剪貼板":"Link copied to clipboard"})}catch(o){if(o instanceof Error&&o.name!=="AbortError")try{await navigator.clipboard.writeText(i),N({title:s.language==="zh"?"連結已複製":"Link Copied",description:s.language==="zh"?"連結已複製到剪貼板":"Link copied to clipboard"})}catch{N({title:s.language==="zh"?"複製失敗":"Copy Failed",description:s.language==="zh"?"無法複製連結,請手動複製":"Failed to copy link, please copy manually",variant:"destructive"})}}},[s.language,N]),sa=n.useCallback(async(t,a)=>{if(a==null||a.preventDefault(),a==null||a.stopPropagation(),!v||!(h!=null&&h.email)){S("LANDING");return}if(St.has(t.id)||ns.has(t.id)||Me.has(t.id))return;const i=le.has(t.id),u=t.likes||0,o=t.dislikes||0,d=!i,k=i?Math.max(0,u-1):u+1;rs(b=>new Set(b).add(t.id)),de(b=>{const j=new Set(b);return d?j.add(t.id):j.delete(t.id),j});const w=b=>b.id===t.id?{...b,likes:k}:b;F(b=>b.map(w)),K(b=>b.map(w));try{const b=await pa(t.id,h.email,u,o);de(c=>{const y=new Set(c);return b.liked?y.add(t.id):y.delete(t.id),y});const j=c=>c.id===t.id?{...c,likes:b.newLikesCount,dislikes:b.newDislikesCount}:c;F(c=>c.map(j)),K(c=>c.map(j))}catch{de(j=>{const c=new Set(j);return i?c.add(t.id):c.delete(t.id),c});const b=j=>j.id===t.id?{...j,likes:u,dislikes:o}:j;F(j=>j.map(b)),K(j=>j.map(b)),N({title:s.language==="zh"?"操作失敗":"Operation Failed",description:s.language==="zh"?"無法更新讚好狀態,請稍後再試":"Failed to update like status, please try again",variant:"destructive"})}finally{rs(b=>{const j=new Set(b);return j.delete(t.id),j})}},[Me,ns,s.language,v,le,St,S,N,h]);n.useEffect(()=>{var t,a,i,u,o;if(!(B===ut.current&&((t=Ne.current)==null?void 0:t.id)===B&&ke.current!==B))if(B){if(ke.current===B)return;ut.current=B,F([]),K([]);const d=Rt.current.find(k=>k.id===B);if(d)((a=Ne.current)==null?void 0:a.id)!==B&&E(d),ce(B,!0);else if(kt.current.length>0){const k=kt.current.find(w=>w.id===B);k?(((i=Ne.current)==null?void 0:i.id)!==B&&E(k),ce(B,!0)):(((u=Ne.current)==null?void 0:u.id)!==B&&A(!0),ce(B,!1))}else((o=Ne.current)==null?void 0:o.id)!==B&&A(!0)}else ut.current=null,Ne.current&&(E(null),F([]),K([]),A(!1),ke.current=null)},[B,ce]),n.useEffect(()=>{if(B&&R.length>0&&!Ne.current){const t=R.find(a=>a.id===B);
60t&&(ut.current=B,F([]),K([]),E(t),ce(B,!1))}},[R.length,B,ce]),n.useEffect(()=>{r&&v&&(h!=null&&h.email)&&(async()=>{try{const a=await at(h.email,h.email),i=await va(r.id,a);D(u=>{const o=new Set(u);return i?o.add(r.id):o.delete(r.id),o})}catch(a){console.error("Error checking like status for selected post:",a)}})()},[r==null?void 0:r.id,v,h==null?void 0:h.email]),n.useEffect(()=>{if(ls.current&&r){const a=setTimeout(()=>{var o;const i=((o=ls.current)==null?void 0:o.scrollHeight)||0,u=600;Os(d=>{const k=new Set(d);return i>u?k.add(r.id):k.delete(r.id),k})},100);return()=>clearTimeout(a)}},[r==null?void 0:r.content,r==null?void 0:r.id]),n.useEffect(()=>{const i=setTimeout(()=>{Bs(u=>{const o=new Set(u);return Gs.current.forEach((d,k)=>{d.scrollHeight>400?o.add(k):o.delete(k)}),o})},100);return()=>clearTimeout(i)},[se]),n.useEffect(()=>{const t=a=>{const i=a.target;if(i.tagName==="IMG"&&i.hasAttribute("data-image-url")){const u=i.getAttribute("data-image-url");u&&(a.preventDefault(),a.stopPropagation(),Qe(u),_e(!0))}};return document.addEventListener("click",t),()=>{document.removeEventListener("click",t)}},[]);const aa=n.useCallback(t=>Y.filter(a=>a.parentReplyId===t).sort((a,i)=>!a.createdAt||!i.createdAt?0:new Date(a.createdAt).getTime()-new Date(i.createdAt).getTime()),[Y]),ps=(t,a,i)=>{if(a<=1)return null;const u=Array.from({length:Math.min(a,5)},(o,d)=>a<=5||t<=3?d+1:t>=a-2?a-4+d:t-2+d);return e.jsxs("div",{className:"forum-pagination",children:[e.jsx("button",{type:"button",disabled:t===1,onClick:()=>i(t-1),children:l("forum.pagination.previous")}),u.map(o=>e.jsx("button",{type:"button",className:t===o?"is-active":"",onClick:()=>i(o),children:o},o)),e.jsx("button",{type:"button",disabled:t===a,onClick:()=>i(t+1),children:l("forum.pagination.next")})]})},xs=(t,a=0)=>{const i=be(t,t.author,t.authorId,s.language),u=t.parentReplyId?Y.find(d=>d.id===t.parentReplyId):void 0,o=a<2?aa(t.id):[];return e.jsx(Xa,{reply:t,authorName:i,timeAgo:Mt(t.createdAt,s.language),liked:le.has(t.id),liking:St.has(t.id),onLike:d=>sa(t,d),onReply:d=>{d.stopPropagation(),et(t)},onOpenImage:d=>{Qe(d),_e(!0)},parentAuthorName:a===0&&u?be(u,u.author,u.authorId,s.language):void 0,parentPreview:a===0?u==null?void 0:u.content:void 0,onJumpToParent:u?()=>ea(u.id):void 0,children:o.map(d=>xs(d,a+1))},t.id)},zt=(h==null?void 0:h.username)||l("forum.genericUser"),Dt=r?be(r,r.author,r.authorId,s.language):"",ra=Hs,ks=M?be(M,M.author,M.authorId,s.language):Dt;return e.jsxs("div",{className:"forum-page",children:[e.jsx(oa,{}),e.jsxs("div",{className:`forum-workspace ${r?"forum-workspace--thread":""}`,children:[e.jsx(Za,{categories:gs,selectedCategory:G,isVet:Te,isAuthenticated:v===!0,onCompose:()=>He("post"),onAskVet:()=>He("ask-vet"),onSelectCategory:we}),r?e.jsxs("div",{className:"forum-column",children:[e.jsx("div",{className:"forum-sticky",children:e.jsxs("div",{className:"forum-thread-top",children:[e.jsx("button",{type:"button",className:"forum-icon-btn",onClick:At,"aria-label":l("forum.backToForum"),children:e.jsx(Aa,{className:"h-5 w-5"})}),e.jsx("h1",{children:s.language==="zh"?"討論":"Thread"}),e.jsx("button",{type:"button",className:"forum-icon-btn",onClick:t=>_t(r,t),"aria-label":"Share",children:e.jsx(Xt,{className:"h-4 w-4"})})]})}),e.jsxs("article",{className:"forum-article",children:[e.jsxs("div",{className:"forum-article__head",children:[e.jsx(Ge,{name:Dt,anonymous:r.isAnonymous,size:"lg"}),e.jsxs("div",{children:[e.jsx("div",{className:"forum-feed-post__name",children:Dt}),e.jsxs("div",{className:"forum-feed-post__time",children:[Mt(r.createdAt,s.language),r.category?` · ${$t(r.category,s.language)}`:""]}),r.asksVet?e.jsx("div",{className:"forum-article__vet",children:e.jsx("span",{className:`forum-vet-badge ${r.visibility==="PRIVATE"?"is-private":""}`,children:As(r.vetStatus,s.language)})}):null]})]}),e.jsx("h2",{className:"forum-article__title",children:Se(r.title)}),e.jsx("div",{className:"forum-article__content prose max-w-none",dangerouslySetInnerHTML:{__html:Yt(r.content)}}),r.asksVet?e.jsx("p",{className:"forum-article__disclaimer",children:l("forum.askVet.disclaimer")}):null,e.jsx(ts,{urls:ra,onOpen:t=>{Qe(t),_e(!0)}}),e.jsxs("div",{className:"forum-article__stats",children:[e.jsxs("span",{children:[e.jsx("strong",{children:Ee(r.likes)})," ",s.language==="zh"?"讚好":"Likes"]}),e.jsxs("span",{children:[e.jsx("strong",{children:Ee(ie||r.replies)})," ",l("forum.replies")]})]}),e.jsxs("div",{className:"forum-feed-post__actions",children:[e.jsxs("button",{type:"button",className:"forum-action",onClick:()=>et(null),children:[e.jsx(Gt,{className:"h-4 w-4"}),e.jsx("span",{children:s.language==="zh"?"留言":"Reply"})]}),e.jsxs("button",{type:"button",className:`forum-action ${O.has(r.id)?"is-liked":""}`,disabled:Ue.has(r.id),onClick:t=>fs(r,t),children:[e.jsx(es,{className:O.has(r.id)?"is-filled":""}),e.jsx("span",{children:Ee(r.likes)})]}),e.jsx("button",{type:"button",className:"forum-action",onClick:t=>_t(r,t),children:e.jsx(Xt,{className:"h-4 w-4"})})]})]}),e.jsx(tr,{name:zt,value:ue,replyToName:M?ks:null,submitting:ct,textareaRef:Ct,onChange:ve,onSubmit:ta,onClearReplyTo:()=>Fe(null),onOpenRichEditor:()=>xe(!0),teamHint:r.asksVet&&Te?l("forum.askVet.teamReplyHint"):null}),Ce?e.jsx("div",{className:"forum-empty",children:e.jsx(ot,{className:"h-6 w-6 mx-auto animate-spin text-[#FF902A]"})}):se.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"forum-replies-label",children:l("forum.replies")}),se.map(t=>xs(t)),ps(_,q,bt)]}):e.jsxs("div",{className:"forum-empty forum-empty--first-reply",children:[e.jsx("p",{children:l("forum.noReplies")}),e.jsx("button",{type:"button",className:"forum-composer-prompt__cta mt-4",onClick:()=>et(null),children:s.language==="zh"?"率先留言":"Be the first to reply"})]}),e.jsx(Ja,{name:zt,replyToName:ks,onPress:()=>et(M)})]}):e.jsxs("div",{className:"forum-column",children:[e.jsxs("div",{className:"forum-sticky",children:[e.jsxs("div",{className:"forum-tabs",children:[e.jsx("button",{type:"button",className:ze==="recent"?"is-active":"",onClick:()=>us("recent"),children:l("forum.sortRecent")}),e.jsx("button",{type:"button",className:ze==="hot"?"is-active":"",onClick:()=>us("hot"),children:l("forum.sortHot")})]}),e.jsx("div",{className:"forum-search-row",children:e.jsxs("div",{className:"forum-search",children:[e.jsx($s,{}),e.jsx("input",{type:"text",placeholder:l("forum.searchPlaceholder"),value:
60Ie,onChange:t=>xt(t.target.value)}),Ie?e.jsx("button",{type:"button",className:"forum-icon-btn",onClick:()=>{xt(""),Ve(!0)},"aria-label":"Clear search",children:e.jsx(it,{})}):null]})}),e.jsxs("div",{className:"forum-pills",children:[e.jsx("button",{type:"button",className:`forum-pill ${G==="all"?"is-active":""}`,onClick:()=>we("all"),children:l("forum.allCategories")}),e.jsx("button",{type:"button",className:`forum-pill is-vet ${G===Ut?"is-active":""}`,onClick:()=>we(Ut),children:l("forum.askVet.feed")}),v===!0?e.jsx("button",{type:"button",className:`forum-pill is-vet ${G===Vt?"is-active":""}`,onClick:()=>we(Vt),children:l("forum.askVet.myQuestions")}):null,Te?e.jsx("button",{type:"button",className:`forum-pill is-vet ${G===Ht?"is-active":""}`,onClick:()=>we(Ht),children:l("forum.askVet.queue")}):null,gs.map(t=>e.jsx("button",{type:"button",className:`forum-pill ${G===t.value?"is-active":""}`,onClick:()=>we(t.value),children:t.label},t.value))]})]}),e.jsxs("div",{className:"forum-ask-vet-banner",children:[e.jsx("div",{className:"forum-ask-vet-banner__icon","aria-hidden":!0,children:e.jsx(Ps,{})}),e.jsxs("div",{className:"forum-ask-vet-banner__text",children:[e.jsx("h3",{children:l("forum.askVet.bannerTitle")}),e.jsx("p",{children:l("forum.askVet.bannerBody")})]}),e.jsx("button",{type:"button",onClick:()=>He("ask-vet"),children:l("forum.askVet.cta")})]}),e.jsx(Ya,{name:zt,onClick:()=>He("post")}),ae&&ee.length===0?e.jsx("div",{className:"forum-skeletons",children:[1,2,3,4,5].map(t=>e.jsxs("div",{className:"forum-skeleton-row",children:[e.jsx(jt,{className:"h-11 w-11 rounded-full"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(jt,{className:"h-4 w-1/3"}),e.jsx(jt,{className:"h-4 w-full"}),e.jsx(jt,{className:"h-4 w-2/3"})]})]},t))}):ge?e.jsxs("div",{className:"forum-error",children:[e.jsx(Ma,{className:"w-10 h-10 mx-auto mb-3 text-destructive"}),e.jsx("h3",{children:ge}),e.jsx(z,{onClick:()=>Ve(!0),variant:"outline",className:"mt-4",children:l("forum.retry")})]}):ee.length===0?e.jsxs("div",{className:"forum-empty",children:[e.jsx("h3",{children:l("forum.noContent")}),e.jsx("button",{type:"button",className:"forum-composer-prompt__cta mt-4",onClick:()=>He("post"),children:l("forum.createPost.button")})]}):e.jsxs("div",{className:"forum-feed",children:[ee.map(t=>{const a=be(t,t.author,t.authorId,s.language);return e.jsx(Qa,{post:t,authorName:a,timeAgo:Mt(t.createdAt,s.language),categoryLabel:t.category?$t(t.category,s.language):void 0,liked:O.has(t.id),liking:Ue.has(t.id),onOpen:()=>Et(t),onLike:i=>fs(t,i),onReply:i=>{i.stopPropagation(),Pt.current=!0,Et(t),wt()||et(null)},onShare:i=>_t(t,i),onOpenImage:i=>{Qe(i),_e(!0)}},t.id)}),ps(m,Js,Zs)]})]}),e.jsx(er,{searchQuery:Ie,onSearchChange:t=>{xt(t),r&&At()},onClearSearch:()=>{xt(""),Ve(!0),r&&At()},posts:Xs,onOpenPost:Et})]}),r?null:e.jsx("button",{type:"button",className:"forum-fab",onClick:()=>He("post"),"aria-label":l("forum.createPost.button"),children:e.jsx(Ta,{})}),e.jsx(Wa,{open:De,onOpenChange:t=>{fe(t),t||Ae("post")},onPostCreated:()=>Ve(!0),mode:$e}),e.jsx(st,{open:Vs,onOpenChange:t=>{if(xe(t),!t){if(te.current){te.current=!1;return}Fe(null),ve(""),Le.forEach(a=>{URL.revokeObjectURL(a.preview)}),Ke([])}},children:e.jsxs(We,{className:"sm:max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(rt,{children:e.jsx(qe,{children:M?s.language==="zh"?"回覆留言":"Reply to Comment":s.language==="zh"?"發表留言":"Post a Reply"})}),v?e.jsxs("form",{onSubmit:t=>{t.preventDefault(),Tt()},className:"space-y-4",children:[M&&(()=>{const t=be(M,M.author,M.authorId,s.language),a=/\[img\].*?\[\/img\]/gi.test(M.content),i=M.content.match(/\[img\](.*?)\[\/img\]/gi);return e.jsxs("div",{className:"p-3 bg-muted/40 border-l-4 border-[#FF902A]/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.language==="zh"?"回覆":"Replying to"," "]}),e.jsx("span",{className:"text-sm font-semibold",style:{color:Ss(t)},children:t})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-foreground
60/80 line-clamp-2",dangerouslySetInnerHTML:{__html:Yt(M.content.replace(/\[img\].*?\[\/img\]/gi,"").trim())}}),a&&i&&e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[i.slice(0,3).map((u,o)=>{const d=u.match(/\[img\](.*?)\[\/img\]/i),k=d?Qt(d[1]):"";return e.jsx("div",{className:"flex items-center gap-1.5",children:k?e.jsx("img",{src:k,alt:s.language==="zh"?"圖片":"Image",className:"w-12 h-12 object-cover rounded border border-border cursor-pointer hover:opacity-80",onClick:w=>{w.stopPropagation(),Qe(k),_e(!0)}}):e.jsx("span",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:s.language==="zh"?"[圖片]":"[Picture]"})},o)}),i.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",i.length-3," ",s.language==="zh"?"更多":"more"]})]})]})]})})(),e.jsxs("div",{className:"border border-border rounded-lg p-4 bg-background relative",children:[e.jsx(Jt,{value:ue,onChange:ve,placeholder:s.language==="zh"?"輸入您的留言...":"Enter your reply...",rows:16,maxLength:1e4,disabled:ct,onImageSelect:t=>{const a=t.map(o=>({id:`${Date.now()}-${Math.random()}`,file:o,preview:URL.createObjectURL(o)}));Ke(o=>[...o,...a]);const i=s.language==="zh"?"[圖片]":"[Image]",u=a.map(()=>i).join(" ");ve(o=>{const d=document.querySelector("textarea");if(d){const k=d.selectionStart,w=d.selectionEnd,b=o.substring(0,k),j=o.substring(w),c=(b&&!b.endsWith(" ")&&!b.endsWith(`
61`)?" ":"")+u+(j&&!j.startsWith(" ")&&!j.startsWith(`
62`)?" ":"");return b+c+j}return o+(o&&!o.endsWith(" ")?" ":"")+u})},imagePreviews:Le,onRemoveImage:t=>{Ke(a=>{const i=a.find(d=>d.id===t);i&&URL.revokeObjectURL(i.preview);const u=a.filter(d=>d.id!==t),o=s.language==="zh"?"[圖片]":"[Image]";return ve(d=>{const k=a.findIndex(c=>c.id===t);if(k===-1)return d;let w=0,b=0;for(let c=0;c<k;c++){const y=d.indexOf(o,b);if(y!==-1)w++,b=y+o.length;else break}let j=0;for(let c=0;c<=w;c++){const y=d.indexOf(o,j);if(y!==-1&&c===w)return d.substring(0,y)+d.substring(y+o.length).replace(/^\s+/,"");if(y!==-1)j=y+o.length;else break}return d}),u})}}),e.jsx("div",{className:"absolute bottom-4 right-4",children:e.jsx(z,{type:"submit",disabled:!ue.trim()||ct,className:"bg-[#FF902A] hover:bg-[#FF7A1A] text-white",size:"sm",children:ct?e.jsxs(e.Fragment,{children:[e.jsx(ot,{className:"h-4 w-4 mr-2 animate-spin"}),s.language==="zh"?"發表中...":"Posting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"h-4 w-4 mr-2"}),s.language==="zh"?"發表留言":"Post Reply"]})})})]}),e.jsx("div",{className:"flex items-center justify-start",children:e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ue.length,"/10000 ",s.language==="zh"?"字":"characters"]})})]}):e.jsxs("div",{className:"space-y-4",children:[M&&(()=>{const t=be(M,M.author,M.authorId,s.language);return e.jsx("div",{className:"p-3 bg-muted/40 border-l-4 border-primary/50 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.language==="zh"?"回覆":"Replying to"," "]}),e.jsx("span",{className:"text-sm font-semibold",style:{color:Ss(t)},children:t})]})})})(),e.jsxs("div",{className:"border border-border rounded-lg p-4 bg-background relative",children:[e.jsx(Jt,{value:ue,onChange:ve,placeholder:s.language==="zh"?"輸入您的留言...":"Enter your reply...",rows:16,maxLength:1e4,disabled:!1}),e.jsx("div",{className:"absolute bottom-4 right-4",children:e.jsxs(z,{type:"button",disabled:!ue.trim(),className:"bg-primary hover:bg-primary/90 text-primary-foreground",size:"sm",onClick:()=>Ft(!0),children:[e.jsx(Gt,{className:"h-4 w-4 mr-2"}),s.language==="zh"?"登入並發表":"Login & Post"]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.language==="zh"?"需要登入或建立帳戶後才能發表留言,您寫嘅內容會被保留":"Login or create an account to post. Your draft will be saved."})]})]})}),e.jsx(st,{open:Ws,onOpenChange:_e,children:e.jsxs(We,{className:"max-w-[95vw] max-h-[95vh] w-[95vw] h-[95vh] p-0 gap-0 bg-black/95 border-none overflow-hidden",children:[e.jsx(qe,{className:"sr-only",children:s.language==="zh"?"查看圖片":"View Image"}),e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center p-4 overflow-hidden",children:[e.jsx(z,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 z-50 text-white hover:bg-white/20 rounded-full",onClick:()=>_e(!1),children:e.jsx(it,{className:"h-6 w-6"})}),is&&e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:is,alt:"Full size",className:"max-w-full max-h-full w-auto h-auto object-contain rounded-lg",style:{maxWidth:"100%",maxHeight:"100%"},onClick:t=>t.stopPropagation()})})]})]})}),e.jsx(st,{open:qs,onOpenChange:t=>{},children:e.jsxs(We,{className:"sm:max-w-lg",children:[e.jsx(rt,{children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Fa,{className:"h-6 w-6 text-amber-600 dar
62k:text-amber-400"}),e.jsx(qe,{className:"text-xl font-semibold text-amber-900 dark:text-amber-100",children:s.language==="zh"?"重要聲明":"Important Notice"})]})}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"text-sm text-foreground space-y-3",children:[e.jsx("p",{children:s.language==="zh"?"本平台不鼓勵寵物買賣或任何形式的寵物繁殖活動。根據香港相關法規,寵物繁殖需要相關許可證。":"This platform does not encourage pet trading or any form of pet breeding activities. According to Hong Kong regulations, pet breeding requires relevant licenses."}),e.jsx("p",{className:"font-medium",children:s.language==="zh"?"本平台不對任何交易或繁殖相關活動承擔責任。用戶需自行承擔所有風險,並確保遵守香港相關法律法規。":"This platform does not assume responsibility for any trading or breeding-related activities. Users are responsible for all risks and must ensure compliance with relevant Hong Kong laws and regulations."})]})}),e.jsx(Es,{children:e.jsx(z,{onClick:()=>{sessionStorage.setItem("trading_disclaimer_acknowledged","true"),os(!1)},className:"bg-[#FF902A] hover:bg-[#FF7A1A] text-white w-full",children:s.language==="zh"?"我明白":"I Understand"})})]})}),e.jsx(st,{open:W,onOpenChange:$,children:e.jsxs(We,{className:"sm:max-w-md",children:[e.jsx(rt,{children:e.jsx(qe,{className:"text-2xl text-center",children:s.language==="zh"?"🎉 留言成功!":"🎉 Reply Posted!"})}),e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx("p",{className:"text-foreground font-medium",children:s.language==="zh"?"下載 PetWell App,即可免費獲得一個智能寵物名牌!":"Download PetWell App and get a FREE smart pet name tag!"}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s.language==="zh"?"🏷️ 每個名牌都有獨特嘅寵物專屬網頁,萬一寵物走失,拾獲者掃描名牌即可聯繫你。":"🏷️ Each tag has a unique pet profile page. If your pet gets lost, anyone who scans it can contact you."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.language==="zh"?"📱 App 仲有獸醫診所評價、寵物健康記錄等功能!":"📱 The app also features vet clinic reviews, pet health records and more!"})]}),e.jsx(z,{onClick:()=>{$(!1),window.open("/download","_blank")},className:"w-full bg-primary hover:bg-primary/90 text-primary-foreground font-semibold",size:"lg",children:s.language==="zh"?"立即下載,領取免費名牌":"Download Now & Get Free Tag"}),e.jsx(z,{variant:"ghost",onClick:()=>$(!1),className:"w-full text-muted-foreground",size:"sm",children:s.language==="zh"?"稍後再說":"Maybe Later"})]})]})})]})};export{Ur as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.