(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,27156,e=>{"use strict";var t=e.i(43476),c=e.i(75385),a=e.i(71645),r=e.i(25348);e.s(["default",0,()=>{let[e,l]=(0,a.useState)([]),[s,i]=(0,a.useState)("");(0,a.useEffect)(()=>{o()},[]);let o=async()=>{try{let e=await (0,c.default)("/api/script/all-widget");e?.success&&l(e.data)}catch(e){console.error("Failed to fetch widgets:",e)}},d=async e=>{if(e?.length>0){let t=`<script async src="https://tool.chatknot.com${e}"></script>`;try{await navigator.clipboard.writeText(t),(0,r.default)("Success!","Script copied to clipboard!","success")}catch(c){console.error("Clipboard API failed:",c);let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select();try{document.execCommand("copy")?alert("Script copied to clipboard!"):alert("Copy failed.")}catch(e){console.error("Fallback copy error:",e),alert("Failed to copy script to clipboard.")}finally{document.body.removeChild(e)}}}else alert("No script available to copy.")},n=e.filter(e=>e?.brand_name?.toLowerCase().includes(s.toLowerCase()));return(0,t.jsxs)("div",{className:"container-fluid table-container table-responsive",children:[(0,t.jsx)("h2",{className:"my-3",children:"Widgets"}),(0,t.jsx)("div",{className:"mb-3",children:(0,t.jsx)("input",{type:"text",className:"form-control",placeholder:"Search by Brand Name",value:s,onChange:e=>i(e.target.value)})}),(0,t.jsxs)("table",{className:"table table-striped mt-4",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"#"}),(0,t.jsx)("th",{children:"Brand Name"}),(0,t.jsx)("th",{children:"Script"}),(0,t.jsx)("th",{children:"Action"})]})}),(0,t.jsxs)("tbody",{children:[n.map((e,c)=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:c+1}),(0,t.jsx)("td",{children:e?.brand_name||"N/A"}),(0,t.jsx)("td",{children:(0,t.jsx)("code",{className:"d-block text-truncate",style:{maxWidth:"400px"},children:`<script async src="https://tool.chatknot.com${e.file_path}"></script>`})}),(0,t.jsx)("td",{children:(0,t.jsx)("button",{className:"btn btn-sm btn-outline-primary",onClick:()=>d(e.file_path),children:"Copy Script"})})]},c)),0===n.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:"4",className:"text-center",children:"No widgets found."})})]})]})]})}])}]);