PageSourceSearch

https://bbcc.ai/build/assets/AISearchView-B78aEFeD.js

js bbcc.ai collected 2026-10-05 12:12:48 UTC 576,085 bytes, 3,628 lines download raw bytes

1import{r as s,j as e,b as B,H as br,L as xt,G as js}from"./app-DP13319Q.js";import{M as Pt,a as Lt,r as Bt}from"./index-WruS1vxz.js";import{E as Cs,l as Ns,u as Ss,a as Ms,P as As}from"./react-stripe.esm-D6Ettci4.js";import{F as m,S as Dt,V as kn,h as Yt,W as ba,X as oa,K as It,Y as Es,m as ya,o as zs,Z as Ts,k as Ee,a as bt,O as Sr,N as Mr,d as zr,x as va,B as wa,C as ka,E as ja,G as Ca,H as yr,I as Ps,f as gt,_ as Ls,$ as Bs,a0 as la,a1 as vr,i as da,a2 as wr,j as _s,J as bn,M as Yn,P as Ar,v as yn,a3 as Rs,a4 as ca,w as Fs,y as Is,z as Ds,A as Os,D as Hs}from"./index-CtyZ6W6U.js";import{M as Us}from"./react-tooltip.min-DW3XhwOj.js";import{E as Na,D as qs}from"./DraggableMenu-Bk7Spryo.js";import{S as Sa}from"./SocialMediaComposer-BYx7f4su.js";import{f as Ws,a as Gs,b as Zs,c as Ys,d as Vs,e as Xs,g as Qs,h as Ks}from"./index-DQkUn08L.js";import{Q as Js}from"./index-CMiBza1W.js";import{r as _t,H as vn,d as Vn}from"./index-Dtkw-V2D.js";import{M as $s}from"./react-masonry-css.module-Bp4sH3TF.js";/* empty css            *//* empty css            */const Ma=({isOpen:r,onClose:p,slug:y,url:v,title:T="Check out this post on Ez.wiki",description:N="",initialTab:_="share"})=>{const[q,n]=s.useState(_),[K,ke]=s.useState(!1),[H,W]=s.useState(!1),[me,_e]=s.useState(!1),[X,ie]=s.useState("iframe"),[re,be]=s.useState("500"),[F,oe]=s.useState("500"),[G,Ue]=s.useState(!0),[qe,Qe]=s.useState(!0),[We,De]=s.useState(!0),[ee,he]=s.useState(!1);s.useEffect(()=>{r&&n(_)},[r,_]);const A=v||(y?`${typeof window<"u"?window.location.origin:""}/X/${encodeURIComponent(y)}`:typeof window<"u"?window.location.href:""),pe=y||(A.split("/X/")[1]?decodeURIComponent(A.split("/X/")[1]):""),U=N?`${T} - ${N.slice(0,100)}`:T,S=re==="custom"?parseInt(F,10)||500:parseInt(re,10),se=["width: 100%",`height: ${S}px`];G?se.push("border: 1px solid #e5e7eb"):se.push("border: 0"),qe&&se.push("border-radius: 12px"),We&&se.push("box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"),se.push("overflow: hidden"),se.push("max-width: 100%");const ye=se.join("; "),Ne=(T||`Ez.wiki - ${pe||"Search"}`).replace(/"/g,"&quot;"),Se=(()=>{switch(X){case"card":return`<iframe src="${A}" width="100%" height="340" frameborder="0" style="border: 1px solid #e2e8f0; border-radius: 12px; max-width: 540px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);" title="${Ne}" loading="lazy" allow="clipboard-write"></iframe>`;case"responsive":return`<div style="position: relative; width: 100%; height: 0; padding-bottom: 65%; overflow: hidden; border-radius: ${qe?"12px":"0"}; ${G?"border: 1px solid #e5e7eb;":""} ${We?"box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);":""}">
2  <iframe src="${A}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;" title="${Ne}" loading="lazy" allow="clipboard-write"></iframe>
3</div>`;case"markdown":return`<!-- Ez.wiki Embed -->
4[![${Ne}](${A})](${A})
5
6<iframe src="${A}" width="100%" height="${S}" frameborder="0" style="${ye}"></iframe>`;case"iframe":default:return`<iframe src="${A}" width="100%" height="${S}" frameborder="0" style="${ye}" title="${Ne}" loading="lazy" allow="clipboard-write"></iframe>`}})();if(s.useEffect(()=>{const g=je=>{je.key==="Escape"&&r&&p()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r,p]),!r)return null;const Me=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(A);else{const g=document.createElement("input");g.value=A,document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g)}ke(!0),setTimeout(()=>ke(!1),2500)}catch(g){console.error("Failed to copy share URL:",g)}},h=async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(Se);else{const g=document.createElement("textarea");g.value=Se,document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g)}W(!0),setTimeout(()=>W(!1),2500)}catch(g){console.error("Failed to copy embed code:",g)}},ge=async()=>{if(navigator.share)try{await navigator.share({title:T||"Ez.wiki Share",text:U,url:A})}catch(g){g instanceof Error&&g.name!=="AbortError"&&console.error("Error sharing:",g)}},le=[{name:"Facebook",icon:Ws,bgClass:"bg-[#1877F2] hover:bg-[#1565C0] text-white",shareUrl:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(A)}`},{name:"X (Twitter)",icon:Gs,bgClass:"bg-black hover:bg-neutral-800 text-white",shareUrl:`https://twitter.com/intent/tweet?url=${encodeURIComponent(A)}&text=${encodeURIComponent(U)}`},{name:"WhatsApp",icon:Zs,bgClass:"bg-[#25D366] hover:bg-[#20bd5a] text-white",shareUrl:`https://api.whatsapp.com/se
6nd?text=${encodeURIComponent(`${U} ${A}`)}`},{name:"Telegram",icon:Ys,bgClass:"bg-[#24A1DE] hover:bg-[#1d8fc7] text-white",shareUrl:`https://t.me/share/url?url=${encodeURIComponent(A)}&text=${encodeURIComponent(U)}`},{name:"LinkedIn",icon:Vs,bgClass:"bg-[#0A66C2] hover:bg-[#084e96] text-white",shareUrl:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(A)}`},{name:"Reddit",icon:Xs,bgClass:"bg-[#FF4500] hover:bg-[#e03d00] text-white",shareUrl:`https://reddit.com/submit?url=${encodeURIComponent(A)}&title=${encodeURIComponent(U)}`},{name:"Threads",icon:Qs,bgClass:"bg-black hover:bg-neutral-800 text-white",shareUrl:`https://threads.net/intent/post?text=${encodeURIComponent(`${U} ${A}`)}`},{name:"Pinterest",icon:Ks,bgClass:"bg-[#E60023] hover:bg-[#c5001e] text-white",shareUrl:`https://pinterest.com/pin/create/button/?url=${encodeURIComponent(A)}&description=${encodeURIComponent(U)}`},{name:"Email",icon:ba,bgClass:"bg-gray-700 hover:bg-gray-800 text-white",shareUrl:`mailto:?subject=${encodeURIComponent(T)}&body=${encodeURIComponent(`${U}
7
8${A}`)}`}],xe=g=>{window.open(g,"_blank","noopener,noreferrer,width=600,height=500")};return e.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-xs transition-opacity duration-200",onClick:p}),e.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl max-w-lg w-full p-6 transform transition-all duration-200 border border-gray-100 z-10 max-h-[92vh] overflow-y-auto",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-gray-100 mb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-green-50 text-[#22c55e] flex items-center justify-center shadow-xs",children:e.jsx(m,{icon:q==="embed"?Dt:kn,className:"text-lg"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900 leading-tight",children:q==="embed"?"Embed Code":"Share Post"}),pe&&e.jsxs("p",{className:"text-xs text-gray-500 font-mono mt-0.5 flex items-center gap-1",children:[e.jsx("span",{children:"Slug:"}),e.jsxs("span",{className:"font-semibold text-emerald-600 bg-emerald-50 px-1.5 py-0.5 rounded text-[11px]",children:["X/",pe]})]})]})]}),e.jsx("button",{type:"button",onClick:p,className:"text-gray-400 hover:text-gray-600 p-1.5 rounded-lg hover:bg-gray-100 transition-colors focus:outline-none cursor-pointer","aria-label":"Close",children:e.jsx(m,{icon:Yt,className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-gray-100 rounded-xl mb-4 text-xs font-semibold",children:[e.jsxs("button",{type:"button",onClick:()=>n("share"),className:`flex-1 py-2 px-3 rounded-lg flex items-center justify-center gap-2 transition-all cursor-pointer ${q==="share"?"bg-white text-gray-900 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(m,{icon:kn,className:q==="share"?"text-[#22c55e]":""}),e.jsx("span",{children:"Share & Social"})]}),e.jsxs("button",{type:"button",onClick:()=>n("embed"),className:`flex-1 py-2 px-3 rounded-lg flex items-center justify-center gap-2 transition-all cursor-pointer ${q==="embed"?"bg-white text-gray-900 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(m,{icon:Dt,className:q==="embed"?"text-indigo-600":""}),e.jsx("span",{children:"Embed Code"}),e.jsx("span",{className:"bg-indigo-100 text-indigo-700 text-[10px] px-1.5 py-0.2 rounded-full font-bold",children:"</>"})]})]}),N&&e.jsx("div",{className:"p-3 bg-gray-50 rounded-xl border border-gray-100 mb-4",children:e.jsxs("p",{className:"text-xs text-gray-600 line-clamp-2 italic",children:['"',N,'"']})}),q==="share"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-2.5 flex items-center justify-between",children:e.jsx("span",{children:"Share to Social Media"})}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("embed"),className:"flex flex-col items-center justify-center p-2.5 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white transition-all duration-150 transform hover:-translate-y-0.5 hover:shadow-md cursor-pointer ring-2 ring-indigo-200",title:"Generate Embed Code",children:[e.jsx(m,{icon:Dt,className:"text-lg mb-1"}),e.jsx("span",{className:"text-[11px] font-semibold leading-tight",children:"Embed Code"})]}),le.map(g=>e.jsxs("button",{type:"button",onClick:()=>xe(g.shareUrl),className:`flex flex-col items-center justify-center p-2.5 rounded-xl transition-all duration-150 transform hover:-translate-y-0.5 hover:shadow-md cursor-pointer ${g.bgClass}`,title:`Share on ${g.name}`,children:[e.jsx(m,{icon:g.icon,className:"text-lg mb-1"}),e.jsx("span",{className:"text-[11px] font-medium leading-tight",children:g.name})]},g.name)),typeof navigator<"u"&&typeof navigator.share=="function"&&e.jsxs("button",{type:"button",onClick:ge,className:"flex flex-col items-center justify-center p-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 text-white transition-all duration-150 transform hover:-translate-y-0.5 hover:shadow-md cursor-pointer",title:"More Options",children:[e.jsx(m,{icon:kn,className:"text-lg mb-1"}),e.jsx("span",{className:"text-[11px] font-medium leading-tight",children:"More"})]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-2",children:"Direct Link"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"relative flex-1",children:e.jsx("input",{type:"text",readOnly:!0,value:A,onClick:g=>g.target.select(),className:"w-full bg-gray-50 border border-gray-200 text-gray-700 text-xs rounded-xl px-3.5 py-2.5 focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:bg-white font-mono"})}),e.jsxs("button",{type:"button",onClick:Me,className:`px-4 py-2.5 text-xs font-semibold rounded-xl transition-all duration-200 flex items-center gap-1.5 shadow-xs whitespace-nowrap cursor-pointer ${K?"bg-emerald-600 text-white shadow-emerald-200":"bg-[#22c55e] hover:bg-[#16a34a] text-white"}`,children:[e.jsx(m,{icon:K?oa:It,className:"w-3.5 h-3.5"}),e.jsx("span",{children:K?"Copied!":"Copy Link"})]})]})]}),e.jsxs("div",{className:"pt-3 border-t border-gray-100",children:[e.jsxs("button",{type:"button",onClick:()=>_e(!me),className:"w-full flex items-center justify-between text-xs font-medium text-gray-500 hover:text-gray-800 transition-colors py-1 focus:outline-none cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(m,{icon:Es,className:"text-gray-400"}),e.jsx("span",{children:me?"Hide QR Code":"Show QR Code for Mobile Scanning"})]}),e.jsx("span",{className:"text-[11px] text-gray-400",children:me?"▲":"▼"})]}),me&&e.jsxs("div",{className:"flex flex-col items-center justify-center p-4 bg-gray-50 rounded-xl mt-3 border border-gray-200/80",children:[e.jsx("div",{className:"p-3 bg-white rounded-xl shadow-xs border border-gray-100",children:e.jsx(Js,{value:A,size:148,level:"M",includeMargin:!1})}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-2.5 text-center",children:"Scan with phone camera or QR reader to open this 
8slug"})]})]})]}),q==="embed"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-gray-400 mb-2",children:"Embed Type"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-1.5",children:[{id:"iframe",label:"Standard iFrame",desc:"Full responsive"},{id:"card",label:"Card Widget",desc:"Compact mini-card"},{id:"responsive",label:"Aspect Ratio",desc:"Fluid container"},{id:"markdown",label:"Markdown",desc:"Obsidian / Docs"}].map(g=>e.jsxs("button",{type:"button",onClick:()=>ie(g.id),className:`p-2 rounded-xl text-left border transition-all cursor-pointer ${X===g.id?"border-indigo-600 bg-indigo-50/60 text-indigo-900 ring-1 ring-indigo-500":"border-gray-200 bg-gray-50/50 hover:bg-gray-100 text-gray-700"}`,children:[e.jsx("div",{className:"text-[11px] font-bold leading-tight",children:g.label}),e.jsx("div",{className:"text-[10px] text-gray-500 leading-tight mt-0.5",children:g.desc})]},g.id))})]}),X!=="card"&&X!=="responsive"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400",children:"Height (Pixels)"}),re==="custom"&&e.jsxs("span",{className:"text-xs text-indigo-600 font-mono font-bold",children:[S,"px"]})]}),e.jsx("div",{className:"flex items-center gap-1.5",children:[{id:"340",label:"340px (Compact)"},{id:"500",label:"500px (Default)"},{id:"650",label:"650px (Tall)"},{id:"custom",label:"Custom"}].map(g=>e.jsx("button",{type:"button",onClick:()=>be(g.id),className:`flex-1 py-1.5 px-2 rounded-lg text-xs font-medium border transition-colors cursor-pointer text-center ${re===g.id?"bg-indigo-600 text-white border-indigo-600":"bg-gray-50 hover:bg-gray-100 text-gray-700 border-gray-200"}`,children:g.label},g.id))}),re==="custom"&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"200",max:"1200",step:"20",value:F,onChange:g=>oe(g.target.value),className:"w-28 px-3 py-1.5 text-xs bg-gray-50 border border-gray-200 rounded-lg text-gray-800 font-mono focus:outline-none focus:ring-2 focus:ring-indigo-500",placeholder:"500"}),e.jsx("span",{className:"text-xs text-gray-500",children:"pixels height"})]})]}),X!=="markdown"&&e.jsxs("div",{className:"flex flex-wrap gap-3 py-2 px-3 bg-gray-50 rounded-xl border border-gray-100 text-xs text-gray-700",children:[e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:G,onChange:g=>Ue(g.target.checked),className:"rounded text-indigo-600 focus:ring-indigo-500"}),e.jsx("span",{children:"Border"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:qe,onChange:g=>Qe(g.target.checked),className:"rounded text-indigo-600 focus:ring-indigo-500"}),e.jsx("span",{children:"Rounded (12px)"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:We,onChange:g=>De(g.target.checked),className:"rounded text-indigo-600 focus:ring-indigo-500"}),e.jsx("span",{children:"Drop Shadow"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 flex items-center gap-1.5",children:[e.jsx(m,{icon:Dt,className:"text-indigo-500"}),e.jsx("span",{children:"HTML Embed Snippet"})]}),e.jsx("span",{className:"text-[11px] text-gray-400",children:"Ready to paste into HTML, WordPress, Notion, Obsidian, or Wiki"})]}),e.jsxs("div",{className:"relative group",children:[e.jsx("textarea",{readOnly:!0,rows:4,value:Se,onClick:g=>g.target.select(),className:"w-full bg-slate-900 text-emerald-400 font-mono text-[11px] p-3 rounded-xl border border-slate-800 focus:outline-none focus:ring-2 focus:ring-indigo-500 leading-relaxed resize-none shadow-inner"}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>he(!ee),className:"px-3 py-2 text-xs font-medium text-gray-600 hover:text-gray-900 bg-gray-100 hover:bg-gray-200 rounded-xl transition-colors flex items-center gap-1.5 cursor-pointer",children:[e.jsx(m,{icon:ya,className:"text-gray-500"}),e.jsx("span",{children:ee?"Hide Live Preview":"Show Live Preview"})]}),e.jsxs("button",{type:"button",onClick:h,className:`px-5 py-2 text-xs font-bold rounded-xl transition-all duration-200 flex items-center gap-2 shadow-sm whitespace-nowrap cursor-pointer ${H?"bg-emerald-600 text-white shadow-emerald-200 ring-2 ring-emerald-400":"bg-indigo-600 hover:bg-indigo-700 text-white"}`,children:[e.jsx(m,{icon:H?oa:It,className:"w-3.5 h-3.5"}),e.jsx("span",{children:H?"Embed Code Copied!":"Copy Embed Code"})]})]})]})]}),ee&&e.jsxs("div",{className:"p-3 bg-gray-50 rounded-xl border border-gray-200 animate-in fade-in duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-xs font-bold text-gray-700 flex items-center gap-1.5",children:[e.jsx(m,{icon:zs,className:"text-gray-500"}),e.jsx("span",{children:"Live Embed Preview"})]}),e.jsxs("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-indigo-600 hover:text-indigo-800 flex items-center gap-1 font-medium",children:[e.jsx("span",{children:"Open in new tab"}),e.jsx(m,{icon:Ts,className:"text-[10px]"})]})]}),e.jsx("div",{className:"w-full bg-white rounded-xl overflow-hidden border border-gray-200 shadow-xs",children:e.jsx("iframe",{src:A,title:"Embed Preview",className:"w-full",style:{height:`${Math.min(S,400)}px`},loading:"lazy"})})]}),e.jsxs("div",{className:"p-2.5 bg-indigo-50/50 rounded-xl border border-indigo-100 text-[11px] text-indigo-900/80 leading-normal flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-indigo-600",children:"Tip:"}),e.jsx("span",{children:"Paste this snippet directly inside any website, blog post, documentation page, or CMS. The embedded content stays automatically synced with Ez.wiki updates."})]})]})]})})]})}
8,ei=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml","application/pdf","video/mp4","video/webm","video/ogg","video/quicktime","video/x-msvideo","audio/mpeg","audio/mp3","audio/wav","audio/ogg","audio/webm","audio/x-wav","text/html","application/xhtml+xml"],ti=[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".pdf",".mp4",".webm",".ogg",".mov",".avi",".mp3",".wav",".ogg",".m4a",".html",".htm"],Aa=r=>{if(r===0)return"0 Bytes";const p=1024,y=["Bytes","KB","MB","GB"],v=Math.floor(Math.log(r)/Math.log(p));return parseFloat((r/Math.pow(p,v)).toFixed(2))+" "+y[v]},ni=r=>{if(r.size>100*1024*1024)return{valid:!1,error:`File size exceeds 100MB limit. Current size: ${Aa(r.size)}. Maximum allowed: 100MB.`};const p=r.name.toLowerCase(),y=ti.some(T=>p.endsWith(T));return!ei.includes(r.type)&&!y?{valid:!1,error:"File type is not supported. Please upload images (JPG, PNG, GIF, WEBP), PDF, video (MP4, WEBM, OGG), audio (MP3, WAV, OGG), or HTML files only. Max size: 100MB."}:{valid:!0}},ri=(r,p)=>r.startsWith("image/")?zr:r==="application/pdf"||p.toLowerCase().endsWith(".pdf")?va:r.includes("video/")||p.match(/\.(mp4|webm|ogg|mov|avi)$/i)?wa:r.includes("audio/")||p.match(/\.(mp3|wav|ogg|m4a)$/i)?ka:r.includes("html")||p.match(/\.(html|htm)$/i)?ja:Ca,kr={like:{type:"like",label:"Like",color:"#1877F2",bgColor:"bg-[#1877F2]",textColor:"text-[#1877F2]"},love:{type:"love",label:"Love",color:"#FA3E3E",bgColor:"bg-[#FA3E3E]",textColor:"text-[#FA3E3E]"},care:{type:"care",label:"Care",color:"#F7B125",bgColor:"bg-[#F7B125]",textColor:"text-[#F7B125]"},haha:{type:"haha",label:"Haha",color:"#F7B125",bgColor:"bg-[#F7B125]",textColor:"text-[#F7B125]"},wow:{type:"wow",label:"Wow",color:"#F7B125",bgColor:"bg-[#F7B125]",textColor:"text-[#F7B125]"},sad:{type:"sad",label:"Sad",color:"#F7B125",bgColor:"bg-[#F7B125]",textColor:"text-[#F7B125]"},angry:{type:"angry",label:"Angry",color:"#E02447",bgColor:"bg-[#E02447]",textColor:"text-[#E02447]"}},jr=({type:r,size:p="md"})=>{const y={sm:"w-4 h-4",md:"w-7 h-7",lg:"w-9 h-9"}[p];switch(r){case"like":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#1877F2] to-[#0D65D9] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsx("svg",{className:"w-[58%] h-[58%] text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})});case"love":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#FA3E3E] to-[#E02447] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsx("svg",{className:"w-[58%] h-[58%] text-white",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})});case"care":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#FFD966] to-[#F59E0B] flex items-center justify-center shadow-sm flex-shrink-0 select-none overflow-hidden relative`,children:e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 36 36",children:[e.jsx("circle",{fill:"#FFCC4D",cx:"18",cy:"18",r:"18"}),e.jsx("path",{fill:"#664500",d:"M10 13c1.2-1 2.8-1 4 0M22 13c1.2-1 2.8-1 4 0",stroke:"#664500",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("ellipse",{fill:"#664500",cx:"12",cy:"15",rx:"1.8",ry:"2.2"}),e.jsx("ellipse",{fill:"#664500",cx:"24",cy:"15",rx:"1.8",ry:"2.2"}),e.jsx("path",{fill:"#664500",d:"M14 21c1.2 1.5 2.8 2 4 2s2.8-.5 4-2",stroke:"#664500",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("path",{fill:"#E02447",d:"M18 28.5c-3-3.2-6-5.8-6-8.5 0-2 1.5-3.5 3.5-3.5 1.2 0 2.3.6 3 1.6.7-1 1.8-1.6 3-1.6 2 0 3.5 1.5 3.5 3.5 0 2.7-3 5.3-6 8.5z"}),e.jsx("path",{fill:"#FFD966",stroke:"#E59400",strokeWidth:"1",d:"M10 24c1.5-1 3.5 0 4 1.5M26 24c-1.5-1-3.5 0-4 1.5"})]})});case"haha":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#FFD966] to-[#F59E0B] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 36 36",children:[e.jsx("circle",{fill:"#FFCC4D",cx:"18",cy:"18",r:"18"}),e.jsx("path",{fill:"none",stroke:"#664500",strokeWidth:"2.4",strokeLinecap:"round",d:"M8.5 13.5c2-2 4.5-2 6.5 0M21 13.5c2-2 4.5-2 6.5 0"}),e.jsx("path",{fill:"#664500",d:"M8 19.5c0 5.5 4.5 9.5 10 9.5s10-4 10-9.5H8z"}),e.jsx("path",{fill:"#FF7088",d:"M13 25c1.2 1.5 3 2 5 2s3.8-.5 5-2c0 0-2 2.5-5 2.5s-5-2.5-5-2.5z"})]})});case"wow":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#FFD966] to-[#F59E0B] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 36 36",children:[e.jsx("circle",{fill:"#FFCC4D",cx:"18",cy:"18",r:"18"}),e.jsx("path",{fill:"none",stroke:"#664500",strokeWidth:"1.8",strokeLinecap:"round",d:"M9 9c2-2 5-2 7 0M20 9c2-2 5-2 7 0"}
8),e.jsx("ellipse",{fill:"#664500",cx:"12",cy:"14",rx:"2.4",ry:"3.2"}),e.jsx("ellipse",{fill:"#664500",cx:"24",cy:"14",rx:"2.4",ry:"3.2"}),e.jsx("ellipse",{fill:"#664500",cx:"18",cy:"24",rx:"4",ry:"5.5"})]})});case"sad":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#FFD966] to-[#F59E0B] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 36 36",children:[e.jsx("circle",{fill:"#FFCC4D",cx:"18",cy:"18",r:"18"}),e.jsx("path",{fill:"none",stroke:"#664500",strokeWidth:"1.8",strokeLinecap:"round",d:"M9 11c2 1 4 0 5-1M27 11c-2 1-4 0-5-1"}),e.jsx("ellipse",{fill:"#664500",cx:"11.5",cy:"15.5",rx:"2.2",ry:"2.8"}),e.jsx("ellipse",{fill:"#664500",cx:"24.5",cy:"15.5",rx:"2.2",ry:"2.8"}),e.jsx("path",{fill:"none",stroke:"#664500",strokeWidth:"2.2",strokeLinecap:"round",d:"M13 25c1.5-2 3.2-2.8 5-2.8s3.5.8 5 2.8"}),e.jsx("path",{fill:"#55ACEE",d:"M25 21.5c0 1.8-1.4 3-2.5 3s-2.5-1.2-2.5-3c0-1.5 2.5-4.5 2.5-4.5s2.5 3 2.5 4.5z"})]})});case"angry":return e.jsx("div",{className:`${y} rounded-full bg-gradient-to-b from-[#F2522B] to-[#D9381E] flex items-center justify-center shadow-sm flex-shrink-0 select-none`,children:e.jsxs("svg",{className:"w-full h-full",viewBox:"0 0 36 36",children:[e.jsx("circle",{fill:"#D9381E",cx:"18",cy:"18",r:"18"}),e.jsx("path",{fill:"none",stroke:"#262626",strokeWidth:"2.2",strokeLinecap:"round",d:"M8.5 12l6 3.5M27.5 12l-6 3.5"}),e.jsx("ellipse",{fill:"#FFFFFF",cx:"12",cy:"17",rx:"2.5",ry:"3"}),e.jsx("circle",{fill:"#000000",cx:"12.5",cy:"17",r:"1.4"}),e.jsx("ellipse",{fill:"#FFFFFF",cx:"24",cy:"17",rx:"2.5",ry:"3"}),e.jsx("circle",{fill:"#000000",cx:"23.5",cy:"17",r:"1.4"}),e.jsx("path",{fill:"none",stroke:"#FFFFFF",strokeWidth:"2.2",strokeLinecap:"round",d:"M12.5 26c1.8-2 3.5-2.8 5.5-2.8s3.7.8 5.5 2.8"})]})})}},Cr=({messageId:r,messageSlug:p,initialLikes:y=0,initialComments:v=0,initialVisits:T=0,initialReactions:N={},onAddComment:_,conversationId:q=null,currentUser:n=null,messageQuery:K="",messageResponse:ke=null,shareUrl:H,onReplyPost:W,onReplyAskAI:me,onReplyUpload:_e,onCommentAdded:X,onCommentDeleted:ie})=>{const re=!!n,be=s.useCallback(()=>{if(typeof window>"u")return null;try{const f=localStorage.getItem(`ez_reaction_${r}`)||localStorage.getItem(`ez_reaction_${p}`);if(f&&["like","love","care","haha","wow","sad","angry"].includes(f))return f}catch{}return null},[r,p]),[F,oe]=s.useState({total:y||0,breakdown:{like:N.like||Math.max(0,Math.round((y||0)*.65)),love:N.love||Math.max(0,Math.round((y||0)*.2)),care:N.care||Math.max(0,Math.round((y||0)*.08)),haha:N.haha||Math.max(0,Math.round((y||0)*.04)),wow:N.wow||Math.max(0,Math.round((y||0)*.02)),sad:N.sad||0,angry:N.angry||0},comments:v||0,visits:T||0}),[G,Ue]=s.useState(be),[qe,Qe]=s.useState(!0),[We,De]=s.useState(!1),[ee,he]=s.useState(!1),[A,pe]=s.useState(null),[U,S]=s.useState(!1),[se,ye]=s.useState(!1),[Ne,M]=s.useState(!1),[Se,Me]=s.useState("social"),[h,ge]=s.useState("composer"),[le,xe]=s.useState("markdown"),[g,je]=s.useState(""),[de,yt]=s.useState(null),[Vt,jn]=s.useState(""),[sn,Oe]=s.useState(null),[on,Ot]=s.useState(!1),[Cn,Nn]=s.useState(!1),ze=s.useRef(null),[Sn,vt]=s.useState(""),[wt,it]=s.useState(null),[Tr,kt]=s.useState(!1),[Xn,Xt]=s.useState(!1),[Ke,Qn]=s.useState([]),[Qt,Mn]=s.useState(!1),[ln,jt]=s.useState(!1),Ct=s.useRef(null),An=s.useRef(null),Re=s.useRef(!0),ot=s.useCallback(async()=>{var f,I;if(!(!r&&!p)){Mn(!0);try{const j=new URLSearchParams;r&&j.append("message_id",String(r)),p&&j.append("message_slug",p);const R=await B.get(`/comments?${j.toString()}`);(f=R.data)!=null&&f.success&&Array.isArray((I=R.data)==null?void 0:I.data)&&Re.current&&(Qn(R.data.data),R.data.total!==void 0&&oe(D=>({...D,comments:R.data.total})))}catch(j){console.warn("Comments fetch notice:",j)}finally{Re.current&&Mn(!1)}}},[r,p]);s.useEffect(()=>{U&&ot()},[U,ot]);const ve=["like","love","care","haha","wow","sad","angry"],En=s.useCallback(async()=>{var f,I,j,R,D,J,ae;if(!r){Qe(!1);return}Qe(!0);try{const te=await B.get(`/api/reactions/${r}`);if(te.data.success&&Re.current){const Q=te.data.data,cn={like:((f=Q.breakdown)==null?void 0:f.like)||0,love:((I=Q.breakdown)==null?void 0:I.love)||0,care:((j=Q.breakdown)==null?void 0:j.care)||0,haha:((R=Q.breakdown)==null?void 0:R.haha)||0,wow:((D=Q.breakdown)==null?void 0:D.wow)||0,sad:((J=Q.breakdown)==null?void 0:J.sad)||0,angry:((ae=Q.breakdown)==null?void 0:ae.angry)||0};if(oe(He=>({...He,total:Q.total||0,breakdown:cn,comments:Q.comments_count!==void 0?Q.comments_count:He.comments,visits:Q.visits_count!==void 0?Q.visits_count:He.visits})),Q.user_reaction){Ue(Q.user_reaction);try{localStorage.setItem(`ez_reaction_${r}`,Q.user_reaction)}catch(He){console.warn(He)}}else{const He=be();He&&Ue(He)}}}catch(te){console.warn("Reactions fetch notice:",te)}finally{Re.current&&Qe(!1)}},[r,be]);s.useEffect(()=>(Re.current=!0,En(),()=>{Re.current=!1}),[En]);const Z=async f=>{if(!r)return;const I=G;let j;const R={...F.breakdown};let D=F.total;if(I===f){j=null,R[f]=Math.max(0,(R[f]||0)-1),D=Math.max(0,D-1);try{localStorage.removeItem(`ez_reaction_${r}`),localStorage.removeItem(`ez_reaction_${p}`)}catch(J){console.warn(J)}}else{I?R[I]=Math.max(0,(R[I]||0)-1):D+=1,R[f]=(R[f]||0)+1,j=f;try{localStorage.setItem(`ez_reaction_${r}`,f),localStorage.setItem(`ez_reaction_${p}`,f)}catch(J){console.warn(J)}}oe(J=>({...J,total:D,breakdown:R})),Ue(j);try{const J=await B.post("/api/reactions/toggle",{message_id:r,message_slug:p,reaction_type:f});if(J.data.success&&Re.current){const ae=J.data.data;oe(te=>({...te,total:ae.total??te.total,breakdown:ae.breakdown||te.breakdown,visits:ae.visits_count!==void 0?ae.visits_count:te.visits})),ae.user_reaction!==void 0&&Ue(ae.user_reaction)}}catch(J){console.warn("Reactions toggle notice:",J)}De(!1),pe(null)},Ht=()=>{Z(G||"like")},ce=()=>{M(!0)},dn=async(f,I,j)=>{var R;if(!(!f.trim()&&I.length===0)){ye(!0);try{try{const D=await B.post("/comments",{content:f,message_id:r,message_slug:p,conversation_id:q,media:I,content_warning:j,format:le,content_type:"comment"});(R=D.data)!=null&&R.success&&(ot(),oe(J=>{var ae;return{...J,comments:((ae=D.data)==null?void 0:ae.comments_count)!==void 0?D.data.comments_count:(J.comments||0)+1}}),X==null||X())}catch(D){console.warn("Comments API note:",D)}Me("social"),ge("composer")}catch(D){console.error("Error posting reply:",D)}finally{ye(!1)}}},lt=async()=>{var j,R,D,J,ae;if(!g.trim()||se)return;ye(!0);const f=g.trim(),I=((j=document.querySelector('meta[name="csrf-token"]'))==null?void 0:j.getAttribute("content"))||"";try{const te=await B.post("/searchai/ai",{query:f,conversation_id:q,parent_slug:p,message_id:r,as_comment:!0,enable_thinking:!1},{headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":I}});(R=te.data)!=null&&R.success?(ot(),oe(Q=>({...Q,comments:te.data.comments_count!==void 0?te.data.comments_count:(Q.comments||0)+2})),X==null||X(),je(""),S(!0)):alert(((D=te.data)==null?void 0:D.message)||"Failed to get AI response")}catch(te){console.error("Error asking AI for comment:",te);const Q=((ae=(J=te==null?void 0:te.response)==null?void 0:J.data)==null?void 0:ae.message)||(te==null?void 0:te.message)||"Failed to get AI response. Please try again.";alert(Q)}finally{ye(!1)}},Kn=f=>{Oe(null);const I=ni(f);if(!I.valid){Oe(I.error||"Invalid file type"),ze.current&&(ze.current.value="");return}if(f.type.startsWith("image/")){const j=new FileReader;j.onload=R=>{var D;yt({file:f,name:f.name,size:f.size,type:f.type,dataUrl:(D=R.target)==null?void 0:D.result})},j.readAsDataURL(f)}else yt({file:f,name:f.name,size:f.size,type:f.type})},P=f=>{var j;const I=(j=f.target.files)==null?void 0:j[0];I&&Kn(I)},Ge=f=>{f.preventDefault(),f.stopPropagation(),Nn(!0)},dt=f=>{f.preventDefault(),f.stopPropagation(),Nn(!1)},Kt=f=>{var j;f.preventDefault(),f.stopPropagation(),Nn(!1);const I=(j=f.dataTransfer.files)==null?void 0:j[0];I&&Kn(I)},Je=()=>{yt(null),Oe(null),ze.current&&(ze.current.value="")},w=async()=>{var f,I;if(!re){jt(!0);return}if(!de){Oe("Please select a file to upload");return}Ot(!0),Oe(null);try{const j=new FormData;de.file?j.append("file",de.file):de.dataUrl&&j.append("media[]",de.dataUrl),j.append("content",Vt.trim()||`Attachment: ${de.name}`),j.append("description",Vt.trim()||`Attachment: ${de.name}`),r&&j.append("message_id",String(r)),p&&j.append("message_slug",p),q&&j.append("conversation_id",q),j.append("format","markdown"),j.append("content_type","upload");const R=await B.post("/comments",j,{headers:{"Content-Type":"multipart/form-data","X-CSRF-TOKEN":((f=d
8ocument.querySelector('meta[name="csrf-token"]'))==null?void 0:f.getAttribute("content"))||""}});(I=R.data)!=null&&I.success&&(ot(),oe(D=>{var J;return{...D,comments:((J=R.data)==null?void 0:J.comments_count)!==void 0?R.data.comments_count:(D.comments||0)+1}}),X==null||X()),yt(null),jn(""),ze.current&&(ze.current.value=""),Me("social"),ge("composer")}catch(j){console.error("Error uploading file in reply:",j),Oe(j instanceof Error?j.message:"Failed to upload file. Please try again.")}finally{Ot(!1)}},ct=()=>{Ct.current&&clearTimeout(Ct.current),De(!0)},Jt=()=>{Ct.current=setTimeout(()=>{ee||(De(!1),pe(null))},300)},Ze=s.useCallback(()=>{Me("social"),ge("composer"),je(""),yt(null),jn(""),Oe(null),vt(""),it(null),ze.current&&(ze.current.value="")},[]),Ut=s.useCallback(()=>{if(!re){jt(!0);return}U&&Ze(),S(f=>!f)},[re,U,Ze]),qt=Object.entries(F.breakdown).filter(([,f])=>f>0).sort((f,I)=>I[1]-f[1]).map(([f])=>f).slice(0,3),$e=G?kr[G]:null,Ce=()=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 sm:p-4 border-b border-gray-200 overflow-x-auto no-scrollbar flex-nowrap sm:flex-wrap",children:[e.jsx("button",{onClick:()=>{Me("social"),ge("composer")},className:`px-4 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none ${Se==="social"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"})]}),e.jsx("span",{children:"Social & Upload"})]})}),e.jsx("button",{onClick:()=>Me("text"),className:`px-4 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none ${Se==="text"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7v8H3v-8a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-1.01-1-1.73a2 2 0 0 1 2-2Z"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M12 9v6"})]}),e.jsx("span",{children:"Ask AI"})]})})]}),e.jsx("div",{className:"p-6",children:Se==="social"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3 border-b border-gray-200 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>{xe("markdown"),ge("composer")},className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${le==="markdown"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"Markdown"}),e.jsx("button",{onClick:()=>{xe("html"),ge("composer")},className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${le==="html"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"HTML"})]}),e.jsx("div",{className:"h-6 w-px bg-gray-200"}),e.jsxs("button",{onClick:()=>ge("upload"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${h==="upload"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Upload Media"]}),e.jsxs("button",{onClick:()=>ge("embed"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${h==="embed"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Embed Content"]})]}),h==="upload"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-[#22c55e]",children:e.jsx("path",{d:"M4 16l4.586-4.586a2 2 0 0 1 2.828 0L16 16m-2-2l1.586-1.586a2 2 0 0 1 2.828 0L20 14m-6-6h.01M6 20h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Upload Files"}),e.jsx("span",{className:"text-xs text-gray-400",children:"• Images, PDF, Video, Audio, HTML up to 100MB"})]}),sn&&e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 rounded-xl text-sm text-red-600 flex items-center gap-2",children:[e.jsx(m,{icon:bt,className:"text-red-500 flex-shrink-0 text-sm"}),e.jsx("span",{children:sn})]}),de?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-3.5 bg-gray-50 border border-gray-200 rounded-xl",children:[e.jsxs("div",{className:"flex items-center space-x-3 min-w-0",children:[e.jsx("div",{className:"w-12 h-12 bg-[#22c55e]/10 rounded-lg flex items-center justify-center flex-shrink-0 overflow-hidden",children:de.dataUrl?e.jsx("img",{src:de.dataUrl,alt:de.name,className:"w-12 h-12 object-cover rounded-lg"}):e.jsx(m,{icon:ri(de.type,de.name),className:"text-[#22c55e] text-xl"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:de.n
8ame}),e.jsx("p",{className:"text-xs text-gray-500",children:Aa(de.size)})]})]}),e.jsx("button",{type:"button",onClick:Je,className:"p-1.5 text-gray-400 hover:text-red-500 rounded-lg hover:bg-white transition-colors",title:"Remove file",children:e.jsx(m,{icon:Yt,className:"w-4 h-4"})})]}),e.jsx("input",{type:"text",value:Vt,onChange:f=>jn(f.target.value),placeholder:"Add a description (optional)",className:"w-full px-3.5 py-2.5 text-sm border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#22c55e] focus:border-transparent",disabled:on}),e.jsx("button",{type:"button",onClick:w,disabled:on,className:"w-full px-4 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white font-medium rounded-xl transition-colors flex items-center justify-center space-x-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-sm",children:on?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),e.jsx("span",{children:"Uploading File..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Sr,className:"w-4 h-4"}),e.jsx("span",{children:"Upload & Reply"})]})})]}):e.jsxs("div",{onClick:()=>{var f;return(f=ze.current)==null?void 0:f.click()},onDragOver:Ge,onDragLeave:dt,onDrop:Kt,className:`relative border-2 border-dashed rounded-xl p-8 text-center transition-colors cursor-pointer ${Cn?"border-[#22c55e] bg-green-50/50":"border-gray-300 bg-gray-50 hover:border-[#22c55e] hover:bg-gray-100"}`,children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"w-12 h-12 mb-3 rounded-full bg-white shadow-sm border border-gray-200 flex items-center justify-center text-gray-400",children:e.jsx(m,{icon:Sr,className:"text-lg text-gray-500"})}),e.jsxs("p",{className:"text-sm text-gray-600",children:[e.jsx("span",{className:"font-semibold text-[#22c55e]",children:"Click to upload"})," or drag & drop"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"✅ Images (JPG, PNG, GIF, WEBP) • PDF • Video (MP4, WEBM, OGG) • Audio (MP3, WAV, OGG) • HTML"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Max size: 100MB"})]}),e.jsx("input",{ref:ze,type:"file",className:"hidden",accept:"image/*,.pdf,video/*,audio/*,.mp4,.webm,.ogg,.mp3,.wav,.mov,.avi,.m4a,.html,.htm",onChange:P})]})]}):h==="embed"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-[#22c55e]",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Embed Content"}),F.comments>0&&e.jsx("span",{className:"text-xs bg-[#22c55e] text-white px-2 py-0.5 rounded-full",children:F.comments})]}),F.comments>0&&e.jsx("div",{className:"mb-4 p-3 bg-gray-50 rounded-lg border border-gray-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[e.jsx(m,{icon:Mr,className:"mr-2 text-[#22c55e]"}),F.comments," comment",F.comments>1?"s":""," in this conversation"]}),e.jsx("span",{className:"text-xs text-gray-400",children:"View in conversation above"})]})}),wt&&e.jsxs("div",{className:"p-3 bg-red-50 border border-red-200 rounded-xl text-sm text-red-600 flex items-center gap-2",children:[e.jsx(m,{icon:bt,className:"text-red-500 flex-shrink-0 text-sm"}),e.jsx("span",{children:wt})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed border-gray-200 rounded-xl bg-gray-50",children:[e.jsx("div",{className:"w-16 h-16 bg-white rounded-full flex items-center justify-center shadow-sm mb-4",children:e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"9",y1:"21",x2:"9",y2:"9"})]})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Embed Row & Masonry Builder"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 text-center max-w-md",children:"Create beautiful rows, carousels, or masonry layouts with your embed snippets."}),e.jsxs("button",{onClick:()=>Xt(!0),className:"px-6 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white font-medium rounded-xl transition-colors shadow-sm flex items-center gap-2",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M15 3h6v6M14 10l6.1-6.1M9 21H3v-6M10 14l-6.1 6.1"})}),"Open Embed Builder"]})]}),e.jsx(Na,{isOpen:Xn,onClose:()=>Xt(!1),parentSlug:p,conversationId:q||void 0,onChildConvoCreated:async(f,I)=>{await dn(f,[],null),S(!1),Xt(!1)},onCommentCreated:f=>{X==null||X()}})]}):e.jsx(Sa,{onPost:dn,className:"w-full",conversationId:q,contentFormat:le})]}):e.jsxs("form",{onSubmit:f=>{f.preventDefault(),lt()},children:[e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:g,onChange:f=>je(f.target.value),placeholder:"Ask a follow-up question... (Press Enter to send, Shift+Enter for new line)",className:"w-full bg-gray-50 border border-gray-200 rounded-lg py-3 px-4 pr-32 text-sm focus:outline-none focus:ring-2 focus:ring-[#22c55e] min-h-[100px] resize-y",rows:3,disabled:se}),e.jsx("div",{className:"absolute bottom-3 right-16",children:e.jsx("button",{type:"submit",disabled:!g.trim()||se,className:"px-4 py-2 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:se?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),e.jsx("span",{children:"Asking..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7v8H3v-8a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-1.01-1-1.73a2 2 0 0 1 2-2Z"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M12 9v6"})]}),e.jsx("span",{children:"Ask AI"})]})})})]}),e.jsx("div",{className:"flex items-center justify-between mt-4 text-sm text-gray-500",children:e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{children:"Press Enter to send"}),e.jsx("span",{children:"•"}),e.jsx("span",{children:"Shift+Enter for new line"})]})})]})})]});return qe&&F.total===0?e.jsx("div",{className:"w-full mt-2 pt-2 border-t border-gray-100/80",children:e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400",children:[e.jsx(m,{icon:Ee,className:"animate-spin w-3 h-3"}),e.jsx("span",{children:"Loading reactions..."})]})}):e.jsxs("div",{className:"w-full mt-2 pt-2 border-t border-gray-100/80",children:[ln&&e.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:()=>jt(!1)}),e.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:e.jsxs("div",{className:"relative bg-white rounded-xl shadow-xl max-w-md w-full p-6 transform transition-all",children:[e.jsx("button",{onClick:()=>jt(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4"}),e.jsx("path",{d:"M12 16h.01"})]})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Login Required"}),e.jsx("p",{className:"text-gray-600",children:"Please log in to react to messages."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("a",{href:"/login",className:"block w-full px-4 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium text-center",children:"Log In"}),e.jsx("a",{href:"/register",className:"block w-full px-4 py-3 border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-lg transition-colors font-medium text-center",children:"Create Account"}),e.jsx("button",{onClick:()=>jt(!1),className:"block w-full px-4 py-3 text-gray-500 hover:text-gray-700 transition-colors font-medium text-center",children:"Close"})]})]})})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs select-none",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{ref:An,className:"relative",onMouseEnter:ct,onMouseLeave:Jt,children:[We&&e.jsx("div",{className:"absolute bottom-full left-0 mb-2 z-40 bg-white/95 backdrop-blur-sm rounded-full py-1 px-2 shadow-2xl border border-gray-200/80 flex items-center gap-1.5 animate-in fade-in zoom-in-95 duration-150",onMouseEnter:()=>{Ct.current&&clearTimeout(Ct.current),he(!0)},onMouseLeave:()=>{he(!1),De(!1),pe(null)},children:ve.map(f=>{const I=A===f,j=G===f;return e.jsxs("button",{type:"button",onClick:R=>{R.stopPropagation(),Z(f)},onMouseEnter:()=>pe(f),className:`relative p-1 rounded-full transition-all duration-150 transform hover:-translate-y-1.5 hover:scale-125 focus:outline-none cursor-pointer ${j?"ring-2 ring-[#22c55e] ring-offset-1 scale-110":""}`,title:kr[f].label,children:[e.jsx(jr,{type:f,size:"md"}),I&&e.jsx("span",{className:"absolute -top-7 left-1/2 transform -translate-x-1/2 bg-gray-900/90 text-white text-[10px] font-medium py-0.5 px-2 rounded-full whitespace-nowrap pointer-events-none shadow-md",children:kr[f].label})]},f)})}),e.jsxs("button",{type:"button",onClick:Ht,className:`flex items-center gap-1.5 px-2 py-1 rounded-lg transition-colors focus:outline-none cursor-pointer ${G?`${($e==null?void 0:$e.textColor)||"text-blue-600"} font-semibold bg-gray-50`:"text-gray-500 hover:text-[#22c55e] hover:bg-gray-50"}`,children:[G?e.jsx(jr,{type:G,size:"sm"}):e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 10v12"}),e.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h3"})]}),e.jsx("span",{className:"text-xs font-medium",children:F.total>0?F.total:"Like"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg text-gray-500 hover:text-gray-700 select-none cursor-default",title:`${F.visits.toLocaleStr
8ing()} visit${F.visits===1?"":"s"}`,children:[e.jsx(m,{icon:ya,className:"w-3.5 h-3.5 text-gray-400"}),e.jsx("span",{className:"text-xs font-medium",children:F.visits.toLocaleString()})]}),e.jsxs("button",{type:"button",onClick:Ut,className:`flex items-center gap-1.5 px-2 py-1 rounded-lg transition-colors focus:outline-none cursor-pointer ${U&&re?"text-[#22c55e] bg-green-50/60 font-semibold":"text-gray-500 hover:text-[#22c55e] hover:bg-gray-50"}`,title:re?"Comment":"Login to comment",children:[e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("span",{className:"text-xs font-medium",children:F.comments>0?F.comments:"Comment"})]}),e.jsxs("button",{type:"button",onClick:ce,className:"flex items-center gap-1.5 px-2 py-1 rounded-lg transition-colors focus:outline-none text-gray-500 hover:text-[#22c55e] hover:bg-gray-50 cursor-pointer",title:"Share slug on social media",children:[e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"m15 14 5-5-5-5"}),e.jsx("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5v2.5"})]}),e.jsx("span",{className:"text-xs font-medium",children:"Share"})]})]}),qt.length>0&&F.total>0&&e.jsxs("div",{className:"flex items-center gap-1 cursor-pointer group/summary",onClick:ct,children:[e.jsx("div",{className:"flex items-center -space-x-1.5",children:qt.map(f=>e.jsx("div",{className:"ring-1 ring-white rounded-full transition-transform group-hover/summary:scale-110",children:e.jsx(jr,{type:f,size:"sm"})},f))}),e.jsx("span",{className:"text-[11px] font-semibold text-gray-500 group-hover/summary:text-gray-800 ml-1",children:F.total})]})]}),U&&re&&Ce(),e.jsx(Ma,{isOpen:Ne,onClose:()=>M(!1),slug:p,url:H||(typeof window<"u"?`${window.location.origin}/X/${encodeURIComponent(p)}`:""),title:K?K.length>60?K.slice(0,60)+"...":K:`Ez.wiki - ${p}`,description:K||ke||""})]})},ai=`(function(){\r
9const VERSION='V618.19';\r
10const MODEL_W=380,MODEL_H=285;   /* 3D 卡的預設尺寸(4:3) */\r
11function verBadge(){if(document.getElementById('verBadge'))return;const d=document.createElement('div');d.id='verBadge';d.className='ver-badge';d.textContent=VERSION;document.body.appendChild(d);}\r
12const STD_W=340,STD_H=220,HTML_W=520,HTML_H=720,GRID=20,MIN=120,MAX=4000,DAY=86400000;\r
13const YT=/(?:youtube\\.com\\/(?:embed\\/|watch\\?v=|shorts\\/|live\\/)|youtube-nocookie\\.com\\/embed\\/|youtu\\.be\\/)([a-zA-Z0-9_-]{11})/;\r
14const ESC={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'};\r
15function esc(s){return String(s==null?'':s).replace(/[&<>"']/g,c=>ESC[c]);}\r
16function httpUrl(s){try{const u=new URL(String(s));return (u.protocol==='http:'||u.protocol==='https:')?u.href:'';}catch(e){return '';}}\r
17function size(v,d){v=Math.round(Number(v));return Number.isFinite(v)&&v>=MIN&&v<=MAX?v:d;}\r
18function uid(){return Math.random().toString(36).slice(2,10)+Date.now().toString(36).slice(-4);}\r
19/* 一般 Spotify 網址自動轉成嵌入網址 */\r
20function toEmbed(u){\r
21  try{const x=new URL(u);\r
22    if(x.hostname==='open.spotify.com'){const m=x.pathname.match(/^\\/(?:intl-[a-z-]+\\/)?(?:embed\\/)?(track|episode|show|album|playlist|artist)\\/([A-Za-z0-9]+)/);\r
23      if(m)return 'https://open.spotify.com/embed/'+m[1]+'/'+m[2]+x.search;}\r
24  }catch(e){}\r
25  return u;\r
26}\r
27/* 每張卡的「合身規則」:\r
28   fixed=固定內容高度(Spotify、SoundCloud、Apple Podcasts、嵌入碼寫了 height 但寬度是 %)\r
29   ratio=固定比例(YouTube、Vimeo、嵌入碼寬高都是數字)\r
30   auto =HTML 嵌入碼,由 iframe 內回報實際高度\r
31   page =一般網頁,看不到內容高度,用版面預設比例 */\r
32function attrNum(raw,name){const m=String(raw).match(new RegExp('\\\\s'+name+'\\\\s*=\\\\s*["\\']?\\\\s*([0-9.]+)\\\\s*(%)?','i'));return m?{v:parseFloat(m[1]),pct:!!m[2]}:null;}\r
33function fitOf(o){\r
34  if(isTomb(o))return {t:'fixed',h:250};\r
35  if(o.type==='youtube')return {t:'ratio',r:16/9};\r
36  if(o.type==='html'||o.type==='md')return {t:'auto'};\r
37  /* 3D 視窗用固定長寬比,不隨內容變高,也不需要量高度 */\r
38  if(o.type==='model')return {t:'ratio',r:4/3};\r
39  const raw=String(o._raw||''),u=String(o.url||'');\r
40  /* Facebook 外掛:影片區依寬度等比縮放,下方貼文文字/按讚列高度固定 */\r
41  const fbm=u.match(/^https:\\/\\/(?:www\\.)?facebook\\.com\\/plugins\\/[^?]+\\?(.*)$/);\r
42  if(fbm){const q=new URLSearchParams(fbm[1]),uw=+q.get('width'),uh=+q.get('height'),H=(attrNum(raw,'height')||{}).v;\r
43    if(uw>0&&uh>0)return {t:'lin',r:uh/uw,x:H>uh?Math.round(H-uh):0};}\r
44  const ifr=(raw.match(/<iframe\\b[^>]*>/i)||[])[0];\r
45  if(ifr){\r
46    const w=attrNum(ifr,'width'),h=attrNum(ifr,'height');\r
47    if(h&&!h.pct&&h.v>=40){if(w&&!w.pct&&w.v>0)return {t:'ratio',r:w.v/h.v};return {t:'fixed',h:Math.round(h.v)};}\r
48  }\r
49  let host='';try{host=new URL(u).hostname;}catch(e){}\r
50  if(host==='open.spotify.com'&&/\\/embed\\//.test(u))return {t:'fixed',h:/\\/embed\\/(track|episode)\\//.test(u)?232:352};\r
51  if(host==='w.soundcloud.com')return {t:'fixed',h:166};\r
52  if(/(^|\\.)sketchfab\\.com$/.test(host)&&/\\/embed/.test(u))return {t:'ratio',r:4/3};\r
53  if(host==='embed.podcasts.apple.com')return {t:'fixed',h:/[?&]i=/.test(u)?175:450};\r
54  if(host==='player.vimeo.com'||host==='player.bilibili.com'||(host==='www.dailymotion.com'&&/\\/embed\\//.test(u)))return {t:'ratio',r:16/9};\r
55  return {t:'page'};\r
56}\r
57/* 已知會拒絕被嵌入(X-Frame-Options/CSP frame-ancestors)的網站;路徑含 embed/preview/pub 的例外 */\r
58const NO_FRAME=/(^|\\.)(google\\.[a-z.]+|facebook\\.com|fb\\.com|instagram\\.com|threads\\.net|x\\.com|twitter\\.com|linkedin\\.com|github\\.com|gitlab\\.com|amazon\\.[a-z.]+|reddit\\.com|stackoverflow\\.com|stackexchange\\.com|medium\\.com|apple\\.com|openai\\.com|chatgpt\\.com|claude\\.ai|notion\\.so|paypal\\.com|netflix\\.com|discord\\.com|tiktok\\.com|zhihu\\.com|weibo\\.com|ebay\\.[a-z.]+|dropbox\\.com|zoom\\.us|youtube\\.com|figma\\.com|canva\\.com)$/i;\r
59/* 官方嵌入網址一律放行:…/embed、/preview、/pub、Facebook 的 /plugins/…、embed.xxx 子網域(embed.reddit.com、embed.music.apple.com) */\r
60const FRAME_OK=/\\/(embed|preview|pub|pubhtml|plugins)(\\/|\\?|$)|[?&](embed|output=embed)/i;\r
61function knownBlocked(u){try{const x=new URL(u);return NO_FRAME.test(x.hostname)&&!/^embed\\./i.test(x.hostname)&&!FRAME_OK.test(x.pathname+x.search);}catch(e){return false;}}\r
62/* emb:'no'=手動標成墓碑、'yes'=手動強制嵌入;blk=伺服器檢查判定不能嵌å
62…¥ */\r
63function isTomb(o){return o.type==='web'&&(o.emb==='no'||(o.emb!=='yes'&&(o.blk||knownBlocked(o.url))));}\r
64const GAP=18,BORDER=5;\r
65/* 依寬度算出合身高度;k=欄數(一般網頁 1 欄用 16:9,其餘 4:3) */\r
66/* 會自己回報高度的卡(HTML 嵌入、Markdown):內容再長,卡片也只長到這個上限,\r
67   多出來的在卡片裡捲動,底部出現「展開全文」;展開後才用完整高度(只影響這位觀看者)。 */\r
68function autoCap(w){return Math.max(420,Math.min(900,Math.round(w*1.25)));}\r
69function fitH(o,w,k){\r
70  const f=o.fit||{t:'page'};let h;\r
71  if(f.t==='fixed')h=f.h+BORDER;\r
72  else if(f.t==='ratio')h=Math.round((w-BORDER)/f.r)+BORDER;\r
73  else if(f.t==='lin')h=Math.round((w-BORDER)*f.r+f.x)+BORDER;\r
74  else if(f.t==='auto')h=o.mh?Math.min(o.mh,o.full?Infinity:autoCap(w))+BORDER:Math.round(Math.min(w*1.2,autoCap(w)));\r
75  else h=Math.round(w*(k===1?0.5625:0.75));\r
76  return Math.max(f.t==='page'?MIN:40,Math.min(MAX,h));\r
77}\r
78function sameOrigin(url){try{return new URL(url).origin===location.origin;}catch(e){return false;}}\r
79\r
80/* 所有資料(localStorage、上傳 JSON、獨立牆)都必須經過這裡:只放行合法類型與 http(s) 網址 */\r
81/* 貼進來的東西若只是「一層 srcdoc 外框」(例如從預覽複製出來的 iframe),拆掉外框只留裡面的內容。\r
82   用 DOMParser 解析:它是惰性文件,不會載入圖片也不會觸發 onerror 之類的處理常式 */\r
83function unwrapSrcdoc(h){\r
84  const s=String(h||'').trim();\r
85  if(!/^<iframe\\b/i.test(s))return h;\r
86  try{\r
87    const d=new DOMParser().parseFromString(s,'text/html'),k=d.body.children;\r
88    if(k.length!==1)return h;\r
89    const f=k[0];\r
90    if(f.tagName!=='IFRAME'||f.hasAttribute('src')||!f.hasAttribute('srcdoc'))return h;\r
91    if(d.body.textContent.trim())return h;\r
92    return f.getAttribute('srcdoc');\r
93  }catch(e){return h;}\r
94}\r
95\r
96/* ==================== Markdown 卡 ====================\r
97   <md> … </md> 包起來的一段文字,或自動偵測貼入的 Markdown 內容。\r
98   強大且安全的零依賴渲染器(GFM 規格):\r
99   標題、段落、粗體、斜體、刪除線、行內程式碼、語法程式碼區塊(含語言標籤與複製按鈕)、\r
100   引言、任務清單(含勾選樣式)、巢狀清單、表格、水平線、連結、圖片。\r
101   原生 HTML 均經安全跳脫,確保無 XSS 風險。\r
102   圖片接受 https, http 與 data:image 嵌入,高度自適應回報,呈現完美預覽。 */\r
103const MD_W=420,MD_H=520,MD_MAX=60000;\r
104const MD_RE=/^<md>[\\s\\S]*<\\/md>$/i;\r
105function mdInner(raw){return String(raw||'').trim().replace(/^<md>[ \\t]*\\r?\\n?/i,'').replace(/\\r?\\n?[ \\t]*<\\/md>$/i,'');}\r
106function mdTag(md){return '<md>\\n'+md+'\\n</md>';}\r
107\r
108/* 自動偵測是否為 HTML 程式碼片段、元件或文件 */\r
109function isHtml(s){\r
110  if(!s||typeof s!=='string')return false;\r
111  const t=s.trim();\r
112  if(!t)return false;\r
113  if(MD_RE.test(t))return false;\r
114  if(/^<model\\b/i.test(t))return false;\r
115  if(/^https?:\\/\\/\\S+$/i.test(t))return false;\r
116  if(YT.test(t)&&!t.includes('\\n')&&!t.includes('<'))return false;\r
117  if(/^<https?:\\/\\/[^\\s>]+>$/i.test(t))return false;\r
118\r
119  // 1. DOCTYPE 或 <html> 完整文件結構\r
120  if(/^<!doctype\\s+html/i.test(t))return true;\r
121  if(/^<html\\b/i.test(t))return true;\r
122\r
123  // 2. 以標準 HTML 標籤開頭\r
124  if(/^<\\/?(?:html|head|body|div|p|span|a|h[1-6]|ul|ol|li|table|tr|td|th|tbody|thead|tfoot|iframe|embed|object|video|audio|canvas|svg|button|form|input|select|textarea|label|style|script|link|meta|section|article|header|footer|nav|aside|main|figure|figcaption|code|pre|blockquote|b|strong|i|em|mark|del|ins|hr|br|img|picture|source|details|summary|dialog|template)\\b/i.test(t)){\r
125    return true;\r
126  }\r
127\r
128  // 3. HTML 註解後接標籤\r
129  if(/^<!--[\\s\\S]*?-->\\s*<[a-z!/]/i.test(t))return true;\r
130\r
131  // 4. 內含成對的 HTML 標籤或標準容器標籤\r
132  if(/<\\/?(?:div|iframe|p|span|h[1-6]|table|tr|td|th|script|style|svg|canvas|button|form|video|audio|ul|ol|li|section|article|header|footer|blockquote)\\b[^>]*>/i.test(t)){\r
133    return true;\r
134  }\r
135  if(/<([a-z][a-z0-9]*)\\b[^>]*>[\\s\\S]*<\\/\\1>/i.test(t)){\r
136    return true;\r
137  }\r
138\r
139  return false;\r
140}\r
141\r
142/* 自動偵測是否為 Markdown 格式或文字卡片 */\r
143function isMarkdown(s){\r
144  if(!s||typeof s!=='string')return false;\r
145  const t=s.trim();\r
146  if(!t)return false;\r
147  if(MD_RE.test(t))return true;\r
148  if(isHtml(t))return false;\r
149  if(/^<model\\b/i.test(t)||/^<iframe\\b/i.test(t))return false;\r
150  if(/^https?:\\/\\/\\S+$/i.test(t))return false;\r
151  if(YT.test(t)&&!t.includes('\\n'))return false;\r
152  if(!t.includes('\\n')&&!/\\s/.test(t)&&/^[^\\/\\s]+\\.[a-z]{2,}(\\/|\\?|#|$)/i.test(t))return false;\r
153\r
154  // 標題 (# Heading)\r
155  if(/(^|\\n) {0,3}#{1,6}[ \\t]+\\S+/m.test(t))return true;\r
156  // 程式碼區塊 (\`\`\` 或 ~~~)\r
157  if(/(^|\\n) {0,3}(\`{3,}|~{3,})/.test(t))return true;\r
158  // 行內程式碼 (\`code\`)\r
159  if(/\`[^\`\\n]+\`/.test(t))return true;\r
160  // 引言 (> Quote)\r
161  if(/(^|\\n) {0,3}>\\s*\\S+/m.test(t))return true;\r
162  // 清單 (- item, * item, + item, 1. item)\r
163  if(/(^|\\n) {0,3}([-*+]|\\d{1,9}[.)])[ \\t]+\\S+/m.test(t))return true;\r
164  // 粗體、斜體、刪除線、標記 (==mark==)\r
165  if(/\\*\\*[^*\\n]+\\*\\*/.test(t)||/__[^_\\n]+__/.test(t))return true;\r
166  if(/\\*[^*\\n]+\\*/.test(t)||/(^|[^\\w])_[^_\\n]+_(?!\\w)/.test(t))return true;\r
167  if(/~~[^~\\n]+~~/.test(t)||/==[^=\\n]+==/.test(t))return true;\r
168  // 連結或圖片 ([text](url), ![alt](url))\r
169  if(/!?\\[[^\\]\\n]*\\]\\([^)\\s]+\\)/.test(t))return true;\r
170  // 水平線 (--- 或 ***)\r
171  if(/(^|\\n) {0,3}
171([-*_])(?:[ \\t]*\\1){2,}[ \\t]*($|\\n)/m.test(t))return true;\r
172  // 表格 (| col | col |)\r
173  if(/\\|.+?\\|\\s*\\n\\s*\\|? *[-:]+[-| :]*\\|?/.test(t))return true;\r
174  // 任務清單 ([ ] 或 [x])\r
175  if(/\\[[ xX]\\]\\s+/.test(t))return true;\r
176\r
177  // 多行非 HTML 內容自動作為文字/Markdown 呈現\r
178  if(t.includes('\\n')&&!t.startsWith('<'))return true;\r
179  // 多詞或帶有空白的敘述字串\r
180  if(/\\s{1,}/.test(t)&&!t.startsWith('<'))return true;\r
181\r
182  return false;\r
183}\r
184\r
185const MD_A=u=>'<a href="'+esc(u)+'" target="_blank" rel="noopener noreferrer">';\r
186function mdInline(s){\r
187  const keep=[],hold=h=>'\\u0001'+(keep.push(h)-1)+'\\u0002';\r
188  s=String(s).replace(/[\\u0001\\u0002]/g,'');\r
189  s=s.replace(/(\`+)([^\`]|[^\`][\\s\\S]*?[^\`])\\1(?!\`)/g,(m,f,x)=>hold('<code>'+esc(x.trim())+'</code>'));\r
190  s=s.replace(/\\\\([\\\\\`*_{}\\[\\]()#+\\-.!|~>=])/g,(m,ch)=>hold(esc(ch)));\r
191  s=s.replace(/!\\[([^\\]\\n]*)\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+"[^"]*")?\\s*\\)/g,(m,a,u)=>{\r
192    const x=/^(?:https?:\\/\\/|data:image\\/)/i.test(u)?(u.startsWith('data:')?u:httpUrl(u)):'';\r
193    return x?hold('<img src="'+esc(x)+'" alt="'+esc(a)+'" loading="lazy">'):hold(esc(m));});\r
194  s=s.replace(/\\[([^\\]\\n]+)\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+"[^"]*")?\\s*\\)/g,(m,a,u)=>{\r
195    const x=httpUrl(u);return x?hold(MD_A(x))+mdInline(a)+hold('</a>'):m;});\r
196  s=s.replace(/<(https?:\\/\\/[^\\s<>]+)>/g,(m,u)=>{const x=httpUrl(u);return x?hold(MD_A(x)+esc(u)+'</a>'):m;});\r
197  s=s.replace(/(^|[\\s((])(https?:\\/\\/[^\\s<>()()]*[^\\s<>()().,;:!?'"。,、!?])/g,(m,p,u)=>{const x=httpUrl(u);return x?p+hold(MD_A(x)+esc(u)+'</a>'):m;});\r
198  s=s.replace(/==(?=\\S)([\\s\\S]*?\\S)==/g,'<mark>$1</mark>');\r
199  s=esc(s)\r
200    .replace(/\\*\\*(?=\\S)([\\s\\S]*?\\S)\\*\\*/g,'<strong>$1</strong>')\r
201    .replace(/(^|[^\\w])__(?=\\S)([\\s\\S]*?\\S)__(?!\\w)/g,'$1<strong>$2</strong>')\r
202    .replace(/\\*(?=[^\\s*])([^*]*?[^\\s*])\\*/g,'<em>$1</em>')\r
203    .replace(/(^|[^\\w])_(?=[^\\s_])([^_]*?[^\\s_])_(?!\\w)/g,'$1<em>$2</em>')\r
204    .replace(/~~(?=\\S)([\\s\\S]*?\\S)~~/g,'<del>$1</del>')\r
205    .replace(/(?: {2,}|\\\\)\\n/g,'<br>');\r
206  return s.replace(/\\u0001(\\d+)\\u0002/g,(m,i)=>keep[+i]);\r
207}\r
208const MD_FENCE=/^ {0,3}(\`{3,}|~{3,})\\s*([\\w+#.-]*)/,MD_HR=/^ {0,3}([-*_])(?:[ \\t]*\\1){2,}[ \\t]*$/,\r
209      MD_HD=/^ {0,3}(#{1,6})(?:[ \\t]+(.*?))?[ \\t]*#*[ \\t]*$/,MD_Q=/^ {0,3}>/,MD_LI=/^( *)([-*+]|\\d{1,9}[.)])[ \\t]+(.*)$/,\r
210      MD_SETEXT=/^ {0,3}(=+|-+)[ \\t]*$/,MD_TSEP=/^ *\\|? *:?-+:? *(\\| *:?-+:? *)*\\|? *$/;\r
211function mdBlockStart(l){return MD_FENCE.test(l)||MD_HD.test(l)||MD_Q.test(l)||MD_HR.test(l)||MD_LI.test(l);}\r
212function mdCells(s){return s.trim().replace(/^\\|/,'').replace(/(^|[^\\\\])\\|$/,'$1').split(/(?<!\\\\)\\|/).map(x=>x.trim().replace(/\\\\\\|/g,'|'));}\r
213function mdRender(src,depth){\r
214  depth=depth||0;if(depth>12)return '<p>'+esc(src)+'</p>';\r
215  const L=String(src).replace(/\\r\\n?/g,'\\n').replace(/\\t/g,'    ').split('\\n'),out=[],blank=s=>!s.trim();\r
216  let i=0,m;\r
217  while(i<L.length){\r
218    const l=L[i];\r
219    if(blank(l)){i++;continue;}\r
220    if((m=l.match(MD_FENCE))){\r
221      const f=m[1],buf=[];i++;\r
222      while(i<L.length&&!(L[i].trim().startsWith(f[0].repeat(f.length))&&!L[i].trim().replace(/[\`~]/g,''))){buf.push(L[i]);i++;}\r
223      i++;\r
224      const lang=esc(m[2]||'');\r
225      out.push('<div class="code-wrap"><div class="code-header"><span class="code-lang">'+(lang||'code')+'</span><button type="button" class="code-copy" onclick="navigator.clipboard&&navigator.clipboard.writeText(this.closest(\\'.code-wrap\\').querySelector(\\'code\\').innerText).then(()=>{this.textContent=\\'✓ Copied\\';setTimeout(()=>{this.textContent=\\'Copy\\';},1500);})">Copy</button></div><pre><code'+(lang?' class="lang-'+lang+'"':'')+'>'+esc(buf.join('\\n'))+'</code></pre></div>');\r
226      continue;\r
227    }\r
228    if((m=l.match(MD_HD))){const n=m[1].length;out.push('<h'+n+'>'+mdInline(m[2]||'')+'</h'+n+'>');i++;continue;}\r
229    if(MD_HR.test(l)){out.push('<hr>');i++;continue;}\r
230    if(MD_Q.test(l)){\r
231      const buf=[];\r
232      while(i<L.length&&!blank(L[i])&&(MD_Q.test(L[i])||!mdBlockStart(L[i]))){buf.push(L[i].replace(/^ {0,3}> ?/,''));i++;}\r
233      out.push('<blockquote>'+mdRender(buf.join('\\n'),depth+1)+'</blockquote>');continue;\r
234    }\r
235    if(l.includes('|')&&i+1<L.length&&L[i+1].includes('-')&&MD_TSEP.test(L[i+1]
235)){\r
236      const al=mdCells(L[i+1]).map(x=>/^:-+:$/.test(x)?'center':/-:$/.test(x)?'right':/^:/.test(x)?'left':'');\r
237      const cell=(tag,x,k)=>'<'+tag+(al[k]?' style="text-align:'+al[k]+'"':'')+'>'+mdInline(x)+'</'+tag+'>';\r
238      let h='<table><thead><tr>'+mdCells(l).map((x,k)=>cell('th',x,k)).join('')+'</tr></thead><tbody>';\r
239      i+=2;\r
240      while(i<L.length&&!blank(L[i])&&L[i].includes('|')){h+='<tr>'+mdCells(L[i]).map((x,k)=>cell('td',x,k)).join('')+'</tr>';i++;}\r
241      out.push('<div class="tw">'+h+'</tbody></table></div>');continue;\r
242    }\r
243    if((m=l.match(MD_LI))){\r
244      const ord=/\\d/.test(m[2]),base=m[1].length,items=[];let loose=false;\r
245      while(i<L.length){\r
246        const x=L[i],mm=x.match(MD_LI);\r
247        if(mm&&mm[1].length<=base+1&&/\\d/.test(mm[2])===ord){items.push({pad:mm[1].length+mm[2].length+1,lines:[mm[3]]});i++;continue;}\r
248        if(mm&&mm[1].length<=base+1)break;\r
249        const cur=items[items.length-1];\r
250        if(blank(x)){\r
251          const nx=L[i+1];\r
252          if(nx!==undefined&&!blank(nx)&&(/^ /.test(nx)&&nx.match(/^ */)[0].length>base||(nx.match(MD_LI)&&nx.match(MD_LI)[1].length<=base+1))){cur.lines.push('');loose=true;i++;continue;}\r
253          break;\r
254        }\r
255        const ind=x.match(/^ */)[0].length;\r
256        if(ind>base||!mdBlockStart(x)){cur.lines.push(x.slice(Math.min(ind,cur.pad)));i++;continue;}\r
257        break;\r
258      }\r
259      const start=ord?parseInt(m[2],10):1;\r
260      out.push((ord?'<ol'+(start!==1?' start="'+start+'"':'')+'>':'<ul>')+items.map(it=>{\r
261        let first=it.lines[0],task='';\r
262        const tk=first.match(/^\\[([ xX])\\][ \\t]+/);\r
263        const isDone=tk&&tk[1]!==' ';\r
264        if(tk){task='<input type="checkbox" disabled'+(isDone?' checked':'')+'> ';first=first.slice(tk[0].length);}\r
265        let body=mdRender([first].concat(it.lines.slice(1)).join('\\n'),depth+1);\r
266        if(!loose)body=body.replace(/^<p>([\\s\\S]*?)<\\/p>/,'$1');\r
267        return '<li'+(task?' class="task'+(isDone?' done':'')+'"':'')+'>'+task+body+'</li>';\r
268      }).join('')+(ord?'</ol>':'</ul>'));\r
269      continue;\r
270    }\r
271    const buf=[l];i++;\r
272    while(i<L.length&&!blank(L[i])&&!MD_SETEXT.test(L[i])&&!mdBlockStart(L[i])){buf.push(L[i]);i++;}\r
273    if(i<L.length&&MD_SETEXT.test(L[i])){const n=L[i].trim()[0]==='='?1:2;out.push('<h'+n+'>'+mdInline(buf.join('\\n'))+'</h'+n+'>');i++;continue;}\r
274    out.push('<p>'+mdInline(buf.join('\\n'))+'</p>');\r
275  }\r
276  return out.join('\\n');\r
277}\r
278const MD_CSS="html{scrollbar-width:thin;scrollbar-color:#c9c5bd transparent}html,body{margin:0;background:#fff}"\r
279 +"::-webkit-scrollbar{width:7px;height:7px}::-webkit-scrollbar-thumb{background:#c9c5bd;border-radius:9px}::-webkit-scrollbar-track{background:transparent}"\r
280 +"body{padding:18px 20px 46px;color:#1e293b;font:14.5px/1.7 -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",Roboto,Helvetica,Arial,\\"PingFang TC\\",\\"Microsoft JhengHei\\",\\"Noto Sans TC\\",\\"Noto Sans\\",sans-serif;overflow-wrap:anywhere;-webkit-font-smoothing:antialiased}"\r
281 +".md::before{content:\\"\\";float:left;width:40px;height:40px;margin:-18px 0 0 -20px;shape-outside:polygon(0 0,100% 0,0 100%)}"\r
282 +".md>:first-child{margin-top:0}.md>:last-child{margin-bottom:0}"\r
283 +"h1,h2,h3,h4,h5,h6{line-height:1.35;margin:1.15em 0 .5em;font-weight:800;color:#0f172a}"\r
284 +"h1{font-size:1.65em;border-bottom:1.5px solid #e2e8f0;padding-bottom:.3em}h2{font-size:1.35em;border-bottom:1px solid #e2e8f0;padding-bottom:.25em}h3{font-size:1.18em}h4,h5,h6{font-size:1em}"\r
285 +"p,ul,ol,blockquote,.code-wrap,.tw{margin:0 0 .9em}ul,ol{padding-left:1.5em}li{margin-top:.25em}li+li{margin-top:.35em}"\r
286 +"li.task{list-style:none;margin-left:-1.3em}li.task input[type=\\"checkbox\\"]{margin:0 .5em 0 0;vertical-align:-1px;accent-color:#0E7C7B;width:15px;height:15px;cursor:default}"\r
287 +"li.task.done{color:#94a3b8;text-decoration:line-through}"\r
288 +"a{color:#0E7C7B;font-weight:700;text-decoration:underline;text-underline-offset:2px;transition:color .15s}a:hover{color:#095756}"\r
289 +"img{max-width:100%;height:auto;border-radius:10px;display:block;margin:.6em 0;box-shadow:0 3px 10px rgba(0,0,0,.08)}"\r
290 +"code{font:12.5px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#f1f5f9;color:#0f172a;border-radius:5px;padding:.15em .4em;border:1px solid #e2e8f0}"\r
291 +".code-wrap{position:relative;background:#18181b;color:#f8fafc;border-radius:12px;margin:.9em 0;overflow:hidden;box-shadow:0 4px 16px rgba(0,0,0,.15)}"\r
292 +".code-header{display:flex;justify-content:space-between;align-items:center;background:#27272a;padding:5px 12px;font:11px/1.4 ui-monospace,Menlo,monospace;color:#a1a1aa;text-transform:lowercase;border-bottom:1px solid #3f3f46}"\r
293 +".code-copy{background:transparent;border:1px solid #52525b;color:#e4e4e7;border-radius:6px;padding:2px 8px;font-size:10.5px;font-weight:700;cursor:pointer;transition:all .15s}.code-copy:hover{background:#3f3f46;color:#fff}"\r
294 +"pre{margin:0;padding:12px 14px;overflow-x:auto;font:12.5px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}pre code{background:none;border:none;padding:0;color:inherit;font:inherit}"\r
295 +"blockquote{border-left:4px solid #0E7C7B;background:#f0fdfa;padding:.6em 1em;border-radius:0 10px 10px 0;color:#134e4a;font-style:normal}blockquote>:last-child{margin-bottom:0}"\r
296 +"hr{border:0;border-top:2px dashed #cbd5e1;margin:1.4em 0}mark{background:#fef08a;color:#713f12;padding:.1em .3em;border-radius:3px}"\r
297 +".tw{overflow-x:auto;margin:.9em 0}table{border-collapse:collapse;width:100%;font-size:13px;border-radius:8px;overflow:hidden}"\r
298 +"th,td{border:1px solid #e2e8f0;padding:8px 12px;text-align:left}th{background:#f8fafc;font-weight:800;color:#0f172a;border-bottom:2px solid #cbd5e1}tr:nth-child(even) td{background:#f8fafc}tr:hover td{background:#f1f5f9}del{opacity:.6}";\r
299\r
300/* 附在 HTML 嵌入碼與 Markdown 卡後面:量內容實際高度回報給外層(Twitter、Markdown 等載入後長高會自動回報適應高度) */\r
301const REPORT='<script>(function(){var last=-1;function m(){var b=document.body;if(!b)return;var r=b.getBoundingClientRect(),h=Math.ceil(Math.max(r.bottom+(parseFloat(getComputedStyle(b).marginBottom)||
3010),document.documentElement.scrollHeight,b.scrollHeight));if(Math.abs(h-last)>1){last=h;parent.postMessage({__wallH:h},"*");}}addEventListener("load",m);if(window.ResizeObserver&&document.body)new ResizeObserver(m).observe(document.body);setTimeout(m,30);setTimeout(m,150);setTimeout(m,600);setTimeout(m,1500);setTimeout(m,3000);})();<\\/script>';\r
302\r
303function mdDoc(md){\r
304  return '<!doctype html><html><head><meta charset="utf-8">'\r
305    +'<meta http-equiv="Content-Security-Policy" content="default-src \\'none\\'; img-src https: http: data:; style-src \\'unsafe-inline\\'; script-src \\'unsafe-inline\\'">'\r
306    +'<meta name="viewport" content="width=device-width,initial-scale=1"><style>'+MD_CSS+'</style></head>'\r
307    +'<body><article class="md">'+mdRender(md)+'</article>'\r
308    +REPORT\r
309    +'</body></html>';\r
310}\r
311\r
312/* 將 HTML 內容組裝成在 iframe 內完美呈現的文件(含合適字型、響應式 viewport、防溢出樣式與高度回報) */\r
313function htmlDoc(rawHtml){\r
314  const s=String(rawHtml||'').trim();\r
315  if(!s)return '<!doctype html><html><body>'+REPORT+'</body></html>';\r
316\r
317  // 已經是完整 HTML 文件\r
318  if(/^<!doctype\\s+html/i.test(s)||/<html\\b/i.test(s)){\r
319    let doc=s;\r
320    if(!/<meta\\b[^>]*name=["']viewport["']/i.test(doc)){\r
321      if(/<head\\b[^>]*>/i.test(doc)){\r
322        doc=doc.replace(/<head\\b[^>]*>/i,'$&\\n<meta name="viewport" content="width=device-width,initial-scale=1">');\r
323      }\r
324    }\r
325    if(/<\\/body>/i.test(doc)){\r
326      return doc.replace(/<\\/body>/i,REPORT+'</body>');\r
327    }\r
328    if(/<\\/html>/i.test(doc)){\r
329      return doc.replace(/<\\/html>/i,REPORT+'</html>');\r
330    }\r
331    return doc+REPORT;\r
332  }\r
333\r
334  // HTML 片段/小工具:包裝進清晰、精緻且自適應的卡片外框\r
335  const baseCss='html,body{margin:0;padding:0;background:#fff;box-sizing:border-box}'\r
336    +'*,*:before,*:after{box-sizing:inherit}'\r
337    +'body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,"PingFang TC","Microsoft JhengHei","Noto Sans TC","Noto Sans",sans-serif;color:#1e293b;line-height:1.6;font-size:14px;padding:16px 18px 36px;overflow-wrap:anywhere;-webkit-font-smoothing:antialiased}'\r
338    +'img,video,iframe,canvas,svg{max-width:100%;height:auto}'\r
339    +'h1,h2,h3,h4,h5,h6{color:#0f172a;line-height:1.3;margin-top:0.6em;margin-bottom:0.4em;font-weight:800}'\r
340    +'h1{font-size:1.5em}h2{font-size:1.3em}h3{font-size:1.15em}'\r
341    +'p{margin:0 0 0.8em}'\r
342    +'a{color:#0E7C7B;text-decoration:underline}'\r
343    +'code{background:#f1f5f9;color:#0f172a;padding:2px 5px;border-radius:4px;font-size:12px;font-family:ui-monospace,Menlo,monospace}'\r
344    +'pre{background:#18181b;color:#f8fafc;padding:10px 12px;border-radius:8px;overflow:auto}'\r
345    +'table{border-collapse:collapse;width:100%;margin:0.8em 0}'\r
346    +'th,td{border:1px solid #e2e8f0;padding:6px 10px;text-align:left}'\r
347    +'th{background:#f8fafc;font-weight:700}';\r
348\r
349  return '<!doctype html><html><head><meta charset="utf-8">'\r
350    +'<meta name="viewport" content="width=device-width,initial-scale=1">'\r
351    +'<style>'+baseCss+'</style></head>'\r
352    +'<body>'\r
353    +s\r
354    +REPORT\r
355    +'</body></html>';\r
356}\r
357function mdTitle(md){\r
358  const h=String(md).match(/^ {0,3}#{1,6}[ \\t]+(.+?)[ \\t#]*$/m);\r
359  const s=h?h[1]:(String(md).split('\\n').find(x=>x.trim())||'');\r
360  return s.replace(/[*_\`~>#\\[\\]]|\\(https?:[^)]*\\)/g,'').trim().slice(0,80);\r
361}\r
362\r
363/* 「外包一層」的嵌入碼:只有一個 iframe,旁邊只有文字與連結(Sketchfab、Vimeo、Spotify 的署名段落)。\r
364   當成 HTML 卡會被放進沒有 same-origin 的 sandbox,裡面的 iframe 繼承限制,\r
365   WebGL 播放器(Sketchfab 等)因此載不起來。改成直接嵌入 iframe 的網址,原文照樣保留在 _raw。\r
366   用 DOMParser 解析:惰性文件,不載入任何東西。 */\r
367const SOLO_OK=/^(DIV|P|SPAN|A|B|STRONG|EM|I|U|BR|SMALL|IFRAME|FIGURE|FIGCAPTION|CENTER|SECTION|H[1-6])$/;\r
368function soloIframe(h){\r
369  const s=String(h||'').trim();\r
370  if(!/^<[a-z]/i.test(s)||!/<iframe\\b/i.test(s))return null;\r
371  try{\r
372    const d=new DOMParser().parseFromString(s,'text/html'),fs=d.querySelectorAll('iframe');\r
373    if(fs.length!==1||d.head.children.length)return null;\r
374    if([...d.body.querySelectorAll('*')].some(e=>!SOLO_OK.test(e.tagName)))return null;\r
375    const f=fs[0],src=httpUrl((f.getAttribute('src')||'').trim());\r
376    if(!src||f.hasAttribute('srcdoc'))return null;\r
377    return {src,title:(f.getAttribute('title')||'').trim().slice(0,200)};\r
378  }catch(e){return null;}\r
379}\r
380function normalize(o){\r
381  if(!o||typeof o!=='object')return null;\r
382  const raw=String(o._raw||o.html||o.url||'');\r
383  const _id=/^[a-z0-9]{6,32}$/i.test(String(o._id||''))?o._id:uid();\r
384  const extra={manual:!!o.manual,zone:(o.zone==='a'||o.zone==='c')?o.zone:'b'};\r
385  const px=Number(o.px),py=Number(o.py);\r
386  if(o.free&&Number.isFinite(px)&&Number.isFinite(py)&&px>=0&&py>=0&&px<20000&&py<200000){extra.free=true;extra.px=Math.round(px);extra.py=Math.round(py);}\r
387  /* 篩選用的資料:at=加入時間、pub=發布時間、title/tags/dur(秒) */\r
388  const at=Number(o.at);if(at>946684800000&&at<Date.now()+DAY)extra.at=at;\r
389  const pub=Number(o.pub);if(pub>0&&pub<Date.now()+2*DAY)extra.pub=pub;\r
390  if(typeof o.title==='string'&&o.title.trim())extra.title=o.title.trim().slice(0,200);\r
391  let tg=o.tags;if(typeof tg==='string')tg=tg.split(',');\r
392  if(Array.isArray(tg)){tg=tg.map(x=>String(x).trim().replace(/^#/,'').slice(0,40)).filter(Boolean).slice(0,20);if(tg.length)extra.tags=tg;}\r
393  const du=Number(o.dur);if(du>0&&du<172800)extra.dur=Math.round(du);if(o.emb==='no'||o.emb==='yes')extra.emb=o.emb;if(o.blk===true)extra.blk=true;if(o.pic===true)extra.pic=true;const sp=Number(o.span),rh=Number(o.rh);\r
394  if(Number.isInteger(sp)&&sp>=1&&sp<=8)extra.span=sp;if(rh>=0.3&&rh<=3)extra.rh=rh;const mh=Number(o.mh);if(mh>0&&mh<MAX)extra.mh=Math.round(mh);\r
395  const done=r=>r?Object.assign(r,extra,{fit:fitOf(r)}):null;\r
396  if(o.type==='youtube'){\r
397    const id=/^[a-zA-Z0-9_-]{11}$/.test(String(o.id||''))?o.id:(String(o.embedSrc||o.url||raw).match(YT)||[])[1];\r
398    return done(id?{_id,_raw:raw,type:'youtube',id,url:String(o.url||raw),w:size(o.w,STD_W),h:size(o.h,STD_H)}:null);\r
399  }\r
400  if(o.type==='model'){\r
401    /* 兩種來源:d=內嵌 data URI(版主上傳),u=公開的 https 模型網址(來客也能用) */\r
402    const m=o.mdl||{},d=String(m.d||''),u=/^https:\\/\\//i.test(String(m.u||''))?httpUrl(m.u):'',e=String(m.e||'').toLowerCase();\r
403    const inl=/^data:[^,]{0,120},/.test(d);\r
404    if(!M3D_OK.test(e)||!(inl||u))return null;\r
405    const mdl=inl?{d,e,n:String(m.n||'').slice(0,120)}:{u,e,n:String(m.n||'').slice(0,120)};\r
406    const r=done({_id,_raw:raw&&(raw.charAt(0)==='<'||mdl.u)?raw:modelTag(mdl),type:'model',mdl,\r
407      html:modelDoc(mdl),w:size(o.w,MODEL_W),h:size(o.h,MODEL_H)});\r
408    /* 存檔時不要把組好的 srcdoc 一起寫進去,只留模型資料本身 */\r
409    if(r)Object.defineProperty(r,'toJSON',{value:function(){\r
410      const c=Object.assign({},this);delete c.html;delete c.fit;return c;}});\r
411    return r;\r
412  }\r
413  if(o.type==='md'){\r
414    const md=typeof o.md==='string'?o.md:mdInner(raw);\r
415    if(!md.trim()||md.length>MD_MAX)return null;\r
416    const r=done({_id,_raw:MD_RE.test(raw.trim())?raw.trim():mdTag(md),type:'md',md,html:mdDoc(md),w:size(o.w,MD_W),h:size(o.h,MD_H)});\r
417    if(r)Object.defineProperty(r,'toJSON',{value:function(){\r
418      const c=Object.assign({},this);delete c.html;delete c.fit;delete c.md;return c;}});\r
419    return r;\r
420  }\r
421  if(o.type==='html'){\r
422    const html=unwrapSrcdoc(o.html||raw);\r
423    const solo=soloIframe(html);\r
424    if(solo){\r
425      const base=Object.assign({},o,{_id,_raw:raw||html,html:undefined});\r
426      if(!base.title&&solo.title)base.title=solo.title;\r
427      const yt=solo.src.match(YT);\r
428      return normalize(yt?Object.assign(base,{type:'youtube',id:yt[1],url:solo.src}):Object.assign(base,{type:'web',url:solo.src}));\r
429    }\r
430    return done(html.trim()?{_id,_raw:raw||html,type:'html',html,w:size(o.w,HTML_W),h:size(o.h,HTML_H)}:null);\r
431  }\r
432  const url=toEmbed(httpUrl(o.url||raw));\r
433  return done(url?{_id,_raw:raw||url,type:'web',url,w:size(o.w,STD_W),h:size(o.h,STD_H)}:null);\r
434}\r
435\r
436function fitPluginUrl(u,w){\r
437  try{const x=new URL(u);\r
438    if(!w||!/(^|\\.)facebook\\.com$/.test(x.hostname)||!/^\\/plugins\\//.test(x.pathname))return u;\r
439    const ow=+x.searchParams.get('width'),oh=+x.searchParams.get('height');\r
440    x.searchParams.set('width',Math.round(w));if(ow>0&&oh>0)x.searchParams.set('height',Math.round(oh*w/ow));\r
441    return x.href;\r
442  }catch(e){return u;}\r
443}\r
444function frameHTML(o,w){\r
445  if(o.type==='youtube')return \`<iframe class="embed" src="https://www.youtube-nocookie.com/embed/\${esc(o.id)}" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen loading="lazy"></iframe>\`;\r
446  /* 使用者貼的 HTML:不給 allow-same-origin,讀不到主頁的 localStorage 與 DOM */\r
447  if(o.type==='html')return \`<iframe class="html-frame" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation" loading="lazy"></iframe>\`;\r
448  /* 3D 檢視器只需要跑 script,不給彈窗、不給同源 */\r
449  if(o.type==='model')return \`<iframe class="html-frame m3d" sandbox="allow-scripts" loading="lazy"></iframe>\`;\r
450  /* Markdown:內容全部跳脫過,script 只給量高度用;連結可以開新分頁 */\r
451  if(o.type==='md')return \`<iframe class="html-frame md" sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox" loading="lazy"></iframe>\`;\r
452  /* 同網域網頁不能同時給 scripts + same-origin,否則可自行拆掉 sandbox */\r
453  const sb=sameOrigin(o.url)?'allow-scripts allow-popups allow-forms':'allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation';\r
454  const cls=o.fit&&o.fit.t!=='page'?' class="embed"':'';\r
455  return \`<iframe\${cls} src="\${esc(fitPluginUrl(o.url,w))}" sandbox="\${sb}" loading="lazy" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture; xr-spatial-tracking; accelerometer; gyroscope; web-share" allowfullscreen></iframe>\`;\r
456}\r
457\r
458const TOMB_SVG='<svg class="tomb-img" viewBox="0 0 120 104" aria-hidden="true">'\r
459 +'<ellipse cx="60" cy="98" rx="54" ry="6" fill="#0A7A34" opacity=".22"/>'\r
460 +'<path d="M30 97V44a30 30 0 0 1 60 0v53z" fill="#D6D2CA" stroke="#111" stroke-width="3" stroke-linejoin="round"/>'\r
461 +'<path d="M38 94V46a22 22 0 0 1 22-22" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" opacity=".55"/>'\r
462 +'<text x="60" y="56" text-anchor="middle" font-size="15" font-weight="900" fill="#111" opacity=".72" font-family="Georgia,serif">R.I.P.</text>'\r
463 +'<path d="M46 67h28M50 76h20" stroke="#111" stroke-width="2.5" stroke-linecap="round" opacity=".3"/>'\r
464 +'<path d="M81 27l-6 9 5 5-5 8" fill="none" stroke="#111" stroke-width="2" stroke-linejoin="round" opacity=".45"/>'\r
465 +'<path d="M20 98h80" stroke="#111" stroke-width="3" stroke-linecap="round"/>'\r
466 +'<path d="M14 98l4-9 3 9 3-11 3 11 3-8 2 8zM88 98l3-8 3 8 3-11 3 11 4-9 3 9z" fill="#0A7A34" stroke="#111" stroke-width="1.5" stroke-linejoin="round"/>'\r
467 +'<path d="M36 97v-10" stroke="#0A7A34" stroke-width="2.5" stroke-linecap="round"/><circle cx="36" cy="85" r="4.5" fill="#FFE27A" stroke="#111" stroke-width="1.5"/>'\r
468 +'</svg>';\r
469function hostOf(u){try{return new URL(u).hostname.replace(/^www\\./,'');}catch(e){return '';}}\r
470function tombHTML(o){\r
471  return '<div class="tomb-body">'+TOMB_SVG+'<div class="tomb-label">Non-Embeddable</div>'\r
472    +'<div class="tomb-host">'+esc(hostOf(o.url))+'</div><div class="tomb-note" data-i18n="tombNote">'+esc(t('tombNote'))+'</div>'\r
473    +'<a class="tomb-link" href="'+esc(o.url)+'" target="_blank" rel="noopener noreferrer"><span data-i18n="openTab">'+esc(t('openTab'))+'</span><span aria-hidden="true">↗</span></a></div>';\r
474}\r
475/* 左上三角:主人卡 WiKi(黃)/來客卡 Co-WiKi(青)。\r
476   來客卡待審時是淺色虛線,版主認可後變成實心實線,但保留 Co-WiKi 的來源標記。 */\r
477function cornerHTML(o){\r
478  const co=!!o.guest,cls=co?'co '+(o.ok?'ok':'pend'):'own';\r
479  return '<div class="corner '+cls+'" aria-hidden="true"><svg viewBox="0 0 52 52"><path class="c-fill" d="M0 0H52L0 52Z"/><path class="c-edge" d="M52 0L0 52"/></svg><span class="c-lbl">'+(co?'Co-WiKi':'WiKi')+'</span></div>';\r
480}\r
481function cardHTML(o,ro){\r
482  const tomb=isTomb(o);\r
483  const isOwner = (typeof window !== 'undefined' && window.isOwner === true) || !!(typeof ownerToken === 'function' && ownerToken());\r
484  const tog=!ro&&o.type==='web'?'<button class="tog" data-act="emb" data-i18n-aria="'+(tomb?'tryEmbed':'markTomb')+'" aria-label="'+esc(t(tomb?'tryEmbed':'markTomb'))+'" title="'+esc(t(tomb?'tryEmbed':'markTomb'))+'">'+(tomb?'↻':'🪦')+'</button>':'';\r
485  /* 插卡鍵:版主與訪客都有。只有這面牆的牆主才能刪除牆上的卡片,按 + 後面的 ✕ 關閉圖示 */\r
486  const delBtnHTML = isOwner\r
487    ? '<button class="gdel del-card" data-act="del" title="'+esc(t('del')||'Delete')+'" aria-label="'+esc(t('del')||'Delete')+'" data-i18n-aria="del">✕</button>'\r
488    : '';\r
489  const ins='<button class="ins" data-act="ins" title="'+esc(t('insCard'))+'" aria-label="'+esc(t('insCard'))+'" data-i18n-aria="insCard">\\uFF0B</button>'\r
490    +delBtnHTML;\r
491  /* 調整大小的把手:訪客也有;搬移、刪除、編輯仍然只有版主 */\r
492  const grips='<div class="side-anchor"></div><div class="resize-anchor"></div>';\r
493  const fold=o.fit&&o.fit.t==='auto'?'<div class="fold"><button type="button" class="fold-btn" data-i18n="foldMore">'+esc(t('foldMore'))+'</button></div>':'';\r
494  const delBtn=isOwner?'<button class="del" data-act="del" aria-label="'+esc(t('del'))+'">✕</button>':'';\r
495  const tools=ins+(ro?grips:tog+delBtn+'<button class="edit" data-act="edit" aria-label="'+esc(t('edit'))+'">✎</button><div class="move-anchor" title="'+esc(t('moveCard'))+'"></div>'+grips);\r
496  return \`<div class="item\${tomb?' tomb':''}\${o.guest?' guest '+(o.ok?'ok':'pending'):''}" data-id="\${esc(o._id)}" style="width:\${o.w}px;height:\${o.h}px">\${cornerHTML(o)}\${ro?'':'<div class="corner-dim">'+o.w+'×'+o.h+'</div>'}\${tomb?tombHTML(o):(LAZY?phHTML(o):frameHTML(o))}\${fold}\${tools}</div>\`;\r
497}\r
498\r
499/* ==================== 3D 模型卡 ====================\r
500   支援三種最通用的格式:glTF(.glb/.gltf)、STL(二進位與 ASCII)、OBJ。\r
501   檔案以 base64 data URI 內嵌,卡片裡是一個 sandbox iframe,\r
502   內含一支不依賴任何函式庫、也不連外網的 WebGL 檢視器。\r
503   模型資料只存 mdl{d,e,n},srcdoc 在載入時才組出來,所以\r
504   localStorage 與獨立牆匯出都不會被重複的檢視器程式碼灌大。 */\r
505const M3D_EXT=/\\.(glb|gltf|stl|obj)$/i;\r
506const M3D_MIME={glb:'model/gltf-binary',gltf:'model/gltf+json',stl:'model/stl',obj:'model/obj'};\r
507const M3D_OK=/^(glb|gltf|stl|obj)$/;\r
508const M3D_CSS="html,body{margin:0;height:100%;background:transparent;font:13px/1.5 -apple-system,BlinkMacSystemFont,\\"Segoe UI\\",\\"PingFang TC\\",\\"Noto Sans\\",sans-serif}#w{position:relative;width:100%;height:100vh;background:radial-gradient(120% 120% at 50% 0%,#ffffff 0%,#EAE7E1 100%)}canvas{width:100%;height:100%;display:block;cursor:grab;touch-action:none}#n{display:none;position:absolute;inset:0;padding:22px;align-items:center;justify-content:center;text-align:center;font-weight:700;color:#666}#b{display:none;position:absolute;right:9px;bottom:9px;background:rgba(17,17,17,.82);color:#fff;font-size:10px;font-weight:800;padding:3px 8px;border-radius:99px;letter-spacing:.05em}";\r
509const VIEWER3D="/* ============================================================\\n   Tiny self-contained 3D card viewer.\\n   Formats: glTF (.glb / .gltf), STL (binary + ASCII), OBJ.\\n   Raw WebGL, no libraries, no network. Runs inside the card's\\n   sandboxed iframe; the model arrives as a base64 data URI.\\n   ============================================================ */\\n(function(){\\nvar C=document.getElementById('c'),NOTE=document.getElementById('n'),BADGE=document.getElementById('b');\\nvar SRC=C.getAttribute('data-src'),EXT=(C.getAttribute('data-ext')||'').toLowerCase();\\nfunction say(m){NOTE.textContent=m;NOTE.style.display='flex';}\\n\\n/* ---------- data URI -> ArrayBuffer ---------- */\\nfunction toBuf(u){\\n  var b=u.indexOf(',')+1,s=u.slice(b);\\n  if(/;base64/i.test(u.slice(0,b))){\\n    var bin=atob(s),n=bin.length,a=new Uint8Array(n);\\n    for(var i=0;i<n;i++)a[i]=bin.charCodeAt(i);\\n    return a.buffer;\\n  }\\n  return new TextEncoder().encode(decodeURIComponent(s)).buffer;\\n}\\nvar td=new TextDecoder();\\n\\n/* ================= mat4 (column-major) ================= */\\nfunction mIdent(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);}\\nfunction mMul(a,b){\\n  var o=new Float32Array(16);\\n  for(var c=0;c<4;c++)for(var r=0;r<4;r++){\\n    var s=0;for(var k=0;k<4;k++)s+=a[k*4+r]*b[c*4+k];\\n    o[c*4+r]=s;\\n  }\\n  return o;\\n}\\nfunction mTRS(t,q,s){\\n  var x=q[0],y=q[1],z=q[2],w=q[3];\\n  var x2=x+x,y2=y+y,z2=z+z;\\n  var xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;\\n  return new Float32Array([\\n    (1-(yy+zz))*s[0],(xy+wz)*s[0],(xz-wy)*s[0],0,\\n    (xy-wz)*s[1],(1-(xx+zz))*s[1],(yz+wx)*s[1],0,\\n    (xz+wy)*s[2],(yz-wx)*s[2],(1-(xx+yy))*s[2],0,\\n    t[0],t[1],t[2],1]);\\n}\\nfunction mPersp(f,a,n,fr){\\n  var t=1/Math.tan(f/2),d=1/(n-fr);\\n  return new Float32Array([t/a,0,0,0, 0,t,0,0, 0,0,(fr+n)*d,-1, 0,0,2*fr*n*d,0]);\\n}\\nfunction mLook(e,c,u){\\n  var z=norm([e[0]-c[0],e[1]-c[1],e[2]-c[2]]),x=norm(cross(u,z)),y=cross(z,x);\\n  return new Float32Array([x[0],y[0],z[0],0, x[1],y[1],z[1],0, x[2],y[2],z[2],0,\\n    -dot(x,e),-dot(y,e),-dot(z,e),1]);\\n}\\nfunction cross(a,b){return [a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]
509*b[0]];}\\nfunction dot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];}\\nfunction norm(a){var l=Math.hypot(a[0],a[1],a[2])||1;return [a[0]/l,a[1]/l,a[2]/l];}\\n/* upper-left 3x3 inverse-transpose, for normals under non-uniform scale */\\nfunction mNormal(m){\\n  var a=m[0],b=m[1],c=m[2],d=m[4],e=m[5],f=m[6],g=m[8],h=m[9],i=m[10];\\n  var A=e*i-f*h,B=f*g-d*i,Cc=d*h-e*g,det=a*A+b*B+c*Cc;\\n  if(!det)return new Float32Array([1,0,0,0,1,0,0,0,1]);\\n  var id=1/det;\\n  return new Float32Array([A*id,B*id,Cc*id,\\n    (c*h-b*i)*id,(a*i-c*g)*id,(b*g-a*h)*id,\\n    (b*f-c*e)*id,(c*d-a*f)*id,(a*e-b*d)*id]);\\n}\\n\\n/* ================= flat-shaded normals ================= */\\nfunction faceNormals(pos){\\n  var n=new Float32Array(pos.length);\\n  for(var i=0;i<pos.length;i+=9){\\n    var ax=pos[i+3]-pos[i],ay=pos[i+4]-pos[i+1],az=pos[i+5]-pos[i+2];\\n    var bx=pos[i+6]-pos[i],by=pos[i+7]-pos[i+1],bz=pos[i+8]-pos[i+2];\\n    var v=norm([ay*bz-az*by,az*bx-ax*bz,ax*by-ay*bx]);\\n    for(var k=0;k<3;k++){n[i+k*3]=v[0];n[i+k*3+1]=v[1];n[i+k*3+2]=v[2];}\\n  }\\n  return n;\\n}\\n\\n/* ================= STL ================= */\\nfunction parseSTL(buf){\\n  var u8=new Uint8Array(buf);\\n  /* ASCII if it starts with \\"solid\\" and has no plausible binary triangle count */\\n  var head=td.decode(u8.subarray(0,Math.min(84,u8.length)));\\n  var isAscii=/^\\\\s*solid/i.test(head);\\n  if(isAscii&&u8.length>84){\\n    var dv0=new DataView(buf),tri=dv0.getUint32(80,true);\\n    if(84+tri*50===u8.length)isAscii=false;\\n  }\\n  if(isAscii){\\n    var txt=td.decode(u8),pos=[],m,re=/vertex\\\\s+(-?[\\\\d.eE+-]+)\\\\s+(-?[\\\\d.eE+-]+)\\\\s+(-?[\\\\d.eE+-]+)/g;\\n    while((m=re.exec(txt)))pos.push(+m[1],+m[2],+m[3]);\\n    var p=new Float32Array(pos);\\n    return [{pos:p,nrm:faceNormals(p),color:[.62,.66,.72]}];\\n  }\\n  var dv=new DataView(buf),n=dv.getUint32(80,true);\\n  if(84+n*50>buf.byteLength)n=Math.floor((buf.byteLength-84)/50);\\n  var P=new Float32Array(n*9),N=new Float32Array(n*9),o=84;\\n  for(var i=0;i<n;i++){\\n    var nx=dv.getFloat32(o,true),ny=dv.getFloat32(o+4,true),nz=dv.getFloat32(o+8,true);o+=12;\\n    for(var v=0;v<3;v++){\\n      var k=i*9+v*3;\\n      P[k]=dv.getFloat32(o,true);P[k+1]=dv.getFloat32(o+4,true);P[k+2]=dv.getFloat32(o+8,true);o+=12;\\n      N[k]=nx;N[k+1]=ny;N[k+2]=nz;\\n    }\\n    o+=2;\\n  }\\n  if(!N.some(function(x){return x;}))N=faceNormals(P);\\n  return [{pos:P,nrm:N,color:[.62,.66,.72]}];\\n}\\n\\n/* ================= OBJ ================= */\\nfunction parseOBJ(buf){\\n  var lines=td.decode(new Uint8Array(buf)).split(/\\\\r?\\\\n/);\\n  var V=[],VN=[],P=[],N=[];\\n  function idx(s,len){var i=parseInt(s,10);return i<0?len+i:i-1;}\\n  for(var L=0;L<lines.length;L++){\\n    var t=lines[L].trim();\\n    if(!t||t.charCodeAt(0)===35)continue;\\n    var p=t.split(/\\\\s+/),k=p[0];\\n    if(k==='v')V.push([+p[1],+p[2],+p[3]]);\\n    else if(k==='vn')VN.push([+p[1],+p[2],+p[3]]);\\n    else if(k==='f'){\\n      var f=[];\\n      for(var i=1;i<p.length;i++){\\n        var s=p[i].split('/');\\n        f.push([idx(s[0],V.length),s[2]?idx(s[2],VN.length):-1]);\\n      }\\n      /* fan-triangulate any polygon */\\n      for(var j=1;j+1<f.length;j++){\\n        var tri=[f[0],f[j],f[j+1]];\\n        for(var q=0;q<3;q++){\\n          var vv=V[tri[q][0]];if(!vv)continue;\\n          P.push(vv[0],vv[1],vv[2]);\\n          var nn=tri[q][1]>=0?VN[tri[q][1]]:null;\\n          N.push(nn?nn[0]:0,nn?nn[1]:0,nn?nn[2]:0);\\n        }\\n      }\\n    }\\n  }\\n  var pos=new Float32Array(P),nrm=new Float32Array(N);\\n  if(!nrm.some(function(x){return x;}))nrm=faceNormals(pos);\\n  return [{pos:pos,nrm:nrm,color:[.70,.72,.76]}];\\n}\\n\\n/* ================= glTF / GLB ================= */\\nvar CSZ={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},\\n    NC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT4:16},\\n    CA={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};\\n\\nfunction parseGLB(buf){\\n  var dv=new DataView(buf);\\n  if(dv.getUint32(0,true)!==0x46546C67)throw new Error('not a GLB');\\n  var len=dv.getUint32(8,true),o=12,json=null,bin=null;\\n  while(o+8<=len&&o+8<=buf.byteLength){\\n    var cl=dv.getUint32(o,true),ct=dv.getUint32(o+4,true);o+=8;\\n    if(ct===0x4E4F534A)json=JSON.parse(td.decode(new Uint8Array(buf,o,cl)));\\n    else if(ct===0x004E4942)bin=buf.slice(o,o+cl);\\n    o+=cl+((4-cl%4)%4===4?0:0);\\n    o+=(4-(cl%4))%4;\\n  }\\n  if(!json)throw new Error('GLB has no JSON chunk');\\n  return buildGLTF(json,bin);\\n}\\nfunction parseGLTF(buf){\\n  var j=JSON.parse(td.decode(new Uint8Array(buf)));\\n  return buildGLTF(j,null);\\n}\\n\\nfunction buildGLTF(j,bin){\\n  if(j.extensionsRequired&&j.extensionsRequired.some(function(x){return /draco|meshopt/i.test(x);}))\\n    throw new Error('compressed');\\n  /* buffers: GLB chunk, or embedded data URIs (external .bin cannot be fetched) */\\n  var bufs=(j.buffers||[]).map(function(b,i){\\n    if(b.uri==null)return bin;\\n    if(/^data:/i.test(b.uri))return toBuf(b.uri);\\n    throw new Error('external');\\n  });\\n  function view(i){\\n    var v=j.bufferViews[i],b=bufs[v.buffer];\\n    if(!b)throw new Error('external');\\n    return {buf:b,off:v.byteOffset||0,len:v.byteLength,stride:v.byteStride||0};\\n  }\\n  function acc(i){\\n    if(i==null)return null;
509\\n    var a=j.accessors[i],nc=NC[a.type]||1,cs=CSZ[a.componentType],Ctor=CA[a.componentType];\\n    var out=new Float32Array(a.count*nc);\\n    if(a.bufferView==null)return out;\\n    var v=view(a.bufferView),base=v.off+(a.byteOffset||0),stride=v.stride||nc*cs;\\n    for(var e=0;e<a.count;e++){\\n      var t=new Ctor(v.buf,base+e*stride,nc);\\n      for(var c=0;c<nc;c++)out[e*nc+c]=t[c];\\n    }\\n    return out;\\n  }\\n  function accInt(i){\\n    if(i==null)return null;\\n    var a=j.accessors[i],cs=CSZ[a.componentType],Ctor=CA[a.componentType];\\n    if(a.bufferView==null)return null;\\n    var v=view(a.bufferView),base=v.off+(a.byteOffset||0),stride=v.stride||cs;\\n    var out=new Uint32Array(a.count);\\n    for(var e=0;e<a.count;e++)out[e]=new Ctor(v.buf,base+e*stride,1)[0];\\n    return out;\\n  }\\n  function matColor(mi){\\n    if(mi==null||!j.materials||!j.materials[mi])return [.78,.78,.80];\\n    var m=j.materials[mi],p=m.pbrMetallicRoughness||{},f=p.baseColorFactor;\\n    return f?[f[0],f[1],f[2]]:[.78,.78,.80];\\n  }\\n  var parts=[];\\n  function node(ni,parent){\\n    var n=j.nodes[ni];if(!n)return;\\n    var local=n.matrix?new Float32Array(n.matrix)\\n      :mTRS(n.translation||[0,0,0],n.rotation||[0,0,0,1],n.scale||[1,1,1]);\\n    var world=mMul(parent,local);\\n    if(n.mesh!=null&&j.meshes[n.mesh]){\\n      (j.meshes[n.mesh].primitives||[]).forEach(function(pr){\\n        if(pr.mode!=null&&pr.mode!==4)return;               /* triangles only */\\n        var P=acc(pr.attributes&&pr.attributes.POSITION);if(!P||!P.length)return;\\n        var N=acc(pr.attributes&&pr.attributes.NORMAL);\\n        var I=accInt(pr.indices);\\n        var pos,nrm;\\n        if(I){\\n          pos=new Float32Array(I.length*3);\\n          nrm=N?new Float32Array(I.length*3):null;\\n          for(var k=0;k<I.length;k++){\\n            var s=I[k]*3,d=k*3;\\n            pos[d]=P[s];pos[d+1]=P[s+1];pos[d+2]=P[s+2];\\n            if(nrm){nrm[d]=N[s];nrm[d+1]=N[s+1];nrm[d+2]=N[s+2];}\\n          }\\n        }else{pos=P;nrm=N;}\\n        if(!nrm)nrm=faceNormals(pos);\\n        parts.push({pos:pos,nrm:nrm,color:matColor(pr.material),mat:world,nmat:mNormal(world)});\\n      });\\n    }\\n    (n.children||[]).forEach(function(c){node(c,world);});\\n  }\\n  var scene=j.scenes&&j.scenes[j.scene||0];\\n  var roots=scene&&scene.nodes?scene.nodes:(j.nodes||[]).map(function(_,i){return i;});\\n  roots.forEach(function(r){node(r,mIdent());});\\n  if(!parts.length)throw new Error('empty');\\n  return parts;\\n}\\n\\n/* ================= load + render ================= */\\nfunction start(buf){\\nvar parts;\\ntry{\\n  parts=EXT==='glb'?parseGLB(buf):EXT==='gltf'?parseGLTF(buf):EXT==='stl'?parseSTL(buf):parseOBJ(buf);\\n}catch(e){\\n  var m=String(e&&e.message||e);\\n  say(m==='compressed'?'This glTF uses Draco/meshopt compression, which this viewer cannot unpack.'\\n    :m==='external'?'This .gltf refers to a separate .bin file. Use a .glb instead — it bundles everything.'\\n    :'Could not read this model file.');\\n  return;\\n}\\nvar tris=0;parts.forEach(function(p){tris+=p.pos.length/9;});\\nif(!tris){say('This model has no triangles to draw.');return;}\\n\\n/* bounds in world space */\\nvar lo=[1e30,1e30,1e30],hi=[-1e30,-1e30,-1e30];\\nparts.forEach(function(p){\\n  var m=p.mat;\\n  for(var i=0;i<p.pos.length;i+=3){\\n    var x=p.pos[i],y=p.pos[i+1],z=p.pos[i+2],X,Y,Z;\\n    if(m){X=m[0]*x+m[4]*y+m[8]*z+m[12];Y=m[1]*x+m[5]*y+m[9]*z+m[13];Z=m[2]*x+m[6]*y+m[10]*z+m[14];}\\n    else{X=x;Y=y;Z=z;}\\n    if(X<lo[0])lo[0]=X;if(Y<lo[1])lo[1]=Y;if(Z<lo[2])lo[2]=Z;\\n    if(X>hi[0])hi[0]=X;if(Y>hi[1])hi[1]=Y;if(Z>hi[2])hi[2]=Z;\\n  }\\n});\\nvar ctr=[(lo[0]+hi[0])/2,(lo[1]+hi[1])/2,(lo[2]+hi[2])/2];\\nvar rad=Math.max(1e-4,Math.hypot(hi[0]-lo[0],hi[1]-lo[1],hi[2]-lo[2])/2);\\n\\nvar gl=C.getContext('webgl',{antialias:true,alpha:true,premultipliedAlpha:false})\\n     ||C.getContext('experimental-webgl');\\nif(!gl){say('WebGL is not available in this browser.');return;}\\n\\nvar VS='attribute vec3 p;attribute vec3 n;uniform mat4 mvp;uniform mat4 mdl;uniform mat3 nm;'\\n      +'varying vec3 vn;varying vec3 vp;'\\n      +'void main(){vn=normalize(nm*n);vec4 w=mdl*vec4(p,1.0);vp=w.xyz;gl_Position=mvp*vec4(p,1.0);}';\\nvar FS='precision mediump float;varying vec3 vn;varying vec3 vp;uniform vec3 col;uniform vec3 eye;'\\n      +'void main(){vec3 N=normalize(vn);if(!gl_FrontFacing)N=-N;'\\n      +'vec3 V=normalize(eye-vp);'\\n      +'vec3 L1=normalize(vec3(0.45,0.80,0.60)),L2=normalize(vec3(-0.6,0.25,-0.5));'\\n      +'float d=max(dot(N,L1),0.0)*0.85+max(dot(N,L2),0.0)*0.28;'\\n      +'float rim=pow(1.0-max(dot(N,V),0.0),2.5)*0.22;'\\n      +'vec3 H=normalize(L1+V);float s=pow(max(dot(N,H),0.0),34.0)*0.30;'\\n      +'vec3 c=col*(0.26+d)+vec3(s)+vec3(0.06,0.09,0.10)*rim;'\\n      +'gl_FragColor=vec4(pow(clamp(c,0.0,1.0),vec3(0.4545)),1.0);}';\\nfunction sh(t,s){var o=gl.createShader(t);gl.shaderSource(o,s);gl.compileShader(o);return o;}\\nvar pg=gl.createProgram();\\ngl.attachShader(pg,sh(gl.VERTEX_SHADER,VS));gl.attachShader(pg,sh(gl.FRAGMENT_SHADER,FS));\\ngl.bindAttribLocation(pg,0,'p');gl.bindAttribLocation(pg,1,'n');\\ngl.linkProgram(pg);\\nif(!gl.getProgramParameter(pg,gl.LINK_STATUS)){say('WebGL shader failed to build.');return;}\\ngl.useProgram(pg);\\nvar U={mvp:gl.getUniformLocation(pg,'mvp'),mdl:gl.getUniformLocation(pg,'mdl'),\\n       nm:gl.getUniformLocation(pg,'nm'),col:gl.getUniformLocation(pg,'col'),\\n       eye:gl.getUniformLocation(pg,'eye')};
509\\n\\nparts.forEach(function(p){\\n  p.vb=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,p.vb);gl.bufferData(gl.ARRAY_BUFFER,p.pos,gl.STATIC_DRAW);\\n  p.nb=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,p.nb);gl.bufferData(gl.ARRAY_BUFFER,p.nrm,gl.STATIC_DRAW);\\n  p.count=p.pos.length/3;\\n  p.mat=p.mat||mIdent();p.nmat=p.nmat||mNormal(p.mat);\\n});\\ngl.enable(gl.DEPTH_TEST);gl.enableVertexAttribArray(0);gl.enableVertexAttribArray(1);\\n\\n/* camera: yaw / pitch / distance around the model centre */\\nvar yaw=0.7,pitch=0.38,dist=rad*2.7,spin=true,W=0,H=0;\\nfunction resize(){\\n  var dpr=Math.min(window.devicePixelRatio||1,2);\\n  var w=C.clientWidth||300,h=C.clientHeight||220;\\n  if(w===W&&h===H)return;\\n  W=w;H=h;C.width=Math.round(w*dpr);C.height=Math.round(h*dpr);\\n  gl.viewport(0,0,C.width,C.height);\\n}\\nfunction draw(){\\n  resize();\\n  if(spin)yaw+=0.0042;\\n  var cp=Math.cos(pitch),eye=[ctr[0]+dist*Math.sin(yaw)*cp,ctr[1]+dist*Math.sin(pitch),ctr[2]+dist*Math.cos(yaw)*cp];\\n  var vp=mMul(mPersp(0.82,(C.width/C.height)||1,rad*0.02,rad*40),mLook(eye,ctr,[0,1,0]));\\n  gl.clearColor(0,0,0,0);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);\\n  gl.uniform3fv(U.eye,eye);\\n  for(var i=0;i<parts.length;i++){\\n    var p=parts[i];\\n    gl.uniformMatrix4fv(U.mvp,false,mMul(vp,p.mat));\\n    gl.uniformMatrix4fv(U.mdl,false,p.mat);\\n    gl.uniformMatrix3fv(U.nm,false,p.nmat);\\n    gl.uniform3fv(U.col,p.color);\\n    gl.bindBuffer(gl.ARRAY_BUFFER,p.vb);gl.vertexAttribPointer(0,3,gl.FLOAT,false,0,0);\\n    gl.bindBuffer(gl.ARRAY_BUFFER,p.nb);gl.vertexAttribPointer(1,3,gl.FLOAT,false,0,0);\\n    gl.drawArrays(gl.TRIANGLES,0,p.count);\\n  }\\n  raf=requestAnimationFrame(draw);\\n}\\nvar raf=requestAnimationFrame(draw);\\n/* stop drawing while the card is off screen or the tab is hidden */\\nfunction pause(){if(raf){cancelAnimationFrame(raf);raf=0;}}\\nfunction resume(){if(!raf)raf=requestAnimationFrame(draw);}\\ndocument.addEventListener('visibilitychange',function(){document.hidden?pause():resume();});\\nif(window.IntersectionObserver)new IntersectionObserver(function(es){\\n  es[0].isIntersecting?resume():pause();\\n}).observe(C);\\n\\n/* ---------- orbit / zoom ---------- */\\nvar drag=false,lx=0,ly=0;\\nC.addEventListener('pointerdown',function(e){\\n  drag=true;spin=false;lx=e.clientX;ly=e.clientY;C.setPointerCapture(e.pointerId);C.style.cursor='grabbing';\\n});\\nC.addEventListener('pointermove',function(e){\\n  if(!drag)return;\\n  yaw-=(e.clientX-lx)*0.0095;\\n  pitch=Math.max(-1.45,Math.min(1.45,pitch+(e.clientY-ly)*0.0095));\\n  lx=e.clientX;ly=e.clientY;\\n});\\n['pointerup','pointercancel'].forEach(function(k){\\n  C.addEventListener(k,function(){drag=false;C.style.cursor='grab';});\\n});\\nC.addEventListener('wheel',function(e){\\n  e.preventDefault();\\n  dist=Math.max(rad*1.15,Math.min(rad*14,dist*(1+(e.deltaY>0?0.12:-0.12))));\\n},{passive:false});\\nC.addEventListener('dblclick',function(){yaw=0.7;pitch=0.38;dist=rad*2.7;spin=true;});\\nBADGE.textContent=EXT.toUpperCase()+' · '+tris.toLocaleString()+' tri';\\nBADGE.style.display='block';\\n}\\n/* https 模型:用 fetch 取回(對方主機必須送 Access-Control-Allow-Origin),上限 40 MB */\\nif(/^https:/i.test(SRC)){\\n  say('Loading 3D model\\\\u2026');\\n  fetch(SRC,{credentials:'omit'}).then(function(r){\\n    if(!r.ok)throw new Error('http');\\n    var n=+(r.headers.get('content-length')||0);if(n>41943040)throw new Error('big');\\n    return r.arrayBuffer();\\n  }).then(function(b){\\n    if(b.byteLength>41943040)throw new Error('big');\\n    NOTE.style.display='none';start(b);\\n  }).catch(function(e){\\n    say(e&&e.message==='big'?'This model is larger than 40 MB.':'Could not download this model. Its host must allow cross-origin (CORS) access.');\\n  });\\n}else start(toBuf(SRC));\\n})();\\n";\r
510/* 一張 3D 卡的完整文件 */\r
511function modelDoc(m){\r
512  return '<!doctype html><html><head><meta charset="utf-8">'\r
513    +'<meta name="viewport" content="width=device-width,initial-scale=1"><style>'+M3D_CSS+'</style></head>'\r
514    +'<body><div id="w">
514<canvas id="c" data-ext="'+esc(m.e)+'" data-src="'+esc(m.d||m.u)+'"></canvas>'\r
515    +'<div id="n"></div><div id="b"></div></div><script>'+VIEWER3D+'<\\/script></body></html>';\r
516}\r
517/* EzSheet 裡的可讀表示法,貼回去也還原得回來 */\r
518function modelTag(m){\r
519  return '<model type="'+esc(m.e)+'" name="'+esc(m.n||'')+'" src="'+esc(m.d||m.u)+'"></model>';\r
520}\r
521/* <model …> 標籤 -> mdl 物件 */\r
522function parseModelTag(s){\r
523  const g=k=>((s.match(new RegExp('\\\\b'+k+'=["\\']([^"\\']*)["\\']','i'))||[])[1]||'');\r
524  const d=g('src').replace(/&amp;/g,'&'),e=g('type').toLowerCase()||(d.match(/^data:model\\/(gltf-binary|gltf\\+json|stl|obj)/i)||[])[1]||'';\r
525  let ex=e==='gltf-binary'?'glb':e==='gltf+json'?'gltf':e;\r
526  if(/^https:\\/\\//i.test(d)){\r
527    const u=httpUrl(d);if(!u)return null;\r
528    if(!ex)ex=modelExt(new URL(u).pathname);\r
529    return M3D_OK.test(ex)?{u,e:ex,n:g('name')||decodeURIComponent(new URL(u).pathname.split('/').pop()||'')}:null;\r
530  }\r
531  return M3D_OK.test(ex)&&/^data:[^,]{0,120},/.test(d)?{d,e:ex,n:g('name')}:null;\r
532}\r
533const isModelFile=f=>M3D_EXT.test(f&&f.name||'');\r
534const modelExt=name=>String(name||'').toLowerCase().replace(/^.*\\./,'');\r
535\r
536/* ==================== 插卡 ====================\r
537   每張卡左下角一個「+」:在這張卡前面插入一張新的。\r
538   編輯器裡是版主在編自己的牆;獨立牆裡開放給任何訪客ï¼
538Œ\r
539   但訪客插的卡只寫進他自己瀏覽器的 localStorage,不會influence別人。 */\r
540\r
541/* 把一段貼上的內容變成一張卡;看不懂就回 null。\r
542   編輯器的 makeItem 與插卡對話框共用這一份,判斷標準永遠一致。 */\r
543function parseOne(raw){\r
544  raw=String(raw||'').trim();if(!raw)return null;\r
545  if(MD_RE.test(raw))return normalize({_raw:raw,type:'md',md:mdInner(raw)});\r
546\r
547  /* 自動偵測 HTML 內容或嵌入碼 */\r
548  if(isHtml(raw)){\r
549    if(/^<model\\b/i.test(raw)){const m=parseModelTag(raw);if(m)return normalize({_raw:raw,type:'model',mdl:m});}\r
550    const src=((raw.match(/\\bsrc=["']([^"']+)["']/i)||[])[1]||'').replace(/&amp;/g,'&');\r
551    const yt=src.match(YT);\r
552    if(yt)return normalize({_raw:raw,type:'youtube',id:yt[1],url:src});\r
553    if(/^<iframe\\b[^>]*>\\s*<\\/iframe>$/i.test(raw)){const u=httpUrl(src);if(u)return normalize({_raw:raw,type:'web',url:u});}\r
554    return normalize({_raw:raw,type:'html',html:raw});\r
555  }\r
556\r
557  if(raw.startsWith('<')){\r
558    if(/^<model\\b/i.test(raw)){const m=parseModelTag(raw);if(m)return normalize({_raw:raw,type:'model',mdl:m});}\r
559    const src=((raw.match(/\\bsrc=["']([^"']+)["']/i)||[])[1]||'').replace(/&amp;/g,'&');\r
560    const yt=src.match(YT);\r
561    if(yt)return normalize({_raw:raw,type:'youtube',id:yt[1],url:src});\r
562    if(/^<iframe\\b[^>]*>\\s*<\\/iframe>$/i.test(raw)){const u=httpUrl(src);if(u)return normalize({_raw:raw,type:'web',url:u});}\r
563    return normalize({_raw:raw,type:'html',html:raw});\r
564  }\r
565  const yt=raw.match(YT);if(yt)return normalize({_raw:raw,type:'youtube',id:yt[1],url:raw});\r
566  let s=raw;\r
567  let isPotentialUrl=false;\r
568  if(/^https?:\\/\\//i.test(s)){\r
569    isPotentialUrl=!/\\s/.test(s);\r
570  }else if(!/\\s/.test(s)&&/^[^\\/\\s]+\\.[a-z]{2,}(\\/|:|\\?|#|$)/i.test(s)){\r
571    s='https://'+s;\r
572    isPotentialUrl=true;\r
573  }\r
574  if(isPotentialUrl){\r
575    const u=httpUrl(s);\r
576    if(u){\r
577      /* 直接指向 .glb/.gltf/.stl/.obj 的 https 網址 → 3D 卡(對方主機要允許 CORS) */\r
578      try{const x=new URL(u);if(x.protocol==='https:'&&M3D_EXT.test(x.pathname))\r
579        return normalize({_raw:raw,type:'model',mdl:{u,e:modelExt(x.pathname),n:decodeURIComponent(x.pathname.split('/').pop())}});}catch(e){}\r
580      return normalize({_raw:raw,type:'web',url:u});\r
581    }\r
582  }\r
583\r
584  /* 自動偵測 Markdown 或富文字內容 */\r
585  if(isMarkdown(raw)){\r
586    const md=raw;\r
587    if(md.length>MD_MAX)return null;\r
588    return normalize({_raw:mdTag(md),type:'md',md});\r
589  }\r
590  return null;\r
591}\r
592/* 訪客插的卡要記住「插在誰前面」。卡片的 _id 每次載入都會重新產生,\r
593   不能當錨點,所以用原文的雜湊值。 */\r
594function rawHash(s){\r
595  let x=2166136261;s=String(s||'');\r
596  for(let i=0;i<s.length;i++){x^=s.charCodeAt(i);x=Math.imul(x,16777619);}\r
597  return (x>>>0).toString(36);\r
598}\r
599\r
600/* ---------- 調整卡片大小(編輯器與獨立牆共用) ----------\r
601   右下角把手同時調寬高,側邊把手只調寬度。\r
602   內容有固定長寬比的卡(影片之類)預設維持比例,按住 Shift 才能自由拉高。 */\r
603function resizeStart(a,el,o,side,ev,onDone){\r
604  ev.preventDefault();\r
605  try{a.setPointerCapture(ev.pointerId);}catch(e){}\r
606  document.body.classList.add('resizing');el.classList.add('dragging');\r
607  const sx=ev.clientX,sy=ev.clientY,sw=el.offsetWidth,sh=el.offsetHeight;\r
608  const locked=o.fit&&o.fit.t!=='page';let free=false;\r
609  const move=e2=>{\r
610    o.w=Math.max(MIN,Math.round((sw+e2.clientX-sx)/GRID)*GRID);\r
611    free=side?false:(!locked||e2.shiftKey);\r
612    o.h=free?Math.max(MIN,Math.round((sh+e2.clientY-sy)/GRID)*GRID)\r
613            :(locked?fitH(o,o.w,2):Math.max(MIN,Math.round(sh*(o.w/Math.max(1,sw))/GRID)*GRID));\r
614    applySize(el,o);\r
615  };\r
616  const up=()=>{\r
617    a.removeEventListener('pointermove',move);a.removeEventListener('pointerup',up);\r
618    a.removeEventListener('pointercancel',up);\r
619    document.body.classList.remove('resizing');el.classList.remove('dragging');\r
620    o.manual=locked&&free;o.span=0;\r
621    if(onDone)onDone();\r
622  };\r
623  a.addEventListener('pointermove',move);a.addEventListener('pointerup',up);\r
624  a.addEventListener('pointercancel',up);\r
625}\r
626\r
627let insBox=null;\r
628function insClose(){if(insBox){insBox.remove();insBox=null;}}\r
629/* 插卡對話框:貼上 → 檢查 → 可以呈現才交給 onSave */\r
630function insertDialog(guest,onSave){\r
631  insClose();\r
632  const box=document.createElement('div');\r
633  box.className='ins-modal';box.id='insModal';\r
634  box.innerHTML='<div class="ins-card" role="dialog" aria-modal="true" aria-labelledby="insHead">'\r
635    +'<b id="insHead" data-i18n="insTitle"></b>'\r
636    /* 三種情況說三種話:沒接伺服器/連著/設了但現在斷線 */\r
637    +'<p class="ins-hint" data-i18n="'+(guest?(SYNC?(SYNC_UP?'insHintLive':'insDown'):'insHintGuest'):'insHintOwner')+'"></p>'\r
638    +'<textarea id="insTa" rows="3" spellcheck="false" data-i18n-ph="insPh" data-i18n-aria="insTitle"></textarea>'\r
639    +'<div class="ins-kinds">'\r
640    +'<div class="ins-kinds-left" style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">'\r
641    +'<button type="button" class="ins-kind" id="insMd" data-i18n="insMd"></button>'\r
642    +'<button type="button" class="ins-kind ins-preview-btn" id="insPreviewBtn" style="display:none;background:#fff;color:#111;border:1.5px solid #111;border-radius:999px;padding:3px 10px;font-size:11px;font-weight:800;cursor:pointer">👁 Preview</button>'\r
643    +'<span class="ins-md-badge" id="insMdBadge" style="display:none;font-size:11px;font-weight:800;color:#0E7C7B;background:#ecfdf5;border:1px solid #a7f3d0;border-radius:999px;padding:2px 8px">✓ Markdown detected</span>'\r
644    +'<span class="ins-html-badge" id="insHtmlBadge" style="display:none;font-size:11px;font-weight:800;color:#2563EB;background:#eff6ff;border:1px solid #bfdbfe;border-radius:999px;padding:2px 8px">✓ HTML detected</span>'\r
645    +'</div>'\r
646    +'<span class="ins-kinds-note" data-i18n="insKinds"></span>'\r
647    +'</div>'\r
648    +'<div class="ins-md-preview-pane" id="insMdPreviewPane" style="display:none;border:2px solid #111;border-radius:12px;background:#fff;padding:12px;max-height:240px;overflow:auto;display:none;flex-direction:column;gap:8px">'\r
649    +'<div class="ins-md-preview-head" style="display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:900;text-transform:uppercase;color:#0E7C7B;border-bottom:1px solid #e5e7eb;padding-bottom:4px"><span id="insPreviewTitle">Preview</span><button type="button" id="insMdPreviewClose" style="background:none;border:none;cursor:pointer;font-weight:900;font-size:12px">✕</button></div>'\r
650    +'<div class="ins-md-preview-body" id="insMdPreviewBody" style="font-size:13px;line-height:1.6;color:#111;overflow-wrap:anywhere"></div>'\r
651    +'<iframe class="ins-preview-frame" id="insHtmlPreviewFrame" style="display:none;width:100%;height:180px;border:1.5px solid #e2e8f0;border-radius:8px;background:#fff" sandbox="allow-scripts allow-forms allow-popups"></iframe>'\r
652    +'</div>'\r
653    +'<div class="ins-err" id="insErr" role="alert"></div>'\r
654    +'<div class="ins-go"><button type="button" class="ins-btn" id="insNo" data-i18n="insCancel"></button>'\r
655    +'<button type="button" class="ins-btn on" id="insYes" data-i18n="insSave"></button></div></div>';\r
656  document.body.appendChild(box);insBox=box;\r
657  applyI18n();\r
658  const ta=box.querySelector('#insTa'),err=box.querySelector('#insErr');\r
659  const btnYes=box.querySelector('#insYes'),btnNo=box.querySelector('#insNo');\r
660  const btnPreview=box.querySelector('#insPreviewBtn');\r
661  const mdBadge=box.querySelector('#insMdBadge');\r
662  const htmlBadge=box.querySelector('#insHtmlBadge');\r
663  const previewPane=box.querySelector('#insMdPreviewPane');\r
664  const previewTitle=box.querySelector('#insPreviewTitle');\r
665  const previewBody=box.querySelector('#insMdPreviewBody');\r
666  const htmlFrame=box.querySelector('#insHtmlPreviewFrame');\r
667  const previewClose=box.querySelector('#insMdPreviewClose');\r
668  box.addEventListener('click',e=>{if(e.target===box)insClose();});\r
669  btnNo.addEventListener('click',insClose);\r
670\r
671  const checkInputState=()=>{\r
672    const v=ta.value.trim();\r
673    if(isHtml(v)){\r
674      htmlBadge.style.display='inline-flex';\r
675      mdBadge.style.display='none';\r
676      btnPreview.style.display='inline-flex';\r
677      previewTitle.textContent='HTML Preview';\r
678      previewTitle.style.color='#2563EB';\r
679      if(previewPane.style.display!=='none'){\r
680        previewBody.style.display='none';\r
681        htmlFrame.style.display='block';\r
682        htmlFrame.srcdoc=htmlDoc(v);\r
683      }\r
684    }else if(isMarkdown(v)){\r
685      mdBadge.style.display='inline-flex';\r
686      htmlBadge.style.display='none';\r
687      btnPreview.style.display='inline-flex';\r
688      previewTitle.textContent='Markdown Preview';\r
689      previewTitle.style.color='#0E7C7B';\r
690      if(previewPane.style.display!=='none'){\r
691        htmlFrame.style.display='none';\r
692        previewBody.style.display='block';\r
693        previewBody.innerHTML=mdRender(MD_RE.test(v)?mdInner(v):v);\r
694      }\r
695    }else{\r
696      mdBadge.style.display='none';\r
697      htmlBadge.style.display='none';\r
698      btnPreview.style.display='none';\r
699      previewPane.style.display='none';\r
700      htmlFrame.style.display='none';\r
701      btnPreview.textContent='👁 Preview';\r
702    }\r
703  };\r
704\r
705  btnPreview.addEventListener('click',()=>{\r
706    if(previewPane.style.display==='none'){\r
707      const v=ta.value.trim();\r
708      if(isHtml(v)){\r
709        previewBody.style.display='none';\r
710        htmlFrame.style.display='block';\r
711        htmlFrame.srcdoc=htmlDoc(v);\r
712        previewTitle.textContent='HTML Preview';\r
713        previewTitle.style.color='#2563EB';\r
714      }else{\r
715        htmlFrame.style.display='none';\r
716        previewBody.style.display='block';\r
717        previewBody.innerHTML=mdRender(MD_RE.test(v)?mdInner(v):v);\r
718        previewTitle.textContent='Markdown Preview';\r
719        previewTitle.style.color='#0E7C7B';\r
720      }\r
721      previewPane.style.display='flex';\r
722      btnPreview.textContent='✎ Edit text';\r
723    }else{\r
724      previewPane.style.display='none';\r
725      btnPreview.textContent='👁 Preview';\r
726      ta.focus();\r
727    }\r
728  });\r
729\r
730  previewClose.addEventListener('click',()=>{\r
731    previewPane.style.display='none';\r
732    btnPreview.textContent='👁 Preview';\r
733    ta.focus();\r
734  });\r
735\r
736  /* 一鍵包成 Markdown 卡:已經有內容就把它包進 <md>,沒有就放一個範本 */\r
737  box.querySelector('#insMd').addEventListener('click',()=>{\r
738    const v=ta.value.trim();\r
739    if(!MD_RE.test(v)){ta.value=mdTag(v||t('insMdTpl'));}\r
740    ta.focus();const p=ta.value.indexOf('\\n')+1;ta.setSelectionRange(p,ta.value.length-6);err.textContent='';\r
741    checkInputState();\r
742  });\r
743  let isSubmitting = false;\r
744  const commit = () => {\r
745    if (isSubmitting) return;\r
746    let v = ta.value.trim();\r
747    if (!v) { err.textContent = t('insBad'); ta.focus(); return; }\r
748\r
749    if (isMarkdown(v) && !isHtml(v) && (MD_RE.test(v) ? mdInner(v).length : v.length) > MD_MAX) {\r
750      err.textContent = t('insBig');\r
751      ta.focus();\r
752      return;\r
753    }\r
754\r
755    if (isMarkdown(v) && !isHtml(v) && !MD_RE.test(v)) {\r
756      v = mdTag(v);\r
757    }\r
758\r
759    const o = parseOne(v);\r
760    if (!o) { err.textContent = t('insBad'); ta.focus(); return; }\r
761\r
762    isSubmitting = true;\r
763    btnYes.disabled = true;\r
764    btnNo.disabled = true;\r
765    btnYes.style.pointerEvents = 'none';\r
766    const origYesHtml = btnYes.innerHTML;\r
767    btnYes.innerHTML = '<span class="ins-spin"></span><span>' + (t('insSaving') || t('insSave') || 'Saving...') + '</span>';\r
768    err.textContent = '';\r
769\r
770    const back = why => {\r
771      isSubmitting = false;\r
772      btnYes.disabled = false;\r
773      btnNo.disabled = false;\r
774      btnYes.style.pointerEvents = '';\r
775      btnYes.innerHTML = origYesHtml;\r
776      err.textContent = t(why || 'insBusy');\r
777      ta.focus();\r
778    };\r
779\r
780    try {\r
781      const r = onSave(o);\r
782      if (!r || typeof r.then !== 'function') {\r
783        setTimeout(() => insClose(), 250);\r
784        return;\r
785      }\r
786      r.then(\r
787        ok => {\r
788          if (ok === true) insClose();\r
789          else back(typeof ok === 'string' ? ok : 'insBusy');\r
790        },\r
791        () => back('insDown')\r
792      );\r
793    } catch (e) {\r
794      back('insBusy');\r
795    }\r
796  };\r
797  btnYes.addEventListener('click',commit);\r
798  ta.addEventListener('input',()=>{err.textContent='';checkInputState();});\r
799  ta.addEventListener('paste',()=>{setTimeout(checkInputState,10);});\r
800  box.addEventListener('keydown',e=>{\r
801    e.stopPropagation();                       /* 別讓「/」開篩選之類的快捷鍵插手 */\r
802    if(e.key==='Escape'){e.preventDefault();insClose();}\r
803    else if(e.key==='Enter'&&(e.ctrlKey||e.metaKey)){e.preventDefault();commit();}\r
804  });\r
805  setTimeout(()=>ta.focus(),30);\r
806}\r
807\r
808/* ==================== 伺服器同步(選配) ====================\r
809   setWallSync('https://ez.wiki') 之後,訪客插的卡改走伺服器:\r
810   立刻公開、用 SSE 推給所有正在看的人,版主另外有一份待審列表。\r
811   沒設就完全是原本的行為——卡片只存在訪客自己的瀏覽器裡。 */\r
812let SYNC='',SYNC_ES=null,SYNC_UP=false;   /* SYNC=有沒有設定;SYNC_UP=此刻通不通 */\r
813function setWallSync(u){\r
814  SYNC=httpUrl(u)?String(u).replace(/\\/+$/,''):'';\r
815  /* 同步和嵌入檢查是同一台伺服器,沒有另外指定就自動接上 */\r
816  if(SYNC&&!FRAME_CHECK)setFrameCheck(SYNC+'/api/frame-check');\r
817}\r
818/* 這位訪客的身分:只用來讓他刪掉自己貼的卡,伺服器只存雜湊後的值 */\r
819function wallMe(){\r
820  let v='';try{v=localStorage.getItem('wall_me')||'';}catch(e){}\r
821  if(!/^[a-z0-9-]{8,64}$/i.test(v)){\r
822    v=(crypto&&crypto.randomUUID)?crypto.randomUUID():String(Math.random()).slice(2)+Date.now().toString(36);\r
823    try{localStorage.setItem('wall_me',v);}catch(e){}\r
824  }\r
825  return v;\r
826}\r
827function ownerToken(){try{return localStorage.getItem('wall_owner')||'';}catch(e){return '';}}\r
828function setOwnerToken(v){try{v?localStorage.setItem('wall_owner',v):localStorage.removeItem('wall_owner');}catch(e){}}\r
829function syncHeaders(json){\r
830  const hd={'x-wall-me':wallMe()};\r
831  if(json)hd['content-type']='application/json';\r
832  const o=ownerToken();if(o)hd['x-wall-owner']=o;\r
833  if(typeof window !== 'undefined' && window.auth && window.auth.user) {\r
834    hd['x-user-id'] = String(window.auth.user.id || '');\r
835  }\r
836  if(typeof window !== 'undefined' && window.isOwner) {\r
837    hd['x-is-owner'] = '1';\r
838  }\r
839  return hd;\r
840}\r
841function getEffectiveOrigin(){\r
842  if (SYNC && SYNC !== 'null' && !SYNC.startsWith('about:')) return SYNC;\r
843  if (typeof window !== 'undefined' && window.location && window.location.origin && window.location.origin !== 'null' && !window.location.origin.startsWith('about:')) {\r
844    return window.location.origin;\r
845  }\r
846  return '';\r
847}\r
848const syncBase=id=>{\r
849  let o = String(getEffectiveOrigin() || '');\r
850  while(o.endsWith('/')) o = o.slice(0, -1);\r
851  return (o ? o : '') + '/api/wall/' + encodeURIComponent(id);\r
852};\r
853function syncAdd(id,card){\r
854  const url = syncBase(id)+'/cards';\r
855  const bodyData = Object.assign({}, card, { wall_id: id });\r
856  return fetch(url, {\r
857    method: 'POST',\r
858    headers: syncHeaders(true),\r
859    credentials: 'same-origin',\r
860    body: JSON.stringify(bodyData)\r
861  }).then(async r => {\r
862    let j = null;\r
863    try { j = await r.json(); } catch(e){}\r
864    return { ok: r.ok, status: r.status, j };\r
865  });\r
866}\r
867function syncDrop(id,cid){\r
868  return fetch(syncBase(id)+'/cards/'+encodeURIComponent(cid),{\r
869    method:'DELETE',\r
870    headers:syncHeaders(false),\r
871    credentials:'same-origin'\r
872  }).then(r=>({ok:r.ok,status:r.status}));\r
873}\r
874function syncDropAll(id){\r
875  return fetch(syncBase(id)+'/cards',{\r
876    method:'DELETE',\r
877    headers:syncHeaders(false),\r
878    credentials:'same-origin'\r
879  }).then(r=>({ok:r.ok,status:r.status}));\r
880}\r
881function syncApprove(id,cid){\r
882  return fetch(syncBase(id)+'/cards/'+encodeURIComponent(cid)+'/approve',{\r
883    method:'POST',\r
884    headers:syncHeaders(fals
884e),\r
885    credentials:'same-origin'\r
886  }).then(r=>({ok:r.ok,status:r.status}));\r
887}\r
888function syncReview(id){\r
889  return fetch(syncBase(id)+'/review',{headers:syncHeaders(false)})\r
890    .then(r=>r.ok?r.json():Promise.reject(r.status));\r
891}\r
892/* SSE:sync=一次給全部,card/drop=單張增減,ping=心跳 */\r
893function syncStream(id,on){\r
894  if(!SYNC||typeof EventSource==='undefined')return null;\r
895  let es;\r
896  try{es=new EventSource(syncBase(id)+'/stream');}catch(e){return null;}\r
897  SYNC_ES=es;\r
898  es.addEventListener('sync',e=>{try{on('sync',JSON.parse(e.data));}catch(x){}});\r
899  es.addEventListener('card',e=>{try{on('card',JSON.parse(e.data));}catch(x){}});\r
900  es.addEventListener('drop',e=>{try{on('drop',JSON.parse(e.data));}catch(x){}});\r
901  es.addEventListener('promote',e=>{try{on('promote',JSON.parse(e.data));}catch(x){}});\r
902  es.addEventListener('error',()=>{SYNC_UP=false;on('down',null);});\r
903  es.addEventListener('open',()=>{SYNC_UP=true;on('up',null);});\r
904  addEventListener('pagehide',()=>{try{es.close();}catch(x){}});\r
905  return es;\r
906}\r
907/* 連線狀態的小圓點,和版主的待審鍵 */\r
908function syncBtnHTML(){\r
909  return '<span id="syncDot" class="pill sync" hidden title=""><span class="mi">●</span></span>'\r
910        +'<button id="revBtn" class="pill rev" title="Review List (🛡)" aria-label="Review List" data-i18n-aria="revTitle"><span class="mi">🛡</span></button>';\r
911}\r
912\r
913/* 3D 卡有自己的長寬比;HTML 與 md 卡自帶高度回報與視圖優化 */\r
914function srcdocOf(o){\r
915  if(o.type==='model')return o.html;\r
916  if(o.type==='md'){\r
917    if(o.html&&o.html.includes('__wallH'))return o.html;\r
918    if(o.html)return o.html.replace('</body>', REPORT + '</body>');\r
919    return mdDoc(o.md||'');\r
920  }\r
921  if(o.type==='html'){\r
922    if(o.html&&o.html.includes('__wallH'))return o.html;\r
923    return htmlDoc(o.html||o._raw||'');\r
924  }\r
925  return o.html+REPORT;\r
926}\r
927const measureCbs=[];\r
928window.addEventListener('message',e=>{\r
929  const d=e.data;if(!d||typeof d.__wallH!=='number'||!(d.__wallH>0))return;\r
930  const f=[...document.querySelectorAll('iframe.html-frame')].find(x=>x.contentWindow===e.source);if(!f)return;\r
931  const el=f.closest('.item');\r
932  /* A 區卡片的 id 前面多了 a-,回報時換回原本的卡片 id */\r
933  if(el)measureCbs.forEach(cb=>cb(el.dataset.id.replace(/^[ac]-/,''),Math.min(Math.round(d.__wallH),MAX-BORDER)));\r
934});\r
935function onMeasure(cb){measureCbs.push(cb);}\r
936/* 選配:伺服器端嵌入檢查。瀏覽器讀不到別的網站能不能被嵌入,只有伺服器能看 X-Frame-Options/CSP。\r
937   setFrameCheck('https://ez.wiki/api/frame-check') 後,會對一般網頁卡 GET ?url=…,\r
938   回傳 {"embeddable":false} 的就改成墓碑。未設定時只用上面的已知清單與手動標記。 */\r
939let FRAME_CHECK='';const asked=new Set();\r
940function setFrameCheck(u){FRAME_CHECK=httpUrl(u)?u:'';}\r
941function checkFrames(list,onBlocked){\r
942  if(!FRAME_CHECK)return;\r
943  list.forEach(o=>{\r
944    if(o.type!=='web'||o.emb||o.blk||isTomb(o)||(o.fit&&o.fit.t!=='page')||asked.has(o.url))return;\r
945    asked.add(o.url);\r
946    fetch(FRAME_CHECK+(FRAME_CHECK.includes('?')?'&':'?')+'url='+encodeURIComponent(o.url))\r
947      .then(r=>r.ok?r.json():null).then(j=>{if(j&&j.embeddable===false){o.blk=true;o.fit=fitOf(o);onBlocked(o);}}).catch(()=>{});\r
948  });\r
949}\r
950/* ---------- 延遲載入 ----------\r
951   卡片接近畫面(上下一個螢幕高內)才建立 iframe,每個畫面格最多建 3 個,避免一次塞爆;\r
952   離開很遠(上下三個螢幕外)超過 10 秒就卸載,換回佔位。\r
953   使用者點進去互動過的卡(例如正在播的 Podcast)永遠不卸載。\r
954   牆放在 ez.wiki 預覽框裡也有效:交集是以最外層分頁的可視範圍計算。 */\r
955const LAZY='IntersectionObserver' in window;\r
956let nearIO=null,farIO=null,qRaf=0;const mountQ=new Set();\r
957function phHTML(o){\r
958  const k={video:'▶',audio:'♪',html:'</>',page:'🌐',model:'◈',md:'M↓'}[kindOf(o)]||'🌐';   /* sketchfab → ◈ */\r
959  const lbl=o.type==='md'?'Markdown':o.type==='model'?(o.mdl&&o.mdl.e||'3d').toUpperCase()\r
960    :o.type==='html'?'HTML':o.type==='youtube'?'youtube.com':hostOf(o.url);\r
961  return '<div class="ph" aria-hidden="true"><span class="ph-i">'+k+'</span><span class="ph-h">'+esc(lbl)+'</span></div>';\r
962}\r
963function mount(el){\r
964  if(el._mounted||!el._o)return;const ph=el.querySelector('.ph');if(!ph)return;\r
965  el._pw=el.clientWidth-BORDER;\r
966  const tp=document.createElement('template');tp.innerHTML=frameHTML(el._o,el._pw);\r
967  const f=tp.content.firstElementChild;if(f.classList.contains('html-frame'))f.srcdoc=srcdocOf(el._o);\r
968  ph.replaceWith(f);el._mounted=true;\r
969}\r
970function unmount(el){\r
971  if(!el._mounted||el._keep||el.classList.contains('engaged'))return;\r
972  const f=el.querySelector('iframe');if(!f)return;\r
973  const tp=document.createElement('template');tp.innerHTML=phHTML(el._o);\r
974  f.replaceWith(tp.content.firstElementChild);el._mounted=false;\r
975}\r
976function pump(){\r
977  if(qRaf)return;\r
978  qRaf=requestAnimationFrame(()=>{\r
979    qRaf=0;\r
980    if(document.body.classList.contains('shuffling'))return;\r
981    let n=0;\r
982    for(const el of mountQ){mountQ.delete(el);if(!el.isConnected||!(el._vis||el._keep))continue;
982mount(el);if(++n>=3)break;}\r
983    if(mountQ.size)pump();\r
984  });\r
985}\r
986function observeCard(el){\r
987  if(!nearIO){\r
988    nearIO=new IntersectionObserver(es=>es.forEach(e=>{\r
989      const el=e.target;el._vis=e.isIntersecting;\r
990      if(e.isIntersecting){clearTimeout(el._unT);if(!document.body.classList.contains('shuffling')){mountQ.add(el);pump();}}\r
991    }),{rootMargin:'100% 50%'});\r
992    farIO=new IntersectionObserver(es=>es.forEach(e=>{\r
993      const el=e.target;clearTimeout(el._unT);\r
994      if(!e.isIntersecting)el._unT=setTimeout(()=>unmount(el),10000);\r
995    }),{rootMargin:'300% 200%'});\r
996    /* 點進 iframe(播放、捲動內容)時外層會失焦:標記這張卡為互動中 */\r
997    addEventListener('blur',()=>setTimeout(()=>{const f=document.activeElement;if(f&&f.tagName==='IFRAME'){const it=f.closest('.item');if(it)it.classList.add('engaged');}},0));\r
998  }\r
999  nearIO.observe(el);farIO.observe(el);\r
1000}\r
1001function dropCard(el){if(nearIO){nearIO.unobserve(el);farIO.unobserve(el);}clearTimeout(el._unT);mountQ.delete(el);el.remove();}\r
1002function makeCard(o,ro){\r
1003  bindFold();\r
1004  const tp=document.createElement('template');tp.innerHTML=cardHTML(o,ro);\r
1005  const el=tp.content.firstElementChild;el._o=o;\r
1006  const f=el.querySelector('.html-frame');if(f)f.srcdoc=srcdocOf(o);\r
1007  if(el.querySelector('.ph'))observeCard(el);\r
1008  return el;\r
1009}\r
1010\r
1011function renderAll(wall,list,ro){wall.replaceChildren(...list.map(o=>makeCard(o,ro)));}\r
1012\r
1013function applySize(el,o){el.style.width=o.w+'px';el.style.height=o.h+'px';const t=el.querySelector('.corner-dim');if(t)t.textContent=o.w+'×'+o.h;}\r
1014/* 內容比卡片高:顯示底部的淡出與「展開全文」;展開中則顯示「收合」 */\r
1015function foldSync(el,o,h){\r
1016  const f=el.querySelector('.fold');if(!f)return;\r
1017  const cut=!!(o.mh&&o.mh+BORDER>h+6),open=!!o.full&&!!o.mh&&o.mh+BORDER>autoCap(el.clientWidth||h)+6;\r
1018  el.classList.toggle('clipped',cut);el.classList.toggle('unfolded',!cut&&open);\r
1019  const b=f.querySelector('.fold-btn'),k=cut?'foldMore':'foldLess';\r
1020  if(b.dataset.i18n!==k){b.dataset.i18n=k;b.textContent=t(k);}\r
1021}\r
1022let foldBound=false;\r
1023function bindFold(){\r
1024  if(foldBound)return;foldBound=true;\r
1025  document.addEventListener('click',e=>{\r
1026    const b=e.target.closest('.fold-btn');if(!b)return;\r
1027    const el=b.closest('.item'),o=el&&el._o;if(!o)return;\r
1028    e.preventDefault();e.stopPropagation();\r
1029    o.full=!o.full;\r
1030    /* 拉過高度的卡:展開=用完整高度,收合=回到上限 */\r
1031    if(o.manual)o.manual=false;\r
1032    if(!o.full&&el.getBoundingClientRect().top<0)el.scrollIntoView({block:'start',behavior:'smooth'});\r
1033    dispatchEvent(new Event('wall:relayout'));\r
1034  },true);\r
1035}\r
1036/* 來客卡被認可:就地換掉標記與移除鍵,iframe 不重新載入 */\r
1037function markApproved(o){\r
1038  o.ok=true;\r
1039  ['', 'a-', 'c-'].forEach(p=>document.querySelectorAll('.item[data-id="'+p+o._id+'"]').forEach(el=>{\r
1040    el.classList.remove('pending');el.classList.add('ok');\r
1041    const k=el.querySelector('.corner');if(k)k.outerHTML=cornerHTML(o);\r
1042    const g=el.querySelector('.gdel');\r
1043    const isOw = (typeof window !== 'undefined' && window.isOwner === true) || !!(typeof ownerToken === 'function' && ownerToken());\r
1044    if(g && !isOw)g.remove();\r
1045  }));\r
1046}\r
1047\r
1048/* N 欄:依牆面寬度均分;太窄時自動降欄,每張不小於 MIN */\r
1049function colSize(wall,n){\r
1050  const W=wall.clientWidth;\r
1051  const k=Math.max(1,Math.min(n,Math.floor((W+GAP)/(MIN+GAP))));\r
1052  return {k,w:Math.max(MIN,Math.floor((W-GAP*(k-1))/k))};\r
1053}\r
1054/* 排版:cols>0 → 等寬,每張依內容定高,放進目前最短的一欄\r
1055          cols=0 → 保留各卡寬高,用 skyline 找最高能放的位置,不等寬也能緊密排 */\r
1056function carK(W,cols){return cols>0?Math.max(1,Math.min(cols,Math.floor((W+GAP)/(MIN+GAP)))):Math.max(1,Math.min(4,Math.floor((W+GAP)/(340+GAP))));}\r
1057function layoutWall(wall,list,cols,car){\r
1058  const W=wall.clientWidth,pos=new Map(),sz=new Map();let H=0;\r
1059  /* 使用者拖過的卡片固定在自己的位置,其他卡片排版時會往下避開它們 */\r
1060  const fixed=[];\r
1061  if(!car)list.forEach(o=>{\r
1062    if(!o.free||o.px==null)return;\r
1063    const w=Math.min(o.w,W),x=Math.max(0,Math.min(o.px,Math.max(0,W-w))),y=Math.max(0,o.py);\r
1064    pos.set(o._id,[x,y]);fixed.push([x,y,w,o.h]);H=Math.max(H,y+o.h);\r
1065  });\r
1066  const avoid=(x,y,w,h)=>{\r
1067    let moved=true,guard=0;\r
1068    while(moved&&guard++<40){\r
1069      moved=false;\r
1070      for(const f of fixed){\r
1071        if(x<f[0]+f[2]+GAP&&f[0]<x+w+GAP&&y<f[1]+f[3]+GAP&&f[1]<y+h+GAP){y=f[1]+f[3]+GAP;moved=true;}\r
1072      }\r
1073    }\r
1074    return y;\r
1075  };\r
1076  if(car){\r
1077    /* 輪播:一次顯示的張數=欄位設定(隨機/原始時依寬度自動 1~4 張)。\r
1078       尺寸只用來顯示,不寫回卡片資料,關掉輪播後原本的版面不變 */\r
1079    const k=carK(W,cols),w=Math.max(MIN,Math.floor((W-GAP*(k-1))/k));\r
1080    wall._hs=[];\r
1081    list.forEach((o,i)=>{const h=fitH(o,w,k);sz.set(o._id,{w,h});pos.set(o._id,[i*(w+GAP),0]);wall._hs.push(h);if(h>H)H=h;});\r
1082    wall.dataset.k=k;wall._step=w+GAP;wall._n=list.length;wall._ids=list.map(o=>o._id);\r
1083  }else if(cols>0){\r
1084    const {k,w}=colSize(wall,cols),colH=new Array(k).fill(0);\r
1085    list.forEach(o=>{\r
1086      o.w=w;o.h=fitH(o,w,k);o.manual=false;o.span=0;\r
1087      if(pos.has(o._id))return;                       /* 已固定的卡片不參與排版 */\r
1088      let c=0;for(let i=1;i<k;i++)if(colH[i]<colH[c]-.5)c=i;\r
1089      const x=c*(w+GAP),y=avoid(x,colH[c],w,o.h);\r
1090      pos.set(o._id,[x,y]);colH[c]=y+o.h+GAP;\r
1091    });\r
1092    H=Math.max(H,Math.max(...colH)-GAP);\r
1093  }else{\r
1094    /* 自由/隨機:把牆切成 G 條細欄(約 190px 一條),每張卡橫跨 1~3 條。\r
1095       隨機的卡記的是「跨幾條+高寬比」,換螢幕寬度也會整齊貼齊左右兩邊;\r
1096       手動拉過的卡保留自己的寬度,佔用夠放它的條數 */\r
1097    const G=Math.max(2,Math.min(8,Math.round((W+GAP)/(190+GAP)))),cw=(W-GAP*(G-1))/G,colH=new Array(G).fill(0);\r
1098    list.forEach(o=>{\r
1099      let s;\r
1100      if(o.span){s=Math.min(o.span,G);o.w=Math.round(s*cw+(s-1)*GAP);o.h=(o.fit||{}).t==='page'?Math.max(MIN,Math.round(o.w*(o.rh||.75))):fitH(o,o.w,2);}\r
1101      else s=Math.min(G,Math.max(1,Math.ceil((Math.min(o.w,W)+GAP)/(cw+GAP)-.001)));\r
1102      if(pos.has(o._id))return;\r
1103      let bc=0,by=Infinity;\r
1104      for(let c=0;c+s<=G;c++){let y=0;for(let j=c;j<c+s;j++)if(colH[j]>y)y=colH[j];if(y<by-.5){by=y;bc=c;}}\r
1105      const x=Math.round(bc*(cw+GAP));by=avoid(x,by,Math.round(s*cw+(s-1)*GAP),o.h);\r
1106      pos.set(o._id,[x,by]);for(let j=bc;j<bc+s;j++)colH[j]=by+o.h+GAP;\r
1107    });\r
1108    H=Math.max(H,Math.max(0,...colH)-GAP);\r
1109  }\r
1110  const byId=new Map(list.map(o=>[o._id,o]));\r
1111  wall.querySelectorAll('.item').forEach(el=>{\r
1112    const o=byId.get(el.dataset.id),p=pos.get(el.dataset.id);if(!o||!p)return;\r
1113    const d=sz.get(el.dataset.id)||o;\r
1114    el._o=o;applySize(el,d);foldSync(el,o,d.h);el.style.left=p[0]+'px';el.style.top=p[1]+'px';\r
1115    el.classList.toggle('free',!!o.free&&!car);\r
1116    /* Facebook 外掛寬度寫在網址裡:卡片寬度變很多時換一個對應寬度的新框 */\r
1117    if(el._mounted&&o.fit&&o.fit.t==='lin'&&Math.abs((el._pw||0)-(d.w-BORDER))>24){\r
1118      const f=el.querySelector('iframe'),tp=document.createElement('template');el._pw=d.w-BORDER;\r
1119      tp.innerHTML=frameHTML(o,el._pw);if(f)f.replaceWith(tp.content.firstElementChild);\r
1120    }\r
1121  });\r
1122  wall.style.height=list.length?Math.max(0,H)+'px':'';\r
1123  if(!wall.classList.contains('ready'))requestAnimationFrame(()=>requestAnimationFrame(()=>wall.classList.add('ready')));\r
1124  if(car){\r
1125    /* 版面變動後瀏覽器會「追著原本貼齊的那張」捲動,所以明確捲回目前這一頁 */\r
1126    const {k,step,pages}=carState(wall),pg=Math.min(wall._carPage||0,pages-1);\r
1127    const sb=wall.style.scrollBehavior;wall.style.scrollBehavior='auto';wall.scrollLeft=pg*k*step;wall.style.scrollBehavior=sb;\r
1128    carSync(wall,true);\r
1129  }\r
1130}\r
1131\r
1132/* ---------- 輪播控制:底部 ‹ 點點 ›、方向鍵、觸控滑動(原生捲動) ---------- */\r
1133function carouselBtnHTML(){return '<button id="carBtn" class="pill car" aria-pressed="false" data-i18n-aria="carousel"><span class="mi">🎠</span><span class="lbl" data-i18n="carousel"></span></button>';}\r
1134function carState(wall){const k=+wall.dataset.k||1,step=wall._step||1,n=wall._n||0;return {k,step,n,pages:Math.max(1,Math.ceil(n/k))};}\r
1135function carCurrent(wall){\r
1136  const {k,step,pages}=carState(wall);if(!wall._n)return 0;\r
1137  if(wall.scrollLeft>=wall.scrollWidth-wall.clientWidth-2&&wall.scrollLeft>0)return pages-1;\r
1138  return Math.max(0,Math.min(pages-1,Math.round(wall.scrollLeft/step/k)));\r
1139}\r
1140function carGo(wall,p){const {k,step,pages}=carState(wall);p=Math.max(0,Math.min(pages-1,p));wall.scrollTo({left:p*k*step});}\r
1141let carRaf=0;\r
1142function placeSides(wall){\r
1143  const L=document.getElementById('carL'),R=document.getElementById('carR');if(!L)return;\r
1144  const on=wall.classList.contains('carousel');L.hidden=R.hidden=!on;if(!on)return;\r
1145  const r=wall.getBoundingClientRect(),h=parseFloat(wall.style.height)||r.height,sz=L.offsetWidth||44;\r
1146  const y=r.top+scrollY+Math.min(h/2,260)-sz/2;\r
1147  L.style.top=R.style.top=Math.round(y)+'px';\r
1148  L.style.left=Math.round(r.left+scrollX+6)+'px';\r
1149  R.style.left=Math.round(r.right+scrollX-sz-6)+'px';\r
1150}\r
1151function carSync(wall,force){\r
1152  const nav=document.getElementById('carNav');if(!nav||nav.hidden){placeSides(wall);return;}\r
1153  const {pages,k,step,n}=carState(wall),cur=carCurrent(wall),box=nav.querySelector('.car-dots');\r
1154  const first=Math.max(0,Math.min(Math.round(wall.scrollLeft/step),n-k));\r
1155  if(!force&&cur===wall._carPage&&first===wall._carFirst)return;\r
1156  wall._carPage=cur;wall._carFirst=first;\r
1157  if(wall._ids){\r
1158    const idx=new Map(wall._ids.map((id,i)=>[id,i])),from=first-k,to=first+2*k;\r
1159    wall.querySelectorAll('.item').forEach(el=>{const i=idx.get(el.dataset.id);el._keep=i!=null&&i>=from&&i<to;if(el._keep)mountQ.add(el);});\r
1160    pump();\r
1161  }\r
1162  /* 牆高=目前看得到的幾張裡最高的那張,不留ä¸
1162‹æ–¹ç©ºç™½ */\r
1163  if(wall._hs&&wall._hs.length){const vis=wall._hs.slice(first,first+k);if(vis.length)wall.style.height=Math.max(...vis)+'px';}\r
1164  if(pages<=10){\r
1165    if(box.children.length!==pages||box.firstElementChild&&!box.firstElementChild.classList.contains('car-dot')){\r
1166      box.innerHTML='';for(let i=0;i<pages;i++){const d=document.createElement('button');d.className='car-dot';d.dataset.page=i;box.appendChild(d);}\r
1167    }\r
1168    [...box.children].forEach((d,i)=>{d.setAttribute('aria-current',i===cur);d.setAttribute('aria-label',t('page',{n:i+1}));});\r
1169  }else box.innerHTML='<span class="car-count">'+(cur+1)+' / '+pages+'</span>';\r
1170  const [prev,next]=nav.querySelectorAll('.car-arrow'),L=document.getElementById('carL'),R=document.getElementById('carR');\r
1171  prev.disabled=L.disabled=cur<=0;next.disabled=R.disabled=cur>=pages-1;\r
1172  [prev,L].forEach(b=>b.setAttribute('aria-label',t('prev')));[next,R].forEach(b=>b.setAttribute('aria-label',t('next')));\r
1173  placeSides(wall);\r
1174}\r
1175function setCarousel(wall,on){\r
1176  let nav=document.getElementById('carNav');\r
1177  if(!nav){\r
1178    nav=document.createElement('div');nav.id='carNav';nav.className='car-nav';nav.hidden=true;\r
1179    nav.innerHTML='<button class="car-arrow" data-dir="-1">‹</button><div class="car-dots"></div><button class="car-arrow" data-dir="1">›</button>';\r
1180    wall.before(nav);\r
1181    /* 兩側箭頭 */\r
1182    document.body.insertAdjacentHTML('beforeend','<button id="carL" class="car-side" data-dir="-1" hidden>‹</button><button id="carR" class="car-side" data-dir="1" hidden>›</button>');\r
1183    ['carL','carR'].forEach(id=>document.getElementById(id).addEventListener('click',e=>carGo(wall,carCurrent(wall)+ +e.currentTarget.dataset.dir)));\r
1184    wall.addEventListener('transitionend',e=>{if(e.target===wall)placeSides(wall);});\r
1185    addEventListener('resize',()=>placeSides(wall));\r
1186    addEventListener('wall:offset',()=>placeSides(wall));\r
1187    nav.addEventListener('click',e=>{\r
1188      const a=e.target.closest('[data-dir]');if(a){carGo(wall,carCurrent(wall)+ +a.dataset.dir);return;}\r
1189      const d=e.target.closest('[data-page]');if(d)carGo(wall,+d.dataset.page);\r
1190    });\r
1191    wall.addEventListener('scroll',()=>{if(!carRaf)carRaf=requestAnimationFrame(()=>{carRaf=0;carSync(wall);});},{passive:true});\r
1192    document.addEventListener('keydown',e=>{\r
1193      if(!wall.classList.contains('carousel')||(e.key!=='ArrowLeft'&&e.key!=='ArrowRight'))return;\r
1194      if(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable],.menu'))return;\r
1195      const panel=document.getElementById('panel');if(panel&&!panel.classList.contains('hidden'))return;\r
1196      e.preventDefault();carGo(wall,carCurrent(wall)+(e.key==='ArrowRight'?1:-1));\r
1197    });\r
1198  }\r
1199  wall._carPage=0;wall.classList.toggle('carousel',on);nav.hidden=!on;\r
1200  if(!on)wall.querySelectorAll('.item').forEach(el=>{el._keep=false;});document.body.classList.toggle('car-on',on);\r
1201  wall._carFirst=-1;if(!on)wall.scrollLeft=0;\r
1202  const b=document.getElementById('carBtn');if(b)b.setAttribute('aria-pressed',on);\r
1203  dispatchEvent(new Event('wall:carousel'));placeSides(wall);\r
1204}\r
1205/* 牆面寬度改變(視窗縮放、捲軸出現)時回呼,只看寬度避免無限迴圈 */\r
1206function watchWidth(wall,cb){\r
1207  let last=wall.clientWidth,raf=0,pending=false;\r
1208  const run=()=>{raf=0;if(document.hidden){pending=true;return;}const W=wall.clientWidth;if(W!==last){last=W;cb();}};\r
1209  document.addEventListener('visibilitychange',()=>{if(!document.hidden&&pending){pending=false;last=-1;run();}});\r
1210  const kick=()=>{if(!raf)raf=requestAnimationFrame(run);};\r
1211  if('ResizeObserver' in window)new ResizeObserver(kick).observe(wall);else window.addEventListener('resize',kick);\r
1212}\r
1213/* Content 牆的欄數:0=隨機瀑布流,1~COLS_MAX=等寬欄。\r
1214   實際畫出幾欄還會被寬度限制(見 colSize),放不下就自動少排幾欄。 */\r
1215const COLS_MAX=5,COLS_QUICK=5;\r
1216const validCols=c=>Number.isInteger(c)&&c>=0&&c<=COLS_MAX;\r
1217\r
1218\r
1219/* ---------- 多語系(編輯器與獨立牆共用,預設英文) ---------- */\r
1220const I18N={"en": {"title": "Wall editor", "upload": "Upload", "download": "Download", "copyWall": "Copy standalone wall", "dlWall": "Download standalone wall", "clear": "Clear", "hint": "Enter adds a ━━━━ divider | a boundary labels the block above it: ### = InfoMercial, === = Topic; whatever is left is Content | Shift+Enter: line break only | Ctrl+Enter: push to wall", "placeholder": "Paste URLs, one per line", "cancel": "Cancel", "pu
1220sh": "✓ Push to wall", "count": "{n} items", "layout": "Layout", "random": "Random", "cols": "{n} columns", "col1": "1 column", "openEditor": "Open editor", "close": "Close", "edit": "Edit", "language": "Language", "noInput": "No URLs or embed code found", "skipped": "Skipped {n} unrecognized line(s)", "storageFull": "⚠️ Not saved: browser storage is full or disabled. Download a backup first.", "emptyWall": "The wall is empty. Add content first.", "copied": "✓ Standalone wall HTML copied ({n} items)", "clipFallback": "Clipboard unavailable. Downloaded .html instead.", "downloaded": "✓ Standalone wall downloaded ({n} items)", "fileEmpty": "No usable content in this file", "loaded": "✓ Loaded {n} items", "loadedSkip": ", {n} skipped", "confirmClear": "Clear this wall?", "wallEmpty": "This wall has no content yet", "del": "Delete", "original": "Original", "shuffle": "Shuffle", "tombNote": "This site doesn't allow embedding", "openTab": "Open in new tab", "markTomb": "Mark as non-embeddable", "tryEmbed": "Try embedding again", "carousel": "Carousel", "prev": "Previous", "next": "Next", "page": "Page {n}", "filter": "Filter", "searchPh": "Search titles, sites, #tags…", "fType": "Type", "fDate": "Date", "fSort": "Sort", "tAll": "All types", "tVideo": "Video", "tAudio": "Audio", "tPage": "Web pages", "tHtml": "HTML", "tBlocked": "Non-embeddable", "dAny": "Any date", "dToday": "Today", "d7": "Last 7 days", "d30": "Last 30 days", "sWall": "Sort: wall order", "sNew": "Newest first", "sOld": "Oldest first", "sLong": "Longest first", "sShort": "Shortest first", "sAz": "Title A–Z", "results": "{n} of {m}", "fClear": "Clear", "noMatch": "No cards match these filters", "fTitle": "Title", "fTags": "Tags", "fLength": "Length", "tagsPh": "comma, separated", "lenPh": "mm:ss", "fxToggle": "Effects", "resetPos": "Reset positions", "moveCard": "Move card", "fxFire": "Fireworks", "fxFly": "Flying bees", "fxSound": "Sound", "tabSheet": "EzSheet", "tabPics": "Images & 3D", "picDrop": "Drop images or 3D models here, or click to choose files", "picHint": "Images and 3D models (.glb .gltf .stl .obj) are inlined into the wall, so nothing is fetched from the network. Each one can become a card; images can also replace the flying sprites in Topic.", "asCard": "As card", "asSprite": "As flying sprite", "picAdd": "Add as cards", "picSprites": "Use as sprites", "spriteReset": "Default bees", "picZoneA": "Topic", "picZoneB": "Content", "picAdded": "{n} image card(s) added", "spriteOk": "{n} flying sprite(s) applied", "picNone": "No images yet", "zA": "Topic band", "zB": "Content wall", "zC": "InfoMercial band", "zorder": "Zone order", "zorderHint": "Drag to set the order of the two top bands", "picZoneC": "InfoMercial", "tModel": "3D models", "picTooBig": "{n} file(s) skipped: over 12 MB", "picBadType": "{n} file(s) skipped: not an image or 3D model", "insCard": "Insert a card before this one", "insTitle": "Insert a card", "insHintOwner": "Paste a URL, an embed code, or Markdown. It goes in right before this card.", "insHintGuest": "Paste a URL, an embed code, or Markdown. It goes in right before this card, and is kept only in this browser — other visitors will not see it.", "insPh": "https://…  ·  <iframe> embed code  ·  <md>…</md>  ·  https://…/model.glb", "insSave": "Save and insert", "insCancel": "Cancel", "insBad": "That is not a URL, an embed code, or a <md>…</md> block this wall can show.", "insDone": "✓ One card inserted", "insDel": "Remove the card you added", "revTitle": "Co-WiKi cards", "revDrop": "Remove this card", "revHint": "Visitor cards go live immediately as Co-WiKi. ✓ approves one and makes it permanent; ✕ removes it for everyone.", "revNone": "No visitor cards yet", "revDenied": "Wrong owner key.", "revFail": "Could not reach the server.", "revAsk": "Owner key", "syncOn": "Live — shared with every visitor", "syncOff": "Offline — new cards stay in this browser until the connection is back", "insHintLive": "Paste a URL, an embed code, or Markdown. It goes in right before this card as a Co-WiKi card, every visitor sees it straight away, and it becomes permanent once the owner approves it.", "insBusy": "The server would not take that card.", "insRate": "Too many cards from here for now. Try again later.", "insDown": "This wall is offline at the moment, so a new card cannot be shared yet. Wait for the dot on the bar to turn green, then try again.", "insBig": "This Markdown card is too long.", "insMd": "M↓ Markdown", "insKinds": "3D: paste a Sketchfab embed or a public https link to .glb / .stl / .obj", "insMdTpl": "# Title\\n\\nWrite **Markdown** here — lists, tables, links and https images all work.", "revOk": "Approve — make this card permanent", "revPend": "Pending", "revOkd": "Approved", "tMd": "Markdown", "sprTitle": "Flying sprites 🐝", "sprHint": "The two built-in bees are ready to swap: ⇄ replaces one, ✕ removes it, + adds one (up to 4), or drop an image on a slot. Remove them all and the 🐝 button is disabled for visitors.", "sprRep": "Replace image", "sprDel": "Remove", "sprAdd": "Add a flying sprite", "sprReset": "Back to the built-in bees", "sprDef": "built-in", "sprNone": "No flying sprites — the 🐝 button will be disabled.", "sprBig": "That image is over 2 MB.", "foldMore": "⌄ Show all", "foldLess": "⌃ Show less"}, "zh-TW": {"title": "牆面編輯", "upload": "上傳", "download": "下載", "copyWall": "複製獨立牆", "dlWall": "下載獨立牆", "clear": "清空", "hint": "Enter 自動加━━━━分隔|界線標記「線以上那一段」:### 以上是 InfoMercial,=== 以上是 Topic,其餘是 Content|Shift+Enter 純換行|Ctrl+Enter 推上牆", "placeholder": "貼網址,每行一個", "cancel": "取消", "push": "✓ 推上牆", "count": "{n} 組", "layout": "版面", "random": "自由隨機", "cols": "{n} 欄", "openEditor": "開啟編輯面板", "close": "關閉", "edit": "編輯", "language": "語言", "noInput": "沒抓到可用的網址æ
1220ˆ–嵌入碼", "skipped": "已略過 {n} 行無法辨識的內容", "storageFull": "⚠️ 沒存到:瀏覽器儲存空間已滿或被停用,請先下載備份", "emptyWall": "牆是空的,先推內容上牆", "copied": "✓ 已複製獨立牆 HTML({n} 組)", "clipFallback": "剪貼簿無法使用,已改為下載 .html", "downloaded": "✓ 已下載獨立牆({n} 組)", "fileEmpty": "檔案裡沒有可用的內容", "loaded": "✓ 已載入 {n} 組", "loadedSkip": ",略過 {n} 組", "confirmClear": "清空這面牆?", "wallEmpty": "這面牆目前沒有內容", "del": "刪除", "original": "原始版面", "shuffle": "洗牌", "tombNote": "此網站不允許嵌入", "openTab": "在新分頁開啟", "markTomb": "標示為無法嵌入", "tryEmbed": "重新嘗試嵌入", "carousel": "輪播", "prev": "上一頁", "next": "下一頁", "page": "第 {n} 頁", "filter": "篩選", "searchPh": "搜尋標題、網站、#標籤…", "fType": "類型", "fDate": "日期", "fSort": "排序", "tAll": "所有類型", "tVideo": "影片", "tAudio": "音訊", "tPage": "網頁", "tHtml": "HTML", "tBlocked": "無法嵌入", "dAny": "不限日期", "dToday": "今天", "d7": "最近 7 天", "d30": "最近 30 天", "sWall": "排序:牆面順序", "sNew": "最新優先", "sOld": "最舊優先", "sLong": "最長優先", "sShort": "最短優先", "sAz": "標題 A–Z", "results": "{n} / {m}", "fClear": "清除", "noMatch": "沒有符合篩選條件的卡片", "fTitle": "標題", "fTags": "標籤", "fLength": "長度", "tagsPh": "以逗號分隔", "lenPh": "分:秒", "fxToggle": "特效", "resetPos": "一鍵復位", "moveCard": "拖曳搬移", "fxFire": "煙火", "fxFly": "飛行物", "fxSound": "音效", "tabSheet": "EzSheet", "tabPics": "圖檔與 3D", "picDrop": "把圖檔或 3D 模型拖到這裡,或點一下選擇檔案", "picHint": "圖片與 3D 模型(.glb .gltf .stl .obj)會直接內嵌進牆面,不依賴外部網址。每個都可以變成一張卡片;圖片還可以取代 Topic 區的飛行圖示。", "asCard": "當卡片", "asSprite": "當飛行圖示", "picAdd": "加入為卡片", "picSprites": "套用為飛行圖示", "spriteReset": "回到預設蜜蜂", "picZoneA": "放 Topic", "picZoneB": "放 Content", "picAdded": "已加入 {n} 張圖卡", "spriteOk": "已套用 {n} 個飛行圖示", "picNone": "還沒有圖檔", "zA": "Topic(主題帶)", "zB": "Content(內容牆)", "zC": "InfoMercial(業配帶)", "zorder": "區塊順序", "zorderHint": "拖曳調整上方兩條帶(Topic/InfoMercial)的順序", "picZoneC": "放 InfoMercial", "tModel": "3D 模型", "picTooBig": "已略過 {n} 個檔案:超過 12 MB", "picBadType": "已略過 {n} 個檔案:不是圖檔或 3D 模型", "insCard": "在這張卡前面插入一張", "insTitle": "插入新卡", "insHintOwner": "貼上網址、嵌入碼或 Markdown,會插在這張卡的前面。", "insHintGuest": "貼上網址、嵌入碼或 Markdown,會插在這張卡的前面。只存在你這台瀏覽器裡,其他訪客看不到。", "insPh": "https://… · <iframe> 嵌入碼 · <md>…</md> · https://…/model.glb", "insSave": "儲存並插入", "insCancel": "取消", "insBad": "這段內容不是網址、嵌入碼,也不是這面牆能呈現的 <md>…</md> 區塊。", "insDone": "✓ 已插入一張卡", "insDel": "移除你加的這張卡", "revTitle": "Co-WiKi 來客卡", "revDrop": "移除這張卡", "revHint": "來客卡以 Co-WiKi 即時公開。按 ✓ 認可成為永久卡;按 ✕ 移除,所有人那邊會立刻消失。", "revNone": "目前沒有訪客卡片", "revDenied": "版主金鑰不對。", "revFail": "連不上伺服器。", "revAsk": "版主金鑰", "syncOn": "連線中——所有訪客同步看到", "syncOff": "離線——新卡先留在這台瀏覽器,連上後再送出", "insHintLive": "貼上網址、嵌入碼或 Markdown,會以 Co-WiKi 卡插在這張卡的前面,所有訪客立刻看得到;版主認可後成為永久卡。", "insBusy": "伺服器不接受這張卡。", "insRate": "這裡送出的卡太多了,請稍後再試。", "insDown": "這面牆目前連不上伺服器,新卡還送不出去。等上方那顆點變綠再試一次。", "insBig": "這張 Markdown 卡太長了。", "insMd": "M↓ Markdown", "insKinds": "3D:貼 Sketchfab 嵌入碼,或 .glb/.stl/.obj 的公開 https 網址", "insMdTpl": "# 標題\\n\\n在這裡寫 **Markdown**:清單、表格、連結、https 圖片都可以。", "revOk": "認可:升級為永久卡", "revPend": "待審", "revOkd": "已認可", "tMd": "Markdown", "sprTitle": "飛行圖示 🐝", "sprHint": "內建的兩隻蜜蜂可以直接替換:⇄ 換圖、✕ 移除、+ 新增(最多 4 張),也可以把圖檔拖到格子上。全部移除時,訪客的 🐝 鍵會停用。", "sprRep": "換圖", "sprDel": "移除", "sprAdd": "新增飛行圖示", "sprReset": "恢復內建蜜蜂", "sprDef": "內建", "sprNone": "沒有飛行圖示:🐝 鍵將停用。", "sprBig": "圖檔超過 2 MB。", "foldMore": "⌄ 展開全文", "foldLess": "⌃ 收合"}, "zh-CN": {"title": "墙面编辑", "upload": "上传", "download": "下载", "copyWall": "复制独立墙", "dlWall": "下载独立墙", "clear": "清空", "hint": "Enter 自动加━━━━分隔|界线标记“线以上那一段”:### 以上是 InfoMercial,=== 以上是 Topic,其余是 Content|Shift+Enter 纯换行|Ctrl+Enter 推上墙", "placeholder": "粘贴网址,每行一个", "cancel": "取消", "push": "✓ 推上墙", "count": "{n} 组", "layout": "版面", "random": "自由随机", "cols": "{n} 栏", "openEditor": "打开编辑面板", "close": "关闭", "edit": "编辑", "language": "语言", "noInput": "没抓到可用的网址或嵌入码", "skipped": "已跳过 {n} 行无法识别的内容", "storageFull": "⚠️ 没保存:浏览器存储空间已满或被禁用,请先下载备份", "emptyWall": "墙是空的,先推内容上墙", "copied": "✓ 已复制独立墙 HTML({n} 组)", "clipFallback": "剪贴板无法使用,已改为下载 .html", "downloaded": "✓ 已下载独立墙({n} 组)", "fileEmpty": "文件里没有可用的内容", "loaded": "✓ 已载å
1220…¥ {n} 组", "loadedSkip": ",跳过 {n} 组", "confirmClear": "清空这面墙?", "wallEmpty": "这面墙目前没有内容", "del": "删除", "original": "原始版面", "shuffle": "洗牌", "tombNote": "此网站不允许嵌入", "openTab": "在新标签页打开", "markTomb": "标记为无法嵌入", "tryEmbed": "重新尝试嵌入", "carousel": "轮播", "prev": "上一页", "next": "下一页", "page": "第 {n} 页", "filter": "筛选", "searchPh": "搜索标题、网站、#标签…", "fType": "类型", "fDate": "日期", "fSort": "排序", "tAll": "所有类型", "tVideo": "视频", "tAudio": "音频", "tPage": "网页", "tHtml": "HTML", "tBlocked": "无法嵌入", "dAny": "不限日期", "dToday": "今天", "d7": "最近 7 天", "d30": "最近 30 天", "sWall": "排序:墙面顺序", "sNew": "最新优先", "sOld": "最旧优先", "sLong": "最长优先", "sShort": "最短优先", "sAz": "标题 A–Z", "results": "{n} / {m}", "fClear": "清除", "noMatch": "没有符合筛选条件的卡片", "fTitle": "标题", "fTags": "标签", "fLength": "长度", "tagsPh": "用逗号分隔", "lenPh": "分:秒", "fxToggle": "特效", "resetPos": "一键复位", "moveCard": "拖曳搬移", "fxFire": "烟火", "fxFly": "飞行物", "fxSound": "音效", "tabSheet": "EzSheet", "tabPics": "图档与 3D", "picDrop": "把图档或 3D 模型拖到这里,或点一下选择文件", "picHint": "图片与 3D 模型(.glb .gltf .stl .obj)会直接内嵌进墙面,不依赖外部网址。每个都可以变成一张卡片;图片还可以取代 Topic 区的飞行图示。", "asCard": "当卡片", "asSprite": "当飞行图示", "picAdd": "加入为卡片", "picSprites": "套用为飞行图示", "spriteReset": "回到默认蜜蜂", "picZoneA": "放 Topic", "picZoneB": "放 Content", "picAdded": "已加入 {n} 张图卡", "spriteOk": "已套用 {n} 个飞行图示", "picNone": "还没有图档", "zA": "Topic(主题带)", "zB": "Content(内容墙)", "zC": "InfoMercial(推广带)", "zorder": "区块顺序", "zorderHint": "拖拽调整上方两条带(Topic/InfoMercial)的顺序", "picZoneC": "放 InfoMercial", "tModel": "3D 模型", "picTooBig": "已跳过 {n} 个文件:超过 12 MB", "picBadType": "已跳过 {n} 个文件:不是图档或 3D 模型", "insCard": "在这张卡前面插入一张", "insTitle": "插入新卡", "insHintOwner": "粘贴网址、嵌入码或 Markdown,会插在这张卡的前面。", "insHintGuest": "粘贴网址、嵌入码或 Markdown,会插在这张卡的前面。只存在你这台浏览器里,其他访客看不到。", "insPh": "https://… · <iframe> 嵌入码 · <md>…</md> · https://…/model.glb", "insSave": "保存并插入", "insCancel": "取消", "insBad": "这段内容不是网址、嵌入码,也不是这面墙能呈现的 <md>…</md> 区块。", "insDone": "✓ 已插入一张卡", "insDel": "移除你加的这张卡", "revTitle": "Co-WiKi 来客卡", "revDrop": "移除这张卡", "revHint": "来客卡以 Co-WiKi 即时公开。按 ✓ 认可成为永久卡;按 ✕ 移除,所有人那边会立刻消失。", "revNone": "目前没有访客卡片", "revDenied": "版主密钥不对。", "revFail": "连不上服务器。", "revAsk": "版主密钥", "syncOn": "连线中——所有访客同步看到", "syncOff": "离线——新卡先留在这台浏览器,连上后再送出", "insHintLive": "粘贴网址、嵌入码或 Markdown,会以 Co-WiKi 卡插在这张卡的前面,所有访客立刻看得到;版主认可后成为永久卡。", "insBusy": "服务器不接受这张卡。", "insRate": "这里é€
1220å‡ºçš„卡太多了,请稍后再试。", "insDown": "这面墙目前连不上服务器,新卡还送不出去。等上方那颗点变绿再试一次。", "insBig": "这张 Markdown 卡太长了。", "insMd": "M↓ Markdown", "insKinds": "3D:粘贴 Sketchfab 嵌入码,或 .glb/.stl/.obj 的公开 https 网址", "insMdTpl": "# 标题\\n\\n在这里写 **Markdown**:列表、表格、链接、https 图片都可以。", "revOk": "认可:升级为永久卡", "revPend": "待审", "revOkd": "已认可", "tMd": "Markdown", "sprTitle": "飞行图示 🐝", "sprHint": "内置的两只蜜蜂可以直接替换:⇄ 换图、✕ 移除、+ 新增(最多 4 张),也可以把图片拖到格子上。全部移除时,访客的 🐝 键会停用。", "sprRep": "换图", "sprDel": "移除", "sprAdd": "新增飞行图示", "sprReset": "恢复内置蜜蜂", "sprDef": "内置", "sprNone": "没有飞行图示:🐝 键将停用。", "sprBig": "图片超过 2 MB。", "foldMore": "⌄ 展开全文", "foldLess": "⌃ 收起"}, "ja": {"title": "ウォール編集", "upload": "アップロード", "download": "ダウンロード", "copyWall": "単体ウォールをコピー", "dlWall": "単体ウォールを保存", "clear": "クリア", "hint": "Enterで━━━━区切り|区切り線はその上のブロックを指します:### は InfoMercial、=== は Topic、残りが Content|Shift+Enterは改行のみ|Ctrl+Enterで追加", "placeholder": "URLを1行に1つずつ貼り付け", "cancel": "キャンセル", "push": "✓ ウォールに追加", "count": "{n}ä»¶", "layout": "レイアウト", "random": "ランダム", "cols": "{n}列", "openEditor": "エディタを開く", "close": "閉じる", "edit": "編集", "language": "言語", "noInput": "URLや埋め込みコードが見つかりません", "skipped": "認識できない{n}行をスキップしました", "storageFull": "⚠️ 保存できません:ブラウザのストレージが満杯か無効です。先にバックアップをダウンロードしてください", "emptyWall": "ウォールが空です。先に内容を追加してください", "copied": "✓ 単体ウォールのHTMLをコピーしました({n}件)", "clipFallback": "クリップボードが使えないため .html をダウンロードしました", "downloaded": "✓ 単体ウォールを保存しました({n}件)", "fileEmpty": "このファイルに使える内容がありません", "loaded": "✓ {n}件を読み込みました", "loadedSkip": "({n}件スキップ)", "confirmClear": "このウォールをクリアしますか?", "wallEmpty": "このウォールにはまだ内容がありません", "del": "削除", "original": "オリジナル", "shuffle": "シャッフル", "tombNote": "このサイトは埋め込みを許可していません", "openTab": "新しいタブで開く", "markTomb": "埋め込み不可にする", "tryEmbed": "もう一度埋め込む", "carousel": "カルーセル", "prev": "前へ", "next": "次へ", "page": "{n}ページ目", "filter": "フィルター", "searchPh": "タイトル・サイト・#タグを検索…", "fType": "種類", "fDate": "日付", "fSort": "並べ替え", "tAll": "すべての種類", "tVideo": "動画", "tAudio": "音声", "tPage": "ウェブページ", "tHtml": "HTML", "tBlocked": "埋め込み不可", "dAny": "すべての日付", "dToday": "今日", "d7": "過去7日間", "d30": "過去30日間", "sWall": "並び:ウォール順", "sNew": "新しい順", "sOld": "古い順", "sLong": "長い順", "sShort": "短い順", "sAz": "タイトル順", "results": "{n} / {m}ä»¶", "fClear": "クリア", "noMatch": "条件に合うカードがありません", "fTitle": "タイトル", "fTags": "タグ", "fLength": "長さ", "tagsPh": "カンマ区切り", "lenPh": "分:秒", "fxToggle": "エフェクト", "resetPos": "位置をリセット", "moveCard": "カードを移動", "fxFire": "花火", "fxFly": "飛行体", "fxSound": "サウンド", "tabSheet": "EzSheet", "tabPics": "画像と3D", "picDrop": "画像や3Dモデルをここにドロップ、またはクリックして選択", "picHint": "画像と3Dモデル(.glb .gltf .stl .obj)はウォールに直接埋め込まれ、外部からの読み込みはありません。どれもカードにでき、画像は Topic の飛行画像にもできます。", "asCard": "カードにする", "asSprite": "飛ぶ画像にする", "picAdd": "カードとして追加", "picSprites": "飛行画像に使う", "spriteReset": "既定のミツバチ", "picZ
1220oneA": "Topic へ", "picZoneB": "Content へ", "picAdded": "{n}枚の画像カードを追加しました", "spriteOk": "飛行画像 {n}件を適用しました", "picNone": "画像がありません", "zA": "Topic(トピック帯)", "zB": "Content(コンテンツ)", "zC": "InfoMercial(PR 帯)", "zorder": "区の並び", "zorderHint": "上の2帯(Topic/InfoMercial)の順番をドラッグで入れ替え", "picZoneC": "InfoMercial へ", "tModel": "3Dモデル", "picTooBig": "{n}件をスキップ:12 MB を超えています", "picBadType": "{n}件をスキップ:画像でも3Dモデルでもありません", "insCard": "このカードの前に1枚挿入", "insTitle": "カードを挿入", "insHintOwner": "URL・埋め込みコード・Markdown を貼り付けてください。このカードの前に入ります。", "insHintGuest": "URL・埋め込みコード・Markdown を貼り付けてください。このカードの前に入ります。このブラウザにだけ保存され、他の訪問者には見えません。", "insPh": "https://… · <iframe> 埋め込みコード · <md>…</md> · https://…/model.glb", "insSave": "保存して挿入", "insCancel": "キャンセル", "insBad": "URL でも、埋め込みコードでも、表示できる <md>…</md> ブロックでもありません。", "insDone": "✓ カードを1枚挿入しました", "insDel": "自分が追加したカードを削除", "revTitle": "Co-WiKi カード", "revDrop": "このカードを削除", "revHint": "訪問者のカードは Co-WiKi としてすぐ公開されます。✓ で承認して常設に、✕ で全員の画面から削除します。", "revNone": "訪問者のカードはまだありません", "revDenied": "オーナーキーが違います。", "revFail": "サーバーに接続できません。", "revAsk": "オーナーキー", "syncOn": "接続中 — すべての訪問者と共有", "syncOff": "オフライン — 新しいカードは接続が戻るまでこのブラウザに残ります", "insHintLive": "URL・埋め込みコード・Markdown を貼り付けてください。このカードの前に Co-WiKi カードとして入り、すぐに全員に表示されます。オーナーが承認すると常設カードになります。", "insBusy": "サーバーがこのカードを受け付けませんでした。", "insRate": "ここからの投稿が多すぎます。しばらくしてからお試しください。", "insDown": "このウォールは現在オフラインのため、新しいカードをまだ共有できません。上のドットが緑になってからもう一度お試しください。", "insBig": "この Markdown カードは長すぎます。", "insMd": "M↓ Markdown", "insKinds": "3D:Sketchfab の埋め込み、または .glb/.stl/.obj の公開 https リンク", "insMdTpl": "# タイトル\\n\\nここに **Markdown** を書きます。リスト・表・リンク・https 画像が使えます。", "revOk": "承認して常設カードにする", "revPend": "承認待ち", "revOkd": "承認済み", "tMd": "Markdown", "sprTitle": "飛ぶ画像 🐝", "sprHint": "内蔵の 2 匹のハチはそのまま差し替えできます:⇄ で交換、✕ で削除、+ で追加(最大 4 枚)。画像を枠にドロップしても交換できます。すべて削除すると訪問者の 🐝 ボタンは無効になります。", "sprRep": "画像を交換", "sprDel": "削除", "sprAdd": "飛ぶ画像を追加", "sprReset": "内蔵のハチに戻す", "sprDef": "内蔵", "sprNone": "飛ぶ画像がありません:🐝 ボタンは無効になります。", "sprBig": "画像が 2 MB を超えています。", "foldMore": "⌄ 全文を表示", "foldLess": "⌃ 折りたたむ"}, "ko": {"title": "월 편집", "upload": "업로드", "download": "다운로드", "copyWall": "독립 월 복사", "dlWall": "독립 월 저장", "clear": "비우기", "hint": "Enter로 ━━━━ 구분선|경계선은 ê·¸ 위 블록을 가리킵니다: ### 는 InfoMercial, === 는 Topic, 나머지는 Content|Shift+Enter는 줄바꿈만|Ctrl+Enter로 올리기", "placeholder": "URL을 한 ì
1220¤„에 하나씩 붙여넣기", "cancel": "취소", "push": "✓ 월에 올리기", "count": "{n}개", "layout": "레이아웃", "random": "랜덤", "cols": "{n}열", "openEditor": "편집기 열기", "close": "닫기", "edit": "편집", "language": "언어", "noInput": "URL이나 임베드 코드를 찾지 못했습니다", "skipped": "인식할 수 없는 {n}줄을 건너뛰었습니다", "storageFull": "⚠️ 저장 실패: 브라우저 저장 공간이 가득 찼거나 꺼져 있습니다. 먼저 백업을 다운로드하세요", "emptyWall": "월이 비어 있습니다. 먼저 콘텐츠를 올리세요", "copied": "✓ 독립 월 HTML을 복사했습니다({n}개)", "clipFallback": "클립보드를 쓸 수 없어 .html로 다운로드했습니다", "downloaded": "✓ 독립 월을 저장했습니다({n}개)", "fileEmpty": "이 파일에 사용할 수 있는 내용이 없습니다", "loaded": "✓ {n}개를 불러왔습니다", "loadedSkip": ", {n}개 건너뜀", "confirmClear": "이 월을 비울까요?", "wallEmpty": "이 월에는 아직 콘텐츠가 없습니다", "del": "삭제", "original": "원본", "shuffle": "셔플", "tombNote": "이 사이트는 임베드를 허용하지 않습니다", "openTab": "새 탭에서 열기", "markTomb": "임베드 불가로 표시", "tryEmbed": "다시 임베드 시도", "carousel": "캐러셀", "prev": "이전", "next": "다음", "page": "{n}페이지", "filter": "필터", "searchPh": "제목, 사이트, #태그 검색…", "fType": "유형", "fDate": "날짜", "fSort": "정렬", "tAll": "모든 유형", "tVideo": "동영상", "tAudio": "오디오", "tPage": "웹페이지", "tHtml": "HTML", "tBlocked": "임베드 불가", "dAny": "모든 날짜", "dToday": "오늘", "d7": "최근 7일", "d30": "최근 30일", "sWall": "정렬: 월 순서", "sNew": "최신순", "sOld": "오래된순", "sLong": "긴 순", "sShort": "짧은 순", "sAz": "제목순", "results": "{n} / {m}", "fClear": "지우기", "noMatch": "조건에 맞는 카드가 없습니다", "fTitle": "제목", "fTags": "태그", "fLength": "길이", "tagsPh": "쉼표로 구분", "lenPh": "분:초", "fxToggle": "이펙트", "resetPos": "위치 초기화", "moveCard": "카드 이동", "fxFire": "불꽃", "fxFly": "비행체", "fxSound": "사운드", "tabSheet": "EzSheet", "tabPics": "이미지 · 3D", "picDrop": "이미지나 3D 모델을 끌어다 놓거나 클릭해서 선택", "picHint": "이미지와 3D 모델(.glb .gltf .stl .obj)은 월에 직접 포함되어 외부 요청이 없습니다. 각각 카드로 쓸 수 있고, 이미지는 Topic 영역의 나는 이미지로도 쓸 수 있습니다.", "asCard": "카드로", "asSprite": "나는 이미지로", "picAdd": "카드로 추가", "picSprites": "나는 이미지로 적용", "spriteReset": "기본 벌로", "picZoneA": "Topic", "picZoneB": "Content", "picAdded": "이미지 카드 {n}개를 추가했습니다", "spriteOk": "나는 이미지 {n}개를 적용했습니다", "picNone": "이미지가 없습니다", "zA": "Topic(주제 밴드)", "zB": "Content(콘텐츠 월)", "zC": "InfoMercial(광고 밴드)", "zorder": "영역 순서", "zorderHint": "위 두 밴드(Topic/InfoMercial) 순서를 끌어서 변경", "picZoneC": "InfoMercial", "tModel": "3D 모델", "picTooBig": "{n}개 건너뜀: 12 MB 초과", "picBadType": "{n}개 건너뜀: 이미지나 3D 모델이 아닙니다", "insCard": "이 카드 앞에 한 장 삽입", "insTitle": "카드 삽입", "insHintOwner": "URL, 임베드 코드 또는 Markdown을 붙여 넣으세요. 이 카드 앞에 들어갑니다.", "insHintGuest": "URL, 임베드 코드 또는 Markdown을 붙여 넣으세요. 이 카드 앞에 들어갑니다. 이 브라우저에만 저장되어 다른 방문자에게는 보이지 않습니다.", "insPh": "https://…  ·  <iframe> 임베드 코드  ·  <md>…</md>  ·  https://…/model.glb", "insSave": "저장하고 삽입", "insCancel": "취소", "insBad": "URL, 임베드 코드, 또는 표시할 수 있는 <md>…</md> 블록이 아닙니다.", "insDone": "✓ 카드 한 장을 삽입했습니다", "insDel": "내가 추가한 카드 삭제", "revTitle": "Co-WiKi 카드", "revDrop": "이 카드 삭제", "revHint": "방문자 카드는 C
1220o-WiKi로 바로 공개됩니다. ✓ 로 승인하면 영구 카드가 되고, ✕ 로 모두의 화면에서 삭제합니다.", "revNone": "아직 방문자 카드가 없습니다", "revDenied": "소유자 키가 올바르지 않습니다.", "revFail": "서버에 연결할 수 없습니다.", "revAsk": "소유자 키", "syncOn": "연결됨 — 모든 방문자와 공유", "syncOff": "오프라인 — 새 카드는 연결될 때까지 이 브라우저에 남습니다", "insHintLive": "URL, 임베드 코드 또는 Markdown을 붙여 넣으세요. 이 카드 앞에 Co-WiKi 카드로 들어가 모든 방문자에게 바로 보이며, 운영자가 승인하면 영구 카드가 됩니다.", "insBusy": "서버가 이 카드를 받지 않았습니다.", "insRate": "이곳에서 보낸 카드가 너무 많습니다. 잠시 후 다시 시도하세요.", "insDown": "이 월은 지금 오프라인이라 새 카드를 아직 공유할 수 없습니다. 위쪽 점이 초록색이 되면 다시 시도하세요.", "insBig": "이 Markdown 카드는 너무 깁니다.", "insMd": "M↓ Markdown", "insKinds": "3D: Sketchfab 임베드 또는 .glb / .stl / .obj 공개 https 링크", "insMdTpl": "# 제목\\n\\n여기에 **Markdown**을 쓰세요. 목록, 표, 링크, https 이미지를 쓸 수 있습니다.", "revOk": "승인하여 영구 카드로", "revPend": "승인 대기", "revOkd": "승인됨", "tMd": "Markdown", "sprTitle": "나는 이미지 🐝", "sprHint": "기본 벌 두 마리를 바로 바꿀 수 있습니다: ⇄ 교체, ✕ 삭제, + 추가(최대 4장). 이미지를 칸에 끌어다 놓아도 됩니다. 모두 삭제하면 방문자의 🐝 버튼이 비활성화됩니다.", "sprRep": "이미지 교체", "sprDel": "삭제", "sprAdd": "나는 이미지 추가", "sprReset": "기본 벌로 되돌리기", "sprDef": "기본", "sprNone": "나는 이미지가 없습니다: 🐝 버튼이 비활성화됩니다.", "sprBig": "이미지가 2 MB를 넘습니다.", "foldMore": "⌄ 전체 보기", "foldLess": "⌃ 접기"}, "th": {"title": "แก้ไขวอลล์", "upload": "อัปโหลด", "download": "ดาวน์โหลด", "copyWall": "คัดลอกวอลล์แบบแยก", "dlWall": "ดาวน์โหลดวอลล์แบบแยก", "clear": "ล้าง", "hint": "Enter เพิ่มเส้นคั่น ━━━━ | เส้นแบ่งกำกับบล็อกเหนือมัน: ### คือ InfoMercial, === คือ Topic, ที่เหลือคือ Content | Shift+Enter ขึ้นบรรทัด | Ctrl+Enter ส่งขึ้นวอลล์", "placeholder": "วาง URL บรรทัดละหนึ่งรายการ", "cancel": "ยกเลิก", "push": "✓ ส่งขึ้นวอลล์", "count": "{n} รายการ", "layout": "เลย์เอาต์", "random": "สุ่ม", "cols": "{n} คอลัมน์", "openEditor": "เปิดตัวแก้ไข", "close": "ปิด", "edit": "แก้ไข", "language": "ภาษา", "noInput": "ไม่พบ URL หรือโค้ดฝัง", "skipped": "ข้ามบรรทัดที่อ่านไม่ออก {n} บรรทัด", "storageFull": "⚠️ บันทึกไม่ได้: พื้นที่เบราว์เซอร์เต็มหรือถูกปิดไว้ โปรดดาวน์โหลดสำรองก่อน", "emptyWall": "วอลล์ยังว่างอยู่ เพิ่มเนื้อหาก่อน", "copied": "✓ คัดลอก HTML วอลล์แบบแยกแล้ว ({n} รายการ)", "clipFallback": "ใช้คลิปบอร์ดไม่ได้ จึงดาวน์โหลดเป็น .html แทน", "downloaded": "✓ ดาวน์โหลดวอลล์แบบแยกแล้ว ({n} รายการ)", "fileEmpty": "ไม่มีเนื้อหาที่ใช้ได้ในไฟล์นี้", "loaded": "✓ โหลดแล้ว {n} รายการ", "loadedSkip": " ข้าม {n} รายการ", "confirmClear": "ล้างวอลล์นี้หรือไม่?", "wallEmpty": "วอลล์นี้ยังไม่มีเนื้อหา", "del": "ลบ", "original": "ต้นฉบับ", "shuffle": "สับไพ่", "tombNote": "เว็บไซต์นี้ไม่อนุญาตให้ฝัง", "openTab": "เปิดในแท็บใหม่", "markTomb": "ทำเครื่องหมายว่าฝังไม่ได้", "tryEmbed": "ลองฝังอีกครั้ง", "carousel": "ภาพหมุน", "prev": "ก่อนหน้า", "next": "ถัดไป", "page": "หน้า {n}", "filter": "ตัวกรอง", "searchPh": "ค้นหาชื่อ เว็บไซต์ #แท็ก…", "fType": "ประเภท", "fDate": "วันที่", "fSort": "เรียงลำดับ", "tAll": "ทุกประเภท", "tVideo": "วิดีโอ", "tAudio": "เสียง", "tPage": "หน้าเว็บ", "tHtml": "HTML", "tBlocked": "ฝังไม่ได้", "dAny": "ทุกวันที่", "dToday": "วันนี้", "d7": "7 วันล่าสุด", "d30": "30 วันล่าสุด", "sWall": "เรียง: ตามวอลล์", "sNew": "ใหม่สุดก่อน", "sOld": "เก่าสุดก่อน", "sLong": "ยาวสุดก่อน", "sShort": "สั้นสุดก่อน", "sAz": "เรียงตามชื่อ", "results": "{n} จาก {m}", "fClear": "ล้าง", "noMatch": "ไม่มีการ์ดที่ตรงกับตัวกรอง", "fTitle": "ชื่อ", "fTags": "แท็ก", "fLength": "ความยาว", "tagsPh": "คั่นด้วยจุลภาค", "lenPh": "นาที:วินาที", "fxToggle": "เอฟเฟกต์", "resetPos": "รีเซ็ตตำแหน่ง", "moveCard": "ย้ายการ์ด", "fxFire": "พลุ", "fxFly": "ตัวบิน", "fxSound": "เสียง", "tabSheet": "EzSheet", "tabPics": "รูปและ 3D", "picDrop": "วางรูปหรือโมเดล 3D ที่นี่ หรือคลิกเพื่อเลือกไฟล์", "picHint": "รูปและโมเดล 3D (.glb .gltf .stl .obj) จะฝังลงในวอลล์โดยตรง ไม่ดึงจากเครือข่าย แต่ละไฟล์ทำเป็นการ์ดได้ และรูปยังใช้แทนตัวบินในโซน Topic ได้", "asCard": "เป็นการ์ด", "asSprite": "เป็นตัวบิน", "picAdd": "เพิ่มเป็นการ์ด", "picSprites": "ใช้เป็นตัวบิน", "spriteReset": "กลับเป็นผึ้ง", "picZ
1220oneA": "Topic", "picZoneB": "Content", "picAdded": "เพิ่มการ์ดรูป {n} ใบแล้ว", "spriteOk": "ใช้ตัวบิน {n} รูปแล้ว", "picNone": "ยังไม่มีรูป", "zA": "Topic (แถบหัวข้อ)", "zB": "Content (ผนังเนื้อหา)", "zC": "InfoMercial (แถบโฆษณา)", "zorder": "ลำดับโซน", "zorderHint": "ลากเพื่อจัดลำดับสองแถบบน (Topic/InfoMercial)", "picZoneC": "InfoMercial", "tModel": "โมเดล 3D", "picTooBig": "ข้าม {n} ไฟล์: เกิน 12 MB", "picBadType": "ข้าม {n} ไฟล์: ไม่ใช่รูปหรือโมเดล 3D", "insCard": "แทรกการ์ดก่อนใบนี้", "insTitle": "แทรกการ์ด", "insHintOwner": "วาง URL โค้ดฝัง หรือ Markdown การ์ดจะแทรกก่อนการ์ดนี้", "insHintGuest": "วาง URL โค้ดฝัง หรือ Markdown การ์ดจะแทรกก่อนการ์ดนี้ และเก็บไว้ในเบราว์เซอร์นี้เท่านั้น ผู้เยี่ยมชมคนอื่นจะไม่เห็น", "insPh": "https://…  ·  โค้ดฝัง <iframe>  ·  <md>…</md>  ·  https://…/model.glb", "insSave": "บันทึกและแทรก", "insCancel": "ยกเลิก", "insBad": "นี่ไม่ใช่ URL โค้ดฝัง หรือบล็อก <md>…</md> ที่ผนังนี้แสดงได้", "insDone": "✓ แทรกการ์ดแล้ว 1 ใบ", "insDel": "ลบการ์ดที่คุณเพิ่ม", "revTitle": "การ์ด Co-WiKi", "revDrop": "ลบการ์ดนี้", "revHint": "การ์ดของผู้เยี่ยมชมเผยแพร่ทันทีในชื่อ Co-WiKi กด ✓ เพื่ออนุมัติเป็นการ์ดถาวร กด ✕ เพื่อลบออกจากทุกคน", "revNone": "ยังไม่มีการ์ดจากผู้เข้าชม", "revDenied": "คีย์เจ้าของไม่ถูกต้อง", "revFail": "เชื่อมต่อเซิร์ฟเวอร์ไม่ได้", "revAsk": "คีย์เจ้าของ", "syncOn": "เชื่อมต่ออยู่ — ผู้เข้าชมทุกคนเห็นตรงกัน", "syncOff": "ออฟไลน์ — การ์ดใหม่จะอยู่ในเบราว์เซอร์นี้จนกว่าจะเชื่อมต่อได้", "insHintLive": "วาง URL โค้ดฝัง หรือ Markdown การ์ดจะแทรกก่อนการ์ดนี้เป็นการ์ด Co-WiKi ทุกคนเห็นทันที และจะกลายเป็นการ์ดถาวรเมื่อเจ้าของอนุมัติ", "insBusy": "เซิร์ฟเวอร์ไม่รับการ์ดนี้", "insRate": "ส่งการ์ดจากที่นี่มากเกินไป กรุณาลองใหม่ภายหลัง", "insDown": "ขณะนี้วอลล์นี้ออฟไลน์ จึงยังแชร์การ์ดใหม่ไม่ได้ รอให้จุดด้านบนเป็นสีเขียวแล้วลองอีกครั้ง", "insBig": "การ์ด Markdown นี้ยาวเกินไป", "insMd": "M↓ Markdown", "insKinds": "3D: วางโค้ดฝัง Sketchfab หรือลิงก์ https สาธารณะของ .glb / .stl / .obj", "insMdTpl": "# หัวเรื่อง\\n\\nเขียน **Markdown** ที่นี่ ใช้รายการ ตาราง ลิงก์ และรูป https ได้", "revOk": "อนุมัติเป็นการ์ดถาวร", "revPend": "รออนุมัติ", "revOkd": "อนุมัติแล้ว", "tMd": "Markdown", "sprTitle": "ภาพที่บินได้ 🐝", "sprHint": "ผึ้งในตัวสองตัวเปลี่ยนได้ทันที: ⇄ เปลี่ยนภาพ ✕ ลบ + เพิ่ม (สูงสุด 4 ภาพ) หรือลากภาพมาวางบนช่อง ถ้าลบหมด ปุ่ม 🐝 ของผู้เยี่ยมชมจะใช้ไม่ได้", "sprRep": "เปลี่ยนภาพ", "sprDel": "ลบ", "sprAdd": "เพิ่มภาพที่บินได้", "sprReset": "กลับเป็นผึ้งในตัว", "sprDef": "ในตัว", "sprNone": "ไม่มีภาพที่บินได้ ปุ่ม 🐝 จะใช้ไม่ได้", "sprBig": "ภาพใหญ่เกิน 2 MB", "foldMore": "⌄ ดูทั้งหมด", "foldLess": "⌃ ย่อ"}};\r
1221let LANG='en';\r
1222function setLangCode(l){LANG=I18N[l]?l:'en';return LANG;}\r
1223function getLang(){return LANG;}\r
1224function t(k,v){let s=(I18N[LANG]||{})[k];if(s==null)s=I18N.en[k];if(s==null)s=k;return v?s.replace(/\\{(\\w+)\\}/g,(_,x)=>v[x]!=null?v[x]:''):s;}\r
1225function colsText(n){return t(n===1&&I18N[LANG].col1?'col1':'cols',{n});}\r
1226function applyI18n(){\r
1227  document.documentElement.lang=LANG;\r
1228  document.querySelectorAll('[data-i18n]').forEach(el=>{el.textContent=t(el.dataset.i18n);});\r
1229  document.querySelectorAll('[data-i18n-aria]').forEach(el=>
1229{el.setAttribute('aria-label',t(el.dataset.i18nAria));el.title=t(el.dataset.i18nAria);});\r
1230  document.querySelectorAll('[data-i18n-ph]').forEach(el=>{el.placeholder=t(el.dataset.i18nPh);});\r
1231  document.querySelectorAll('[data-i18n-cols]').forEach(el=>{el.textContent=colsText(+el.dataset.i18nCols);});\r
1232  document.querySelectorAll('.item .del').forEach(b=>b.setAttribute('aria-label',t('del')));\r
1233  document.querySelectorAll('.item .edit').forEach(b=>b.setAttribute('aria-label',t('edit')));\r
1234}\r
1235const LANGS=[['en','EN'],['zh-TW','繁中'],['zh-CN','简中'],['ja','日本語'],['ko','한국어'],['th','ไทย']];\r
1236function langSelectHTML(){return '<select id="lang" class="lang-select" data-i18n-aria="language">'+LANGS.map(([v,n])=>'<option value="'+v+'">'+n+'</option>').join('')+'</select>';}\r
1237\r
1238/* ---------- 版面下拉:-1=原始(獨立牆專用)、0=隨機、1~4=欄 ---------- */\r
1239const bars=n=>'<span class="ci">'+'<i></i>'.repeat(n)+'</span>';\r
1240function menuHTML(withOriginal){\r
1241  let items=withOriginal?'<button role="menuitemradio" data-cols="-1"><span class="mi">📌</span><span data-i18n="original"></span></button>':'';\r
1242  items+='<button data-reset="1"><span class="mi">↺</span><span data-i18n="resetPos"></span></button><hr>';\r
1243  items+='<button role="menuitemradio" data-cols="0"><span class="mi">🎲</span><span data-i18n="random"></span></button><hr>';\r
1244  for(let n=1;n<=COLS_QUICK;n++)items+='<button role="menuitemradio" data-cols="'+n+'"><span class="mi">'+bars(Math.min(n,4))+(n>4?'<b class="cn">'+n+'</b>':'')+'</span><span data-i18n-cols="'+n+'"></span></button>';\r
1245  return '<div class="menu-wrap" id="menuWrap"><button id="layoutBtn" class="pill" aria-haspopup="menu" aria-expanded="false" aria-controls="layoutMenu"><span class="mi" id="layoutIcon"></span><span class="lbl" id="layoutText"></span><span class="caret">▼</span></button><div id="layoutMenu" class="menu" role="menu" hidden>'+items+'</div></div>';\r
1246}\r
1247function updateLayoutUI(mode){\r
1248  document.querySelectorAll('#layoutMenu [data-cols]').forEach(b=>{const on=+b.dataset.cols===mode;b.classList.toggle('on',on);b.setAttribute('aria-checked',on);});\r
1249  const txt=mode>0?colsText(mode):mode===0?t('random'):t('original');\r
1250  const icon=document.getElementById('layoutIcon');if(!icon)return;\r
1251  icon.innerHTML=mode>0?bars(Math.min(mode,4))+(mode>4?'<b class="cn">'+mode+'</b>':''):mode===0?'🎲':'📌';\r
1252  document.getElementById('layoutText').textContent=txt;\r
1253  const b=document.getElementById('layoutBtn');b.classList.toggle('random',mode===0);\r
1254  b.setAttribute('aria-label',t('layout')+': '+txt);b.title=t('layout')+': '+txt;\r
1255}\r
1256/* 點外面、Esc、選完都會關閉;方向鍵、Home、End 可移動 */\r
1257function bindMenu(onPick){\r
1258  const menu=document.getElementById('layoutMenu'),btn=document.getElementById('layoutBtn'),wrap=document.getElementById('menuWrap');\r
1259  const items=()=>[...menu.querySelectorAll('button')];\r
1260  const open=()=>{menu.hidden=false;btn.setAttribute('aria-expanded','true');(menu.querySelector('.on')||items()[0]).focus();};\r
1261  const close=f=>{if(menu.hidden)return;menu.hidden=true;btn.setAttribute('aria-expanded','false');if(f)btn.focus();};\r
1262  btn.addEventListener('click',()=>menu.hidden?open():close(false));\r
1263  btn.addEventListener('keydown',e=>{if(e.key==='ArrowDown'&&menu.hidden){e.preventDefault();open();}});\r
1264  menu.addEventListener('click',e=>{\r
1265    const r=e.target.closest('[data-reset]');if(r){close(true);onPick('reset');return;}\r
1266    const b=e.target.closest('[data-cols]');if(!b)return;close(true);onPick(+b.dataset.cols);\r
1267  });\r
1268\r
1269  menu.addEventListener('keydown',e=>{\r
1270    const it=items(),i=it.indexOf(document.activeElement);\r
1271    if(e.key==='ArrowDown'){e.preventDefault();it[(i+1)%it.length].focus();}\r
1272    else if(e.key==='ArrowUp'){e.preventDefault();it[(i-1+it.length)%it.length].focus();}\r
1273    else if(e.key==='Home'){e.preventDefault();it[0].focus();}\r
1274    else if(e.key==='End'){e.preventDefault();it[it.length-1].focus();}\r
1275    else if(e.key==='Escape'){e.preventDefault();e.stopPropagation();close(true);}\r
1276    else if(e.key==='Tab')close(false);\r
1277  });\r
1278  document.addEventListener('pointerdown',e=>{if(!menu.hidden&&!wrap.contains(e.target))close(false);});\r
1279}\r
1280\r
1281\r
1282/* ---------- 洗牌 ----------\r
1283   只改資料順序再重新排版,卡片節點不搬動,所以 iframe 不會重新載入。\r
1284   動畫三段:收成一疊 → 左右分兩半交錯洗兩次 → 依新順序一張張發回去 */\r
1285function shuffled(a){\r
1286  if(a.length<2)return a.slice();\r
1287  let b;do{b=a.slice();for(let i=b.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[b[i],b[j]]=[b[j],b[i]];}}\r
1288  while(b.every((o,i)=>o===a[i]));\r
1289  return b;\r
1290}\r
1291function shuffleBtnHTML(){return '<button id="shuffleBtn" class="pill shuffle" data-i18n-aria="shuffle"><span class="mi">🔀</span><span class="lbl" data-i18n="shuffle"></span></button>';}\r
1292let busy=false;\r
1293async function reorderAnimated(wall,next,commit){\r
1294  if(busy)return false;\r
1295  const els=new Map([...wall.querySelectorAll('.item')].map(el=>[el.dataset.id,el]));\r
1296  const apply=()=>
1296{if(commit)commit();};\r
1297  const reduce=window.matchMedia&&matchMedia('(prefers-reduced-motion: reduce)').matches;\r
1298  if(reduce||typeof Element.prototype.animate!=='function'||els.size<2||wall.classList.contains('carousel')){wall._carPage=0;wall._carFirst=-1;wall.scrollLeft=0;apply();return true;}\r
1299  busy=true;document.body.classList.add('shuffling');\r
1300  const btn=document.getElementById('shuffleBtn');if(btn)btn.setAttribute('aria-busy','true');\r
1301  const cards=[...els.values()].filter(el=>!el.classList.contains('f-out'));\r
1302  try{\r
1303    const cx=innerWidth/2,cy=innerHeight/2,CARD=150,n=cards.length;\r
1304    const info=new Map(cards.map(el=>{const r=el.getBoundingClientRect();return [el,{r,s:Math.min(1,CARD/Math.max(1,r.width)),rot:Math.random()*14-7}];}));\r
1305    /* 把卡片中心移到畫面中心,縮成撲克牌大小並微微歪斜;dx/rot 用來做洗牌時的左右分開 */\r
1306    const T=(el,dx=0,rot=0)=>{const f=info.get(el);return \`translate(\${cx-(f.r.left+f.r.width/2)+dx}px,\${cy-(f.r.top+f.r.height/2)}px) rotate(\${f.rot+rot}deg) scale(\${f.s})\`;};\r
1307    const setZ=list=>list.forEach((el,k)=>{el.style.zIndex=String(1+k);});\r
1308\r
1309    /* 1. 收牌 */\r
1310    setZ(cards);\r
1311    const g=Math.min(35,520/n);\r
1312    await Promise.all(cards.map((el,k)=>el.animate([{transform:'none'},{transform:T(el)}],\r
1313      {duration:480,delay:k*g,easing:'cubic-bezier(.55,0,.25,1)',fill:'forwards'}).finished));\r
1314\r
1315    /* 2. 洗兩次:分成左右兩半、交錯疊回。第二次疊回時,最上面就是新順序的第一張 */\r
1316    const dealOrder=next.map(o=>els.get(o._id)).filter(el=>el&&!el.classList.contains('f-out'));\r
1317    for(let pass=0;pass<2;pass++){\r
1318      const stackNow=[...cards].sort((a,b)=>(+a.style.zIndex)-(+b.style.zIndex));\r
1319      const half=Math.max(1,Math.ceil(n/2)),L=stackNow.slice(0,half),R=stackNow.slice(half);\r
1320      const woven=[];for(let i=0;i<half;i++){if(L[i])woven.push(L[i]);if(R[i])woven.push(R[i]);}\r
1321      const zAfter=pass===0?woven:[...dealOrder].reverse();\r
1322      const anims=stackNow.map((el,k)=>{const side=k<half?-1:1;\r
1323        return el.animate([{transform:T(el)},{transform:T(el,side*120,side*8),offset:.45},{transform:T(el)}],\r
1324          {duration:600,delay:(k%half)*8,easing:'ease-in-out',fill:'forwards'}).finished;});\r
1325      setTimeout(()=>setZ(zAfter),300);\r
1326      await Promise.all(anims);\r
1327    }\r
1328\r
1329    /* 3. 發牌:同一個步驟內取消動畫、換順序、量新位置,再從牌堆飛回,畫面不會閃 */\r
1330    cards.forEach(el=>el.getAnimations().forEach(a=>a.cancel()));\r
1331    apply();\r
1332    dealOrder.forEach((el,k)=>{info.get(el).r=el.getBoundingClientRect();el.style.zIndex=String(n+1-k);});\r
1333    const d=Math.min(80,1200/n);\r
1334    await Promise.all(dealOrder.map((el,k)=>el.animate([{transform:T(el)},{transform:'none'}],\r
1335      {duration:560,delay:k*d,easing:'cubic-bezier(.2,.8,.2,1)',fill:'backwards'}).finished));\r
1336  }catch(e){cards.forEach(el=>el.getAnimations().forEach(a=>a.cancel()));apply();}\r
1337  finally{\r
1338    cards.forEach(el=>{el.style.zIndex='';});\r
1339    document.body.classList.remove('shuffling');\r
1340    if(btn)btn.removeAttribute('aria-busy');\r
1341    busy=false;\r
1342    /* 洗牌途中所有卡都經過畫面中央;等可見範圍更新後,只載入真正落在畫面附近的 */\r
1343    requestAnimationFrame(()=>requestAnimationFrame(()=>{wall.querySelectorAll('.item').forEach(el=>{if(el._vis||el._keep)mountQ.add(el);});pump();}));\r
1344  }\r
1345  return true;\r
1346}\r
1347\r
1348/* ---------- 開場特效 ----------\r
1349   1) B 區滿版煙火 2 秒 2) 接著一艘飛船掠過 A 區。\r
1350   都畫在暫時的圖層上,播完立刻移除,不影響卡片與嵌入內容。 */\r
1351/* 想換成自己的飛碟圖片:填直接的圖片網址(.png/.webp,建議透明背景)或 data: URI。\r
1352   留空就用內建的向量飛碟。圖片載入失敗會自動退回向量版。 */\r
1353const BEE_DEFAULT=['data:image/webp;base64,UklGRkJCAABXRUJQVlA4WAoAAAAQAAAA0gAA5QAAQUxQSPATAAAB8EZb2zI52bZt+3Ec51ndUdw1AYK7xiBXuHC/JNeFu14uuOvlhru7XEEvg+HuwbmuK0ISHOLprjpk335UdXV39Vln/kbEBKAQjcGosz7iS7dds9/ygGCJMLcHLaay/s0jjJUlADH406LkE1OMiTwBVsqfwZH0kY19bd7ZUv4stl7gI3tO5EoiZc/hCkY2G+JtMCXPiJuu2pRy0Waw5c5i4wXszfyxyMpdjp/GyF7O26HsOYyZz+aV87dxrtwZVL6kNkX1p6CzuJzLKpXMFp0Mmp5Sc0k/n4CKFJRFQ8lNocHhFIbmmPj5BFSkiMRg3VX3PPkXew2HMYUmMuwVhiY0KT2/mAhjikeAs6Z+MIec89bPh8IWGQzGBUbVOiVJZeAntw+HKaBzEsmUyPi/SbBSYDD4znwyxRgT+f7xHzIykReKSLGIk5vIlJJqSpGfj0dWZDBY+4rZiaR+fuOKWP4pVqmBFzknhZLlJ6uyZ8+ZG8AUGQww8tdXXnHNeZsAObaYSU9VnisdUhwyyO45X2MTrPLOQSJFBuvQ2BpY7DCNNWrQ/dEpxSAuc8C5jNoMaxwHU2iAy+udAMgwejprjPHjnZAVgwWw16XvR23Ox+utFFzTkmPsTEZGfjYBTgaezbDt9y6eSyqbD7zOtBFIjh2mM7LGGRsZO+AMsPeshWQtspeek2DbCKQDP+hWZTePgBtYYgVbPNxFphi1d4fAtBWs03mWRgb9YBTMQBJgyKTp1BgCe+/1iPYCiOBc1hg5ZR2RgeMw+OdPUmP05KzfPRK1KQ1xbLuBWDxFzyovgxkwDh3Xk1Ej+db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N1/8ybyn5NgwUGKwU4npujMuO3QCnhnXMJKZn1mO6wD4zhcqH2CAqKe5a/7E8nu1nDozK+FQoXgjO21SvS3eMLrhnz/lE5lZdLtSvAEjUA6xnfBJpFYeeOrp8+9cdNiIMtb4AN9Tzbw3P4Kl7brfEokge3dblIRdh8SbK2Z/XLXkp79Htz4JJOY4RLLmIE4gG8SUvdqYgYkAQh1m+eQR+VWX4k19foZR0Ag4ZZH4DLKo3/jXf/xbAwrQdAwXH+DnlN9dXfCotGZ/tO5F7LGMSodqIWy5AnbkWEURYiGWhkawF45mVDHFrr9jwD1BZn1VUeicyn7s6w6ZYRqpeqZpcDNpoBfc8alIwXbAdLrZvAAA'];\r
1354/* Flying sprites can be replaced at runtime (window.WALL_SPRITES), so the editor and\r
1355   exported walls can carry their own artwork. */\r
1356/* 飛行圖示清單:'bee:0'/'bee:1' 代表內建的兩隻蜜蜂(不必重複內嵌),其餘是 data:image/…。\r
1357   編輯器與產生器把目前的清單寫進 window.WALL_SPRITES;空陣列=不放飛行物,🐝 鍵停用。\r
1358   舊版匯出沒有這個變數時,才退回內建蜜蜂。 */\r
1359const SPRITE_MAX=4,SPRITE_BYTES=2*1024*1024,SPRITE_DEF=['bee:0','bee:1'];\r
1360function spriteSrc(x){const m=/^bee:(\\d)$/.exec(String(x));return m?((typeof BEE_DEFAULT!=='undefined'&&BEE_DEFAULT[+m[1]])||'bee:3d'):(/^data:image\\/[\\w.+-]+[;,]/.test(String(x))?String(x):'');}\r
1361function validSprites(a){return Array.isArray(a)?a.filter(x=>typeof x==='string'&&(/^bee:\\d$/i.test(x)||spriteSrc(x))).slice(0,SPRITE_MAX):null;}\r
1362const beeImgs=()=>(validSprites(window.WALL_SPRITES)||SPRITE_DEF).map(spriteSrc);\r
1363/* 飛行圖示編輯列(編輯器、產生器共用):縮圖+⇄ 換圖+✕ 移除++ 新增+↺ 恢復內建。\r
1364   也可以直接把圖檔拖到某一格上替換。get() 取目前清單,set(新清單) 存回去。 */\r
1365function spriteStrip(box,get,set,tr){\r
1366  tr=tr||t;\r
1367  const inp=document.createElement('input');inp.type='file';inp.accept='image/*';inp.hidden=true;\r
1368  let slot=-1;\r
1369  const put=(file,i)=>{\r
1370    if(!file||!/^image\\//.test(file.type))return;\r
1371    if(file.size>SPRITE_BYTES){box.dataset.err=tr('sprBig');paint();return;}\r
1372    const r=new FileReader();\r
1373    r.onload=()=>{const a=get().slice(),v=String(r.result);if(!spriteSrc(v))return;\r
1374      if(i>=0&&i<a.length)a[i]=v;else if(a.length<SPRITE_MAX)a.push(v);else a[a.length-1]=v;\r
1375      delete box.dataset.err;set(a);paint();};\r
1376    r.readAsDataURL(file);\r
1377  };\r
1378  function paint(){\r
1379    const a=get();\r
1380    box.innerHTML='<div class="spr-row">'+a.map((x,i)=>'<div class="spr" data-i="'+i+'">'\r
1381        +'<img src="'+esc(spriteSrc(x))+'" alt="">'+(/^bee:/.test(x)?'<span class="spr-tag">'+esc(tr('sprDef'))+'</span>':'')\r
1382        +'<div class="spr-acts"><button type="button" data-rep="'+i+'" title="'+esc(tr('sprRep'))+'" aria-label="'+esc(tr('sprRep'))+'">⇄</button>'\r
1383        +'<button type="button" data-del="'+i+'" title="'+esc(tr('sprDel'))+'" aria-label="'+esc(tr('sprDel'))+'">✕</button></div></div>').join('')\r
1384      +(a.length<SPRITE_MAX?'<button type="button" class="spr-add" data-add title="'+esc(tr('sprAdd'))+'" aria-label="'+esc(tr('sprAdd'))+'">+</button>':'')\r
1385      +'<button type="button" class="spr-reset" data-reset title="'+esc(tr('sprReset'))+'" aria-label="'+esc(tr('sprReset'))+'">↺</button></div>'\r
1386      +(a.length?'':'<div class="spr-note">'+esc(tr('sprNone'))+'</div>')\r
1387      +(box.dataset.err?'<div class="spr-note bad">'+esc(box.dataset.err)+'</div>':'');\r
1388    box.appendChild(inp);\r
1389  }\r
1390  box.addEventListener('click',e=>{\r
1391    const b=e.target.closest('button');if(!b||!box.contains(b))return;\r
1392    if(b.dataset.rep!=null){slot=+b.dataset.rep;inp.click();}\r
1393    else if(b.dataset.add!=null){slot=-1;inp.click();}\r
1394    else if(b.dataset.del!=null){const a=get().slice();a.splice(+b.dataset.del,1);set(a);paint();}\r
1395    else if(b.dataset.reset!=null){delete box.dataset.err;set(SPRITE_DEF.slice());paint();}\r
1396  });\r
1397  inp.addEventListener('change',()=>{put(inp.files[0],slot);inp.value='';});\r
1398  box.addEventListener('dragover',e=>{if(e.target.closest('.spr,.spr-add')){e.preventDefault();e.stopPropagation();}});\r
1399  box.addEventListener('drop',e=>{\r
1400    const el=e.target.closest('.spr,.spr-add');if(!el)return;\r
1401    e.preventDefault();e.stopPropagation();\r
1402    put(e.dataTransfer.files[0],el.classList.contains('spr')?+el.dataset.i:-1);\r
1403  });\r
1404  paint();\r
1405  return {paint};\r
1406}\r
1407const FX_COLORS=['#FFE27A','#0E7C7B','#F7F5F1','#FF8A65','#81C784','#64B5F6'];\r
1408const fxReduce=()=>window.matchMedia&&matchMedia('(prefers-reduced-motion: reduce)').matches;\r
1409/* 煙火固定在可視範圍內:不論捲到哪裡都看得到,也不會多畫看不見的地方 */\r
1410function fireworks(target,ms,done){\r
1411  if(fxReduce()){if(done)done();return;}\r
1412  const W=Math.max(320,innerWidth),H=Math.max(240,innerHeight);\r
1413  const cv=document.createElement('canvas');\r
1414  cv.className='fx-layer';cv.width=W;cv.height=H;cv.style.width=W+'px';cv.style.height=H+'px';\r
1415  document.body.appendChild(cv);\r
1416  const g=cv.getContext('2d'),parts=[],rockets=[],t0=performance.now(),fade=900,CAP=2400;\r
1417  let next=0,lastFinale=-9000;\r
1418  const launch=()=>{\r
1419    const x=W*(0.12+Math.random()*0.76),y=H*(0.14+Math.random()*0.42);\r
1420    rockets.push({x,y:H+10,tx:x,ty:y,c:FX_COLORS[(Math.random()*FX_COLORS.length)|0]});\r
1421    sfxLaunch();\r
1422  };\r
1423  /* gen 0:主爆;gen 1:碎裂後的二次小爆,畫面更熱鬧 */\r
1424  const burst=(x,y,c,gen)=>{\r
1425    const big=!gen,ring=big&&Math.random()<0.3,willow=big&&!ring&&Math.random()<0.28;\r
1426    const n=big?(120+((Math.random()*70)|0)):(22+((Math.random()*14)|0)),sp=(big?5.2:2.4)+Math.random()*3.6;\r
1427    for(let i=0;i<n;i++){\r
1428      const a=(Math.PI*2*i)/n+Math.random()*(ring?.05:.2);\r
1429      const v=sp*(ring?(0.92+Math.random()*0.16):(0.45+Math.random()*1.05));\r
1430      parts.push({x,y,px:x,py:y,vx:Math.cos(a)*v,vy:Math.sin(a)*v,life:1,c,\r
1431        r:(big?5.6:3.2)+Math.random()*4.2,gen:gen||0,split:big&&Math.random()<0.26,\r
1432        drag:willow?0.995:0.988,fall:willow?0.022:0.045,slow:willow?0.0055:0});   /* 垂枝:慢慢往下淌 */\r
1433    }\r
1434    if(parts.length>CAP)parts.splice(0,parts.length-CAP);\r
1435  };\r
1436  const tick=now=>{\r
1437    const el=now-t0;\r
1438    /* 每約 14 秒來一次大齊放 */\r
1439    if(el-lastFinale>14000&&el<ms){lastFinale=el;for(let f=0;f<6;f++)setTimeout(launch,f*90);}\r
1440    if(el>=next&&el<ms){\r
1441      launch();
1441if(Math.random()<.6)launch();\r
1442      if(Math.random()<.16){launch();launch();}        /* 偶爾來個齊放 */\r
1443      next=el+(ms>10000?380+Math.random()*220:Math.max(140,ms/16));\r
1444    }\r
1445    /* 背景短暫壓暗,煙火才亮得起來 */\r
1446    /* 開場壓暗讓煙火跳出來,接著慢慢還原亮度,長時間播放也不會遮住內容 */\r
1447    const hold=Math.min(ms,9000),ease=Math.min(1,Math.max(0,(el-hold)/6000));\r
1448    const base=0.46-(0.46-0.14)*ease;\r
1449    const veil=base*Math.min(1,el/240)*(ms===Infinity?1:Math.min(1,Math.max(0,(ms+fade-el)/fade)));\r
1450    g.globalCompositeOperation='source-over';g.clearRect(0,0,W,H);\r
1451    g.fillStyle='rgba(12,12,14,'+veil.toFixed(3)+')';g.fillRect(0,0,W,H);\r
1452    g.globalCompositeOperation='lighter';\r
1453    for(let i=rockets.length-1;i>=0;i--){\r
1454      const k=rockets[i];k.y-=10+Math.random()*3;\r
1455      g.strokeStyle=k.c;g.lineWidth=3.4;g.globalAlpha=.95;\r
1456      g.beginPath();g.moveTo(k.x,k.y);g.lineTo(k.x,k.y+20);g.stroke();\r
1457      if(k.y<=k.ty){burst(k.x,k.ty,k.c,0);sfxBoom(k.x/W);rockets.splice(i,1);}\r
1458    }\r
1459    for(let i=parts.length-1;i>=0;i--){\r
1460      const p=parts[i];\r
1461      p.px=p.x;p.py=p.y;p.x+=p.vx;p.y+=p.vy;p.vy+=(p.fall||0.045);\r
1462      const dr=p.drag||0.988;p.vx*=dr;p.vy*=dr;\r
1463      p.life-=p.gen?0.016:(p.slow?p.slow:0.009);\r
1464      if(p.life<=0){parts.splice(i,1);continue;}\r
1465      if(p.split&&p.life<0.55){p.split=false;burst(p.x,p.y,FX_COLORS[(Math.random()*FX_COLORS.length)|0],1);}\r
1466      const tw=p.life>0.6?1:0.55+0.45*Math.sin(el/28+p.x);       /* 尾段閃爍 */\r
1467      g.globalAlpha=Math.max(0,p.life*tw);g.lineCap='round';\r
1468      g.strokeStyle=p.c;g.lineWidth=p.r;\r
1469      g.beginPath();g.moveTo(p.px,p.py);g.lineTo(p.x,p.y);g.stroke();\r
1470      if(p.life>0.45){                                            /* 中心白熱核心,更亮 */\r
1471        g.globalAlpha=Math.max(0,(p.life-0.45)*1.6*tw);g.strokeStyle='#fff';g.lineWidth=Math.max(1,p.r*0.42);\r
1472        g.beginPath();g.moveTo(p.px,p.py);g.lineTo(p.x,p.y);g.stroke();\r
1473      }\r
1474    }\r
1475    g.globalAlpha=1;g.globalCompositeOperation='source-over';\r
1476    if(cv._stop){cv.remove();return;}\r
1477    if(ms===Infinity||el<ms+fade+400)requestAnimationFrame(tick);\r
1478    else{cv.remove();if(done)done();}\r
1479  };\r
1480  requestAnimationFrame(tick);\r
1481}\r
1482/* 兩隻蜜蜂在 A 區帶狀範圍內各自亂飛,路徑隨機所以會交錯而過。\r
1483   位置固定在視界內,捲動時不會飛走;每飛完一段就重新抽一條新路徑。 */\r
1484function beeBand(){\r
1485  const za=document.getElementById('zoneA');\r
1486  if(za&&!za.hidden){\r
1487    const r=za.getBoundingClientRect();\r
1488    if(r.bottom>0&&r.top<innerHeight)return {top:Math.max(4,r.top),h:Math.max(120,r.height)};\r
1489  }\r
1490  return {top:Math.round(innerHeight*0.08),h:Math.round(innerHeight*0.3)};\r
1491}\r
1492/* 3D 飛行:除了左右上下,還有遠近(Z 軸)。\r
1493   近的放大、亮一點、蓋住另一隻;遠的縮小、淡一點、稍微模糊,兩隻交錯時就有前後穿越的感覺。\r
1494   轉向用 rotateY,轉彎時 rotateZ 帶一點側傾。 */\r
1495const PERSP=900;\r
1496function beeHop(el,i){\r
1497  if(!el.isConnected||el._stopped)return;\r
1498  let bw=150;\r
1499  try{\r
1500    const elem=el.querySelector('svg, img');\r
1501    if(elem){\r
1502      const cw=elem.clientWidth||(elem.getBoundingClientRect&&elem.getBoundingClientRect().width);\r
1503      if(typeof cw==='number'&&cw>0)bw=Math.round(cw);\r
1504    }\r
1505  }catch(e){}\r
1506  const band=beeBand(),W=innerWidth;\r
1507  const k=[],n=5+((Math.random()*3)|0);\r
1508  let x=el._x==null?(i?Math.round(W*0.65):Math.round(W*0.22)):el._x,\r
1509      y=el._y==null?band.top+band.h*(i?0.55:0.25):el._y,\r
1510      z=el._z==null?(i?-200:60):el._z;\r
1511  const frame=(px,py,pz,off)=>{\r
1512    const dx=px-x,dy=py-y;\r
1513    const yaw=Math.max(-52,Math.min(52,dx*0.16))+(dx<0?180:0);   /* 朝著去向轉身 */\r
1514    const bank=Math.max(-16,Math.min(16,-dx*0.035+dy*0.03));      /* 轉彎側傾 */\r
1515    const sc=PERSP/(PERSP-pz);\r
1516    k.push({\r
1517      transform:'perspective('+PERSP+'px) translate3d('+Math.round(px)+'px,'+Math.round(py)+'px,'+Math.round(pz)+'px) rotateY('+yaw.toFixed(1)+'deg) rotateZ('+bank.toFixed(1)+'deg)',\r
1518      opacity:(0.72+0.28*Math.min(1,sc)).toFixed(2),\r
1519      filter:'drop-shadow(0 '+Math.round(6*sc)+'px '+Math.round(12*sc)+'px rgba(0,0,0,.3)) blur('+(pz<-260?1.2:0).toFixed(1)+'px) brightness('+(0.86+0.14*Math.min(1.2,sc)).toFixed(2)+')',\r
1520      offset:off\r
1521    });\r
1522    x=px;y=py;z=pz;\r
1523  };\r
1524  frame(x,y,z,0);\r
1525  for(let j=1;j<=n;j++){\r
1526    const px=-bw*0.4+Math.random()*(W-bw*0.2),\r
1527          py=band.top+Math.random()*(band.h-40),\r
1528          pz=-420+Math.random()*560;                              /* 由遠到近 */\r
1529    frame(px,py,pz,j/n);\r
1530  }\r
1531  el._x=x;el._y=y;el._z=z;\r
1532  if(i===0)buzzAt(x/Math.max(1,innerWidth),(z+420)/560);\r
1533  /* 近的那隻蓋住遠的那隻 */\r
1534  clearInterval(el._zt);\r
1535  el._zt=setInterval(()=>{\r
1536    const m=(el.style.transform||'').match(/translate3d\\([^,]+,[^,]+,(-?[\\d.]+)px\\)/);\r
1537    if(m)el.style.zIndex=String(9+Math.round((+m[1]+420)/120));\r
1538  },500);\r
1539  const a=el.animate(k,{duration:7000+Math.random()*6000,easing:'ease-in-out',fill:'forwards'});\r
1540  el._anim=a;\r
1541  a.finished.then(()=>beeHop(el,i)).catch(()=>{});\r
1542}\r
1543function create3DBee(container, size){\r
1544  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r
1545  svg.setAttribute('class', 'zdog-svg');\r
1546  svg.setAttribute('width', '250');\r
1547  svg.setAttribute('height', '200');\r
1548  svg.setAttribute('viewBox', '-125 -100 250 200');\r
1549  svg.style.display = 'block';\r
1550  svg.style.overflow = 'visible';\r
1551  svg.style.width = (size || 150) + 'px';\r
1552  svg.style.height = Math.round((size || 150) * 0.8) + 'px';\r
1553  svg.style.pointerEvents = 'auto';\r
1554  svg.style.cursor = 'grab';\r
1555  container.appendChild(svg);\r
1556\r
1557  let isSpinning = true;\r
1558  let animId = null;\r
1559\r
1560  function initModel(zd){\r
1561    if (svg._stopped) return;\r
1562    const TAU = zd.TAU;\r
1563    const yellow = 'rgb(255, 200, 0, 1)';\r
1564\r
1565    const illo = new zd.Illustration({\r
1566      element: svg,\r
1567      dragRotate: true,\r
1568      zoom: 1.1,\r
1569      rotate: { x: -TAU / 8, y: -TAU / 8 }\r
1570    });\r
1571\r
1572    const body = new zd.Anchor({\r
1573      addTo: illo,\r
1574    });\r
1575\r
1576    const head = new zd.Ellipse({\r
1577      addTo: body,\r
1578      diameter: 16,\r
1579      stroke: 32,\r
1580      fill: true,\r
1581      color: yellow,\r
1582    });\r
1583\r
1584    const eyes = new zd.Shape({\r
1585      addTo: body,\r
1586      translate: { z: -24 },\r
1587      path: [\r
1588        { x: 12, y: -4 },\r
1589        { x: 12, y: 4 },\r
1590        { move: { x: -12, y: -4 } },\r
1591        { x: -12, y: 4 },\r
1592      ],\r
1593      closed: false,\r
1594      stroke: 12,\r
1595      color: '#000',\r
1596    });\r
1597\r
1598    const sensor = new zd.Ellipse({\r
1599      addTo: head,\r
1600      translate: { x: 8, y: -32, z: -16 },\r
1601      rotate: { y: TAU / 4 },\r
1602      diameter: 32,\r
1603      quarters: 1,\r
1604      stroke: 12,\r
1605      color: '#000',\r
1606    });\r
1607    sensor.copy({\r
1608      translate: { x: -8, y: -32, z: -16 },\r
1609    });\r
1610\r
1611    const ring1 = new zd.Ellipse({\r
1612      addTo: head,\r
1613      translate: { z: 26 },\r
1614      diameter: 42,\r
1615      stroke: 16,\r
1616      color: '#000',\r
1617    });\r
1618\r
1619    const ring2 = new zd.Ellipse({\r
1620      addTo: ring1,\r
1621      translate: { z: 18 },\r
1622      diameter: 48,\r
1623      stroke: 16,\r
1624      color: yellow,\r
1625    });\r
1626\r
1627    const ring3 = new zd.Ellipse({\r
1628      addTo: ring2,\r
1629      translate: { z: 18 },\r
1630      diameter: 42,\r
1631      stroke: 16,\r
1632      color: '#000',\r
1633    });\r
1634\r
1635    const ring4 = new zd.Ellipse({\r
1636      addTo: ring3,\r
1637      translate: { z: 18 },\r
1638      diameter: 24,\r
1639      stroke: 16,\r
1640      color: yellow,\r
1641    });\r
1642\r
1643    const stinger = new zd.Shape({\r
1644      addTo: ring4,\r
1645      translate: { z: 18 },\r
1646      stroke: 16,\r
1647      color: '#000',\r
1648    });\r
1649\r
1650    const anchorWingL = new zd.Anchor({\r
1651      addTo: body,\r
1652      translate: { x: 42, z: 42 },\r
1653    });\r
1654\r
1655    new zd.RoundedRect({\r
1656      addTo: anchorWingL,\r
1657      translate: { x: 32 },\r
1658      rotate: { x: TAU / 4 },\r
1659      width: 64,\r
1660      height: 42,\r
1661      cornerRadius: 8,\r
1662      stroke: 12,\r
1663      fill: true,\r
1664      color: 'rgba(89, 171, 255, 0.6)',\r
1665    });\r
1666\r
1667    const anchorWingR = new zd.Anchor({\r
1668      addTo: body,\r
1669      translate: { x: -42, z: 42 },\r
1670    });\r
1671\r
1672    new zd.RoundedRect({\r
1673      addTo: anchorWingR,\r
1674      translate: { x: -32 },\r
1675      rotate: { x: TAU / 4 },\r
1676      width: 64,\r
1677      height: 42,\r
1678      cornerRadius: 8,\r
1679      stroke: 12,\r
1680      fill: true,\r
1681      color: 'rgba(89, 171, 255, 0.6)',\r
1682    });\r
1683\r
1684    illo.updateRenderGraph();\r
1685\r
1686    let t = 1;\r
1687    const tSpeed = 1 / 2.89;\r
1688\r
1689    function animate() {\r
1690      if (svg._stopped) return;\r
1691      t += tSpeed;\r
1692      const theta = t * TAU;\r
1693\r
1694      anchorWingL.rotate.z = 1.5 * Math.sin(theta);\r
1695      anchorWingL.rotate.x = 0.5 * Math.cos(theta);\r
1696\r
1697      anchorWingR.rotate.z = -1.5 * Math.sin(theta);\r
1698      anchorWingR.rotate.x = -0.5 * Math.cos(theta);\r
1699\r
1700      if (isSpinning) {\r
1701        illo.rotate.y += -0.02;\r
1702      }\r
1703\r
1704      illo.updateRenderGraph();\r
1705      animId = requestAnimationFrame(animate);\r
1706    }\r
1707\r
1708    animate();\r
1709  }\r
1710\r
1711  function tryInit(attempts){\r
1712    if (svg._stopped) return;\r
1713    const zd = (typeof Zdog !== 'undefined' ? Zdog : (typeof window !== 'undefined' && window.Zdog ? window.Zdog : (typeof parent !== 'undefined' && parent.Zdog ? parent.Zdog : null)));\r
1714    if (zd) {\r
1715      initModel(zd);\r
1716    } else if ((attempts || 0) < 30) {\r
1717      setTimeout(() => tryInit((attempts || 0) + 1), 100);\r
1718    }\r
1719  }\r
1720  tryInit(0);\r
1721\r
1722  svg.addEventListener('mousedown', () => { isSpinning = false; });\r
1723  svg.addEventListener('mouseup', () => { isSpinning = true; });\r
1724  svg.addEventListener('mouseleave', () => { isSpinning = true; });\r
1725  svg.addEventListener('touchstart', (e) => {\r
1726    isSpinning = false;\r
1727    e.preventDefault();\r
1728  }, { passive: false });\r
1729  svg.addEventListener('touchend', () => { isSpinning = true; });\r
1730\r
1731  svg._stop = () => {\r
1732    svg._stopped = true;\r
1733    if (animId) cancelAnimationFrame(animId);\r
1734  };\r
1735\r
1736  return svg;\r
1737}\r
1738\r
1739function flyBees(){\r
1740  const sps = (validSprites(window.WALL_SPRITES)||SPRITE_DEF);\r
1741  sps.forEach((spr,i)=>{\r
1742    if(document.querySelector('.fx-bee[data-bee="'+i+'"]'))return;\r
1743    const d=document.createElement('div');d.className='fx-bee';d.dataset.bee=i;\r
1744    const wob=document.createElement('span');wob.className='wob';\r
1745    const zd = (typeof Zdog !== 'undefined' ? Zdog : (typeof window !== 'undefined' && window.Zdog ? window.Zdog : null));\r
1746    const is3D = (/^bee:/i.test(String(spr)) || !spr) && !!zd;\r
1747    d.appendChild(wob);\r
1748    document.body.appendChild(d);\r
1749    if(is3D){\r
1750      create3DBee(wob, 150);\r
1751    } else {\r
1752      const src = spriteSrc(spr);\r
1753      if(src){\r
1754        const im=new Image();im.src=src;im.alt='';im.decoding='async';\r
1755        im.onerror=()=>d.remove();\r
1756        wob.appendChild(im);\r
1757      }\r
1758    }\r
1759    d._stop=()=>{\r
1760      d._stopped=true;clearInterval(d._zt);\r
1761      if(d._anim)d._anim.cancel();\r
1762      const s=d.querySelector('svg');if(s&&s._stop)s._stop();\r
1763      d.remove();\r
1764    };\r
1765    setTimeout(()=>beeHop(d,i),i*900);\r
1766  });\r
1767}\r
1768/* ---------- 音效 ----------\r
1769   全部用 Web Audio 即時合成,沒有任何外部音檔,所以獨立牆仍然是單檔、離線可用。\r
1770   瀏覽器規定要有使用者動作才能出聲,因此音訊在第一次點擊後才會啟動。 */\r
1771let AC=null,MASTER=null,SND=true;\r
1772function audio(){\r
1773  if(AC)return AC;\r
1774  const C=window.AudioContext||window.webkitAudioContext;if(!C)return null;\r
1775  AC=new C();MASTER=AC.createGain();MASTER.gain.value=SND?0.5:0;MASTER.connect(AC.destination);\r
1776  return AC;\r
1777}\r
1778function audioResume(){const c=audio();if(c&&c.state==='suspended')c.resume();}\r
1779function sndSet(on){\r
1780  SND=!!on;try{localStorage.setItem('wiki_snd',SND?'1':'0');}catch(e){}\r
1781  if(MASTER&&AC)MASTER.gain.setTargetAtTime(SND?0.5:0,AC.currentTime,0.05);\r
1782  const b=document.getElementById('sndBtn');\r
1783  if(b){b.setAttribute('aria-pressed',SND);b.querySelector('.mi').textContent=SND?'🔊':'🔇';}\r
1784  if(SND){audioResume();if(fxFly)buzzStart();}else buzzStop();\r
1785}\r
1786/* 升空:短促的上滑哨音 */\r
1787function sfxLaunch(){\r
1788  const c=audio();if(!c||!SND||!fxFw)return;\r
1789  const o=c.createOscillator(),g=c.createGain();\r
1790  o.type='sine';o.frequency.setValueAtTime(420,c.currentTime);\r
1791  o.frequency.exponentialRampToValueAtTime(1500,c.currentTime+0.45);\r
1792  g.gain.setValueAtTime(0.0001,c.currentTime);\r
1793  g.gain.exponentialRampToValueAtTime(0.05,c.currentTime+0.06);\r
1794  g.gain.exponentialRampToValueAtTime(0.0001,c.currentTime+0.5);\r
1795  o.connect(g);g.connect(MASTER);o.start();o.stop(c.currentTime+0.55);\r
1796}\r
1797/* 爆炸:低頻轟聲+白噪尾巴,位置決定左右聲道 */\r
1798function sfxBoom(pan){\r
1799  const c=audio();if(!c||!SND||!fxFw)return;\r
1800  const dur=1.1,sr=c.sampleRate,buf=c.createBuffer(1,Math.round(sr*dur),sr),d=buf.getChannelData(0);\r
1801  for(let i=0;i<d.length;i++){const t=i/d.length;d[i]=(Math.random()*2-1)*Math.pow(1-t,3);}\r
1802  const n=c.createBufferSource();n.buffer=buf;\r
1803  const lp=c.createBiquadFilter();lp.type='lowpass';\r
1804  lp.frequency.setValueAtTime(1800,c.currentTime);\r
1805  lp.frequency.exponentialRampToValueAtTime(220,c.currentTime+0.7);\r
1806  const g=c.createGain();\r
1807  g.gain.setValueAtTime(0.28,c.currentTime);\r
1808  g.gain.exponentialRampToValueAtTime(0.0008,c.currentTime+dur);\r
1809  const th=c.createOscillator(),tg=c.createGain();\r
1810  th.type='sine';th.frequency.setValueAtTime(90,c.currentTime);\r
1811  th.frequency.exponentialRampToValueAtTime(38,c.currentTime+0.35);\r
1812  tg.gain.setValueAtTime(0.22,c.currentTime);\r
1813  tg.gain.exponentialRampToValueAtTime(0.0008,c.currentTime+0.5);\r
1814  let out=MASTER;\r
1815  if(c.createStereoPanner){const sp=c.createStereoPanner();sp.pan.value=Math.max(-1,Math.min(1,(pan||0.5)*2-1));
1815sp.connect(MASTER);out=sp;}\r
1816  n.connect(lp);lp.connect(g);g.connect(out);th.connect(tg);tg.connect(out);\r
1817  n.start();th.start();th.stop(c.currentTime+0.5);\r
1818}\r
1819/* 飛行物:持續的嗡嗡聲,音量與左右位置跟著飛行位置走 */\r
1820let BUZZ=null;\r
1821function buzzStart(){\r
1822  const c=audio();if(!c||!SND||!fxFly||BUZZ)return;\r
1823  const o1=c.createOscillator(),o2=c.createOscillator(),lfo=c.createOscillator();\r
1824  const lg=c.createGain(),lp=c.createBiquadFilter(),g=c.createGain();\r
1825  o1.type='sawtooth';o1.frequency.value=112;o2.type='sawtooth';o2.frequency.value=119;\r
1826  lfo.type='sine';lfo.frequency.value=7.5;lg.gain.value=14;lfo.connect(lg);\r
1827  lg.connect(o1.frequency);lg.connect(o2.frequency);\r
1828  lp.type='lowpass';lp.frequency.value=900;lp.Q.value=6;\r
1829  g.gain.value=0.0001;\r
1830  let out=g;\r
1831  const pan=c.createStereoPanner?c.createStereoPanner():null;\r
1832  o1.connect(lp);o2.connect(lp);lp.connect(g);\r
1833  if(pan){g.connect(pan);pan.connect(MASTER);}else g.connect(MASTER);\r
1834  o1.start();o2.start();lfo.start();\r
1835  g.gain.setTargetAtTime(0.035,c.currentTime,0.6);\r
1836  BUZZ={o1,o2,lfo,g,pan};\r
1837}\r
1838function buzzStop(){\r
1839  if(!BUZZ||!AC)return;\r
1840  const b=BUZZ;BUZZ=null;\r
1841  b.g.gain.setTargetAtTime(0.0001,AC.currentTime,0.15);\r
1842  setTimeout(()=>{try{b.o1.stop();b.o2.stop();b.lfo.stop();}catch(e){}},400);\r
1843}\r
1844/* 蜜蜂飛到哪,嗡嗡聲就偏到哪、近的大聲遠的小聲 */\r
1845function buzzAt(x,depth){\r
1846  if(!BUZZ||!AC)return;\r
1847  if(BUZZ.pan)BUZZ.pan.pan.setTargetAtTime(Math.max(-1,Math.min(1,x*2-1)),AC.currentTime,0.25);\r
1848  BUZZ.g.gain.setTargetAtTime(0.02+0.03*Math.max(0,Math.min(1,depth)),AC.currentTime,0.4);\r
1849}\r
1850\r
1851/* ---------- 特效開關 ----------\r
1852   煙火與飛行物各自獨立,狀態分開記住;另有一顆音效總開關。\r
1853   兩個特效都從載入就開始跑,分頁切到背景時自動暫停。 */\r
1854let fxFw=false,fxFly=true,fxT=0,fxWall=null;   /* 預設開啟 3D 飛行蜜蜂 */\r
1855function fxClearFly(){\r
1856  document.querySelectorAll('.fx-bee,.fx-spark').forEach(el=>{\r
1857    if(el._stop)el._stop();\r
1858    el.getAnimations&&el.getAnimations().forEach(a=>a.cancel());el.remove();\r
1859  });\r
1860  buzzStop();\r
1861}\r
1862function fxClearFw(){document.querySelectorAll('.fx-layer').forEach(c=>{c._stop=true;});}\r
1863function fxClear(){fxClearFly();fxClearFw();}\r
1864function fxStart(wall){\r
1865  fxWall=wall||fxWall;\r
1866  if(document.hidden||fxReduce()||!fxWall)return;\r
1867  if(fxFly&&beeImgs().length){flyBees();if(SND)buzzStart();}\r
1868  if(fxFw&&!document.querySelector('.fx-layer'))fireworks(fxWall,Infinity,null);\r
1869}\r
1870function fxPaint(){\r
1871  const f=document.getElementById('fwBtn'),y=document.getElementById('flyBtn'),n=document.getElementById('sndBtn');\r
1872  if(f){f.setAttribute('aria-pressed',fxFw);f.querySelector('.mi').textContent=fxFw?'🎆':'🌑';}\r
1873  if(y){y.setAttribute('aria-pressed',fxFly);y.querySelector('.mi').textContent=fxFly?'🐝':'💤';y.disabled=!beeImgs().length;}\r
1874  if(n){n.setAttribute('aria-pressed',SND);n.querySelector('.mi').textContent=SND?'🔊':'🔇';}\r
1875}\r
1876function fxSetFw(on){\r
1877  fxFw=!!on;try{localStorage.setItem('wiki_fx_fw2',fxFw?'1':'0');}catch(e){}\r
1878  fxPaint();audioResume();\r
1879  fxFw?fxStart():fxClearFw();\r
1880}\r
1881function fxSetFly(on){\r
1882  fxFly=!!on;try{localStorage.setItem('wiki_fx_fly2',fxFly?'1':'0');}catch(e){}\r
1883  fxPaint();audioResume();\r
1884  fxFly?fxStart():fxClearFly();\r
1885}\r
1886function fxSet(on){fxSetFw(on);fxSetFly(on);}        /* 舊介面:兩個一起開關 */\r
1887/* 目前的特效開關,匯出獨立牆時當作預設值寫進去 */\r
1888function fxState(){return {fw:fxFw,fly:fxFly,snd:SND};}\r
1889/* 作者匯出時的特效預設;訪客自己在 localStorage 的選擇仍然優先(見 fxInit) */\r
1890function fxDefaults(d){\r
1891  if(!d||typeof d!=='object')return;\r
1892  if(typeof d.fly==='boolean')fxFly=d.fly;\r
1893  if(typeof d.fw==='boolean')fxFw=d.fw;\r
1894  if(typeof d.snd==='boolean')SND=d.snd;\r
1895}\r
1896function fwBtnHTML(){return '<button id="fwBtn" class="pill fx" aria-pressed="false" data-i18n-aria="fxFire"><span class="mi">🎆</span></button>';}\r
1897function flyBtnHTML(){return '<button id="flyBtn" class="pill fx" aria-pressed="true" data-i18n-aria="fxFly"><span class="mi">🐝</span></button>';}\r
1898function sndBtnHTML(){return '<button id="sndBtn" class="pill snd" aria-pressed="true" data-i18n-aria="fxSound"><span class="mi">🔊</span></button>';}\r
1899function fxBtnHTML(){return '<span id="fxGroup" class="fx-group">'+fwBtnHTML()+flyBtnHTML()+sndBtnHTML()+'</span>';}\r
1900/* 這面牆有沒有「放進來的東西」——圖卡、3D 卡,或自訂的飛行圖示。\r
1901   都沒有的話特效就沒有對象,MagicBar 上不擺特效鍵,特效本身也不跑。 */\r
1902function isMediaCard(o){\r
1903  if(!o)return false;\r
1904  if(o.type==='model'||o.pic===true)return true;\r
1905  return o.type==='html'&&/<img\\b[^>]*\\bsrc=["']data:image\\//i.test(o.html||'');\r
1906}\r
1907/* 特效鍵一律出現(不再看牆裡有沒有圖卡/3D 卡) */\r
1908function fxAvailable(){return true;}\r
1909/* 顯示/收起整組特效鍵。收起時特效停掉,但不寫進 localStorage,\r
1910   之後放了檔案再出現時,使用者原本的開關選擇還在。 */\r
1911let fxOff=false;\r
1912function fxShow(on){\r
1913  const g=document.getElementById('fxGroup');\r
1914  if(g)g.hidden=!on;\r
1915  const was=fxOff;fxOff=!on;\r
1916  if(fxOff){fxClear();buzzStop();}\r
1917  else if(was&&fxWall)playFX(fxWall,200);\r
1918}\r
1919function playFX(wall,delay){\r
1920  fxWall=wall;\r
1921  if(fxOff)return;\r
1922  clearTimeout(fxT);\r
1923  fxT=setTimeout(()=>fxStart(wall),delay||0);\r
1924}\r
1925function fxInit(wall, explicitFx){\r
1926  /* 訪客自己按過的開關優先於作者匯出時的預設;沒按過才用作者的預設 */\r
1927  try{\r
1928    const g=k=>localStorage.getItem(k);\r
1929    if(g('wiki_fx_fw2')!==null)fxFw=g('wiki_fx_fw2')==='1';\r
1930    if(g('wiki_fx_fly2')!==null)fxFly=g('wiki_fx_fly2')==='1';\r
1931    if(g('wiki_snd')!==null)SND=g('wiki_snd')==='1';\r
1932  }catch(e){}\r
1933  if(explicitFx&&typeof explicitFx==='object'){\r
1934    if(typeof explicitFx.fly==='boolean')fxFly=explicitFx.fly;\r
1935    if(typeof explicitFx.fw==='boolean')fxFw=explicitFx.fw;\r
1936    if(typeof explicitFx.snd==='boolean')SND=explicitFx.snd;\r
1937  }\r
1938  fxPaint();\r
1939  const f=document.getElementById('fwBtn'),y=document.getElementById('flyBtn'),n=document.getElementById('sndBtn');\r
1940  if(f)f.addEventListener('click',()=>fxSetFw(!fxFw));\r
1941  if(y)y.addEventListener('click',()=>fxSetFly(!fxFly));\r
1942  if(n)n.addEventListener('click',()=>sndSet(!SND));\r
1943  /* 瀏覽器要求:先有使用者動作才能播放聲音 */\r
1944  const wake=()=>{audioResume();if(SND&&fxFly)buzzStart();};\r
1945  ['pointerdown','keydown'].forEach(k=>document.addEventListener(k,wake,{once:false,passive:true}));\r
1946  document.addEventListener('visibilitychange',()=>{document.hidden?fxClear():fxStart();});\r
1947  addEventListener('resize',()=>{fxClear();setTimeout(()=>fxStart(),260);});\r
1948  playFX(wall,300);\r
1949}\r
1950const introFX=playFX;\r
1951\r
1952/* ---------- A 區:頂部走馬燈 ----------\r
1953   編輯區裡一行「===」以上的卡片屬於 A 區,以下屬於 B 區,兩區內容各自獨立、不會互相流通。\r
1954   「===」只是輸入時的分隔記號,前端不顯示。\r
1955   A 區一次顯示 3 張(窄螢幕 2 或 1 張),每 3.5 秒滑一張。\r
1956   位置用「環狀座標」計算,節點從不搬動,所以 iframe 不會重新載入;\r
1957   只有看得到的 3 張+下一張會真的載入,其餘維持佔位。 */\r
1958const ZA_MS=3500;\r
1959/* A band is a marquee strip: 3 cards at a time (2 or 1 on narrow screens), advancing one card\r
1960   every 3.5s, paused while the pointer is over it. Zone A and Zone C are two independent bands\r
1961   built from the same code, so they behave identically. */\r
1962function Band(id){return {id,els:new Map(),items:[],off:0,timer:0,step:0,h:0,k:3,hover:false,paused:false};}\r
1963const ZA=Band('zoneA'),ZC=Band('zoneC');\r
1964const bandOf=id=>id==='zoneC'?ZC:ZA;\r
1965const zaSig=o=>o._raw+'|'+(o.emb||'')+'|'+(o.blk?1:0);\r
1966const zaCols=W=>W<560?1:W<860?2:3;\r
1967const zaReduce=()=>window.matchMedia&&matchMedia('(prefers-reduced-motion: reduce)').matches;\r
1968function zaStop(B){clearInterval(B.timer);B.timer=0;}\r
1969function zaStart(B){\r
1970  zaStop(B);\r
1971  if(B.items.length>B.k&&!B.hover&&!B.paused&&!zaReduce())B.timer=setInterval(()=>zaMove(B,1),ZA_MS);\r
1972}\r
1973/* Side arrows: one card per press, and the timer restarts after a manual move. */\r
1974function zaMove(B,d){\r
1975  const n=B.items.length;if(n<=B.k)return;\r
1976  B.off=(B.off+d+n)%n;zaPlace(B,false);\r
1977  if(B.timer)zaStart(B);\r
1978}\r
1979function zaPlace(B,instant){\r
1980  const n=B.items.length,cw=B.step-GAP;\r
1981  /* The band height is the tallest card, so its bottom edge never shifts while sliding. */\r
1982  const band=B.h;\r
1983  const sec=document.getElementById(B.id);\r
1984  B.items.forEach((o,i)=>{\r
1985    const el=B.els.get(o._id);if(!el)return;\r
1986    const rel=(i-B.off+n)%n,x=rel*B.step,h=Math.min(fitH(o,cw,B.k),B.h);\r
1987    applySize(el,{w:cw,h});foldSync(el,o,h);\r
1988    el.style.top=Math.round((band-h)/2)+'px';\r
1989    /* The card that wraps to the back jumps instead of sliding across the whole track. */\r
1990    if(instant||el._rel==null||Math.abs(el._rel-rel)>1){el.style.transition='none';el.style.left=x+'px';void el.offsetWidth;el.style.transition='';}\r
1991    else el.style.left=x+'px';\r
1992    el._rel=rel;el._keep=rel<=B.k;\r
1993    if(el._keep)mountQ.add(el);\r
1994  });\r
1995  pump();\r
1996}\r
1997function bandUpdate(B,items){\r
1998  const sec=document.getElementById(B.id);if(!sec)return;\r
1999  const track=sec.querySelector('.za-track');\r
2000  const on=items.length>0,was=!sec.hidden;\r
2001  sec.hidden=!on;\r
2002  if(B.id==='zoneA')document.body.classList.toggle('za-on',on);\r
2003  if(was!==on){sec.style.marginTop='';dispatchEvent(new Event('wall:carousel'));}\r
2004  if(!on){B.els.forEach(el=>dropCard(el));B.els.clear();B.items=[];zaStop(B);return;}\r
2005  const keep=new Map(items.map(o=>[o._id,o]));\r
2006  B.els.forEach((el,id)=>{const o=keep.get(id);if(!o||el._sig!==zaSig(o)){dropCard(el);B.els.delete(id);}});\r
2007  B.items=items;\r
2008  const W=sec.clientWidth||document.documentElement.clientWidth;\r
2009  B.k=Math.min(zaCols(W),items.length);\r
2010  B.step=Math.round((W-GAP*(B.k-1))/B.k)+GAP;\r
2011  let h=0;items.forEach(o=>{const ih=fitH(o,B.step-GAP,B.k);if(ih>h)h=ih;});\r
2012  B.h=Math.max(160,Math.min(h,600));sec.style.height=B.h+'px';\r
2013  items.forEach(o=>{\r
2014    let el=B.els.get(o._id);\r
2015    if(!el){el=makeCard(o,true);el.dataset.id=(B.id==='zoneC'?'c-':'a-')+o._id;el._sig=zaSig(o);track.appendChild(el);B.els.set(o._id,el);}\r
2016    el._o=o;\r
2017  });\r
2018  if(B.off>=items.length)B.off=0;\r
2019  sec.querySelectorAll('.za-arrow').forEach(b=>{b.hidden=items.length<=B.k;});\r
2020  zaPlace(B,true);\r
2021  /* Measure any HTML card that has not reported a height yet, so the band opens tall enough. */\r
2022  items.forEach(o=>{if(o.type==='html'&&!o.mh){const el=B.els.get(o._id);if(el){el._keep=true;mountQ.add(el);}}});\r
2023  pump();\r
2024  zaStart(B);\r
2025}\r
2026function bandInit(B,before,cls){\r
2027  if(document.getElementById(B.id))return;\r
2028  before.insertAdjacentHTML('beforebegin','<section id="'+B.id+'" class="zone-a '+(cls||'')+'" hidden aria-label="'+(B.id==='zoneC'?'InfoMercial':'Topic')+'"><div class="za-track"></div></section>');\r
2029  const sec=document.getElementById(B.id);\r
2030  sec.insertAdjacentHTML('beforeend','<button class="za-arrow za-l" data-za="-1" data-i18n-aria="prev" hidden>‹</button><button class="za-arrow za-r" data-za="1" data-i18n-aria="next" hidden>›</button>');\r
2031  sec.addEventListener('click',e=>{const b=e.target.closest('[data-za]');if(b)zaMove(B,+b.dataset.za);});\r
2032  sec.addEventListener('pointerenter',()=>{B.hover=true;zaStop(B);});\r
2033  sec.addEventListener('pointerleave',()=>{B.hover=false;zaStart(B);});\r
2034  sec.addEventListener('focusin',()=>{B.hover=true;zaStop(B);});\r
2035  sec.addEventListener('focusout',()=>{B.hover=false;zaStart(B);});\r
2036  document.addEventListener('visibilitychange',()=>{B.paused=document.hidden;B.paused?zaStop(B):zaStart(B);});\r
2037  if('IntersectionObserver' in window)new IntersectionObserver(es=>{B.paused=!es[0].isIntersecting;B.paused?zaStop(B):zaStart(B);},{threshold:0}).observe(sec);\r
2038  addEventListener('resize',()=>{if(B.items.length)bandUpdate(B,B.items);});\r
2039}\r
2040function zoneAInit(before){bandInit(ZA,before,'');}\r
2041function zoneAUpdate(items){bandUpdate(ZA,items);}\r
2042function zoneCInit(before){bandInit(ZC,before,'zone-c');}\r
2043function zoneCUpdate(items){bandUpdate(ZC,items);}\r
2044\r
2045/* ---------- 版主的待審列表 ----------\r
2046   卡片是即時公開的,這裡是事後把關:看得到誰什麼時候貼了什麼,一鍵刪除。 */\r
2047let revBox=null;\r
2048function reviewClose(){if(revBox){revBox.remove();revBox=null;}}\r
2049function reviewOpen(id,onDrop,onOk){\r
2050  reviewClose();\r
2051  const box=document.createElement('div');\r
2052  box.className='ins-modal';box.id='revModal';\r
2053  box.innerHTML='<div class="ins-card rev-card" role="dialog" aria-modal="true" aria-labelledby="revHead">'\r
2054    +'<div class="rev-topbar"><div class="rev-title-group"><b id="revHead" data-i18n="revTitle">Review Cards (🛡)</b>'\r
2055    +'<p class="ins-hint" data-i18n="revHint">Pending cards come first. Approved cards do not count toward the wall’s limit (MAX 500 counts pending only).</p></div>'\r
2056    +'<div id="revCount"></div></div>'\r
2057    +'<div class="rev-list" id="revList"></div>'\r
2058    +'<div class="ins-go" style="display:flex;justify-content:space-between;align-items:center;width:100%">'\r
2059      +'<button type="button" class="ins-btn" id="revDropAll" style="background:#dc2626;color:#fff;border:1.5px solid #b91c1c;padding:6px 14px;border-radius:8px;font-size:12px;font-weight:700;cursor:pointer">🗑 Delete All Cards</button>'\r
2060      +'<button type="button" class="ins-btn" id="revClose" data-i18n="insCancel">Close</button>'\r
2061    +'</div></div>';\r
2062  document.body.appendChild(box);revBox=box;\r
2063  applyI18n();\r
2064  box.addEventListener('click',e=>{if(e.target===box)reviewClose();});\r
2065  box.addEventListener('keydown',e=>{e.stopPropagation();if(e.key==='Escape')reviewClose();});\r
2066  box.querySelector('#revClose').addEventListener('click',reviewClose);\r
2067  const btnDropAll=box.querySelector('#revDropAll');\r
2068  if(btnDropAll){\r
2069    btnDropAll.addEventListener('click',()=>{\r
2070      if(!confirm('Are you sure you want to delete all wall cards from this wall?'))return;\r
2071      btnDropAll.disabled=true;\r
2072      syncDropAll(id).then(r=>{\r
2073        if(r.ok){\r
2074          paint([],0);\r
2075          if(onDrop)onDrop('all');\r
2076          reviewClose();\r
2077          const wallEl=document.getElementById('wall');\r
2078          if(wallEl){const emp=document.createElement('div');emp.className='empty';wallEl.replaceChildren(emp);}\r
2079          dispatchEvent(new Event('wall:relayout'));\r
2080        }else{\r
2081          alert('Failed to delete cards. Please check permissions.');\r
2082          btnDropAll.disabled=false;\r
2083        }\r
2084      }).catch(()=>{btnDropAll.disabled=false;});\r
2085    });\r
2086  }\r
2087  const list=box.querySelector('#revList');\r
2088  const paint=(cards, pCount)=>{\r
2089    if(!cards.length){list.innerHTML='<div class="rev-none" data-i18n="revNone">No cards to review.</div>';applyI18n();return;}\r
2090    // Pending cards come first; within same status, newest first\r
2091    const sorted = cards.slice().sort((a,b)=>{\r
2092      const aPend = (!a.ok || a.status === 'pending') ? 0 : 1;\r
2093      const bPend = (!b.ok || b.status === 'pending') ? 0 : 1;\r
2094      return (aPend - bPend) || (b.at - a.at);\r
2095    });\r
2096\r
2097    const pendingNum = (typeof pCount === 'number') ? pCount : sorted.filter(c => !c.ok || c.status === 'pending').length;\r
2098    const cntEl = box.querySelector('#revCount');\r
2099    if (cntEl) {\r
2100      cntEl.innerHTML = '<span class="rev-cnt-pill">' + pendingNum + ' / 500 pending (MAX)</span>';\r
2101    }\r
2102\r
2103    list.innerHTML = sorted.map(c => {\r
2104      const isApproved = (c.ok && c.status !== 'pending');\r
2105      const timeStr = c.at ? new Date(c.at).toLocaleString() : '';\r
2106      const zoneName = ZNAME[c.zone] ? (ZNAME[c.zone] + ' (' + c.zone.toUpperCase() + ')') : ('Zone ' + c.zone.toUpperCase());\r
2107      const fp = esc(String(c.ip || (c.user_id ? ('user #' + c.user_id) : (c.cid || 'anon'))).slice(0, 12));\r
2108      const pasted = esc(String(c.raw || '').slice(0, 300));\r
2109\r
2110      return '<div class="rev-row' + (isApproved ? ' ok' : ' pending') + '" data-cid="' + esc(c.cid) + '">'\r
2111        + '<div class="rev-meta">'\r
2112          + '<span class="rev-st ' + (isApproved ? 'rev-st-ok' : 'rev-st-pend') + '">' + (isApproved ? 'Approved' : 'Pending') + '</span>'\r
2113          + '<span class="rev-time" title="' + esc(timeStr) + '">🕒 ' + esc(timeStr) + '</span>'\r
2114          + '<span class="rev-zone">📍 ' + esc(zoneName) + '</span>'\r
2115          + '<span class="rev-fp" title="Visitor fingerprint">👤 ' + fp + '</span>'\r
2116        + '</div>'\r
2117        + '<div class="rev-body"><code class="rev-raw">' + pasted + '</code></div>'\r
2118        + '<div class="rev-acts">'\r
2119          + (!isApproved ? '<button type="button" class="rev-ok" data-ok="' + esc(c.cid) + '" title="Ap
2119prove - The card becomes permanent" aria-label="Approve">✓ <span class="rev-btn-lbl">Approve</span></button>' : '<span class="rev-permanent-tag">Permanent</span>')\r
2120          + '<button type="button" class="rev-x" data-drop="' + esc(c.cid) + '" title="Remove - The card disappears from every open screen at once" aria-label="Remove">✕ <span class="rev-btn-lbl">Remove</span></button>'\r
2121        + '</div>'\r
2122      + '</div>';\r
2123    }).join('');\r
2124    applyI18n();\r
2125  };\r
2126  list.innerHTML='<div class="rev-none">…</div>';\r
2127  syncReview(id).then(r => {\r
2128    const cards = Array.isArray(r) ? r : (r.cards || []);\r
2129    paint(cards, r.pending_count);\r
2130  }).catch(code => {\r
2131    list.innerHTML = '<div class="rev-none">' + esc(t(code === 403 ? 'revDenied' : 'revFail')) + '</div>';\r
2132  });\r
2133  list.addEventListener('click',e=>{\r
2134    const a=e.target.closest('[data-ok]');\r
2135    if(a){\r
2136      const cid=a.dataset.ok;a.disabled=true;\r
2137      syncApprove(id,cid).then(r=>{\r
2138        if(!r.ok){a.disabled=false;return;}\r
2139        const row=a.closest('.rev-row');\r
2140        if(row){\r
2141          row.classList.remove('pending');\r
2142          row.classList.add('ok');\r
2143          const st=row.querySelector('.rev-st');\r
2144          if(st){\r
2145            st.className='rev-st rev-st-ok';\r
2146            st.textContent='Approved';\r
2147          }\r
2148          a.outerHTML='<span class="rev-permanent-tag">Permanent</span>';\r
2149        }\r
2150        if(onOk)onOk(cid);\r
2151      },()=>{a.disabled=false;});\r
2152      return;\r
2153    }\r
2154    const b=e.target.closest('[data-drop]');if(!b)return;\r
2155    const cid=b.dataset.drop;b.disabled=true;\r
2156    syncDrop(id,cid).then(r=>{\r
2157      if(!r.ok){b.disabled=false;return;}\r
2158      const row=b.closest('.rev-row');if(row)row.remove();\r
2159      if(!list.querySelector('.rev-row'))paint([], 0);\r
2160      if(onDrop)onDrop(cid);\r
2161    },()=>{b.disabled=false;});\r
2162  });\r
2163}\r
2164\r
2165/* ---------- 篩選與排序(關鍵字/類型/日期/長度) ----------\r
2166   篩掉的卡只是隱藏(display:none),節點不動、iframe 不重新載入 */\r
2167const FDEF={q:'',type:'all',date:'any',sort:'wall'};\r
2168/* 獨立牆只有超過這個張數才附篩選功能 */\r
2169const FILTER_MIN=16;\r
2170const txtCache=new WeakMap();\r
2171function textOf(o){\r
2172  if(o.type==='md')return String(o.md||'').replace(/\\s+/g,' ').trim();\r
2173  if(o.type!=='html')return '';\r
2174  if(!txtCache.has(o)){let x='';try{const d=new DOMParser().parseFromString(o.html,'text/html');d.querySelectorAll('script,style').forEach(e=>e.remove());x=(d.body.textContent||'').replace(/\\s+/g,' ').trim();}catch(e){}txtCache.set(o,x);}\r
2175  return txtCache.get(o);\r
2176}\r
2177function kindOf(o){\r
2178  if(isTomb(o))return 'blocked';\r
2179  if(o.type==='model')return 'model';\r
2180  if(o.type==='md')return 'md';\r
2181  if(o.type==='html')return 'html';\r
2182  if(o.type==='youtube')return 'video';\r
2183  const h=hostOf(o.url);\r
2184  if(/(^|\\.)(sketchfab\\.com)$/.test(h))return 'model';\r
2185  if(/(^|\\.)(open\\.spotify\\.com|soundcloud\\.com|podcasts\\.apple\\.com)$/.test(h))return 'audio';\r
2186  if((o.fit&&(o.fit.t==='ratio'||(o.fit.t==='lin'&&/\\/plugins\\/video/.test(o.url))))||/(^|\\.)(vimeo\\.com|bilibili\\.com|dailymotion\\.com|tiktok\\.com)$/.test(h))return 'video';\r
2187  return 'page';\r
2188}\r
2189function titleOf(o){return o.title||(o.type==='model'?(o.mdl&&o.mdl.n||'3D model'):o.type==='md'?mdTitle(o.md):o.type==='html'?textOf(o).slice(0,80):'')||hostOf(o.url)||o.type;}\r
2190/* 日期:有發布時間用發布時間,否則用加入牆面的時間 */\r
2191function dateOf(o){return o.pub||o.at||0;}\r
2192function matches(o,F){\r
2193  if(F.type!=='all'&&kindOf(o)!==F.type)return false;\r
2194  if(F.date!=='any'){\r
2195    const d=dateOf(o);if(!d)return false;\r
2196    const lim=F.date==='today'?new Date().setHours(0,0,0,0):Date.now()-(F.date==='7d'?7:30)*DAY;\r
2197    if(d<lim)return false;\r
2198  }\r
2199  const q=String(F.q||'').trim().toLowerCase();if(!q)return true;\r
2200  const hay=[o.title,(o.tags||[]).map(x=>'#'+x).join(' '),hostOf(o.url),o.url,t('t'+kindOf(o).replace(/^./,c=>c.toUpperCase())),textOf(o)].join(' ').toLowerCase();\r
2201  return q.split(/\\s+/).every(w=>hay.includes(w));\r
2202}\r
2203function viewOf(list,F){\r
2204  let v=list.filter(o=>matches(o,F));\r
2205  /* 沒有資料的(例如不知道長度)一律排最後 */\r
2206  const by=(f,dir)=>{v=v.map((o,i)=>[o,f(o),i]).sort((a,b)=>{if(a[1]==null&&b[1]==null)return a[2]-b[2];if(a[1]==null)return 1;if(b[1]==null)return -1;return dir*(a[1]-b[1])||a[2]-b[2];}).map(x=>x[0]);};\r
2207  if(F.sort==='new')by(o=>dateOf(o)||null,-1);\r
2208  else if(F.sort==='old')by(o=>dateOf(o)||null,1);\r
2209  else if(F.sort==='long')by(o=>o.dur||null,-1);\r
2210  else if(F.sort==='short')by(o=>o.dur||null,1);\r
2211  else if(F.sort==='az'){const c=new Intl.Collator(LANG,{sensitivity:'base',numeric:true});v=[...v].sort((a,b)=>c.compare(titleOf(a),titleOf(b)));}\r
2212  return v;\r
2213}\r
2214function filterActive(F){return String(F.q||'').trim()!==''||F.type!=='all'||F.date!=='any'||F.sort!=='wall';}\r
2215function applyView(wall,list,F,more){\r
2216  const v=viewOf(list,F),keep=new Set(v.map(o=>o._id));\r
2217  [wall].concat(more||[]).filter(Boolean).forEach(w=>\r
2218    w.querySelectorAll('.item').forEach(el=>el.classList.toggle('f-out',!keep.has(el.dataset.id))));\r
2219  let nm=wall.querySelector('.no-match');\r
2220  if(list.length&&!v.length){if(!nm){nm=document.createElement('div');nm.className='no-match';wall.appendChild(nm);}nm.textContent=t('noMatch');}\r
2221  else if(nm)nm.remove();\r
2222  const c=document.getElementById('fcount');if(c)c.textContent=filterActive(F)?t('results',{n:v.length,m:list.length}):'';\r
2223  const b=document.getElementById('filterBtn');if(b)b.classList.toggle('active',filterActive(F));\r
2224  return v;\r
2225}\r
2226/* ---------- Zone switches ----------\r
2227   A, B and C can each be turned off. In the editor the current state is also the default\r
2228   written into an exported wall; visitors can still toggle zones for themselves. */\r
2229const ZONES=['a','b','c'];\r
2230/* Display names: Zone A = Topic, Zone B = Content, Zone C = InfoMercial */\r
2231/* 三個區塊的名字,介面各處與 EzSheet 說明都用同一組字 */\r
2232const ZNAME={a:'Topic',b:'Content',c:'InfoMercial'};\r
2233function zoneBtnHTML(){\r
2234  return ZONES.map(z=>'<button id="zone'+z.toUpperCase()+'Btn" class="pill zone" data-zone="'+z\r
2235    +'" aria-pressed="true" data-i18n-aria="z'+z.toUpperCase()+'"><span class="lbl">'+ZNAME[z]+'</span>'\r
2236    +'<span class="zn" id="zn'+z.toUpperCase()+'"></span></button>').join('');\r
2237}\r
2238/* Show how many cards each zone holds, so it is obvious where content ended up */\r
2239function zonePaint(state,counts){\r
2240  ZONES.forEach(z=>{\r
2241    const b=document.getElementById('zone'+z.toUpperCase()+'Btn');if(!b)return;\r
2242    b.setAttribute('aria-pressed',!!state[z]);\r
2243    const n=document.getElementById('zn'+z.toUpperCase());\r
2244    if(n&&counts)n.textContent=counts[z]?String(counts[z]):'';\r
2245    b.title=t('z'+z.toUpperCase())+(counts?' · '+(counts[z]||0):'');\r
2246    b.hidden=!!(counts&&!counts[z]&&!state[z]===false&&counts[z]===0&&false);\r
2247  });\r
2248}\r
2249function zoneCounts(list){\r
2250  const c={a:0,b:0,c:0};\r
2251  (list||[]).forEach(o=>{const z=(o.zone==='a'||o.zone==='c')?o.zone:'b';c[z]++;});\r
2252  return c;\r
2253}\r
2254function bindZones(state,onChange){\r
2255  ZONES.forEach(z=>{const b=document.getElementById('zone'+z.toUpperCase()+'Btn');\r
2256    if(b)b.addEventListener('click',()=>{state[z]=!state[z];zonePaint(state);onChange(z);});});\r
2257  zonePaint(state);\r
2258}\r
2259function validZones(o){\r
2260  const r={a:true,b:true,c:true};\r
2261  if(o&&typeof o==='object')ZONES.forEach(z=>{if(typeof o[z]==='boolean')r[z]=o[z];});\r
2262  return r;\r
2263}\r
2264/* ---------- Zone order ----------\r
2265   The three zones can be shown in any order. Order is expressed with CSS \`order\` on a flex\r
2266   body, so no node is ever moved and no iframe reloads. Zone B always keeps the control bar\r
2267   and the carousel page bar directly above it. */\r
2268/* Zone B is always last, with the control bar directly above it; only C and A swap. */\r
2269const ZORDERS=[['c','a','b'],['a','c','b']];\r
2270function validOrder(o){\r
2271  if(Array.isArray(o)&&o.indexOf('a')>=0&&o.indexOf('c')>=0)\r
2272    return o.indexOf('a')<o.indexOf('c')?['a','c','b']:['c','a','b'];\r
2273  return ZORDERS[0].slice();\r
2274}\r
2275function orderLabel(o){return o.map(z=>ZNAME[z]).join(' · ');}\r
2276function applyZoneOrder(order){\r
2277  const put=(id,v)=>{const el=document.getElementById(id);if(el)el.style.order=v;};\r
2278  order.forEach((z,i)=>{\r
2279    const base=(i+1)*10;\r
2280    if(z==='b'){put('barZone',base+1);put('carNav',base+2);put('wall',base+3);}\r
2281    else put(z==='a'?'zoneA':'zoneC',base+1);\r
2282  });\r
2283}\r
2284function zordBtnHTML(){return '';}\r
2285function filterBtnHTML(){return '<button id="filterBtn" class="pill filt" aria-pressed="false" aria-controls="filterBar" data-i18n-aria="filter"><span class="mi">🔍</span><span class="lbl" data-i18n="filter"></span></button>';}\r
2286function filterBarHTML(){\r
2287  const sel=(id,aria,opts)=>'<select id="'+id+'" data-i18n-aria="'+aria+'">'+opts.map(([v,k])=>'<option value="'+v+'" data-i18n="'+k+'"></option>').join('')+'</select>';\r
2288  return '<div id="filterBar" class="filter-bar" role="search" hidden>'\r
2289    +'<input id="fq" type="search" autocomplete="off" spellcheck="false" data-i18n-ph="searchPh" data-i18n-aria="searchPh">'\r
2290    +sel('ftype','fType',[['all','tAll'],['video','tVideo'],['audio','tAudio'],['page','tPage'],['html','tHtml'],['md','tMd'],['model','tModel'],['blocked','tBlocked']])\r
2291    +sel('fdate','fDate',[['any','dAny'],['today','dToday'],['7d','d7'],['30d','d30']])\r
2292    +sel('fsort','fSort',[['wall','sWall'],['new','sNew'],['old','sOld'],['long','sLong'],['short','sShort'],['az','sAz']])\r
2293    +'<span id="fcount" class="f-count" aria-live="polite"></span><button id="fclear" class="f-clear" data-i18n="fClear"></button></div>';\r
2294}\r
2295function bindFilter(wall,F,onChange){\r
2296  const $=id=>document.getElementById(id),bar=$('filterBar'),btn=$('filterBtn'),q=$('fq'),ty=$('ftype'),dt=$('fdate'),so=$('fsort');\r
2297  const sync=()=>{q.value=F.q;ty.value=F.type;dt.value=F.date;so.value=F.sort;};\r
2298  /* 篩選列打開時把牆往下推,列有換行也不會蓋到卡片 */\r
2299  /* 篩選列就排在操縱桿底下,不必再推開版面 */\r
2300  const offset=()=>{dispatchEvent(new Event('wall:offset'));};\r
2301  addEventListener('wall:carousel',offset);\r
2302  const show=(on,quiet)=>{bar.hidden=!on;btn.setAttribute('aria-pressed',on);offset();
2302if(on&&!quiet)q.focus();};\r
2303  btn.addEventListener('click',()=>show(bar.hidden));\r
2304  let tm=0;q.addEventListener('input',()=>{clearTimeout(tm);tm=setTimeout(()=>{F.q=q.value;onChange();},150);});\r
2305  q.addEventListener('keydown',e=>{if(e.key==='Escape'){e.stopPropagation();if(q.value){q.value='';F.q='';onChange();}else show(false);}});\r
2306  ty.addEventListener('change',()=>{F.type=ty.value;onChange();});\r
2307  dt.addEventListener('change',()=>{F.date=dt.value;onChange();});\r
2308  so.addEventListener('change',()=>{F.sort=so.value;onChange();});\r
2309  $('fclear').addEventListener('click',()=>{Object.assign(F,FDEF);sync();onChange();q.focus();});\r
2310  /* 讓外部可以問「篩選列開著嗎」、也可以直接把它打開並帶入條件 */\r
2311  const open=()=>!bar.hidden;\r
2312  /* 「/」快速搜尋 */\r
2313  document.addEventListener('keydown',e=>{\r
2314    if(e.key!=='/'||e.ctrlKey||e.metaKey||e.altKey)return;\r
2315    if(e.target.closest&&e.target.closest('input,textarea,select,[contenteditable]'))return;\r
2316    const panel=$('panel');if(panel&&!panel.classList.contains('hidden'))return;\r
2317    e.preventDefault();show(true);\r
2318  });\r
2319  addEventListener('resize',offset);\r
2320  sync();\r
2321  return {sync,show,open};\r
2322}\r
2323\r
2324/* ---------- 自動抓標題/長度/發布日 ----------\r
2325   Spotify、Vimeo 的官方 oEmbed 可以直接讀;設定 setMetaFetch() 後改用自己的伺服器,任何網站都能補 */\r
2326let META='';const metaAsked=new Set();\r
2327function setMetaFetch(u){META=httpUrl(u)?u:'';}\r
2328function pageUrlOf(o){return o.type==='youtube'?'https://www.youtube.com/watch?v='+o.id:o.url;}\r
2329function metaSource(o){\r
2330  if(o.type!=='web')return '';\r
2331  let m=o.url.match(/^https:\\/\\/open\\.spotify\\.com\\/embed\\/(track|episode|show|album|playlist|artist)\\/([A-Za-z0-9]+)/);\r
2332  if(m)return 'https://open.spotify.com/oembed?url='+encodeURIComponent('https://open.spotify.com/'+m[1]+'/'+m[2]);\r
2333  m=o.url.match(/^https:\\/\\/player\\.vimeo\\.com\\/video\\/(\\d+)/);\r
2334  if(m)return 'https://vimeo.com/api/oembed.json?url='+encodeURIComponent('https://vimeo.com/'+m[1]);\r
2335  return '';\r
2336}\r
2337function fetchMeta(list,onUpdate){\r
2338  list.forEach(o=>{\r
2339    if(o.type==='html'||(o.title&&o.dur))return;\r
2340    const key=pageUrlOf(o);if(!key||metaAsked.has(key))return;\r
2341    const src=META?META+(META.includes('?')?'&':'?')+'url='+encodeURIComponent(key):metaSource(o);if(!src)return;\r
2342    metaAsked.add(key);\r
2343    fetch(src).then(r=>r.ok?r.json():null).then(j=>{\r
2344      if(!j)return;let ch=false;\r
2345      if(!o.title&&typeof j.title==='string'&&j.title.trim()){o.title=j.title.trim().slice(0,200);ch=true;}\r
2346      const d=Number(j.duration);if(!o.dur&&d>0&&d<172800){o.dur=Math.round(d);ch=true;}\r
2347      const p=Date.parse(j.published||j.upload_date||j.release_date||'');if(!o.pub&&p>0){o.pub=p;ch=true;}\r
2348      if(ch)onUpdate(o);\r
2349    }).catch(()=>{});\r
2350  });\r
2351}\r
2352function parseDur(s){\r
2353  s=String(s||'').trim();if(!s)return 0;\r
2354  if(/^\\d+(\\.\\d+)?$/.test(s))return Math.round(parseFloat(s)*60);\r
2355  const p=s.split(':').map(Number);if(p.some(n=>!Number.isFinite(n)))return 0;\r
2356  return p.reduce((a,n)=>a*60+n,0);\r
2357}\r
2358function fmtDur(n){if(!n)return '';const h=Math.floor(n/3600),m=Math.floor(n%3600/60),x=n%60;return (h?h+':'+String(m).padStart(2,'0'):m)+':'+String(x).padStart(2,'0');}\r
2359\r
2360/* 隨機:跨 1~3 條細欄(2 條最常見);一般網頁再隨機高寬比,嵌入類高度照內容 */\r
2361function randomSize(o){\r
2362  const span=[1,1,2,2,2,3][Math.floor(Math.random()*6)];\r
2363  return {...o,span,rh:Math.round((0.6+Math.random()*0.7)*100)/100,manual:false};\r
2364}\r
2365\r
2366/* 獨立牆啟動:讀 <script id="wall-data">,加上頂部「版面/語言」列,依觀看者的選擇呈現 */\r
2367function bootReadonly(){\r
2368  let d={};try{d=JSON.parse(document.getElementById('wall-data').textContent);}catch(e){}\r
2369  const arr=Array.isArray(d)?d:(Array.isArray(d.list)?d.list:[]);\r
2370  const items=arr.map(normalize).filter(Boolean);\r
2371  /* 這位訪客自己插過的卡:存在他的 localStorage,靠原文雜湊記得插在誰前面 */\r
2372  const AKEY='wall_add_'+(String(d.id||'')||'default');\r
2373  let adds=[];\r
2374  try{const a=JSON.parse(localStorage.getItem(AKEY)||'[]');\r
2375    if(Array.isArray(a))adds=a.filter(x=>x&&typeof x.raw==='string').slice(0,200);}catch(e){}\r
2376  const saveAdds=()=>{try{localStorage.setItem(AKEY,JSON.stringify(adds));}catch(e){}};\r
2377  /* 放回原來的位置:找到錨點就插在它前面,找不到就接在同一區的最後 */\r
2378  function placeGuest(o,anchor,zone){\r
2379    o.guest=true;
2379o.zone=(zone==='a'||zone==='c')?zone:'b';\r
2380    let at=-1;\r
2381    if(anchor)at=items.findIndex(x=>!x.guest&&rawHash(x._raw)===anchor);\r
2382    if(at<0){\r
2383      for(let k=items.length-1;k>=0;k--){\r
2384        const z=items[k].zone||'b';\r
2385        if(z===o.zone){at=k+1;break;}\r
2386      }\r
2387    }\r
2388    if(at<0)at=items.length;\r
2389    items.splice(at,0,o);\r
2390    return at;\r
2391  }\r
2392  adds.forEach(a=>{const o=parseOne(a.raw);if(o)placeGuest(o,a.anchor,a.zone);});\r
2393  const orig=new Map(items.map((o,i)=>[o._id,{w:o.w,h:o.h,span:o.span,rh:o.rh,i}]));\r
2394  /* 訪客自己拉過的卡片尺寸:存在他的瀏覽器,用原文雜湊認卡。\r
2395     orig 已經先記下作者的原始尺寸,所以「原始版面」還是回得去。 */\r
2396  const ZSKEY='wall_size_'+(String(d.id||'')||'default');\r
2397  let sizes={};\r
2398  try{const s=JSON.parse(localStorage.getItem(ZSKEY)||'{}');if(s&&typeof s==='object')sizes=s;}catch(e){}\r
2399  const saveSizes=()=>{try{localStorage.setItem(ZSKEY,JSON.stringify(sizes));}catch(e){}};\r
2400  const clampSize=v=>Math.max(MIN,Math.min(MAX,Math.round(+v||0)));\r
2401  items.forEach(o=>{\r
2402    const s=sizes[rawHash(o._raw)];if(!s)return;\r
2403    if(+s.w>0)o.w=clampSize(s.w);\r
2404    if(+s.h>0)o.h=clampSize(s.h);\r
2405    o.manual=!!s.manual;o.span=0;o.rh=0;\r
2406  });\r
2407  const byId=new Map(items.map(o=>[o._id,o]));\r
2408  const id=String(d.id||'');\r
2409  /* 作者匯出時的欄位設定是預設值;沒有欄位就用原始版面 */\r
2410  const authorMode=validCols(d.cols)&&d.cols>0?d.cols:-1;\r
2411  const VKEY='wall_view_'+(id||'default');\r
2412  let pref={};try{pref=JSON.parse(localStorage.getItem(VKEY)||'{}')||{};}catch(e){}\r
2413  let mode=pref.mode===-1||validCols(pref.mode)?pref.mode:authorMode;\r
2414  let car=typeof pref.car==='boolean'?pref.car:!!d.car;\r
2415  const useFilter=typeof d.filter==='boolean'?d.filter:items.length>FILTER_MIN;\r
2416  /* 作者在編輯器裡設定的特效/音效,當作這面牆的預設 */\r
2417  fxDefaults(d.fx);\r
2418  setLangCode(I18N[pref.lang]?pref.lang:d.lang);\r
2419  const savePref=()=>{try{localStorage.setItem(VKEY,JSON.stringify({mode,lang:LANG,car,zones,zorder}));}catch(e){}};\r
2420\r
2421  document.body.insertAdjacentHTML('afterbegin','<div class="bar-zone" id="barZone" aria-label="EzBar"><div class="fab-wrap"><span class="fab badge">'+esc(id||'Wall')+'</span>'+menuHTML(true)+shuffleBtnHTML()+carouselBtnHTML()+(useFilter?filterBtnHTML():'')+zoneBtnHTML()+fxBtnHTML()+syncBtnHTML()+langSelectHTML()+'</div>'+(useFilter?filterBarHTML():'')+'</div>');\r
2422  if(id)document.title=id;\r
2423  const wall=document.getElementById('wall');\r
2424  let empty=null;\r
2425  const bItems=items.filter(o=>o.zone==='b'||!o.zone);\r
2426  if(bItems.length)renderAll(wall,bItems,true);\r
2427  else if(!items.length){empty=document.createElement('div');empty.className='empty';wall.replaceChildren(empty);}\r
2428  const zones=validZones(typeof pref.zones==='object'?pref.zones:d.zones);\r
2429  let zorder=validOrder(pref.zorder||d.zorder);\r
2430\r
2431  function apply(){\r
2432    if(mode===-1)items.forEach(o=>{const g=orig.get(o._id);o.w=g.w;o.h=g.h;o.span=g.span;o.rh=g.rh;});\r
2433    /* 拉過大小的卡不再參與隨機,否則每次重排 span 又被設回去、尺寸就被抹掉。\r
2434       o.manual 只代表「高度也自由拉過」,所以另外看這位訪客存了尺寸沒有。 */\r
2435    else if(mode===0)items.forEach((o,i)=>{\r
2436      if(o.manual||sizes[rawHash(o._raw)])return;\r
2437      items[i]=Object.assign(o,randomSize(o));\r
2438    });\r
2439    pack();\r
2440    updateLayoutUI(mode);\r
2441  }\r
2442  const F={...FDEF};\r
2443  function pack(){\r
2444    const v=applyView(wall,items,F);\r
2445    const A=zones.a?v.filter(o=>o.zone==='a'):[],\r
2446          B=zones.b?v.filter(o=>o.zone==='b'||!o.zone):[],\r
2447          C=zones.c?v.filter(o=>o.zone==='c'):[];\r
2448    zoneCUpdate(C);zoneAUpdate(A);\r
2449    zonePaint(zones,zoneCounts(items));\r
2450    wall.hidden=!zones.b;\r
2451    if(B.length)layoutWall(wall,B,mode>0?mode:0,car);else wall.style.height='';\r
2452  }\r
2453  let raf=0;const later=()=>{if(!raf)raf=requestAnimationFrame(()=>{raf=0;pack();});};\r
2454  addEventListener('wall:relayout',later);\r
2455  const grow=new Map();\r
2456  onMeasure((cid,h)=>{\r
2457    const o=byId.get(cid);if(!o||Math.abs((o.mh||0)-h)<=2)return;\r
2458    if(o.mh&&h>o.mh){const g=(grow.get(cid)||0)+1;grow.set(cid,g);if(g>4)return;}\r
2459    o.mh=h;if(mode!==-1||!orig.get(cid)||o.h>fitH(o,o.w,mode>0?mode:2))o.h=fitH(o,o.w,mode>0?mode:2);later();\r
2460  });\r
2461  function applyLangUI(){applyI18n();updateLayoutUI(mode);applyZoneOrder(zorder);carSync(wall,true);if(empty)empty.textContent=t('wallEmpty');\r
2462    const dot=document.getElementById('syncDot');\r
2463    if(dot&&!dot.hidden)dot.title=t(dot.classList.contains('on')?'syncOn':'syncOff');}\r
2464\r
2465  const reorder=next=>reorderAnimated(wall,next,()=>{items.splice(0,items.length,...next);pack();playFX(wall,60);});\r
2466  /* 訪客拉動把手:改完切回自由版面(欄位版面會覆寫尺寸),並記在本機 */\r
2467  wall.addEventListener('pointerdown',e=>{\r
2468    const a=e.target.closest('.resize-anchor,.side-anchor');
2468if(!a)return;\r
2469    const el=a.closest('.item');if(!el)return;\r
2470    const o=byId.get(el.dataset.id);if(!o)return;\r
2471    resizeStart(a,el,o,a.classList.contains('side-anchor'),e,()=>{\r
2472      /* 欄位版面會覆寫尺寸,「原始版面」會還原成作者的尺寸,\r
2473         兩種都留不住訪客自己拉的大小,所以一律切到自由版面 */\r
2474      if(mode!==0){mode=0;savePref();updateLayoutUI(mode);}\r
2475      sizes[rawHash(o._raw)]={w:o.w,h:o.h,manual:!!o.manual};saveSizes();\r
2476      pack();\r
2477    });\r
2478  });\r
2479  bindMenu(n=>{if(n==='reset'){\r
2480      items.forEach(o=>{delete o.free;delete o.px;delete o.py;\r
2481        const g=orig.get(o._id);\r
2482        if(g){o.w=g.w;o.h=g.h;o.span=g.span;o.rh=g.rh;o.manual=false;}});\r
2483      sizes={};saveSizes();\r
2484      pack();playFX(wall,120);return;}\r
2485    mode=n;savePref();apply();playFX(wall,120);\r
2486    if(n===-1){const back=[...items].sort((a,b)=>orig.get(a._id).i-orig.get(b._id).i);if(back.some((o,i)=>o!==items[i]))reorder(back);}});\r
2487  const fb=useFilter?bindFilter(wall,F,pack):null;\r
2488  /* 作者匯出時篩選列是開著的,就照他留下的條件開著 */\r
2489  /* 讓外層(例如產生器的預覽框)讀回此刻畫面上的設定,當作匯出的預設值 */\r
2490  try{window.wallSettings=function(){\r
2491    const open=!!(fb&&fb.open&&fb.open());\r
2492    return {cols:mode,car:car,zones:Object.assign({},zones),zorder:zorder.slice(),\r
2493      lang:getLang(),fx:fxState(),filter:open||useFilter,\r
2494      fset:open?{q:F.q,type:F.type,date:F.date,sort:F.sort}:null};\r
2495  };}catch(e){}\r
2496  if(fb&&d.fset&&typeof d.fset==='object'){\r
2497    ['q','type','date','sort'].forEach(k=>{if(typeof d.fset[k]==='string')F[k]=d.fset[k];});\r
2498    fb.sync();fb.show(true,true);\r
2499  }\r
2500  bindZones(zones,()=>{savePref();pack();});\r
2501  applyZoneOrder(zorder);\r
2502  document.getElementById('shuffleBtn').addEventListener('click',()=>{if(items.length<2)return;if(fb&&F.sort!=='wall'){F.sort='wall';fb.sync();}reorder(shuffled(items));});\r
2503  const sel=document.getElementById('lang');sel.value=LANG;\r
2504  sel.addEventListener('change',()=>{setLangCode(sel.value);applyLangUI();savePref();});\r
2505  document.getElementById('carBtn').addEventListener('click',()=>{car=!car;savePref();setCarousel(wall,car);pack();playFX(wall,120);});\r
2506  setCarousel(wall,car&&items.length>0);\r
2507  zoneAInit(document.getElementById('barZone'));\r
2508  zoneCInit(document.getElementById('zoneA'));   /* Zone C band sits above Zone A */\r
2509  applyLangUI();apply();\r
2510  verBadge();fxInit(wall, d.fx);\r
2511  /* 這面牆沒有圖卡/3D 卡/自訂飛行圖示時,不顯示特效鍵 */\r
2512  fxShow(fxAvailable(items));\r
2513  /* ---- 插卡:訪客把新卡插在某張卡前面,只存進自己的瀏覽器 ---- */\r
2514  function remountB(){\r
2515    const B=items.filter(o=>o.zone==='b'||!o.zone);\r
2516    if(B.length&&empty){empty.remove();empty=null;}\r
2517    const have=new Set([...wall.children].map(el=>el.dataset.id));\r
2518    B.forEach(o=>{if(!have.has(o._id))wall.appendChild(makeCard(o,true));});\r
2519  }\r
2520  function loadCardsFromDB(){\r
2521    const url = syncBase(typeof WALL_ID !== 'undefined' ? WALL_ID : 'default')+'/cards';\r
2522    const doFetch = (fn) => fn(url, { headers: syncHeaders(false) }).then(r=>r.ok?r.json():null);\r
2523    const applyCards = (data) => {\r
2524      if(data && Array.isArray(data.cards) && data.cards.length){\r
2525        let touched=false;\r
2526        data.cards.forEach(c=>{\r
2527          touched = addServerCard(c) || touched;\r
2528          if(c.ok) promoteServerCard(c.cid);\r
2529        });\r
2530        if(touched){ remountB(); pack(); fxShow(fxAvailable(items)); }\r
2531      }\r
2532    };\r
2533    doFetch(fetch).then(applyCards).catch(()=>{});\r
2534  }\r
2535  loadCardsFromDB();\r
2536\r
2537  function showWallOtpModal(onSuccess){\r
2538    let modal = document.getElementById('wallOtpModal');\r
2539    if (modal) modal.remove();\r
2540\r
2541    modal = document.createElement('div');\r
2542    modal.id = 'wallOtpModal';\r
2543    modal.className = 'ins-modal';\r
2544    modal.innerHTML = '<div class="ins-card wall-otp-card" role="dialog" aria-modal="true" style="max-width:390px;text-align:left;position:relative;">'\r
2545      + '<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;">'\r
2546      + '<b style="font-size:16px;color:var(--ink,#fff);">Sign in to Add Card</b>'\r
2547      + '<button type="button" class="otp-close-btn" style="background:transparent;border:none;color:#94a3b8;font-size:20px;cursor:pointer;line-height:1;padding:4px;">✕</button>'\r
2548      + '</div>'\r
2549      + '<p id="otpPromptHint" class="ins-hint" style="margin-bottom:14px;color:#cbd5e1;font-size:12px;line-height:1.5;">'\r
2550      + 'Please enter your email to sign in and insert your card on this wall.'\r
2551      + '</p>'\r
2552      + '<div id="otpStepEmail">'\r
2553      + '<label style="display:block;font-size:11px;font-weight:600;text-transform:uppercase;color:#94a3b8;margin-bottom:6px;">Email Address</label>'\r
2554      + '<input type="email" id="wallEmailInput" placeholder="[email protected]" style="width:100%;box-sizing:border-box;padding:10px 12px;border-radius:6px;border:1px solid #475569;background:#0f172a;color:#fff;font-size:13px;margin-bottom:12px;outline:none;" />'\r
2555      + '<div id="wallEmailErr" class="ins-err" style="color:#f87171;font-size:11px;margin-bottom:10px;min-height:16px;"></div>'\r
2556      + '<div class="ins-go" style="display:flex;justify-content:flex-end;
2556gap:8px;">'\r
2557      + '<button type="button" class="ins-btn" id="wallEmailCancel">Cancel</button>'\r
2558      + '<button type="button" class="ins-btn on" id="wallEmailSubmit" style="background:#0d9488;color:#fff;border-color:#0d9488;">Send 4-Digit Code</button>'\r
2559      + '</div></div>'\r
2560      + '<div id="otpStepVerify" style="display:none;">'\r
2561      + '<label style="display:block;font-size:11px;font-weight:600;text-transform:uppercase;color:#94a3b8;margin-bottom:6px;">4-Digit Verification Code</label>'\r
2562      + '<input type="text" id="wallCodeInput" maxlength="4" placeholder="••••" style="letter-spacing:10px;font-weight:bold;font-size:22px;text-align:center;width:100%;box-sizing:border-box;padding:10px 12px;border-radius:6px;border:1px solid #475569;background:#0f172a;color:#2dd4bf;margin-bottom:8px;outline:none;" />'\r
2563      + '<div id="wallOtpDebug" style="font-size:11px;color:#2dd4bf;margin-bottom:8px;display:none;background:rgba(45,212,191,0.1);padding:4px 8px;border-radius:4px;"></div>'\r
2564      + '<div id="wallCodeErr" class="ins-err" style="color:#f87171;font-size:11px;margin-bottom:10px;min-height:16px;"></div>'\r
2565      + '<div class="ins-go" style="display:flex;justify-content:space-between;align-items:center;">'\r
2566      + '<button type="button" id="wallResendOtp" style="background:transparent;border:none;color:#38bdf8;font-size:11px;cursor:pointer;text-decoration:underline;">Resend Code</button>'\r
2567      + '<div style="display:flex;gap:8px;">'\r
2568      + '<button type="button" class="ins-btn" id="wallCodeBack">Back</button>'\r
2569      + '<button type="button" class="ins-btn on" id="wallCodeSubmit" style="background:#0d9488;color:#fff;border-color:#0d9488;">Verify & Log in</button>'\r
2570      + '</div></div></div>'\r
2571      + '</div>';\r
2572\r
2573    document.body.appendChild(modal);\r
2574\r
2575    const close = () => { modal.remove(); };\r
2576    modal.querySelector('.otp-close-btn').onclick = close;\r
2577    modal.querySelector('#wallEmailCancel').onclick = close;\r
2578    modal.onclick = (e) => { if (e.target === modal) close(); };\r
2579\r
2580    let currentEmail = '';\r
2581\r
2582    const sendOtpRequest = (email) => {\r
2583      const errEl = modal.querySelector('#wallEmailErr');\r
2584      const submitBtn = modal.querySelector('#wallEmailSubmit');\r
2585      errEl.textContent = '';\r
2586      submitBtn.disabled = true;\r
2587      submitBtn.textContent = 'Sending...';\r
2588\r
2589      fetch('/api/wall/auth/send-otp', {\r
2590        method: 'POST',\r
2591        headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },\r
2592        body: JSON.stringify({ email: email })\r
2593      }).then(async r => {\r
2594        const data = await r.json().catch(() => ({}));\r
2595        submitBtn.disabled = false;\r
2596        submitBtn.textContent = 'Send 4-Digit Code';\r
2597        if (!r.ok || !data.success) {\r
2598          errEl.textContent = data.message || 'Failed to send code. Please try again.';\r
2599          return;\r
2600        }\r
2601        currentEmail = email;\r
2602        modal.querySelector('#otpStepEmail').style.display = 'none';\r
2603        modal.querySelector('#otpStepVerify').style.display = 'block';\r
2604        modal.querySelector('#otpPromptHint').textContent = 'We sent a 4-digit code to ' + email + '. Enter it below:';\r
2605        if (data.debug_otp) {\r
2606          const dbg = modal.querySelector('#wallOtpDebug');\r
2607          dbg.style.display = 'block';\r
2608          dbg.textContent = 'Test Code: ' + data.debug_otp;\r
2609        }\r
2610        const codeInp = modal.querySelector('#wallCodeInput');\r
2611        codeInp.value = '';\r
2612        codeInp.focus();\r
2613      }).catch(err => {\r
2614        submitBtn.disabled = false;\r
2615        submitBtn.textContent = 'Send 4-Digit Code';\r
2616        errEl.textContent = 'Network error. Please try again.';\r
2617      });\r
2618    };\r
2619\r
2620    modal.querySelector('#wallEmailSubmit').onclick = () => {\r
2621      const val = modal.querySelector('#wallEmailInput').value.trim();\r
2622      if (!val || !val.includes('@')) {\r
2623        modal.querySelector('#wallEmailErr').textContent = 'Please enter a valid email address.';\r
2624        return;\r
2625      }\r
2626      sendOtpRequest(val);\r
2627    };\r
2628\r
2629    modal.querySelector('#wallEmailInput').onkeydown = (e) => {\r
2630      if (e.key === 'Enter') { e.preventDefault(); modal.querySelector('#wallEmailSubmit').click(); }\r
2631    };\r
2632\r
2633    modal.querySelector('#wallCodeBack').onclick = () => {\r
2634      modal.querySelector('#otpStepVerify').style.display = 'none';\r
2635      modal.querySelector('#otpStepEmail').style.display = 'block';\r
2636      modal.querySelector('#otpPromptHint').textContent = 'Please enter your email to sign in and insert your card on this wall.';\r
2637    };\r
2638\r
2639    modal.querySelector('#wallResendOtp').onclick = () => {\r
2640      if (currentEmail) sendOtpRequest(currentEmail);\r
2641    };\r
2642\r
2643    modal.querySelector('#wallCodeSubmit').onclick = () => {\r
2644      const code = modal.querySelector('#wallCodeInput').value.trim();\r
2645      const errEl = modal.querySelector('#wallCodeErr');\r
2646      const submitBtn = modal.querySelector('#wallCodeSubmit');\r
2647      errEl.textContent = '';\r
2648      if (!code || code.length !== 4) {\r
2649        errEl.textContent = 'Please enter all 4 digits.';\r
2650        return;\r
2651      }\r
2652      submitBtn.disabled = true;\r
2653      submitBtn.textContent = 'Verifying...';\r
2654\r
2655      fetch('/api/wall/auth/verify-otp', {\r
2656        method: 'POST',\r
2657        headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },\r
2658        body: JSON.stringify({ email: currentEmail, otp: code })\r
2659      }).then(async r => {\r
2660        const data = await r.json().catch(() => ({}));\r
2661        submitBtn.disabled = false;\r
2662        submitBtn.textContent = 'Verify & Log in';\r
2663        if (!r.ok || !data.success) {\r
2664          errEl.textContent = data.message || 'Verification failed. Please check code.';\r
2665          return;\r
2666        }\r
2667        window.auth = window.auth || {};\r
2668        window.auth.user = data.user;\r
2669        close();\r
2670        if (typeof onSuccess === 'function') {\r
2671          onSuccess(data.user);\r
2672        }\r
2673      }).catch(err => {\r
2674        submitBtn.disabled = false;\r
2675        submitBtn.textContent = 'Verify & Log in';\r
2676        errEl.textContent = 'Network error. Please try again.';\r
2677      });\r
2678    };\r
2679\r
2680    modal.querySelector('#wallCodeInput').onkeydown = (e) => {\r
2681      if (e.key === 'Enter') { e.preventDefault(); modal.querySelector('#wallCodeSubmit').click(); }\r
2682    };\r
2683\r
2684    setTimeout(() => {\r
2685      const inp = modal.querySelector('#wallEmailInput');\r
2686      if (inp) inp.focus();\r
2687    }, 50);\r
2688  }\r
2689\r
2690  function checkAuthThenInsert(el, anchorItem){\r
2691    const auth = (typeof window !== 'undefined' ? window.auth : null) || {};\r
2692    if (auth?.user) {\r
2693      insertBefore(el, anchorItem);\r
2694      return;\r
2695    }\r
2696\r
2697    fetch('/api/wall/auth/me', {\r
2698      method: 'GET',\r
2699      headers: { 'Accept': 'application/json' },\r
2700      credentials: 'same-origin'\r
2701    }).then(r => r.json()).then(data => {\r
2702      if (data && data.authenticated && data.user) {\r
2703        window.auth = { user: data.user };\r
2704        insertBefore(el, anchorItem);\r
2705      } else {\r
2706        showWallOtpModal(() => {\r
2707          insertBefore(el, anchorItem);\r
2708        });\r
2709      }\r
2710    }).catch(() => {\r
2711      fetch('/wall/auth/me', {\r
2712        method: 'GET',\r
2713        headers: { 'Accept': 'application/json' },\r
2714        credentials: 'same-origin'\r
2715      }).then(r2 => r2.json()).then(d2 => {\r
2716        if (d2 && d2.authenticated && d2.user) {\r
2717          window.auth = { user: d2.user };\r
2718          insertBefore(el, anchorItem);\r
2719        } else {\r
2720          showWallOtpModal(() => {\r
2721            insertBefore(el, anchorItem);\r
2722          });\r
2723        }\r
2724      }).catch(() => {\r
2725        showWallOtpModal(() => {\r
2726          insertBefore(el, anchorItem);\r
2727        });\r
2728      });\r
2729    });\r
2730  }\r
2731\r
2732  function insertBefore(el,anchorItem){\r
2733    insertDialog(true,o=>{\r
2734      const zone=anchorItem.zone||'b',anchor=rawHash(anchorItem._raw);\r
2735      const targetWallId = wallId || (typeof WALL_ID !== 'undefined' ? WALL_ID : 'default');\r
2736      const userId = (window.auth && window.auth.user) ? window.auth.user.id : null;\r
2737\r
2738      const isOwner = (typeof window !== 'undefined' && window.isOwner);\r
2739      const showCardNow = (c) => {\r
2740        if(!addServerCard(c)){\r
2741          const isApproved = !!c.ok && c.status !== 'pending';\r
2742          o.guest = !isOwner;\r
2743          o.zone = zone;\r
2744          o.cid = c.cid;\r
2745          o.ok = isApproved;\r
2746          o.status = c.status || (isApproved ? 'approved' : 'pending');\r
2747          o.user_id = userId;\r
2748          const at=items.indexOf(anchorItem);\r
2749          items.splice(at<0?items.length:at,0,o);\r
2750          orig.set(o._id,{w:o.w,h:o.h,span:o.span,rh:o.rh,i:at<0?items.length:at});\r
2751          byId.set(o._id,o);\r
2752        }\r
2753        remountB();pack();fxShow(fxAvailable(items));\r
2754      };\r
2755\r
2756      return syncAdd(targetWallId,{raw:o._raw,anchor,zone,wall_id:targetWallId,user_id:userId}).then(r=>{\r
2757        if(r.status===413)return 'insBig';\r
2758        const cardObj = (r.ok&&r.j&&r.j.card) ? r.j.card : {\r
2759          cid: 'c_' + Date.now().toString(36),\r
2760          raw: o._raw,\r
2761          anchor,\r
2762          zone,\r
2763          ok: isOwner ? true : false,\r
2764          status: isOwner ? 'approved' : 'pending',\r
2765          user_id: userId,\r
2766          at: Date.now()\r
2767        };\r
2768        showCardNow(cardObj);\r
2769        return true;\r
2770      }).catch(()=>{\r
2771        const fallbackCard = {\r
2772          cid: 'c_' + Date.now().toString(36),\r
2773          raw: o._raw,\r
2774          anchor,\r
2775          zone,\r
2776          ok: isOwner ? true : false,\r
2777          status: isOwner ? 'approved' : 'pending',\r
2778          user_id: userId,\r
2779          at: Date.now()\r
2780        };\r
2781        showCardNow(fallbackCard);\r
2782        return true;\r
2783      });\r
2784    });\r
2785  }\r
2786  function removeCard(o){\r
2787    if(SYNC&&o.cid){\r
2788      syncDrop(wallId,o.cid).then(r=>{\r
2789        if(r.ok&&dropServerCard(o.cid)){remountB();pack();fxShow(fxAvailable(items));}\r
2790      }).catch(err=>{\r
2791        console.warn('syncDrop err',err);\r
2792        dropLocalCard(o);\r
2793      });\r
2794      return;\r
2795    }\r
2796    dropLocalCard(o);\r
2797  }\r
2798  function removeGuest(o){\r
2799    removeCard(o);\r
2800  }\r
2801  function dropLocalCard(o){\r
2802    const at=items.indexOf(o);if(at>=0)items.splice(at,1);\r
2803    byId.delete(o._id);orig.delete(o._id);\r
2804    const k=adds.findIndex(a=>a.raw===o._raw);if(k>=0){adds.splice(k,1);saveAdds();}\r
2805    const el=document.querySelector('.item[data-id="'+o._id+'"]');if(el)dropCard(el);\r
2806    ['a-','c-'].forEach(p=>{const zel=document.querySelector('.item[data-id="'+p+o._id+'"]');if(zel)dropCard(zel);});\r
2807    remountB();pack();fxShow(fxAvailable(items));\r
2808    if(!items.length){\r
2809      const wallEl=document.getElementById('wall');\r
2810      if(wallEl){\r
2811        const emp=document.createElement('div');\r
2812        emp.className='empty';\r
2813        wallEl.replaceChildren(emp);\r
2814      }\r
2815    }\r
2816    try{\r
2817      const wd=document.getElementById('wall-data');\r
2818      if(wd){\r
2819        const parsed=JSON.parse(wd.textContent||'{}');\r
2820        if(Array.isArray(parsed.list)){\r
2821          parsed.list=items.map(exportItem);\r
2822          parsed.count=items.length;\r
2823          wd.textContent=JSON.stringify(parsed);\r
2824        }\r
2825      }\r
2826    }catch(e){}\r
2827    if(window.parent&&window.parent!==window){\r
2828      try{\r
2829        window.parent.postMessage({__ezsheetCardDeleted:true, id:o._id, cid:o.cid, raw:o._raw},'*');\r
2830      }catch(e){}\r
2831    }\r
2832  }\r
2833  /* ---- 伺服器同步:有設 setWallSync() 才啟用 ---- */\r
2834  const wallId=String(d.id||'')||'default';\r
2835  const byCid=new Map();
2835                       /* 伺服器卡片 id -> 卡片物件 */\r
2836  function addServerCard(c){\r
2837    if(!c||!c.cid||byCid.has(c.cid))return false;\r
2838    const o=parseOne(c.raw);if(!o)return false;\r
2839    o.guest=true;o.ok=!!c.ok;o.cid=c.cid;o.at=c.at||Date.now();\r
2840    placeGuest(o,c.anchor,c.zone);\r
2841    byCid.set(c.cid,o);\r
2842    orig.set(o._id,{w:o.w,h:o.h,span:o.span,rh:o.rh,i:items.indexOf(o)});\r
2843    byId.set(o._id,o);\r
2844    return true;\r
2845  }\r
2846  function promoteServerCard(cid){\r
2847    const o=byCid.get(cid);if(!o||o.ok)return false;\r
2848    markApproved(o);return true;\r
2849  }\r
2850  function dropServerCard(cid){\r
2851    const o=byCid.get(cid);if(!o)return false;\r
2852    byCid.delete(cid);\r
2853    const at=items.indexOf(o);if(at>=0)items.splice(at,1);\r
2854    byId.delete(o._id);orig.delete(o._id);\r
2855    const el=document.querySelector('.item[data-id="'+o._id+'"]');if(el)dropCard(el);\r
2856    return true;\r
2857  }\r
2858  function syncPaint(state){\r
2859    const dot=document.getElementById('syncDot');if(!dot)return;\r
2860    dot.hidden=!SYNC;\r
2861    dot.classList.toggle('on',state==='up');\r
2862    dot.classList.toggle('off',state!=='up');\r
2863    dot.title=t(state==='up'?'syncOn':'syncOff');\r
2864  }\r
2865  if(SYNC){\r
2866    /* 伺服器是這面牆的訪客卡片來源,本機那份就不再套用,免得重複 */\r
2867    adds.length=0;\r
2868    syncStream(wallId,(kind,data)=>{\r
2869      if(kind==='up'||kind==='down'){syncPaint(kind);return;}\r
2870      let touched=false;\r
2871      if(kind==='sync'){\r
2872        const seen=new Set((data.cards||[]).map(c=>c.cid));\r
2873        [...byCid.keys()].forEach(cid=>{if(!seen.has(cid))touched=dropServerCard(cid)||touched;});\r
2874        (data.cards||[]).forEach(c=>{touched=addServerCard(c)||touched;if(c.ok)promoteServerCard(c.cid);});\r
2875      }\r
2876      else if(kind==='promote'){promoteServerCard(data.cid);return;}\r
2877      else if(kind==='card')touched=addServerCard(data);\r
2878      else if(kind==='drop')touched=dropServerCard(data.cid);\r
2879      if(touched){remountB();pack();fxShow(fxAvailable(items));}\r
2880    });\r
2881    syncPaint('down');\r
2882    /* 版主輸入金鑰或已登入之後才看得到待審列表 */\r
2883    const rb=document.getElementById('revBtn');\r
2884    if(rb){\r
2885      const showRev=()=>{\r
2886        const isOw = (typeof window !== 'undefined' && window.isOwner === true) || !!ownerToken();\r
2887        rb.hidden = !isOw;\r
2888      };\r
2889      showRev();\r
2890      rb.addEventListener('click',()=>reviewOpen(wallId,cid=>{\r
2891        if(dropServerCard(cid)){remountB();pack();fxShow(fxAvailable(items));}\r
2892      },promoteServerCard));\r
2893      /* 版主用 ?owner=… 進來一次,金鑰就記在這台瀏覽器裡 */\r
2894      try{\r
2895        const q=new URLSearchParams(location.search).get('owner');\r
2896        if(q){setOwnerToken(q);showRev();\r
2897          history.replaceState(null,'',location.pathname+location.hash);}\r
2898      }catch(e){}\r
2899      /* 長按牆名可以輸入或清掉金鑰 */\r
2900      const fab=document.querySelector('.fab.badge');\r
2901      if(fab){\r
2902        let hold=0;\r
2903        const ask=()=>{\r
2904          const v=prompt(t('revAsk'),ownerToken());\r
2905          if(v===null)return;\r
2906          setOwnerToken(v.trim());showRev();\r
2907        };\r
2908        fab.addEventListener('pointerdown',()=>{hold=setTimeout(ask,700);});\r
2909        ['pointerup','pointerleave','pointercancel'].forEach(k=>fab.addEventListener(k,()=>clearTimeout(hold)));\r
2910      }\r
2911    }\r
2912  }\r
2913  ['wall','zoneA','zoneC'].forEach(cid=>{\r
2914    const host=document.getElementById(cid);if(!host)return;\r
2915    host.addEventListener('click',e=>{\r
2916      const b=e.target.closest('[data-act]');if(!b)return;\r
2917      const el=b.closest('.item');if(!el)return;\r
2918      /* A/C 區的卡片 id 前面多了 a-/c- */\r
2919      const o=byId.get(String(el.dataset.id).replace(/^[ac]-/,''));if(!o)return;\r
2920      if(b.dataset.act==='ins'){e.preventDefault();checkAuthThenInsert(el,o);}\r
2921      else if(b.dataset.act==='gdel'||b.dataset.act==='del'){\r
2922        const isOw = (typeof window !== 'undefined' && window.isOwner === true) || !!(typeof ownerToken === 'function' && ownerToken());\r
2923        if(!isOw){\r
2924          e.preventDefault();\r
2925          console.warn('Only the owner of this wall can delete cards');\r
2926          return;\r
2927        }\r
2928        e.preventDefault();\r
2929        removeCard(o);\r
2930      }\r
2931    });\r
2932  });\r
2933  /* 伺服器端的嵌入檢查:有些網站肯讓你嵌,卻回一張機器人驗證或登入牆,\r
2934     瀏覽器看不出來,只有伺服器能分辨。擋下來的換成墓碑卡+開新分頁連結。 */\r
2935  checkFrames(items,o=>{\r
2936    const el=document.querySelector('.item[data-id="'+o._id+'"]');\r
2937    if(el)dropCard(el);\r
2938    remountB();pack();\r
2939  });\r
2940  watchWidth(wall,pack);\r
2941}\r
2942\r
2943window.WallCore={STD_W,STD_H,GRID,MIN,YT,esc,httpUrl,normalize,makeCard,renderAll,applySize,watchWidth,validCols,bootReadonly,layoutWall,fitH,onMeasure,fitOf,isTomb,setFrameCheck,checkFrames,dropCard,carouselBtnHTML,setCarousel,carSync,\r
2944  VERSION,verBadge,parseOne,isMarkdown,isHtml,htmlDoc,autoCap,foldSync,spriteStrip,validSprites,spriteSrc,SPRITE_DEF,SPRITE_MAX,fxPaint,soloIframe,cornerHTML,markApproved,mdRender,mdDoc,mdInner,mdTag,MD_RE,MD_MAX,rawHash,insertDialog,resizeStart,setWallSync,wallMe,setOwnerToken,ownerToken,syncBtnHTML,syncDropAll,reviewOpen,modelDoc,modelTag,parseModelTag,isModelFile,modelExt,M3D_EXT,M3D_OK,MODEL_W,MODEL_H,ZONES,ZNAME,ZORDERS,validOrder,applyZoneOrder,orderLabel,zoneBtnHTML,zonePaint,zoneCounts,bindZones,validZones,FDEF,FILTER_MIN,applyView,zoneAInit,zoneAUpdate,zoneCInit,zoneCUpdate,introFX,playFX,fxInit,fxSet,fxSetFw,fxSetFly,fxState,fxDefaults,fxShow,fxAvailable,isMediaCard,sndSet,fxBtnHTML,fwBtnHTML,flyBtnHTML,sndBtnHTML,fireworks,flyBees,create3DBee,filterBtnHTML,filterBarHTML,bindFilter,setMetaFetch,fetchMeta,parseDur,fmtDur,\r
2945  I18N,t,colsText,setLangCode,getLang,applyI18n,langSelectHTML,menuHTML,updateLayoutUI,bindMenu,randomSize,\r
2946  shuffled,shuffleBtnHTML,reorderAnimated};\r
2947})();\r
2948`,si=`/*!
2949 * Zdog v1.1.3
2950 * Round, flat, designer-friendly pseudo-3D engine
2951 * Licensed MIT
2952 * https://zzz.dog
2953 * Copyright 2020 Metafizzy
2954 */
2955(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e()}else{t.Zdog=e()}})(this,function t(){var e={};e.TAU=Math.PI*2;e.extend=function(t,e){for(var r in e){t[r]=e[r]}return t};e.lerp=function(t,e,r){return(e-t)*r+t};e.modulo=function(t,e){return(t%e+e)%e};var s={2:function(t){return t*t},3:function(t){return t*t*t},4:function(t){return t*t*t*t},5:function(t){return t*t*t*t*t}};e.easeInOut=function(t,e){if(e==1){return t}t=Math.max(0,Math.min(1,t));var r=t<.5;var i=r?t:1-t;i/=.5;var n=s[e]||s[2];var o=n(i);o/=2;return r?o:1-o};return e});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e()}else{t.Zdog.CanvasRenderer=e()}})(this,function t(){var n={isCanvas:true};n.begin=function(t){t.beginPath()};n.move=function(t,e,r){t.moveTo(r.x,r.y)};n.line=function(t,e,r){t.lineTo(r.x,r.y)};n.bezier=function(t,e,r,i,n){t.bezierCurveTo(r.x,r.y,i.x,i.y,n.x,n.y)};n.closePath=function(t){t.closePath()};n.setPath=function(){};n.renderPath=function(e,r,t,i){this.begin(e,r);t.forEach(function(t){t.render(e,r,n)});if(i){this.closePath(e,r)}};n.stroke=function(t,e,r,i,n){if(!r){return}t.strokeStyle=i;t.lineWidth=n;t.stroke()};n.fill=function(t,e,r,i){if(!r){return}t.fillStyle=i;t.fill()};n.end=function(){};return n});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e()}else{t.Zdog.SvgRenderer=e()}})(this,function t(){var o={isSvg:true};var e=o.round=function(t){return Math.round(t*1e3)/1e3};function s(t){return e(t.x)+","+e(t.y)+" "}o.begin=function(){};o.move=function(t,e,r){return"M"+s(r)}
2955;o.line=function(t,e,r){return"L"+s(r)};o.bezier=function(t,e,r,i,n){return"C"+s(r)+s(i)+s(n)};o.closePath=function(){return"Z"};o.setPath=function(t,e,r){e.setAttribute("d",r)};o.renderPath=function(e,r,t,i){var n="";t.forEach(function(t){n+=t.render(e,r,o)});if(i){n+=this.closePath(e,r)}this.setPath(e,r,n)};o.stroke=function(t,e,r,i,n){if(!r){return}e.setAttribute("stroke",i);e.setAttribute("stroke-width",n)};o.fill=function(t,e,r,i){var n=r?i:"none";e.setAttribute("fill",n)};o.end=function(t,e){t.appendChild(e)};return o});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"))}else{var r=t.Zdog;r.Vector=e(r)}})(this,function t(r){function e(t){this.set(t)}var h=r.TAU;e.prototype.set=function(t){this.x=t&&t.x||0;this.y=t&&t.y||0;this.z=t&&t.z||0;return this};e.prototype.write=function(t){if(!t){return this}this.x=t.x!=undefined?t.x:this.x;this.y=t.y!=undefined?t.y:this.y;this.z=t.z!=undefined?t.z:this.z;return this};e.prototype.rotate=function(t){if(!t){return}this.rotateZ(t.z);
2955this.rotateY(t.y);this.rotateX(t.x);return this};e.prototype.rotateZ=function(t){i(this,t,"x","y")};e.prototype.rotateX=function(t){i(this,t,"y","z")};e.prototype.rotateY=function(t){i(this,t,"x","z")};function i(t,e,r,i){if(!e||e%h===0){return}var n=Math.cos(e);var o=Math.sin(e);var s=t[r];var a=t[i];t[r]=s*n-a*o;t[i]=a*n+s*o}e.prototype.isSame=function(t){if(!t){return false}return this.x===t.x&&this.y===t.y&&this.z===t.z};e.prototype.add=function(t){if(!t){return this}this.x+=t.x||0;this.y+=t.y||0;this.z+=t.z||0;return this};e.prototype.subtract=function(t){if(!t){return this}this.x-=t.x||0;this.y-=t.y||0;this.z-=t.z||0;return this};e.prototype.multiply=function(t){if(t==undefined){return this}if(typeof t=="number"){this.x*=t;this.y*=t;this.z*=t}else{this.x*=t.x!=undefined?t.x:1;this.y*=t.y!=undefined?t.y:1;this.z*=t.z!=undefined?t.z:1}return this};e.prototype.transform=function(t,e,r){this.multiply(r);this.rotate(e);this.add(t);return this};e.prototype.lerp=function(t,e){this.x=r.lerp(this.x,t.x||0,e);this.y=r.lerp(this.y,t.y||0,e);this.z=r.lerp(this.z,t.z||0,e);return this};e.prototype.magnitude=function(){var t=this.x*this.x+this.y*this.y+this.z*this.z;return n(t)};function n(t){if(Math.abs(t-1)<1e-8){return 1}return Math.sqrt(t)}e.prototype.magnitude2d=function(){var t=this.x*this.x+this.y*this.y;return n(t)};e.prototype.copy=function(){return new e(this)};return e});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./vector"),require("./canvas-renderer"),require("./svg-renderer"))}else{var r=t.Zdog;r.Anchor=e(r,r.Vector,r.CanvasRenderer,r.SvgRenderer)}})(this,function t(n,e,r,i){var o=n.TAU;var s={x:1,y:1,z:1};function a(t){this.create(t||{})}a.prototype.create=function(t){this.children=[];n.extend(this,this.constructor.defaults);this.setOptions(t);this.translate=new e(t.translate);this.rotate=new e(t.rotate);this.scale=new e(s).multiply(this.scale);this.origin=new e;this.renderOrigin=new e;if(this.addTo){this.addTo.addChild(this)}};a.defaults={};a.optionKeys=Object.keys(a.defaults).concat(["rotate","translate","scale","addTo"]);a.prototype.setOptions=function(t){var e=this.constructor.optionKeys;for(var r in t){if(e.indexOf(r)!=-1){this[r]=t[r]}}};a.prototype.addChild=function(t){if(this.children.indexOf(t)!=-1){return}t.remove();t.addTo=this;this.children.push(t)};a.prototype.removeChild=function(t){var e=this.children.indexOf(t);if(e!=-1){this.children.splice(e,1)}};a.prototype.remove=function(){if(this.addTo){this.addTo.removeChild(this)}};a.prototype.update=function(){this.reset();this.children.forEach(function(t){t.update()});this.transform(this.translate,this.rotate,this.scale)};a.prototype.reset=function(){this.renderOrigin.set(this.origin)};a.prototype.transform=function(e,r,i){this.renderOrigin.transform(e,r,i);this.children.forEach(function(t){t.transform(e,r,i)})};a.prototype.updateGraph=function(){this.update();this.updateFlatGraph();this.flatGraph.forEach(function(t){t.updateSortValue()});this.flatGraph.sort(a.shapeSorter)};a.shapeSorter=function(t,e){return t.sortValue-e.sortValue};Object.defineProperty(a.prototype,"flatGraph",{get:function(){if(!this._flatGraph){this.updateFlatGraph()}return this._flatGraph},set:function(t){this._flatGraph=t}});a.prototype.updateFlatGraph=function(){this.flatGraph=this.getFlatGraph()};a.prototype.getFlatGraph=function(){var t=[this];return this.addChildFlatGraph(t)};a.prototype.addChildFlatGraph=function(r){this.children.forEach(function(t){var e=t.getFlatGraph();Array.prototype.push.apply(r,e)});return r};a.prototype.updateSortValue=function(){this.sortValue=this.renderOrigin.z};a.prototype.render=function(){};a.prototype.renderGraphCanvas=function(e){if(!e){throw new Error("ctx is "+e+". "+"Canvas context required for render. Check .renderGraphCanvas( ctx ).")}this.flatGraph.forEach(function(t){t.render(e,r)})};a.prototype.renderGraphSvg=function(e){if(!e){throw new Error("svg is "+e+". "+"SVG required for render. Check .renderGraphSvg( svg ).")}this.flatGraph.forEach(function(t){t.render(e,i)})};a.prototype.copy=function(t){var e={};var r=this.constructor.optionKeys;r.forEach(function(t){e[t]=this[t]},this);n.extend(e,t);var i=this.constructor;return new i(e)};a.prototype.copyGraph=function(t){var e=this.copy(t);
2955this.children.forEach(function(t){t.copyGraph({addTo:e})});return e};a.prototype.normalizeRotate=function(){this.rotate.x=n.modulo(this.rotate.x,o);this.rotate.y=n.modulo(this.rotate.y,o);this.rotate.z=n.modulo(this.rotate.z,o)};function h(r){return function(t){function e(t){this.create(t||{})}e.prototype=Object.create(r.prototype);e.prototype.constructor=e;e.defaults=n.extend({},r.defaults);n.extend(e.defaults,t);e.optionKeys=r.optionKeys.slice(0);Object.keys(e.defaults).forEach(function(t){if(!e.optionKeys.indexOf(t)!=1){e.optionKeys.push(t)}});e.subclass=h(e);return e}}a.subclass=h(a);return a});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e()}else{t.Zdog.Dragger=e()}})(this,function t(){var r=typeof window!="undefined";var e="mousedown";var i="mousemove";var n="mouseup";if(r){if(window.PointerEvent){e="pointerdown";i="pointermove";n="pointerup"}else if("ontouchstart"in window){e="touchstart";i="touchmove";n="touchend"}}function o(){}function s(t){this.create(t||{})}s.prototype.create=function(t){this.onDragStart=t.onDragStart||o;this.onDragMove=t.onDragMove||o;this.onDragEnd=t.onDragEnd||o;this.bindDrag(t.startElement)};s.prototype.bindDrag=function(t){t=this.getQueryElement(t);if(!t){return}t.style.touchAction="none";t.addEventListener(e,this)};s.prototype.getQueryElement=function(t){if(typeof t=="string"){t=document.querySelector(t)}return t};s.prototype.handleEvent=function(t){var e=this["on"+t.type];if(e){e.call(this,t)}};s.prototype.onmousedown=s.prototype.onpointerdown=function(t){this.dragStart(t,t)};s.prototype.ontouchstart=function(t){this.dragStart(t,t.changedTouches[0])};s.prototype.dragStart=function(t,e){t.preventDefault();this.dragStartX=e.pageX;this.dragStartY=e.pageY;if(r){window.addEventListener(i,this);window.addEventListener(n,this)}this.onDragStart(e)};s.prototype.ontouchmove=function(t){this.dragMove(t,t.changedTouches[0])};s.prototype.onmousemove=s.prototype.onpointermove=function(t){this.dragMove(t,t)};s.prototype.dragMove=function(t,e){t.preventDefault();var r=e.pageX-this.dragStartX;var i=e.pageY-this.dragStartY;this.onDragMove(e,r,i)};s.prototype.onmouseup=s.prototype.onpointerup=s.prototype.ontouchend=s.prototype.dragEnd=function(){window.removeEventListener(i,this);window.removeEventListener(n,this);this.onDragEnd()};return s});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./anchor"),require("./dragger"))}else{var r=t.Zdog;r.Illustration=e(r,r.Anchor,r.Dragger)}})(this,function t(e,r,a){function i(){}var h=e.TAU;var n=r.subclass({element:undefined,centered:true,zoom:1,dragRotate:false,resize:false,onPrerender:i,onDragStart:i,onDragMove:i,onDragEnd:i,onResize:i});e.extend(n.prototype,a.prototype);n.prototype.create=function(t){r.prototype.create.call(this,t);a.prototype.create.call(this,t);this.setElement(this.element);this.setDragRotate(this.dragRotate);this.setResize(this.resize)};n.prototype.setElement=function(t){t=this.getQueryElement(t);if(!t){throw new Error("Zdog.Illustration element required. Set to "+t)}var e=t.nodeName.toLowerCase();if(e=="canvas"){this.setCanvas(t)}else if(e=="svg"){this.setSvg(t)}};n.prototype.setSize=function(t,e){t=Math.round(t);e=Math.round(e);if(this.isCanvas){this.setSizeCanvas(t,e)}else if(this.isSvg){this.setSizeSvg(t,e)}};n.prototype.setResize=function(t){this.resize=t;if(!this.resizeListener){this.resizeListener=this.onWindowResize.bind(this)}if(t){window.addEventListener("resize",this.resizeListener);this.onWindowResize()}else{window.removeEventListener("resize",this.resizeListener)}};n.prototype.onWindowResize=function(){this.setMeasuredSize();this.onResize(this.width,this.height)};n.prototype.setMeasuredSize=function(){var t,e;var r=this.resize=="fullscreen";if(r){t=window.innerWidth;e=window.innerHeight}else{var i=this.element.getBoundingClientRect();t=i.width;e=i.height}this.setSize(t,e)};n.prototype.renderGraph=function(t){if(this.isCanvas){this.renderGraphCanvas(t)}else if(this.isSvg){this.renderGraphSvg(t)}};n.prototype.updateRenderGraph=function(t){this.updateGraph();this.renderGraph(t)};n.prototype.setCanvas=function(t){this.element=t;this.isCanvas=true;this.ctx=this.element.getContext("2d");this.setSizeCanvas(t.width,t.height)};n.prototype.setSizeCanvas=function(t,e){this.width=t;this.height=e;var r=this.pixelRatio=window.devicePixelRatio||1;this.element.width=this.canvasWidth=t*r;this.element.height=this.canvasHeight=e*r;var i=r>1&&!this.resize;if(i){this.element.style.width=t+"px";this.element.style.height=e+"px"}};n.prototype.renderGraphCanvas=function(t){t=t||this;this.prerenderCanvas();r.prototype.renderGraphCanvas.call(t,this.ctx);this.postrenderCanvas()};n.prototype.prerenderCanvas=function(){var t=this.ctx;t.lineCap="round";t.lineJoin="round";t.clearRect(0,0,this.canvasWidth,this.canvasHeight);t.save();if(this.centered){var e=this.width/2*this.pixelRatio;var r=this.height/2*this.pixelRatio;t.translate(e,r)}var i=this.pixelRatio*this.zoom;t.scale(i,i);this.onPrerender(t)};
2955n.prototype.postrenderCanvas=function(){this.ctx.restore()};n.prototype.setSvg=function(t){this.element=t;this.isSvg=true;this.pixelRatio=1;var e=t.getAttribute("width");var r=t.getAttribute("height");this.setSizeSvg(e,r)};n.prototype.setSizeSvg=function(t,e){this.width=t;this.height=e;var r=t/this.zoom;var i=e/this.zoom;var n=this.centered?-r/2:0;var o=this.centered?-i/2:0;this.element.setAttribute("viewBox",n+" "+o+" "+r+" "+i);if(this.resize){this.element.removeAttribute("width");this.element.removeAttribute("height")}else{this.element.setAttribute("width",t);this.element.setAttribute("height",e)}};n.prototype.renderGraphSvg=function(t){t=t||this;o(this.element);this.onPrerender(this.element);r.prototype.renderGraphSvg.call(t,this.element)};function o(t){while(t.firstChild){t.removeChild(t.firstChild)}}n.prototype.setDragRotate=function(t){if(!t){return}else if(t===true){t=this}this.dragRotate=t;this.bindDrag(this.element)};n.prototype.dragStart=function(){this.dragStartRX=this.dragRotate.rotate.x;this.dragStartRY=this.dragRotate.rotate.y;a.prototype.dragStart.apply(this,arguments)};n.prototype.dragMove=function(t,e){var r=e.pageX-this.dragStartX;var i=e.pageY-this.dragStartY;var n=Math.min(this.width,this.height);var o=r/n*h;var s=i/n*h;this.dragRotate.rotate.x=this.dragStartRX-s;this.dragRotate.rotate.y=this.dragStartRY-o;a.prototype.dragMove.apply(this,arguments)};return n});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./vector"))}else{var r=t.Zdog;r.PathCommand=e(r.Vector)}})(this,function t(i){function e(t,e,r){this.method=t;this.points=e.map(n);this.renderPoints=e.map(o);this.previousPoint=r;this.endRenderPoint=this.renderPoints[this.renderPoints.length-1];if(t=="arc"){this.controlPoints=[new i,new i]}}function n(t){if(t instanceof i){return t}else{return new i(t)}}function o(t){return new i(t)}e.prototype.reset=function(){var i=this.points;this.renderPoints.forEach(function(t,e){var r=i[e];t.set(r)})};e.prototype.transform=function(e,r,i){this.renderPoints.forEach(function(t){t.transform(e,r,i)})};e.prototype.render=function(t,e,r){return this[this.method](t,e,r)};e.prototype.move=function(t,e,r){return r.move(t,e,this.renderPoints[0])};e.prototype.line=function(t,e,r){return r.line(t,e,this.renderPoints[0])};e.prototype.bezier=function(t,e,r){var i=this.renderPoints[0];var n=this.renderPoints[1];var o=this.renderPoints[2];return r.bezier(t,e,i,n,o)};var h=9/16;e.prototype.arc=function(t,e,r){var i=this.previousPoint;var n=this.renderPoints[0];var o=this.renderPoints[1];var s=this.controlPoints[0];var a=this.controlPoints[1];s.set(i).lerp(n,h);a.set(o).lerp(n,h);return r.bezier(t,e,s,a,o)};return e});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./vector"),require("./path-command"),require("./anchor"))}else{var r=t.Zdog;r.Shape=e(r,r.Vector,r.PathCommand,r.Anchor)}})(this,function t(e,r,p,i){var n=i.subclass({stroke:1,fill:false,color:"#333",closed:true,visible:true,path:[{}],front:{z:1},backface:true});n.prototype.create=function(t){i.prototype.create.call(this,t);this.updatePath();this.front=new r(t.front||this.front);this.renderFront=new r(this.front);this.renderNormal=new r};var d=["move","line","bezier","arc"];n.prototype.updatePath=function(){this.setPath();this.updatePathCommands()};n.prototype.setPath=function(){};n.prototype.updatePathCommands=function(){var u;this.pathCommands=this.path.map(function(t,e){var r=Object.keys(t);var i=r[0];var n=t[i];var o=r.length==1&&d.indexOf(i)!=-1;if(!o){i="line";n=t}var s=i=="line"||i=="move";var a=Array.isArray(n);if(s&&!a){n=[n]}i=e===0?"move":i;var h=new p(i,n,u);u=h.endRenderPoint;return h})};n.prototype.reset=function(){this.renderOrigin.set(this.origin);this.renderFront.set(this.front);this.pathCommands.forEach(function(t){t.reset()})};n.prototype.transform=function(e,r,i){this.renderOrigin.transform(e,r,i);this.renderFront.transform(e,r,i);this.renderNormal.set(this.renderOrigin).subtract(this.renderFront);this.pathCommands.forEach(function(t){t.transform(e,r,i)});
2955this.children.forEach(function(t){t.transform(e,r,i)})};n.prototype.updateSortValue=function(){var t=this.pathCommands.length;var e=this.pathCommands[0].endRenderPoint;var r=this.pathCommands[t-1].endRenderPoint;var i=t>2&&e.isSame(r);if(i){t-=1}var n=0;for(var o=0;o<t;o++){n+=this.pathCommands[o].endRenderPoint.z}this.sortValue=n/t};n.prototype.render=function(t,e){var r=this.pathCommands.length;if(!this.visible||!r){return}this.isFacingBack=this.renderNormal.z>0;if(!this.backface&&this.isFacingBack){return}if(!e){throw new Error("Zdog renderer required. Set to "+e)}var i=r==1;if(e.isCanvas&&i){this.renderCanvasDot(t,e)}else{this.renderPath(t,e)}};var o=e.TAU;n.prototype.renderCanvasDot=function(t){var e=this.getLineWidth();if(!e){return}t.fillStyle=this.getRenderColor();var r=this.pathCommands[0].endRenderPoint;t.beginPath();var i=e/2;t.arc(r.x,r.y,i,0,o);t.fill()};n.prototype.getLineWidth=function(){if(!this.stroke){return 0}if(this.stroke==true){return 1}return this.stroke};n.prototype.getRenderColor=function(){var t=typeof this.backface=="string"&&this.isFacingBack;var e=t?this.backface:this.color;return e};n.prototype.renderPath=function(t,e){var r=this.getRenderElement(t,e);var i=this.pathCommands.length==2&&this.pathCommands[1].method=="line";var n=!i&&this.closed;var o=this.getRenderColor();e.renderPath(t,r,this.pathCommands,n);e.stroke(t,r,this.stroke,o,this.getLineWidth());e.fill(t,r,this.fill,o);e.end(t,r)};var s="http://www.w3.org/2000/svg";n.prototype.getRenderElement=function(t,e){if(!e.isSvg){return}if(!this.svgElement){this.svgElement=document.createElementNS(s,"path");this.svgElement.setAttribute("stroke-linecap","round");this.svgElement.setAttribute("stroke-linejoin","round")}return this.svgElement};return n});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./anchor"))}else{var r=t.Zdog;r.Group=e(r.Anchor)}})(this,function t(r){var e=r.subclass({updateSort:false,visible:true});e.prototype.updateSortValue=function(){var e=0;this.flatGraph.forEach(function(t){t.updateSortValue();e+=t.sortValue});this.sortValue=e/this.flatGraph.length;if(this.updateSort){this.flatGraph.sort(r.shapeSorter)}};e.prototype.render=function(e,r){if(!this.visible){return}this.flatGraph.forEach(function(t){t.render(e,r)})};e.prototype.updateFlatGraph=function(){var t=[];this.flatGraph=this.addChildFlatGraph(t)};e.prototype.getFlatGraph=function(){return[this]};return e});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./shape"))}else{var r=t.Zdog;r.Rect=e(r.Shape)}})(this,function t(e){var r=e.subclass({width:1,height:1});r.prototype.setPath=function(){var t=this.width/2;var e=this.height/2;this.path=[{x:-t,y:-e},{x:t,y:-e},{x:t,y:e},{x:-t,y:e}]};return r});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./shape"))}else{var r=t.Zdog;r.RoundedRect=e(r.Shape)}})(this,function t(e){var r=e.subclass({width:1,height:1,cornerRadius:.25,closed:false});r.prototype.setPath=function(){var t=this.width/2;var e=this.height/2;var r=Math.min(t,e);var i=Math.min(this.cornerRadius,r);var n=t-i;var o=e-i;var s=[{x:n,y:-e},{arc:[{x:t,y:-e},{x:t,y:-o}]}];if(o){s.push({x:t,y:o})}s.push({arc:[{x:t,y:e},{x:n,y:e}]});if(n){s.push({x:-n,y:e})}s.push({arc:[{x:-t,y:e},{x:-t,y:o}]});if(o){s.push({x:-t,y:-o})}s.push({arc:[{x:-t,y:-e},{x:-n,y:-e}]});if(n){s.push({x:n,y:-e})}this.path=s};return r});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./shape"))}else{var r=t.Zdog;r.Ellipse=e(r.Shape)}})(this,function t(e){var r=e.subclass({diameter:1,width:undefined,height:undefined,quarters:4,closed:false});r.prototype.setPath=function(){var t=this.width!=undefined?this.width:this.diameter;var e=this.height!=undefined?this.height:this.diameter;var r=t/2;var i=e/2;this.path=[{x:0,y:-i},{arc:[{x:r,y:-i},{x:r,y:0}]}];if(this.quarters>1){this.path.push({arc:[{x:r,y:i},{x:0,y:i}]})}if(this.quarters>2){this.path.push({arc:[{x:-r,y:i},{x:-r,y:0}]})}if(this.quarters>3){this.path.push({arc:[{x:-r,y:-i},{x:0,y:-i}]})}};return r});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./shape"))}else{var r=t.Zdog;r.Polygon=e(r,r.Shape)}}
2955)(this,function t(e,r){var i=r.subclass({sides:3,radius:.5});var n=e.TAU;i.prototype.setPath=function(){this.path=[];for(var t=0;t<this.sides;t++){var e=t/this.sides*n-n/4;var r=Math.cos(e)*this.radius;var i=Math.sin(e)*this.radius;this.path.push({x:r,y:i})}};return i});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./vector"),require("./anchor"),require("./ellipse"))}else{var r=t.Zdog;r.Hemisphere=e(r,r.Vector,r.Anchor,r.Ellipse)}})(this,function t(e,r,i,n){var o=n.subclass({fill:true});var u=e.TAU;o.prototype.create=function(){n.prototype.create.apply(this,arguments);this.apex=new i({addTo:this,translate:{z:this.diameter/2}});this.renderCentroid=new r};o.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,3/8);this.sortValue=this.renderCentroid.z};o.prototype.render=function(t,e){this.renderDome(t,e);n.prototype.render.apply(this,arguments)};o.prototype.renderDome=function(t,e){if(!this.visible){return}var r=this.getDomeRenderElement(t,e);var i=Math.atan2(this.renderNormal.y,this.renderNormal.x);var n=this.diameter/2*this.renderNormal.magnitude();var o=this.renderOrigin.x;var s=this.renderOrigin.y;if(e.isCanvas){var a=i+u/4;var h=i-u/4;t.beginPath();t.arc(o,s,n,a,h)}else if(e.isSvg){i=(i-u/4)/u*360;this.domeSvgElement.setAttribute("d","M "+-n+",0 A "+n+","+n+" 0 0 1 "+n+",0");this.domeSvgElement.setAttribute("transform","translate("+o+","+s+" ) rotate("+i+")")}e.stroke(t,r,this.stroke,this.color,this.getLineWidth());e.fill(t,r,this.fill,this.color);e.end(t,r)};var s="http://www.w3.org/2000/svg";o.prototype.getDomeRenderElement=function(t,e){if(!e.isSvg){return}if(!this.domeSvgElement){this.domeSvgElement=document.createElementNS(s,"path");this.domeSvgElement.setAttribute("stroke-linecap","round");this.domeSvgElement.setAttribute("stroke-linejoin","round")}return this.domeSvgElement};return o});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./path-command"),require("./shape"),require("./group"),require("./ellipse"))}else{var r=t.Zdog;r.Cylinder=e(r,r.PathCommand,r.Shape,r.Group,r.Ellipse)}})(this,function t(e,r,i,n,o){function s(){}var a=n.subclass({color:"#333",updateSort:true});a.prototype.create=function(){n.prototype.create.apply(this,arguments);this.pathCommands=[new r("move",[{}]),new r("line",[{}])]};a.prototype.render=function(t,e){this.renderCylinderSurface(t,e);n.prototype.render.apply(this,arguments)};a.prototype.renderCylinderSurface=function(t,e){if(!this.visible){return}var r=this.getRenderElement(t,e);var i=this.frontBase;var n=this.rearBase;var o=i.renderNormal.magnitude();var s=i.diameter*o+i.getLineWidth();this.pathCommands[0].renderPoints[0].set(i.renderOrigin);this.pathCommands[1].renderPoints[0].set(n.renderOrigin);if(e.isCanvas){t.lineCap="butt"}e.renderPath(t,r,this.pathCommands);e.stroke(t,r,true,this.color,s);e.end(t,r);if(e.isCanvas){t.lineCap="round"}};var h="http://www.w3.org/2000/svg";a.prototype.getRenderElement=function(t,e){if(!e.isSvg){return}if(!this.svgElement){this.svgElement=document.createElementNS(h,"path")}return this.svgElement};a.prototype.copyGraph=s;var u=o.subclass();u.prototype.copyGraph=s;var p=i.subclass({diameter:1,length:1,frontFace:undefined,fill:true});var d=e.TAU;p.prototype.create=function(){i.prototype.create.apply(this,arguments);this.group=new a({addTo:this,color:this.color,visible:this.visible});var t=this.length/2;var e=this.backface||true;this.frontBase=this.group.frontBase=new o({addTo:this.group,diameter:this.diameter,translate:{z:t},rotate:{y:d/2},color:this.color,stroke:this.stroke,fill:this.fill,backface:this.frontFace||e,visible:this.visible});this.rearBase=this.group.rearBase=this.frontBase.copy({translate:{z:-t},rotate:{y:0},backface:e})};p.prototype.render=function(){};var c=["stroke","fill","color","visible"];
2955c.forEach(function(e){var r="_"+e;Object.defineProperty(p.prototype,e,{get:function(){return this[r]},set:function(t){this[r]=t;if(this.frontBase){this.frontBase[e]=t;this.rearBase[e]=t;this.group[e]=t}}})});return p});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./vector"),require("./path-command"),require("./anchor"),require("./ellipse"))}else{var r=t.Zdog;r.Cone=e(r,r.Vector,r.PathCommand,r.Anchor,r.Ellipse)}})(this,function t(e,r,i,n,o){var s=o.subclass({length:1,fill:true});var v=e.TAU;s.prototype.create=function(){o.prototype.create.apply(this,arguments);this.apex=new n({addTo:this,translate:{z:this.length}});this.renderApex=new r;this.renderCentroid=new r;this.tangentA=new r;this.tangentB=new r;this.surfacePathCommands=[new i("move",[{}]),new i("line",[{}]),new i("line",[{}])]};s.prototype.updateSortValue=function(){this.renderCentroid.set(this.renderOrigin).lerp(this.apex.renderOrigin,1/3);this.sortValue=this.renderCentroid.z};s.prototype.render=function(t,e){this.renderConeSurface(t,e);o.prototype.render.apply(this,arguments)};s.prototype.renderConeSurface=function(t,e){if(!this.visible){return}this.renderApex.set(this.apex.renderOrigin).subtract(this.renderOrigin);var r=this.renderNormal.magnitude();var i=this.renderApex.magnitude2d();var n=this.renderNormal.magnitude2d();var o=Math.acos(n/r);var s=Math.sin(o);var a=this.diameter/2*r;var h=a*s<i;if(!h){return}var u=Math.atan2(this.renderNormal.y,this.renderNormal.x)+v/2;var p=i/s;var d=Math.acos(a/p);var c=this.tangentA;var f=this.tangentB;c.x=Math.cos(d)*a*s;c.y=Math.sin(d)*a;f.set(this.tangentA);f.y*=-1;c.rotateZ(u);f.rotateZ(u);c.add(this.renderOrigin);f.add(this.renderOrigin);this.setSurfaceRenderPoint(0,c);this.setSurfaceRenderPoint(1,this.apex.renderOrigin);this.setSurfaceRenderPoint(2,f);var l=this.getSurfaceRenderElement(t,e);e.renderPath(t,l,this.surfacePathCommands);e.stroke(t,l,this.stroke,this.color,this.getLineWidth());e.fill(t,l,this.fill,this.color);e.end(t,l)};var a="http://www.w3.org/2000/svg";s.prototype.getSurfaceRenderElement=function(t,e){if(!e.isSvg){return}if(!this.surfaceSvgElement){this.surfaceSvgElement=document.createElementNS(a,"path");this.surfaceSvgElement.setAttribute("stroke-linecap","round");this.surfaceSvgElement.setAttribute("stroke-linejoin","round")}return this.surfaceSvgElement};s.prototype.setSurfaceRenderPoint=function(t,e){var r=this.surfacePathCommands[t].renderPoints[0];r.set(e)};return s});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./anchor"),require("./shape"),require("./rect"))}else{var r=t.Zdog;r.Box=e(r,r.Anchor,r.Shape,r.Rect)}})(this,function t(e,r,i,n){var o=n.subclass();o.prototype.copyGraph=function(){};var s=e.TAU;var a=["frontFace","rearFace","leftFace","rightFace","topFace","bottomFace"];var h=e.extend({},i.defaults);delete h.path;a.forEach(function(t){h[t]=true});e.extend(h,{width:1,height:1,depth:1,fill:true});var u=r.subclass(h);u.prototype.create=function(t){r.prototype.create.call(this,t);this.updatePath();this.fill=this.fill};u.prototype.updatePath=function(){a.forEach(function(t){this[t]=this[t]},this)};a.forEach(function(e){var r="_"+e;Object.defineProperty(u.prototype,e,{get:function(){return this[r]},set:function(t){this[r]=t;this.setFace(e,t)}})});u.prototype.setFace=function(t,e){var r=t+"Rect";var i=this[r];if(!e){this.removeChild(i);return}var n=this.getFaceOptions(t);n.color=typeof e=="string"?e:this.color;if(i){i.setOptions(n)}else{i=this[r]=new o(n)}i.updatePath();this.addChild(i)};u.prototype.getFaceOptions=function(t){return{frontFace:{width:this.width,height:this.height,translate:{z:this.depth/2}},rearFace:{width:this.width,height:this.height,translate:{z:-this.depth/2},rotate:{y:s/2}},leftFace:{width:this.depth,height:this.height,translate:{x:-this.width/2},rotate:{y:-s/4}},rightFace:{width:this.depth,height:this.height,translate:{x:this.width/2},rotate:{y:s/4}},topFace:{width:this.width,height:this.depth,translate:{y:-this.height/2},rotate:{x:-s/4}},bottomFace:{width:this.width,height:this.depth,translate:{y:this.height/2},rotate:{x:s/4}}}[t]};var p=["color","stroke","fill","backface","front","visible"];p.forEach(function(o){var t="_"+o;Object.defineProperty(u.prototype,o,{get:function(){return this[t]},set:function(n){this[t]=n;a.forEach(function(t){var e=this[t+"Rect"];
2955var r=typeof this[t]=="string";var i=o=="color"&&r;if(e&&!i){e[o]=n}},this)}})});return u});(function(t,e){if(typeof module=="object"&&module.exports){module.exports=e(require("./boilerplate"),require("./canvas-renderer"),require("./svg-renderer"),require("./vector"),require("./anchor"),require("./dragger"),require("./illustration"),require("./path-command"),require("./shape"),require("./group"),require("./rect"),require("./rounded-rect"),require("./ellipse"),require("./polygon"),require("./hemisphere"),require("./cylinder"),require("./cone"),require("./box"))}else if(typeof define=="function"&&define.amd){define("zdog",[],t.Zdog)}})(this,function t(e,r,i,n,o,s,a,h,u,p,d,c,f,l,v,y,m,g){e.CanvasRenderer=r;e.SvgRenderer=i;e.Vector=n;e.Anchor=o;e.Dragger=s;e.Illustration=a;e.PathCommand=h;e.Shape=u;e.Group=p;e.Rect=d;e.RoundedRect=c;e.Ellipse=f;e.Polygon=l;e.Hemisphere=v;e.Cylinder=y;e.Cone=m;e.Box=g;return e});`,ii=`
2956:root{--cloud:#F7F5F1;--teal:#0E7C7B;--green:#0A7A34;--yellow:#FFE27A;--ink:#111}
2957*{box-sizing:border-box}
2958html{scrollbar-gutter:stable}
2959body{margin:0;padding:16px;background:var(--cloud);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",sans-serif;display:flex;flex-direction:column}
2960html:lang(zh-TW) body{font-family:-apple-system,"PingFang TC","Microsoft JhengHei","Noto Sans TC",sans-serif}
2961html:lang(zh-CN) body{font-family:-apple-system,"PingFang SC","Microsoft YaHei","Noto Sans SC",sans-serif}
2962html:lang(ja) body{font-family:-apple-system,"Hiragino Sans","Yu Gothic UI","Noto Sans JP",sans-serif}
2963html:lang(ko) body{font-family:-apple-system,"Apple SD Gothic Neo","Malgun Gothic","Noto Sans KR",sans-serif}
2964html:lang(th) body{font-family:-apple-system,"Thonburi","Leelawadee UI","Noto Sans Thai",sans-serif}
2965.masonry{position:relative;z-index:0;min-height:40px}
2966.zone-c{margin:0 auto 14px}
2967#wall[hidden]{display:none}
2968.pill.zord .lbl{letter-spacing:.08em}
2969.pill.zone{min-width:34px;justify-content:center;gap:4px}
2970@media (max-width:620px){.pill.zone .lbl{font-size:10px}}
2971.zn{font-size:9px;opacity:.75;font-weight:900}
2972.pill.zone[aria-pressed="false"]{opacity:.5}
2973.pill.zone[aria-pressed="true"]{background:var(--ink);color:#fff}
2974.masonry>.item{position:absolute;left:0;top:0}
2975.masonry.ready>.item{transition:left .4s cubic-bezier(.2,.8,.2,1),top .4s cubic-bezier(.2,.8,.2,1),width .4s cubic-bezier(.2,.8,.2,1),height .4s cubic-bezier(.2,.8,.2,1)}
2976body.resizing .masonry>.item,body.shuffling .masonry>.item{transition:none}
2977.masonry>.item.dragging{z-index:5}
2978@media (prefers-reduced-motion:reduce){.masonry.ready>.item{transition:none}}
2979.item{max-width:100%;border-radius:18px;overflow:hidden;background:#111;border:2.5px solid var(--ink);position:relative;box-shadow:0 10px 24px rgba(0,0,0,.14)}
2980.item iframe{width:100%;height:100%;border:0;display:block;background:#fff}
2981.item iframe.embed{background:transparent}
2982.ins,.gdel{position:absolute;bottom:6px;width:22px;height:22px;padding:0;border-radius:50%;
2983  border:1.5px solid var(--ink);cursor:pointer;z-index:9;font-weight:900;font-size:13px;
2984  line-height:19px;text-align:center;opacity:.42;transition:opacity .15s,transform .15s}
2985.ins{left:6px;background:var(--teal);color:#fff}
2986.gdel{left:32px;background:#fff;color:var(--ink);font-size:10px}
2987.item:hover .ins,.item:hover .gdel,.ins:focus-visible,.gdel:focus-visible{opacity:1}
2988.ins:hover,.gdel:hover{transform:scale(1.12)}
2989.gdel:hover{background:#fee2e2;color:#ef4444;border-color:#ef4444}
2990@media (pointer:coarse){.ins,.gdel{opacity:.62}}
2991@media (prefers-reduced-motion:reduce){.ins,.gdel{transition:none}}
2992.item.guest{border-color:var(--teal);box-shadow:0 10px 24px rgba(14,124,123,.28)}
2993.pill[hidden],.pill.sync[hidden],.pill.rev[hidden]{display:none}
2994.pill.sync{padding:7px 9px;cursor:default;border-color:var(--ink)}
2995.pill.sync .mi{font-size:10px;width:auto}
2996.pill.sync.on .mi{color:var(--green)}
2997.pill.sync.off .mi{color:#c0392b}
2998.pill.rev{padding:7px 10px}
2999.rev-card{width:min(760px,100%)}
3000.rev-topbar{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:6px}
3001.rev-title-group{display:flex;flex-direction:column;gap:3px}
3002.rev-cnt-pill{display:inline-block;font-size:11px;font-weight:800;background:#fef3c7;color:#b45309;padding:3px 10px;border-radius:999px;border:1.5px solid #f59e0b;white-space:nowrap}
3003.rev-list{max-height:55vh;overflow:auto;display:flex;flex-direction:column;gap:8px;
3004  border:2px solid var(--ink);border-radius:12px;padding:10px;background:var(--cloud)}
3005.rev-row{position:relative;background:#fff;border:1.5px solid rgba(0,0,0,.15);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:6px;transition:all .15s ease}
3006.rev-row.pending{border-left:4px solid #f59e0b;background:#fffdfa}
3007.rev-row.ok{border-left:4px solid var(--teal);background:#fafffd}
3008.rev-meta{display:flex;gap:8px;align-items:center;font-size:11px;font-weight:700;color:var(--ink);flex-wrap:wrap}
3009.rev-st{font-size:10px;font-weight:900;padding:2px 8px;border-radius:99px;text-transform:uppercase;letter-spacing:.5px}
3010.rev-st-pend{background:#fef3c7;color:#b45309;border:1.5px dashed #f59e0b}
3011.rev-st-ok{background:var(--teal);color:#fff;border:1.5px solid var(--teal)}
3012.rev-time{opacity:.8;font-size:10.5px}
3013.rev-zone{background:var(--ink);color:#fff;border-radius:999px;padding:1px 8px;font-size:10px}
3014.rev-fp{background:#e2e8f0;color:#334155;border-radius:6px;padding:1px 6px;font-family:ui-monospace,Menlo,monospace;font-size:10.5px}
3015.rev-body{margin:2px 0}
3016.rev-raw{display:block;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:11.5px;line-height:1.45;word-break:break-all;white-space:pre-wrap;max-height:72px;overflow:auto;background:#f8fafc;padding:6px 8px;border-radius:6px;border:1px solid #e2e8f0}
3017.rev-acts{display:flex;gap:8px;align-items:center;justify-content:flex-end;margin-top:2px}
3018.rev-ok{display:inline-flex;align-items:center;gap:4px;border-radius:999px;border:1.5px solid var(--teal);background:var(--teal);color:#fff;font-weight:900;cursor:pointer;padding:4px 12px;font-size:11px;transition:transform .1s ease}
3019.rev-ok:hover{background:#0d7a71;transform:scale(1.02)}
3020.rev-ok:disabled{opacity:.4;cursor:default}
3021.rev-x{display:inline-flex;align-items:center;gap:4px;border-radius:999px;border:1.5px solid #ef4444;background:#fff;color:#ef4444;font-weight:900;cursor:pointer;padding:4px 12px;font-size:11px;transition:transform .1s ease}
3022.rev-x:hover{background:#fef2f2;transform:scale(1.02)}
3023.rev-x:disabled{opacity:.4;cursor:default}
3024.rev-permanent-tag{font-size:10.5px;font-weight:800;color:var(--teal);padding:3px 8px;background:#ecfdf5;border-radius:999px;border:1px solid #a7f3d0}
3025.rev-none{font-size:12px;font-weight:800;opacity:.65;padding:16px;text-align:center}
3026.ins-modal{position:fixed;inset:0;z-index:120;background:rgba(17,17,17,.45);
3027  display:flex;align-items:center;justify-content:center;padding:18px}
3028.ins-card{width:min(560px,100%);background:#fff;border:2.5px solid var(--ink);border-radius:18px;
3029  padding:16px 18px;box-shadow:0 18px 44px rgba(0,0,0,.3);display:flex;flex-direction:column;gap:8px}
3030.ins-card b{font-size:14px}
3031.ins-hint{margin:0;font-size:11px;line-height:1.6;opacity:.65;font-weight:700}
3032.ins-card textarea, #insTa{width:100%;height:88px!important;min-height:60px!important;max-height:180px;flex:0 0 auto!important;resize:vertical;border:2px solid var(--ink);border-radius:12px;
3033  padding:10px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;line-height:1.6;
3034  background:var(--cloud);color:var(--ink)}
3035.ins-kinds{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
3036.ins-kinds-left{display:flex;align-items:center;gap:6px}
3037.ins-md-badge{display:inline-flex;align-items:center;font-size:10.5px;font-weight:800;color:var(--teal);background:#ecfdf5;border:1px solid #a7f3d0;border-radius:999px;padding:2px 8px}
3038.ins-html-badge{display:inline-flex;align-items:center;font-size:10.5px;font-weight:800;color:#2563EB;background:#eff6ff;border:1px solid #bfdbfe;border-radius:999px;padding:2px 8px}
3039.ins-preview-btn{border:1.5px solid var(--ink);border-radius:999px;padding:3px 10px;font-size:11px;font-weight:800;cursor:pointer;background:#fff;color:var(--ink);transition:all .15s}
3040.ins-preview-btn:hover{background:var(--cloud)}
3041.ins-md-preview-pane{border:2px solid var(--ink);border-radius:12px;background:#fff;padding:12px;max-height:240px;overflow:auto;display:flex;flex-direction:column;gap:8px}
3042.ins-md-preview-head{display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:900;text-transform:uppercase;letter-spacing:.05em;
3042color:var(--teal);border-bottom:1px solid #e5e7eb;padding-bottom:4px}
3043.ins-md-preview-close{background:none;border:none;cursor:pointer;font-size:12px;font-weight:900;color:var(--ink);padding:2px 6px;border-radius:4px}
3044.ins-md-preview-close:hover{background:#f3f4f6}
3045.ins-md-preview-body{font-size:13px;line-height:1.6;color:#111;overflow-wrap:anywhere}
3046.ins-md-preview-body :first-child{margin-top:0}
3047.ins-md-preview-body :last-child{margin-bottom:0}
3048.ins-preview-frame{width:100%;height:180px;border:1.5px solid #e2e8f0;border-radius:8px;background:#fff;display:none}
3049.ins-err{min-height:15px;font-size:11px;font-weight:800;color:#c0392b}
3050.ins-go{display:flex;justify-content:flex-end;gap:8px}
3051.ins-btn{border:2.5px solid var(--ink);border-radius:999px;padding:8px 16px;font:inherit;font-size:12px;
3052  font-weight:900;cursor:pointer;background:#fff;color:var(--ink);transition:opacity .15s}
3053.ins-btn.on{background:var(--teal);color:#fff}
3054.ins-btn:disabled{opacity:.65;cursor:not-allowed;pointer-events:none}
3055@keyframes insSpin{to{transform:rotate(360deg)}}
3056.ins-spin{display:inline-block;width:12px;height:12px;border:2px solid rgba(255,255,255,0.4);border-top-color:#fff;border-radius:50%;animation:insSpin .75s linear infinite;vertical-align:-2px;margin-right:6px}
3057.resize-anchor{position:absolute;right:0;bottom:0;width:44px;height:44px;cursor:nwse-resize;z-index:8;touch-action:none;background:linear-gradient(135deg,transparent 50%,rgba(255,226,122,0.95) 50%)}
3058.resize-anchor::after{content:'↘';position:absolute;right:5px;bottom:2px;font-weight:900;font-size:15px}
3059.side-anchor{position:absolute;right:0;top:34px;bottom:44px;width:28px;max-width:30%;cursor:ew-resize;z-index:7;touch-action:none;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s}
3060.side-anchor::after{content:'';width:8px;height:54px;border-radius:999px;background:var(--ink);opacity:.35;box-shadow:0 0 0 2px rgba(255,255,255,.65)}
3061.item:hover .side-anchor{opacity:1}
3062body.resizing .side-anchor{opacity:1}
3063@media (pointer:coarse){.side-anchor{width:36px;opacity:.55}.side-anchor::after{width:10px;height:64px}}
3064body.resizing{user-select:none;cursor:nwse-resize}
3065body.resizing iframe{pointer-events:none}
3066.ph{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;background:repeating-linear-gradient(135deg,#1b1b1b 0 14px,#222 14px 28px);color:#fff;font-weight:900;pointer-events:none}
3067.ph-i{font-size:22px;opacity:.75}
3068.ph-h{font-size:11px;opacity:.55;max-width:90%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3069.item.tomb{background:#FBFAF7}
3070.tomb-body{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:14px 12px;text-align:center;color:var(--ink);overflow:hidden}
3071.tomb-img{width:86px;height:auto;flex:0 0 auto;margin-bottom:2px}
3072.tomb-label{font-weight:900;font-size:14px;letter-spacing:.02em}
3073.tomb-host{font-size:11px;font-weight:800;opacity:.6;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3074.tomb-note{font-size:11px;opacity:.55;line-height:1.35}
3075.tomb-link{margin-top:6px;display:inline-flex;gap:6px;align-items:center;background:var(--teal);color:#fff;border:2px solid var(--ink);border-radius:999px;padding:7px 13px;font-size:11px;font-weight:900;text-decoration:none;white-space:nowrap}
3076.tomb-link:hover{filter:brightness(1.12)}
3077.tomb-link:focus-visible{outline:3px solid var(--teal);outline-offset:2px}
3078.corner{position:absolute;left:0;top:0;width:52px;height:52px;z-index:5;pointer-events:none}
3079.corner svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
3080.corner .c-fill{fill:var(--yellow)}
3081.corner .c-edge{fill:none;stroke:var(--ink);stroke-width:1.6}
3082.corner .c-lbl{position:absolute;left:-5px;top:12px;width:44px;text-align:center;font-size:9px;font-weight:900;line-height:10px;letter-spacing:-.15px;color:var(--green);transform:rotate(-45deg);white-space:nowrap}
3083.corner.co.pend .c-fill{fill:#D9F0EE}
3084.corner.co.pend .c-edge{stroke:var(--teal);stroke-width:2;stroke-dasharray:4 3}
3085.corner.co.pend .c-lbl{color:var(--teal)}
3086.corner.co.ok .c-fill{fill:var(--teal)}
3087.corner.co.ok .c-lbl{color:#fff}
3088.item.guest.pending{border-style:dashed}
3089.corner-dim{position:absolute;left:50%;bottom:7px;transform:translateX(-50%);z-index:6;pointer-events:none;background:rgba(17,17,17,.8);color:#fff;font-size:10px;font-weight:800;padding:2px 8px;border-radius:99px;opacity:0;transition:opacity .15s;white-space:nowrap}
3090.item:hover .corner-dim,.item.dragging .corner-dim{opacity:1}
3091.bar-zone{position:sticky;top:8px;z-index:70;display:flex;flex-direction:column;align-items:center;gap:8px;margin:0 0 14px}
3092.zone-a{position:relative;overflow:hidden;width:100%;margin:0 auto 18px;transition:height .45s cubic-bezier(.2,.8,.2,1)}
3093.zone-a[hidden]{display:none}
3094.za-track{position:relative;height:100%}
3095.za-arrow{position:absolute;top:50%;transform:translateY(-50%);z-index:7;width:38px;height:38px;border-radius:50%;border:2.5px solid var(--ink);background:var(--yellow);color:var(--ink);font-size:24px;font-weight:900;line-height:1;cursor:pointer;display:grid;place-items:center;padding:0 0 3px;box-shadow:0 6px 16px rgba(0,0,0,.22);opacity:.55;transition:opacity .15s,transform .15s}
3096.zone-a:hover .za-arrow,.za-arrow:focus-visible{opacity:1}
3097.za-arrow:hover{transform:translateY(-50%) scale(1.08)}
3098.za-arrow[hidden]{display:none}
3099.za-l{left:6px}.za-r{right:6px}
3100@media (max-width:560px){.za-arrow{width:32px;height:32px;font-size:20px;opacity:.85}}
3101.za-track>.item{position:absolute;left:0;top:0;transition:left .6s cubic-bezier(.2,.8,.2,1)}
3102@media (prefers-reduced-motion:reduce){.za-track>.item,.zone-a,.za-arrow{transition:none}}
3103.fx-layer{position:fixed;left:0;top:0;z-index:8;pointer-events:none}
3104.fx-bee{position:fixed;left:0;top:0;z-index:9;pointer-events:none;width:max-content;will-change:transform;filter:drop-shadow(0 8px 14px rgba(0,0,0,.28))}
3105.fx-bee{transform-style:preserve-3d}
3106.fx-bee img,.fx-bee svg.zdog-svg{display:block;width:150px;height:120px;backface-visibility:visible;overflow:visible;pointer-events:auto;cursor:grab}
3107.fx-bee .wob{display:block;transform-style:preserve-3d;animation:fxwob .42s ease-in-out infinite alternate}
3108@keyframes fxwob{from{transform:translateY(-6px) rotateX(10deg) rotateZ(-4deg)}to{transform:translateY(6px) rotateX(-8deg) rotateZ(4deg)}}
3109@media (max-width:560px){.fx-bee img,.fx-bee svg.zdog-svg{width:110px;height:88px}}
3110.fx-spark{position:fixed;z-index:8;pointer-events:none;width:16px;height:16px;border-radius:50%;background:var(--yellow);box-shadow:0 0 22px 6px rgba(255,226,122,.9);animation:fxspark 1.2s ease-out forwards}
3111@keyframes fxspark{from{transform:scale(1);opacity:.95}to{transform:scale(.2) translateY(18px);opacity:0}}
3112@media (prefers-reduced-motion:reduce){.fx-layer,.fx-ship{display:none}}
3113.ver-badge{position:fixed;top:10px;right:12px;z-index:75;padding:5px 10px;border:2px solid var(--ink);border-radius:999px;background:rgba(255,255,255,.88);color:var(--ink);font-size:11px;font-weight:900;letter-spacing:.04em;pointer-events:none;box-shadow:0 4px 12px rgba(0,0,0,.12)}
3114@media (max-width:420px){.ver-badge{top:auto;bottom:10px;right:8px;font-size:10px;padding:4px 8px;opacity:.85}}
3115.empty{padding:40px 16px;text-align:center;opacity:.55;font-weight:800}
3116.fab-wrap{position:relative;z-index:1;max-width:100%;display:flex;gap:8px;align-items:center;background:#fff;border:2.5px solid var(--ink);border-radius:999px;padding:6px 12px;box-shadow:0 8px 24px rgba(0,0,0,.15)}
3117.fab{background:var(--teal);color:#fff;border:2px solid var(--ink);border-radius:999px;padding:9px 14px;font-weight:900;cursor:pointer;font-size:12px;max-width:34vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3118.lang-select{border:2px solid var(--ink);border-radius:999px;padding:7px 12px;font-weight:800;background:#fff;font-size:12px;cursor:pointer;outline:none}
3119button,select{font-family:inherit}
3120@media (max-width:760px){
3121  .fab-wrap{flex-wrap:wrap;justify-content:center;border-radius:22px;padding:8px 10px}
3122  .fab{max-width:46vw}
3123}
3124.menu-wrap{position:relative;flex:0 0 auto}
3125.pill{display:inline-flex;align-items:center;gap:6px;background:#fff;border:2px solid var(--ink);border-radius:999px;padding:7px 10px;font-weight:800;font-size:12px;cursor:pointer;white-space:nowrap;color:var(--ink)}
3126.pill.random{background:var(--yellow)}
3127.pill .caret{font-size:9px;transition:transform .15s}
3128.pill[aria-expanded="true"] .caret{transform:rotate(180deg)}
3129.menu{position:absolute;top:calc(100% + 12px);left:50%;transform:translateX(-50%);min-width:176px;background:#fff;border:2.5px solid var(--ink);border-radius:16px;padding:6px;box-shadow:0 12px 28px rgba(0,0,0,.18);display:flex;flex-direction:column;gap:2px}
3130.menu[hidden]{display:none}
3131.menu button{display:flex;align-items:center;gap:10px;width:100%;background:none;border:0;border-radius:10px;padding:9px 10px;font-size:12px;font-weight:800;text-align:left;cursor:pointer;color:var(--ink)}
3132.menu button:hover,.menu button:focus-visible{background:var(--cloud);outline:none}
3133.menu button.on{background:var(--ink);color:#fff}
3134.menu button[data-cols="0"].on{background:var(--yellow);color:var(--ink);box-shadow:inset 0 0 0 2px var(--ink)}
3135.menu hr{border:0;border-top:1.5px dashed rgba(0,0,0,.25);margin:4px 6px}
3136.mi{display:inline-flex;justify-content:center;width:22px;flex:0 0 22px}
3137.cn{font-size:10px;font-weight:900;margin-left:1px}
3138.fx-group{display:contents}
3139.fx-group[hidden]{display:none}
3140.ci{display:inline-flex;gap:2px;width:20px;height:12px}.ci i{flex:1;background:currentColor;border-radius:1.5px}
3141.pill.exp{background:#F3E5F5;border-color:var(--ink)}
3142#copyBtn{margin-left:6px}
3143body.empty-wall .pill.exp{display:none}
3144.pill .lbl{display:none}
3145.pill.zone .lbl{display:inline}
3146.pill{padding:7px 9px}
3147.pill.zone{padding:7px 11px}
3148@media (max-width:560px){.fab{max-width:28vw}}
3149@media (max-width:420px){.fab-wrap{gap:4px;padding:4px 6px}.pill{padding:6px 7px}.fab{padding:8px 10px;max-width:22vw}.lang-select{padding:6px 4px;max-width:64px}}
3150@media (prefers-reduced-motion:reduce){.pill .caret{transition:none}}
3151button:focus-visible,.tool-btn:focus-within,select:focus-visible{outline:3px solid var(--teal);outline-offset:2px}
3152.fab.badge{cursor:default}
3153.pill.filt.active{background:var(--yellow)}
3154.pill.fx[aria-pressed="false"]{opacity:.55}
3155.pill.fx[aria-pressed="true"]{background:var(--yellow)}
3156.pill.snd[aria-pressed="true"]{background:var(--teal);color:#fff}
3157.pill.filt[aria-pressed="true"]{box-shadow:inset 0 0 0 2px var(--ink)}
3158.filter-bar{position:relative;z-index:1;width:min(920px,100%);display:flex;flex-wrap:wrap;gap:8px;align-items:center;background:#fff;border:2.5px solid var(--ink);border-radius:20px;padding:8px 10px;box-shadow:0 8px 24px rgba(0,0,0,.12)}
3159.filter-bar[hidden]{display:none}
3160.filter-bar input{flex:1 1 220px;min-width:0;border:2px solid var(--ink);border-radius:999px;padding:8px 14px;font:inherit;font-size:13px;font-weight:700;background:var(--cloud);color:var(--ink)}
3161.filter-bar select{border:2px solid var(--ink);border-radius:999px;padding:7px 10px;font:inherit;font-size:12px;font-weight:800;background:#fff;color:var(--ink);max-width:100%}
3162.filter-bar input:focus-visible,.filter-bar select:focus-visible{outline:3px solid var(--teal);outline-offset:2px}
3163.f-count{font-size:12px;font-weight:900;opacity:.7;white-space:nowrap}
3164.f-clear{border:2px solid var(--ink);border-radius:999px;padding:7px 12px;font:inherit;font-size:12px;font-weight:800;background:#fff;cursor:pointer;color:var(--ink)}
3165.masonry>.item.f-out{display:none}
3166.no-match{padding:48px 16px;text-align:center;font-weight:800;opacity:.55}
3167.pill.car[aria-pressed="true"]{background:var(--ink);color:#fff}
3168.masonry.carousel{overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory;scroll-behavior:smooth;overscroll-behavior-x:contain;scrollbar-width:none}
3169.masonry.carousel::-webkit-scrollbar{display:none}
3170.masonry.carousel>.item{scroll-snap-align:start}
3171.masonry.carousel.ready>.item{transition:none}
3172.masonry.carousel.ready{transition:height .3s ease}
3173.masonry.carousel .resize-anchor,.masonry.carousel .side-anchor{display:none}
3174.car-nav{position:relative;z-index:6;margin:0 auto 14px;width:max-content;max-width:calc(100% - 8px);display:flex;align-items:center;gap:10px;background:#fff;border:2.5px solid var(--ink);border-radius:999px;padding:6px 8px;box-shadow:0 8px 24px rgba(0,0,0,.12)}
3175.car-nav[hidden]{display:none}
3176.car-arrow{width:34px;height:34px;border-radius:50%;border:2px solid var(--ink);background:var(--yellow);font-size:20px;font-weight:900;line-height:1;cursor:pointer;color:var(--ink);flex:0 0 auto}
3177.car-arrow:disabled{opacity:.35;cursor:default}
3178.car-side{position:absolute;z-index:6;width:44px;height:44px;border-radius:50%;border:2.5px solid var(--ink);background:var(--yellow);color:var(--ink);font-size:28px;font-weight:900;line-height:1;cursor:pointer;box-shadow:0 6px 16px rgba(0,0,0,.22);display:grid;place-items:center;padding:0 0 4px;transition:opacity .15s,transform .15s}
3179.car-side[hidden]{display:none}
3180.car-side:hover:not(:disabled){transform:scale(1.08)}
3181.car-side:disabled{opacity:.25;cursor:default}
3182@media (max-width:560px){.car-side{width:36px;height:36px;font-size:22px}}
3183@media (prefers-reduced-motion:reduce){.car-side{transition:none}}
3184.car-dots{display:flex;align-items:center;gap:6px;overflow:hidden}
3185.car-dot{width:10px;height:10px;padding:0;border-radius:50%;border:2px solid var(--ink);background:#fff;cursor:pointer;flex:0 0 auto;transition:width .2s,background .2s}
3186.car-dot[aria-current="true"]{width:24px;border-radius:999px;background:var(--teal)}
3187.car-count{font-size:12px;font-weight:900;min-width:54px;text-align:center}
3188@media (prefers-reduced-motion:reduce){.masonry.carousel{scroll-behavior:auto}.car-dot{transition:none}}
3189.pill.shuffle:hover{background:var(--cloud)}
3190.pill[aria-busy="true"]{opacity:.55;cursor:progress}
3191body.shuffling iframe{pointer-events:none}
3192body.shuffling{overflow-x:hidden}
3193.menu button[data-cols="-1"].on{background:var(--teal);color:#fff}
3194.ins-kinds{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
3195.ins-kind{border:2px solid var(--ink);border-radius:999px;background:#fff;padding:4px 11px;font:inherit;font-size:11px;font-weight:900;cursor:pointer}
3196.ins-kind:hover{background:var(--yellow)}
3197.ins-kinds-note{font-size:10.5px;font-weight:700;opacity:.55}
3198.spr-box{display:flex;flex-direction:column;gap:6px;border:2px dashed var(--ink);border-radius:14px;padding:10px 12px;background:#fff}
3199.spr-box>b{font-size:12px}
3200.spr-row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
3201.spr{position:relative;width:74px;height:74px;border:2px solid var(--ink);border-radius:12px;background:var(--cloud);display:flex;align-items:center;justify-content:center}
3202.spr img{max-width:58px;max-height:58px;object-fit:contain}
3203.spr-tag{position:absolute;
3203left:4px;top:3px;font-size:8.5px;font-weight:900;color:var(--green)}
3204.spr-acts{position:absolute;right:-6px;bottom:-8px;display:flex;gap:3px}
3205.spr-acts button,.spr-add,.spr-reset{border:2px solid var(--ink);background:#fff;border-radius:50%;width:24px;height:24px;padding:0;font:inherit;font-size:11px;font-weight:900;cursor:pointer;line-height:1}
3206.spr-acts button[data-rep]{background:var(--yellow)}
3207.spr-add{width:74px;height:74px;border-radius:12px;border-style:dashed;font-size:22px}
3208.spr-reset{width:30px;height:30px}
3209.spr-acts button:hover,.spr-add:hover,.spr-reset:hover{background:var(--teal);color:#fff}
3210.spr-note{font-size:11px;font-weight:800;opacity:.6}.spr-note.bad{color:#c0392b;opacity:1}
3211.pill.fx:disabled{opacity:.35;cursor:not-allowed}
3212.fold{display:none;position:absolute;left:0;right:0;bottom:0;z-index:7;height:74px;align-items:flex-end;justify-content:center;padding-bottom:10px;pointer-events:none;background:linear-gradient(to bottom,rgba(255,255,255,0),rgba(255,255,255,.92) 62%)}
3213.item.clipped .fold{display:flex}
3214.item.unfolded .fold{display:flex;height:auto;background:none}
3215.fold-btn{pointer-events:auto;border:2px solid var(--ink);background:var(--yellow);color:var(--ink);border-radius:999px;padding:4px 14px;font:inherit;font-size:12px;font-weight:900;cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,.15)}
3216.fold-btn:hover{background:var(--teal);color:#fff}
3217.item.unfolded .fold-btn{background:#fff}
3218.masonry.carousel .fold{display:none!important}
3219.ins,.gdel{z-index:9}
3220.del,.edit,.tog{position:absolute;top:6px;width:18px;height:18px;padding:0;border-radius:50%;border:0;cursor:pointer;z-index:9;font-weight:900;font-size:9px;line-height:18px;text-align:center;opacity:.35;transition:opacity .15s}
3221.del{right:6px;background:rgba(0,0,0,.6);color:#fff}
3222.edit{right:28px;background:rgba(255,255,255,.75);color:#111}
3223.tog{right:50px;background:rgba(255,255,255,.75);color:#111;font-size:10px}
3224.item:hover .del,.item:hover .edit,.item:hover .tog,.del:focus-visible,.edit:focus-visible,.tog:focus-visible{opacity:1}
3225@media (pointer:coarse){.del,.edit,.tog{width:22px;height:22px;line-height:22px;font-size:10px;opacity:.5}.edit{right:32px}.tog{right:58px}}
3226@media (prefers-reduced-motion:reduce){.del,.edit,.tog{transition:none}}
3227.move-anchor{position:absolute;left:0;top:0;bottom:0;width:28px;cursor:grab;z-index:7;touch-action:none;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s}
3228.move-anchor::after{content:'â ¿';font-size:18px;font-weight:900;color:var(--ink);opacity:.5;text-shadow:0 0 3px rgba(255,255,255,.9)}
3229.item:hover .move-anchor{opacity:1}
3230body.dragging-card .move-anchor{opacity:1;cursor:grabbing}
3231.item.moving{cursor:grabbing;box-shadow:0 18px 36px rgba(0,0,0,.28);z-index:6!important}
3232.item.free::after{content:'📌';position:absolute;left:48px;top:4px;z-index:6;font-size:13px;line-height:1;pointer-events:none}
3233.masonry.carousel .move-anchor,body.guest .move-anchor{display:none}
3234@media (pointer:coarse){.move-anchor{width:34px;opacity:.5}}
3235.import-panel{position:fixed;top:68px;left:50%;transform:translateX(-50%);width:min(920px,96vw);background:#fff;border:2.5px solid var(--ink);border-radius:20px;padding:16px;max-height:92vh;display:flex;flex-direction:column;z-index:85;overflow:auto}
3236.import-panel.hidden{display:none}
3237.import-panel textarea, .ta-wrap textarea, textarea#input{width:100%;flex:1;min-height:380px;border:2px solid var(--ink);border-radius:12px;padding:12px;font-family:monospace;background:var(--cloud);line-height:1.8;font-size:12px}
3238.ta-wrap{display:flex;gap:8px;flex:1;min-height:380px;position:relative}
3239.ta-wrap.sized{flex:0 0 auto;height:var(--ta-h);min-height:0}
3240.ta-wrap.sized #input{min-height:0;height:100%}
3241#input{resize:none}
3242.ta-grip{position:absolute;right:6px;bottom:6px;width:22px;height:22px;z-index:4;
3243  cursor:ns-resize;border-radius:6px;touch-action:none;
3244  background:linear-gradient(135deg,transparent 0 46%,var(--ink) 46% 54%,transparent 54% 70%,var(--ink) 70% 78%,transparent 78%);
3245  opacity:.38;transition:opacity .15s}
3246.ta-grip:hover,.ta-grip:focus-visible{opacity:.95;outline:none}
3247.ta-grip:focus-visible{box-shadow:0 0 0 2px var(--teal)}
3248.ta-wrap #input{flex:1;min-height:0;scrollbar-width:none}
3249.ta-wrap #input::-webkit-scrollbar{width:0;height:0}
3250.ta-bar{width:30px;flex:0 0 30px;border:2px solid var(--ink);border-radius:999px;background:var(--cloud);position:relative;touch-action:none;cursor:pointer}
3251.ta-bar[hidden]{display:none}
3252.ta-thumb{position:absolute;
3252left:3px;right:3px;top:0;min-height:56px;border-radius:999px;background:var(--teal);box-shadow:inset 0 0 0 1.5px var(--ink);cursor:grab}
3253.ta-bar.drag .ta-thumb{cursor:grabbing;background:#0b6b6a}
3254.import-panel{scrollbar-width:auto}
3255.toolbar{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0;align-items:center}
3256.tool-btn{border:2px solid var(--ink);border-radius:999px;padding:8px 14px;font-size:11px;font-weight:800;cursor:pointer;background:#fff}
3257.tool-btn.primary{background:var(--teal);color:#fff}
3258.zdrag{display:flex;align-items:center;gap:6px}
3259.zchip{display:inline-flex;align-items:center;gap:5px;border:2px solid var(--ink);border-radius:999px;padding:5px 12px;font-size:11px;font-weight:900;background:#fff;cursor:grab;user-select:none}
3260.zchip .grip{opacity:.45;font-size:12px}
3261.zchip.fixed{background:var(--cloud);cursor:default;opacity:.7}
3262.zchip.drag{opacity:.45;cursor:grabbing}
3263.zchip.over{box-shadow:0 0 0 3px var(--teal)}
3264.tabs{display:flex;gap:6px;margin:6px 0 2px}
3265.tab{border:2px solid var(--ink);border-radius:999px;padding:6px 14px;font:inherit;font-size:11px;font-weight:900;background:#fff;cursor:pointer;color:var(--ink)}
3266.tab[aria-selected="true"]{background:var(--ink);color:#fff}
3267.pane[hidden]{display:none}
3268.pane-pics{display:flex;flex-direction:column;gap:10px;flex:1;min-height:320px}
3269.drop{border:2.5px dashed var(--ink);border-radius:16px;padding:22px;text-align:center;font-weight:800;font-size:12px;background:var(--cloud);cursor:pointer}
3270.drop.over{background:var(--yellow)}
3271.pics{display:flex;flex-wrap:wrap;gap:10px;overflow:auto;max-height:280px}
3272.pic .m3d{width:100%;height:76px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;background:radial-gradient(120% 120% at 50% 0%,#fff,#E6E2DB);color:#111;font-weight:900}
3273.pic .m3d b{font-size:19px;line-height:1}
3274.pic .m3d span{font-size:9px;letter-spacing:.09em;opacity:.7}
3275.pic .m3d i{font-size:9px;font-style:normal;opacity:.5;max-width:92%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3276.pic{width:150px;border:2px solid var(--ink);border-radius:12px;overflow:hidden;background:var(--cloud)}
3277.pic img{display:block;width:100%;height:92px;object-fit:contain;background:#fff}
3278.pic .row{display:flex;align-items:center;gap:4px;padding:6px;font-size:10px;font-weight:800}
3279.pic select{flex:1;min-width:0;border:1.5px solid var(--ink);border-radius:999px;padding:3px 4px;font:inherit;font-size:10px;font-weight:800;background:#fff}
3280.pic button{border:1.5px solid var(--ink);background:#fff;border-radius:999px;width:22px;height:22px;cursor:pointer;font-weight:900}
3281.meta-fields{display:grid;grid-template-columns:2fr 1.5fr 1fr;gap:8px;margin:4px 0 8px}
3282.meta-fields[hidden]{display:none}
3283.meta-fields label{display:flex;flex-direction:column;gap:3px;font-size:10px;font-weight:900;opacity:.85}
3284.meta-fields input{border:2px solid var(--ink);border-radius:10px;padding:7px 10px;font:inherit;font-size:12px;font-weight:700;background:var(--cloud);color:var(--ink)}
3285@media (max-width:560px){.meta-fields{grid-template-columns:1fr}}
3286.globe{background:#fff;border:2.5px solid var(--ink);border-radius:50%;width:36px;height:36px;cursor:pointer;flex:0 0 auto}
3287@media (max-width:420px){.globe{display:none}}
3288.toast{position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);background:var(--ink);color:#fff;padding:10px 16px;border-radius:999px;font-size:12px;font-weight:800;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:95;max-width:92vw}
3289.toast.show{opacity:1;transform:translate(-50%,0)}
3290@media (prefers-reduced-motion:reduce){.toast{transition:none}}
3291`,ua=/^[━─—–\-_*•·・-ー]{3,}$/,ma=/^={3,}$/,pa=/^#{1,}$/,oi=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i;function li(r){let p=0;const y=/<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/g;let v;for(;v=y.exec(r);)oi.test(v[2])||v[3]||(p+=v[1]?-1:1);return p}const fa=r=>r.lastIndexOf("<")<=r.lastIndexOf(">")&&li(r)<=0;function di(r){const p=[];let y=null,v=null;for(const T of String(r).split(/\r?\n/)){const N=T.trim();if(v!==null){v+=`
3292`+T,/<\/md>\s*$/i.test(N)&&(p.push(v.trim()),v=null);continue}if(y===null&&/^<md>/i.test(N)){/<\/md>\s*$/i.test(N)&&N.length>4?p.push(N):v=T;continue}if(y!==null)if(pa.test(N)||ma.test(N)||ua.test(N)||/^https?:\/\/\S+$/i.test(N)&&y.lastIndexOf("<")<=y.lastIndexOf(">"))p.push(y.trim()),y=null;else{y+=`
3293`+T,fa(y)&&(p.push(y.trim()),y=null);continue}if(pa.test(N)){p.push("__ZONE_C__");continue}if(ma.test(N)){p.push("__ZONE_A__");continue}if(!N||ua.test(N))continue;if(N.startsWith("<")){/^<script\b/i.test(N)&&p.length&&p[p.length-1].startsWith("<")?y=p.pop()+`
3294`+T:y=T,fa(y)&&(p.push(y.trim()),y=null);continue}const _=N.match(/https?:\/\/[^\s"'<>]+/gi);_?p.push(..._):p.push(N)}return y!==null&&p.push(y.trim()),v!==null&&p.push(v.trim()),p}const ha=({content:r,title:p="EzSheet Preview",className:y="",height:v=900,wallId:T="ezsheet",lang:N="en",cols:_,car:q,filter:n,editable:K=!1,zones:ke,zorder:H,fireworks:W,flying:me=!0,sound:_e,sprites:X,syncUrl:ie,frameCheckUrl:re,metaUrl:be,auth:F,isOwner:oe=!1,onItemsChange:G})=>{const Ue=s.useRef(null),[qe,Qe]=s.useState(null),We=s.useMemo(()=>{var ee,he,A,pe;if(F!=null&&F.user)return F;if(typeof window<"u"){if((ee=window.auth)!=null&&ee.user)return window.auth;try{const U=document.getElementById("app");if((he=U==null?void 0:U.dataset)!=null&&he.page){const S=JSON.parse(U.dataset.page);if((pe=(A=S==null?void 0:S.props)==null?void 0:A.auth)!=null&&pe.user)return S.props.auth}}catch{}}return F||{user:null}},[F]),De=s.useMemo(()=>
3294{if(!r)return null;let ee=[],he=T,A=typeof _=="number"?_:void 0,pe=typeof q=="boolean"?q:void 0,U=typeof n=="boolean"?n:void 0,S=N,se=ke,ye=H,Ne={fw:!!W,fly:me!==!1,snd:_e!==!1};const M=String(r).trim(),Se=M.match(/<script\s+id=["']wall-data["'][^>]*>([\s\S]*?)<\/script>/i);if(Se!=null&&Se[1])try{const h=JSON.parse(Se[1]);h&&typeof h=="object"&&(h.id&&(he=String(h.id)),Array.isArray(h.list)?ee=h.list:Array.isArray(h)&&(ee=h),typeof h.cols=="number"&&(A=h.cols),typeof h.car=="boolean"&&(pe=h.car),typeof h.filter=="boolean"&&(U=h.filter),typeof h.lang=="string"&&(S=h.lang),h.zones&&typeof h.zones=="object"&&(se=h.zones),Array.isArray(h.zorder)&&(ye=h.zorder),h.fx&&typeof h.fx=="object"&&(Ne=h.fx))}catch(h){console.warn("EzSheetPreview: failed to parse wall-data JSON",h)}if(ee.length===0&&/^[\[{]/.test(M))try{const h=JSON.parse(M);Array.isArray(h)?ee=h:h&&typeof h=="object"&&(h.id&&(he=String(h.id)),Array.isArray(h.list)&&(ee=h.list),typeof h.cols=="number"&&(A=h.cols),typeof h.car=="boolean"&&(pe=h.car),typeof h.filter=="boolean"&&(U=h.filter),typeof h.lang=="string"&&(S=h.lang),h.zones&&typeof h.zones=="object"&&(se=h.zones),Array.isArray(h.zorder)&&(ye=h.zorder),h.fx&&typeof h.fx=="object"&&(Ne=h.fx))}catch(h){console.warn("EzSheetPreview: failed to parse JSON content",h)}if(ee.length===0&&M){const h=di(M),ge=[];let le=[];const xe=g=>{le.forEach(je=>{je.zone=g,ge.push(je)}),le=[]};for(const g of h){if(g==="__ZONE_C__"){xe("c");continue}if(g==="__ZONE_A__"){xe("a");continue}const je=g.trim();if(!je)continue;const de=ci(je);de&&le.push(de)}xe("b"),ee=ge}if(ee.length===0)return null;const Me=ee.map(h=>{if(!h||typeof h!="object")return null;const le={_raw:h._raw||h.type==="html"&&h.html||h.type==="md"&&h.md&&`<md>${h.md}</md>`||h.url||"",type:h.type||(h.html?"html":h.md?"md":"web"),w:Number(h.w)||340,h:Number(h.h)||220,zone:h.zone==="a"||h.zone==="c"?h.zone:"b"};if(["url","id","html","md","mdl","title","tags","at","pub","dur","span","rh","emb","blk","manual","free","px","py","pic","mh"].forEach(xe=>{h[xe]!==void 0&&(le[xe]=h[xe])}),!le.type||le.type==="web"){const xe=String(le.url||"").match(/(?:youtube\.com\/(?:embed\/|watch\?v=|shorts\/|live\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);xe&&(le.type="youtube",le.id=xe[1])}return le}).filter(Boolean);return{id:he,cols:A!==void 0?A:0,car:pe===!0,lang:S,zones:se,zorder:ye,fx:Ne,filter:U===!0?!0:U===!1?!1:void 0,list:Me,editable:K,sprites:X}},[r,T,N,_,q,n,ke,H,W,me,_e,X,K]);return s.useEffect(()=>{if(!De||!Ue.current)return;const ee=Ue.current,he=JSON.stringify(De).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`window.WALL_SPRITES=${JSON.stringify(X||["bee:0","bee:1"]).replace(/</g,"\\u003c")};`,pe=typeof window<"u"&&window.location&&window.location.origin&&window.location.origin!=="null"&&!window.location.origin.startsWith("about:")?window.location.origin:"",U=ie||pe,S=`<!DOCTYPE html>
3295<html lang="${De.lang||"en"}">
3296<head>
3297<meta charset="UTF-8">
3298<meta name="viewport" content="width=device-width,initial-scale=1.0">
3299<title>${p}</title>
3300<style>${ii}</style>
3301<script>
3302${si}
3303if(typeof window !== 'undefined' && typeof Zdog === 'undefined' && window.Zdog){
3304  var Zdog = window.Zdog;
3305}
3306<\/script>
3307<script src="https://unpkg.com/zdog@1/dist/zdog.dist.min.js"><\/script>
3308</head>
3309<body class="${K?"edit":"ro"}">
3310<div id="wall" class="masonry"></div>
3311<script id="wall-data" type="application/json">${he}<\/script>
3312<script>${A}<\/script>
3313<script>${ai}<\/script>
3314<script>
3315window.auth = ${JSON.stringify(We)};
3316window.isOwner = ${JSON.stringify(!!oe)};
3317window.WALL_ORIGIN = ${JSON.stringify(pe)};
3318try{WallCore.setWallSync(${JSON.stringify(U)});}catch(e){}
3319${re?`try{WallCore.setFrameCheck(${JSON.stringify(re)});}catch(e){}`:""}
3320${be?`try{WallCore.setMetaFetch(${JSON.stringify(be)});}catch(e){}`:""}
3321try { WallCore.bootReadonly(); } catch (e) { console.error('bootReadonly failed', e); }
3322${K&&G?`
3323window.addEventListener('message', function(e){
3324  if(e.data && e.data.__ezsheetRequestItems){
3325    try {
3326      var el = document.getElementById('wall-data');
3327      if(el) parent.postMessage({__ezsheetItems: JSON.parse(el.textContent).list}, '*');
3328    } catch(err){}
3329  }
3330});
3331try {
3332  setInterval(function(){
3333    try {
3334      var el = document.getElementById('wall-data');
3335      if(el) parent.postMessage({__ezsheetItems: JSON.parse(el.textContent).list}, '*');
3336    } catch(err){}
3337  }, 4000);
3338} catch(e){}
3339`:""}
3340<\/script>
3341</body>
3342</html>`;try{ee.srcdoc=S,Qe(null)}catch(se){Qe("Failed to render EzSheet preview"),console.error("EzSheetPreview: error setting srcdoc",se)}},[De,p,ie,re,be,K,G,X,oe,We]),s.useEffect(()=>{if(!G)return;const ee=he=>{he.data&&he.data.__ezsheetItems&&G(he.data.__ezsheetItems)};return window.addEventListener("message",ee),()=>window.removeEventListener("message",ee)},[G]),r?qe?e.jsx("div",{className:`w-full bg-red-50 border border-red-200 rounded-lg p-4 ${y}`,children:e.jsx("p",{className:"text-sm text-red-600",children:qe})}):e.jsx("div",{className:`w-full bg-white border border-gray-200 rounded-xl overflow-hidden shadow-sm relative ${y}`,children:e.jsx("iframe",{ref:Ue,title:p,className:"w-full block bg-[#F7F5F1]",style:{height:`${v}px`,border:0},sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation allow-same-origin allow-downloads",loading:"lazy"})}):e.jsx("div",{className:`w-full flex items-center justify-center bg-gray-50 border border-gray-200 rounded-lg p-8 ${y}`,children:e.jsxs("div",{className:"text-center text-gray-500 text-sm",children:[e.jsx("div",{className:"text-2xl mb-2",children:"📊"}),e.jsx("p",{children:"No EzSheet content to preview"})]})})};function ci(r){if(r=String(r||"").trim(),!r)return null;if(/^<md>[\s\S]*<\/md>$/i.test(r))return{_raw:r,type:"md",md:r.replace(/^<md>[ \t]*\r?\n?/i,"").replace(/\r?\n?[ \t]*<\/md>$/i,""),w:420,h:520};const p=/^<!doctype\s+html/i.test(r)||/^<html\b/i.test(r)||/^<\/?(?:html|head|body|div|p|span|a|h[1-6]|ul|ol|li|table|tr|td|th|tbody|thead|tfoot|iframe|embed|object|video|audio|canvas|svg|button|form|input|select|textarea|label|style|script|link|meta|section|article|header|footer|nav|aside|main|figure|figcaption|code|pre|blockquote|b|strong|i|em|mark|del|ins|hr|br|img|picture|source|details|summary|dialog|template)\b/i.test(r)||/<\/?(?:div|iframe|p|span|h[1-6]|table|tr|td|th|script|style|svg|canvas|button|form|video|audio|ul|ol|li|section|article|header|footer|blockquote)\b[^>]*>/i.test(r)||/<([a-z][a-z0-9]*)\b[^>]*>[\s\S]*<\/\1>/i.test(r);if(p||r.startsWith("<")){if(r.match(/^<model\b/i)){const ke=_e=>(r.match(new RegExp("\\b"+_e+`=["']([^"']*)["']`,"i"))||[])[1]||"",H=ke("src").replace(/&amp;/g,"&"),W=ke("type").toLowerCase()||(H.match(/^data:model\/(gltf-binary|gltf\+json|stl|obj)/i)||[])[1]||"",me=W==="gltf-binary"?"glb":W==="gltf+json"?"gltf":W;if(me&&/^(glb|gltf|stl|obj)$/.test(me)&&H)return{_raw:r,type:"model",mdl:/^https?:\/\//i.test(H)?{u:H,e:me,n:ke("name")}:{d:H,e:me,n:ke("name")},w:380,h:285}}const q=r.match(/\bsrc=["']([^"']+)["']/i),n=((q==null?void 0:q[1])||"").replace(/&amp;/g,"&"),K=(n||r).match(/(?:youtube\.com\/(?:embed\/|watch\?v=|shorts\/|live\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);return K?{type:"youtube",id:K[1],url:n||`https://www.youtube.com/watch?v=${K[1]}`,w:340,h:220,_raw:r}:/^<iframe\b[^>]*>\s*<\/iframe>$/i.test(r)&&n?{type:"web",url:n,w:340,h:220,_raw:r}:{type:"html",html:r,w:520,h:720,_raw:r}}const y=r.match(/(?:youtube\.com\/(?:embed\/|watch\?v=|shorts\/|live\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(y)return{type:"youtube",id:y[1],url:r,w:340,h:220,_raw:r};let v=r,T=!1;if(/^https?:\/\//i.test(v)?T=!/\s/.test(v):!/\s/.test(v)&&/^[^\/\s]+\.[a-z]{2,}(\/|:|\?|$)/i.test(v)&&(v="https://"+v,T=!0),T)try{const _=new URL(v);if(_.protocol==="http:"||_.protocol==="https:")return _.protocol==="https:"&&/\.(glb|gltf|stl|obj)$/i.test(_.pathname)?{type:"model",mdl:{u:_.href,e:_.pathname.toLowerCase().replace(/^.*\./,""),n:decodeURIComponent(_.pathname.split("/").pop()||"")},w:380,h:285,_raw:r}:{type:"web",url:_.href,w:340,h:220,_raw:r}}catch{}return!p&&(/(^|\n) {0,3}#{1,6}[ \t]+\S+/m.test(r)||/(^|\n) {0,3}(`{3,}|~{3,})/.test(r)||/`[^`\n]+`/.test(r)||/(^|\n) {0,3}>\s*\S+/m.test(r)||/(^|\n) {0,3}
3342([-*+]|\d{1,9}[.)])[ \t]+\S+/m.test(r)||/\*\*[^*\n]+\*\*/.test(r)||/__[^_\n]+__/.test(r)||/\*[^*\n]+\*/.test(r)||/(^|[^\w])_[^_\n]+_(?!\w)/.test(r)||/~~[^~\n]+~~/.test(r)||/==[^=\n]+==/.test(r)||/!?\[[^\]\n]*\]\([^)\s]+\)/.test(r)||/(^|\n) {0,3}([-*_])(?:[ \t]*\1){2,}[ \t]*($|\n)/m.test(r)||/\|.+?\|\s*\n\s*\|? *[-:]+[-| :]*\|?/.test(r)||/\[[ xX]\]\s+/.test(r)||r.includes(`
3343`)&&!r.startsWith("<")||/\s{1,}/.test(r)&&!r.startsWith("<"))&&r.length<=6e4?{_raw:`<md>
3344${r}
3345</md>`,type:"md",md:r,w:420,h:520}:null}const ui={default:3,1024:2,640:1},mi=Ns("pk_live_51IyCo8Dpr0bpQPac24tix9UpShzoMw1uWsW3JvzcMrKVFnvUsXAnvBknJSPYucZCYSLT4Z0UVBeKx49jlYakdjIw00coa3YVdn"),xa=[{id:"kimi-k3",name:"Kimi K3",description:"2.8T params, native vision, 1M context, frontier intelligence",isNew:!0,type:"flagship"},{id:"gpt-4o",name:"GPT-4o",description:"OpenAI's most advanced multimodal model",isNew:!0,type:"flagship"},{id:"deepseek-chat",name:"DeepSeek Chat",description:"Advanced conversational AI with 128K context",isNew:!0,type:"flagship"},{id:"sonar-pro",name:"Sonar Pro",description:"Enhanced search capabilities with better accuracy",isNew:!0,type:"flagship"},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",description:"Latest preview version of Gemini 3 Flash with enhanced capabilities",isNew:!0,type:"flagship"}],ga=r=>!r||r.length===0?r:[...r].sort((p,y)=>{const v=p.position!==void 0&&p.position!==null?p.position:Number.MAX_SAFE_INTEGER,T=y.position!==void 0&&y.position!==null?y.position:Number.MAX_SAFE_INTEGER;if(v!==T)return v-T;const N=new Date(p.created_at).getTime(),_=new Date(y.created_at).getTime();return N-_});class _i extends js.Component{constructor(p){super(p),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(p,y){console.error("Error caught by boundary:",p,y)}render(){return this.state.hasError?this.props.fallback||e.jsx("div",{className:"w-8 h-8 rounded-full bg-[#22c55e] flex items-center justify-center",children:e.jsx(m,{icon:Ar,className:"w-4 h-4 text-white"})}):this.props.children}}const pi=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/svg+xml","application/pdf","video/mp4","video/webm","video/ogg","video/quicktime","video/x-msvideo","audio/mpeg","audio/mp3","audio/wav","audio/ogg","audio/webm","audio/x-wav","text/html","application/xhtml+xml"],fi=[".jpg",".jpeg",".png",".gif",".webp",".bmp",".svg",".pdf",".mp4",".webm",".ogg",".mov",".avi",".mp3",".wav",".ogg",".m4a",".html",".htm"],Er=()=>[".md",".markdown",".zip",".rar",".7z",".tar",".gz",".bz2",".exe",".msi",".dmg",".bat",".sh",".cmd",".apk",".ipa",".iso",".img",".torrent",".psd",".ai",".eps",".csv",".xls",".xlsx",".ppt",".pptx",".json",".xml",".yaml",".yml",".sql",".db",".sqlite",".log",".tmp",".temp",".ini",".cfg",".conf",".config",".key",".pem",".crt",".p12",".ttf",".otf",".woff",".woff2",".eot",".ico",".cur",".webp",".bmp",".tiff",".tif",".avi",".mov",".wmv",".flv",".mkv",".flac",".aac",".wma",".numbers",".pages",".keynote",".cdr",".svg"],hi=({message:r,type:p,onClose:y})=>{s.useEffect(()=>{const N=setTimeout(()=>{y()},5e3);return()=>clearTimeout(N)},[y]);const v={success:"bg-green-50 border-green-200 text-green-800",error:"bg-red-50 border-red-200 text-red-800",info:"bg-blue-50 border-blue-200 text-blue-800",warning:"bg-yellow-50 border-yellow-200 text-yellow-800"},T={success:e.jsx("svg",{className:"w-5 h-5 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:e.jsx("svg",{className:"w-5 h-5 text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:e.jsx("svg",{className:"w-5 h-5 text-yellow-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})};return e.jsx("div",{className:`fixed top-20 right-4 z-[200] p-4 rounded-xl border shadow-lg ${v[p]} animate-slide-left max-w-md`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:T[p]}),e.jsx("div",{className:"flex-1 text-sm font-medium break-words",children:r}),e.jsx("button",{onClick:y,className:"flex-shrink-0 opacity-50 hover:opacity-100 transition-opacity",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})},wn=r=>{if(typeof document>"u")return r;const p=document.createElement("div");return p.innerHTML=r,p.textContent||p.innerText||""},Ft=r=>{if(r===0)return"0 Bytes";const p=1024,y=["Bytes","KB","MB","GB"],v=Math.floor(Math.log(r)/Math.log(p));return parseFloat((r/Math.pow(p,v)).toFixed(2))+" "+y[v]},xi=(r,p)=>r.startsWith("image/")?zr:r==="application/pdf"?va:r.includes("word")||p.match(/doc|docx/)?Is:r.includes("excel")||r.includes("spreadsheet")||p.match(/xls|xlsx|csv/)?Ds:r.includes("powerpoint")||r.includes("presentation")||p.match(/ppt|pptx/)?Os:r.includes("video/")?wa:r.includes("audio/")?ka:r.includes("zip")||r.includes("compressed")||p.match(/zip|rar|7z|tar|gz/)?Hs:r.includes("json")||r.includes("xml")||r.includes("html")||r.includes("javascript")||p.match(/js|ts|py|java|cpp|php/)?ja:Ca,gi=r=>[/^#{1,6}\s+/m,/\*\*.+\*\*/,/_{2}.+_{2}/,/\*.+\*/,/\[.+\]\(.+\)/,/^- /,/^\d+\. /,/```/,/`[^`]+`/,/>\s/,/!\[.*\]\(.*\)/,/^\|/,/^---$/].some(v=>v.test(r)),Rt={backgroundColor:"transparent",color:"#1f2937",fontFamily:'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif',fontSize:"16px",lineHeight:"1.7",wordBreak:"break-word",overflowWrap:"break-word"},Nr=r=>{if(r.size>100*1024*1024)return{valid:!1,error:`❌ File size exceeds 100MB limit. Current size: ${Ft(r.size)}. Maximum allowed: 100MB.`};if(!pi.includes(r.type)){const T="."+r.name.toLowerCase().split(".").pop();return Er().includes(T)?{valid:!1,error:`❌ File type "${T}" is not supported. Please upload images (JPG, PNG, GIF, WEBP), PDF, video (MP4, WEBM, OGG), audio (MP3, WAV, OGG), or HTML files only. Max size: 100MB.`}:{valid:!1,error:`❌ File type "${r.type||"unknown"}" is not supported. Please upload images (JPG, PNG, GIF, WEBP), PDF, video (MP4, WEBM, OGG), audio (MP3, WAV, OGG), or HTML files only. Max size: 100MB.`}}const p=r.name.toLowerCase();if(!fi.some(v=>p.endsWith(v))){const v="."+p.split(".").pop();return Er().includes(v)?{valid:!1,error:`❌ File extension "${v}" is not supported. Please upload images (JPG, PNG, GIF, WEBP), PDF, video (MP4, WEBM, OGG), audio (MP3, WAV, OGG), or HTML files only. Max size: 100MB.`}:{valid:!1,error:`❌ File extension "${v}" is not supported. Please upload images (JPG, PNG, GIF, WEBP), PDF, video (MP4, WEBM, OGG), audio (MP3, WAV, OGG), or HTML files only. Max size: 100MB.`}}return{valid:!0}},bi=({price:r,email:p,clientSecret:y,onSuccess:v,onBack:T,onError:N,tooltips:_})=>{const q=Ss(),n=Ms(),[K,ke]=s.useState(!1),[H,W]=s.useState(""),[me,_e]=s.useState(!1),X=async ie=>{if(ie.preventDefault(),W(""),!q||!n){W("Payment system not ready. Please try again.");return}ke(!0);try{const{error:re}=await n.submit();if(re){W(re.message||"Payment form validation failed");return}const{error:be,paymentIntent:F}=await q.confirmPayment({elements:n,confirmParams:{return_url:`${window.location.origin}/payment-success`,receipt_email:p,payment_method_data:{billing_details:{email:p}}},clientSecret:y,redirect:"if_required"});if(be){W(be.message||"Payment failed");return}if(!F){W("Payment processing failed. No payment intent received.");return}switch(F.status){case"succeeded":v();break;case"requires_action":W("Payment requires additional authentication. Please complete the verification.");break;case"processing":W("Payment is processing. Please wait for confirmation.");break;default:W(`Payment failed. Status: ${F.status}`)}}catch(re){const be=re instanceof Error?re.message:"Payment processing failed. Please try again.";W(be)}finally{ke(!1)}};return e.jsxs("form",{onSubmit:X,children:[H&&e.jsxs("div",{className:"mb-4 p-3 bg-red-500/90 text-white rounded-lg flex items-center gap-2",children:[e.jsx(m,{icon:bt}),e.jsx("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(_==null?void 0:_.ai_search_view_error_notification)||"Error notification",children:H})]}),e.jsxs("div",{className:"mt-4 text-sm text-gray-300",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{children:"Email:"}),e.jsx("span",{className:"text-yellow-400",children:p})]}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{children:"Amount:"}),e.jsxs("span",{className:"text-yellow-400",children:["US$",r.toFixed(2)]})]})]}),e.jsx("div",{className:"mt-6 space-y-4",children:e.jsx(As,{options:{layout:"tabs",fields:{billingDetails:{email:"auto"}}},onReady:()=>_e(!0)})}),e.jsx("div",{className:"mt-6",children:e.jsx("button",{type:"submit",disabled:K||!q||!me,className:`w-full bg-yellow-400 text-black font-bold py-3 px-4 roun
3345ded-full hover:bg-yellow-500 transition-colors ${K||!q||!me?"opacity-70 cursor-not-allowed":""}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":q?me?K?"Processing payment...":`Complete payment of US${r.toFixed(2)}`:"Payment form loading...":"Payment system loading...",children:K?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin mr-2"}),(_==null?void 0:_.ai_search_view_processing)||"Processing..."]}):`Pay US${r.toFixed(2)}`})}),e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("button",{type:"button",onClick:T,className:"text-sm text-yellow-400 hover:underline","data-tooltip-id":"main-tooltip","data-tooltip-content":(_==null?void 0:_.ai_search_view_cancel)||"Go back to email entry",children:"Back to email"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"Payment secured by STRIPE. You'll be redirected after payment."})]})]})};function Ri({search:r,conversation_messages:p,message_count:y,share_url:v,related_searches:T,domains:N=[],checkDomainUrl:_="/check-handle-availability",checkStandardDomainUrl:q="/ezai/check-ezpressstandard-domain",tooltips:n={},tokenInfo:K,promoprice:ke=0,aiSettings:H,auth:W={user:null},guestInteractionDisabled:me=!1,requiresLogin:_e=!1,needsPrivateAccess:X=!1,conversationStatus:ie="public",hasPrivateAccess:re=!1,codepage:be="",initial_comments:F=[]}){var aa,sa;const[oe,G]=s.useState(F||[]),[Ue,qe]=s.useState(!1),[Qe,We]=s.useState(!1),[De,ee]=s.useState(!1),[he,A]=s.useState(!1),[pe,U]=s.useState("share"),[S,se]=s.useState(""),[ye,Ne]=s.useState(!1),[M,Se]=s.useState([]),[Me,h]=s.useState(r.conversation_title),[ge,le]=s.useState(r.conversation_cost),[xe,g]=s.useState(r.conversation_tokens),[je,de]=s.useState(!1),[yt,Vt]=s.useState(null),[jn,sn]=s.useState(null),[Oe,on]=s.useState(!1),[Ot,Cn]=s.useState(!1),[Nn,ze]=s.useState(""),[Sn,vt]=s.useState(""),[wt,it]=s.useState(!1),[Tr,kt]=s.useState(!0),[Xn,Xt]=s.useState(""),[Ke,Qn]=s.useState(!1),[Qt,Mn]=s.useState(!1),[ln,jt]=s.useState(null),[Ct,An]=s.useState(!1),[Re,ot]=s.useState(!1),[ve,En]=s.useState("domain"),[Z,Ht]=s.useState(""),[ce,dn]=s.useState(""),[lt,Kn]=s.useState(N),[P,Ge]=s.useState({checking:!1,available:null,message:""}),[dt,Kt]=s.useState(!1),[Je,w]=s.useState(""),[ct,Jt]=s.useState(""),[Ze,Ut]=s.useState(""),[qt,$e]=s.useState(!1),[Ce,f]=s.useState({valid:null,message:"",discount:0}),[I,j]=s.useState(""),[R,D]=s.useState(null),[J,ae]=s.useState(!1),[te,Q]=s.useState(1),[cn,He]=s.useState(""),[Ea,Jn]=s.useState(""),[fe,zn]=s.useState(""),[et,Tn]=s.useState(""),[Wt,Pn]=s.useState(""),[Fe,Ln]=s.useState(null),[$t,tt]=s.useState(!1),[un,en]=s.useState({success:!1,message:"",url:""}),[za,Pr]=s.useState(!1),[Ta,Pa]=s.useState(0),[$n,Bn]=s.useState(!1),[Lr,Nt]=s.useState(!1),$=s.useCallback(async()=>{var t,a,i;if(!(!(r!=null&&r.conversation_id)&&!(r!=null&&r.id)&&!(r!=null&&r.slug))){qe(!0);try{const l={};r.conversation_id?l.conversation_id=r.conversation_id:r.id?l.message_id=r.id:r.slug&&(l.message_slug=r.slug);const o=await B.get("/comments",{params:l});(t=o.data)!=null&&t.success&&Array.isArray((a=o.data)==null?void 0:a.data)?G(o.data.data):Array.isArray((i=o.data)==null?void 0:i.comments)?G(o.data.comments):Array.isArray(o.data)&&G(o.data)}catch(l){console.warn("Failed to load comments:",l)}finally{qe(!1)}}},[r==null?void 0:r.conversation_id,r==null?void 0:r.id,r==null?void 0:r.slug]);s.useEffect(()=>{$()},[$]);const La=async t=>{var a,i,l,o;if(window.confirm("Are you sure you want to delete this comment?"))try{const u=await B.delete(`/comments/${t}`);(a=u.data)!=null&&a.success?(G(d=>d.filter(c=>c.id!==t&&c.parent_id!==t)),b("Comment deleted successfully","success")):b(((i=u.data)==null?void 0:i.message)||"Failed to delete comment","error")}catch(u){console.error("Failed to delete comment:",u),b(((o=(l=u==null?void 0:u.response)==null?void 0:l.data)==null?void 0:o.message)||"Failed to delete comment","error")}},[er,St]=s.useState(!1),[tr,Ba]=s.useState(!1),[nr,_n]=s.useState(""),[Rn,Br]=s.useState("social"),[Fn,tn]=s.useState("composer"),[In,mn]=s.useState(""),[yi,_r]=s.useState(!1),[we,Dn]=s.useState([]),[rr,Mt]=s.useState(!1),[Rr,Fr]=s.useState(!1),[Ir,nt]=s.useState(null),[_a,Te]=s.useState(!1),[Ra,vi]=s.useState("ai"),[pn,On]=s.useState(!1),[Pe,Hn]=s.useState(""),[ut,Gt]=s.useState(""),[Dr,fn]=s.useState("request"),[ar,Or]=s.useState(!1),[sr,Hr]=s.useState(!1),[wi,Ur]=s.useState(!1),[qr,Un]=s.useState(""),[hn,Wr]=s.useState({show:!1,message:"",type:"info"}),[ir,Fa]=s.useState([]),[Ia,Gr]=s.useState(!1),Zr=s.useRef(!1),nn=s.useRef([]),Yr=s.useRef(""),At=s.useRef(!1),[rn,Da]=s.useState({id:"kimi-k3",name:"Kimi K3",description:"2.8T params, native vision, 1M context, frontier intelligence",isNew:!0,t
3345ype:"flagship"}),[or,lr]=s.useState(!1),dr=s.useRef(null),[Et,cr]=s.useState("markdown"),[Oa,qn]=s.useState(!1),Vr=s.useRef(null),Ha=s.useRef(null),Ua=s.useRef(null),ur=s.useRef(null),Ae=s.useRef(null),E=(W==null?void 0:W.user)||null,Le=s.useMemo(()=>E?!0:!me,[E,me]),rt=s.useCallback(t=>{let a=t;!Ke&&!Qt&&(a=a.filter(i=>i.status!=="hidden")),Se(ga(a))},[Ke,Qt]),mt=s.useCallback(t=>{if(!t)return[];if(Array.isArray(t))return t.filter(Boolean).map(a=>String(a).replace(/^#+/,"").trim()).filter(Boolean);if(typeof t=="string"&&t.trim()){try{const a=JSON.parse(t);if(Array.isArray(a))return a.filter(Boolean).map(i=>String(i).replace(/^#+/,"").trim()).filter(Boolean)}catch{}return t.split(/[\s,]+/).map(a=>a.replace(/^#+/,"").trim()).filter(Boolean)}return[]},[]),pt=s.useMemo(()=>{const t=new Set;return mt(r==null?void 0:r.hashtag).forEach(a=>t.add(a)),r!=null&&r.hashtag_display&&mt(r.hashtag_display).forEach(a=>t.add(a)),M&&Array.isArray(M)&&M.forEach(a=>{mt(a.hashtag).forEach(i=>t.add(i)),a.hashtag_display&&mt(a.hashtag_display).forEac
3345h(i=>t.add(i))}),Array.from(t)},[r==null?void 0:r.hashtag,r==null?void 0:r.hashtag_display,M,mt]);s.useEffect(()=>()=>{document.querySelectorAll("img").forEach(a=>{a.onerror=null})},[]);const b=(t,a="error")=>{Wr({show:!0,message:t,type:a})};s.useCallback(()=>{const t=r==null?void 0:r.landing_page_url;t&&t.trim()!==""&&(window.open(t,"_blank"),b(`Opening landing page: ${t}`,"info"))},[r==null?void 0:r.landing_page_url]),s.useEffect(()=>{const t=r==null?void 0:r.landing_page_url;if(t&&t.trim()!==""&&!Zr.current){Zr.current=!0;const a=setTimeout(()=>{window.open(t,"_blank"),b(`Landing page opened in new tab: ${t}`,"info")},500);return()=>clearTimeout(a)}},[r==null?void 0:r.landing_page_url]);const Ye=async()=>{Gr(!0);try{const t=await B.get("/ai/pinned-conversations-all");t.data.success&&Fa(t.data.data)}catch(t){console.error("Error fetching pinned conversations:",t)}finally{Gr(!1)}};s.useEffect(()=>{pn&&(E!=null&&E.email)&&Hn(E.email)},[pn,E==null?void 0:E.email]),s.useEffect(()=>{function t(a){dr.current&&!dr.current.contains(a.target)&&lr(!1)}return document.addEventListener("mousedown",t),()=>{document.removeEventListener("mousedown",t)}},[]),s.useEffect(()=>{Ye()},[]);const z=s.useMemo(()=>H?E?H.user_ai_enabled?H.user_char_limit:0:H.guest_ai_enabled?H.guest_char_limit:0:E?2e3:300,[E,H]),Wn=s.useMemo(()=>H?E?!H.user_ai_enabled:!H.guest_ai_enabled:!1,[E,H]);s.useEffect(()=>{lt&&lt.length>0&&dn(lt[0].domain)},[lt]),s.useEffect(()=>{const t=p.find(u=>!u.parent_id)||p[0],a=(t==null?void 0:t.status)||r.status||"public",i=(E==null?void 0:E.id)||"guest",l=`${r.slug}|${a}|${i}`;if(At.current||Yr.current===l&&wt)return;Yr.current=l,At.current=!0,(async()=>{var c;kt(!0);let u=!1;E&&(u=p.some(x=>x.user_id===E.id)||((c=r.user)==null?void 0:c.id)===E.id),Qn(u);let d=!1;if(a==="private")try{(await B.get("/searchai/private/check-access",{params:{slug:r.slug}})).data.has_access&&(d=!0)}catch(x){console.error("Error checking private access:",x)}if(d){it(!0),Mn(!0),kt(!1),At.current=!1;return}if(a==="public"){it(!0),kt(!1),At.current=!1;return}if(a==="private"){if(u){it(!0),kt(!1),At.current=!1;return}it(!1),On(!0),Xt("This is a private conversation. Please enter your email to get an access code."),kt(!1),At.current=!1;return}if(a==="hidden"){u?it(!0):(it(!1),Xt((n==null?void 0:n.ai_search_view_hidden_conversation)||"This conversation has been hidden and is not available for viewing.")),kt(!1),At.current=!1;return}it(!0),kt(!1),At.current=!1})()},[r.slug,r.status,(aa=r.user)==null?void 0:aa.id,E==null?void 0:E.id,n]),s.useEffect(()=>{let t=p;!Ke&&!Qt&&(t=p.filter(a=>a.status!=="hidden")),Se(ga(t))},[p,Ke,Qt]),s.useEffect(()=>{const t=p.filter(a=>a.content_type==="upload");t.length>0&&console.log("Upload messages found:",t.length)},[p]),s.useEffect(()=>{const t=async()=>{var i;if(fe&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(fe))try{const l=await B.post("/ezai/check-user-exists",{email:fe},{headers:{"X-CSRF-TOKEN":((i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.getAttribute("content"))||""}});Ln(l.data.exists)}catch(l){console.error("Error checking user existence:",l),Ln(null)}else Ln(null)},a=setTimeout(()=>{t()},500);return()=>clearTimeout(a)},[fe]);const qa=s.useCallback(async t=>{var a;if(!t||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){Nt(!1),St(!1);return}Bn(!0),Nt(!1),St(!1);try{const i=await B.post("/searchai/check-email-ownership",{email:t,slug:r.id},{headers:{"X-CSRF-TOKEN":((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||""}});if(i.data.success)if(Nt(i.data.is_owner),St(!0),i.data.is_owner)w(""),b("Email verified! You are the owner of this conversation.","success");else{const l="This email doesn't belong to this conversation. You can not purchase the domain.";w(l),b(l,"warning");return}else St(!0),Nt(!1)}catch(i){console.error("Error checking email ownership:",i),St(!0),Nt(!1);return}finally{Bn(!1)}},[r.slug]);s.useEffect(()=>{tr&&ur.current&&ur.current.focus()},[tr]),s.useEffect(()=>{if(Je){const t=setTimeout(()=>{w("")},6e4);return()=>clearTimeout(t)}},[Je]),s.useEffect(()=>{if(ct){const t=setTimeout(()=>{Jt("")},6e4);return()=>clearTimeout(t)}},[ct]),s.useEffect(()=>{if(Z.trim()&&ce&&Re){const t=setTimeout(()=>{mr()},800);return()=>clearTimeout(t)}},[Z,ce,ve,Re]),s.useEffect(()=>{z===0?(ze((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is currently disabled"),vt((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled. Please try again later.")):S.length>z?(ze(`Character limit exceeded (${S.length}/${z})`),vt(((n==null?void 0:n.ai_search_view_question_too_long)||"Maximum {max} characters allowed. You have {count} too many.").replace("{max}",z.toString()).replace("{count}",(S.length-z).toString()))):(ze(""),vt(""))},[S,z,n]);const Wa=async()=>
3345{if(!Ze.trim()||!Z.trim()){f({valid:!1,message:"Please enter a coupon code and brand name",discount:0,domain_discount:0});return}try{f({valid:null,message:"Validating coupon...",discount:0,domain_discount:0});const t=await B.post("/ezai/couponcodecustomdomain",{couponcode:Ze.trim(),domainurl:Z.trim(),type:ve});if(t.data.valid){const a=t.data.offprice!==void 0?t.data.offprice:t.data.original_price,i=t.data.original_price,l=wn(t.data.title||"Coupon applied successfully!");f({valid:!0,message:l,discount:Number(a),domain_discount:Number(a)}),Pa(o=>o+1)}else{const a=wn(t.data.title||"Invalid coupon code");f({valid:!1,message:a,discount:0,domain_discount:0})}}catch(t){console.error("Error validating coupon:",t),f({valid:!1,message:"Error validating coupon. Please try again.",discount:0,domain_discount:0})}};s.useEffect(()=>{if(Ze.trim()&&Z.trim()&&Re){const t=setTimeout(()=>{Wa()},800);return()=>clearTimeout(t)}else f({valid:null,message:"",discount:0,domain_discount:0})},[Ze,Z,Re,ve]);const[zt,Xr]=s.useState(null),at=s.useRef(null),an=s.useRef(null),ft=s.useCallback(()=>{at.current!==null&&(cancelAnimationFrame(at.current),at.current=null),an.current=null,Xr(null)},[]),Qr=s.useCallback(t=>{if(zt===t){ft();return}at.current!==null&&(cancelAnimationFrame(at.current),at.current=null),an.current=null,Xr(t);const a=240,i=l=>{an.current===null&&(an.current=l);const o=Math.min(l-an.current,50);an.current=l;const u=a*o/1e3,d=window.scrollY||document.documentElement.scrollTop,c=Math.max(0,document.documentElement.scrollHeight-window.innerHeight);if(t==="up"){if(d<=0){ft();return}const x=Math.max(0,d-u);if(window.scrollTo(0,x),x<=0){ft();return}}else{if(d>=c-1){ft();return}const x=Math.min(c,d+u);if(window.scrollTo(0,x),x>=c-1){ft();return}}at.current=requestAnimationFrame(i)};at.current=requestAnimationFrame(i)},[zt,ft]);s.useEffect(()=>{if(!zt)return;const t=()=>{ft()};return window.addEventListener("wheel",t,{passive:!0}),window.addEventListener("touchmove",t,{passive:!0}),window.addEventListener("keydown",t,{passive:!0}),()=>{window.removeEventListener("wheel",t),window.removeEventListener("touchmove",t),window.removeEventListener("keydown",t)}},[zt,ft]),s.useEffect(()=>()=>{at.current!==null&&cancelAnimationFrame(at.current)},[]);const Tt=()=>{var t;ft(),(t=Vr.current)==null||t.scrollIntoView({behavior:"smooth"})},Kr=t=>{const a=document.getElementById(`message-${t}`);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),a.classList.add("bg-yellow-50","transition-colors","duration-1000"),setTimeout(()=>{a.classList.remove("bg-yellow-50")},2e3))},Ga=()=>{navigator.clipboard.writeText(v),We(!0),setTimeout(()=>{We(!1)},2e3)},Gn=(t,a)=>{navigator.clipboard.writeText(a),jt(t),b("Copied to clipboard!","success"),setTimeout(()=>{jt(null)},2e3)},Za=()=>{const t=M.filter(a=>a.message_role!=="system").map(a=>{const i=a.message_role==="user",l=i?"User":"AI Assistant",o=i?a.query:a.response,u=ht(a.created_at);let d="";return a.content_type==="upload"?d="[File Upload] ":a.content_type==="comment"?d="[Comment] ":a.content_type==="conversationcomment"?d="[Conversation Comment] ":a.content_type==="social"||a.content_type==="social_media"?d="[Social Media] ":a.content_type==="embed"&&(d="[Embed] "),`${l} (${u})${d?" - "+d:""}:
3346${o}
3347`}).join(`
3348---
3349
3350`);navigator.clipboard.writeText(t),An(!0),b("Entire conversation copied to clipboard!","success"),setTimeout(()=>{An(!1)},2e3)},Be=s.useMemo(()=>{let a=P.promoPrice&&P.promoPrice>0?Number(P.promoPrice)||0:Number(P.price)||0;return Ce.valid&&Ce.domain_discount!==void 0&&(a=Number(Ce.domain_discount)),a>0&&a<1&&(a=1),{domainPrice:Number(a),totalPrice:Number(a)}},[P,Ce,Ta]),Ya=t=>{const a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return t?a.test(t)?"":"Please enter a valid email address":(n==null?void 0:n.ai_search_view_email_required)||"Email is required"},Zn=()=>{Ba(!1),zn(""),_n("")},Va=async t=>{var i,l,o,u,d;t.preventDefault();const a=Ya(fe);if(a){_n(a);return}de(!0),_n("");try{const c=await B.post("/theme/create",{slug:r.slug,url:window.location.href,title:Me,email:fe},{headers:{"X-CSRF-TOKEN":((i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.getAttribute("content"))||"",Accept:"application/json","Content-Type":"application/json"}});if(c.data.success){Zn(),sn(c.data.theme);const x=e.jsxs("span",{className:"flex items-center gap-4",children:["Theme saved successfully!"," ",e.jsxs("span",{className:"inline-flex items-center gap-2 bg-gray-900/70 border border-gray-700 rounded-xl px-3 py-2 hover:shadow-lg hover:border-yellow-400/50 transition-all",children:[e.jsx("span",{className:"text-white text-md font-medium",children:((l=c.data.theme)==null?void 0:l.title)||"Untitled Theme"}),e.jsxs("span",{className:"text-md text-gray-400",children:["ID: ",((o=c.data.theme)==null?void 0:o.unique_id)||"N/A"]}),e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-md font-medium bg-yellow-400/20 text-yellow-300",children:["EZ$ ",((u=c.data.theme)==null?void 0:u.price)||"0"]}),e.jsx("a",{href:`https://ez.wiki/${((d=c.data.theme)==null?void 0:d.unique_id)||"#"}`,target:"_blank",rel:"noopener noreferrer",className:"px-2 py-0.5 text-md bg-blue-600 text-white rounded-md hover:bg-blue-500 transition-colors",children:"Preview"})]})]});Vt(x)}else alert(c.data.message||"Failed to save theme")}catch(c){console.error("Error saving theme:",c),B.isAxiosError(c)&&c.response?alert(c.response.data.message||"An error occurred while saving the theme"):alert("An error occurred. Please try again.")}finally{de(!1)}},Xa=(t,a)=>{var i,l;if(a&&/^\d$/.test(a)){const o=ut.split("");o[t]=a,Gt(o.join("")),t<3&&((i=nn.current[t+1])==null||i.focus())}else if(!a){const o=ut.split("");o[t]="",Gt(o.join("")),t>0&&((l=nn.current[t-1])==null||l.focus())}},Qa=(t,a)=>{var i;a.key==="Backspace"&&!ut[t]&&t>0&&((i=nn.current[t-1])==null||i.focus()),a.key==="Enter"&&$r()},Jr=async()=>{var t,a;if(!Pe||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Pe)){w("Please enter a valid email address");return}Or(!0),w("");try{const i=await B.post("/searchai/private/request-access",{slug:r.slug,email:Pe});
3350i.data.success?(Un(Pe),Ur(!0),fn("verify"),Jt("Access code sent! Please check your email."),Gt(""),setTimeout(()=>{var l;(l=nn.current[0])==null||l.focus()},100)):w(i.data.message)}catch(i){(a=(t=i.response)==null?void 0:t.data)!=null&&a.message?w(i.response.data.message):w("Failed to request access. Please try again.")}finally{Or(!1)}},$r=async()=>{var t,a;if(!ut||ut.length!==4){w("Please enter a valid 4-digit access code");return}Hr(!0),w("");try{const i=await B.post("/searchai/private/verify-access",{slug:r.slug,access_number:ut,email:qr});i.data.success?(On(!1),window.location.href=i.data.conversation_url):w(i.data.message)}catch(i){(a=(t=i.response)==null?void 0:t.data)!=null&&a.message?w(i.response.data.message):w("Invalid access code. Please try again.")}finally{Hr(!1)}},ea=()=>{On(!1),Hn(""),Gt(""),fn("request"),Ur(!1),Un(""),w("")},Ka=()=>{ot(!0),Ht(""),Ge({checking:!1,available:null,message:""}),Ut(""),f({valid:null,message:"",discount:0,domain_discount:0}),$e(!1),en({success:!1,message:"",url:""}),w(""),Jt("")},Ja=()=>{ot(!1),Ht(""),Ge({checking:!1,available:null,message:""}),Ut(""),f({valid:null,message:"",discount:0,domain_discount:0}),$e(!1),en({success:!1,message:"",url:""}),w(""),Jt(""),ae(!1),Q(1),He(""),Jn(""),D(null),tt(!1),zn(""),Tn(""),Pn(""),Ln(null),Nt(!1),St(!1),Bn(!1)},$a=t=>{En(t),Ge({checking:!1,available:null,message:""}),$e(!1)},mr=async()=>{var a,i;if(!Z.trim()||!ce){Ge({checking:!1,available:!1,message:"Please enter a brand name and select a domain"});return}const t=`${Z.trim()}-${ce}-${ve}`;j(t),Kt(!0),Ge({checking:!0,available:null,message:(n==null?void 0:n.ai_search_view_checking)||"Checking availability..."});try{const l=ve==="handle"?_:"/ezai/check-ezpressstandard-domain",o=await B.post(l,{handle:Z.trim(),domain:ce});en({success:!1,message:"",url:""});const u=o.data.price||0,d=o.data.promoPrice||0,c=o.data.charCount||0;Ge({checking:!1,available:o.data.available,message:o.data.message,price:Number(u),promoPrice:Number(d),charCount:Number(c)})}catch(l){Ge({checking:!1,available:!1,message:((i=(a=l.response)==null?void 0:a.data)==null?void 0:i.message)||"Error checking availability",price:0,promoPrice:0,charCount:0})}finally{Kt(!1)}},es=async()=>{var a,i,l,o,u;if(w(""),!fe){w("Please enter your email address"),b("Please enter your email address","error");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(fe)){w("Please enter a valid email address"),b("Please enter a valid email address","error");return}if(Fe===null){w("Checking user account..."),b("Checking user account...","info");return}if(Fe===!0)try{const d=await B.post("/searchai/check-email-ownership",{email:fe,slug:r.id},{headers:{"X-CSRF-TOKEN":((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||""}});if(d.data.success&&!d.data.is_owner){b("Note: This email doesn't match the conversation owner. You can not purchase the domain.","warning");return}}catch(d){console.error("Error checking ownership:",d);return}if(!Fe){if(!et){w("Please enter a password"),b("Please enter a password","error");return}if(et.length<8){w("Password must be at least 8 characters long"),b("Password must be at least 8 characters long","error");return}if(!Wt){w("Please confirm your password"),b("Please confirm your password","error");return}if(et!==Wt){w("Passwords do not match"),b("Passwords do not match","error");return}}let t=Number(Be.totalPrice);if(t>0&&t<1&&(t=1),t===0){tt(!0),w("");try{const d=await B.post("/ezai/free-purchase",{email:fe,password:Fe?void 0:et,custom_handle:Z.trim(),domain:ce,type:ve,coupon_code:Ze,slug:r.slug,slug_id:r.id,url:window.location.href,title:Me,view_mode:"ai"},{headers:{"X-CSRF-TOKEN":((i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.getAttribute("content"))||""}});if(d.data.success){const c=ve==="handle"?`https://${ce}/${Z.trim()}`:`https://${Z.trim()}.${ce}`;en({success:!0,message:"Purchase successful! Your new URL: ",url:c}),b(`Purchase successful! Your new URL: ${c}`,"success"),ae(!1),D(null),w(""),setTimeout(()=>{Ht(""),Ge({checking:!1,available:null,message:""}),Ut(""),f({valid:null,message:"",discount:0,domain_discount:0}),$e(!1),Tn(""),Pn("")},6e4)}else{const c=d.data.error||d.data.message||"Free purchase failed";w(c),b(c,"error")}}catch(d){console.error("Free purchase error:",d);let c="Failed to process free purchase";if(B.isAxiosError(d))if(d.response){const x=d.response.data;c=(x==null?void 0:x.error)||(x==null?void 0:x.message)||`Error ${d.response.status}: ${d.response.statusText}`}else d.request?c="No response from server. Please check your connection.":c=d.message||"Failed to process free purchase";else d instanceof Error&&(c=d.message);w(c),b(c,"error")}finally{tt(!1)}return}if(t<1&&t!==0){w("Minimum payment amount is $1"),b("Minimum payment amount is $1","error");return}tt(!0),w("");try{const c=await B.post("/ezai/initiate-domain-homepayment",{price:Number(Be.domainPrice),email:fe,password:Fe?void 0:et,custom_handle:Z.trim(),domain:ce,promo_price:Number(t),coupon_code:Ze,selling_price:0,payment_method:"usd",funnelId:0,view_mode:"ai"},{headers:{"X-CSRF-TOKEN":((l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"))||""}});if(c.data.clientSecret)He(c.data.clientSecret),Jn(c.data.payment_intent_id),Q(2),tt(!1);else throw new Error("No client secret received from payment service")}catch(d){if(tt(!1),B.isAxiosError(d)){const c=((u=(o=d.response)==null?void 0:o.data)==null?void 0:u.error)||"Failed to initialize payment";w(c),b(c,"error")}else{const c="Failed to connect to payment service";w(c),b(c,"error")}}},ts=async()=>{var t,a,i;tt(!0),w("");try{const o=await B.post("/ezai/home-domain-handle-success",{payment_intent_id:Ea,slug:r.slug,slug_id:r.id,url:window.location.href,title:Me,view_mode:"ai"},{headers:{"X-CSRF-TOKEN":((t=document.querySelector('meta[name="csrf-token"]'))==null?void 0:t.getAttribute("content"))||""}});if(o.data.success){const u=ve==="handle"?`https://${ce}/${Z.trim()}`:`https://${Z.trim()}.${ce}`;en({success:!0,message:"Payment successful! Your new URL: ",url:u}),b(`Payment successful! Your new URL: ${u}`,"success"),ae(!1),D(null),Q(1),He(""),Jn(""),w(""),tt(!1),setTimeout(()=>{Ht(""),Ge({checking:!1,available:null,message:""}),Ut(""),f({valid:null,message:"",discount:0,domain_discount:0}),$e(!1),Tn(""),Pn(""),ot(!1)},3e3)}else{tt(!1);const u=o.data.error||"Payment verification failed";w(u),b(u,"error")}}catch(l){tt(!1);const o=((i=(a=l.response)==null?void 0:a.data)==null?void 0:i.error)||"Payment verification failed";w(o),b(o,"error")}},ns=()=>{const t=`${Z.trim()}-${ce}-${ve}`;if(!Z.trim()||!ce||P.available===!1||I!==t){w("Please check availability first"),b("Please check availability first","error");return}if(!qt){w("Please agree to the terms and conditions"),b("Please agree to the terms and conditions","error");return}D(ve),ae(!0)},rs=async()=>{Kt(!0);try{console.log("Processing purchase with view mode:",Ra)}catch(t){console.error("Error processing purchase:",t)}finally{Kt(!1),Pr(!1)}},pr=t=>{const a=Array.from(t);if(a.length===0)return;nt(null);const i=[],l=[];
3350if(a.forEach(o=>{if(o.size>100*1024*1024){l.push(`❌ "${o.name}" exceeds 100MB limit (${Ft(o.size)}).`);return}const u=Nr(o);if(!u.valid){l.push(`❌ "${o.name}": ${u.error||"Invalid file type"}`);return}i.push(o)}),l.length>0){const o=l.join(`
3351`);nt(o),b(o,"error")}if(i.length===0){Ae.current&&(Ae.current.value="");return}Promise.all(i.map(o=>new Promise(u=>{const d=new FileReader;d.onload=c=>{var x;u({name:o.name,size:o.size,type:o.type,data:((x=c.target)==null?void 0:x.result)||"",file:o})},d.onerror=()=>{u({name:o.name,size:o.size,type:o.type,data:"",file:o})},d.readAsDataURL(o)}))).then(o=>{Dn(u=>{const d=new Set(u.map(x=>`${x.name}_${x.size}`)),c=o.filter(x=>!d.has(`${x.name}_${x.size}`));return[...u,...c]}),nt(null)})},as=async()=>{var a,i;if(!Le){Te(!0);return}if(!we||we.length===0)return;nt(null);for(const l of we)if(l.file){const o=Nr(l.file);if(!o.valid){const u=o.error||"Invalid file type";nt(u),b(u,"error");return}}Fr(!0);const t=new FormData;we.forEach(l=>{l.file&&t.append("files[]",l.file)}),(a=we[0])!=null&&a.file&&t.append("file",we[0].file),t.append("description",In),t.append("conversation_id",r.conversation_id);try{const l=await B.post("/content/upload",t,{headers:{"Content-Type":"multipart/form-data","X-CSRF-TOKEN":((i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.getAttribute("content"))||""}});if(l.data.success)l.data.conversation_messages&&rt(l.data.conversation_messages),Dn([]),mn(""),nt(null),Ae.current&&(Ae.current.value=""),setTimeout(()=>{Tt()},100),Ye(),b(`${we.length>1?"Files":"File"} uploaded successfully!`,"success");else{const o=l.data.message||"Failed to upload file";nt(o),b(o,"error"),Ae.current&&(Ae.current.value="")}}catch(l){if(console.error("Upload error:",l),B.isAxiosError(l)&&l.response){const o=l.response.data.message||"Failed to upload file";nt(o),b(o,"error"),Ae.current&&(Ae.current.value="")}else{const o="Failed to upload file. Please try again.";nt(o),b(o,"error"),Ae.current&&(Ae.current.value="")}}finally{Fr(!1)}},ss=t=>{t.target.files&&t.target.files.length>0&&(pr(t.target.files),t.target.value="")},xn=s.useCallback(async(t,a,i)=>{var o,u;if(!Le){Te(!0);return}const l=a!==void 0?a:In;if(l.trim()){_r(!0);try{if(i==="conversationcomment"){const L=await B.post("/content/comment",{content:l,conversation_id:r.conversation_id,parent_slug:r.slug,content_type:"conversationcomment"},{headers:{"X-CSRF-TOKEN":((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||""}});if(L.data.success)L.data.conversation_messages&&rt(L.data.conversation_messages),a===void 0&&mn(""),setTimeout(()=>{Tt()},100),setTimeout(()=>{Tt()},450),Ye(),b("Comment posted successfully!","success");else{const ne=L.data.message||"Failed to post comment";b(ne,"error"),alert(ne)}return}const d=i==="embed"||a!==void 0&&(a.includes("embed-row")||a.includes("embed-carousel")||a.includes("embed-masonry")||a.includes("masonry-wrapper"));if(!d){const L={content:l,message_id:(r==null?void 0:r.id)||null,message_slug:t||(r==null?void 0:r.slug)||null,conversation_id:(r==null?void 0:r.conversation_id)||null,format:"markdown",content_type:"comment"},ne=await B.post("/comments",L);if(ne.data.success)a===void 0&&mn(""),b("Comment posted successfully!","success");else{const V=ne.data.message||"Failed to post comment";b(V,"error"),alert(V)}return}const c={content:l,conversation_id:r.conversation_id,parent_slug:d?null:t||null};i?c.content_type=i:d&&(c.content_type="embed");const x=await B.post("/content/comment",c,{headers:{"X-CSRF-TOKEN":((u=document.querySelector('meta[name="csrf-token"]'))==null?void 0:u.getAttribute("content"))||""}});if(x.data.success)x.data.conversation_messages&&rt(x.data.conversation_messages),a===void 0&&mn(""),setTimeout(()=>{Tt()},100),setTimeout(()=>{Tt()},450),Ye(),b(d?"Embed added to conversation successfully!":t?"Child conversation added successfully!":"Comment posted successfully!","success");else{const L=x.data.message||"Failed to post comment";b(L,"error"),alert(L)}}catch(d){if(console.error("Comment error:",d),B.isAxiosError(d)&&d.response){const c=d.response.data.message||"Failed to post comment";b(c,"error"),alert(c)}else{const c="Failed to post comment. Please try again.";b(c,"error"),alert(c)}}finally{_r(!1)}}},[Le,In,r.conversation_id,r.slug,rt]),is=s.useCallback(async(t,a,i)=>{var l;if(!Le){Te(!0);return}try{const o=await B.post("/content/social",{content:t,media:a,content_warning:i,conversation_id:r.conversation_id,parent_slug:null,format:Et},{headers:{"X-CSRF-TOKEN":((l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"))||""}});if(o.data.success)o.data.conversation_messages&&rt(o.data.conversation_messages),setTimeout(()=>{Tt()},100),Ye(),b("Social media post created successfully!","success");else{const u=o.data.message||"Failed to create social media post";b(u,"error"),alert(u)}}catch(o){if(console.error("Social media post error:",o),B.isAxiosError(o)&&o.response){const u=o.response.data.message||"Failed to create social media post";b(u,"error"),alert(u)}else{const u="Failed to create social media post. Please try again.";b(u,"error"),alert(u)}}},[r.conversation_id,rt,Le,Et,Ye,Tt]),fr=s.useCallback(async(t,a,i,l)=>{var o;if(!Le){Te(!0);return}try{const u=await B.post("/comments",{content:t,media:a,content_warning:i,conversation_id:r.conversation_id,message_id:l.id||r.id||null,message_slug:l.slug||r.slug||null,parent_id:null,format:Et,content_type:"comment"},{headers:{"X-CSRF-TOKEN":((o=document.querySelector('meta[name="csrf-token"]'))==null?void 0:o.getAttribute("content"))||""}});if(u.data.success)u.data.data&&G(d=>[u.data.data,...d]),$(),Ye(),b("Comment reply posted successfully!","success");else{const d=u.data.message||"Failed to post reply";b(d,"error"),alert(d)}}catch(u){if(console.error("Reply post error:",u),B.isAxiosError(u)&&u.response){const d=u.response.data.message||"Failed to post reply";b(d,"error")}else b("Failed to post reply. Please try again.","error")}},[r.conversation_id,r.id,r.slug,Le,Et,$,Ye]),hr=s.useCallback(async(t,a,i)=>{var u;if(!Le){Te(!0);return}const l=Nr(t);if(!l.valid){const d=l.error||"Invalid file type";throw b(d,"error"),new Error(d)}const o=new FormData;o.append("file",t),o.append("content",a||`Attachment: ${t.name}`),o.append("description",a||`Attachment: ${t.name}`),o.append("conversation_id",r.conversation_id),o.append("message_slug",i.slug),i.id&&o.append("message_id",String(i.id)),o.append("content_type","upload"),o.append("format","markdown");try{const d=await B.post("/comments",o,{headers:{"Content-Type":"multipart/form-data","X-CSRF-TOKEN":((u
3351=document.querySelector('meta[name="csrf-token"]'))==null?void 0:u.getAttribute("content"))||""}});if(d.data.success)d.data.data&&G(c=>[d.data.data,...c]),$(),b("File uploaded successfully to comments!","success");else{const c=d.data.message||"Failed to upload file";throw b(c,"error"),new Error(c)}}catch(d){if(console.error("Reply upload error:",d),B.isAxiosError(d)&&d.response){const c=d.response.data.message||"Failed to upload file";throw b(c,"error"),new Error(c)}else{const c=(d==null?void 0:d.message)||"Failed to upload file. Please try again.";throw b(c,"error"),d}}},[r.conversation_id,Le,$]),xr=s.useCallback(async(t,a)=>{var i;if(Wn){b((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is currently disabled.","error");return}if(t.length>z){b(`Question exceeds maximum length of ${z} characters.`,"error");return}if(t.trim()){Ne(!0);try{const o=await(await fetch("/searchai/ai",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":((i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.getAttribute("content"))||""},body:JSON.stringify({query:t,conversation_id:r.conversation_id,thread_id:r.thread_id,parent_slug:a.slug,message_id:a.id,as_comment:!0,enable_thinking:!1,model:rn.id})})).json();if(o.success){if(o.is_comment||o.user_comment||o.ai_comment){const u=[];o.user_comment&&u.push(o.user_comment),o.ai_comment&&u.push(o.ai_comment),u.length>0&&G(d=>[...d,...u]),$(),b("AI response added to comments!","success")}else o.conversation_messages&&Array.isArray(o.conversation_messages)?(rt(o.conversation_messages),b("AI response received!","success")):($(),b("AI response added to comments!","success"));o.conversation_cost!==void 0&&le(o.conversation_cost),o.conversation_tokens!==void 0&&g(o.conversation_tokens),Ye()}else{const u=o.message||"Failed to get AI response";b(u,"error"),alert(u)}}catch(l){console.error("Error asking AI:",l),b("An error occurred. Please try again.","error"),alert("An error occurred. Please try again.")}finally{Ne(!1)}}},[r.conversation_id,r.thread_id,rt,Wn,z,n,rn,$,Ye]),ta=async t=>{var a;if(!Le){Te(!0);return}if(t&&t.preventDefault(),Wn){w((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is currently disabled. Please try again later."),b((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is currently disabled. Please try again later.","error");return}if(!wt){w("You do not have permission to continue this conversation."),b("You do not have permission to continue this conversation.","error");return}if(S.length>z){w(((n==null?void 0:n.ai_search_view_question_too_long)||"Question exceeds maximum length of {max} characters. Please shorten your question.").replace("{max}",z.toString())),b(((n==null?void 0:n.ai_search_view_question_too_long)||"Question exceeds maximum length of {max} characters. Please shorten your question.").replace("{max}",z.toString()),"error");return}if(!(!S.trim()||ye)){Ne(!0);try{const l=await(await fetch("/searchai/ai",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":((a=document.querySelector('meta[name="csrf-token"]'))==null?void 0:a.getAttribute("content"))||""},body:JSON.stringify({query:S,conversation_id:r.conversation_id,thread_id:r.thread_id,parent_slug:null,enable_thinking:!1,model:rn.id})})).json();if(l.success)l.conversation_messages&&Array.isArray(l.conversation_messages)&&rt(l.conversation_messages),se(""),l.conversation_cost!==void 0&&le(l.conversation_cost),l.conversation_tokens!==void 0&&g(l.conversation_tokens),setTimeout(()=>{Tt()},100),Ye();else{const o=l.message||"Failed to get response";b(o,"error"),alert(o)}}catch(i){console.error("Error asking question:",i),b("An error occurred. Please try again.","error"),alert("An error occurred. Please try again.")}finally{Ne(!1)}}},os=t=>{t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),ta()):t.key==="Escape"&&se("")},ht=t=>{const a=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(a)},ls=t=>(t/1e3*.01).toFixed(4),ds=t=>{if(!t)return"";const a=t.split(".");if(a.length===4)return`${a[0]}.${a[1]}.${a[2]}.***`;{const i=t.lastIndexOf(":");if(i!==-1)return t.substring(0,i+1)+"***";const l=Math.floor(t.length/2);return t.substring(0,l)+"*".repeat(t.length-l)}},gr=t=>{const a=t.mime_type.startsWith("image/"),i=t.mime_type.startsWith("video/"),l=t.mime_type.startsWith("audio/"),o=t.mime_type==="application/pdf",u=t.mime_type==="text/html"||t.extension==="html"||t.extension==="htm",d=()=>
3351{if(a)return`![${t.original_name}](${t.url})
3352
3353*${t.original_name}*`;if(i||l)return null;if(o){const c=`https://docs.google.com/viewer?url=${encodeURIComponent(t.url)}&embedded=true`;return`<div class="pdf-viewer-container">
3354                    <div class="pdf-viewer-toolbar">
3355                        <a href="${t.url}" target="_blank" rel="noopener noreferrer" class="pdf-download-btn">
3356                            📄 Open PDF in New Tab
3357                        </a>
3358                        <a href="${t.url}" download class="pdf-download-btn">
3359                            💾 Download PDF
3360                        </a>
3361                    </div>
3362                    <iframe
3363                        src="${c}"
3364                        class="pdf-iframe"
3365                        style="width: 100%; height: 600px; border: 1px solid #e5e7eb; border-radius: 0.5rem; background-color: #f9fafb;"
3366                        title="${t.original_name}"
3367                        sandbox="allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-modals allow-presentation allow-top-navigation-by-user-activation"
3368                    >
3369                        <div class="pdf-fallback">
3370                            <p>Your browser cannot display PDF files inline.</p>
3371                            <a href="${t.url}" target="_blank">Click here to open the PDF</a>
3372                        </div>
3373                    </iframe>
3374                </div>`}return u?`<div style="width: 100%;">
3375                    <iframe src="${t.url}" style="width: 100%; height: 500px; border: 1px solid #e5e7eb; border-radius: 0.5rem; display: block;" title="${t.original_name}" sandbox="allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-modals allow-presentation allow-top-navigation-by-user-activation">
3376                        Your browser does not support iframes.
3377                    </iframe>
3378                    <div style="margin-top: 12px; text-align: center;">
3379                        <a href="${t.url}" target="_blank" rel="noopener noreferrer" style="color: #22c55e; text-decoration: underline;">📄 View permanent link</a>
3380                    </div>
3381                </div>`:`**File:** [${t.original_name}](${t.url}) (${Ft(t.size)})`};if(a)return e.jsxs("div",{className:"w-full",children:[e.jsx("div",{className:"rounded-lg overflow-hidden border border-gray-200/80 bg-gray-50 flex items-center justify-center relative group/img shadow-2xs",children:e.jsx("img",{src:t.url,alt:t.original_name,className:"w-full h-auto max-h-[70vh] object-contain rounded-lg transition-transform duration-200 group-hover/img:scale-[1.01]",loading:"lazy"})}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs text-gray-500",children:[e.jsxs("span",{className:"truncate font-medium text-gray-700",title:t.original_name,children:["📷 ",t.original_name]}),e.jsx("span",{className:"text-gray-400 shrink-0 ml-2 text-[11px] font-mono",children:Ft(t.size)})]})]});if(i)return e.jsxs("div",{className:"w-full break-words",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:["🎬 ",t.original_name]}),e.jsxs("span",{className:"text-xs text-gray-400",children:["(",Ft(t.size),")"]})]}),e.jsx("div",{className:"flex justify-center w-full bg-black/5 rounded-lg overflow-hidden",children:e.jsx("video",{src:t.url,controls:!0,className:"w-full max-h-[70vh] rounded-lg",style:{maxWidth:"100%",height:"auto"},preload:"metadata",children:"Your browser does not support the video tag."})}),e.jsx("div",{className:"mt-3 text-center",children:e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors text-sm",children:[e.jsx(m,{icon:yn}),"Open video in new tab"]})})]});if(l)return e.jsxs("div",{className:"w-full break-words",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:["🎵 ",t.original_name]}),e.jsxs("span",{className:"text-xs text-gray-400",children:["(",Ft(t.size),")"]})]}),e.jsx("div",{className:"flex justify-center w-full bg-black/5 rounded-lg p-4",children:e.jsx("audio",{src:t.url,controls:!0,className:"w-full max-w-2xl",style:{width:"100%"},preload:"metadata",children:"Your browser does not support the audio tag."})}),e.jsx("div",{className:"mt-3 text-center",children:e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors text-sm",children:[e.jsx(m,{icon:yn}),"Open audio in new tab"]})})]});if(o){const c=`https://docs.google.com/viewer?url=${encodeURIComponent(t.url)}&embedded=true`;return e.jsxs("div",{className:"w-full break-words",children:[e.jsxs("div",{className:"flex gap-3 mb-3 flex-wrap",children:[e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 transition-colors text-sm",children:[e.jsx(m,{icon:yn}),"Open PDF in New Tab"]}),e.jsxs("a",{href:t.url,download:!0,className:"inline-flex items-center gap-2 px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors text-sm",children:[e.jsx(m,{icon:Fs}),"Download PDF"]})]}),e.jsx("iframe",{src:c,className:"w-full h-[600px] rounded-lg border border-gray-200",title:t.original_name,style:{backgroundColor:"#f9fafb"},sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-modals"})]})}if(u){const c=d();return Vn(c),e.jsx("div",{className:"w-full break-words",style:{width:"100%"},children:e.jsx(vn,{content:c,title:"HTML Preview",filename:"preview.html"})})}return e.jsx("div",{className:"break-words w-full",style:{width:"100%"},children:e.jsx(Pt,{source:d(),style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#1f2937",width:"100%"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})})},na=t=>{if(Vn(t).isHtml)return e.jsx("div",{className:"break-words w-full",children:e.jsx(vn,{content:t,title:"HTML Preview",filename:"preview.html"})});const i=/^#{1,6}\s+/m.test(t)||gi(t);return e.jsx("div",{className:"break-words w-full",children:i||t.includes("```")||t.includes("#")||t.includes("**")?e.jsx("div",{className:"comment-content markdown-body",children:e.jsx(Pt,{source:t,style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#1f2937"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t],disallowedElements:[]})}):e.jsx("div",{className:"comment-content text-gray-800 whitespace-pre-wrap",children:t})})},cs=t=>{var o,u,d,c;const a=t.query,i=((o=t.social_media_metadata)==null?void 0:o.format)||t.format||"markdown";Vn(a);const l=i==="markdown"?"📝 Markdown":i==="html"?"🌐 HTML":"📊 EzSheet";return e.jsxs("div",{className:"break-words w-full",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2 flex-wrap",children:[t.content_warning&&e.jsxs("span",{className:"text-xs bg-amber-100 text-amber-700 px-2 py-1 rounded-full flex items-center gap-1",children:["⚠️ CW: ",t.content_warning]}),t.media_count!==void 0&&t.media_count!==null&&t.media_count>0&&e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-700 px-2 py-1 rounded-full flex items-center gap-1",children:["📷 ",t.media_count," media"]}),e.jsx("span",{className:"text-xs bg-gray-100 text-gray-600 px-2 py-1 rounded-full flex items-center gap-1",children:l})]}),i==="html"?e.jsx(vn,{content:a,title:"HTML Preview",filename:"preview.html"}):i==="ezsheet"?e.jsxs("div",{className:"space-y-2",children:[(((u=t.social_media_metadata)==null?void 0:u.wall_id)||t.wall_id)&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-indigo-700 bg-indigo-50/90 border border-indigo-200 rounded-lg px-3 py-1.5 font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-semibold",children:["🧱 Wall ID: ",e.jsx("span",{className:"bg-indigo-600 text-white px-2 py-0.5 rounded text-[11px] font-bold",children:((d=t.social_media_metadata)==null?void 0:d.wall_id)||t.wall_id})]}),e.jsx("span",{className:"text-[11px] text-indigo-500 font-sans",children:"Saved in walls table"})]}),e.jsx(ha,{content:a,title:"EzSheet Preview",wallId:((c=t.social_media_metadata)==null?void 0:c.wall_id)||t.wall_id||t.slug||"ezsheet",height:720,filter:!0,auth:W,isOwner:Ke})]}):e.jsx("div",{className:"social-post-content markdown-body",children:e.jsx(Pt,{source:a,style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#1f2937"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})})]})},us=t=>{let a="",i="";const l=t.ip_address||r.ip_address||"";l&&(i=ds(l));const o=t.user||r.user||(E!=null&&E.id?E:null);if(o&&o.email){const u=o.email,[d,c]=u.split("@"),x=(d||"us").substring(0,2)+"***",L=c?c.split("."):["com"],V="***"+(L[L.length-1]||"com");a=`${x}@${V}`}else if(t.user_name||r.user_name){const u=t.user_name||r.user_name||"Guest";a=u.length>2?u.substring(0,2)+"***":u}else a="Guest";return{displayInfo:a,ipDisplay:i}},ra=(t,a=!1,i=!1)=>{var Ve,st,ue;if(t.status==="hidden"&&!Ke&&!Qt)return null;const l=t.message_role==="user",o=ln===t.id,u=t.content_type==="upload"||t.content_type==="comment"||t.content_type==="conversationcomment"||t.content_type==="embed"||t.content_type==="social"||t.content_type==="social_media",{displayInfo:d,ipDisplay:c}=us(t),x=t.total_tokens||((Ve=t.usage)==null?void 0:Ve.total_tokens)||(t.response?Math.max(100,Math.round(((((st=t.query)==null?void 0:st.length)||0)+(((ue=t.response)==null?void 0:ue.length)||0))/3.5)):0),L=t.model||"kimi-k3";if(a){const C=t.content_type==="ai"||!l;return e.jsxs("div",{id:`message-${t.slug}`,className:"w-full scroll-mt-24 transition-all duration-200 group relative flex flex-col justify-between bg-white rounded-xl border border-gray-200/90 shadow-2xs hover:shadow-md hover:border-gray-300 p-4 min-h-[220px] mb-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center shadow-2xs ring-2 ring-white ${C?"bg-[#a85
33815f7] text-white":"bg-[#22c55e] text-white"}`,children:e.jsx(m,{icon:C?Yn:Ar,className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-mono flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-gray-400 text-[11px] font-sans",children:C?"Model:":"User:"}),e.jsx("span",{className:"font-semibold text-gray-800 text-[12px] truncate max-w-[130px]",children:C?L:d||"Guest"})]}),c&&!C&&e.jsxs("div",{className:"font-mono text-gray-400 text-[11px]",children:[e.jsx("span",{className:"text-gray-300",children:"IP:"})," ",c]})]}),e.jsx("button",{type:"button",onClick:()=>Gn(t.id,t.response||t.query||""),className:"text-gray-400 hover:text-[#22c55e] transition-colors p-1 rounded focus:outline-none cursor-pointer",title:"Copy",children:e.jsx(m,{icon:o?gt:It,className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"flex-1 min-w-0 mb-3 text-xs text-gray-800 leading-relaxed break-words",children:C?e.jsx(Pt,{source:t.response||t.query||"",style:{...Rt,backgroundColor:"transparent",fontSize:"13px",color:"#1f2937"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]}):e.jsx("div",{className:"whitespace-pre-wrap",children:t.query})}),e.jsxs("div",{className:"mt-auto pt-3 border-t border-gray-100 w-full",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mb-2",children:[e.jsx("span",{children:ht(t.created_at)}),x>0&&e.jsxs("span",{children:[x," tokens"]})]}),e.jsx(Cr,{messageId:t.id,messageSlug:t.slug,initialLikes:t.reaction_total||0,initialReactions:t.reaction_counts||{},initialComments:oe.filter(O=>O.message_id===t.id||O.message_slug===t.slug).length,onAddComment:async O=>{await xn(t.slug,O),$()},onCommentAdded:()=>{$()},onCommentDeleted:O=>{G(k=>k.filter(Ie=>Ie.id!==O))},onReplyPost:async(O,k,Ie)=>{await fr(O,k,Ie,t),$()},onReplyAskAI:async O=>{await xr(O,t),$()},onReplyUpload:async(O,k)=>{await hr(O,k,t),$()},conversationId:r.conversation_id,parentSlug:t.slug,tooltips:n,currentUser:E,messageQuery:t.query,messageResponse:t.response,shareUrl:t.share_url})]})]},t.id)}if(u)return e.jsx("div",{id:`message-${t.slug}`,className:"w-full scroll-mt-24 transition-all duration-200 group relative flex flex-col justify-between mb-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center shadow-2xs ring-2 ring-white bg-blue-500 text-white",children:t.content_type==="upload"?e.jsx(m,{icon:zr,className:"w-4 h-4 text-white"}):t.content_type==="embed"?e.jsx(m,{icon:Dt,className:"w-4 h-4 text-white"}):t.content_type==="conversationcomment"?e.jsx(m,{icon:Mr,className:"w-4 h-4 text-white"}):t.content_type==="comment"?e.jsx(m,{icon:Mr,className:"w-4 h-4 text-white"}):e.jsx(m,{icon:kn,className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[d&&e.jsxs("div",{className:"text-xs text-gray-500 mb-1 font-mono",children:["User: ",d]}
3381),e.jsx("div",{className:"flex-1 min-w-0 w-full mb-3",children:t.content_type==="upload"&&t.file_data?gr(t.file_data):t.content_type==="conversationcomment"||t.content_type==="comment"?na(t.query):t.content_type==="embed"?e.jsx("div",{className:"break-words w-full",children:e.jsx(vn,{content:t.query,title:"Embed Row / Masonry Layout",filename:"embed.html"})}):cs(t)}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs text-gray-400",children:[e.jsx("span",{children:ht(t.created_at)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>window.open(`/X/${encodeURIComponent(t.slug)}`,"_blank"),className:"text-gray-400 hover:text-[#22c55e] transition-colors p-1 rounded focus:outline-none cursor-pointer",children:e.jsx(m,{icon:yn,className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>Gn(t.id,t.query),className:`text-gray-400 hover:text-[#22c55e] transition-colors p-1 rounded focus:outline-none cursor-pointer ${o?"text-green-500":""}`,children:e.jsx(m,{icon:o?gt:It,className:"w-3.5 h-3.5"})})]})]}),e.jsx(Cr,{messageId:t.id,messageSlug:t.slug,initialLikes:t.reaction_total||0,initialReactions:t.reaction_counts||{},initialComments:oe.filter(C=>C.message_id===t.id||C.message_slug===t.slug).length,onAddComment:async C=>{await xn(t.slug,C),$()},onCommentAdded:()=>{$()},onCommentDeleted:C=>{G(O=>O.filter(k=>k.id!==C))},onReplyPost:async(C,O,k)=>{await fr(C,O,k,t),$()},onReplyAskAI:async C=>{await xr(C,t),$()},onReplyUpload:async(C,O)=>{await hr(C,O,t),$()},conversationId:r.conversation_id,parentSlug:t.slug,tooltips:n,currentUser:E,messageQuery:t.query,messageResponse:t.response,shareUrl:t.share_url})]})]})},t.id);const ne=(l||!i)&&!!t.query,V=!l||!!t.response;return e.jsxs("div",{id:`message-${t.slug}`,className:"w-full scroll-mt-24 transition-all duration-200",children:[ne&&e.jsxs("div",{className:"flex items-start gap-3 w-full",children:[e.jsx("div",{className:"shrink-0 w-9 h-9 rounded-full bg-[#22c55e] flex items-center justify-center text-white shadow-2xs",children:e.jsx(m,{icon:Ar,className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-xs mb-1.5 space-y-0.5 select-none font-mono",children:[d&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-gray-400 font-sans",children:"User:"}),e.jsx("span",{className:"font-medium text-gray-700",children:d})]}),c&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-gray-400 font-sans",children:"IP:"}),e.jsx("span",{className:"text-gray-500",children:c})]})]}),e.jsx("div",{className:"w-full bg-[#22c55e] text-white rounded-2xl px-5 py-3.5 break-words shadow-2xs",children:e.jsx("div",{className:"text-white text-base sm:text-[15px] leading-relaxed [&_*]:text-white!",children:e.jsx(Pt,{source:t.query,style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#ffffff"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})})})]})]}),V&&e.jsx("div",{className:`border-l-2 border-gray-200/80 pl-4 sm:pl-5 ml-4.5 ${ne?"mt-6":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"shrink-0 w-9 h-9 rounded-full bg-[#a855f7] flex items-center justify-center text-white shadow-2xs",children:e.jsx(m,{icon:Yn,className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1 select-none",children:[e.jsx("span",{className:"text-xs text-gray-400 font-sans",children:"Model:"}),e.jsx("span",{className:"text-xs font-mono font-medium text-gray-500",children:L})]}),e.jsx("div",{className:"text-gray-900 text-[15px] sm:text-base leading-relaxed break-words markdown-body mt-1",children:e.jsx(Pt,{source:t.response||"",style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#111827"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})}),mt(t.hashtag).length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-2.5",children:mt(t.hashtag).map(C=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(C)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs font-medium bg-emerald-50 text-emerald-700 hover:bg-emerald-100 border border-emerald-200/80 px-2 py-0.5 rounded-full transition-colors",children:["#",C]},C))}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-400 mt-4 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-gray-400",children:ht(t.created_at)}),x>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{className:"text-gray-400",children:[x," tokens"]}),e.jsx("span",{className:"text-gray-300",children:"•"}),e.jsxs("span",{className:"text-gray-400 font-mono",children:["$",ls(x)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>window.open(`/X/${encodeURIComponent(t.slug)}`,"_blank"),className:"text-gray-400 hover:text-gray-600 transition-colors p-1 rounded focus:outline-none cursor-pointer","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_permalink)||"Open permanent link in new tab",children:e.jsx(m,{icon:yn,className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>Gn(t.id,t.response||""),className:`text-gray-400 hover:text-gray-600 transition-colors p-1 rounded focus:outline-none cursor-pointer ${o?"text-green-500":""}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":o?(n==null?void 0:n.ai_search_view_message_copied)||"Copied!":(n==null?void 0:n.ai_search_view_copy_message)||"Copy this response",children:o?e.jsx(m,{icon:gt,className:"w-3.5 h-3.5 text-green-500"}):e.jsx(m,{icon:It,className:"w-3.5 h-3.5"})})]})]}),e.jsx(Cr,{messageId:t.id,messageSlug:t.slug,initialLikes:t.reaction_total||0,initialReactions:t.reaction_counts||{},initialComments:oe.filter(C=>C.message_id===t.id||C.message_slug===t.slug).length,onAddComment:async C=>{await xn(t.slug,C),$()},onCommentAdded:()=>{$()},onCommentDeleted:C=>{G(O=>O.filter(k=>k.id!==C))},onReplyPost:async(C,O,k)=>{await fr(C,O,k,t),$()},onReplyAskAI:async C=>{await xr(C,t),$()},onReplyUpload:async(C,O)=>{await hr(C,O,t),$()},conversationId:r.conversation_id,parentSlug:t.slug,tooltips:n,currentUser:E,messageQuery:t.query,messageResponse:t.response,shareUrl:t.share_url})]})]})})]},t.id)},ms=t=>{var u,d,c,x,L;if(typeof t=="object"&&t!==null&&t.url){const ne=t.extension||((d=(u=t.url.
3381split(".").pop())==null?void 0:u.split("?")[0])==null?void 0:d.toLowerCase())||"";let V=t.mime_type||"";return V||(["mp4","webm","ogg","mov","avi"].includes(ne)?V="video/mp4":["mp3","wav","ogg","m4a"].includes(ne)?V="audio/mpeg":ne==="pdf"?V="application/pdf":["html","htm"].includes(ne)?V="text/html":V="image/jpeg"),{original_name:t.original_name||t.name||`file.${ne||"bin"}`,size:t.size||0,mime_type:V,extension:ne||"bin",path:t.path||t.url,url:t.url,access_token:t.access_token,uploaded_at:t.uploaded_at,storage_disk:t.storage_disk||"local",width:t.width,height:t.height}}const a=String(t||""),i=((x=(c=a.split(".").pop())==null?void 0:c.split("?")[0])==null?void 0:x.toLowerCase())||"";let l="image/jpeg";return["mp4","webm","ogg","mov","avi"].includes(i)?l="video/mp4":["mp3","wav","ogg","m4a"].includes(i)?l="audio/mpeg":i==="pdf"?l="application/pdf":["html","htm"].includes(i)?l="text/html":a.startsWith("data:video/")?l="video/mp4":a.startsWith("data:audio/")?l="audio/mpeg":a.startsWith("data:application/pdf")?l="application/pdf":a.startsWith("data:image/")&&(l=a.substring(5,a.indexOf(";"))),{original_name:((L=a.split("/").pop())==null?void 0:L.split("?")[0])||`attachment.${i||"jpg"}`,size:0,mime_type:l,extension:i||"jpg",path:a,url:a,storage_disk:"local"}},ps=t=>{var Ve,st;const a=t.content_type==="ai",i=t.ai_reply||oe.find(ue=>ue.parent_id===t.id&&ue.content_type==="ai"),l=a||!!i;let o="",u="",d="",c="",x="",L="";a&&!i?(t.parent?(o=t.parent.user_name||"Anonymous",u=t.parent.user_avatar,d=t.parent.created_at_formatted||"Just now",c=t.parent.content||""):t.query?(o=(E==null?void 0:E.name)||"User",u=E==null?void 0:E.avatar,d=t.created_at_formatted||"Just now",c=t.query):(o="",c=""),x=t.created_at_formatted||"Just now",L=t.content||""):(o=t.user_name||((Ve=t.user)==null?void 0:Ve.name)||"Anonymous",u=t.user_avatar||((st=t.user)==null?void 0:st.avatar),d=t.created_at_formatted||"Just now",c=t.content||"",i&&(x=i.created_at_formatted||t.created_at_formatted||"Just now",L=i.content||""));const ne=(o||"U").charAt(0).toUpperCase(),V=()=>{let ue="";l&&(c||L)?c&&L?ue=`User: ${c}
3382
3383AI Assistant: ${L}`:L?ue=L:ue=c:ue=t.content||"",Gn(t.id,ue)};return e.jsxs("div",{className:`w-full rounded-2xl p-4 sm:p-5 border shadow-2xs hover:shadow-xs transition-all mb-4 group ${t.is_owner?"bg-amber-50 border-amber-300":"bg-white border-gray-200/90 hover:border-gray-300"}`,children:[(o||c||!a)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[u?e.jsx("img",{src:u,alt:o,className:"w-9 h-9 rounded-full object-cover border border-green-200 shrink-0"}):e.jsx("div",{className:"w-9 h-9 rounded-full bg-[#dcfce7] border border-[#86efac] text-[#15803d] flex items-center justify-center text-sm font-semibold shrink-0",children:ne}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold text-gray-900 text-sm tracking-tight truncate",children:o}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:d})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 text-gray-400",children:[e.jsx("button",{type:"button",onClick:V,className:"text-gray-400 hover:text-gray-600 transition-colors p-1.5 rounded focus:outline-none cursor-pointer",title:"Copy",children:e.jsx(m,{icon:ln===t.id?gt:It,className:"w-3.5 h-3.5"})}),(t.is_owner||Ke)&&e.jsx("button",{type:"button",onClick:()=>La(t.id),className:"text-gray-400 hover:text-red-600 transition-colors p-1.5 rounded focus:outline-none cursor-pointer",title:"Delete Comment",children:e.jsx(m,{icon:Rs,className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"mb-2.5 flex items-center gap-2 flex-wrap",children:[t.content_warning&&e.jsxs("span",{className:"text-xs bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full flex items-center gap-1",children:["⚠️ CW: ",t.content_warning]}),Array.isArray(t.media)&&t.media.length>0&&e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded-full flex items-center gap-1",children:["📎 ",t.media.length," ",t.media.length===1?"file":"files"]}),t.content_type==="upload"&&e.jsx("span",{className:"text-xs bg-emerald-100 text-emerald-700 px-2 py-0.5 rounded-full flex items-center gap-1",children:"📁 
3383Uploaded Media"}),e.jsx("span",{className:"text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full flex items-center gap-1",children:t.format==="html"?"🌐 HTML":t.format==="ezsheet"?"📊 EzSheet":"📝 Markdown"})]}),c&&e.jsx("div",{className:"break-words w-full mb-3",children:(()=>{var O;const ue=Vn(c);if((t.format==="html"||ue.isHtml)&&!l)return e.jsx(vn,{content:c,title:"HTML Preview",filename:"comment.html"});if(t.format==="ezsheet"&&!l){const k=((O=t.social_media_metadata)==null?void 0:O.wall_id)||t.wall_id||message.slug||"ezsheet";return e.jsxs("div",{className:"space-y-2",children:[k!=="ezsheet"&&e.jsxs("div",{className:"flex items-center justify-between text-xs text-indigo-700 bg-indigo-50/90 border border-indigo-200 rounded-lg px-3 py-1.5 font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-semibold",children:["🧱 Wall ID: ",e.jsx("span",{className:"bg-indigo-600 text-white px-2 py-0.5 rounded text-[11px] font-bold",children:k})]}),e.jsx("span",{className:"text-[11px] text-indigo-500 font-sans",children:"Saved in walls table"})]}),e.jsx(ha,{content,title:"EzSheet Preview",wallId:k,height:600,filter:!0,auth:W,isOwner:Ke})]})}return e.jsx("div",{className:"social-post-content markdown-body",children:e.jsx(Pt,{source:c,style:{...Rt,backgroundColor:"transparent",fontSize:"15px",color:"#1f2937"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})})})()}),Array.isArray(t.media)&&t.media.length>0&&e.jsx("div",{className:"space-y-3 mb-4 w-full",children:t.media.map((ue,C)=>{const O=ms(ue);return e.jsx("div",{className:"w-full",children:gr(O)},C)})}),!Array.isArray(t.media)&&t.file_data&&e.jsx("div",{className:"mb-4 w-full",children:gr(t.file_data)})]}),l&&e.jsxs("div",{className:o||c?"pt-1":"",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-[#a855f7] text-white flex items-center justify-center shrink-0 shadow-2xs",children:e.jsx(m,{icon:Yn,className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-gray-900 text-sm tracking-tight",children:"AI Assistant"}),e.jsx("span",{className:"text-[11px] font-semibold px-2 py-0.5 bg-[#f3e8ff] text-[#9333ea] rounded-full inline-flex items-center",children:"AI"})]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:x})]})]}),!(o||c)&&e.jsx("div",{className:"flex items-center gap-1.5 shrink-0 text-gray-400",children:e.jsx("button",{type:"button",onClick:V,className:"text-gray-400 hover:text-gray-600 transition-colors p-1.5 rounded focus:outline-none cursor-pointer",title:"Copy",children:e.jsx(m,{icon:ln===t.id?gt:It,className:"w-3.5 h-3.5"})})})]}),e.jsx("div",{className:"text-sm text-gray-800 leading-relaxed break-words",children:e.jsx(Pt,{source:L,style:{...Rt,backgroundColor:"transparent",fontSize:"14px",color:"#1f2937"},wrapperElement:{"data-color-mode":"light"},remarkPlugins:[Bt],rehypePlugins:[Lt,_t]})})]})]},`db-${t.id}`)},fs=({model:t,selectedModel:a,onSelect:i})=>e.jsx("button",{onClick:i,className:`w-full px-4 py-3 text-left hover:bg-gray-50 transition-colors ${a.id===t.id?"bg-[#22c55e]/5":""}`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:`text-sm font-medium ${a.id===t.id?"text-[#22c55e]":"text-gray-900"}`,children:t.name}),t.isNew&&e.jsx("span",{className:"text-[10px] font-semibold text-white bg-[#22c55e] px-1.5 py-0.5 rounded-full",children:"NEW"})]}),t.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5 max-w-[200px]",children:t.description})]}),a.id===t.id&&e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"flex-shrink-0 mt-1",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})})]})}),hs=()=>e.jsxs("div",{className:"relative",ref:dr,children:[e.jsxs("button",{onClick:()=>lr(!or),className:"flex items-center space-x-2 px-3 py-1.5 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors focus:outline-none focus:ring-2 focus:ring-[#22c55e]/30","data-tooltip-id":"main-tooltip","data-tooltip-content":"Select AI model for your conversation",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:rn.name}),rn.isNew&&e.jsx("span",{className:"text-[10px] font-semibold text-white bg-[#22c55e] px-1.5 py-0.5 rounded-full",children:"NEW"}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`text-gray-500 transition-transform duration-200 ${or?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),or&&e.jsxs("div",{className:"absolute left-0 mt-1 w-80 bg-white border border-gray-200 rounded-xl shadow-xl z-50 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Select Model"})}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:xa.map(t=>e.jsx(fs,{model:t,selectedModel:rn,onSelect:()=>{Da(t),lr(!1)}},t.id))}),e.jsx("div",{className:"px-4 py-2 bg-gray-50 border-t border-gray-200",children:e.jsxs("p",{className:"text-xs text-gray-500 text-center",children:["Powered by Moonshot AI, OpenAI, DeepSeek, Perplexity & Google Gemini • ",xa.length," models available"]})})]})]}),xs=()=>
3383{if(!Le)return e.jsxs("div",{className:"bg-gray-50 border-2 border-dashed border-gray-300 rounded-xl p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",children:e.jsx("path",{d:"M4 16l4.586-4.586a2 2 0 0 1 2.828 0L16 16m-2-2l1.586-1.586a2 2 0 0 1 2.828 0L20 14m-6-6h.01M6 20h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"})})}),e.jsx("p",{className:"text-gray-600 mb-2",children:"Login required to upload files"}),e.jsx("button",{onClick:()=>Te(!0),className:"inline-block px-6 py-2 bg-[#22c55e] text-white rounded-lg hover:bg-[#16a34a] transition-colors text-sm font-medium",children:"Login to Access"})]});const t=we.reduce((a,i)=>a+i.size,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-[#22c55e]",children:e.jsx("path",{d:"M4 16l4.586-4.586a2 2 0 0 1 2.828 0L16 16m-2-2l1.586-1.586a2 2 0 0 1 2.828 0L20 14m-6-6h.01M6 20h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Upload Media to Conversation"}),e.jsx("button",{type:"button",onClick:()=>{const a=Er().join(", ");b(`❌ Unsupported file types: ${a}
3384
3385✅ Supported: Images (JPG, PNG, GIF, WEBP), PDF, Video (MP4, WEBM, OGG), Audio (MP3, WAV, OGG), HTML files only.
3386📦 Max size: 100MB per file`,"info")},className:"text-xs text-gray-400 hover:text-gray-600 underline ml-1",children:"What's supported?"})]}),e.jsx("span",{className:"text-xs text-gray-400",children:"Up to 100MB per file"})]}),Ir&&e.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-sm text-red-600 flex items-center gap-2 whitespace-pre-wrap",children:[e.jsx(m,{icon:bt,className:"text-red-500 flex-shrink-0"}),e.jsx("span",{children:Ir})]})}),we.length===0?e.jsx("div",{className:`relative border-2 border-dashed rounded-xl p-8 text-center transition-all cursor-pointer ${rr?"border-[#22c55e] bg-green-50/50 scale-[0.99]":"border-gray-300 hover:border-[#22c55e] bg-gray-50 hover:bg-gray-100"}`,onClick:()=>{var a;return(a=Ae.current)==null?void 0:a.click()},onDragOver:a=>{a.preventDefault(),a.stopPropagation(),Mt(!0)},onDragEnter:a=>{a.preventDefault(),a.stopPropagation(),Mt(!0)},onDragLeave:a=>{a.preventDefault(),a.stopPropagation(),Mt(!1)},onDrop:a=>{var i;a.preventDefault(),a.stopPropagation(),Mt(!1),(i=a.dataTransfer.files)!=null&&i.length&&pr(a.dataTransfer.files)},"data-tooltip-id":"main-tooltip","data-tooltip-content":"Click to upload multiple files or drag & drop",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("svg",{className:`w-12 h-12 mb-3 transition-colors ${rr?"text-[#22c55e]":"text-gray-400"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsxs("p",{className:"text-sm text-gray-600",children:[e.jsx("span",{className:"font-semibold text-[#22c55e]",children:"Click to upload multiple files"})," or drag & drop"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"✅ Images (JPG, PNG, GIF, WEBP) • PDF • Video (MP4, WEBM, OGG) • Audio (MP3, WAV, OGG) • HTML"}),e.jsx("p",{className:"text-xs text-red-400 mt-1",children:"❌ Not supported: Markdown (.md), Archives (.zip, .rar), Executables, Spreadsheets, etc."}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Select one or multiple files at once (up to 100MB each)"})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("div",{className:"text-xs font-medium text-gray-600",children:[e.jsx("span",{className:"text-[#22c55e] font-semibold",children:we.length})," ",we.length===1?"file":"files"," selected (",Ft(t),")"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{var a;return(a=Ae.current)==null?void 0:a.click()},className:"text-xs font-medium text-[#22c55e] hover:text-[#16a34a] flex items-center gap-1 transition-colors px-2 py-1 rounded-md hover:bg-green-50",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add More"]}),e.jsx("button",{type:"button",onClick:()=>{Dn([]),nt(null),Ae.current&&(Ae.current.value="")},className:"text-xs font-medium text-red-500 hover:text-red-700 transition-colors px-2 py-1 rounded-md hover:bg-red-50",children:"Clear All"})]})]}),e.jsx("div",{className:`max-h-64 overflow-y-auto space-y-2 p-2 bg-gray-50/80 rounded-xl border ${rr?"border-[#22c55e] bg-green-50/30":"border-gray-200"}`,onDragOver:a=>{a.preventDefault(),a.stopPropagation(),Mt(!0)},onDragEnter:a=>{a.preventDefault(),a.stopPropagation(),Mt(!0)},onDragLeave:a=>{a.preventDefault(),a.stopPropagation(),Mt(!1)},onDrop:a=>{var i;a.preventDefault(),a.stopPropagation(),Mt(!1),(i=a.dataTransfer.files)!=null&&i.length&&pr(a.dataTransfer.files)},children:we.map((a,i)=>e.jsxs("div",{className:"relative flex items-center justify-between p-2.5 bg-white rounded-lg border border-gray-200 hover:border-gray-300 shadow-sm transition-all",children:[e.jsxs("div",{className:"flex items-center space-x-3 min-w-0 flex-1 mr-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-gradient-to-br from-[#22c55e] to-[#16a34a] flex-shrink-0 overflow-hidden",children:a.type.startsWith("image/")&&a.data?e.jsx("img",{src:a.data,alt:a.name,className:"w-10 h-10 object-cover rounded-lg"}):e.jsx(m,{icon:xi(a.type,a.name),className:"text-white text-lg"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-gray-900 truncate",title:a.name,children:a.name}),e.jsx("p",{className:"text-[11px] text-gray-400",children:Ft(a.size)})]})]}),e.jsx("button",{type:"button",onClick:()=>{Dn(l=>l.filter((o,u)=>u!==i))},className:"w-6 h-6 rounded-full bg-gray-100 hover:bg-red-50 text-gray-400 hover:text-red-500 flex items-center justify-center transition-colors flex-shrink-0",title:"Remove file",children:e.jsx(m,{icon:Yt,className:"text-xs"})})]},`${a.name}-${i}`))}),e.jsx("input",{type:"text",value:In,onChange:a=>mn(a.target.value),placeholder:"Add an optional description for these files...",className:"w-full px-4 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#22c55e]"}),e.jsx("button",{onClick:as,disabled:Rr||we.length===0,className:"w-full px-4 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white font-medium rounded-xl transition-colors flex items-center justify-center space-x-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-sm","data-tooltip-id":"main-tooltip","data-tooltip-content":"Upload files to the conversation",children:Rr?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),e.jsxs("span",{children:["Uploading ",we.length," ",we.length===1?"file":"files","..."]})]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Sr}),e.jsxs("span",{children:["Upload ",we.length," ",we.length===1?"File":"Files"]})]})})]}),e.jsx("input",{ref:Ae,type:"file",multiple:!0,className:"hidden",accept:"image/*,.pdf,video/*,audio/*,.mp4,.webm,.ogg,.mp3,.wav,.mov,.avi,.m4a,.html,.htm",onCh
3386ange:ss})]})},gs=()=>Le?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 border-2 border-dashed border-gray-200 rounded-xl bg-gray-50",children:[e.jsx("div",{className:"w-16 h-16 bg-white rounded-full flex items-center justify-center shadow-sm mb-4",children:e.jsx(m,{icon:Dt,className:"text-2xl text-[#22c55e]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Embed Row & Masonry Builder"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 text-center max-w-md",children:"Create beautiful rows, carousels, or masonry layouts with your embed snippets."}),e.jsxs("button",{onClick:()=>qn(!0),className:"px-6 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white font-medium rounded-xl transition-colors shadow-sm flex items-center gap-2",children:[e.jsx(m,{icon:Dt}),"Open Embed Builder"]})]})}):e.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-xl p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("p",{className:"text-gray-600 mb-2",children:"Login required to add comments"}),e.jsx("button",{onClick:()=>Te(!0),className:"inline-block px-6 py-2 bg-[#22c55e] text-white rounded-lg hover:bg-[#16a34a] transition-colors text-sm font-medium",children:"Login to Access"})]}),bs=()=>e.jsx(Sa,{onPost:is,className:"w-full",conversationId:r.conversation_id,contentFormat:Et}),ys=()=>Le?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3 border-b border-gray-200 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-gray-100 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>{cr("markdown"),tn("composer")},className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${Et==="markdown"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Use Markdown formatting",children:"Markdown"}),e.jsx("button",{onClick:()=>{cr("html"),tn("composer")},className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${Et==="html"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Use HTML formatting",children:"HTML"}),e.jsxs("button",{onClick:()=>{cr("ezsheet"),tn("composer")},className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${Et==="ezsheet"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Use EzSheet formatting",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"9",y1:"21",x2:"9",y2:"9"})]}),"EzSheet"]})]}),e.jsx("div",{className:"h-6 w-px bg-gray-200"}),e.jsxs("button",{onClick:()=>tn("upload"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${Fn==="upload"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Upload files (Images, PDF, Video, Audio, HTML up to 100MB)",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Upload Media"]}),e.jsxs("button",{onClick:()=>tn("embed"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors flex items-center gap-1.5 ${Fn==="embed"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Post Embed Content",children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Embed Content"]})]}),e.jsx("div",{className:"mt-3",children:Fn==="upload"?xs():Fn==="embed"?gs():bs()})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#9ca3af",strokeWidth:"2",children:e.jsx("path",{d:"M4 4v16h16V4H4z M8 9h8 M8 13h6 M8 17h4"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:(n==null?void 0:n.ai_search_view_login_required)||"Login Required"}),e.jsx("p",{className:"text-gray-600 mb-4",children:(n==null?void 0:n.ai_search_view_login_to_post)||"Please log in to create content posts"}),e.jsx("button",{onClick:()=>Te(!0),className:"px-6 py-2 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium",children:(n==null?void 0:n.ai_search_view_login)||"Log In"})]}),vs=()=>wt?Le?e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 sm:p-4 border-b border-gray-200 overflow-x-auto no-scrollbar flex-nowrap sm:flex-wrap",children:[e.jsx("button",{onClick:()=>
3386{Br("social"),tn("composer")},className:`px-4 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none ${Rn==="social"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_social_post)||"Create content with Markdown or HTML",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"})]}),e.jsx("span",{children:"Social & Upload"})]})}),e.jsx("button",{onClick:()=>Br("text"),className:`px-4 py-2 text-sm font-semibold rounded-md transition-colors duration-200 focus:outline-none ${Rn==="text"?"bg-[#22c55e] text-white":"text-gray-600 hover:bg-gray-100"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_ask_ai)||"Ask AI a question",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7v8H3v-8a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-1.01-1-1.73a2 2 0 0 1 2-2Z"}),e.jsx("path",{d:"M9 12h6"}),e.jsx("path",{d:"M12 9v6"})]}),e.jsx("span",{children:"Ask AI"})]})})]}),e.jsxs("div",{className:"p-6",children:[Rn==="social"&&ys(),Rn==="text"&&e.jsx("form",{onSubmit:t=>ta(t),children:Wn?e.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-6 text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4"}),e.jsx("path",{d:"M12 16h.01"})]})}),e.jsx("h3",{className:"text-lg font-semibold text-yellow-800 mb-2",children:(n==null?void 0:n.ai_search_view_disabled)||"Ask AI Disabled"}),e.jsxs("p",{className:"text-yellow-700",children:["Ask AI is currently disabled for ",E?"logged-in users":"guests",". Please try again later."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:Ua,value:S,onChange:t=>{const a=t.target.value;z===0?vt((n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled"):a.length<=z?(se(a),vt("")):vt(((n==null?void 0:n.ai_search_view_question_too_long)||"Maximum {max} characters allowed").replace("{max}",z.toString()))},onKeyDown:os,placeholder:z===0?(n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled":((n==null?void 0:n.ai_search_view_question_placeholder)||"Ask a follow-up question... (Max {max} chars, Press Enter to send, Shift+Enter for new line)").replace("{max}",z.toString()),className:`w-full bg-gray-50 border ${S.length>z||Sn?"border-red-500 focus:ring-red-500":"border-gray-200 focus:ring-[#22c55e]"} rounded-lg py-3 px-4 pr-32 text-sm focus:outline-none focus:ring-2 focus:border-transparent min-h-[100px] resize-y`,disabled:ye||z===0,rows:3,maxLength:z===0?0:z,"data-tooltip-id":"main-tooltip","data-tooltip-content":z===0?(n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled":((n==null?void 0:n.ai_search_view_characters_remaining)||"Maximum {max} characters. You have {remaining} remaining.").replace("{max}",z.toString()).replace("{remaining}",(z-S.length).toString())}),z>0&&e.jsx("div",{className:"absolute bottom-3 right-3 text-xs",children:e.jsxs("span",{className:`${S.length>z?"text-red-500 font-bold":"text-gray-400"}`,children:[S.length,"/",z]})}),e.jsx("div",{className:"absolute bottom-3 right-16",children:e.jsx("button",{type:"submit",disabled:!S.trim()||ye||S.length>z||z===0,className:"px-4 py-2 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2","data-tooltip-id":"main-tooltip","data-tooltip-content":z===0?(n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled":S.trim()?S.length>z?((n==null?void 0:n.ai_search_view_question_too_long)||"Question too long (max {max} chars)").replace("{max}",z.toString()):ye?(n==null?void 0:n.ai_search_view_ai_thinking)||"AI is thinking...":(n==null?void 0:n.ai_search_view_send_question)||"Send your question to AI":(n==null?void 0:n.ai_search_view_type_question)||"Type a question first",children:ye?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),e.jsx("span",{children:"Asking..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Yn}),e.jsx("span",{children:"Ask AI"})]})})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 text-sm text-gray-500",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_press_enter)||"Press Enter to send your message",children:"Press Enter to send"}),e.jsx("span",{children:"•"}),e.jsx("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_shift_enter)||"Use Shift+Enter to add a new line",children:"Shift+Enter for new line"})]}),e.jsx("div",{className:"flex items-center space-x-4",children:e.jsx("span",{className:`${S.length>z?"text-red-500 font-semibold":""}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":z===0?(n==null?void 0:n.ai_search_view_disabled)||"Ask AI is disabled":E?((n==null?void 0:n.ai_search_view_char_remaining)||"You have {remaining} characters remaining").replace("{remaining}",(z-S.length).toString()):((n==null?void 0:n.ai_search_view_login_for_more)||"Login for up to {limit} characters").replace("{limit}",((H==null?void 0:H.user_char_limit)||2e3).toString()),children:z===0?"Disabled":S.length>z?((n==null?void 0:n.ai_search_view_exceeded_by)||"⚠️ Exceeded by {count}").replace("{count}",(S.length-z).toString()):((n==null?void 0:n.ai_search_view_char_count)||"{current}/{max} chars").replace("{current}",S.length.toString()).replace("{max}",z.toString())})})]}),Sn&&e.jsxs("div",{className:"mt-2 text-sm text-red-600 flex items-center gap-1",children:[e.jsx(m,{icon:bt,className:"w-4 h-4"}),Sn]})]})})]})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4"}),e.jsx("path",{d:"M12 16h.01"})]})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:(n==null?void 0:n.ai_search_view_login_required)||"Login Required"}),e.jsx("p",{className:"text-gray-600 mb-4",children:(n==null?void 0:n.ai_search_view_login_to_interact)||"Please log in to ask AI, post comments, upload files, and create content posts."}),e.jsx("button",{onClick:()=>Te(!0),className:"px-6 py-2 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium",children:(n==null?void 0:n.ai_search_view_login)||"Log In"}),e.jsx("button",{onClick:()=>Te(!1),className:"ml-3 px-6 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-lg transition-colors font-medium",children:(n==null?void 0:n.ai_search_view_cancel)||"Cancel"})]}):e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(m,{icon:bn,className:"text-2xl text-purple-600"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:ie==="private"?(n==null?void 0:n.ai_search_view_private_conversation)||"Private Conversation":(n==null?void 0:n.ai_search_view_access_required)||"Access Required"}),e.jsx("p",{className:"text-gray-600 mb-4",children:ie==="private"?"This is a private conversation. Please request access to continue."
3386:"You don't have permission to interact with this conversation."}),ie==="private"&&e.jsx("button",{onClick:()=>On(!0),className:"px-6 py-2 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_request_access)||"Request access to this private conversation",children:"Request Access"})]}),ws=()=>e.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:ea}),e.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:e.jsxs("div",{className:"relative bg-white rounded-xl shadow-xl max-w-md w-full p-6 transform transition-all",children:[e.jsx("button",{onClick:ea,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":"Close",children:e.jsx(m,{icon:Yt})}),e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(m,{icon:bn,className:"text-2xl text-purple-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Private Conversation"}),e.jsx("p",{className:"text-gray-600 text-sm",children:Dr==="request"?"This conversation is private. Enter your email to request access.":"Check your email for the access code."})]}),Dr==="request"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Email Address"}),e.jsx("input",{type:"email",value:Pe,onChange:t=>Hn(t.target.value),placeholder:"[email protected]",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent",onKeyPress:t=>{t.key==="Enter"&&Jr()},disabled:ar,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Enter your email address to receive access code"})]}),e.jsx("button",{onClick:Jr,disabled:ar||!Pe,className:"w-full bg-purple-600 hover:bg-purple-700 text-white font-medium py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2","data-tooltip-id":"main-tooltip","data-tooltip-content":Pe?"Request access code":"Please enter your email",children:ar?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:ba}),"Request Access"]})}),e.jsxs("div",{className:"relative mt-6",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-300"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-white text-gray-500",children:"Already have an access code?"})})]}),e.jsxs("button",{onClick:()=>{if(!Pe||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Pe)){w("Please enter your email address first");return}Un(Pe),fn("verify"),Gt(""),w(""),setTimeout(()=>{var t;(t=nn.current[0])==null||t.focus()},100)},disabled:!Pe||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Pe),className:"w-full mt-4 bg-gray-100 hover:bg-gray-200 text-gray-700 font-medium py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2","data-tooltip-id":"main-tooltip","data-tooltip-content":Pe?"Enter your access code":"Please enter your email first",children:[e.jsx(m,{icon:ca}),"I already have an access code"]}),e.jsx("p",{className:"text-xs text-center text-gray-500 mt-4",children:"We'll send a 4-digit access code to your email."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Access Code"}),e.jsx("div",{className:"flex gap-3 justify-center",children:[0,1,2,3].map(t=>e.jsx("input",{ref:a=>nn.current[t]=a,type:"text",value:ut[t]||"",onChange:a=>Xa(t,a.target.value),onKeyDown:a=>Qa(t,a),onFocus:a=>a.target.select(),placeholder:"•",maxLength:1,className:"w-16 h-20 text-3xl text-center bg-white border-2 border-gray-300 rounded-xl focus:border-purple-500 focus:outline-none focus:ring-2 focus:ring-purple-500 transition-colors font-mono",disabled:sr,"data-tooltip-id":"main-tooltip","data-tooltip-content":"Enter the 4-digit code sent to your email"},t))}),e.jsxs("p",{className:"text-sm text-gray-600 mt-3 text-center",children:["Code sent to: ",e.jsx("span",{className:"font-medium",children:qr||Pe})]})]}),e.jsx("button",{onClick:$r,disabled:sr||ut.length!==4,className:"w-full bg-purple-600 hover:bg-purple-700 text-white font-medium py-3 px-4 roun
3386ded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2","data-tooltip-id":"main-tooltip","data-tooltip-content":ut.length!==4?"Please enter the 4-digit code":"Verify your access code",children:sr?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),"Verifying..."]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:ca}),"Verify Access"]})}),e.jsxs("div",{className:"flex gap-3 mt-3",children:[e.jsx("button",{onClick:()=>{fn("request"),Gt(""),w("")},className:"flex-1 text-sm text-purple-600 hover:text-purple-700 font-medium py-2","data-tooltip-id":"main-tooltip","data-tooltip-content":"Request a new access code",children:"Didn't receive code?"}),e.jsx("button",{onClick:()=>{fn("request"),Hn(""),Gt(""),w(""),Un("")},className:"flex-1 text-sm text-gray-500 hover:text-gray-700 font-medium py-2","data-tooltip-id":"main-tooltip","data-tooltip-content":"Use a different email",children:"Use different email"})]})]}),Je&&e.jsx("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 text-red-600 rounded-lg text-sm",children:Je}),ct&&e.jsx("div",{className:"mt-4 p-3 bg-green-50 border border-green-200 text-green-600 rounded-lg text-sm",children:ct})]})})]});return Tr?e.jsxs(e.Fragment,{children:[e.jsx(br,{title:"Checking Access..."}),e.jsx("div",{className:"min-h-screen bg-[#FCFCFC] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 border-4 border-gray-200 border-t-[#22c55e] rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:(n==null?void 0:n.ai_search_view_loading_more)||"Checking access permissions..."})]})})]}):!wt&&!pn?e.jsxs(e.Fragment,{children:[e.jsx(br,{title:"Access Denied | Ez.wiki"}),e.jsx("div",{className:"min-h-screen bg-[#FCFCFC] flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 shadow-lg max-w-md w-full p-8 text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-6",children:ie==="hidden"?e.jsx(m,{icon:yr,className:"text-3xl text-red-600"}):e.jsx(m,{icon:Ps,className:"text-3xl text-red-600"})}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-3",children:ie==="hidden"?(n==null?void 0:n.ai_search_view_hidden_conversation)||"Conversation Hidden":_e?(n==null?void 0:n.ai_search_view_login_required)||"Login Required":(n==null?void 0:n.ai_search_view_private_conversation)||"Access Denied"}),e.jsx("p",{className:"text-gray-600 mb-6",children:Xn||(_e?"The owner of this conversation has disabled guest interaction. Please log in to continue.":ie==="hidden"?"This conversation has been hidden and is not available for viewing.":"You do not have permission to view this conversation.")}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xt,{href:"/",className:"block w-full px-4 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_go_homepage)||"Go to homepage",children:"Go to Homepage"}),(ie==="private"||_e)&&!E&&e.jsx(xt,{href:"/login",className:"block w-full px-4 py-3 border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-lg transition-colors font-medium","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_login)||"Log In",children:"Log In"})]})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(br,{title:`${Me} | Ez.wiki AI Conversation`}),e.jsx(Us,{id:"main-tooltip",place:"top",className:"!bg-gray-900 !text-white !text-xs !px-3 !py-2 !rounded-lg !z-[100] !shadow-xl",effect:"solid"}),(W==null?void 0:W.user)&&e.jsx(qs,{auth:W,parentSlug:r.slug,conversationId:r.conversation_id,onChildConvoCreated:async(t,a)=>{await xn(void 0,t,a||"embed")}}),e.jsxs("div",{className:"min-h-screen bg-[#FCFCFC] text-slate-800",children:[pn&&ws(),yt&&e.jsx("div",{className:"fixed top-20 left-1/2 transform -translate-x-1/2 z-50 max-w-4xl w-full px-4 animate-slideDown",children:e.jsxs("div",{className:"bg-gradient-to-r from-green-50 to-emerald-50 border border-green-200 text-green-800 rounded-xl shadow-lg p-4 backdrop-blur-sm relative pr-12",children:[e.jsx("button",{onClick:()=>{Vt(null),sn(null)},className:"absolute top-4 right-4 text-green-600 hover:text-green-800 transition-colors","aria-label":"Close alert","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_alert)||"Close notification",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),yt]})}),Je&&!hn.show&&e.jsxs("div",{className:"fixed top-20 right-4 bg-red-600 text-white px-4 py-2 rounded-md shadow-lg z-50","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_error_notification)||"Error notification",children:[e.jsx(m,{icon:bt,className:"mr-2"}),Je]}),ct&&!pn&&!hn.show&&e.jsxs("div",{className:"fixed top-20 right-4 bg-green-600 text-white px-4 py-2 rounded-md shadow-lg z-50","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_success_notification)||"Success notification",children:[e.jsx(m,{icon:gt,className:"mr-2"}),ct]}),_a&&e.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:()=>Te(!1)}),e.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:e.jsxs("div",{className:"relative bg-white rounded-xl shadow-xl max-w-md w-full p-6 transform transition-all",children:[e.jsx("button",{onClick:()=>Te(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_login_prompt_close)||"Close",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),e.jsxs("div",{className:"mb-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-yellow-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4"}),e.jsx("path",{d:"M12 16h.01"})]})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:(n==null?void 0:n.ai_search_view_login_required)||"Login Required"}),e.jsx("p",{className:"text-gray-600",children:(n==null?void 0:n.ai_search_view_login_to_interact)||"Please log in to ask AI, post comments, upload files, and create content posts."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(xt,{href:"/login",className:"block w-full px-4 py-3 bg-[#22c55e] hover:bg-[#16a34a] text-white rounded-lg transition-colors font-medium text-center","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_login)||"Log In",children:"Log In"}),e.jsx(xt,{href:"/register",className:"block w-full px-4 py-3 border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-lg transition-colors font-medium text-center","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_create_account)||"Create Account",children:"Create Account"}),e.jsx("button",{onClick:()=>Te(!1),className:"block w-full px-4 py-3 text-gray-500 hover:text-gray-700 transition-colors font-medium text-center","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_login_prompt_close)||"Close",children:"Close"})]})]})})]}),e.jsx("header",{className:"border-b border-gray-200 bg-white sticky top-0 z-40 shadow-sm w-full",children:e.jsx("div",{className:"w-full mx-auto px-2 lg:px-4 py-2 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center space-x-1 sm:space-x-4 lg:ml-[15%]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>on(!Oe),className:"w-8 h-8 bg-gradient-to-br from-emerald-500 to-emerald-600 rounded-full flex items-center justify-center text-white shadow-sm",children:e.jsx(m,{icon:Oe?Ls:Bs,className:"text-[10px]"})}),e.jsx("button",{onClick:()=>Cn(!Ot),className:"w-8 h-8 bg-gradient-to-br from-emerald-500 to-emerald-600 rounded-full flex items-center justify-center text-white shadow-sm",children:e.jsx(m,{icon:Ot?la:vr,className:"text-[10px]"})})]}),e.jsxs("a",{href:"https://ez.wiki/aihome",className:"flex items-center space-x-1",target:"_blank",rel:"noopener noreferrer",children:[e.jsx("img",{src:"/ezlogo.png",alt:"Logo",className:"w-6 h-6 sm:w-8 sm:h-8 object-contain"}),e.jsxs("span",{className:"text-sm sm:text-xl font-bold text-gray-900",children:["Ez",e.jsx("span",{className:"hidden sm:inline",children:".wiki"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-1 sm:space-x-3",children:[e.jsx("div",{className:"transform scale-90 sm:scale-100 origin-right",children:e.jsx(hs,{})}
3386),e.jsxs("button",{onClick:Ka,className:"w-9 h-9 sm:w-auto sm:px-4 sm:py-2 bg-green-500 text-white rounded-lg flex items-center justify-center sm:space-x-2 shadow-sm","data-tooltip-id":"main-tooltip","data-tooltip-content":"EXPRESS DOMAIN",children:[e.jsx(m,{icon:da,className:"text-sm"}),e.jsx("span",{className:"hidden sm:inline text-xs font-bold",children:"EXPRESS DOMAIN"})]}),e.jsxs("button",{onClick:()=>{U("share"),A(!0)},className:"w-9 h-9 sm:w-auto sm:px-4 sm:py-2 bg-gray-100 text-gray-700 hover:bg-gray-200 rounded-lg flex items-center justify-center sm:space-x-2 border border-gray-200","data-tooltip-id":"main-tooltip","data-tooltip-content":"Share conversation",children:[e.jsx(m,{icon:kn,className:"text-sm text-green-600"}),e.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:"Share"})]}),e.jsxs("button",{onClick:()=>{U("embed"),A(!0)},className:"w-9 h-9 sm:w-auto sm:px-4 sm:py-2 bg-indigo-50 text-indigo-700 hover:bg-indigo-100 rounded-lg flex items-center justify-center sm:space-x-2 border border-indigo-200","data-tooltip-id":"main-tooltip","data-tooltip-content":"Get Embed Code",children:[e.jsx(m,{icon:Dt,className:"text-sm text-indigo-600"}),e.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:"Embed"})]}),e.jsxs("button",{onClick:Ga,className:"w-9 h-9 sm:w-auto sm:px-4 sm:py-2 bg-gray-100 text-gray-700 rounded-lg flex items-center justify-center sm:space-x-2 border border-gray-200","data-tooltip-id":"main-tooltip","data-tooltip-content":"Copy Link",children:[e.jsx(m,{icon:It,className:"text-sm"}),e.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:Qe?"Copied":"Copy"})]}),e.jsxs("button",{onClick:()=>qn(!0),className:"w-9 h-9 sm:w-auto sm:px-4 sm:py-2 bg-[#22c55e] text-white rounded-lg flex items-center justify-center sm:space-x-2 shadow-sm","data-tooltip-id":"main-tooltip","data-tooltip-content":"Create New Embed Conversation",children:[e.jsx(m,{icon:wr,className:"text-sm"}),e.jsx("span",{className:"hidden sm:inline text-xs font-medium",children:"New"})]})]})]})})}),tr&&e.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:Zn}),e.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:e.jsxs("div",{className:"relative bg-white rounded-xl shadow-xl max-md w-full p-6 transform transition-all",children:[e.jsx("button",{onClick:Zn,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_modal)||"Close modal",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mb-4",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-purple-600",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H5.78a1.65 1.65 0 0 0-1.51 1 1.65 1.65 0 0 0 .33 1.82l.05.05A10 10 0 0 0 12 17.66a10 10 0 0 0 6.24-2.28l.05-.05Z"}),e.jsx("path",{d:"M6.3 8.7 7.7 7.3"}),e.jsx("path",{d:"M17.7 8.7 16.3 7.3"}),e.jsx("path",{d:"M9 5 8 3"}),e.jsx("path",{d:"M15 5 16 3"})]})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:(n==null?void 0:n.ai_search_view_save_theme)||"Save to eztheme"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Enter your email address to save this conversation to your eztheme collection."})]}),e.jsxs("form",{onSubmit:Va,children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-2",children:["Email address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{ref:ur,type:"email",id:"email",value:fe,onChange:t=>{zn(t.target.value),_n("")},placeholder:"[email protected]",className:`w-full px-4 py-2.5 border ${nr?"border-red-500":"border-gray-300"} rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent transition-colors`,disabled:je,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_save_theme_email)||"Enter your email to receive theme access"}),nr&&e.jsx("p",{className:"mt-2 text-sm text-red-600",children:nr})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("button",{type:"button",onClick:Zn,className:"flex-1 px-4 py-2.5 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors text-sm font-medium",disabled:je,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_cancel)||"Cancel and close",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:je||!fe.trim(),className:"flex-1 px-4 py-2.5 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed text-sm font-medium flex items-center justify-center space-x-2","data-tooltip-id":"main-tooltip","data-tooltip-content":fe.trim()?(n==null?void 0:n.ai_search_view_save_theme_button)||"Save this conversation as a theme":(n==null?void 0:n.ai_search_view_theme_email_required)||"Email is required",children:je?e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"animate-spin",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),e.jsx("span",{children:(n==null?void 0:n.ai_search_view_saving_theme)||"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),e.jsx("span",{children:(n==null?void 0:n.ai_search_view_save_theme)||"Save Theme"})]})})]})]}),e.jsx("p",{className:"mt-4 text-xs text-center text-gray-500",children:"We'll send you a confirmation email. You can unsubscribe at any time."})]})})]}),Re&&e.jsx("div",{className:"fixed inset-0 bg-black/70 min-h-screen flex items-center justify-center z-[100] p-4 overflow-y-auto",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl max-w-4xl w-full relative max-h-[90vh] overflow-y-auto border border-gray-200",children:[e.jsx("button",{onClick:Ja,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors z-10 bg-gray-100 hover:bg-gray-200 rounded-full w-8 h-8 flex items-center justify-center","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_express)||"Close express domain modal",children:e.jsx(m,{icon:Yt,className:"text-gray-600"})}),e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 bg-gradient-to-br from-green-100 to-green-200 rounded-2xl mb-4","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_express_domain_service)||"Express Domain Service",children:e.jsx(m,{icon:da,className:"text-2xl text-green-600"})}),e.jsx("h3",{className:"text-3xl font-bold text-gray-900 mb-3",children:(n==null?void 0:n.ai_search_view_express_domain)||"Get Your Express Domain"}),e.jsx("p",{className:"text-gray-600 text-lg",children:(n==null?void 0:n.ai_search_view_express_domain_description)||"Choose your preferred option to establish your Web3 presence"})]}),un.success&&e.jsxs("div",{className:"mb-6 p-4 bg-green-50 border border-green-200 rounded-xl relative",children:[e.jsx("button",{onClick:()=>en({success:!1,message:"",url:""}),className:"absolute top-4 right-4 text-green-600 hover:text-green-800 transition-colors","aria-label":"Close alert","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_success)||"Close success notification",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 text-green-600 mb-2",children:[e.jsx(m,{icon:gt,className:"text-2xl"}),e.jsx("span",{className:"text-lg font-semibold",children:"Purchase Successful!"})]}),e.jsxs("div",{className:"text-center text-gray-700 mb-3",children:[un.message,e.jsx("a",{href:un.url,target:"_blank",rel:"noopener noreferrer",className:"text-green-600 hover:text-green-700 hover:underline font-medium ml-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_purchase_successful)||"Visit your new domain",children:un.url})]})]}),e.jsx("div",{className:"flex justify-center items-center gap-4 mb-10",children:e.jsxs("button",{onClick:()=>$a("domain"),className:`flex items-center justify-center py-3 px-8 rounded-xl shadow-sm font-semibold transition-all ${ve==="domain"?"bg-green-500 text-white shadow-md shadow-green-200":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_brand_domain)||"Get a full domain name (yourbrand.domain)",children:[e.jsx(m,{icon:_s,className:"mr-2"}),"Brand Domain"]})}),e.jsxs("div",{className:"flex flex-col md:flex-row justify-center items-center gap-4 max-w-3xl mx-auto mb-8",children:[e.jsx("div",{className:"relative w-full md:w-2/5",children:e.jsx("input",{type:"text",placeholder:"Enter your brand name",className:"w-full bg-gray-50 border border-gray-200 text-gray-900 py-4 px-6 rounded-xl focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent placeholder-gray-400",value:Z,onChange:t=>Ht(t.target.value),onKeyPress:t=>{t.key==="Enter"&&mr()},"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_enter_brand)||"Enter your desired brand name or handle"})}),e.jsxs("div",{className:"relative w-full md:w-2/5",children:[e.jsx("select",{className:"w-full bg-gray-50 text-gray-900 py-4 px-6 pr-10 rounded-xl border border-gray-200 focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent appearance-none",value:ce,onChange:t=>dn(t.target.value),"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_select_domain)||"Select a domain extension",children:lt==null?void 0:lt.map(t=>e.jsxs("option",{value:t.domain,children:[".",t.domain]},t.id))}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-3 text-gray-400",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})})]}),e.jsx("button",{onClick:mr,className:`w-full md:w-1/5 font-bold py-4 px-6 rounded-xl shadow-sm flex items-center justify-center transition-all ${P.checking?"bg-gray-100 text-gray-500":P.available!==null?P.available?"bg-green-500 text-white hover:bg-green-600 shadow-md shadow-green-200":"bg-red-500 text-white hover:bg-red-600":"bg-green-500 text-white hover:bg-green-600 shadow-md shadow-green-200"}`,disabled:dt||!Z||P.checking,"data-tooltip-id":"main-tooltip","data-tooltip-content":Z?P.checking?(n==null?void 0:n.ai_search_view_checking)||"Checking availability...":P.available?(n==null?void 0:n.ai_search_view_available)||"Domain is available!":(n==null?void 0:n.ai_search_view_check_availability)||"Check if your domain is available":(n==null?void 0:n.ai_search_view_enter_brand_first)||"Enter a brand name first",children:e.jsx("span",{children:P.checking?(n==null?void 0:n.ai_search_view_checking)||"Checking...":P.available!==null?P.available?(n==null?void 0:n.ai_search_view_available)||"Available ✓":(n==null?void 0:n.ai_search_view_unavailable)||"Unavailable ✗":(n==null?void 0:n.ai_search_view_check_availability)||"Check Availability"})})]}),!un.success&&P.message&&e.jsxs("div",{className:`text-center mb-4 transition-all duration-300 ${P.checking?"opacity-70":"opacity-100"}`,children:[e.jsx("div",{className:`flex items-center justify-center gap-2 text-sm font-medium mb-4 ${P.available?"text-green-600":P.available===!1?"text-red-500":"text-yellow-600"}`,children:P.checking?e.jsxs(e.Fragment,{children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),P.message||(n==null?void 0:n.ai_search_view_checking)||"Checking availability..."]}):e.jsxs(e.Fragment,{children:[P.available?e.jsx(m,{icon:gt,className:"text-green-500"}):e.jsx(m,{icon:bt,className:"text-red-500"}),P.message]})}),P.available&&be&&e.jsx("div",{className:"relative mb-8 overflow-hidden rounded-2xl",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:be},className:"w-full [&_*]:max-w-full [&_img]:w-full [&_img]:h-auto [&_img]:object-contain [&_iframe]:w-full [&_iframe]:h-auto [&_iframe]:aspect-video"})}),P.available&&P.price!==void 0&&e.jsxs("div",{className:"mt-8 max-w-2xl mx-auto",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-50 to-white border border-gray-200 rounded-xl p-6 mb-6",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:"Your domain will be:"}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_your_domain)||"Your new domain",children:[Z.trim(),".",ce]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-gray-500","data-tooltip-id":"main-tooltip","data-tooltip-content":((n==null?void 0:n.ai_search_view_characters)||"{count} characters in your brand name").replace("{count}",((sa=P.charCount)==null?void 0:sa.toString())||"0"),children:[P.charCount," characters"]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Price"}),e.jsxs("p",{className:"text-2xl font-bold text-green-600","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_final_price)||"Final price after any discounts",children:["US$",Number(Be.domainPrice).toFixed(2),Ce.valid&&e.jsx("span",{className:"text-green-400 text-sm ml-2",children:"🎉"})]})]})]})]})}),Ce.valid&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4 items-stretch mb-4",children:[e.jsxs("div",{className:"flex-1 bg-gradient-to-r from-emerald-50 to-teal-50 border border-emerald-200 p-4 rounded-xl text-center flex flex-col justify-center shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx("svg",{className:"w-5 h-5 text-emerald-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-emerald-700 text-sm font-semibold",children:(()=>{const t=P.promoPrice||P.price||0,a=Ce.discount||0,i=t-a;return i>0?`You save US${i.toFixed(2)}!`:a>0?"Discount applied!":"Coupon applied!"})()})]}),(()=>{const t=P.promoPrice||P.price||0,a=Ce.discount||0;return t-a>0?e.jsxs("p",{className:"text-xs text-gray-500 line-through",children:["Original: US$",t.toFixed(2)]}):null})()]}),e.jsxs("div",{className:"flex-1 bg-gradient-to-r from-amber-50 to-orange-50 border border-amber-200 p-4 rounded-xl text-center flex flex-col justify-center shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-amber-700 font-semibold text-base",children:"Final Price"})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900",children:["US$",Number(Be.domainPrice).toFixed(2)]}),e.jsx("p",{cl
3386assName:"text-xs text-gray-500 mt-1",children:"Including all fees"})]})]}),!Ce.valid&&Number(P.promoPrice)>0&&e.jsx("div",{className:"bg-blue-50 border border-blue-200 p-4 rounded-xl mb-6",children:e.jsxs("p",{className:"text-blue-700 font-semibold flex items-center justify-center gap-2","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_promo_price)||"Pre-launch promotional price",children:[e.jsx("span",{className:"text-xl",children:"✨"}),(n==null?void 0:n.ai_search_view_promo_price)||"Pre-launch Price",": US$",Number(P.promoPrice).toFixed(2)]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:(n==null?void 0:n.ai_search_view_enter_coupon)||"Have a coupon code?"}),e.jsx("div",{className:"flex gap-2",children:e.jsx("input",{type:"text",className:"flex-1 bg-gray-50 border border-gray-200 text-gray-900 px-4 py-3 rounded-xl focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent",placeholder:"Enter coupon code",value:Ze,onChange:t=>Ut(t.target.value),"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_enter_coupon)||"Enter a coupon code for discounts"})}),Ze&&e.jsx("div",{className:`mt-2 text-sm ${Ce.valid?"text-green-600":Ce.valid===!1?"text-red-500":"text-yellow-600"}`,children:Ce.message||"Validating coupon..."})]}),e.jsx("div",{className:"bg-gray-50 border border-gray-200 p-4 rounded-xl mb-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-700 font-medium",children:"Total Amount:"}),e.jsxs("span",{className:"text-2xl font-bold text-green-600","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_payment_amount)||"Final amount to pay",children:["US$",Number(Be.totalPrice).toFixed(2)]})]})}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"checkbox",id:"terms-checkbox",required:!0,className:"mt-1 mr-3 rounded border-gray-300 text-green-600 focus:ring-green-500",checked:qt,onChange:t=>$e(t.target.checked),"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_agree_terms)||"You must agree to the terms to continue"}),e.jsxs("label",{htmlFor:"terms-checkbox",className:"text-sm text-gray-600",children:["By claiming your domain you agree to the"," ",e.jsx("button",{type:"button",onClick:()=>window.open("/terms-and-conditions","_blank"),className:"text-green-600 hover:text-green-700 hover:underline focus:outline-none","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_view_terms)||"View terms and conditions",children:(n==null?void 0:n.ai_search_view_terms)||"Terms and Conditions"})," ","and"," ",e.jsx("button",{type:"button",onClick:()=>window.open("/privacy-policy","_blank"),className:"text-green-600 hover:text-green-700 hover:underline focus:outline-none","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_view_privacy)||"View privacy policy",children:(n==null?void 0:n.ai_search_view_privacy)||"Privacy Policy"})]})]})}),e.jsx("button",{onClick:()=>{Number(Be.totalPrice)===0?(D(ve),ae(!0)):ns()},className:"w-full bg-green-500 hover:bg-green-600 text-white font-bold py-4 px-6 rounded-xl transition-colors disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-green-200",disabled:dt||!qt,"data-tooltip-id":"main-tooltip","data-tooltip-content":qt?dt?"Processing your purchase...":Number(Be.totalPrice)===0?(n==null?void 0:n.ai_search_view_claim_free)||"Claim your free domain":(n==null?void 0:n.ai_search_view_proceed_payment)||"Proceed to payment":(n==null?void 0:n.ai_search_view_agree_terms)||"Please agree to terms first",children:dt?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),(n==null?void 0:n.ai_search_view_processing)||"Processing..."]}):Number(Be.totalPrice)===0?(n==null?void 0:n.ai_search_view_claim_free)||"Claim Free Domain":`Purchase Domain for US${Number(Be.totalPrice).toFixed(2)}`})]})]})]})]})}),J&&R&&e.jsx("div",{className:"fixed inset-0 bg-black/70 min-h-screen flex items-center justify-center z-[100] p-4 overflow-y-auto",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl max-w-md w-full relative max-h-[90vh] overflow-y-auto border border-gray-200",children:[e.jsx("button",{onClick:()=>{ae(!1),D(null),w(""),Nt(!1),St(!1),Bn(!1)},className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors z-10 bg-gray-100 hover:bg-gray-200 rounded-full w-8 h-8 flex items-center justify-center",disabled:$t,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_modal)||"Close payment modal",children:e.jsx(m,{icon:Yt,className:"text-gray-600"})}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-gradient-to-br from-green-100 to-green-200 rounded-xl mb-4","data-tooltip-id":"main-tooltip","data-tooltip-content":"ez.wiki payment",children:e.jsx("img",{src:"https://ez.wiki/logo.gif",className:"w-8 h-8 rounded-full object-cover",alt:"ez.wiki Logo"})}),e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:R==="handle"?"Handle Purchase":"Domain Purchase"}
3386),e.jsx("p",{className:"text-green-600 font-medium mt-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_your_domain)||"Your selected domain",children:R==="handle"?`${ce}/${Z.trim()}`:`${Z.trim()}.${ce}`})]}),e.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-xl p-4 mb-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-gray-600",children:"Domain Price:"}),e.jsxs("span",{className:"text-gray-900 font-semibold",children:["US$",Number(Be.domainPrice).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 border-t border-gray-200",children:[e.jsx("span",{className:"text-gray-900 font-bold",children:"Total:"}),e.jsxs("span",{className:"text-green-600 font-bold text-xl","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_payment_amount)||"Final payment amount",children:["US$",Number(Be.totalPrice).toFixed(2)]})]}),Ce.valid&&e.jsx("div",{className:"mt-3 p-2 bg-green-50 border border-green-200 rounded-lg text-center",children:e.jsxs("span",{className:"text-green-600 text-sm",children:["Coupon applied: ",Ce.message]})})]}),e.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-xl p-4 mb-6",children:[!Fe&&e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Create Account"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Email Address *"}),e.jsx("input",{type:"email",value:fe,onChange:t=>{zn(t.target.value),Nt(!1),St(!1),w("")},onBlur:t=>{t.target.value&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.target.value)&&qa(t.target.value)},placeholder:"Enter your email address",className:"w-full bg-white border border-gray-200 text-gray-900 py-2 px-4 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent",required:!0,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_payment_email)||"Enter your email for purchase confirmation"}),!$n&&er&&!Lr&&fe&&Fe===!0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600 mt-1",children:[e.jsx(m,{icon:bt}),"⚠️ This email doesn't belong to this conversation. You can still purchase the domain."]}),!$n&&er&&Lr&&fe&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 mt-1",children:[e.jsx(m,{icon:gt}),"✓ Verified: This email matches the conversation owner."]}),Fe!==null&&!$n&&er&&e.jsx("p",{className:`text-xs mt-1 ${Fe?"text-green-600":"text-yellow-600"}`,children:Fe?(n==null?void 0:n.ai_search_view_account_exists)||"✓ Account exists - no password needed":(n==null?void 0:n.ai_search_view_new_account)||"New account - password required"})]}),!Fe&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Password *"}),e.jsx("input",{type:"password",value:et,onChange:t=>Tn(t.target.value),placeholder:"Create your password",className:"w-full bg-white border border-gray-200 text-gray-900 py-2 px-4 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent",required:!0,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_create_password)||"Create a password for your new account"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Confirm Password *"}),e.jsx("input",{type:"password",value:Wt,onChange:t=>Pn(t.target.value),placeholder:"Confirm your password",className:"w-full bg-white border border-gray-200 text-gray-900 py-2 px-4 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-transparent",required:!0,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_confirm_password)||"Confirm your password"}),et!==Wt&&Wt&&e.jsx("p",{className:"text-red-500 text-xs mt-1",children:(n==null?void 0:n.ai_search_view_password_mismatch)||"Passwords do not match"})]})]})]}),e.jsx("button",{onClick:es,disabled:$t||!fe||!Fe&&(!et||!Wt||et!==Wt),className:"w-full bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-4 roun
3386ded-xl transition-colors disabled:opacity-70 disabled:cursor-not-allowed shadow-lg shadow-green-200","data-tooltip-id":"main-tooltip","data-tooltip-content":$t?(n==null?void 0:n.ai_search_view_processing)||"Processing payment...":fe?!Fe&&!et?(n==null?void 0:n.ai_search_view_password_required)||"Password is required for new account":(n==null?void 0:n.ai_search_view_proceed_payment)||"Proceed with payment":(n==null?void 0:n.ai_search_view_email_required)||"Email is required",children:$t?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(m,{icon:Ee,className:"animate-spin"}),(n==null?void 0:n.ai_search_view_processing)||"Processing payment..."]}):Number(Be.totalPrice)===0?((n==null?void 0:n.ai_search_view_claim_free_item)||"Claim Free {item}").replace("{item}",R==="handle"?"Handle":"Domain"):`Pay US${Number(Be.totalPrice).toFixed(2)}`}),e.jsxs("div",{className:"text-center text-xs text-gray-500 mt-4",children:[e.jsx("p",{children:"Payment secured by STRIPE. You'll be taken to a thank you page after the payment."}),e.jsxs("p",{className:"mt-1",children:[e.jsx(xt,{href:"/terms",className:"text-green-600 hover:underline",children:(n==null?void 0:n.ai_search_view_terms)||"Terms"})," and"," ",e.jsx(xt,{href:"/privacy",className:"text-green-600 hover:underline",children:(n==null?void 0:n.ai_search_view_privacy)||"Privacy"}),"."]})]})]})]})}),J&&te===2&&e.jsx("div",{className:"fixed inset-0 bg-black/70 min-h-screen flex items-center justify-center z-[100] p-4 overflow-y-auto",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl max-w-sm w-full relative max-h-[90vh] overflow-y-auto border border-gray-200",children:[e.jsx("button",{onClick:()=>{ae(!1),Q(1),w("")},className:"sticky top-0 right-0 ml-auto text-gray-400 hover:text-gray-600 transition-colors z-10 bg-gray-100 hover:bg-gray-200 rounded-full w-8 h-8 flex items-center justify-center m-2",disabled:$t,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_close_modal)||"Close payment modal",children:e.jsx(m,{icon:Yt,className:"text-gray-600"})}),e.jsxs("div",{className:"p-6",children:[Je&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 text-red-600 rounded-lg flex items-center gap-2",children:[e.jsx(m,{icon:bt}),e.jsx("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_error_notification)||"Error notification",children:Je})]}),$t&&e.jsx("div",{className:"absolute inset-0 bg-white/50 flex items-center justify-center rounded-lg",children:e.jsx(m,{icon:Ee,className:"animate-spin text-4xl text-green-500"})}),e.jsx(Cs,{stripe:mi,options:{clientSecret:cn,appearance:{theme:"stripe",variables:{colorPrimary:"#22c55e",colorBackground:"#ffffff",colorText:"#1f2937",colorDanger:"#ef4444",fontFamily:"Inter, system-ui, sans-serif",borderRadius:"12px"}}},children:cn?e.jsx(bi,{price:Number(Be.totalPrice),email:fe,clientSecret:cn,onSuccess:ts,onBack:()=>Q(1),onError:w,tooltips:n}):e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(m,{icon:Ee,className:"animate-spin text-2xl text-green-500"})})})]})]})}),za&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-1000",children:e.jsxs("div",{className:"bg-white rounded-xl p-6 max-w-md w-full mx-4 border border-gray-200 shadow-2xl",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-4",children:"Confirm Purchase"}),e.jsxs("p",{className:"text-gray-600 mb-2",children:["You're about to purchase:",e.jsx("span",{className:"text-green-600 font-medium ml-1",children:ve==="handle"?`@${Z.trim()}.${ce}`:`${Z.trim()}.${ce}`})]}),e.jsx("p",{className:"text-gray-500 text-sm mb-6",children:"This action cannot be undone. Please confirm to proceed."}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>Pr(!1),className:"px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors",disabled:dt,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_cancel_purchase)||"Cancel purchase",children:(n==null?void 0:n.ai_search_view_cancel)||"Cancel"}),e.jsxs("button",{onClick:rs,className:"px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 transition-colors flex items-center",disabled:dt,"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_confirm_purchase)||"Confirm and complete purchase",children:[dt&&e.jsx(m,{icon:Ee,className:"animate-spin mr-2"}),(n==null?void 0:n.ai_search_view_confirm)||"Confirm Purchase"]})]})]})}),e.jsx("main",{className:"container mx-auto w-full relative",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-8",children:[e.jsx("div",{className:`lg:col-span-1 mt-2 transition-all duration-300 ${Oe?"opacity-100 translate-x-0":"opacity-0 -translate-x-full hidden"}`,children:e.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-6 shadow-sm sticky top-24",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 break-words whitespace-normal overflow-hidden",style:{wordBreak:"break-word",hyphens:"auto"},"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_conversation_title)||"Conversation title",children:Me}),ie==="private"&&e.jsxs("span",{className:"text-xs bg-purple-100 text-purple-700 px-2 py-1 rounded-full flex items-center gap-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_private_conversation)||"Private conversation - requires access code",children:[e.jsx(m,{icon:bn,className:"w-3 h-3"}),"Private"]}),ie==="hidden"&&Ke&&e.jsxs("span",{className:"text-xs bg-gray-100 text-gray-700 px-2 py-1 rounded-full flex items-center gap-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_hidden_conversation)||"Hidden conversation - only visible to you",children:[e.jsx(m,{icon:yr,className:"w-3 h-3"}),"Hidden"]})]}),pt.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2 mb-3",children:pt.map(t=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs font-semibold bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800 border border-emerald-200/80 px-2.5 py-0.5 rounded-full transition-colors shadow-2xs","data-tooltip-id":"main-tooltip","data-tooltip-content":`Explore #${t}`,children:["#",t]},t))}),e.jsxs("div",{className:"flex items-center text-sm text-gray-600 space-x-2",children:[e.jsxs("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_messages)||"Total messages in this conversation",children:[M.length," messages"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{"data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_tokens)||"Total tokens used in this conversation",children:[xe," tokens"]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs("span",{className:"text-xs bg-green-100 text-green-700 px-2 py-1 rounded-full",children:["AI: ",M.filter(t=>t.content_type==="ai").length]}),e.jsxs("span",{className:"text-xs bg-purple-100 text-purple-700 px-2 py-1 rounded-full",children:["Comments: ",M.filter(t=>t.content_type==="comment").length]}),e.jsxs("span",{className:"text-xs bg-teal-100 text-teal-700 px-2 py-1 rounded-full",children:["Conv. Comments: ",M.filter(t=>t.content_type==="conversationcomment").length]}),e.jsxs("span",{className:"text-xs bg-emerald-100 text-emerald-700 px-2 py-1 rounded-full",children:["Embeds: ",M.filter(t=>t.content_type==="embed").length]}),e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-700 px-2 py-1 rounded-full",children:["Uploads: ",M.filter(t=>t.content_type==="upload").length]}),e.jsxs("span",{className:"text-xs bg-pink-100 text-pink-700 px-2 py-1 rounded-full",children:["Social: ",M.filter(t=>t.content_type==="social"||t.content_type==="social_media").length]})]})]}),ir.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(m,{icon:wr,className:"text-yellow-500 w-4 h-4"}),e.jsx("h2",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wider",children:(n==null?void 0:n.ai_search_view_pinned)||"Pinned Conversations"})]}),e.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1 scrollbar-thin",children:Ia?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(m,{icon:Ee,className:"animate-spin text-gray-400"})}):ir.map(t=>e.jsx(xt,{href:`/X/${encodeURIComponent(t.slug)}`,className:"block p-3 bg-yellow-50 hover:bg-yellow-100 rounded-lg transition-colors group border border-yellow-200","data-tooltip-id":"main-tooltip","data-tooltip-content":t.conversation_title,children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{icon:wr,className:"text-yellow-500 w-3 h-3 flex-shrink-0"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 truncate group-hover:text-[#22c55e] transition-colors",children:t.conversation_title})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-1",children:t.query_preview}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-400","data-tooltip-id":"main-tooltip","data-tooltip-content":`${t.message_count} messages`,children:[t.message_count," msgs"]}),e.jsx("span",{className:"text-xs text-gray-400","data-tooltip-id":"main-tooltip","data-tooltip-content":`Pinned on ${t.formatted_created_at}`,children:ht(t.created_at)}),t.status==="private"&&e.jsx(m,{icon:bn,className:"text-purple-400 w-3 h-3"})]})]})})},t.id))}),ir.length>0&&e.jsx(xt,{href:"/ai/dashboard",className:"block text-center text-xs text-[#22c55e] hover:text-[#16a34a] mt-3","data-tooltip-id":"main-tooltip","data-tooltip-content":"View all pinned conversations",children:"View all pinned →"})]}),pt.length>0&&e.jsxs("div",{className:"mb-6 bg-emerald-50/60 border border-emerald-100 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[#22c55e] font-black text-sm",children:"#"}),e.jsx("h2",{className:"text-xs font-bold text-gray-700 uppercase tracking-wider",children:"Hashtags"})]}),e.jsx("span",{className:"text-[10px] font-semibold bg-emerald-100 text-emerald-800 px-2 py-0.5 rounded-full",children:pt.length})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:pt.map(t=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs font-medium bg-white text-emerald-800 hover:text-white hover:bg-[#22c55e] border border-emerald-200 px-2.5 py-1 rounded-full transition-colors shadow-2xs","data-tooltip-id":"main-tooltip","data-tooltip-content":`Search for #${t}`,children:["#",t]},t))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wider mb-3",children:(n==null?void 0:n.ai_search_view_stats)||"Conversation Stats"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_messages)||"Number of messages exchanged",children:[e.jsx("span",{className:"text-xs text-gray-500 block",children:"Total Messages"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:M.length})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_tokens)||"Total tokens used (prompt + completion)",children:[e.jsx("span",{className:"text-xs text-gray-500 block",children:"Total Tokens"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:xe})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_ai_model)||"AI model used for responses",children:[e.jsx("span",{className:"text-xs text-gray-500 block",children:"AI Model"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:r.model})]}),e.jsxs("div",{className:"bg-gray-50 p-3 rounded-lg","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_conversation_cost_tooltip)||"Total cost of this conversation",children:[e.jsx("span",{className:"text-xs text-gray-500 block",children:"Total Cost"}),e.jsxs("span",{className:"text-sm font-semibold text-gray-900",children:["$",ge.toFixed(4)]})]})]})]}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"space-y-3",children:[M.length>0&&e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2 px-2",children:(n==null?void 0:n.ai_search_view_jump_to_message_title)||"Jump to Message"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto pr-1 scrollbar-thin scrollbar-track-gray-100",children:[M.filter(t=>t.message_role==="user").length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 mb-1 px-2 sticky top-0 bg-gray-50 py-1",children:"User Messages"}),e.jsx("ul",{className:"space-y-1",children:M.filter(t=>t.message_role==="user").map((t,a)=>{var l;let i=t.query;return t.content_type==="upload"?i=`[File] ${((l=t.file_data)==null?void 0:l.original_name)||t.query}`:t.content_type==="comment"?i=`[Comment] ${t.query}`:t.content_type==="conversationcomment"?i=`[Conv. Comment] ${t.query}`:t.content_type==="embed"?i="[Embed] Layout":(t.content_type==="social"||t.content_type==="social_media")&&(i=`[Social] ${wn(t.query).substring(0,40)}`),e.jsx("li",{children:e.jsxs("button",{onClick:()=>Kr(t.slug),className:"w-full text-left px-3 py-2 text-sm text-gray-700 hover:bg-white hover:text-[#22c55e] rounded-lg transition-colors truncate",title:i,"data-tooltip-id":"main-tooltip","data-tooltip-content":((n==null?void 0:n.ai_search_view_jump_to_message)||"Jump to: {preview}").replace("{preview}",i.substring(0,50)),children:[e.jsxs("span",{className:"inline-block w-6 text-gray-400",children:[a+1,"."]}
3386),i.substring(0,40),i.length>40?"...":""]})},t.id)})})]}),M.filter(t=>t.message_role==="assistant").length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-400 mb-1 px-2 sticky top-0 bg-gray-50 py-1",children:"AI Responses"}),e.jsx("ul",{className:"space-y-1",children:M.filter(t=>t.message_role==="assistant").map((t,a)=>{const i=wn(t.response||"").substring(0,40);return e.jsx("li",{children:e.jsxs("button",{onClick:()=>Kr(t.slug),className:"w-full text-left px-3 py-2 text-sm text-gray-700 hover:bg-white hover:text-[#22c55e] rounded-lg transition-colors truncate",title:wn(t.response||""),"data-tooltip-id":"main-tooltip","data-tooltip-content":((n==null?void 0:n.ai_search_view_jump_to_message)||"Jump to: {preview}").replace("{preview}",i),children:[e.jsxs("span",{className:"inline-block w-6 text-gray-400",children:[a+1,"."]}),i,i.length>40?"...":""]})},t.id)})})]})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 text-xs text-gray-600",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"AI messages:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="ai").length})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Comments:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="comment").length})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Conv. Comments:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="conversationcomment").length})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Embeds:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="embed").length})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"File uploads:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="upload").length})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Social media posts:"}),e.jsx("span",{className:"font-medium text-gray-900",children:M.filter(t=>t.content_type==="social"||t.content_type==="social_media").length})]})]}),e.jsxs("button",{onClick:()=>window.print(),className:"w-full px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-lg text-sm text-gray-700 flex items-center justify-center space-x-2 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_save_pdf)||"Save this conversation as a PDF file",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),e.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1-2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),e.jsx("rect",{width:"12",height:"8",x:"6",y:"14"})]}),e.jsx("span",{children:(n==null?void 0:n.ai_search_view_save_pdf)||"Save as PDF"})]})]})}),T.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700 uppercase tracking-wider mb-3",children:(n==null?void 0:n.ai_search_view_related)||"Related Conversations"}),e.jsx("div",{className:"space-y-3",children:T.filter(t=>t.status==="public").map((t,a)=>e.jsxs(xt,{href:`/X/${encodeURIComponent(t.slug)}`,className:"block p-3 bg-gray-50 hover:bg-gray-100 rounded-lg transition-colors group","data-tooltip-id":"main-tooltip","data-tooltip-content":`View related conversation: ${t.conversation_title}`,children:[e.jsx("p",{className:"text-sm text-gray-900 line-clamp-2 group-hover:text-[#22c55e] transition-colors",children:t.conversation_title}),mt(t.hashtag).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:mt(t.hashtag).slice(0,3).map(i=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(i)}`,target:"_blank",rel:"noopener noreferrer",onClick:l=>l.stopPropagation(),className:"text-[10px] font-medium bg-emerald-50 text-emerald-700 hover:bg-emerald-100 px-2 py-0.5 rounded-full border border-emerald-200 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":`Explore #${i}`,children:["#",i]},i))}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-500","data-tooltip-id":"main-tooltip","data-tooltip-content":((n==null?void 0:n.ai_search_view_total_messages)||"{count} messages in this conversation").replace("{count}",t.message_count.toString()),children:[t.message_count," msgs"]}),e.jsx("span",{className:"text-xs text-gray-500","data-tooltip-id":"main-tooltip","data-tooltip-content":`Created on ${ht(t.created_at)}`,children:ht(t.created_at)})]})]},a))})]})]})}),e.jsxs("div",{className:`${Oe?"lg:col-span-3":"lg:col-span-4"} transition-all duration-300`,children:[e.jsx("div",{className:`relative rounded-xl text-white mt-2 mb-2 transition-all duration-500 ease-in-out overflow-hidden ${Ot?"max-h-[500px] p-6 o
3386pacity-100":"max-h-0 p-0 opacity-0 mb-2"} ${ie==="private"?"bg-gradient-to-r from-purple-500 to-purple-600":ie==="hidden"?"bg-gradient-to-r from-gray-500 to-gray-600":"bg-gradient-to-r from-purple-500 to-purple-600"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold mb-2 flex items-center gap-2",children:[ie==="private"&&e.jsx(m,{icon:bn,className:"text-white/80"}),ie==="hidden"&&e.jsx(m,{icon:yr,className:"text-white/80"}),"AI Conversation"]}),e.jsx("p",{className:"text-purple-100",children:wt?"Continue chatting with AI in this conversation":"Viewing conversation"}),pt.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-purple-200 mr-1",children:"Hashtags:"}),pt.map(t=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs font-medium bg-white/20 hover:bg-white/30 text-white backdrop-blur-xs px-2.5 py-0.5 rounded-full border border-white/30 transition-colors","data-tooltip-id":"main-tooltip","data-tooltip-content":`Search for #${t}`,children:["#",t]},t))]})]}),e.jsxs("div",{className:"text-right mr-8",children:[e.jsxs("div",{className:"text-sm text-purple-200","data-tooltip-id":"main-tooltip","data-tooltip-content":"Unique conversation identifier",children:["ID: ",r.conversation_id.substring(0,8),"..."]}),e.jsxs("div",{className:"text-sm text-purple-200","data-tooltip-id":"main-tooltip","data-tooltip-content":`Started on ${ht(r.created_at)}`,children:["Started: ",ht(r.created_at)]}),e.jsxs("div",{className:"text-sm text-purple-200 mt-1 font-bold","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_conversation_cost_tooltip)||"Total cost of this conversation",children:["Total Cost: $",ge.toFixed(4)]})]})]})}),!Ot&&e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-4",children:[pt.length>0?e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs font-semibold text-gray-500 mr-1 flex items-center gap-1",children:[e.jsx("span",{className:"text-[#22c55e] font-bold",children:"#"})," Hashtags:"]}),pt.map(t=>e.jsxs("a",{href:`/public/ai/history?searchhashtag=%23${encodeURIComponent(t)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs font-medium bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800 border border-emerald-200/80 px-2.5 py-0.5 rounded-full transition-colors shadow-2xs","data-tooltip-id":"main-tooltip","data-tooltip-content":`Search for #${t}`,children:["#",t]},t))]}):e.jsx("div",{}),e.jsxs("button",{onClick:()=>Cn(!0),className:"text-xs font-bold text-gray-400 hover:text-[#22c55e] flex items-center gap-2 bg-gray-100 px-3 py-1.5 rounded-full transition-all border border-gray-200 shadow-sm ml-auto",children:[e.jsx(m,{icon:vr})," SHOW CONVERSATION INFO"]})]}),e.jsxs("div",{ref:Ha,className:"bg-white rounded-xl border border-gray-200 shadow-sm mb-6",children:[e.jsxs("div",{className:"p-6",children:[M.length>0?(()=>{const t=x=>x.content_type==="comment"?!0:x.parent_id!==null&&x.parent_id!==void 0?x.message_role==="assistant"&&x.content_type!=="upload"&&x.content_type!=="social"&&x.content_type!=="social_media"?!1:M.some(L=>L.id===x.parent_id):!1,a=M.filter(x=>!t(x)),i=M.filter(x=>t(x)),l=a.length>0?a:[M[0]],o=a.length>0?i:M.slice(1),u=new Set(l.map(x=>x.id)),d=new Set(l.map(x=>
3386x.slug).filter(Boolean)),c=(x,L)=>{const ne=o.filter(k=>k.parent_id===x.id),V=oe.filter(k=>k.message_id===x.id||k.parent_id===x.id||k.message_slug&&x.slug&&k.message_slug===x.slug),Ve=new Set,st=V.map(k=>{if(k.content_type!=="ai"){const Ie=k.ai_reply||V.find(Xe=>Xe.parent_id===k.id&&Xe.content_type==="ai")||oe.find(Xe=>Xe.parent_id===k.id&&Xe.content_type==="ai");if(Ie)return Ie.id&&Ve.add(Ie.id),{...k,ai_reply:Ie}}return k});st.forEach(k=>{k.content_type==="ai"&&k.parent_id&&V.some(Xe=>Xe.id===k.parent_id)&&Ve.add(k.id)});const ue=st.filter(k=>!Ve.has(k.id));let C=[...ne.map(k=>({kind:"msg",data:k,key:`msg-${k.id}`})),...ue.map(k=>({kind:"db",data:k,key:`db-${k.id}`}))];if(L===0){const k=o.filter(Y=>!Y.parent_id||!u.has(Y.parent_id)),Ie=oe.filter(Y=>!(Y.message_id&&u.has(Y.message_id)||Y.parent_id&&u.has(Y.parent_id)||Y.message_slug&&d.has(Y.message_slug))),Xe=new Set,ia=Ie.map(Y=>{if(Y.content_type!=="ai"){const Zt=Y.ai_reply||Ie.find(gn=>gn.parent_id===Y.id&&gn.content_type==="ai")||oe.find(gn=>gn.parent_id===Y.id&&gn.content_type==="ai");if(Zt)return Zt.id&&Xe.add(Zt.id),{...Y,ai_reply:Zt}}return Y});ia.forEach(Y=>{Y.content_type==="ai"&&Y.parent_id&&Ie.some(Zt=>Zt.id===Y.parent_id)&&Xe.add(Y.id)});const ks=ia.filter(Y=>!Xe.has(Y.id));C=[...C,...k.map(Y=>({kind:"msg",data:Y,key:`msg-${Y.id}`})),...ks.map(Y=>({kind:"db",data:Y,key:`db-${Y.id}`}))]}const O=new Set;return C.filter(k=>O.has(k.key)?!1:(O.add(k.key),!0))};return e.jsx("div",{className:"space-y-10",children:l.map((x,L)=>{const ne=c(x,L),V=L>0?l[L-1]:null,Ve=x.message_role==="assistant"&&(V==null?void 0:V.message_role)==="user",st=!!(V&&V.message_role==="user"&&V.query===x.query);return e.jsxs("div",{className:Ve?"mt-6":L>0?"pt-10 border-t border-gray-200/80":"",children:[ra(x,!1,st),ne.length>0&&e.jsxs("div",{className:"mt-6 pt-6 border-t border-gray-100",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800",children:"Comments & Replies"}),e.jsx("span",{className:"text-xs font-semibold px-2.5 py-0.5 rounded-full bg-emerald-50 text-emerald-700 border border-emerald-200/70",children:ne.length})]})}),e.jsx($s,{breakpointCols:ui,className:"my-masonry-grid",columnClassName:"my-masonry-grid_column",children:ne.map(ue=>ue.kind==="msg"?ra(ue.data,!0):ps(ue.data))})]})]},x.id)})})})():e.jsx("div",{className:"text-center py-12 text-gray-500",children:"No messages to display in this conversation."}),e.jsx("div",{ref:Vr})]}),M.length>0&&e.jsx("div",{className:"flex justify-center pt-2 pb-6",children:e.jsxs("button",{onClick:Za,className:"px-6 py-2.5 bg-white hover:bg-gray-50 text-gray-700 rounded-full transition-all flex items-center space-x-2 text-sm font-medium border border-gray-300/80 shadow-2xs hover:shadow-sm","data-tooltip-id":"main-tooltip","data-tooltip-content":Ct?(n==null?void 0:n.ai_search_view_message_copied)||"Copied!":(n==null?void 0:n.ai_search_view_copy_entire_conversation)||"Copy the entire conversation to clipboard",children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-500",children:[e.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),e.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]}),e.jsx("span",{children:Ct?(n==null?void 0:n.ai_search_view_message_copied)||"Copied! ✓":"Copy the entire conversation to clipboard"})]})})]}),vs()]})]})}),e.jsx("footer",{className:"border-t border-gray-200 bg-white mt-12",children:e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4 md:mb-0",children:[e.jsx("img",{src:"/ezlogo.png",alt:"Ez.wiki Logo",className:"w-6 h-6 object-contain rounded","data-tooltip-id":"main-tooltip","data-tooltip-content":"Ez.wiki"}),e.jsx("span",{className:"text-lg font-semibold text-gray-900",children:"Ez.wiki"})]}),e.jsxs("div",{className:"text-sm text-gray-600 text-center md:text-right",children:[e.jsxs("p",{className:"mb-1",children:["AI Conversation •",e.jsxs("span",{className:"mx-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_messages)||"Total messages",children:[M.length," messages"]}),"•",e.jsxs("span",{className:"mx-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_total_tokens)||"Total tokens used",children:[xe," tokens"]}),"•",e.jsxs("span",{className:"mx-1","data-tooltip-id":"main-tooltip","data-tooltip-content":(n==null?void 0:n.ai_search_view_conversation_cost_tooltip)||"Total cost",children:["$",ge.toFixed(4)," cost"]})]}),e.jsxs("p",{children:["© ",new Date().getFullYear()," Ez.wiki •",e.jsxs("span",{className:"ml-1","data-tooltip-id":"main-tooltip","data-tooltip-content":"Conversation identifier",children:["Conversation ID: ",r.conversation_id]})]})]})]})})}),e.jsxs("div",{className:"fixed bottom-6 right-6 flex flex-col gap-3 z-[60]",children:[e.jsx("button",{onClick:()=>Qr("up"),className:`w-12 h-12 rounded-full flex items-center justify-center border shadow-md hover:shadow-lg transition-all text-white active:scale-95 ${zt
3386==="up"?"bg-blue-600 border-blue-700 ring-4 ring-blue-300 scale-105 animate-pulse":"bg-blue-500 border-blue-600 hover:bg-blue-600"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":zt==="up"?"Auto-scrolling up in slow motion (Click to stop)":(n==null?void 0:n.ai_search_view_scroll_top)||"Auto scroll to top (Slow motion)","aria-label":"Auto scroll to top in slow motion",children:e.jsx(m,{icon:la})}),e.jsx("button",{onClick:()=>Qr("down"),className:`w-12 h-12 rounded-full flex items-center justify-center border shadow-md hover:shadow-lg transition-all text-white active:scale-95 ${zt==="down"?"bg-green-600 border-green-700 ring-4 ring-green-300 scale-105 animate-pulse":"bg-green-500 border-green-600 hover:bg-green-600"}`,"data-tooltip-id":"main-tooltip","data-tooltip-content":zt==="down"?"Auto-scrolling down in slow motion (Click to stop)":(n==null?void 0:n.ai_search_view_scroll_bottom)||"Auto scroll to bottom (Slow motion)","aria-label":"Auto scroll to bottom in slow motion",children:e.jsx(m,{icon:vr})})]})]}),hn.show&&e.jsx(hi,{message:hn.message,type:hn.type,onClose:()=>Wr({show:!1,message:"",type:"info"})}),e.jsx(Ma,{isOpen:he,onClose:()=>A(!1),slug:r.slug,url:v||(typeof window<"u"?`${window.location.origin}/X/${encodeURIComponent(r.slug)}`:""),title:r.conversation_title||r.query||"Ez.wiki AI Search",description:r.query||"",initialTab:pe}),e.jsx(Na,{isOpen:Oa,onClose:()=>qn(!1),parentSlug:r.slug,conversationId:r.conversation_id,onChildConvoCreated:async(t,a)=>{await xn(void 0,t,a||"embed"),qn(!1)},onCommentCreated:t=>{rt(t),$()}}),e.jsx("style",{children:`
3387                @keyframes slideDown {
3388                    from {
3389                        opacity: 0;
3390                        transform: translate(-50%, -20px);
3391                    }
3392                    to {
3393                        opacity: 1;
3394                        transform: translate(-50%, 0);
3395                    }
3396                }
3397                .animate-slideDown {
3398                    animation: slideDown 0.3s ease-out;
3399                }
3400
3401                @keyframes slide-left {
3402                    from {
3403                        transform: translateX(100%);
3404                        opacity: 0;
3405                    }
3406                    to {
3407                        transform: translateX(0);
3408                        opacity: 1;
3409                    }
3410                }
3411                .animate-slide-left {
3412                    animation: slide-left 0.3s ease-out;
3413                }
3414
3415                @keyframes gradient-x {
3416                    0%, 100% {
3417                        background-position: 0% 50%;
3418                    }
3419                    50% {
3420                        background-position: 100% 50%;
3421                    }
3422                }
3423                .animate-gradient-x {
3424                    background-size: 200% 200%;
3425                    animation: gradient-x 3s ease infinite;
3426                }
3427
3428                @keyframes bounce-slow {
3429                    0%, 100% {
3430                        transform: translateY(0);
3431                    }
3432                    50% {
3433                        transform: translateY(-8px);
3434                    }
3435                }
3436                .animate-bounce-slow {
3437                    animation: bounce-slow 1.5s ease-in-out infinite;
3438                }
3439
3440                .scrollbar-thin::-webkit-scrollbar {
3441                    width: 6px;
3442                }
3443                .scrollbar-thin::-webkit-scrollbar-track {
3444                    background: #f3f4f6;
3445                    border-radius: 3px;
3446                }
3447                .scrollbar-thin::-webkit-scrollbar-thumb {
3448                    background: #d1d5db;
3449                    border-radius: 3px;
3450                }
3451                .scrollbar-thin::-webkit-scrollbar-thumb:hover {
3452                    background: #9ca3af;
3453                }
3454
3455                .comment-content iframe,
3456                .comment-content embed,
3457                .comment-content object,
3458                .comment-content video {
3459                    display: block;
3460                    margin: 1.5rem auto;
3461                    max-width: 100%;
3462                }
3463
3464                .comment-content iframe {
3465                    max-width: 100%;
3466                    height: auto !important;
3467                    min-height: 400px;
3468                    aspect-ratio: unset !important;
3469                }
3470
3471                .comment-content div:has(iframe),
3472                .comment-content div:has(embed) {
3473                    display: flex;
3474                    justify-content: center;
3475                    width: 100%;
3476                }
3477
3478                .comment-content .iframe-wrapper,
3479                .comment-content .embed-wrapper {
3480                    display: flex;
3481                    justify-content: center;
3482                    width: 100%;
3483                }
3484
3485                .comment-html-preview,
3486                .social-post-html-preview {
3487                    width: 100%;
3488                    border-radius: 0.75rem;
3489                }
3490
3491                .comment-html-preview iframe,
3492                .social-post-html-preview iframe {
3493                    display: block;
3494                    width: 100%;
3495                    max-width: 100%;
3496                }
3497
3498                .social-post-content {
3499                    max-width: 100%;
3500                    overflow-x: auto;
3501                }
3502
3503                .social-post-content img {
3504                    max-width: 100%;
3505                    height: auto;
3506                }
3507
3508                .social-post-content video {
3509                    max-width: 100%;
3510                    height: auto;
3511                }
3512
3513                .social-post-content iframe {
3514                    max-width: 100%;
3515                    display: block;
3516                    margin: 0 auto;
3517                }
3518
3519                .social-post-content iframe[src*="facebook"],
3520                .social-post-content iframe[src*="youtube"],
3521                .social-post-content iframe[src*="vimeo"],
3522                .social-post-content iframe[src*="instagram"],
3523                .social-post-content iframe[src*="twitter"] {
3524                    display: block;
3525                    margin: 0 auto;
3526                    max-width: 100%;
3527                }
3528
3529                .comment-content {
3530                    max-width: 100%;
3531                    overflow-x: auto;
3532                }
3533
3534                .comment-content img {
3535                    max-width: 100%;
3536                    height: auto;
3537                }
3538
3539                .comment-content video {
3540                    max-width: 100%;
3541                    height: auto;
3542                }
3543
3544                .comment-content iframe {
3545                    max-width: 100%;
3546                    display: block;
3547                    margin: 0 auto;
3548                }
3549
3550                .comment-content iframe[src*="facebook"],
3551                .comment-content iframe[src*="youtube"],
3552                .comment-content iframe[src*="vimeo"],
3553                .comment-content iframe[src*="instagram"],
3554                .comment-content iframe[src*="twitter"] {
3555                    display: block;
3556                    margin: 0 auto;
3557                    max-width: 100%;
3558                }
3559
3560                .markdown-body {
3561                    all: unset;
3562                    display: block;
3563                }
3564
3565                .markdown-body > *:first-child {
3566                    margin-top: 0;
3567                }
3568
3569                .markdown-body > *:last-child {
3570                    margin-bottom: 0;
3571                }
3572
3573                .markdown-body h1,
3574                .markdown-body h2,
3575                .markdown-body h3,
3576                .markdown-body h4,
3577                .markdown-body h5,
3578                .markdown-body h6 {
3579                    font-weight: 600;
3580                    margin-top: 1.5rem;
3581                    margin-bottom: 0.75rem;
3582                    color: #111827;
3583                    line-height: 1.3;
3584                    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
3585                }
3586
3587                .markdown-body h1 {
3588                    font-size: 1.75rem;
3589                    font-weight: 700;
3590                    border-bottom: 2px solid #e5e7eb;
3591                    padding-bottom: 0.5rem;
3592                }
3593
3594                .markdown-body h2 {
3595                    font-size: 1.5rem;
3596                    font-weight: 600;
3597                }
3598
3599                .markdown-body h3 {
3600                    font-size: 1.25rem;
3601                    font-weight: 600;
3602                }
3603
3604                .markdown-body h4 {
3605                    font-size: 1.1rem;
3606                    font-weight: 600;
3607                }
3608
3609                .markdown-body h5 {
3610                    font-size: 1rem;
3611                    font-weight: 600;
3612                }
3613
3614                .markdown-body h6 {
3615                    font-size: 0.9rem;
3616                    font-weight: 600;
3617                    color: #6b7280;
3618                }
3619
3620                .inline-embed-builder {
3621                    width: 100%;
3622                    border-radius: 0.75rem;
3623                    overflow: hidden;
3624                    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
3625                    border: 1px solid #e5e7eb;
3626                    background: #f3f4f1;
3627                }
3628            `})]})}
3628export{Ri 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.