Files
2025-07-14 15:46:43 +08:00

189 lines
189 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function getImportPath(filename) {
return `./${filename}`;
}
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["copilot_web/WorkflowOption-DFC4F0_u.js","copilot_web/vendor-markdown-CBmlBP6m.js","copilot_web/vendor-react-Dixhfmvb.js","copilot_web/message-components-C9vZwNAZ.js"].map(path => {
const apiBase = window.comfyAPI?.api?.api?.api_base;
if (apiBase) {
// 有 API base 时,使用完整路径
return `${apiBase.substring(1)}/${path}`;
} else {
// 没有 API base 时,使用相对路径
return `./${path}`;
}
}))))=>i.map(i=>d[i]);
import{j as i,r as zg,b as Ug}from"./vendor-markdown-CBmlBP6m.js";import{r as E,R as pr,c as gr,a as Gg}from"./vendor-react-Dixhfmvb.js";import{f as Hg,v as Kg,W as $t,B as Sl,u as En,g as qe,U as qg,A as fs,a as We,b as Jg,c as vr,M as Yg}from"./message-components-C9vZwNAZ.js";import{_ as gs}from"./input.js";import{C as Gn}from"./App-D5UGpCiq.js";/* empty css *//**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xg=l=>l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Nl=(...l)=>l.filter((d,r,f)=>!!d&&d.trim()!==""&&f.indexOf(d)===r).join(" ").trim();/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var Zg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vg=E.forwardRef(({color:l="currentColor",size:d=24,strokeWidth:r=2,absoluteStrokeWidth:f,className:u="",children:h,iconNode:p,...x},w)=>E.createElement("svg",{ref:w,...Zg,width:d,height:d,stroke:l,strokeWidth:f?Number(r)*24/Number(d):r,className:Nl("lucide",u),...x},[...p.map(([N,_])=>E.createElement(N,_)),...Array.isArray(h)?h:[h]]));/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cn=(l,d)=>{const r=E.forwardRef(({className:f,...u},h)=>E.createElement(Vg,{ref:h,iconNode:d,className:Nl(`lucide-${Xg(l)}`,f),...u}));return r.displayName=`${l}`,r};/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],ep=Cn("CircleStop",Qg);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],np=Cn("Image",tp);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rp=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],sp=Cn("Plus",rp);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ip=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],op=Cn("Send",ip);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ap=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],lp=Cn("Settings",ap);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cp=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],up=Cn("Trash",cp);/**
* @license lucide-react v0.475.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const dp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ri=Cn("X",dp);function fp({isOpen:l,onClose:d,onSave:r,initialApiKey:f=""}){const[u,h]=E.useState(f),[p,x]=E.useState(!1),[w,N]=E.useState(""),[_,b]=E.useState("https://api.openai.com/v1"),[I,P]=E.useState(!1),[O,G]=E.useState(!1),[q,F]=E.useState(null),[D,B]=E.useState(null);E.useEffect(()=>{h(f);const z=localStorage.getItem("openaiApiKey"),V=localStorage.getItem("openaiBaseUrl");z&&N(z),V&&b(V),(async()=>{try{const U=localStorage.getItem("rsaPublicKey");if(U)B(U);else{const ae=await Hg();B(ae),localStorage.setItem("rsaPublicKey",ae)}}catch(U){console.error("Failed to fetch RSA public key:",U)}})()},[f]);const C=async()=>{if(!w.trim()){F({success:!1,message:"Please enter an OpenAI API key"});return}if(!D){F({success:!1,message:"RSA public key not available. Please try again later."});return}G(!0),F(null);try{const z=await Kg(w,_,D);F({success:z,message:z?"API key is valid!":"Invalid API key. Please check and try again."})}catch(z){F({success:!1,message:z instanceof Error?z.message:"Failed to verify API key"})}finally{G(!1)}},M=()=>{r(u),w.trim()?(localStorage.setItem("openaiApiKey",w),localStorage.setItem("openaiBaseUrl",_)):(localStorage.removeItem("openaiApiKey"),localStorage.removeItem("openaiBaseUrl")),d()};return l?i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl p-8 w-[480px] shadow-2xl",children:[i.jsx("h2",{className:"text-xl text-gray-900 dark:text-white font-semibold mb-6",children:"Set API Key"}),i.jsxs("div",{className:"mb-6",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"ComfyUI Copilot API Key"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:p?"text":"password",value:u,onChange:z=>h(z.target.value),placeholder:"Enter your API key",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg mb-4 pr-12
bg-gray-50 dark:bg-gray-700
text-gray-900 dark:text-white
placeholder-gray-500 dark:placeholder-gray-400
focus:border-blue-500 dark:focus:border-blue-400
focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20
focus:outline-none`}),i.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 pr-4 flex items-center text-gray-500 dark:text-gray-400
hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none`,onClick:()=>x(!p),children:p?i.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}):i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})})})]}),i.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:[i.jsx("span",{children:"Don't have an API key? "}),i.jsx("a",{href:"https://form.typeform.com/to/tkg91K8D",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:"Click here to request one"})]})]}),i.jsxs("div",{className:"mb-6 border-t border-gray-200 dark:border-gray-700 pt-6",children:[i.jsx("h3",{className:"text-sm text-gray-900 dark:text-white font-medium mb-4",children:"OpenAI API Configuration (Optional)"}),i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"OpenAI API Key"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:I?"text":"password",value:w,onChange:z=>N(z.target.value),placeholder:"Enter your OpenAI API key",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg pr-12 text-xs
bg-gray-50 dark:bg-gray-700
text-gray-900 dark:text-white
placeholder-gray-500 dark:placeholder-gray-400
focus:border-blue-500 dark:focus:border-blue-400
focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20
focus:outline-none`}),i.jsx("button",{type:"button",className:`absolute inset-y-0 right-0 pr-4 flex items-center text-gray-500 dark:text-gray-400
hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none`,onClick:()=>P(!I),children:I?i.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}):i.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})})})]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx("label",{className:"block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2",children:"OpenAI Base URL"}),i.jsx("input",{type:"text",value:_,onChange:z=>b(z.target.value),placeholder:"https://api.openai.com/v1",className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-xs
bg-gray-50 dark:bg-gray-700
text-gray-900 dark:text-white
placeholder-gray-500 dark:placeholder-gray-400
focus:border-blue-500 dark:focus:border-blue-400
focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20
focus:outline-none`})]}),i.jsx("div",{className:"flex items-center mb-2",children:i.jsx("button",{onClick:C,disabled:O||!w.trim(),className:`px-4 py-2 rounded-lg font-medium text-xs transition-colors ${O||!w.trim()?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,children:O?i.jsxs("span",{className:"flex items-center",children:[i.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Verifying..."]}):"Verify"})}),q&&i.jsx("div",{className:`text-xs p-2 rounded-md ${q.success?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"}`,children:q.message})]}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx("button",{onClick:d,className:`px-5 py-2.5 text-gray-700 bg-white dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700
rounded-lg font-medium transition-colors`,children:"Cancel"}),i.jsx("button",{onClick:M,className:`px-5 py-2.5 bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600
text-white rounded-lg font-medium transition-colors`,children:"Save"})]})]})}):null}const hp="/copilot_web/assets/logo-BTZhX0BN.png";function gp({onClose:l,onClear:d,hasMessages:r,onHeightResize:f,title:u="ComfyUI-Copilot"}){const[h,p]=E.useState(!1),[x,w]=E.useState(!1),N=()=>{p(!0)},_=b=>{localStorage.setItem("chatApiKey",b)};return E.useEffect(()=>{const b=P=>{if(!x)return;const O=P.movementY;f?.(O)},I=()=>{w(!1)};return x&&(document.addEventListener("mousemove",b),document.addEventListener("mouseup",I)),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",I)}},[x,f]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:`flex items-center justify-between border-b px-3 py-2
bg-white border-gray-200 sticky top-2 z-10`,children:[i.jsxs("div",{className:"flex items-center space-x-1",children:[i.jsx("img",{src:`.${hp}`,alt:"ComfyUI-Copilot Logo",className:"h-7 w-7 -ml-1"}),i.jsx("h3",{className:"text-[14px] font-medium text-gray-800",children:u}),i.jsx("button",{onClick:N,className:"p-1 bg-white border-none hover:bg-gray-100 rounded text-gray-500",children:i.jsx(lp,{className:"h-4 w-4"})})]}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsx("button",{className:`inline-flex bg-white border-none items-center justify-center rounded-md p-1.5
${r?"text-gray-500 hover:bg-gray-100":"text-gray-300 cursor-not-allowed"}`,disabled:!r,onClick:d,children:i.jsx(up,{className:"h-4 w-4"})})})]}),i.jsx(fp,{isOpen:h,onClose:()=>p(!1),onSave:_,initialApiKey:localStorage.getItem("chatApiKey")||""})]})}const pp=5*1024*1024,fl=["image/jpeg","image/png","image/gif","image/webp"];function mp({input:l,loading:d,onChange:r,onSend:f,onKeyPress:u,onUploadImages:h,uploadedImages:p,onRemoveImage:x,selectedModel:w,onModelChange:N,onStop:_}){const[b,I]=E.useState(!1),[P,O]=E.useState([]),G=pr.useRef(null),q=E.useRef(null);E.useEffect(()=>{q.current&&(q.current.style.height="auto",q.current.style.height=`${Math.min(q.current.scrollHeight,400)}px`)},[l]),E.useEffect(()=>{(async()=>{try{const B=await $t.listModels();O(B.models)}catch(B){console.error("Failed to load models:",B),O([{name:"gpt-4o",image_enable:!0},{name:"gpt-4o-mini",image_enable:!0},{name:"qwen-plus",image_enable:!1},{name:"DeepSeek-V3",image_enable:!1}])}})()},[]);const F=D=>{if(D.target.files){const B=[],C=[];if(Array.from(D.target.files).forEach(M=>{fl.includes(M.type)?M.size>pp?B.push(`${M.name} (exceeds 5MB)`):C.push(M):B.push(`${M.name} (unsupported format)`)}),B.length>0&&alert(`The following files couldn't be uploaded:
${B.join(`
`)}`),C.length>0){const M=new DataTransfer;C.forEach(z=>M.items.add(z)),h(M.files)}}};return i.jsxs("div",{className:`relative ${p.length>0?"mt-12":""}`,children:[p.length>0&&i.jsx("div",{className:"absolute -top-10 left-0 flex gap-2",children:p.map(D=>i.jsxs("div",{className:"relative group",children:[i.jsx("img",{src:D.preview,alt:"uploaded",className:"w-8 h-8 rounded object-cover"}),i.jsx("button",{onClick:()=>x(D.id),className:`absolute -top-1 -right-1 bg-white border-none text-gray-500 rounded-full p-0.5
opacity-0 group-hover:opacity-100 transition-opacity`,children:i.jsx(Ri,{className:"w-3 h-3"})})]},D.id))}),i.jsx("textarea",{ref:q,onChange:r,onKeyDown:D=>{if(D.key==="Enter"&&!D.shiftKey){if(D.nativeEvent.isComposing)return;D.preventDefault(),l.trim()!==""&&f()}u(D)},value:l,placeholder:"Type your message...",className:`w-full min-h-[80px] max-h-[400px] resize-none rounded-md border
border-gray-200 px-3 py-2 pr-12 pb-10 text-[14px] shadow-sm
focus:outline-none focus:ring-2 focus:ring-blue-500
focus:border-transparent bg-white transition-all
duration-200 text-gray-700 overflow-y-auto`,style:{height:"80px"}}),i.jsxs("div",{className:`absolute bottom-2 left-3 right-12 flex items-center gap-2
bg-white border-t border-gray-100 pt-1`,children:[i.jsx("select",{value:w,onChange:D=>N(D.target.value),className:`px-1.5 py-0.5 text-xs rounded-md
border border-gray-200 bg-white text-gray-700
focus:outline-none focus:ring-2 focus:ring-blue-500
focus:border-transparent hover:bg-gray-50
transition-colors border-0`,children:P.map(D=>i.jsx("option",{value:D.name,children:D.name},D.name))}),i.jsx("button",{type:"button",onClick:()=>I(!0),disabled:!P.find(D=>D.name===w)?.image_enable,className:`p-1.5 text-gray-500 bg-white border-none
hover:bg-gray-100 hover:text-gray-600
transition-all duration-200 outline-none
${P.find(D=>D.name===w)?.image_enable?"":"opacity-50 cursor-not-allowed"}`,children:i.jsx(np,{className:"h-4 w-4"})})]}),i.jsx("button",{type:"submit",onClick:d?_:f,disabled:d?!1:l.trim()==="",className:`absolute bottom-3 right-3 p-2 rounded-md text-gray-500 bg-white border-none
hover:bg-gray-100 hover:text-gray-600 disabled:opacity-50
transition-all duration-200 active:scale-95`,children:d?i.jsx(ep,{className:"h-5 w-5 text-red-500 hover:text-red-600"}):i.jsx(op,{className:"h-5 w-5 group-hover:translate-x-1"})}),b&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg p-6 w-96 relative",children:[i.jsx("button",{onClick:()=>I(!1),className:"absolute top-2 right-2 bg-white border-none text-gray-500 hover:text-gray-700",children:i.jsx(Ri,{className:"w-5 h-5"})}),i.jsx("h3",{className:"text-lg text-gray-800 font-medium mb-4",children:"Upload Images"}),i.jsxs("div",{className:`border-2 border-dashed border-gray-300 rounded-lg p-8
flex flex-col items-center justify-center gap-4
hover:border-blue-500 transition-colors cursor-pointer`,onClick:()=>G.current?.click(),children:[i.jsx(sp,{className:"w-8 h-8 text-gray-400"}),i.jsxs("div",{className:"text-center",children:[i.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"Click to upload images or drag and drop"}),i.jsx("p",{className:"text-xs text-gray-400",children:"Supported formats: JPG, PNG, GIF, WebP"}),i.jsx("p",{className:"text-xs text-gray-400",children:"Max file size: 5MB"})]})]}),i.jsx("input",{ref:G,type:"file",multiple:!0,accept:fl.join(","),onChange:F,className:"hidden"}),p.length>0&&i.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:p.map(D=>i.jsxs("div",{className:"relative group",children:[i.jsx("img",{src:D.preview,alt:"preview",className:"w-full h-20 object-cover rounded"}),i.jsx("button",{onClick:()=>x(D.id),className:`absolute -top-1 -right-1 bg-white border-none text-gray-500
rounded-full p-0.5 opacity-0 group-hover:opacity-100
transition-opacity`,children:i.jsx(Ri,{className:"w-3 h-3"})})]},D.id))}),i.jsx("div",{className:"mt-4 flex justify-end gap-2",children:i.jsx("button",{onClick:()=>I(!1),className:`px-4 py-2 text-sm font-medium text-gray-700
bg-white border border-gray-300 rounded-md
hover:bg-gray-50`,children:"Close"})})]})})]})}function xp(){return i.jsx(Sl,{name:"Assistant",children:i.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-gray-50 rounded-lg",children:[i.jsxs("div",{className:"flex space-x-1",children:[i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),i.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),i.jsx("span",{className:"text-sm text-gray-500",children:"AI is thinking..."})]})})}const vp=[{question:"this is a question1!",answer:`this is a answer!this is a answer!this is a answer!
this is a answer!this is a answer!
this is a answer!this is a answer!this is a answer!`},{question:"this is a question2!",answer:`this is a answer!this is a answer!this is a answer!
this is a answer!this is a answer!
this is a answer!this is a answer!this is a answer!`},{question:"this is a question3!",answer:`this is a answer!this is a answer!this is a answer!
this is a answer!this is a answer!
this is a answer!this is a answer!this is a answer!`},{question:"this is a question4!",answer:`this is a answer!this is a answer!this is a answer!
this is a answer!this is a answer!
this is a answer!this is a answer!this is a answer!`}],yp=()=>{const{dispatch:l}=En(),d=f=>{const u={id:qe(),role:"user",content:f};l({type:"ADD_MESSAGE",payload:u}),l({type:"SET_LOADING",payload:!0})},r=f=>{l({type:"SET_LOADING",payload:!1});const u=2;let h=0;const p=qe(),x=(w=!1)=>{h+=u;const N=f.slice(0,h),_={id:p,role:"ai",content:JSON.stringify({text:N}),finished:!1,name:"Assistant"};h>f.length?_.finished=!0:setTimeout(()=>{x()},50),l({type:w?"ADD_MESSAGE":"UPDATE_MESSAGE",payload:_})};x(!0)};return i.jsx(Sl,{name:"questionTitle",children:i.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[i.jsx("div",{className:"text-base text-gray-900 font-medium",children:"welcome to ComfyUI Copilot! This is a question user message component."}),vp.map((f,u)=>i.jsx("div",{className:"flex mt-2",onClick:()=>{d(f.question),setTimeout(()=>{r(f.answer)},1e3)},children:i.jsx("span",{className:"text-sm text-gray-900 font-normal border border-gray-900 rounded-md px-2 py-1",children:f.question})},u.toString()))]})})},bp=l=>`https://ui-avatars.com/api/?name=${l||"User"}&background=random`,wp=E.lazy(()=>gs(()=>import(getImportPath("WorkflowOption-DFC4F0_u.js")),__vite__mapDeps([0,1,2,3])).then(l=>({default:l.WorkflowOption}))),_p=E.lazy(()=>gs(()=>import(getImportPath("message-components-C9vZwNAZ.js")).then(l=>l.N),__vite__mapDeps([3,2,1])).then(l=>({default:l.NodeSearch}))),Sp=E.lazy(()=>gs(()=>import(getImportPath("message-components-C9vZwNAZ.js")).then(l=>l.D),__vite__mapDeps([3,2,1])).then(l=>({default:l.DownstreamSubgraphs}))),Np=E.lazy(()=>gs(()=>import(getImportPath("message-components-C9vZwNAZ.js")).then(l=>l.d),__vite__mapDeps([3,2,1])).then(l=>({default:l.NodeInstallGuide}))),jp=3;function Ep({messages:l,latestInput:d,onOptionClick:r,installedNodes:f,onAddMessage:u,loading:h,isActive:p}){const[x,w]=E.useState(0),[N,_]=E.useState([]),b=E.useRef(null),I=E.useRef(0),P=E.useRef(0),O=E.useRef(!1),G=()=>{b?.current&&(b.current.scrollTop=b.current.scrollHeight)},q=C=>{if(C.role==="user")return i.jsx(qg,{content:C.content,trace_id:C.trace_id},C.id);if(C.role==="question_title")return i.jsx(yp,{});if(C.role==="ai"||C.role==="tool"){const M=bp(C.role);try{const z=JSON.parse(C.content),V=z.ext?.find(R=>R.type==="workflow"),je=z.ext?.find(R=>R.type==="node"),U=z.ext?.find(R=>R.type==="downstream_subgraph_search"),ae=z.ext?.find(R=>R.type==="node_install_guide");let ge=null;if(V)ge=i.jsx(E.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(wp,{content:C.content,name:C.name,avatar:M,latestInput:d,installedNodes:f,onAddMessage:u,onFinishLoad:G})});else if(je)ge=i.jsx(E.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(_p,{content:C.content,name:C.name,avatar:M,installedNodes:f,onFinishLoad:G})});else if(U){const R=i.jsx(E.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Sp,{content:C.content,name:C.name,avatar:M,onAddMessage:u,onFinishLoad:G})});if(C.metadata?.intent==="downstream_subgraph_search")return i.jsx(fs,{content:C.content,name:C.name,avatar:M,format:C.format,onOptionClick:r,extComponent:R,metadata:C.metadata},C.id);ge=R}else ae&&(ge=i.jsx(E.Suspense,{fallback:i.jsx("div",{children:"Loading..."}),children:i.jsx(Np,{content:C.content,onLoadSubgraph:()=>{if(C.metadata?.pendingSubgraph){const R=Object.values(We.canvas.selected_nodes)[0];if(R){const xe=C.metadata.pendingSubgraph,le=xe.json.nodes,se=xe.json.links,ve=le.find(ce=>ce.id===0),Q=ve?.id,K={};Q&&(K[Q]=R),We.canvas.emitBeforeChange();try{for(const ce of le)if(ce.id!==Q){const J=ve?.pos||[0,0],Z=R._pos||[0,0],ye=[ce.pos[0]+Z[0]-J[0],ce.pos[1]+Z[1]-J[1]];K[ce.id]=Jg(ce.type,{pos:ye})}}finally{We.canvas.emitAfterChange()}for(const ce of se){const J=K[ce.origin_id],Z=K[ce.target_id];J&&Z&&J.connect(ce.origin_slot,Z,ce.target_slot)}}else alert("Please select a upstream node first before adding a subgraph.")}else if(C.metadata?.pendingWorkflow){const R=C.metadata.pendingWorkflow,xe=C.metadata.optimizedParams;if(R.nodes)We.loadGraphData(R);else{We.loadApiJson(R);const se=Object.keys(R),ve=Object.keys(We.graph._nodes_by_id)[0],Q=We.graph._nodes_by_id[ve],K=Q?Q.pos[0]:0,ce=Q?Q.pos[1]:0,J=250,Z=60,ye=20,ke=60,Oe=50,Ie=1e3;let Be=K,rt=ce,gt=0;for(const lt of se){const Ge=We.graph._nodes_by_id[lt];if(Ge){gt>Ie&&(Be+=J+ke,gt=0,rt=ce);const pt=Ge.inputs?Ge.inputs.length:0,Mt=Ge.outputs?Ge.outputs.length:0,Bt=Ge.widgets?Ge.widgets.length:0,Xe=Math.max(pt,Mt)+Bt,st=ye*Xe+Z;Ge.size[0]=J,Ge.size[1]=st,Ge.pos[0]=Be,Ge.pos[1]=rt,gt+=st+Oe,rt+=st+Oe}}}for(const[se,ve,Q,K,ce]of xe){const J=We.graph._nodes_by_id[se].widgets;for(const Z of J)Z.name===K&&(Z.value=ce)}We.graph.setDirtyCanvas(!1,!0);const le={id:qe(),role:"tool",content:JSON.stringify({text:"The workflow has been successfully loaded to the canvas",ext:[]}),format:"markdown",name:"Assistant"};u?.(le)}},onFinishLoad:G})}));return z.text||ge?i.jsx(fs,{content:C.content,name:C.name,avatar:M,format:C.format,onOptionClick:r,extComponent:ge,metadata:C.metadata},C.id):ge||i.jsx(fs,{content:C.content,name:C.name,avatar:M,format:C.format,onOptionClick:r,metadata:C.metadata},C.id)}catch(z){return console.error("[MessageList] Error parsing message content:",z),console.error("解析JSON失败",C.content),i.jsx(fs,{content:C.content,name:C.name,avatar:M,format:C.format,onOptionClick:r,metadata:C.metadata},C.id)}}return null},F=C=>{const M=C?.buttonStatus==="not_used";return i.jsx("div",{className:"flex justify-center items-center",children:M?i.jsx("button",{className:"w-full h-[24px] text-gray-700 text-xs bg-gray-50 hover:!bg-gray-200 px-2 py-1 rounded-md",onClick:B,children:"Load more"}):i.jsx("div",{className:"w-full h-[24px] bg-transparent"})},C.id)};function D(C){return C&&typeof C=="object"&&C.buttonType==="loadmore"}const B=()=>{O.current=!0,w(C=>C+1)};return E.useEffect(()=>{let C=[];if(I.current>0&&I.current<l.length)C=l.slice(I.current),l[I.current].role==="user"&&C.unshift({id:`${l[I.current].id}_loadmore`,buttonType:"loadmore",buttonStatus:"used"}),_(M=>[...M,...C]);else{let M=0,z=l?.length;for(let V=l?.length-1;V>=0;V--)if(l[V].role==="ai"||V===0)if(M>jp+x){C.unshift({id:`${l[V].id}_loadmore`,buttonType:"loadmore",buttonStatus:"not_used"});break}else M++,C?.length>0&&C.unshift({id:`${l[V].id}_loadmore`,buttonType:"loadmore",buttonStatus:"used"}),C=[...l?.slice(Math.min(z,V===0?V:V+1),z+1),...C],z=V;_(C)}I.current=l.length},[l,x]),E.useLayoutEffect(()=>{b?.current&&(O.current?(b.current.scrollTop=b.current.scrollHeight-P.current,O.current=!1):b.current.scrollTop=b.current.scrollHeight,P.current=b.current.scrollHeight)},[N]),i.jsxs("div",{className:"flex-1 flex-col overflow-y-auto p-4 h-0",ref:b,style:{display:p?"block":"none"},children:[N?.map(C=>!!C&&(D(C)?F(C):q(C))),h&&i.jsx(xp,{})]})}async function Cp(){try{return await(await vr.fetchApi("/object_info",{method:"GET"})).json()}catch(l){throw console.error("Error fetching object info:",l),l}}async function kp(){const l=await Cp();return Object.keys(l)}async function Ap(l){return await(await vr.fetchApi("/prompt",{method:"POST",body:JSON.stringify(l)})).json()}async function Ip(l){try{const d=await vr.fetchApi("/queue",{method:"POST",body:JSON.stringify(l)});if(!d.ok)throw new Error(`Failed to manage queue: ${d.status} ${d.statusText}`);return d}catch(d){throw console.error("Error managing queue:",d),d}}async function Mp(){try{const l=await vr.fetchApi("/interrupt",{method:"POST"});if(!l.ok)throw new Error(`Failed to interrupt processing: ${l.status} ${l.statusText}`);return l}catch(l){throw console.error("Error interrupting processing:",l),l}}async function Lp(l){try{const d=await vr.fetchApi(`/history/${l}`,{method:"GET"});if(!d.ok)throw new Error(`Failed to fetch history: ${d.status} ${d.statusText}`);return await d.json()}catch(d){throw console.error("Error fetching history:",d),d}}var hs={exports:{}};/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/hs.exports;(function(l,d){(function(){var r,f="4.17.21",u=200,h="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",x="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",N=500,_="__lodash_placeholder__",b=1,I=2,P=4,O=1,G=2,q=1,F=2,D=4,B=8,C=16,M=32,z=64,V=128,je=256,U=512,ae=30,ge="...",R=800,xe=16,le=1,se=2,ve=3,Q=1/0,K=9007199254740991,ce=17976931348623157e292,J=NaN,Z=4294967295,ye=Z-1,ke=Z>>>1,Oe=[["ary",V],["bind",q],["bindKey",F],["curry",B],["curryRight",C],["flip",U],["partial",M],["partialRight",z],["rearg",je]],Ie="[object Arguments]",Be="[object Array]",rt="[object AsyncFunction]",gt="[object Boolean]",lt="[object Date]",Ge="[object DOMException]",pt="[object Error]",Mt="[object Function]",Bt="[object GeneratorFunction]",Xe="[object Map]",st="[object Number]",en="[object Null]",ct="[object Object]",gn="[object Promise]",kn="[object Proxy]",Gt="[object RegExp]",Ze="[object Set]",Lt="[object String]",Ot="[object Symbol]",Y="[object Undefined]",re="[object WeakMap]",we="[object WeakSet]",_e="[object ArrayBuffer]",Fe="[object DataView]",Me="[object Float32Array]",Te="[object Float64Array]",Pe="[object Int8Array]",Je="[object Int16Array]",Tt="[object Int32Array]",_t="[object Uint8Array]",Kn="[object Uint8ClampedArray]",qn="[object Uint16Array]",Jn="[object Uint32Array]",ps=/\b__p \+= '';/g,ms=/\b(__p \+=) '' \+/g,xs=/(__e\(.*?\)|\b__t\)) \+\n'';/g,yr=/&(?:amp|lt|gt|quot|#39);/g,Yn=/[&<>"']/g,vs=RegExp(yr.source),ys=RegExp(Yn.source),bs=/<%-([\s\S]+?)%>/g,br=/<%([\s\S]+?)%>/g,An=/<%=([\s\S]+?)%>/g,ws=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,_s=/^\w*$/,tn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Xn=/[\\^$.*+?()[\]{}|]/g,Ss=RegExp(Xn.source),Zn=/^\s+/,wr=/\s/,Vn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ns=/\{\n\/\* \[wrapped with (.+)\] \*/,_r=/,? & /,Sr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,pn=/[()=,{}\[\]\/\s]/,js=/\\(\\)?/g,nn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,mn=/\w*$/,T=/^[-+]0x[0-9a-f]+$/i,W=/^0b[01]+$/i,Ee=/^\[object .+?Constructor\]$/,et=/^0o[0-7]+$/i,rn=/^(?:0|[1-9]\d*)$/,Ll=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Nr=/($^)/,Ol=/['\n\r\u2028\u2029\\]/g,jr="\\ud800-\\udfff",Tl="\\u0300-\\u036f",Pl="\\ufe20-\\ufe2f",Rl="\\u20d0-\\u20ff",Bi=Tl+Pl+Rl,Fi="\\u2700-\\u27bf",zi="a-z\\xdf-\\xf6\\xf8-\\xff",Dl="\\xac\\xb1\\xd7\\xf7",Wl="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",$l="\\u2000-\\u206f",Bl=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ui="A-Z\\xc0-\\xd6\\xd8-\\xde",Gi="\\ufe0e\\ufe0f",Hi=Dl+Wl+$l+Bl,Es="['’]",Fl="["+jr+"]",Ki="["+Hi+"]",Er="["+Bi+"]",qi="\\d+",zl="["+Fi+"]",Ji="["+zi+"]",Yi="[^"+jr+Hi+qi+Fi+zi+Ui+"]",Cs="\\ud83c[\\udffb-\\udfff]",Ul="(?:"+Er+"|"+Cs+")",Xi="[^"+jr+"]",ks="(?:\\ud83c[\\udde6-\\uddff]){2}",As="[\\ud800-\\udbff][\\udc00-\\udfff]",In="["+Ui+"]",Zi="\\u200d",Vi="(?:"+Ji+"|"+Yi+")",Gl="(?:"+In+"|"+Yi+")",Qi="(?:"+Es+"(?:d|ll|m|re|s|t|ve))?",eo="(?:"+Es+"(?:D|LL|M|RE|S|T|VE))?",to=Ul+"?",no="["+Gi+"]?",Hl="(?:"+Zi+"(?:"+[Xi,ks,As].join("|")+")"+no+to+")*",Kl="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ql="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ro=no+to+Hl,Jl="(?:"+[zl,ks,As].join("|")+")"+ro,Yl="(?:"+[Xi+Er+"?",Er,ks,As,Fl].join("|")+")",Xl=RegExp(Es,"g"),Zl=RegExp(Er,"g"),Is=RegExp(Cs+"(?="+Cs+")|"+Yl+ro,"g"),Vl=RegExp([In+"?"+Ji+"+"+Qi+"(?="+[Ki,In,"$"].join("|")+")",Gl+"+"+eo+"(?="+[Ki,In+Vi,"$"].join("|")+")",In+"?"+Vi+"+"+Qi,In+"+"+eo,ql,Kl,qi,Jl].join("|"),"g"),Ql=RegExp("["+Zi+jr+Bi+Gi+"]"),ec=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,tc=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],nc=-1,Le={};Le[Me]=Le[Te]=Le[Pe]=Le[Je]=Le[Tt]=Le[_t]=Le[Kn]=Le[qn]=Le[Jn]=!0,Le[Ie]=Le[Be]=Le[_e]=Le[gt]=Le[Fe]=Le[lt]=Le[pt]=Le[Mt]=Le[Xe]=Le[st]=Le[ct]=Le[Gt]=Le[Ze]=Le[Lt]=Le[re]=!1;var Ae={};Ae[Ie]=Ae[Be]=Ae[_e]=Ae[Fe]=Ae[gt]=Ae[lt]=Ae[Me]=Ae[Te]=Ae[Pe]=Ae[Je]=Ae[Tt]=Ae[Xe]=Ae[st]=Ae[ct]=Ae[Gt]=Ae[Ze]=Ae[Lt]=Ae[Ot]=Ae[_t]=Ae[Kn]=Ae[qn]=Ae[Jn]=!0,Ae[pt]=Ae[Mt]=Ae[re]=!1;var rc={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},sc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ic={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},oc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ac=parseFloat,lc=parseInt,so=typeof gr=="object"&&gr&&gr.Object===Object&&gr,cc=typeof self=="object"&&self&&self.Object===Object&&self,Ve=so||cc||Function("return this")(),Ms=d&&!d.nodeType&&d,xn=Ms&&!0&&l&&!l.nodeType&&l,io=xn&&xn.exports===Ms,Ls=io&&so.process,St=function(){try{var v=xn&&xn.require&&xn.require("util").types;return v||Ls&&Ls.binding&&Ls.binding("util")}catch{}}(),oo=St&&St.isArrayBuffer,ao=St&&St.isDate,lo=St&&St.isMap,co=St&&St.isRegExp,uo=St&&St.isSet,fo=St&&St.isTypedArray;function mt(v,j,S){switch(S.length){case 0:return v.call(j);case 1:return v.call(j,S[0]);case 2:return v.call(j,S[0],S[1]);case 3:return v.call(j,S[0],S[1],S[2])}return v.apply(j,S)}function uc(v,j,S,H){for(var ie=-1,be=v==null?0:v.length;++ie<be;){var He=v[ie];j(H,He,S(He),v)}return H}function Nt(v,j){for(var S=-1,H=v==null?0:v.length;++S<H&&j(v[S],S,v)!==!1;);return v}function dc(v,j){for(var S=v==null?0:v.length;S--&&j(v[S],S,v)!==!1;);return v}function ho(v,j){for(var S=-1,H=v==null?0:v.length;++S<H;)if(!j(v[S],S,v))return!1;return!0}function sn(v,j){for(var S=-1,H=v==null?0:v.length,ie=0,be=[];++S<H;){var He=v[S];j(He,S,v)&&(be[ie++]=He)}return be}function Cr(v,j){var S=v==null?0:v.length;return!!S&&Mn(v,j,0)>-1}function Os(v,j,S){for(var H=-1,ie=v==null?0:v.length;++H<ie;)if(S(j,v[H]))return!0;return!1}function Re(v,j){for(var S=-1,H=v==null?0:v.length,ie=Array(H);++S<H;)ie[S]=j(v[S],S,v);return ie}function on(v,j){for(var S=-1,H=j.length,ie=v.length;++S<H;)v[ie+S]=j[S];return v}function Ts(v,j,S,H){var ie=-1,be=v==null?0:v.length;for(H&&be&&(S=v[++ie]);++ie<be;)S=j(S,v[ie],ie,v);return S}function fc(v,j,S,H){var ie=v==null?0:v.length;for(H&&ie&&(S=v[--ie]);ie--;)S=j(S,v[ie],ie,v);return S}function Ps(v,j){for(var S=-1,H=v==null?0:v.length;++S<H;)if(j(v[S],S,v))return!0;return!1}var hc=Rs("length");function gc(v){return v.split("")}function pc(v){return v.match(Sr)||[]}function go(v,j,S){var H;return S(v,function(ie,be,He){if(j(ie,be,He))return H=be,!1}),H}function kr(v,j,S,H){for(var ie=v.length,be=S+(H?1:-1);H?be--:++be<ie;)if(j(v[be],be,v))return be;return-1}function Mn(v,j,S){return j===j?Cc(v,j,S):kr(v,po,S)}function mc(v,j,S,H){for(var ie=S-1,be=v.length;++ie<be;)if(H(v[ie],j))return ie;return-1}function po(v){return v!==v}function mo(v,j){var S=v==null?0:v.length;return S?Ws(v,j)/S:J}function Rs(v){return function(j){return j==null?r:j[v]}}function Ds(v){return function(j){return v==null?r:v[j]}}function xo(v,j,S,H,ie){return ie(v,function(be,He,Ce){S=H?(H=!1,be):j(S,be,He,Ce)}),S}function xc(v,j){var S=v.length;for(v.sort(j);S--;)v[S]=v[S].value;return v}function Ws(v,j){for(var S,H=-1,ie=v.length;++H<ie;){var be=j(v[H]);be!==r&&(S=S===r?be:S+be)}return S}function $s(v,j){for(var S=-1,H=Array(v);++S<v;)H[S]=j(S);return H}function vc(v,j){return Re(j,function(S){return[S,v[S]]})}function vo(v){return v&&v.slice(0,_o(v)+1).replace(Zn,"")}function xt(v){return function(j){return v(j)}}function Bs(v,j){return Re(j,function(S){return v[S]})}function Qn(v,j){return v.has(j)}function yo(v,j){for(var S=-1,H=v.length;++S<H&&Mn(j,v[S],0)>-1;);return S}function bo(v,j){for(var S=v.length;S--&&Mn(j,v[S],0)>-1;);return S}function yc(v,j){for(var S=v.length,H=0;S--;)v[S]===j&&++H;return H}var bc=Ds(rc),wc=Ds(sc);function _c(v){return"\\"+oc[v]}function Sc(v,j){return v==null?r:v[j]}function Ln(v){return Ql.test(v)}function Nc(v){return ec.test(v)}function jc(v){for(var j,S=[];!(j=v.next()).done;)S.push(j.value);return S}function Fs(v){var j=-1,S=Array(v.size);return v.forEach(function(H,ie){S[++j]=[ie,H]}),S}function wo(v,j){return function(S){return v(j(S))}}function an(v,j){for(var S=-1,H=v.length,ie=0,be=[];++S<H;){var He=v[S];(He===j||He===_)&&(v[S]=_,be[ie++]=S)}return be}function Ar(v){var j=-1,S=Array(v.size);return v.forEach(function(H){S[++j]=H}),S}function Ec(v){var j=-1,S=Array(v.size);return v.forEach(function(H){S[++j]=[H,H]}),S}function Cc(v,j,S){for(var H=S-1,ie=v.length;++H<ie;)if(v[H]===j)return H;return-1}function kc(v,j,S){for(var H=S+1;H--;)if(v[H]===j)return H;return H}function On(v){return Ln(v)?Ic(v):hc(v)}function Pt(v){return Ln(v)?Mc(v):gc(v)}function _o(v){for(var j=v.length;j--&&wr.test(v.charAt(j)););return j}var Ac=Ds(ic);function Ic(v){for(var j=Is.lastIndex=0;Is.test(v);)++j;return j}function Mc(v){return v.match(Is)||[]}function Lc(v){return v.match(Vl)||[]}var Oc=function v(j){j=j==null?Ve:Tn.defaults(Ve.Object(),j,Tn.pick(Ve,tc));var S=j.Array,H=j.Date,ie=j.Error,be=j.Function,He=j.Math,Ce=j.Object,zs=j.RegExp,Tc=j.String,jt=j.TypeError,Ir=S.prototype,Pc=be.prototype,Pn=Ce.prototype,Mr=j["__core-js_shared__"],Lr=Pc.toString,Ne=Pn.hasOwnProperty,Rc=0,So=function(){var e=/[^.]+$/.exec(Mr&&Mr.keys&&Mr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Or=Pn.toString,Dc=Lr.call(Ce),Wc=Ve._,$c=zs("^"+Lr.call(Ne).replace(Xn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tr=io?j.Buffer:r,ln=j.Symbol,Pr=j.Uint8Array,No=Tr?Tr.allocUnsafe:r,Rr=wo(Ce.getPrototypeOf,Ce),jo=Ce.create,Eo=Pn.propertyIsEnumerable,Dr=Ir.splice,Co=ln?ln.isConcatSpreadable:r,er=ln?ln.iterator:r,vn=ln?ln.toStringTag:r,Wr=function(){try{var e=Sn(Ce,"defineProperty");return e({},"",{}),e}catch{}}(),Bc=j.clearTimeout!==Ve.clearTimeout&&j.clearTimeout,Fc=H&&H.now!==Ve.Date.now&&H.now,zc=j.setTimeout!==Ve.setTimeout&&j.setTimeout,$r=He.ceil,Br=He.floor,Us=Ce.getOwnPropertySymbols,Uc=Tr?Tr.isBuffer:r,ko=j.isFinite,Gc=Ir.join,Hc=wo(Ce.keys,Ce),Ke=He.max,tt=He.min,Kc=H.now,qc=j.parseInt,Ao=He.random,Jc=Ir.reverse,Gs=Sn(j,"DataView"),tr=Sn(j,"Map"),Hs=Sn(j,"Promise"),Rn=Sn(j,"Set"),nr=Sn(j,"WeakMap"),rr=Sn(Ce,"create"),Fr=nr&&new nr,Dn={},Yc=Nn(Gs),Xc=Nn(tr),Zc=Nn(Hs),Vc=Nn(Rn),Qc=Nn(nr),zr=ln?ln.prototype:r,sr=zr?zr.valueOf:r,Io=zr?zr.toString:r;function a(e){if($e(e)&&!oe(e)&&!(e instanceof pe)){if(e instanceof Et)return e;if(Ne.call(e,"__wrapped__"))return Ma(e)}return new Et(e)}var Wn=function(){function e(){}return function(t){if(!De(t))return{};if(jo)return jo(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function Ur(){}function Et(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}a.templateSettings={escape:bs,evaluate:br,interpolate:An,variable:"",imports:{_:a}},a.prototype=Ur.prototype,a.prototype.constructor=a,Et.prototype=Wn(Ur.prototype),Et.prototype.constructor=Et;function pe(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Z,this.__views__=[]}function eu(){var e=new pe(this.__wrapped__);return e.__actions__=ut(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ut(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ut(this.__views__),e}function tu(){if(this.__filtered__){var e=new pe(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function nu(){var e=this.__wrapped__.value(),t=this.__dir__,n=oe(e),s=t<0,o=n?e.length:0,c=gd(0,o,this.__views__),g=c.start,m=c.end,y=m-g,k=s?m:g-1,A=this.__iteratees__,L=A.length,$=0,X=tt(y,this.__takeCount__);if(!n||!s&&o==y&&X==y)return ea(e,this.__actions__);var te=[];e:for(;y--&&$<X;){k+=t;for(var de=-1,ne=e[k];++de<L;){var he=A[de],me=he.iteratee,bt=he.type,at=me(ne);if(bt==se)ne=at;else if(!at){if(bt==le)continue e;break e}}te[$++]=ne}return te}pe.prototype=Wn(Ur.prototype),pe.prototype.constructor=pe;function yn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var s=e[t];this.set(s[0],s[1])}}function ru(){this.__data__=rr?rr(null):{},this.size=0}function su(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function iu(e){var t=this.__data__;if(rr){var n=t[e];return n===w?r:n}return Ne.call(t,e)?t[e]:r}function ou(e){var t=this.__data__;return rr?t[e]!==r:Ne.call(t,e)}function au(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=rr&&t===r?w:t,this}yn.prototype.clear=ru,yn.prototype.delete=su,yn.prototype.get=iu,yn.prototype.has=ou,yn.prototype.set=au;function Ht(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var s=e[t];this.set(s[0],s[1])}}function lu(){this.__data__=[],this.size=0}function cu(e){var t=this.__data__,n=Gr(t,e);if(n<0)return!1;var s=t.length-1;return n==s?t.pop():Dr.call(t,n,1),--this.size,!0}function uu(e){var t=this.__data__,n=Gr(t,e);return n<0?r:t[n][1]}function du(e){return Gr(this.__data__,e)>-1}function fu(e,t){var n=this.__data__,s=Gr(n,e);return s<0?(++this.size,n.push([e,t])):n[s][1]=t,this}Ht.prototype.clear=lu,Ht.prototype.delete=cu,Ht.prototype.get=uu,Ht.prototype.has=du,Ht.prototype.set=fu;function Kt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var s=e[t];this.set(s[0],s[1])}}function hu(){this.size=0,this.__data__={hash:new yn,map:new(tr||Ht),string:new yn}}function gu(e){var t=ns(this,e).delete(e);return this.size-=t?1:0,t}function pu(e){return ns(this,e).get(e)}function mu(e){return ns(this,e).has(e)}function xu(e,t){var n=ns(this,e),s=n.size;return n.set(e,t),this.size+=n.size==s?0:1,this}Kt.prototype.clear=hu,Kt.prototype.delete=gu,Kt.prototype.get=pu,Kt.prototype.has=mu,Kt.prototype.set=xu;function bn(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Kt;++t<n;)this.add(e[t])}function vu(e){return this.__data__.set(e,w),this}function yu(e){return this.__data__.has(e)}bn.prototype.add=bn.prototype.push=vu,bn.prototype.has=yu;function Rt(e){var t=this.__data__=new Ht(e);this.size=t.size}function bu(){this.__data__=new Ht,this.size=0}function wu(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function _u(e){return this.__data__.get(e)}function Su(e){return this.__data__.has(e)}function Nu(e,t){var n=this.__data__;if(n instanceof Ht){var s=n.__data__;if(!tr||s.length<u-1)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new Kt(s)}return n.set(e,t),this.size=n.size,this}Rt.prototype.clear=bu,Rt.prototype.delete=wu,Rt.prototype.get=_u,Rt.prototype.has=Su,Rt.prototype.set=Nu;function Mo(e,t){var n=oe(e),s=!n&&jn(e),o=!n&&!s&&hn(e),c=!n&&!s&&!o&&zn(e),g=n||s||o||c,m=g?$s(e.length,Tc):[],y=m.length;for(var k in e)(t||Ne.call(e,k))&&!(g&&(k=="length"||o&&(k=="offset"||k=="parent")||c&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||Xt(k,y)))&&m.push(k);return m}function Lo(e){var t=e.length;return t?e[ni(0,t-1)]:r}function ju(e,t){return rs(ut(e),wn(t,0,e.length))}function Eu(e){return rs(ut(e))}function Ks(e,t,n){(n!==r&&!Dt(e[t],n)||n===r&&!(t in e))&&qt(e,t,n)}function ir(e,t,n){var s=e[t];(!(Ne.call(e,t)&&Dt(s,n))||n===r&&!(t in e))&&qt(e,t,n)}function Gr(e,t){for(var n=e.length;n--;)if(Dt(e[n][0],t))return n;return-1}function Cu(e,t,n,s){return cn(e,function(o,c,g){t(s,o,n(o),g)}),s}function Oo(e,t){return e&&zt(t,Ye(t),e)}function ku(e,t){return e&&zt(t,ft(t),e)}function qt(e,t,n){t=="__proto__"&&Wr?Wr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function qs(e,t){for(var n=-1,s=t.length,o=S(s),c=e==null;++n<s;)o[n]=c?r:Ci(e,t[n]);return o}function wn(e,t,n){return e===e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function Ct(e,t,n,s,o,c){var g,m=t&b,y=t&I,k=t&P;if(n&&(g=o?n(e,s,o,c):n(e)),g!==r)return g;if(!De(e))return e;var A=oe(e);if(A){if(g=md(e),!m)return ut(e,g)}else{var L=nt(e),$=L==Mt||L==Bt;if(hn(e))return ra(e,m);if(L==ct||L==Ie||$&&!o){if(g=y||$?{}:_a(e),!m)return y?id(e,ku(g,e)):sd(e,Oo(g,e))}else{if(!Ae[L])return o?e:{};g=xd(e,L,m)}}c||(c=new Rt);var X=c.get(e);if(X)return X;c.set(e,g),Za(e)?e.forEach(function(ne){g.add(Ct(ne,t,n,ne,e,c))}):Ya(e)&&e.forEach(function(ne,he){g.set(he,Ct(ne,t,n,he,e,c))});var te=k?y?hi:fi:y?ft:Ye,de=A?r:te(e);return Nt(de||e,function(ne,he){de&&(he=ne,ne=e[he]),ir(g,he,Ct(ne,t,n,he,e,c))}),g}function Au(e){var t=Ye(e);return function(n){return To(n,e,t)}}function To(e,t,n){var s=n.length;if(e==null)return!s;for(e=Ce(e);s--;){var o=n[s],c=t[o],g=e[o];if(g===r&&!(o in e)||!c(g))return!1}return!0}function Po(e,t,n){if(typeof e!="function")throw new jt(p);return fr(function(){e.apply(r,n)},t)}function or(e,t,n,s){var o=-1,c=Cr,g=!0,m=e.length,y=[],k=t.length;if(!m)return y;n&&(t=Re(t,xt(n))),s?(c=Os,g=!1):t.length>=u&&(c=Qn,g=!1,t=new bn(t));e:for(;++o<m;){var A=e[o],L=n==null?A:n(A);if(A=s||A!==0?A:0,g&&L===L){for(var $=k;$--;)if(t[$]===L)continue e;y.push(A)}else c(t,L,s)||y.push(A)}return y}var cn=la(Ft),Ro=la(Ys,!0);function Iu(e,t){var n=!0;return cn(e,function(s,o,c){return n=!!t(s,o,c),n}),n}function Hr(e,t,n){for(var s=-1,o=e.length;++s<o;){var c=e[s],g=t(c);if(g!=null&&(m===r?g===g&&!yt(g):n(g,m)))var m=g,y=c}return y}function Mu(e,t,n,s){var o=e.length;for(n=ue(n),n<0&&(n=-n>o?0:o+n),s=s===r||s>o?o:ue(s),s<0&&(s+=o),s=n>s?0:Qa(s);n<s;)e[n++]=t;return e}function Do(e,t){var n=[];return cn(e,function(s,o,c){t(s,o,c)&&n.push(s)}),n}function Qe(e,t,n,s,o){var c=-1,g=e.length;for(n||(n=yd),o||(o=[]);++c<g;){var m=e[c];t>0&&n(m)?t>1?Qe(m,t-1,n,s,o):on(o,m):s||(o[o.length]=m)}return o}var Js=ca(),Wo=ca(!0);function Ft(e,t){return e&&Js(e,t,Ye)}function Ys(e,t){return e&&Wo(e,t,Ye)}function Kr(e,t){return sn(t,function(n){return Zt(e[n])})}function _n(e,t){t=dn(t,e);for(var n=0,s=t.length;e!=null&&n<s;)e=e[Ut(t[n++])];return n&&n==s?e:r}function $o(e,t,n){var s=t(e);return oe(e)?s:on(s,n(e))}function it(e){return e==null?e===r?Y:en:vn&&vn in Ce(e)?hd(e):Ed(e)}function Xs(e,t){return e>t}function Lu(e,t){return e!=null&&Ne.call(e,t)}function Ou(e,t){return e!=null&&t in Ce(e)}function Tu(e,t,n){return e>=tt(t,n)&&e<Ke(t,n)}function Zs(e,t,n){for(var s=n?Os:Cr,o=e[0].length,c=e.length,g=c,m=S(c),y=1/0,k=[];g--;){var A=e[g];g&&t&&(A=Re(A,xt(t))),y=tt(A.length,y),m[g]=!n&&(t||o>=120&&A.length>=120)?new bn(g&&A):r}A=e[0];var L=-1,$=m[0];e:for(;++L<o&&k.length<y;){var X=A[L],te=t?t(X):X;if(X=n||X!==0?X:0,!($?Qn($,te):s(k,te,n))){for(g=c;--g;){var de=m[g];if(!(de?Qn(de,te):s(e[g],te,n)))continue e}$&&$.push(te),k.push(X)}}return k}function Pu(e,t,n,s){return Ft(e,function(o,c,g){t(s,n(o),c,g)}),s}function ar(e,t,n){t=dn(t,e),e=Ea(e,t);var s=e==null?e:e[Ut(At(t))];return s==null?r:mt(s,e,n)}function Bo(e){return $e(e)&&it(e)==Ie}function Ru(e){return $e(e)&&it(e)==_e}function Du(e){return $e(e)&&it(e)==lt}function lr(e,t,n,s,o){return e===t?!0:e==null||t==null||!$e(e)&&!$e(t)?e!==e&&t!==t:Wu(e,t,n,s,lr,o)}function Wu(e,t,n,s,o,c){var g=oe(e),m=oe(t),y=g?Be:nt(e),k=m?Be:nt(t);y=y==Ie?ct:y,k=k==Ie?ct:k;var A=y==ct,L=k==ct,$=y==k;if($&&hn(e)){if(!hn(t))return!1;g=!0,A=!1}if($&&!A)return c||(c=new Rt),g||zn(e)?ya(e,t,n,s,o,c):dd(e,t,y,n,s,o,c);if(!(n&O)){var X=A&&Ne.call(e,"__wrapped__"),te=L&&Ne.call(t,"__wrapped__");if(X||te){var de=X?e.value():e,ne=te?t.value():t;return c||(c=new Rt),o(de,ne,n,s,c)}}return $?(c||(c=new Rt),fd(e,t,n,s,o,c)):!1}function $u(e){return $e(e)&&nt(e)==Xe}function Vs(e,t,n,s){var o=n.length,c=o,g=!s;if(e==null)return!c;for(e=Ce(e);o--;){var m=n[o];if(g&&m[2]?m[1]!==e[m[0]]:!(m[0]in e))return!1}for(;++o<c;){m=n[o];var y=m[0],k=e[y],A=m[1];if(g&&m[2]){if(k===r&&!(y in e))return!1}else{var L=new Rt;if(s)var $=s(k,A,y,e,t,L);if(!($===r?lr(A,k,O|G,s,L):$))return!1}}return!0}function Fo(e){if(!De(e)||wd(e))return!1;var t=Zt(e)?$c:Ee;return t.test(Nn(e))}function Bu(e){return $e(e)&&it(e)==Gt}function Fu(e){return $e(e)&&nt(e)==Ze}function zu(e){return $e(e)&&cs(e.length)&&!!Le[it(e)]}function zo(e){return typeof e=="function"?e:e==null?ht:typeof e=="object"?oe(e)?Ho(e[0],e[1]):Go(e):ul(e)}function Qs(e){if(!dr(e))return Hc(e);var t=[];for(var n in Ce(e))Ne.call(e,n)&&n!="constructor"&&t.push(n);return t}function Uu(e){if(!De(e))return jd(e);var t=dr(e),n=[];for(var s in e)s=="constructor"&&(t||!Ne.call(e,s))||n.push(s);return n}function ei(e,t){return e<t}function Uo(e,t){var n=-1,s=dt(e)?S(e.length):[];return cn(e,function(o,c,g){s[++n]=t(o,c,g)}),s}function Go(e){var t=pi(e);return t.length==1&&t[0][2]?Na(t[0][0],t[0][1]):function(n){return n===e||Vs(n,e,t)}}function Ho(e,t){return xi(e)&&Sa(t)?Na(Ut(e),t):function(n){var s=Ci(n,e);return s===r&&s===t?ki(n,e):lr(t,s,O|G)}}function qr(e,t,n,s,o){e!==t&&Js(t,function(c,g){if(o||(o=new Rt),De(c))Gu(e,t,g,n,qr,s,o);else{var m=s?s(yi(e,g),c,g+"",e,t,o):r;m===r&&(m=c),Ks(e,g,m)}},ft)}function Gu(e,t,n,s,o,c,g){var m=yi(e,n),y=yi(t,n),k=g.get(y);if(k){Ks(e,n,k);return}var A=c?c(m,y,n+"",e,t,g):r,L=A===r;if(L){var $=oe(y),X=!$&&hn(y),te=!$&&!X&&zn(y);A=y,$||X||te?oe(m)?A=m:ze(m)?A=ut(m):X?(L=!1,A=ra(y,!0)):te?(L=!1,A=sa(y,!0)):A=[]:hr(y)||jn(y)?(A=m,jn(m)?A=el(m):(!De(m)||Zt(m))&&(A=_a(y))):L=!1}L&&(g.set(y,A),o(A,y,s,c,g),g.delete(y)),Ks(e,n,A)}function Ko(e,t){var n=e.length;if(n)return t+=t<0?n:0,Xt(t,n)?e[t]:r}function qo(e,t,n){t.length?t=Re(t,function(c){return oe(c)?function(g){return _n(g,c.length===1?c[0]:c)}:c}):t=[ht];var s=-1;t=Re(t,xt(ee()));var o=Uo(e,function(c,g,m){var y=Re(t,function(k){return k(c)});return{criteria:y,index:++s,value:c}});return xc(o,function(c,g){return rd(c,g,n)})}function Hu(e,t){return Jo(e,t,function(n,s){return ki(e,s)})}function Jo(e,t,n){for(var s=-1,o=t.length,c={};++s<o;){var g=t[s],m=_n(e,g);n(m,g)&&cr(c,dn(g,e),m)}return c}function Ku(e){return function(t){return _n(t,e)}}function ti(e,t,n,s){var o=s?mc:Mn,c=-1,g=t.length,m=e;for(e===t&&(t=ut(t)),n&&(m=Re(e,xt(n)));++c<g;)for(var y=0,k=t[c],A=n?n(k):k;(y=o(m,A,y,s))>-1;)m!==e&&Dr.call(m,y,1),Dr.call(e,y,1);return e}function Yo(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;Xt(o)?Dr.call(e,o,1):ii(e,o)}}return e}function ni(e,t){return e+Br(Ao()*(t-e+1))}function qu(e,t,n,s){for(var o=-1,c=Ke($r((t-e)/(n||1)),0),g=S(c);c--;)g[s?c:++o]=e,e+=n;return g}function ri(e,t){var n="";if(!e||t<1||t>K)return n;do t%2&&(n+=e),t=Br(t/2),t&&(e+=e);while(t);return n}function fe(e,t){return bi(ja(e,t,ht),e+"")}function Ju(e){return Lo(Un(e))}function Yu(e,t){var n=Un(e);return rs(n,wn(t,0,n.length))}function cr(e,t,n,s){if(!De(e))return e;t=dn(t,e);for(var o=-1,c=t.length,g=c-1,m=e;m!=null&&++o<c;){var y=Ut(t[o]),k=n;if(y==="__proto__"||y==="constructor"||y==="prototype")return e;if(o!=g){var A=m[y];k=s?s(A,y,m):r,k===r&&(k=De(A)?A:Xt(t[o+1])?[]:{})}ir(m,y,k),m=m[y]}return e}var Xo=Fr?function(e,t){return Fr.set(e,t),e}:ht,Xu=Wr?function(e,t){return Wr(e,"toString",{configurable:!0,enumerable:!1,value:Ii(t),writable:!0})}:ht;function Zu(e){return rs(Un(e))}function kt(e,t,n){var s=-1,o=e.length;t<0&&(t=-t>o?0:o+t),n=n>o?o:n,n<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var c=S(o);++s<o;)c[s]=e[s+t];return c}function Vu(e,t){var n;return cn(e,function(s,o,c){return n=t(s,o,c),!n}),!!n}function Jr(e,t,n){var s=0,o=e==null?s:e.length;if(typeof t=="number"&&t===t&&o<=ke){for(;s<o;){var c=s+o>>>1,g=e[c];g!==null&&!yt(g)&&(n?g<=t:g<t)?s=c+1:o=c}return o}return si(e,t,ht,n)}function si(e,t,n,s){var o=0,c=e==null?0:e.length;if(c===0)return 0;t=n(t);for(var g=t!==t,m=t===null,y=yt(t),k=t===r;o<c;){var A=Br((o+c)/2),L=n(e[A]),$=L!==r,X=L===null,te=L===L,de=yt(L);if(g)var ne=s||te;else k?ne=te&&(s||$):m?ne=te&&$&&(s||!X):y?ne=te&&$&&!X&&(s||!de):X||de?ne=!1:ne=s?L<=t:L<t;ne?o=A+1:c=A}return tt(c,ye)}function Zo(e,t){for(var n=-1,s=e.length,o=0,c=[];++n<s;){var g=e[n],m=t?t(g):g;if(!n||!Dt(m,y)){var y=m;c[o++]=g===0?0:g}}return c}function Vo(e){return typeof e=="number"?e:yt(e)?J:+e}function vt(e){if(typeof e=="string")return e;if(oe(e))return Re(e,vt)+"";if(yt(e))return Io?Io.call(e):"";var t=e+"";return t=="0"&&1/e==-Q?"-0":t}function un(e,t,n){var s=-1,o=Cr,c=e.length,g=!0,m=[],y=m;if(n)g=!1,o=Os;else if(c>=u){var k=t?null:cd(e);if(k)return Ar(k);g=!1,o=Qn,y=new bn}else y=t?[]:m;e:for(;++s<c;){var A=e[s],L=t?t(A):A;if(A=n||A!==0?A:0,g&&L===L){for(var $=y.length;$--;)if(y[$]===L)continue e;t&&y.push(L),m.push(A)}else o(y,L,n)||(y!==m&&y.push(L),m.push(A))}return m}function ii(e,t){return t=dn(t,e),e=Ea(e,t),e==null||delete e[Ut(At(t))]}function Qo(e,t,n,s){return cr(e,t,n(_n(e,t)),s)}function Yr(e,t,n,s){for(var o=e.length,c=s?o:-1;(s?c--:++c<o)&&t(e[c],c,e););return n?kt(e,s?0:c,s?c+1:o):kt(e,s?c+1:0,s?o:c)}function ea(e,t){var n=e;return n instanceof pe&&(n=n.value()),Ts(t,function(s,o){return o.func.apply(o.thisArg,on([s],o.args))},n)}function oi(e,t,n){var s=e.length;if(s<2)return s?un(e[0]):[];for(var o=-1,c=S(s);++o<s;)for(var g=e[o],m=-1;++m<s;)m!=o&&(c[o]=or(c[o]||g,e[m],t,n));return un(Qe(c,1),t,n)}function ta(e,t,n){for(var s=-1,o=e.length,c=t.length,g={};++s<o;){var m=s<c?t[s]:r;n(g,e[s],m)}return g}function ai(e){return ze(e)?e:[]}function li(e){return typeof e=="function"?e:ht}function dn(e,t){return oe(e)?e:xi(e,t)?[e]:Ia(Se(e))}var Qu=fe;function fn(e,t,n){var s=e.length;return n=n===r?s:n,!t&&n>=s?e:kt(e,t,n)}var na=Bc||function(e){return Ve.clearTimeout(e)};function ra(e,t){if(t)return e.slice();var n=e.length,s=No?No(n):new e.constructor(n);return e.copy(s),s}function ci(e){var t=new e.constructor(e.byteLength);return new Pr(t).set(new Pr(e)),t}function ed(e,t){var n=t?ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function td(e){var t=new e.constructor(e.source,mn.exec(e));return t.lastIndex=e.lastIndex,t}function nd(e){return sr?Ce(sr.call(e)):{}}function sa(e,t){var n=t?ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function ia(e,t){if(e!==t){var n=e!==r,s=e===null,o=e===e,c=yt(e),g=t!==r,m=t===null,y=t===t,k=yt(t);if(!m&&!k&&!c&&e>t||c&&g&&y&&!m&&!k||s&&g&&y||!n&&y||!o)return 1;if(!s&&!c&&!k&&e<t||k&&n&&o&&!s&&!c||m&&n&&o||!g&&o||!y)return-1}return 0}function rd(e,t,n){for(var s=-1,o=e.criteria,c=t.criteria,g=o.length,m=n.length;++s<g;){var y=ia(o[s],c[s]);if(y){if(s>=m)return y;var k=n[s];return y*(k=="desc"?-1:1)}}return e.index-t.index}function oa(e,t,n,s){for(var o=-1,c=e.length,g=n.length,m=-1,y=t.length,k=Ke(c-g,0),A=S(y+k),L=!s;++m<y;)A[m]=t[m];for(;++o<g;)(L||o<c)&&(A[n[o]]=e[o]);for(;k--;)A[m++]=e[o++];return A}function aa(e,t,n,s){for(var o=-1,c=e.length,g=-1,m=n.length,y=-1,k=t.length,A=Ke(c-m,0),L=S(A+k),$=!s;++o<A;)L[o]=e[o];for(var X=o;++y<k;)L[X+y]=t[y];for(;++g<m;)($||o<c)&&(L[X+n[g]]=e[o++]);return L}function ut(e,t){var n=-1,s=e.length;for(t||(t=S(s));++n<s;)t[n]=e[n];return t}function zt(e,t,n,s){var o=!n;n||(n={});for(var c=-1,g=t.length;++c<g;){var m=t[c],y=s?s(n[m],e[m],m,n,e):r;y===r&&(y=e[m]),o?qt(n,m,y):ir(n,m,y)}return n}function sd(e,t){return zt(e,mi(e),t)}function id(e,t){return zt(e,ba(e),t)}function Xr(e,t){return function(n,s){var o=oe(n)?uc:Cu,c=t?t():{};return o(n,e,ee(s,2),c)}}function $n(e){return fe(function(t,n){var s=-1,o=n.length,c=o>1?n[o-1]:r,g=o>2?n[2]:r;for(c=e.length>3&&typeof c=="function"?(o--,c):r,g&&ot(n[0],n[1],g)&&(c=o<3?r:c,o=1),t=Ce(t);++s<o;){var m=n[s];m&&e(t,m,s,c)}return t})}function la(e,t){return function(n,s){if(n==null)return n;if(!dt(n))return e(n,s);for(var o=n.length,c=t?o:-1,g=Ce(n);(t?c--:++c<o)&&s(g[c],c,g)!==!1;);return n}}function ca(e){return function(t,n,s){for(var o=-1,c=Ce(t),g=s(t),m=g.length;m--;){var y=g[e?m:++o];if(n(c[y],y,c)===!1)break}return t}}function od(e,t,n){var s=t&q,o=ur(e);function c(){var g=this&&this!==Ve&&this instanceof c?o:e;return g.apply(s?n:this,arguments)}return c}function ua(e){return function(t){t=Se(t);var n=Ln(t)?Pt(t):r,s=n?n[0]:t.charAt(0),o=n?fn(n,1).join(""):t.slice(1);return s[e]()+o}}function Bn(e){return function(t){return Ts(ll(al(t).replace(Xl,"")),e,"")}}function ur(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Wn(e.prototype),s=e.apply(n,t);return De(s)?s:n}}function ad(e,t,n){var s=ur(e);function o(){for(var c=arguments.length,g=S(c),m=c,y=Fn(o);m--;)g[m]=arguments[m];var k=c<3&&g[0]!==y&&g[c-1]!==y?[]:an(g,y);if(c-=k.length,c<n)return pa(e,t,Zr,o.placeholder,r,g,k,r,r,n-c);var A=this&&this!==Ve&&this instanceof o?s:e;return mt(A,this,g)}return o}function da(e){return function(t,n,s){var o=Ce(t);if(!dt(t)){var c=ee(n,3);t=Ye(t),n=function(m){return c(o[m],m,o)}}var g=e(t,n,s);return g>-1?o[c?t[g]:g]:r}}function fa(e){return Yt(function(t){var n=t.length,s=n,o=Et.prototype.thru;for(e&&t.reverse();s--;){var c=t[s];if(typeof c!="function")throw new jt(p);if(o&&!g&&ts(c)=="wrapper")var g=new Et([],!0)}for(s=g?s:n;++s<n;){c=t[s];var m=ts(c),y=m=="wrapper"?gi(c):r;y&&vi(y[0])&&y[1]==(V|B|M|je)&&!y[4].length&&y[9]==1?g=g[ts(y[0])].apply(g,y[3]):g=c.length==1&&vi(c)?g[m]():g.thru(c)}return function(){var k=arguments,A=k[0];if(g&&k.length==1&&oe(A))return g.plant(A).value();for(var L=0,$=n?t[L].apply(this,k):A;++L<n;)$=t[L].call(this,$);return $}})}function Zr(e,t,n,s,o,c,g,m,y,k){var A=t&V,L=t&q,$=t&F,X=t&(B|C),te=t&U,de=$?r:ur(e);function ne(){for(var he=arguments.length,me=S(he),bt=he;bt--;)me[bt]=arguments[bt];if(X)var at=Fn(ne),wt=yc(me,at);if(s&&(me=oa(me,s,o,X)),c&&(me=aa(me,c,g,X)),he-=wt,X&&he<k){var Ue=an(me,at);return pa(e,t,Zr,ne.placeholder,n,me,Ue,m,y,k-he)}var Wt=L?n:this,Qt=$?Wt[e]:e;return he=me.length,m?me=Cd(me,m):te&&he>1&&me.reverse(),A&&y<he&&(me.length=y),this&&this!==Ve&&this instanceof ne&&(Qt=de||ur(Qt)),Qt.apply(Wt,me)}return ne}function ha(e,t){return function(n,s){return Pu(n,e,t(s),{})}}function Vr(e,t){return function(n,s){var o;if(n===r&&s===r)return t;if(n!==r&&(o=n),s!==r){if(o===r)return s;typeof n=="string"||typeof s=="string"?(n=vt(n),s=vt(s)):(n=Vo(n),s=Vo(s)),o=e(n,s)}return o}}function ui(e){return Yt(function(t){return t=Re(t,xt(ee())),fe(function(n){var s=this;return e(t,function(o){return mt(o,s,n)})})})}function Qr(e,t){t=t===r?" ":vt(t);var n=t.length;if(n<2)return n?ri(t,e):t;var s=ri(t,$r(e/On(t)));return Ln(t)?fn(Pt(s),0,e).join(""):s.slice(0,e)}function ld(e,t,n,s){var o=t&q,c=ur(e);function g(){for(var m=-1,y=arguments.length,k=-1,A=s.length,L=S(A+y),$=this&&this!==Ve&&this instanceof g?c:e;++k<A;)L[k]=s[k];for(;y--;)L[k++]=arguments[++m];return mt($,o?n:this,L)}return g}function ga(e){return function(t,n,s){return s&&typeof s!="number"&&ot(t,n,s)&&(n=s=r),t=Vt(t),n===r?(n=t,t=0):n=Vt(n),s=s===r?t<n?1:-1:Vt(s),qu(t,n,s,e)}}function es(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=It(t),n=It(n)),e(t,n)}}function pa(e,t,n,s,o,c,g,m,y,k){var A=t&B,L=A?g:r,$=A?r:g,X=A?c:r,te=A?r:c;t|=A?M:z,t&=~(A?z:M),t&D||(t&=-4);var de=[e,t,o,X,L,te,$,m,y,k],ne=n.apply(r,de);return vi(e)&&Ca(ne,de),ne.placeholder=s,ka(ne,e,t)}function di(e){var t=He[e];return function(n,s){if(n=It(n),s=s==null?0:tt(ue(s),292),s&&ko(n)){var o=(Se(n)+"e").split("e"),c=t(o[0]+"e"+(+o[1]+s));return o=(Se(c)+"e").split("e"),+(o[0]+"e"+(+o[1]-s))}return t(n)}}var cd=Rn&&1/Ar(new Rn([,-0]))[1]==Q?function(e){return new Rn(e)}:Oi;function ma(e){return function(t){var n=nt(t);return n==Xe?Fs(t):n==Ze?Ec(t):vc(t,e(t))}}function Jt(e,t,n,s,o,c,g,m){var y=t&F;if(!y&&typeof e!="function")throw new jt(p);var k=s?s.length:0;if(k||(t&=-97,s=o=r),g=g===r?g:Ke(ue(g),0),m=m===r?m:ue(m),k-=o?o.length:0,t&z){var A=s,L=o;s=o=r}var $=y?r:gi(e),X=[e,t,n,s,o,A,L,c,g,m];if($&&Nd(X,$),e=X[0],t=X[1],n=X[2],s=X[3],o=X[4],m=X[9]=X[9]===r?y?0:e.length:Ke(X[9]-k,0),!m&&t&(B|C)&&(t&=-25),!t||t==q)var te=od(e,t,n);else t==B||t==C?te=ad(e,t,m):(t==M||t==(q|M))&&!o.length?te=ld(e,t,n,s):te=Zr.apply(r,X);var de=$?Xo:Ca;return ka(de(te,X),e,t)}function xa(e,t,n,s){return e===r||Dt(e,Pn[n])&&!Ne.call(s,n)?t:e}function va(e,t,n,s,o,c){return De(e)&&De(t)&&(c.set(t,e),qr(e,t,r,va,c),c.delete(t)),e}function ud(e){return hr(e)?r:e}function ya(e,t,n,s,o,c){var g=n&O,m=e.length,y=t.length;if(m!=y&&!(g&&y>m))return!1;var k=c.get(e),A=c.get(t);if(k&&A)return k==t&&A==e;var L=-1,$=!0,X=n&G?new bn:r;for(c.set(e,t),c.set(t,e);++L<m;){var te=e[L],de=t[L];if(s)var ne=g?s(de,te,L,t,e,c):s(te,de,L,e,t,c);if(ne!==r){if(ne)continue;$=!1;break}if(X){if(!Ps(t,function(he,me){if(!Qn(X,me)&&(te===he||o(te,he,n,s,c)))return X.push(me)})){$=!1;break}}else if(!(te===de||o(te,de,n,s,c))){$=!1;break}}return c.delete(e),c.delete(t),$}function dd(e,t,n,s,o,c,g){switch(n){case Fe:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case _e:return!(e.byteLength!=t.byteLength||!c(new Pr(e),new Pr(t)));case gt:case lt:case st:return Dt(+e,+t);case pt:return e.name==t.name&&e.message==t.message;case Gt:case Lt:return e==t+"";case Xe:var m=Fs;case Ze:var y=s&O;if(m||(m=Ar),e.size!=t.size&&!y)return!1;var k=g.get(e);if(k)return k==t;s|=G,g.set(e,t);var A=ya(m(e),m(t),s,o,c,g);return g.delete(e),A;case Ot:if(sr)return sr.call(e)==sr.call(t)}return!1}function fd(e,t,n,s,o,c){var g=n&O,m=fi(e),y=m.length,k=fi(t),A=k.length;if(y!=A&&!g)return!1;for(var L=y;L--;){var $=m[L];if(!(g?$ in t:Ne.call(t,$)))return!1}var X=c.get(e),te=c.get(t);if(X&&te)return X==t&&te==e;var de=!0;c.set(e,t),c.set(t,e);for(var ne=g;++L<y;){$=m[L];var he=e[$],me=t[$];if(s)var bt=g?s(me,he,$,t,e,c):s(he,me,$,e,t,c);if(!(bt===r?he===me||o(he,me,n,s,c):bt)){de=!1;break}ne||(ne=$=="constructor")}if(de&&!ne){var at=e.constructor,wt=t.constructor;at!=wt&&"constructor"in e&&"constructor"in t&&!(typeof at=="function"&&at instanceof at&&typeof wt=="function"&&wt instanceof wt)&&(de=!1)}return c.delete(e),c.delete(t),de}function Yt(e){return bi(ja(e,r,Ta),e+"")}function fi(e){return $o(e,Ye,mi)}function hi(e){return $o(e,ft,ba)}var gi=Fr?function(e){return Fr.get(e)}:Oi;function ts(e){for(var t=e.name+"",n=Dn[t],s=Ne.call(Dn,t)?n.length:0;s--;){var o=n[s],c=o.func;if(c==null||c==e)return o.name}return t}function Fn(e){var t=Ne.call(a,"placeholder")?a:e;return t.placeholder}function ee(){var e=a.iteratee||Mi;return e=e===Mi?zo:e,arguments.length?e(arguments[0],arguments[1]):e}function ns(e,t){var n=e.__data__;return bd(t)?n[typeof t=="string"?"string":"hash"]:n.map}function pi(e){for(var t=Ye(e),n=t.length;n--;){var s=t[n],o=e[s];t[n]=[s,o,Sa(o)]}return t}function Sn(e,t){var n=Sc(e,t);return Fo(n)?n:r}function hd(e){var t=Ne.call(e,vn),n=e[vn];try{e[vn]=r;var s=!0}catch{}var o=Or.call(e);return s&&(t?e[vn]=n:delete e[vn]),o}var mi=Us?function(e){return e==null?[]:(e=Ce(e),sn(Us(e),function(t){return Eo.call(e,t)}))}:Ti,ba=Us?function(e){for(var t=[];e;)on(t,mi(e)),e=Rr(e);return t}:Ti,nt=it;(Gs&&nt(new Gs(new ArrayBuffer(1)))!=Fe||tr&&nt(new tr)!=Xe||Hs&&nt(Hs.resolve())!=gn||Rn&&nt(new Rn)!=Ze||nr&&nt(new nr)!=re)&&(nt=function(e){var t=it(e),n=t==ct?e.constructor:r,s=n?Nn(n):"";if(s)switch(s){case Yc:return Fe;case Xc:return Xe;case Zc:return gn;case Vc:return Ze;case Qc:return re}return t});function gd(e,t,n){for(var s=-1,o=n.length;++s<o;){var c=n[s],g=c.size;switch(c.type){case"drop":e+=g;break;case"dropRight":t-=g;break;case"take":t=tt(t,e+g);break;case"takeRight":e=Ke(e,t-g);break}}return{start:e,end:t}}function pd(e){var t=e.match(Ns);return t?t[1].split(_r):[]}function wa(e,t,n){t=dn(t,e);for(var s=-1,o=t.length,c=!1;++s<o;){var g=Ut(t[s]);if(!(c=e!=null&&n(e,g)))break;e=e[g]}return c||++s!=o?c:(o=e==null?0:e.length,!!o&&cs(o)&&Xt(g,o)&&(oe(e)||jn(e)))}function md(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&Ne.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function _a(e){return typeof e.constructor=="function"&&!dr(e)?Wn(Rr(e)):{}}function xd(e,t,n){var s=e.constructor;switch(t){case _e:return ci(e);case gt:case lt:return new s(+e);case Fe:return ed(e,n);case Me:case Te:case Pe:case Je:case Tt:case _t:case Kn:case qn:case Jn:return sa(e,n);case Xe:return new s;case st:case Lt:return new s(e);case Gt:return td(e);case Ze:return new s;case Ot:return nd(e)}}function vd(e,t){var n=t.length;if(!n)return e;var s=n-1;return t[s]=(n>1?"& ":"")+t[s],t=t.join(n>2?", ":" "),e.replace(Vn,`{
/* [wrapped with `+t+`] */
`)}function yd(e){return oe(e)||jn(e)||!!(Co&&e&&e[Co])}function Xt(e,t){var n=typeof e;return t=t??K,!!t&&(n=="number"||n!="symbol"&&rn.test(e))&&e>-1&&e%1==0&&e<t}function ot(e,t,n){if(!De(n))return!1;var s=typeof t;return(s=="number"?dt(n)&&Xt(t,n.length):s=="string"&&t in n)?Dt(n[t],e):!1}function xi(e,t){if(oe(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||yt(e)?!0:_s.test(e)||!ws.test(e)||t!=null&&e in Ce(t)}function bd(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function vi(e){var t=ts(e),n=a[t];if(typeof n!="function"||!(t in pe.prototype))return!1;if(e===n)return!0;var s=gi(n);return!!s&&e===s[0]}function wd(e){return!!So&&So in e}var _d=Mr?Zt:Pi;function dr(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Pn;return e===n}function Sa(e){return e===e&&!De(e)}function Na(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==r||e in Ce(n))}}function Sd(e){var t=as(e,function(s){return n.size===N&&n.clear(),s}),n=t.cache;return t}function Nd(e,t){var n=e[1],s=t[1],o=n|s,c=o<(q|F|V),g=s==V&&n==B||s==V&&n==je&&e[7].length<=t[8]||s==(V|je)&&t[7].length<=t[8]&&n==B;if(!(c||g))return e;s&q&&(e[2]=t[2],o|=n&q?0:D);var m=t[3];if(m){var y=e[3];e[3]=y?oa(y,m,t[4]):m,e[4]=y?an(e[3],_):t[4]}return m=t[5],m&&(y=e[5],e[5]=y?aa(y,m,t[6]):m,e[6]=y?an(e[5],_):t[6]),m=t[7],m&&(e[7]=m),s&V&&(e[8]=e[8]==null?t[8]:tt(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=o,e}function jd(e){var t=[];if(e!=null)for(var n in Ce(e))t.push(n);return t}function Ed(e){return Or.call(e)}function ja(e,t,n){return t=Ke(t===r?e.length-1:t,0),function(){for(var s=arguments,o=-1,c=Ke(s.length-t,0),g=S(c);++o<c;)g[o]=s[t+o];o=-1;for(var m=S(t+1);++o<t;)m[o]=s[o];return m[t]=n(g),mt(e,this,m)}}function Ea(e,t){return t.length<2?e:_n(e,kt(t,0,-1))}function Cd(e,t){for(var n=e.length,s=tt(t.length,n),o=ut(e);s--;){var c=t[s];e[s]=Xt(c,n)?o[c]:r}return e}function yi(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var Ca=Aa(Xo),fr=zc||function(e,t){return Ve.setTimeout(e,t)},bi=Aa(Xu);function ka(e,t,n){var s=t+"";return bi(e,vd(s,kd(pd(s),n)))}function Aa(e){var t=0,n=0;return function(){var s=Kc(),o=xe-(s-n);if(n=s,o>0){if(++t>=R)return arguments[0]}else t=0;return e.apply(r,arguments)}}function rs(e,t){var n=-1,s=e.length,o=s-1;for(t=t===r?s:t;++n<t;){var c=ni(n,o),g=e[c];e[c]=e[n],e[n]=g}return e.length=t,e}var Ia=Sd(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(tn,function(n,s,o,c){t.push(o?c.replace(js,"$1"):s||n)}),t});function Ut(e){if(typeof e=="string"||yt(e))return e;var t=e+"";return t=="0"&&1/e==-Q?"-0":t}function Nn(e){if(e!=null){try{return Lr.call(e)}catch{}try{return e+""}catch{}}return""}function kd(e,t){return Nt(Oe,function(n){var s="_."+n[0];t&n[1]&&!Cr(e,s)&&e.push(s)}),e.sort()}function Ma(e){if(e instanceof pe)return e.clone();var t=new Et(e.__wrapped__,e.__chain__);return t.__actions__=ut(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Ad(e,t,n){(n?ot(e,t,n):t===r)?t=1:t=Ke(ue(t),0);var s=e==null?0:e.length;if(!s||t<1)return[];for(var o=0,c=0,g=S($r(s/t));o<s;)g[c++]=kt(e,o,o+=t);return g}function Id(e){for(var t=-1,n=e==null?0:e.length,s=0,o=[];++t<n;){var c=e[t];c&&(o[s++]=c)}return o}function Md(){var e=arguments.length;if(!e)return[];for(var t=S(e-1),n=arguments[0],s=e;s--;)t[s-1]=arguments[s];return on(oe(n)?ut(n):[n],Qe(t,1))}var Ld=fe(function(e,t){return ze(e)?or(e,Qe(t,1,ze,!0)):[]}),Od=fe(function(e,t){var n=At(t);return ze(n)&&(n=r),ze(e)?or(e,Qe(t,1,ze,!0),ee(n,2)):[]}),Td=fe(function(e,t){var n=At(t);return ze(n)&&(n=r),ze(e)?or(e,Qe(t,1,ze,!0),r,n):[]});function Pd(e,t,n){var s=e==null?0:e.length;return s?(t=n||t===r?1:ue(t),kt(e,t<0?0:t,s)):[]}function Rd(e,t,n){var s=e==null?0:e.length;return s?(t=n||t===r?1:ue(t),t=s-t,kt(e,0,t<0?0:t)):[]}function Dd(e,t){return e&&e.length?Yr(e,ee(t,3),!0,!0):[]}function Wd(e,t){return e&&e.length?Yr(e,ee(t,3),!0):[]}function $d(e,t,n,s){var o=e==null?0:e.length;return o?(n&&typeof n!="number"&&ot(e,t,n)&&(n=0,s=o),Mu(e,t,n,s)):[]}function La(e,t,n){var s=e==null?0:e.length;if(!s)return-1;var o=n==null?0:ue(n);return o<0&&(o=Ke(s+o,0)),kr(e,ee(t,3),o)}function Oa(e,t,n){var s=e==null?0:e.length;if(!s)return-1;var o=s-1;return n!==r&&(o=ue(n),o=n<0?Ke(s+o,0):tt(o,s-1)),kr(e,ee(t,3),o,!0)}function Ta(e){var t=e==null?0:e.length;return t?Qe(e,1):[]}function Bd(e){var t=e==null?0:e.length;return t?Qe(e,Q):[]}function Fd(e,t){var n=e==null?0:e.length;return n?(t=t===r?1:ue(t),Qe(e,t)):[]}function zd(e){for(var t=-1,n=e==null?0:e.length,s={};++t<n;){var o=e[t];s[o[0]]=o[1]}return s}function Pa(e){return e&&e.length?e[0]:r}function Ud(e,t,n){var s=e==null?0:e.length;if(!s)return-1;var o=n==null?0:ue(n);return o<0&&(o=Ke(s+o,0)),Mn(e,t,o)}function Gd(e){var t=e==null?0:e.length;return t?kt(e,0,-1):[]}var Hd=fe(function(e){var t=Re(e,ai);return t.length&&t[0]===e[0]?Zs(t):[]}),Kd=fe(function(e){var t=At(e),n=Re(e,ai);return t===At(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Zs(n,ee(t,2)):[]}),qd=fe(function(e){var t=At(e),n=Re(e,ai);return t=typeof t=="function"?t:r,t&&n.pop(),n.length&&n[0]===e[0]?Zs(n,r,t):[]});function Jd(e,t){return e==null?"":Gc.call(e,t)}function At(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Yd(e,t,n){var s=e==null?0:e.length;if(!s)return-1;var o=s;return n!==r&&(o=ue(n),o=o<0?Ke(s+o,0):tt(o,s-1)),t===t?kc(e,t,o):kr(e,po,o,!0)}function Xd(e,t){return e&&e.length?Ko(e,ue(t)):r}var Zd=fe(Ra);function Ra(e,t){return e&&e.length&&t&&t.length?ti(e,t):e}function Vd(e,t,n){return e&&e.length&&t&&t.length?ti(e,t,ee(n,2)):e}function Qd(e,t,n){return e&&e.length&&t&&t.length?ti(e,t,r,n):e}var ef=Yt(function(e,t){var n=e==null?0:e.length,s=qs(e,t);return Yo(e,Re(t,function(o){return Xt(o,n)?+o:o}).sort(ia)),s});function tf(e,t){var n=[];if(!(e&&e.length))return n;var s=-1,o=[],c=e.length;for(t=ee(t,3);++s<c;){var g=e[s];t(g,s,e)&&(n.push(g),o.push(s))}return Yo(e,o),n}function wi(e){return e==null?e:Jc.call(e)}function nf(e,t,n){var s=e==null?0:e.length;return s?(n&&typeof n!="number"&&ot(e,t,n)?(t=0,n=s):(t=t==null?0:ue(t),n=n===r?s:ue(n)),kt(e,t,n)):[]}function rf(e,t){return Jr(e,t)}function sf(e,t,n){return si(e,t,ee(n,2))}function of(e,t){var n=e==null?0:e.length;if(n){var s=Jr(e,t);if(s<n&&Dt(e[s],t))return s}return-1}function af(e,t){return Jr(e,t,!0)}function lf(e,t,n){return si(e,t,ee(n,2),!0)}function cf(e,t){var n=e==null?0:e.length;if(n){var s=Jr(e,t,!0)-1;if(Dt(e[s],t))return s}return-1}function uf(e){return e&&e.length?Zo(e):[]}function df(e,t){return e&&e.length?Zo(e,ee(t,2)):[]}function ff(e){var t=e==null?0:e.length;return t?kt(e,1,t):[]}function hf(e,t,n){return e&&e.length?(t=n||t===r?1:ue(t),kt(e,0,t<0?0:t)):[]}function gf(e,t,n){var s=e==null?0:e.length;return s?(t=n||t===r?1:ue(t),t=s-t,kt(e,t<0?0:t,s)):[]}function pf(e,t){return e&&e.length?Yr(e,ee(t,3),!1,!0):[]}function mf(e,t){return e&&e.length?Yr(e,ee(t,3)):[]}var xf=fe(function(e){return un(Qe(e,1,ze,!0))}),vf=fe(function(e){var t=At(e);return ze(t)&&(t=r),un(Qe(e,1,ze,!0),ee(t,2))}),yf=fe(function(e){var t=At(e);return t=typeof t=="function"?t:r,un(Qe(e,1,ze,!0),r,t)});function bf(e){return e&&e.length?un(e):[]}function wf(e,t){return e&&e.length?un(e,ee(t,2)):[]}function _f(e,t){return t=typeof t=="function"?t:r,e&&e.length?un(e,r,t):[]}function _i(e){if(!(e&&e.length))return[];var t=0;return e=sn(e,function(n){if(ze(n))return t=Ke(n.length,t),!0}),$s(t,function(n){return Re(e,Rs(n))})}function Da(e,t){if(!(e&&e.length))return[];var n=_i(e);return t==null?n:Re(n,function(s){return mt(t,r,s)})}var Sf=fe(function(e,t){return ze(e)?or(e,t):[]}),Nf=fe(function(e){return oi(sn(e,ze))}),jf=fe(function(e){var t=At(e);return ze(t)&&(t=r),oi(sn(e,ze),ee(t,2))}),Ef=fe(function(e){var t=At(e);return t=typeof t=="function"?t:r,oi(sn(e,ze),r,t)}),Cf=fe(_i);function kf(e,t){return ta(e||[],t||[],ir)}function Af(e,t){return ta(e||[],t||[],cr)}var If=fe(function(e){var t=e.length,n=t>1?e[t-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Da(e,n)});function Wa(e){var t=a(e);return t.__chain__=!0,t}function Mf(e,t){return t(e),e}function ss(e,t){return t(e)}var Lf=Yt(function(e){var t=e.length,n=t?e[0]:0,s=this.__wrapped__,o=function(c){return qs(c,e)};return t>1||this.__actions__.length||!(s instanceof pe)||!Xt(n)?this.thru(o):(s=s.slice(n,+n+(t?1:0)),s.__actions__.push({func:ss,args:[o],thisArg:r}),new Et(s,this.__chain__).thru(function(c){return t&&!c.length&&c.push(r),c}))});function Of(){return Wa(this)}function Tf(){return new Et(this.value(),this.__chain__)}function Pf(){this.__values__===r&&(this.__values__=Va(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function Rf(){return this}function Df(e){for(var t,n=this;n instanceof Ur;){var s=Ma(n);s.__index__=0,s.__values__=r,t?o.__wrapped__=s:t=s;var o=s;n=n.__wrapped__}return o.__wrapped__=e,t}function Wf(){var e=this.__wrapped__;if(e instanceof pe){var t=e;return this.__actions__.length&&(t=new pe(this)),t=t.reverse(),t.__actions__.push({func:ss,args:[wi],thisArg:r}),new Et(t,this.__chain__)}return this.thru(wi)}function $f(){return ea(this.__wrapped__,this.__actions__)}var Bf=Xr(function(e,t,n){Ne.call(e,n)?++e[n]:qt(e,n,1)});function Ff(e,t,n){var s=oe(e)?ho:Iu;return n&&ot(e,t,n)&&(t=r),s(e,ee(t,3))}function zf(e,t){var n=oe(e)?sn:Do;return n(e,ee(t,3))}var Uf=da(La),Gf=da(Oa);function Hf(e,t){return Qe(is(e,t),1)}function Kf(e,t){return Qe(is(e,t),Q)}function qf(e,t,n){return n=n===r?1:ue(n),Qe(is(e,t),n)}function $a(e,t){var n=oe(e)?Nt:cn;return n(e,ee(t,3))}function Ba(e,t){var n=oe(e)?dc:Ro;return n(e,ee(t,3))}var Jf=Xr(function(e,t,n){Ne.call(e,n)?e[n].push(t):qt(e,n,[t])});function Yf(e,t,n,s){e=dt(e)?e:Un(e),n=n&&!s?ue(n):0;var o=e.length;return n<0&&(n=Ke(o+n,0)),us(e)?n<=o&&e.indexOf(t,n)>-1:!!o&&Mn(e,t,n)>-1}var Xf=fe(function(e,t,n){var s=-1,o=typeof t=="function",c=dt(e)?S(e.length):[];return cn(e,function(g){c[++s]=o?mt(t,g,n):ar(g,t,n)}),c}),Zf=Xr(function(e,t,n){qt(e,n,t)});function is(e,t){var n=oe(e)?Re:Uo;return n(e,ee(t,3))}function Vf(e,t,n,s){return e==null?[]:(oe(t)||(t=t==null?[]:[t]),n=s?r:n,oe(n)||(n=n==null?[]:[n]),qo(e,t,n))}var Qf=Xr(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function eh(e,t,n){var s=oe(e)?Ts:xo,o=arguments.length<3;return s(e,ee(t,4),n,o,cn)}function th(e,t,n){var s=oe(e)?fc:xo,o=arguments.length<3;return s(e,ee(t,4),n,o,Ro)}function nh(e,t){var n=oe(e)?sn:Do;return n(e,ls(ee(t,3)))}function rh(e){var t=oe(e)?Lo:Ju;return t(e)}function sh(e,t,n){(n?ot(e,t,n):t===r)?t=1:t=ue(t);var s=oe(e)?ju:Yu;return s(e,t)}function ih(e){var t=oe(e)?Eu:Zu;return t(e)}function oh(e){if(e==null)return 0;if(dt(e))return us(e)?On(e):e.length;var t=nt(e);return t==Xe||t==Ze?e.size:Qs(e).length}function ah(e,t,n){var s=oe(e)?Ps:Vu;return n&&ot(e,t,n)&&(t=r),s(e,ee(t,3))}var lh=fe(function(e,t){if(e==null)return[];var n=t.length;return n>1&&ot(e,t[0],t[1])?t=[]:n>2&&ot(t[0],t[1],t[2])&&(t=[t[0]]),qo(e,Qe(t,1),[])}),os=Fc||function(){return Ve.Date.now()};function ch(e,t){if(typeof t!="function")throw new jt(p);return e=ue(e),function(){if(--e<1)return t.apply(this,arguments)}}function Fa(e,t,n){return t=n?r:t,t=e&&t==null?e.length:t,Jt(e,V,r,r,r,r,t)}function za(e,t){var n;if(typeof t!="function")throw new jt(p);return e=ue(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=r),n}}var Si=fe(function(e,t,n){var s=q;if(n.length){var o=an(n,Fn(Si));s|=M}return Jt(e,s,t,n,o)}),Ua=fe(function(e,t,n){var s=q|F;if(n.length){var o=an(n,Fn(Ua));s|=M}return Jt(t,s,e,n,o)});function Ga(e,t,n){t=n?r:t;var s=Jt(e,B,r,r,r,r,r,t);return s.placeholder=Ga.placeholder,s}function Ha(e,t,n){t=n?r:t;var s=Jt(e,C,r,r,r,r,r,t);return s.placeholder=Ha.placeholder,s}function Ka(e,t,n){var s,o,c,g,m,y,k=0,A=!1,L=!1,$=!0;if(typeof e!="function")throw new jt(p);t=It(t)||0,De(n)&&(A=!!n.leading,L="maxWait"in n,c=L?Ke(It(n.maxWait)||0,t):c,$="trailing"in n?!!n.trailing:$);function X(Ue){var Wt=s,Qt=o;return s=o=r,k=Ue,g=e.apply(Qt,Wt),g}function te(Ue){return k=Ue,m=fr(he,t),A?X(Ue):g}function de(Ue){var Wt=Ue-y,Qt=Ue-k,dl=t-Wt;return L?tt(dl,c-Qt):dl}function ne(Ue){var Wt=Ue-y,Qt=Ue-k;return y===r||Wt>=t||Wt<0||L&&Qt>=c}function he(){var Ue=os();if(ne(Ue))return me(Ue);m=fr(he,de(Ue))}function me(Ue){return m=r,$&&s?X(Ue):(s=o=r,g)}function bt(){m!==r&&na(m),k=0,s=y=o=m=r}function at(){return m===r?g:me(os())}function wt(){var Ue=os(),Wt=ne(Ue);if(s=arguments,o=this,y=Ue,Wt){if(m===r)return te(y);if(L)return na(m),m=fr(he,t),X(y)}return m===r&&(m=fr(he,t)),g}return wt.cancel=bt,wt.flush=at,wt}var uh=fe(function(e,t){return Po(e,1,t)}),dh=fe(function(e,t,n){return Po(e,It(t)||0,n)});function fh(e){return Jt(e,U)}function as(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new jt(p);var n=function(){var s=arguments,o=t?t.apply(this,s):s[0],c=n.cache;if(c.has(o))return c.get(o);var g=e.apply(this,s);return n.cache=c.set(o,g)||c,g};return n.cache=new(as.Cache||Kt),n}as.Cache=Kt;function ls(e){if(typeof e!="function")throw new jt(p);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function hh(e){return za(2,e)}var gh=Qu(function(e,t){t=t.length==1&&oe(t[0])?Re(t[0],xt(ee())):Re(Qe(t,1),xt(ee()));var n=t.length;return fe(function(s){for(var o=-1,c=tt(s.length,n);++o<c;)s[o]=t[o].call(this,s[o]);return mt(e,this,s)})}),Ni=fe(function(e,t){var n=an(t,Fn(Ni));return Jt(e,M,r,t,n)}),qa=fe(function(e,t){var n=an(t,Fn(qa));return Jt(e,z,r,t,n)}),ph=Yt(function(e,t){return Jt(e,je,r,r,r,t)});function mh(e,t){if(typeof e!="function")throw new jt(p);return t=t===r?t:ue(t),fe(e,t)}function xh(e,t){if(typeof e!="function")throw new jt(p);return t=t==null?0:Ke(ue(t),0),fe(function(n){var s=n[t],o=fn(n,0,t);return s&&on(o,s),mt(e,this,o)})}function vh(e,t,n){var s=!0,o=!0;if(typeof e!="function")throw new jt(p);return De(n)&&(s="leading"in n?!!n.leading:s,o="trailing"in n?!!n.trailing:o),Ka(e,t,{leading:s,maxWait:t,trailing:o})}function yh(e){return Fa(e,1)}function bh(e,t){return Ni(li(t),e)}function wh(){if(!arguments.length)return[];var e=arguments[0];return oe(e)?e:[e]}function _h(e){return Ct(e,P)}function Sh(e,t){return t=typeof t=="function"?t:r,Ct(e,P,t)}function Nh(e){return Ct(e,b|P)}function jh(e,t){return t=typeof t=="function"?t:r,Ct(e,b|P,t)}function Eh(e,t){return t==null||To(e,t,Ye(t))}function Dt(e,t){return e===t||e!==e&&t!==t}var Ch=es(Xs),kh=es(function(e,t){return e>=t}),jn=Bo(function(){return arguments}())?Bo:function(e){return $e(e)&&Ne.call(e,"callee")&&!Eo.call(e,"callee")},oe=S.isArray,Ah=oo?xt(oo):Ru;function dt(e){return e!=null&&cs(e.length)&&!Zt(e)}function ze(e){return $e(e)&&dt(e)}function Ih(e){return e===!0||e===!1||$e(e)&&it(e)==gt}var hn=Uc||Pi,Mh=ao?xt(ao):Du;function Lh(e){return $e(e)&&e.nodeType===1&&!hr(e)}function Oh(e){if(e==null)return!0;if(dt(e)&&(oe(e)||typeof e=="string"||typeof e.splice=="function"||hn(e)||zn(e)||jn(e)))return!e.length;var t=nt(e);if(t==Xe||t==Ze)return!e.size;if(dr(e))return!Qs(e).length;for(var n in e)if(Ne.call(e,n))return!1;return!0}function Th(e,t){return lr(e,t)}function Ph(e,t,n){n=typeof n=="function"?n:r;var s=n?n(e,t):r;return s===r?lr(e,t,r,n):!!s}function ji(e){if(!$e(e))return!1;var t=it(e);return t==pt||t==Ge||typeof e.message=="string"&&typeof e.name=="string"&&!hr(e)}function Rh(e){return typeof e=="number"&&ko(e)}function Zt(e){if(!De(e))return!1;var t=it(e);return t==Mt||t==Bt||t==rt||t==kn}function Ja(e){return typeof e=="number"&&e==ue(e)}function cs(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=K}function De(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function $e(e){return e!=null&&typeof e=="object"}var Ya=lo?xt(lo):$u;function Dh(e,t){return e===t||Vs(e,t,pi(t))}function Wh(e,t,n){return n=typeof n=="function"?n:r,Vs(e,t,pi(t),n)}function $h(e){return Xa(e)&&e!=+e}function Bh(e){if(_d(e))throw new ie(h);return Fo(e)}function Fh(e){return e===null}function zh(e){return e==null}function Xa(e){return typeof e=="number"||$e(e)&&it(e)==st}function hr(e){if(!$e(e)||it(e)!=ct)return!1;var t=Rr(e);if(t===null)return!0;var n=Ne.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Lr.call(n)==Dc}var Ei=co?xt(co):Bu;function Uh(e){return Ja(e)&&e>=-K&&e<=K}var Za=uo?xt(uo):Fu;function us(e){return typeof e=="string"||!oe(e)&&$e(e)&&it(e)==Lt}function yt(e){return typeof e=="symbol"||$e(e)&&it(e)==Ot}var zn=fo?xt(fo):zu;function Gh(e){return e===r}function Hh(e){return $e(e)&&nt(e)==re}function Kh(e){return $e(e)&&it(e)==we}var qh=es(ei),Jh=es(function(e,t){return e<=t});function Va(e){if(!e)return[];if(dt(e))return us(e)?Pt(e):ut(e);if(er&&e[er])return jc(e[er]());var t=nt(e),n=t==Xe?Fs:t==Ze?Ar:Un;return n(e)}function Vt(e){if(!e)return e===0?e:0;if(e=It(e),e===Q||e===-Q){var t=e<0?-1:1;return t*ce}return e===e?e:0}function ue(e){var t=Vt(e),n=t%1;return t===t?n?t-n:t:0}function Qa(e){return e?wn(ue(e),0,Z):0}function It(e){if(typeof e=="number")return e;if(yt(e))return J;if(De(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=De(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=vo(e);var n=W.test(e);return n||et.test(e)?lc(e.slice(2),n?2:8):T.test(e)?J:+e}function el(e){return zt(e,ft(e))}function Yh(e){return e?wn(ue(e),-K,K):e===0?e:0}function Se(e){return e==null?"":vt(e)}var Xh=$n(function(e,t){if(dr(t)||dt(t)){zt(t,Ye(t),e);return}for(var n in t)Ne.call(t,n)&&ir(e,n,t[n])}),tl=$n(function(e,t){zt(t,ft(t),e)}),ds=$n(function(e,t,n,s){zt(t,ft(t),e,s)}),Zh=$n(function(e,t,n,s){zt(t,Ye(t),e,s)}),Vh=Yt(qs);function Qh(e,t){var n=Wn(e);return t==null?n:Oo(n,t)}var e0=fe(function(e,t){e=Ce(e);var n=-1,s=t.length,o=s>2?t[2]:r;for(o&&ot(t[0],t[1],o)&&(s=1);++n<s;)for(var c=t[n],g=ft(c),m=-1,y=g.length;++m<y;){var k=g[m],A=e[k];(A===r||Dt(A,Pn[k])&&!Ne.call(e,k))&&(e[k]=c[k])}return e}),t0=fe(function(e){return e.push(r,va),mt(nl,r,e)});function n0(e,t){return go(e,ee(t,3),Ft)}function r0(e,t){return go(e,ee(t,3),Ys)}function s0(e,t){return e==null?e:Js(e,ee(t,3),ft)}function i0(e,t){return e==null?e:Wo(e,ee(t,3),ft)}function o0(e,t){return e&&Ft(e,ee(t,3))}function a0(e,t){return e&&Ys(e,ee(t,3))}function l0(e){return e==null?[]:Kr(e,Ye(e))}function c0(e){return e==null?[]:Kr(e,ft(e))}function Ci(e,t,n){var s=e==null?r:_n(e,t);return s===r?n:s}function u0(e,t){return e!=null&&wa(e,t,Lu)}function ki(e,t){return e!=null&&wa(e,t,Ou)}var d0=ha(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Or.call(t)),e[t]=n},Ii(ht)),f0=ha(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=Or.call(t)),Ne.call(e,t)?e[t].push(n):e[t]=[n]},ee),h0=fe(ar);function Ye(e){return dt(e)?Mo(e):Qs(e)}function ft(e){return dt(e)?Mo(e,!0):Uu(e)}function g0(e,t){var n={};return t=ee(t,3),Ft(e,function(s,o,c){qt(n,t(s,o,c),s)}),n}function p0(e,t){var n={};return t=ee(t,3),Ft(e,function(s,o,c){qt(n,o,t(s,o,c))}),n}var m0=$n(function(e,t,n){qr(e,t,n)}),nl=$n(function(e,t,n,s){qr(e,t,n,s)}),x0=Yt(function(e,t){var n={};if(e==null)return n;var s=!1;t=Re(t,function(c){return c=dn(c,e),s||(s=c.length>1),c}),zt(e,hi(e),n),s&&(n=Ct(n,b|I|P,ud));for(var o=t.length;o--;)ii(n,t[o]);return n});function v0(e,t){return rl(e,ls(ee(t)))}var y0=Yt(function(e,t){return e==null?{}:Hu(e,t)});function rl(e,t){if(e==null)return{};var n=Re(hi(e),function(s){return[s]});return t=ee(t),Jo(e,n,function(s,o){return t(s,o[0])})}function b0(e,t,n){t=dn(t,e);var s=-1,o=t.length;for(o||(o=1,e=r);++s<o;){var c=e==null?r:e[Ut(t[s])];c===r&&(s=o,c=n),e=Zt(c)?c.call(e):c}return e}function w0(e,t,n){return e==null?e:cr(e,t,n)}function _0(e,t,n,s){return s=typeof s=="function"?s:r,e==null?e:cr(e,t,n,s)}var sl=ma(Ye),il=ma(ft);function S0(e,t,n){var s=oe(e),o=s||hn(e)||zn(e);if(t=ee(t,4),n==null){var c=e&&e.constructor;o?n=s?new c:[]:De(e)?n=Zt(c)?Wn(Rr(e)):{}:n={}}return(o?Nt:Ft)(e,function(g,m,y){return t(n,g,m,y)}),n}function N0(e,t){return e==null?!0:ii(e,t)}function j0(e,t,n){return e==null?e:Qo(e,t,li(n))}function E0(e,t,n,s){return s=typeof s=="function"?s:r,e==null?e:Qo(e,t,li(n),s)}function Un(e){return e==null?[]:Bs(e,Ye(e))}function C0(e){return e==null?[]:Bs(e,ft(e))}function k0(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=It(n),n=n===n?n:0),t!==r&&(t=It(t),t=t===t?t:0),wn(It(e),t,n)}function A0(e,t,n){return t=Vt(t),n===r?(n=t,t=0):n=Vt(n),e=It(e),Tu(e,t,n)}function I0(e,t,n){if(n&&typeof n!="boolean"&&ot(e,t,n)&&(t=n=r),n===r&&(typeof t=="boolean"?(n=t,t=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=Vt(e),t===r?(t=e,e=0):t=Vt(t)),e>t){var s=e;e=t,t=s}if(n||e%1||t%1){var o=Ao();return tt(e+o*(t-e+ac("1e-"+((o+"").length-1))),t)}return ni(e,t)}var M0=Bn(function(e,t,n){return t=t.toLowerCase(),e+(n?ol(t):t)});function ol(e){return Ai(Se(e).toLowerCase())}function al(e){return e=Se(e),e&&e.replace(Ll,bc).replace(Zl,"")}function L0(e,t,n){e=Se(e),t=vt(t);var s=e.length;n=n===r?s:wn(ue(n),0,s);var o=n;return n-=t.length,n>=0&&e.slice(n,o)==t}function O0(e){return e=Se(e),e&&ys.test(e)?e.replace(Yn,wc):e}function T0(e){return e=Se(e),e&&Ss.test(e)?e.replace(Xn,"\\$&"):e}var P0=Bn(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),R0=Bn(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),D0=ua("toLowerCase");function W0(e,t,n){e=Se(e),t=ue(t);var s=t?On(e):0;if(!t||s>=t)return e;var o=(t-s)/2;return Qr(Br(o),n)+e+Qr($r(o),n)}function $0(e,t,n){e=Se(e),t=ue(t);var s=t?On(e):0;return t&&s<t?e+Qr(t-s,n):e}function B0(e,t,n){e=Se(e),t=ue(t);var s=t?On(e):0;return t&&s<t?Qr(t-s,n)+e:e}function F0(e,t,n){return n||t==null?t=0:t&&(t=+t),qc(Se(e).replace(Zn,""),t||0)}function z0(e,t,n){return(n?ot(e,t,n):t===r)?t=1:t=ue(t),ri(Se(e),t)}function U0(){var e=arguments,t=Se(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var G0=Bn(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function H0(e,t,n){return n&&typeof n!="number"&&ot(e,t,n)&&(t=n=r),n=n===r?Z:n>>>0,n?(e=Se(e),e&&(typeof t=="string"||t!=null&&!Ei(t))&&(t=vt(t),!t&&Ln(e))?fn(Pt(e),0,n):e.split(t,n)):[]}var K0=Bn(function(e,t,n){return e+(n?" ":"")+Ai(t)});function q0(e,t,n){return e=Se(e),n=n==null?0:wn(ue(n),0,e.length),t=vt(t),e.slice(n,n+t.length)==t}function J0(e,t,n){var s=a.templateSettings;n&&ot(e,t,n)&&(t=r),e=Se(e),t=ds({},t,s,xa);var o=ds({},t.imports,s.imports,xa),c=Ye(o),g=Bs(o,c),m,y,k=0,A=t.interpolate||Nr,L="__p += '",$=zs((t.escape||Nr).source+"|"+A.source+"|"+(A===An?nn:Nr).source+"|"+(t.evaluate||Nr).source+"|$","g"),X="//# sourceURL="+(Ne.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++nc+"]")+`
`;e.replace($,function(ne,he,me,bt,at,wt){return me||(me=bt),L+=e.slice(k,wt).replace(Ol,_c),he&&(m=!0,L+=`' +
__e(`+he+`) +
'`),at&&(y=!0,L+=`';
`+at+`;
__p += '`),me&&(L+=`' +
((__t = (`+me+`)) == null ? '' : __t) +
'`),k=wt+ne.length,ne}),L+=`';
`;var te=Ne.call(t,"variable")&&t.variable;if(!te)L=`with (obj) {
`+L+`
}
`;else if(pn.test(te))throw new ie(x);L=(y?L.replace(ps,""):L).replace(ms,"$1").replace(xs,"$1;"),L="function("+(te||"obj")+`) {
`+(te?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(m?", __e = _.escape":"")+(y?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+L+`return __p
}`;var de=cl(function(){return be(c,X+"return "+L).apply(r,g)});if(de.source=L,ji(de))throw de;return de}function Y0(e){return Se(e).toLowerCase()}function X0(e){return Se(e).toUpperCase()}function Z0(e,t,n){if(e=Se(e),e&&(n||t===r))return vo(e);if(!e||!(t=vt(t)))return e;var s=Pt(e),o=Pt(t),c=yo(s,o),g=bo(s,o)+1;return fn(s,c,g).join("")}function V0(e,t,n){if(e=Se(e),e&&(n||t===r))return e.slice(0,_o(e)+1);if(!e||!(t=vt(t)))return e;var s=Pt(e),o=bo(s,Pt(t))+1;return fn(s,0,o).join("")}function Q0(e,t,n){if(e=Se(e),e&&(n||t===r))return e.replace(Zn,"");if(!e||!(t=vt(t)))return e;var s=Pt(e),o=yo(s,Pt(t));return fn(s,o).join("")}function eg(e,t){var n=ae,s=ge;if(De(t)){var o="separator"in t?t.separator:o;n="length"in t?ue(t.length):n,s="omission"in t?vt(t.omission):s}e=Se(e);var c=e.length;if(Ln(e)){var g=Pt(e);c=g.length}if(n>=c)return e;var m=n-On(s);if(m<1)return s;var y=g?fn(g,0,m).join(""):e.slice(0,m);if(o===r)return y+s;if(g&&(m+=y.length-m),Ei(o)){if(e.slice(m).search(o)){var k,A=y;for(o.global||(o=zs(o.source,Se(mn.exec(o))+"g")),o.lastIndex=0;k=o.exec(A);)var L=k.index;y=y.slice(0,L===r?m:L)}}else if(e.indexOf(vt(o),m)!=m){var $=y.lastIndexOf(o);$>-1&&(y=y.slice(0,$))}return y+s}function tg(e){return e=Se(e),e&&vs.test(e)?e.replace(yr,Ac):e}var ng=Bn(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ai=ua("toUpperCase");function ll(e,t,n){return e=Se(e),t=n?r:t,t===r?Nc(e)?Lc(e):pc(e):e.match(t)||[]}var cl=fe(function(e,t){try{return mt(e,r,t)}catch(n){return ji(n)?n:new ie(n)}}),rg=Yt(function(e,t){return Nt(t,function(n){n=Ut(n),qt(e,n,Si(e[n],e))}),e});function sg(e){var t=e==null?0:e.length,n=ee();return e=t?Re(e,function(s){if(typeof s[1]!="function")throw new jt(p);return[n(s[0]),s[1]]}):[],fe(function(s){for(var o=-1;++o<t;){var c=e[o];if(mt(c[0],this,s))return mt(c[1],this,s)}})}function ig(e){return Au(Ct(e,b))}function Ii(e){return function(){return e}}function og(e,t){return e==null||e!==e?t:e}var ag=fa(),lg=fa(!0);function ht(e){return e}function Mi(e){return zo(typeof e=="function"?e:Ct(e,b))}function cg(e){return Go(Ct(e,b))}function ug(e,t){return Ho(e,Ct(t,b))}var dg=fe(function(e,t){return function(n){return ar(n,e,t)}}),fg=fe(function(e,t){return function(n){return ar(e,n,t)}});function Li(e,t,n){var s=Ye(t),o=Kr(t,s);n==null&&!(De(t)&&(o.length||!s.length))&&(n=t,t=e,e=this,o=Kr(t,Ye(t)));var c=!(De(n)&&"chain"in n)||!!n.chain,g=Zt(e);return Nt(o,function(m){var y=t[m];e[m]=y,g&&(e.prototype[m]=function(){var k=this.__chain__;if(c||k){var A=e(this.__wrapped__),L=A.__actions__=ut(this.__actions__);return L.push({func:y,args:arguments,thisArg:e}),A.__chain__=k,A}return y.apply(e,on([this.value()],arguments))})}),e}function hg(){return Ve._===this&&(Ve._=Wc),this}function Oi(){}function gg(e){return e=ue(e),fe(function(t){return Ko(t,e)})}var pg=ui(Re),mg=ui(ho),xg=ui(Ps);function ul(e){return xi(e)?Rs(Ut(e)):Ku(e)}function vg(e){return function(t){return e==null?r:_n(e,t)}}var yg=ga(),bg=ga(!0);function Ti(){return[]}function Pi(){return!1}function wg(){return{}}function _g(){return""}function Sg(){return!0}function Ng(e,t){if(e=ue(e),e<1||e>K)return[];var n=Z,s=tt(e,Z);t=ee(t),e-=Z;for(var o=$s(s,t);++n<e;)t(n);return o}function jg(e){return oe(e)?Re(e,Ut):yt(e)?[e]:ut(Ia(Se(e)))}function Eg(e){var t=++Rc;return Se(e)+t}var Cg=Vr(function(e,t){return e+t},0),kg=di("ceil"),Ag=Vr(function(e,t){return e/t},1),Ig=di("floor");function Mg(e){return e&&e.length?Hr(e,ht,Xs):r}function Lg(e,t){return e&&e.length?Hr(e,ee(t,2),Xs):r}function Og(e){return mo(e,ht)}function Tg(e,t){return mo(e,ee(t,2))}function Pg(e){return e&&e.length?Hr(e,ht,ei):r}function Rg(e,t){return e&&e.length?Hr(e,ee(t,2),ei):r}var Dg=Vr(function(e,t){return e*t},1),Wg=di("round"),$g=Vr(function(e,t){return e-t},0);function Bg(e){return e&&e.length?Ws(e,ht):0}function Fg(e,t){return e&&e.length?Ws(e,ee(t,2)):0}return a.after=ch,a.ary=Fa,a.assign=Xh,a.assignIn=tl,a.assignInWith=ds,a.assignWith=Zh,a.at=Vh,a.before=za,a.bind=Si,a.bindAll=rg,a.bindKey=Ua,a.castArray=wh,a.chain=Wa,a.chunk=Ad,a.compact=Id,a.concat=Md,a.cond=sg,a.conforms=ig,a.constant=Ii,a.countBy=Bf,a.create=Qh,a.curry=Ga,a.curryRight=Ha,a.debounce=Ka,a.defaults=e0,a.defaultsDeep=t0,a.defer=uh,a.delay=dh,a.difference=Ld,a.differenceBy=Od,a.differenceWith=Td,a.drop=Pd,a.dropRight=Rd,a.dropRightWhile=Dd,a.dropWhile=Wd,a.fill=$d,a.filter=zf,a.flatMap=Hf,a.flatMapDeep=Kf,a.flatMapDepth=qf,a.flatten=Ta,a.flattenDeep=Bd,a.flattenDepth=Fd,a.flip=fh,a.flow=ag,a.flowRight=lg,a.fromPairs=zd,a.functions=l0,a.functionsIn=c0,a.groupBy=Jf,a.initial=Gd,a.intersection=Hd,a.intersectionBy=Kd,a.intersectionWith=qd,a.invert=d0,a.invertBy=f0,a.invokeMap=Xf,a.iteratee=Mi,a.keyBy=Zf,a.keys=Ye,a.keysIn=ft,a.map=is,a.mapKeys=g0,a.mapValues=p0,a.matches=cg,a.matchesProperty=ug,a.memoize=as,a.merge=m0,a.mergeWith=nl,a.method=dg,a.methodOf=fg,a.mixin=Li,a.negate=ls,a.nthArg=gg,a.omit=x0,a.omitBy=v0,a.once=hh,a.orderBy=Vf,a.over=pg,a.overArgs=gh,a.overEvery=mg,a.overSome=xg,a.partial=Ni,a.partialRight=qa,a.partition=Qf,a.pick=y0,a.pickBy=rl,a.property=ul,a.propertyOf=vg,a.pull=Zd,a.pullAll=Ra,a.pullAllBy=Vd,a.pullAllWith=Qd,a.pullAt=ef,a.range=yg,a.rangeRight=bg,a.rearg=ph,a.reject=nh,a.remove=tf,a.rest=mh,a.reverse=wi,a.sampleSize=sh,a.set=w0,a.setWith=_0,a.shuffle=ih,a.slice=nf,a.sortBy=lh,a.sortedUniq=uf,a.sortedUniqBy=df,a.split=H0,a.spread=xh,a.tail=ff,a.take=hf,a.takeRight=gf,a.takeRightWhile=pf,a.takeWhile=mf,a.tap=Mf,a.throttle=vh,a.thru=ss,a.toArray=Va,a.toPairs=sl,a.toPairsIn=il,a.toPath=jg,a.toPlainObject=el,a.transform=S0,a.unary=yh,a.union=xf,a.unionBy=vf,a.unionWith=yf,a.uniq=bf,a.uniqBy=wf,a.uniqWith=_f,a.unset=N0,a.unzip=_i,a.unzipWith=Da,a.update=j0,a.updateWith=E0,a.values=Un,a.valuesIn=C0,a.without=Sf,a.words=ll,a.wrap=bh,a.xor=Nf,a.xorBy=jf,a.xorWith=Ef,a.zip=Cf,a.zipObject=kf,a.zipObjectDeep=Af,a.zipWith=If,a.entries=sl,a.entriesIn=il,a.extend=tl,a.extendWith=ds,Li(a,a),a.add=Cg,a.attempt=cl,a.camelCase=M0,a.capitalize=ol,a.ceil=kg,a.clamp=k0,a.clone=_h,a.cloneDeep=Nh,a.cloneDeepWith=jh,a.cloneWith=Sh,a.conformsTo=Eh,a.deburr=al,a.defaultTo=og,a.divide=Ag,a.endsWith=L0,a.eq=Dt,a.escape=O0,a.escapeRegExp=T0,a.every=Ff,a.find=Uf,a.findIndex=La,a.findKey=n0,a.findLast=Gf,a.findLastIndex=Oa,a.findLastKey=r0,a.floor=Ig,a.forEach=$a,a.forEachRight=Ba,a.forIn=s0,a.forInRight=i0,a.forOwn=o0,a.forOwnRight=a0,a.get=Ci,a.gt=Ch,a.gte=kh,a.has=u0,a.hasIn=ki,a.head=Pa,a.identity=ht,a.includes=Yf,a.indexOf=Ud,a.inRange=A0,a.invoke=h0,a.isArguments=jn,a.isArray=oe,a.isArrayBuffer=Ah,a.isArrayLike=dt,a.isArrayLikeObject=ze,a.isBoolean=Ih,a.isBuffer=hn,a.isDate=Mh,a.isElement=Lh,a.isEmpty=Oh,a.isEqual=Th,a.isEqualWith=Ph,a.isError=ji,a.isFinite=Rh,a.isFunction=Zt,a.isInteger=Ja,a.isLength=cs,a.isMap=Ya,a.isMatch=Dh,a.isMatchWith=Wh,a.isNaN=$h,a.isNative=Bh,a.isNil=zh,a.isNull=Fh,a.isNumber=Xa,a.isObject=De,a.isObjectLike=$e,a.isPlainObject=hr,a.isRegExp=Ei,a.isSafeInteger=Uh,a.isSet=Za,a.isString=us,a.isSymbol=yt,a.isTypedArray=zn,a.isUndefined=Gh,a.isWeakMap=Hh,a.isWeakSet=Kh,a.join=Jd,a.kebabCase=P0,a.last=At,a.lastIndexOf=Yd,a.lowerCase=R0,a.lowerFirst=D0,a.lt=qh,a.lte=Jh,a.max=Mg,a.maxBy=Lg,a.mean=Og,a.meanBy=Tg,a.min=Pg,a.minBy=Rg,a.stubArray=Ti,a.stubFalse=Pi,a.stubObject=wg,a.stubString=_g,a.stubTrue=Sg,a.multiply=Dg,a.nth=Xd,a.noConflict=hg,a.noop=Oi,a.now=os,a.pad=W0,a.padEnd=$0,a.padStart=B0,a.parseInt=F0,a.random=I0,a.reduce=eh,a.reduceRight=th,a.repeat=z0,a.replace=U0,a.result=b0,a.round=Wg,a.runInContext=v,a.sample=rh,a.size=oh,a.snakeCase=G0,a.some=ah,a.sortedIndex=rf,a.sortedIndexBy=sf,a.sortedIndexOf=of,a.sortedLastIndex=af,a.sortedLastIndexBy=lf,a.sortedLastIndexOf=cf,a.startCase=K0,a.startsWith=q0,a.subtract=$g,a.sum=Bg,a.sumBy=Fg,a.template=J0,a.times=Ng,a.toFinite=Vt,a.toInteger=ue,a.toLength=Qa,a.toLower=Y0,a.toNumber=It,a.toSafeInteger=Yh,a.toString=Se,a.toUpper=X0,a.trim=Z0,a.trimEnd=V0,a.trimStart=Q0,a.truncate=eg,a.unescape=tg,a.uniqueId=Eg,a.upperCase=ng,a.upperFirst=Ai,a.each=$a,a.eachRight=Ba,a.first=Pa,Li(a,function(){var e={};return Ft(a,function(t,n){Ne.call(a.prototype,n)||(e[n]=t)}),e}(),{chain:!1}),a.VERSION=f,Nt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){a[e].placeholder=a}),Nt(["drop","take"],function(e,t){pe.prototype[e]=function(n){n=n===r?1:Ke(ue(n),0);var s=this.__filtered__&&!t?new pe(this):this.clone();return s.__filtered__?s.__takeCount__=tt(n,s.__takeCount__):s.__views__.push({size:tt(n,Z),type:e+(s.__dir__<0?"Right":"")}),s},pe.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Nt(["filter","map","takeWhile"],function(e,t){var n=t+1,s=n==le||n==ve;pe.prototype[e]=function(o){var c=this.clone();return c.__iteratees__.push({iteratee:ee(o,3),type:n}),c.__filtered__=c.__filtered__||s,c}}),Nt(["head","last"],function(e,t){var n="take"+(t?"Right":"");pe.prototype[e]=function(){return this[n](1).value()[0]}}),Nt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");pe.prototype[e]=function(){return this.__filtered__?new pe(this):this[n](1)}}),pe.prototype.compact=function(){return this.filter(ht)},pe.prototype.find=function(e){return this.filter(e).head()},pe.prototype.findLast=function(e){return this.reverse().find(e)},pe.prototype.invokeMap=fe(function(e,t){return typeof e=="function"?new pe(this):this.map(function(n){return ar(n,e,t)})}),pe.prototype.reject=function(e){return this.filter(ls(ee(e)))},pe.prototype.slice=function(e,t){e=ue(e);var n=this;return n.__filtered__&&(e>0||t<0)?new pe(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(t=ue(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},pe.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},pe.prototype.toArray=function(){return this.take(Z)},Ft(pe.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),s=/^(?:head|last)$/.test(t),o=a[s?"take"+(t=="last"?"Right":""):t],c=s||/^find/.test(t);o&&(a.prototype[t]=function(){var g=this.__wrapped__,m=s?[1]:arguments,y=g instanceof pe,k=m[0],A=y||oe(g),L=function(he){var me=o.apply(a,on([he],m));return s&&$?me[0]:me};A&&n&&typeof k=="function"&&k.length!=1&&(y=A=!1);var $=this.__chain__,X=!!this.__actions__.length,te=c&&!$,de=y&&!X;if(!c&&A){g=de?g:new pe(this);var ne=e.apply(g,m);return ne.__actions__.push({func:ss,args:[L],thisArg:r}),new Et(ne,$)}return te&&de?e.apply(this,m):(ne=this.thru(L),te?s?ne.value()[0]:ne.value():ne)})}),Nt(["pop","push","shift","sort","splice","unshift"],function(e){var t=Ir[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",s=/^(?:pop|shift)$/.test(e);a.prototype[e]=function(){var o=arguments;if(s&&!this.__chain__){var c=this.value();return t.apply(oe(c)?c:[],o)}return this[n](function(g){return t.apply(oe(g)?g:[],o)})}}),Ft(pe.prototype,function(e,t){var n=a[t];if(n){var s=n.name+"";Ne.call(Dn,s)||(Dn[s]=[]),Dn[s].push({name:t,func:n})}}),Dn[Zr(r,F).name]=[{name:"wrapper",func:r}],pe.prototype.clone=eu,pe.prototype.reverse=tu,pe.prototype.value=nu,a.prototype.at=Lf,a.prototype.chain=Of,a.prototype.commit=Tf,a.prototype.next=Pf,a.prototype.plant=Df,a.prototype.reverse=Wf,a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=$f,a.prototype.first=a.prototype.head,er&&(a.prototype[er]=Rf),a},Tn=Oc();xn?((xn.exports=Tn)._=Tn,Ms._=Tn):Ve._=Tn}).call(gr)})(hs,hs.exports);var Wi=hs.exports;function Op(l=!0){E.useEffect(()=>{if(!l)return;const d=Wi.debounce(r=>{document.documentElement.style.setProperty("--mouse-x",`${r.clientX}px`),document.documentElement.style.setProperty("--mouse-y",`${r.clientY}px`)},16);return document.addEventListener("mousemove",d),()=>{d.cancel(),document.removeEventListener("mousemove",d)}},[l])}function Tp(l=!0){const{state:d,dispatch:r}=En(),{activeTab:f,screenState:u}=d;E.useEffect(()=>{if(!l)return;const h=p=>{const x=f==="parameter-debug",w=f==="chat",N=!u||u.currentScreen===0;if(w||N&&x){const _=We.canvas.selected_nodes;Object.keys(_??{}).length?r({type:"SET_SELECTED_NODE",payload:Object.values(_)}):r({type:"SET_SELECTED_NODE",payload:null})}};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[r,l,f,u])}const Pp=({selectedNodes:l,handleParamSelect:d,selectedParams:r,handleNext:f,handleClose:u})=>{const p=l.flatMap(x=>(x.widgets||[]).map(w=>w.name)).some(x=>r[x]===!0);return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Select parameters"}),i.jsx("p",{className:"text-xs text-gray-500",children:"multiple selections supported"})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:u,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.map((x,w)=>{const N=x.title||"Unknown Node",_=x.widgets||[];return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsx("div",{className:"bg-gray-50 px-3 py-2 text-sm font-medium text-gray-700 border-b",children:N}),i.jsx("div",{className:"p-4 space-y-3",children:i.jsx("div",{className:"flex items-center gap-3 flex-wrap",children:_.map((b,I)=>{const P=b.name;return i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`w-5 h-5 rounded-full border flex items-center justify-center ${r[P]?"border-red-500 bg-red-100":"border-gray-300"}`,onClick:O=>d(P,O),children:r[P]&&i.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"})}),i.jsx("span",{className:"ml-2 text-gray-700 text-xs",children:P})]},`widget-${I}`)})})})]},`node-${w}`)}),i.jsx("div",{className:"mt-6 flex justify-center",children:i.jsx("button",{onClick:x=>f(x),disabled:!p,className:`px-3 py-1.5 text-xs ${p?"bg-pink-200 text-pink-700 hover:bg-pink-300":"bg-gray-200 text-gray-500 cursor-not-allowed"} rounded-md transition-colors`,children:"Next"})})]})},Rp=({selectedNodes:l,paramTestValues:d,selectedParams:r,updateParamTestValues:f,toggleDropdown:u,openDropdowns:h,handleTestValueSelect:p,searchTerms:x,handleSearch:w,handleSelectAll:N,handleNext:_,handlePrevious:b,handleClose:I,inputValues:P,setInputValues:O,textInputs:G,handleTextInputChange:q,handleAddTextInput:F,handleRemoveTextInput:D,openAiWritingModal:B})=>{const C=(M,z,V,je=0)=>{if(M=isNaN(M)?0:M,z=isNaN(z)?100:z,V=isNaN(V)||V<=0?1:V,z<M&&(z=M),Math.floor((z-M)/V)+1<=1)return[M];const ae=[];let ge=M;for(;ge<=z;){const R=Math.pow(10,je),xe=Math.round(ge*R)/R;ae.push(xe),ge+=V}return ae};return E.useEffect(()=>{!l||l.length===0||l.forEach(M=>{const z=M.id.toString(),V=M.widgets||{};Object.values(V).forEach(U=>{const ae=U.name;if(!r[ae])return;if(!(d[z]?.[ae]?.length>0)&&U.type==="number"){const R=U.options?.min||0,xe=U.options?.max||100;let le=(U.options?.step||10)/10;le<.1&&(le=.1);const se=U.options?.precision||0,ve=C(R,xe,le,se);if(ve.length>0){f(z,ae,ve);const Q=`${z}_${ae}`;O(K=>({...K,[Q]:{min:R.toString(),max:xe.toString(),step:le.toString()}}))}}if(U.type==="customtext"||U.type.toLowerCase().includes("text")){const R=`${z}_${ae}`,xe=G[R]||[""];JSON.stringify(xe)!==JSON.stringify(d[z]?.[ae]||[""])&&f(z,ae,xe)}})})},[l,r,d,G,f,O,C]),i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Set test values"}),i.jsx("p",{className:"text-xs text-gray-500",children:"Configure the test values for each parameter"})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:I,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.length>0?l.map((M,z)=>{const V=M.widgets||{},je=Object.values(V),U=M.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b flex justify-between items-center",children:[i.jsxs("span",{children:[M.type," (ID: ",U,")"]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:ae=>I(ae,z),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"p-4 space-y-4",children:je.map((ae,ge)=>{const R=ae.name;if(!r[R])return null;const xe=`${U}_${R}`;if(ae.type==="customtext"||ae.type.toLowerCase().includes("text")){const le=G[xe]||[""];return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center mb-2",children:[i.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[R,":"]}),i.jsxs("button",{className:"px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs flex items-center hover:bg-blue-200 transition-colors",onClick:()=>B(U,R),children:[i.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})}),"AI Writing"]})]}),i.jsx("div",{className:"space-y-2",children:le.map((se,ve)=>i.jsxs("div",{className:"flex items-start",children:[i.jsx("textarea",{className:`flex-1 border ${se?"border-gray-300":"border-red-500"} rounded p-2 text-xs resize-y`,rows:2,placeholder:"Enter text...",value:se,onChange:Q=>q(U,R,ve,Q.target.value),required:!0}),i.jsx("button",{className:"ml-2 text-red-500 hover:text-red-700",onClick:()=>D(U,R,ve),title:"Remove",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},ve))}),i.jsxs("button",{className:"mt-2 px-2 py-1 border border-dashed border-gray-300 rounded text-xs text-gray-600 hover:bg-gray-50 flex items-center",onClick:()=>F(U,R),children:[i.jsx("svg",{className:"w-3 h-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Text"]})]},ge)}if(ae.type==="number"){const le=ae.options?.min||0,se=ae.options?.max||100,ve=(ae.options?.step||10)/10,Q=ae.options?.precision||0,K=C(le,se,ve,Q),ce=P[xe]||{min:le.toString(),max:se.toString(),step:ve.toString()};return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("label",{className:"text-xs font-medium text-gray-700",children:[R,":"]}),i.jsx("div",{className:"w-4"})]}),i.jsxs("div",{className:"flex space-x-2 items-center",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Min"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:ce.min,required:!0,onClick:J=>{J.preventDefault(),J.stopPropagation()},onChange:J=>{J.preventDefault(),J.stopPropagation();const Z=J.target.value;if(O(ye=>({...ye,[xe]:{...ye[xe],min:Z}})),Z===""||!isNaN(parseFloat(Z))){const ye=Z===""?0:parseFloat(Z),ke=parseFloat(ce.max||se.toString()),Oe=parseFloat(ce.step||ve.toString()),Ie=C(ye,ke,Oe,Q);f(U,R,Ie)}}}),i.jsx("label",{className:"text-xs text-gray-600",children:"Max"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:ce.max,onClick:J=>{J.preventDefault(),J.stopPropagation()},required:!0,onChange:J=>{J.preventDefault(),J.stopPropagation();const Z=J.target.value;if(O(ye=>({...ye,[xe]:{...ye[xe],max:Z}})),Z===""||!isNaN(parseFloat(Z))){const ye=parseFloat(ce.min||le.toString()),ke=Z===""?ye:parseFloat(Z),Oe=parseFloat(ce.step||ve.toString()),Ie=C(ye,ke,Oe,Q);f(U,R,Ie)}}}),i.jsx("label",{className:"text-xs text-gray-600",children:"Step"}),i.jsx("input",{type:"text",className:"w-12 h-6 border border-gray-300 rounded text-xs px-2",value:ce.step,required:!0,onClick:J=>{J.preventDefault(),J.stopPropagation()},onChange:J=>{J.preventDefault(),J.stopPropagation();const Z=J.target.value;if(O(ye=>({...ye,[xe]:{...ye[xe],step:Z}})),Z===""||!isNaN(parseFloat(Z))&&parseFloat(Z)>0){const ye=parseFloat(ce.min||le.toString()),ke=parseFloat(ce.max||se.toString());let Oe=Z===""?1:parseFloat(Z);Oe<.1&&(Oe=.1);const Ie=C(ye,ke,Oe,Q);f(U,R,Ie)}}})]}),i.jsxs("div",{className:"mt-1",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),i.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(()=>{const J=d[U]?.[R]||K;if(J.length<=10)return J.map((Z,ye)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:ke=>{ke.stopPropagation(),p(U,R,Z,ke)},children:[i.jsx("span",{children:Z}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},ye));{const Z=J.slice(0,5),ye=J.slice(J.length-5);return i.jsxs(i.Fragment,{children:[Z.map((ke,Oe)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:Ie=>{Ie.stopPropagation(),p(U,R,ke,Ie)},children:[i.jsx("span",{children:ke}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`first-${Oe}`)),i.jsx("div",{className:"px-2 py-0.5 bg-gray-100 text-gray-600 rounded-md flex items-center text-xs",children:"..."}),ye.map((ke,Oe)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs cursor-pointer hover:bg-blue-200",onClick:Ie=>{Ie.stopPropagation(),p(U,R,ke,Ie)},children:[i.jsx("span",{children:ke}),i.jsx("svg",{className:"w-4 h-4 ml-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},`last-${Oe}`))]})}})()})]}),i.jsx("div",{className:"mt-1",children:i.jsx("p",{className:"text-xs text-gray-500",children:"Values are distributed evenly between Min and Max"})})]},ge)}else if(ae.type==="combo"){const le=ae.options?.values||[],se=`${U}_${R}`,ve=K=>typeof K=="string"?K:K&&typeof K=="object"&&"name"in K?K.name:String(K),Q=K=>typeof K=="object"&&K!==null&&"name"in K?K.name:K;return i.jsxs("div",{className:"border-b pb-3",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("label",{className:"text-xs font-medium text-gray-700",children:R}),i.jsxs("div",{className:"relative dropdown-container",children:[i.jsxs("button",{className:`appearance-none border ${(d[U]?.[R]||[]).length===0?"border-red-500":"border-gray-300"} rounded px-2 py-0.5 pr-6 text-xs flex items-center bg-white text-gray-700`,onClick:K=>{K.preventDefault(),K.stopPropagation(),u(U,R,K)},"data-dropdown":se,children:[i.jsx("span",{children:(d[U]?.[R]||[]).length>0?`${R}: ${(d[U]?.[R]||[]).length} selected`:`Select ${R}`}),i.jsx("div",{className:"ml-2",children:i.jsx("svg",{className:"fill-current h-4 w-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:i.jsx("path",{d:"M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"})})})]}),h[se]&&i.jsxs("div",{className:"absolute z-[9999] mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg dropdown-menu",style:{position:"fixed",top:typeof h[se]=="object"?`${h[se].y}px`:"0px",left:typeof h[se]=="object"?`${h[se].x}px`:"0px",maxHeight:"300px",overflowY:"auto"},children:[i.jsx("div",{className:"p-2 border-b sticky top-0 bg-white",children:i.jsx("input",{type:"text",className:"w-full px-2 py-0.5 text-xs border border-gray-300 rounded",placeholder:"Search...",value:x[se]||"",onChange:K=>{K.preventDefault(),K.stopPropagation(),w(U,R,K.target.value)},onClick:K=>{K.preventDefault(),K.stopPropagation()},autoFocus:!0})}),i.jsxs("div",{className:"px-3 py-1.5 bg-gray-50 border-b cursor-pointer text-xs flex items-center text-gray-700 hover:bg-gray-100",onClick:K=>{K.preventDefault(),K.stopPropagation();const J=le.filter(Z=>!x[se]||ve(Z).toLowerCase().includes((x[se]||"").toLowerCase())).map(Q);N(U,R,J)},children:[i.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${le.length>0&&(d[U]?.[R]||[]).length===le.length?"bg-blue-500 border-blue-500":(d[U]?.[R]||[]).length>0?"bg-blue-500 border-blue-500 opacity-50":"border-gray-300"}`,children:(d[U]?.[R]||[]).length>0&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("span",{className:"font-medium",children:le.length>0&&(d[U]?.[R]||[]).length===le.length?"Deselect All":"Select All"})]}),i.jsxs("div",{className:"max-h-60 overflow-y-auto",children:[le.filter(K=>!x[se]||ve(K).toLowerCase().includes((x[se]||"").toLowerCase())).map((K,ce)=>i.jsxs("div",{className:"px-3 py-1.5 hover:bg-gray-100 cursor-pointer text-xs flex items-center text-gray-700",onClick:J=>{J.preventDefault(),J.stopPropagation(),p(U,R,Q(K),J)},children:[i.jsx("div",{className:`w-4 h-4 mr-2 border rounded-sm flex items-center justify-center ${(d[U]?.[R]||[]).includes(Q(K))?"bg-blue-500 border-blue-500":"border-gray-300"}`,children:(d[U]?.[R]||[]).includes(Q(K))&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("span",{className:"whitespace-normal overflow-hidden text-ellipsis",children:ve(K)})]},ce)),le.filter(K=>!x[se]||ve(K).toLowerCase().includes((x[se]||"").toLowerCase())).length===0&&i.jsx("div",{className:"px-3 py-4 text-sm text-gray-500 text-center",children:"No matching options"})]})]})]})]}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),(d[U]?.[R]||[]).length===0&&i.jsx("div",{className:"text-xs text-red-500 mt-1",children:"Please select at least one value"}),i.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:(d[U]?.[R]||[]).map((K,ce)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[i.jsx("span",{children:K}),i.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:J=>{J.preventDefault(),J.stopPropagation(),p(U,R,K,J)},children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},ce))})]})]},ge)}else return i.jsxs("div",{className:"border-b pb-3",children:[i.jsx("div",{className:"flex justify-between items-center",children:i.jsx("label",{className:"text-xs font-medium text-gray-700",children:R})}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-600",children:"Test values"}),i.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[(d[U]?.[R]||[]).map((le,se)=>i.jsxs("div",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded-md flex items-center text-xs",children:[i.jsx("span",{children:le}),i.jsx("svg",{className:"w-4 h-4 ml-1 cursor-pointer hover:text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",onClick:ve=>{ve.preventDefault(),ve.stopPropagation(),p(U,R,le,ve)},children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]},se)),i.jsxs("button",{className:"px-2 py-0.5 border border-dashed border-blue-300 text-blue-600 rounded-md text-xs flex items-center hover:bg-blue-50",onClick:le=>{le.preventDefault(),le.stopPropagation();const se=`${R}${(d[U]?.[R]||[]).length+1}`;f(U,R,[...d[U]?.[R]||[],se])},children:[i.jsx("svg",{className:"w-4 h-4 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),i.jsx("span",{children:"Add"})]})]})]})]},ge)})})]},z)}):i.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),i.jsxs("div",{className:"mt-6 flex justify-between",children:[i.jsx("button",{onClick:M=>b(M),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),i.jsx("button",{onClick:M=>_(M),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"Next"})]})]})},Dp=({selectedNodes:l,paramTestValues:d,selectedParams:r,totalCount:f,errorMessage:u,handlePrevious:h,handleStartGeneration:p,handleClose:x})=>{const[w,N]=E.useState([]),[_,b]=E.useState(null),[I,P]=E.useState(!1),{dispatch:O}=En(),G=()=>{const F=Object.values(We.graph._nodes_by_id),D=[],B=[];for(const M of F)M.type==="SaveImage"?D.push(M.id):M.type==="PreviewImage"&&B.push(M.id);const C=[...D,...B];N(C),C.length===1?b(C[0]):C.length>1&&(P(!0),b(null))};E.useEffect(()=>{G()},[]),E.useEffect(()=>{const F=()=>{if(!We.canvas.selected_nodes)return;const D=Object.values(We.canvas.selected_nodes);if(D.length===0)return;const B=D[0];B&&(B.type==="SaveImage"||B.type==="PreviewImage")&&(console.log("Selected image node:",B.id),b(B.id))};return document.addEventListener("click",F),()=>{document.removeEventListener("click",F)}},[]);const q=F=>{if(F&&(F.preventDefault(),F.stopPropagation()),w.length>1&&!_){P(!0);return}p(F,_||void 0)};return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Conform combinations"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",f," total runs. Each run will generate a separate image."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:x,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),I&&w.length>1&&i.jsx("div",{className:"mb-4 p-3 bg-yellow-50 border border-yellow-200 rounded-md text-amber-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:_===null?`Multiple SaveImage and PreviewImage nodes detected with IDs ${w.join(",")}. Please click the node on canvas.`:`Current node ID is ${_}, please click Start Generation again`})]})}),u&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:u})]})}),l.length>0?l.map((F,D)=>{const B=F.type||"Unknown Node",C=F.widgets||[],M=F.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[B," (ID: ",M,")"]}),i.jsx("div",{className:"p-4 space-y-3",children:C.map((z,V)=>{const je=z.name;if(!r[je])return null;const U=d[M]?.[je]||[],ae=Array.isArray(U)?`[${U.join(", ")}]`:JSON.stringify(U);return i.jsxs("div",{className:V<C.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[i.jsx("label",{className:"font-medium text-gray-700 text-xs",children:je}),i.jsx("div",{className:"flex space-x-2 items-center",children:i.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-xs px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:ae,onClick:ge=>ge.preventDefault()})})]},V)})})]},D)}):i.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500 text-xs",children:"No nodes selected. Please select a node in the workflow to configure parameters."}),i.jsxs("div",{className:"mt-6 flex justify-between",children:[i.jsx("button",{onClick:F=>h(F),className:"px-3 py-1.5 text-xs bg-gray-100 text-gray-800 rounded-md hover:bg-gray-200 transition-colors",children:"Previous"}),i.jsx("button",{onClick:F=>q(F),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${w.length>1&&!_?"bg-gray-200 text-gray-500 cursor-not-allowed":"bg-pink-200 text-pink-700 hover:bg-pink-300"}`,disabled:w.length>1&&!_,children:"Generate & Compare"})]})]})},Wp=({selectedNodes:l,paramTestValues:d,selectedParams:r,totalCount:f,completedCount:u,errorMessage:h,handleClose:p,setIsProcessing:x,setCurrentScreen:w,cleanupPolling:N})=>{const _=b=>{b.preventDefault(),b.stopPropagation(),Ip({clear:!0}),Mp(),N&&N(),x(!1),w(2)};return i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 relative",children:[i.jsx("div",{className:"absolute inset-0 bg-gray-500 bg-opacity-30 flex flex-col items-center justify-center z-10",children:i.jsxs("div",{className:"text-center text-gray-800 bg-white p-4 rounded-lg shadow-lg",children:[i.jsx("div",{className:"mb-2 text-sm font-medium",children:"Processing..."}),i.jsxs("div",{className:"text-xs mb-3",children:["Completed ",u," of ",f," runs"]}),i.jsx("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-pink-500 transition-all duration-200",style:{width:`${u/f*100}%`}})}),i.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:["Already generated ",u," images"]}),i.jsx("button",{onClick:_,className:"mt-4 px-3 py-1.5 text-xs bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors",children:"Cancel"})]})}),i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Confirm Test Configuration"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["In the selected parameter combinations, there are ",f," total runs. Each run will generate a separate image."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:p,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-md text-red-600 text-xs",children:i.jsxs("div",{className:"flex items-start",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.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"})})}),i.jsx("div",{className:"ml-2",children:h})]})}),l.length>0?l.map((b,I)=>{const P=b.type||"Unknown Node",O=b.widgets||[],G=b.id;return i.jsxs("div",{className:"border rounded-md mb-4 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 px-3 py-2 text-xs font-medium text-gray-700 border-b",children:[P," (ID: ",G,")"]}),i.jsx("div",{className:"p-4 space-y-3",children:O.map((q,F)=>{const D=q.name;if(!r[D])return null;const B=d[G]?.[D]||[],C=Array.isArray(B)?`[${B.join(", ")}]`:JSON.stringify(B);return i.jsxs("div",{className:F<O.length-1?"flex justify-between items-center border-b pb-2":"flex justify-between items-center",children:[i.jsx("label",{className:"font-medium text-gray-700",children:D}),i.jsx("div",{className:"flex space-x-2 items-center",children:i.jsx("input",{type:"text",className:"w-64 h-7 border border-gray-300 rounded text-sm px-2 bg-gray-50 cursor-not-allowed text-gray-500",readOnly:!0,disabled:!0,value:C,onClick:M=>M.preventDefault()})})]},F)})})]},I)}):i.jsx("div",{className:"border rounded-md mb-4 p-4 text-center text-gray-500",children:"No nodes selected. Please select a node in the workflow to configure parameters."})]})},mr=({visible:l,imageUrl:d,params:r,onClose:f})=>{if(!l)return null;const u=()=>{if(!r||!r.nodeParams)return null;const h=Object.entries(r.nodeParams).map(([p,x])=>{const w=r.nodeNames?.[p]||r.selectedNodeInfoMap&&r.selectedNodeInfoMap[p]||(p.includes("text")?"Text Node":`Node ${p}`),N=Object.entries(x).filter(([_,b])=>typeof b!="object"||b===null).map(([_,b])=>i.jsxs("div",{className:"pl-4 text-sm py-1 flex",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400 mr-2",children:"-"}),i.jsxs("span",{className:"font-medium mr-1",children:[_,":"]}),i.jsx("span",{className:"text-gray-700 dark:text-gray-300 break-all",children:String(b)})]},_));return i.jsxs("div",{className:"mb-4",children:[i.jsx("div",{className:"font-semibold text-pink-600 dark:text-pink-400 text-base py-1 border-b border-gray-200 dark:border-gray-700 mb-2",children:w}),N.length>0?N:i.jsx("div",{className:"pl-4 text-sm text-gray-500 italic",children:"nodeParams is null"})]},p)});return i.jsx("div",{className:"overflow-y-auto max-h-full",children:h.length>0?h:i.jsx("div",{className:"text-sm text-gray-500 italic",children:"nodeParams is null"})})};return i.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-sm flex items-center justify-center z-50",onClick:f,children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl flex flex-row w-[90%] max-w-6xl max-h-[90vh] relative m-4 overflow-hidden",onClick:h=>h.stopPropagation(),style:{display:"flex",flexDirection:"row"},children:[i.jsx("button",{className:"absolute top-2 right-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 p-1 z-10",onClick:f,children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),i.jsx("div",{className:"w-[65%] border-r border-gray-200 dark:border-gray-700",children:i.jsx("div",{className:"p-4 h-full flex items-center justify-center",children:i.jsx("img",{src:d,alt:"Enlarged image",className:"max-w-full max-h-[calc(90vh-2rem)] object-contain"})})}),i.jsx("div",{className:"w-[35%] h-full overflow-hidden flex flex-col",children:i.jsxs("div",{className:"p-4 flex-1 overflow-y-auto",children:[i.jsx("h3",{className:"text-lg font-medium text-gray-800 dark:text-gray-200 mb-4",children:"Parameters"}),r&&!r.nodeParams&&Object.entries(r).filter(([h,p])=>h!=="nodeParams"&&typeof p!="object").map(([h,p])=>i.jsxs("div",{className:"py-1 text-sm text-gray-600 dark:text-gray-300",children:[i.jsxs("span",{className:"font-medium",children:[h,":"]})," ",String(p)]},h)),i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300",children:u()})]})})]})})};function Hn(l,d,r){let f=r.initialDeps??[],u;function h(){var p,x,w,N;let _;r.key&&((p=r.debug)!=null&&p.call(r))&&(_=Date.now());const b=l();if(!(b.length!==f.length||b.some((O,G)=>f[G]!==O)))return u;f=b;let P;if(r.key&&((x=r.debug)!=null&&x.call(r))&&(P=Date.now()),u=d(...b),r.key&&((w=r.debug)!=null&&w.call(r))){const O=Math.round((Date.now()-_)*100)/100,G=Math.round((Date.now()-P)*100)/100,q=G/16,F=(D,B)=>{for(D=String(D);D.length<B;)D=" "+D;return D};console.info(`%c⏱ ${F(G,5)} /${F(O,5)} ms`,`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*q,120))}deg 100% 31%);`,r?.key)}return(N=r?.onChange)==null||N.call(r,u),u}return h.updateDeps=p=>{f=p},h}function hl(l,d){if(l===void 0)throw new Error("Unexpected undefined");return l}const $p=(l,d)=>Math.abs(l-d)<1.01,Bp=(l,d,r)=>{let f;return function(...u){l.clearTimeout(f),f=l.setTimeout(()=>d.apply(this,u),r)}},gl=l=>{const{offsetWidth:d,offsetHeight:r}=l;return{width:d,height:r}},Fp=l=>l,zp=l=>{const d=Math.max(l.startIndex-l.overscan,0),r=Math.min(l.endIndex+l.overscan,l.count-1),f=[];for(let u=d;u<=r;u++)f.push(u);return f},Up=(l,d)=>{const r=l.scrollElement;if(!r)return;const f=l.targetWindow;if(!f)return;const u=p=>{const{width:x,height:w}=p;d({width:Math.round(x),height:Math.round(w)})};if(u(gl(r)),!f.ResizeObserver)return()=>{};const h=new f.ResizeObserver(p=>{const x=()=>{const w=p[0];if(w?.borderBoxSize){const N=w.borderBoxSize[0];if(N){u({width:N.inlineSize,height:N.blockSize});return}}u(gl(r))};l.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(x):x()});return h.observe(r,{box:"border-box"}),()=>{h.unobserve(r)}},pl={passive:!0},ml=typeof window>"u"?!0:"onscrollend"in window,Gp=(l,d)=>{const r=l.scrollElement;if(!r)return;const f=l.targetWindow;if(!f)return;let u=0;const h=l.options.useScrollendEvent&&ml?()=>{}:Bp(f,()=>{d(u,!1)},l.options.isScrollingResetDelay),p=_=>()=>{const{horizontal:b,isRtl:I}=l.options;u=b?r.scrollLeft*(I&&-1||1):r.scrollTop,h(),d(u,_)},x=p(!0),w=p(!1);w(),r.addEventListener("scroll",x,pl);const N=l.options.useScrollendEvent&&ml;return N&&r.addEventListener("scrollend",w,pl),()=>{r.removeEventListener("scroll",x),N&&r.removeEventListener("scrollend",w)}},Hp=(l,d,r)=>{if(d?.borderBoxSize){const f=d.borderBoxSize[0];if(f)return Math.round(f[r.options.horizontal?"inlineSize":"blockSize"])}return l[r.options.horizontal?"offsetWidth":"offsetHeight"]},Kp=(l,{adjustments:d=0,behavior:r},f)=>{var u,h;const p=l+d;(h=(u=f.scrollElement)==null?void 0:u.scrollTo)==null||h.call(u,{[f.options.horizontal?"left":"top"]:p,behavior:r})};class qp{constructor(d){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let r=null;const f=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(u=>{u.forEach(h=>{const p=()=>{this._measureElement(h.target,h)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(p):p()})}));return{disconnect:()=>{var u;(u=f())==null||u.disconnect(),r=null},observe:u=>{var h;return(h=f())==null?void 0:h.observe(u,{box:"border-box"})},unobserve:u=>{var h;return(h=f())==null?void 0:h.unobserve(u)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([f,u])=>{typeof u>"u"&&delete r[f]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Fp,rangeExtractor:zp,onChange:()=>{},measureElement:Hp,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var f,u;(u=(f=this.options).onChange)==null||u.call(f,this,r)},this.maybeNotify=Hn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const f=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==f){if(this.cleanup(),!f){this.maybeNotify();return}this.scrollElement=f,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(u=>{this.observer.observe(u)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,u=>{this.scrollRect=u,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(u,h)=>{this.scrollAdjustments=0,this.scrollDirection=h?this.getScrollOffset()<u?"forward":"backward":null,this.scrollOffset=u,this.isScrolling=h,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,f)=>{const u=new Map,h=new Map;for(let p=f-1;p>=0;p--){const x=r[p];if(u.has(x.lane))continue;const w=h.get(x.lane);if(w==null||x.end>w.end?h.set(x.lane,x):x.end<w.end&&u.set(x.lane,!0),u.size===this.options.lanes)break}return h.size===this.options.lanes?Array.from(h.values()).sort((p,x)=>p.end===x.end?p.index-x.index:p.end-x.end)[0]:void 0},this.getMeasurementOptions=Hn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(r,f,u,h,p)=>(this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:f,scrollMargin:u,getItemKey:h,enabled:p}),{key:!1}),this.getMeasurements=Hn(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:f,scrollMargin:u,getItemKey:h,enabled:p},x)=>{if(!p)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(_=>{this.itemSizeCache.set(_.key,_.size)}));const w=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const N=this.measurementsCache.slice(0,w);for(let _=w;_<r;_++){const b=h(_),I=this.options.lanes===1?N[_-1]:this.getFurthestMeasurement(N,_),P=I?I.end+this.options.gap:f+u,O=x.get(b),G=typeof O=="number"?O:this.options.estimateSize(_),q=P+G,F=I?I.lane:_%this.options.lanes;N[_]={index:_,start:P,size:G,end:q,key:b,lane:F}}return this.measurementsCache=N,N},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Hn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,f,u,h)=>this.range=r.length>0&&f>0?Jp({measurements:r,outerSize:f,scrollOffset:u,lanes:h}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Hn(()=>{let r=null,f=null;const u=this.calculateRange();return u&&(r=u.startIndex,f=u.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,f]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,f]},(r,f,u,h,p)=>h===null||p===null?[]:r({startIndex:h,endIndex:p,overscan:f,count:u}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const f=this.options.indexAttribute,u=r.getAttribute(f);return u?parseInt(u,10):(console.warn(`Missing attribute name '${f}={index}' on measured element.`),-1)},this._measureElement=(r,f)=>{const u=this.indexFromElement(r),h=this.measurementsCache[u];if(!h)return;const p=h.key,x=this.elementsCache.get(p);x!==r&&(x&&this.observer.unobserve(x),this.observer.observe(r),this.elementsCache.set(p,r)),r.isConnected&&this.resizeItem(u,this.options.measureElement(r,f,this))},this.resizeItem=(r,f)=>{const u=this.measurementsCache[r];if(!u)return;const h=this.itemSizeCache.get(u.key)??u.size,p=f-h;p!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(u,p,this):u.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=p,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(u.index),this.itemSizeCache=new Map(this.itemSizeCache.set(u.key,f)),this.notify(!1))},this.measureElement=r=>{if(!r){this.elementsCache.forEach((f,u)=>{f.isConnected||(this.observer.unobserve(f),this.elementsCache.delete(u))});return}this._measureElement(r,void 0)},this.getVirtualItems=Hn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,f)=>{const u=[];for(let h=0,p=r.length;h<p;h++){const x=r[h],w=f[x];u.push(w)}return u},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const f=this.getMeasurements();if(f.length!==0)return hl(f[jl(0,f.length-1,u=>hl(f[u]).start,r)])},this.getOffsetForAlignment=(r,f,u=0)=>{const h=this.getSize(),p=this.getScrollOffset();f==="auto"&&(f=r>=p+h?"end":"start"),f==="center"?r+=(u-h)/2:f==="end"&&(r-=h);const x=this.getTotalSize()+this.options.scrollMargin-h;return Math.max(Math.min(x,r),0)},this.getOffsetForIndex=(r,f="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const u=this.measurementsCache[r];if(!u)return;const h=this.getSize(),p=this.getScrollOffset();if(f==="auto")if(u.end>=p+h-this.options.scrollPaddingEnd)f="end";else if(u.start<=p+this.options.scrollPaddingStart)f="start";else return[p,f];const x=f==="end"?u.end+this.options.scrollPaddingEnd:u.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(x,f,u.size),f]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(r,{align:f="start",behavior:u}={})=>{u==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(r,f),{adjustments:void 0,behavior:u})},this.scrollToIndex=(r,{align:f="auto",behavior:u}={})=>{u==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),r=Math.max(0,Math.min(r,this.options.count-1));let h=0;const p=10,x=N=>{if(!this.targetWindow)return;const _=this.getOffsetForIndex(r,N);if(!_){console.warn("Failed to get offset for index:",r);return}const[b,I]=_;this._scrollToOffset(b,{adjustments:void 0,behavior:u}),this.targetWindow.requestAnimationFrame(()=>{const P=this.getScrollOffset(),O=this.getOffsetForIndex(r,I);if(!O){console.warn("Failed to get offset for index:",r);return}$p(O[0],P)||w(I)})},w=N=>{this.targetWindow&&(h++,h<p?this.targetWindow.requestAnimationFrame(()=>x(N)):console.warn(`Failed to scroll to index ${r} after ${p} attempts.`))};x(f)},this.scrollBy=(r,{behavior:f}={})=>{f==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+r,{adjustments:void 0,behavior:f})},this.getTotalSize=()=>{var r;const f=this.getMeasurements();let u;if(f.length===0)u=this.options.paddingStart;else if(this.options.lanes===1)u=((r=f[f.length-1])==null?void 0:r.end)??0;else{const h=Array(this.options.lanes).fill(null);let p=f.length-1;for(;p>=0&&h.some(x=>x===null);){const x=f[p];h[x.lane]===null&&(h[x.lane]=x.end),p--}u=Math.max(...h.filter(x=>x!==null))}return Math.max(u-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:f,behavior:u})=>{this.options.scrollToFn(r,{behavior:u,adjustments:f},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(d)}}const jl=(l,d,r,f)=>{for(;l<=d;){const u=(l+d)/2|0,h=r(u);if(h<f)l=u+1;else if(h>f)d=u-1;else return u}return l>0?l-1:0};function Jp({measurements:l,outerSize:d,scrollOffset:r,lanes:f}){const u=l.length-1,h=w=>l[w].start;if(l.length<=f)return{startIndex:0,endIndex:u};let p=jl(0,u,h,r),x=p;if(f===1)for(;x<u&&l[x].end<r+d;)x++;else if(f>1){const w=Array(f).fill(0);for(;x<u&&w.some(_=>_<r+d);){const _=l[x];w[_.lane]=_.end,x++}const N=Array(f).fill(r+d);for(;p>=0&&N.some(_=>_>=r);){const _=l[p];N[_.lane]=_.start,p--}p=Math.max(0,p-p%f),x=Math.min(u,x+(f-1-x%f))}return{startIndex:p,endIndex:x}}const xl=typeof document<"u"?E.useLayoutEffect:E.useEffect;function Yp(l){const d=E.useReducer(()=>({}),{})[1],r={...l,onChange:(u,h)=>{var p;h?Gg.flushSync(d):d(),(p=l.onChange)==null||p.call(l,u,h)}},[f]=E.useState(()=>new qp(r));return f.setOptions(r),xl(()=>f._didMount(),[]),xl(()=>f._willUpdate()),f}function Xp(l){return Yp({observeElementRect:Up,observeElementOffset:Gp,scrollToFn:Kp,...l})}const El=l=>{const{items:d,renderItem:r,minWidth:f=200,gap:u=16}=l,h=E.useRef(null),[p,x]=E.useState(1),[w,N]=E.useState(0);E.useLayoutEffect(()=>{if(!h.current)return;const b=()=>{if(h.current){const P=h.current.offsetWidth,O=Math.max(1,Math.floor(P/(f+u/2)));x(O),N(Math.ceil(d.length/O))}};b();const I=new window.ResizeObserver(Wi.debounce(b,50));return I.observe(h.current),()=>I.disconnect()},[]);const _=Xp({count:w,getScrollElement:()=>h.current,estimateSize:()=>f+40,overscan:3,gap:u});return i.jsx("div",{ref:h,className:"h-full relative overflow-auto hide-scrollbar",children:i.jsx("div",{style:{height:_.getTotalSize(),position:"relative"},children:_.getVirtualItems().map(b=>{const I=b.index,P=I*p,O=Math.min(P+p,d.length);return i.jsx("div",{"data-index":I,ref:_.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${b.start}px)`,display:"grid",gridTemplateColumns:`repeat(${p}, minmax(${f}px, 1fr))`,gap:`${u}px`},children:d.slice(P,O).map((G,q)=>r(G,P+q))},I)})})})},Zp=({generatedImages:l,selectedImageIndex:d,handleSelectImage:r,handleApplySelected:f,handleClose:u,notificationVisible:h,modalVisible:p,modalImageUrl:x,modalImageParams:w,openImageModal:N,closeImageModal:_})=>{const b=(I,P)=>i.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${d===I.index?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:O=>r(P,O),children:[i.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:O=>N(I.url,I.params,O),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),i.jsx("div",{className:"aspect-square",children:i.jsx("img",{src:I.url,alt:`Generated image ${P+1}`,className:"w-full h-full object-cover"})}),i.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(I.params).filter(([O,G])=>O!=="nodeParams"&&typeof G!="object").map(([O,G])=>i.jsxs("div",{children:[O,": ",String(G)]},O))})]},P.toString());return i.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Generation Complete"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["All ",l.length," images have been generated."]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:u,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h&&i.jsx("div",{className:"fixed top-4 right-4 bg-green-100 border-l-4 border-green-500 text-green-700 p-3 shadow-md rounded animate-fade-in-out z-50",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"py-1",children:i.jsx("svg",{className:"h-4 w-4 text-green-500 mr-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),i.jsx("p",{className:"text-xs",children:"Parameters has been applied."})]})}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(El,{items:l,renderItem:b})}),i.jsx("div",{className:"mt-6 flex justify-end",children:i.jsx("button",{onClick:I=>f(I),className:"px-3 py-1.5 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",disabled:d===null,children:"Apply Selected"})}),i.jsx(mr,{visible:p,imageUrl:x,params:w||{},onClose:_})]})},Vp=({visible:l,aiWritingModalText:d,setAiWritingModalText:r,aiGeneratedTexts:f,aiSelectedTexts:u,aiWritingLoading:h,aiWritingError:p,handleAiWriting:x,toggleTextSelection:w,addSelectedTexts:N,onClose:_})=>l?i.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"AI Writing Assistant"}),i.jsx("button",{className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",onClick:_,children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-2",children:"Enter text and AI will generate variations"}),i.jsx("textarea",{className:`w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-900 dark:text-white
bg-gray-50 dark:bg-gray-700
placeholder-gray-500 dark:placeholder-gray-400
focus:border-blue-500 dark:focus:border-blue-400
focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20
focus:outline-none`,rows:3,placeholder:"Enter some text here...",value:d,onChange:b=>r(b.target.value)}),i.jsx("button",{className:`mt-2 px-4 py-2 rounded-lg text-sm flex items-center transition-colors ${h?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,onClick:x,disabled:h,children:h?i.jsxs(i.Fragment,{children:[i.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-gray-500 dark:text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Generating..."]}):i.jsx(i.Fragment,{children:"Generate"})})]}),p&&i.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/20 rounded-md text-red-700 dark:text-red-400 text-sm",children:p}),f.length>0&&i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Generated variations (select items to add):"}),i.jsx("div",{className:"space-y-2 max-h-[40vh] overflow-y-auto p-2",children:f.map((b,I)=>i.jsxs("div",{className:"flex items-start border border-gray-200 dark:border-gray-600 rounded-md p-2",children:[i.jsx("div",{className:"mr-2 mt-1",children:i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:"checkbox",id:`text${I+1}`,checked:!!u[`text${I+1}`],onChange:()=>w(`text${I+1}`),className:"sr-only"}),i.jsx("div",{className:`h-4 w-4 rounded border ${u[`text${I+1}`]?"bg-blue-600 dark:bg-blue-500 border-blue-600 dark:border-blue-500":"border-gray-300 dark:border-gray-600"} flex items-center justify-center cursor-pointer`,onClick:()=>w(`text${I+1}`),children:u[`text${I+1}`]&&i.jsx("svg",{className:"h-3 w-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})})]})}),i.jsx("label",{htmlFor:`text${I+1}`,className:"text-sm text-gray-700 dark:text-gray-300 cursor-pointer flex-1",children:b})]},I))})]})]}),i.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end flex-shrink-0",children:[i.jsx("button",{className:`px-5 py-2.5 text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700
rounded-lg font-medium transition-colors mr-3`,onClick:_,children:"Cancel"}),i.jsx("button",{className:`px-5 py-2.5 rounded-lg font-medium transition-colors ${Object.values(u).every(b=>!b)?"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white"}`,onClick:N,disabled:Object.values(u).every(b=>!b),children:"Add Selected"})]})]})}):null,Di=l=>{const d=[],r={};if(Object.keys(l).forEach(h=>{const p=parseInt(h),x=l[h]||{},w=Object.keys(x).filter(_=>x[_]&&x[_].length>0);if(w.length===0)return;const N=[[]];w.forEach(_=>{const b=x[_],I=[];N.forEach(P=>{b.forEach(O=>{const G=[...P,{nodeId:p,paramName:_,paramValue:String(O)}];I.push(G)})}),N.length=0,N.push(...I)}),r[h]=N}),Object.keys(r).length===0)return d;if(Object.keys(r).length===1){const h=Object.keys(r)[0];return r[h]}const f=Object.keys(r);let u=r[f[0]];for(let h=1;h<f.length;h++){const p=r[f[h]],x=[];u.forEach(w=>{p.forEach(N=>{x.push([...w,...N])})}),u=x}return u},Qp=(l,d)=>{const r={};r.nodeParams={};const f=Di(l);return d<f.length&&f[d].forEach(h=>{const p=h.nodeId.toString(),x=h.paramName,w=h.paramValue;r.nodeParams[p]||(r.nodeParams[p]={}),r.nodeParams[p][x]=w,r[x]=w}),r},Cl="parameter_debug_history",vl=30,yl=async(l,d,r,f,u)=>{try{const h=kl(),p={id:qe(),timestamp:Date.now(),title:$i(l,d),nodeName:l,params:{...d,nodeNames:{...d.nodeNames||{},[l.split("<")[0]]:l.split("<")[0]}},generatedImages:r,totalCount:f,workflow:u};return h.unshift(p),h.length>vl&&h.splice(vl),localStorage.setItem(Cl,JSON.stringify(h)),p}catch(h){return console.error("Error saving parameter debug history:",h),null}},kl=()=>{try{const l=localStorage.getItem(Cl);if(l)return JSON.parse(l)}catch(l){console.error("Error loading parameter debug history:",l)}return[]},Al=l=>{const d=new Date(l);return`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")} ${String(d.getHours()).padStart(2,"0")}:${String(d.getMinutes()).padStart(2,"0")}`},$i=(l,d)=>{if(d.nodeParams)return Object.entries(d.nodeParams).map(([h,p])=>{let x=l;d.selectedNodeInfoMap&&d.selectedNodeInfoMap[h]&&(x=d.selectedNodeInfoMap[h]);const w=Object.keys(p).slice(0,3);return`${x}<${w.join(",")}>`}).join(";");const r=Object.keys(d).filter(f=>f!=="nodeParams"&&f!=="selectedNodeInfoMap").slice(0,3);return`${l}<${r.join(",")}>`},em=({historyItems:l,onViewHistoryItem:d,onClose:r})=>i.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4 flex flex-col h-full",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-center",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-medium text-gray-800",children:"Experiments History"}),i.jsxs("p",{className:"text-xs text-gray-500",children:["Last ",l.length," experiments"]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:r,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),l.length===0?i.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500 text-sm",children:"No history items found"}):i.jsx("div",{className:"flex-1 overflow-y-auto",children:l.map(f=>i.jsxs("div",{className:"border border-gray-200 rounded-lg mb-3 overflow-hidden",children:[i.jsxs("div",{className:"bg-gray-50 py-2 px-3 flex items-center justify-between border-b",children:[i.jsx("div",{className:"text-[14px] text-gray-600",children:Al(f.timestamp)}),i.jsx("button",{onClick:()=>d(f),className:"px-3 py-1 text-xs bg-pink-200 text-pink-700 rounded-md hover:bg-pink-300 transition-colors",children:"view"})]}),i.jsx("div",{className:"p-3",children:i.jsx("div",{className:"text-[10px] font-medium text-gray-700",children:$i(f.nodeName,f.params)})})]},f.id))})]}),tm=({historyItem:l,selectedImageIndex:d,handleSelectImage:r,handleClose:f,modalVisible:u,modalImageUrl:h,modalImageParams:p,openImageModal:x,closeImageModal:w})=>{const{timestamp:N,nodeName:_,generatedImages:b,params:I}=l,P=(O,G)=>i.jsxs("div",{className:`relative flex flex-col rounded-lg overflow-hidden border ${d===G?"border-pink-500 ring-2 ring-pink-300":"border-gray-200"}`,onClick:q=>r(G,q),children:[i.jsx("button",{className:"absolute top-2 right-2 bg-white bg-opacity-75 rounded-full p-0.5 text-gray-600 hover:text-gray-900 shadow-sm z-10",onClick:q=>x(O.url,O.params,q),children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})}),i.jsx("div",{className:"aspect-square",children:i.jsx("img",{src:O.url,alt:`Generated image ${G+1}`,className:"w-full h-full object-cover"})}),i.jsx("div",{className:"p-2 text-xs text-gray-600 bg-white max-h-16 overflow-y-auto",children:Object.entries(O.params).filter(([q,F])=>q!=="nodeParams"&&typeof F!="object").map(([q,F])=>i.jsxs("div",{children:[q,": ",String(F)]},q))})]},G.toString());return i.jsxs("div",{className:"h-full flex flex-col relative bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[i.jsxs("div",{className:"mb-4 border-b pb-2 flex justify-between items-start",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h3",{className:"text-base font-medium text-gray-800 truncate hover:!break-words hover:!whitespace-normal hover:!overflow-visible",children:$i(_,I)}),i.jsxs("p",{className:"text-xs text-gray-500",children:[Al(N)," • ",b.length," images"]})]}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600 mt-0",onClick:f,children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(El,{items:b,renderItem:P})}),i.jsx(mr,{visible:u,imageUrl:h,params:p?{...p,nodeNames:{[l.nodeName.split("<")[0]]:l.nodeName.split("<")[0]}}:void 0,onClose:w})]})},nm=`
@keyframes highlight-pulse {
0% {
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
}
70% {
box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
}
}
.highlight-pulse {
animation: highlight-pulse 1.5s infinite;
border: 2px solid #3b82f6;
}
@keyframes fade-in-out {
0% { opacity: 0; transform: translateY(-20px); }
10% { opacity: 1; transform: translateY(0); }
90% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-20px); }
}
.animate-fade-in-out {
animation: fade-in-out 3s forwards;
}
`,xr="parameter_debug_state",bl=l=>{try{localStorage.setItem(xr,JSON.stringify(l))}catch(d){console.error("Error saving parameter debug state:",d)}},rm=()=>{try{const l=localStorage.getItem(xr);if(l)return JSON.parse(l)}catch(l){console.error("Error loading parameter debug state:",l)}return null},sm=()=>{try{localStorage.removeItem(xr)}catch(l){console.error("Error clearing parameter debug state:",l)}},im=(l,d,r,f,u,h)=>{const p=`${l}_${d}`;h(w=>{const N=[...w[p]||[]];return N[r]=f,{...w,[p]:N}});const x=[...u[p]||[]];return x[r]=f,x},om=(l,d,r,f)=>{const u=`${l}_${d}`;return f(h=>{const p=[...h[u]||[]];return p.push(""),{...h,[u]:p}}),[...r[u]||[],""]},am=(l,d,r,f,u)=>{const h=`${l}_${d}`;u(x=>{const w=[...x[h]||[]];return w.splice(r,1),{...x,[h]:w}});const p=[...f[h]||[]];return p.splice(r,1),p},lm=(l,d,r,f,u)=>{r.preventDefault(),r.stopPropagation();const h=`${l}_${d}`;u(p=>{if(p[h]&&typeof p[h]=="object"?p[h].isOpen:!!p[h])return{...p,[h]:!1};{let w=0,N=0;if(r.currentTarget){const I=r.currentTarget.getBoundingClientRect();w=I.left,N=I.bottom}else w=r.clientX,N=r.clientY+20;const _=window.innerWidth,b=250;return w+b>_&&(w=_-b-10),w<0&&(w=10),{...p,[h]:{isOpen:!0,x:w,y:N}}}})},cm=(l,d,r,f,u)=>{u(h=>{const p={...h};return p[l]||(p[l]={}),p[l][d]=r,p})},um=(l,d,r,f,u,h)=>{h&&(h.preventDefault(),h.stopPropagation()),u(p=>{const x={...p};x[l]||(x[l]={}),x[l][d]||(x[l][d]=[]);const w=x[l][d];return w.includes(r)?x[l][d]=w.filter(N=>N!==r):x[l][d]=[...w,r],x})},dm=(l,d,r,f,u)=>{const h=`${l}_${d}`;u(p=>({...p,[h]:r}))},fm=(l,d,r,f,u)=>{if(!f[l]){u(l,d,r);return}const h=f[l][d]||[];r.length===h.length?u(l,d,[]):u(l,d,[...r])},hm=(l,d,r,f,u,h)=>{h&&(h.preventDefault(),h.stopPropagation());const p=d[l];if(r(x=>({...x,[l]:!p})),p){const x={...f};Object.keys(x).forEach(w=>{x[w][l]&&delete x[w][l]}),u(x)}},gm=(l,d,r,f,u,h,p)=>{p.preventDefault(),p.stopPropagation();const x={...d};if(d.nodeParams){const w={};Object.keys(d.nodeParams).forEach(N=>{const _=r.find(b=>b.id.toString()===N);w[N]=_?_.title||`Node ${N}`:`Node ${N}`}),x.nodeNames=w}else if(Object.keys(d).length>0){const w={};Object.entries(d).forEach(([N,_])=>{(typeof _!="object"||_===null)&&(w[N]=_)}),Object.keys(w).length>0&&(x.nodeParams={default:w},x.nodeNames={default:d.node_name||d.nodeName||"参数"})}f(l),u(x),h(!0)},pm=(l,d)=>{d&&(d.preventDefault(),d.stopPropagation()),l(!1)},mm=(l,d,r,f,u,h,p,x,w,N,_)=>{if(_&&(_.preventDefault(),_.stopPropagation()),l===0){const b={...f};Object.keys(b).forEach(I=>{const P=b[I];Object.keys(P).forEach(O=>{r[O]||delete P[O]})}),u(b)}if(l===1){const b={...f};p.forEach(P=>{const O=P.id.toString(),G=P.widgets||{};Object.values(G).forEach(q=>{const F=q.name;if(r[F]&&(q.type==="customtext"||q.type.toLowerCase().includes("text"))){const D=`${O}_${F}`,B=h[D]||[""];b[O]=b[O]||{},b[O][F]=B}})}),u(b);const I=N(b);x(I.length)}w(null),d(b=>Math.min(b+1,2))},xm=(l,d,r,f,u,h,p,x,w,N)=>{if(N&&(N.preventDefault(),N.stopPropagation()),w(null),p&&x(!1),l===1){const _=r.map(P=>P.id.toString()),b=Object.keys(f),I={...f};b.forEach(P=>{_.includes(P)||delete I[P]}),u(I)}if(l===2||p){const _={...f};Object.entries(h).forEach(([b,I])=>{if(!I||I.length===0)return;const[P,O]=b.split("_");r.some(G=>G.id.toString()===P)&&(_[P]=_[P]||{},JSON.stringify(_[P][O])!==JSON.stringify(I)&&(_[P][O]=I))}),u(_)}d(_=>Math.max(_-1,0))},vm=(l,d,r,f,u)=>{u&&(u.preventDefault(),u.stopPropagation()),f(Math.max(1,Math.min(l,Math.ceil(r.length/d))))};function ym(l,d){try{if(!l)return console.error("Invalid prompt_output: ",l),l;for(const r of d){if(!l[r.nodeId]){console.error(`Node with ID ${r.nodeId} not found`);continue}if(!l[r.nodeId].inputs){console.error(`Inputs not found for node with ID ${r.nodeId}`);continue}l[r.nodeId].inputs[r.paramName]=r.paramValue}return l}catch(r){return console.error("Error updating prompt:",r),l}}async function bm(l){const d=await We.graphToPrompt(),r=ym(d.output,l);console.log("queuePrompt updated_prompt:",r);const f={prompt:r,client_id:We.api.clientId,extra_data:{extra_pageinfo:{workflow:d.workflow}}};console.debug("queuePrompt request_body.prompt:",r);const u=await Ap(f);return console.debug("queuePrompt response:",u),u}function wl(l){const d=document.createElement("canvas"),r=d.getContext("2d");if(d.width=512,d.height=512,r){r.fillStyle="#f8d7da",r.fillRect(0,0,d.width,d.height),r.strokeStyle="#dc3545",r.lineWidth=4,r.strokeRect(10,10,d.width-20,d.height-20),r.fillStyle="#dc3545",r.beginPath(),r.arc(d.width/2,150,50,0,2*Math.PI),r.fill(),r.fillStyle="white",r.font="bold 80px Arial",r.textAlign="center",r.textBaseline="middle",r.fillText("!",d.width/2,150),r.fillStyle="#721c24",r.font="20px Arial",r.textAlign="center",r.textBaseline="middle";const f=d.width-60,u=30,h=l.split(" ");let p="",x=250;for(let w=0;w<h.length;w++){const N=p+h[w]+" ";r.measureText(N).width>f&&w>0?(r.fillText(p,d.width/2,x),p=h[w]+" ",x+=u):p=N}r.fillText(p,d.width/2,x)}return d.toDataURL("image/png")}async function wm(l){try{if(!l||l==="")return console.log("No prompt ID provided"),{1:[wl("Fail to generate prompt ID")]};const d=await Lp(l);if(!d||!d[l])return console.log("Not finished for prompt ID:",l),{};const r=d[l];if(r.status&&r.status.status_str==="error"){console.error("Error for prompt ID:",l);const u=r.status.messages;if(u&&u.length>0){const h=u[u.length-1];if(h&&h.length>0){const p=h[0];return{1:[wl(p)]}}}}const f={};if(r.outputs)for(const u in r.outputs){const h=r.outputs[u];if(h&&h.images){f[u]=[];for(const p of h.images)if(p&&p.filename&&p.type){const x=We.graph._nodes_by_id[u].imgs[0].currentSrc.split("?")[0];f[u].push(x+"?filename="+encodeURIComponent(p.filename)+"&type="+encodeURIComponent(p.type)+(p.subfolder?"&subfolder="+encodeURIComponent(p.subfolder):""))}console.log("outputImages for nodeId:",u,f[u])}}return f}catch(d){throw console.error("Error getting output images from prompt:",d),d}}function _m(){const l=Object.values(We.graph._nodes_by_id),d=[],r=[];for(const f of l)f.type==="SaveImage"?d.push(f.id):f.type==="PreviewImage"&&r.push(f.id);if(console.log("saveNodeIds:",d),console.log("previewNodeIds:",r),d.length===0&&r.length===0)throw new Error("No SaveImage or PreviewImage node found, please add one to the graph");return d.length===1?d[0]:d.length==0&&r.length===1?r[0]:null}async function Sm(l,d){const r=await wm(l);return Object.keys(r).length===0?null:r[d.toString()]&&r[d.toString()].length>0?r[d.toString()][0]:null}const Nm=async(l,d,r,f,u,h,p,x,w,N,_,b,I,P)=>{I&&(I.preventDefault(),I.stopPropagation()),Ml(N,w);const O=_(l),G=O.length;if(G>100){u(`Cannot generate more than 100 images at once (currently: ${G} images)`);return}u(null),r(!0),f(0),console.log("Generated parameter combinations:",O);let q=null;try{q=(await b.graphToPrompt()).output}catch(C){console.error("Error capturing workflow data:",C)}if($t.trackEvent({event_type:"start_generation",message_type:"parameter_debug",message_id:d,data:{workflow:q,all_params:l,count:G}}),O.length===0){u("No valid parameter combinations found. Please check your parameter selections."),r(!1);return}let F=P||null;if(F===null){const C=_m();C!==null&&(F=C)}if(F===null){u("Please select a SaveImage or PreviewImage node first."),r(!1);return}const D={};Object.keys(l).forEach(C=>{const M=b.graph._nodes_by_id[C];M&&(D[C]=M.type||M.comfyClass||"Unknown Node")});const B=[];try{const C=Date.now().toString();w.current=C;for(const ae of O){const ge=await bm(ae);ge.prompt_id?B.push(ge.prompt_id):(console.error("Failed to get prompt_id from response:",ge),B.push(""))}const M=Array(O.length).fill(null).map((ae,ge)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:Qp(l,ge)}));h(M);const z=Date.now(),V=5*60*1e3,je=Object.keys(l)[0],U=D[je]||"Unknown Node";Il(B,F,M,C,z,V,w,N,h,f,r,p,x,U,l,G,q,D)}catch(C){console.error("Error generating images:",C),r(!1)}},Il=async(l,d,r,f,u,h,p,x,w,N,_,b,I,P,O,G,q,F)=>{if(p.current!==f){console.log("Another polling session has started, stopping this one");return}if(Date.now()-u>h){if(console.log("Timeout reached while waiting for images"),p.current===f&&(_(!1),b(!0),I(1),r.length>0&&P&&O)){const B=r[0].params;F&&(B.selectedNodeInfoMap=F),yl(P,B,r,G||r.length,q)}return}let D=0;for(let B=0;B<l.length;B++){const C=l[B];if(C)try{const M=await Sm(C,Number(d));M&&(r[B]={...r[B],url:M},D++)}catch(M){console.error(`Error fetching image for prompt ID ${C}:`,M)}}if(w([...r]),N(D),D===l.length){if(console.log("All images have been generated!"),p.current===f&&(_(!1),b(!0),I(1),r.length>0&&P&&O)){const B=r[0].params;F&&(B.selectedNodeInfoMap=F),yl(P,B,r,G||r.length,q)}return}p.current===f&&(x.current=setTimeout(()=>{Il(l,d,r,f,u,h,p,x,w,N,_,b,I,P,O,G,q,F)},2e3))},Ml=(l,d)=>{l.current&&(clearTimeout(l.current),l.current=null),d.current=null},jm=async(l,d,r,f,u,h)=>{if(!l.trim()){f("Please enter some text to generate variations");return}r(!0),f(null),u([]),h({});try{const p=await $t.generateSDPrompts(l);u(p),$t.trackEvent({event_type:"prompt_generate",message_type:"parameter_debug",message_id:d,data:{input_text:l,generated_texts:p}});const x={};p.forEach((w,N)=>{x[`text${N+1}`]=!1}),h(x)}catch(p){console.error("Error generating text:",p),f("Failed to generate text variations. Please try again.")}finally{r(!1)}},Em=(l,d)=>{d(r=>({...r,[l]:!r[l]}))},Cm=(l,d,r,f,u,h,p,x,w,N)=>{const _=`${l}_${d}`,b=Object.entries(r).filter(([P,O])=>O).map(([P])=>{const O=parseInt(P.replace("text",""))-1;return f[O]});if(b.length===0)return;x(P=>{const O=[...P[_]||[]];return{...P,[_]:[...O,...b]}}),$t.trackEvent({event_type:"prompt_apply",message_type:"parameter_debug",message_id:h,data:{input_text:u,generated_texts:f,selected_texts:b}});const I=[...p[_]||[],...b];w(l,d,I),N(!1)},km=(l,d,r,f,u,h,p,x,w,N)=>{r(!0),f(l),u(d),h(""),p([]),x({}),w(!1),N(null)},Am=(l,d,r,f,u,h,p,x,w,N,_,b,I,P,O,G,q,F,D,B,C,M,z,V,je,U,ae,ge,R,xe=!1)=>{l(0),d({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),r(qe()),f(),u(!1),h(!1),p(0),x(12),w(null),N(Array(12).fill(null).map((le,se)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:se%3===0?5:se%3===1?10:15,sampler_name:"euler",cfg:1}}))),_({}),b({}),I({}),P({}),O(1),G(null),q(!1),F(!1),D(""),B(null),C({}),M(!1),z(""),V([]),je(!1),U(""),ae(""),ge(null),R({}),xe&&sm()},Im=(l,d,r)=>{r&&(r.preventDefault(),r.stopPropagation()),d(l)},Mm=async(l,d,r,f,u,h,p)=>{if(p&&(p.preventDefault(),p.stopPropagation()),l!==null){console.log(`Applied image ${l+1} with parameters:`,d[l].params);let x=1;if(u){for(const N in u)if(u[N])for(const _ in u[N]){const b=u[N][_];if(b){let I=1;Array.isArray(b)?I=b.length>0?b.length:1:typeof b=="object"&&b!==null&&(I=Object.keys(b).length>0?Object.keys(b).length:1),x=x*I}}}$t.trackEvent({event_type:"parameter_debug_apply",message_type:"parameter_debug",message_id:f,data:{workflow:(await r.graphToPrompt()).output,selected_params:d[l].params,all_params:u,count:x}});const w=d[l].params;w.nodeParams&&(Object.entries(w.nodeParams).forEach(([N,_])=>{const b=r.graph._nodes_by_id[N];!b||!b.widgets||Object.entries(_).forEach(([I,P])=>{for(const O of b.widgets)if(O.name===I){O.value=P;break}})}),r.graph.setDirtyCanvas(!1,!0),h(!0),setTimeout(()=>{h(!1)},3e3))}},Lm=(l,d,r,f,u,h,p)=>{if(p&&(p.preventDefault(),p.stopPropagation()),l===1&&r!==void 0){const x=[...d];x[r],x.splice(r,1),x.length===0?u&&(f({type:"SET_SCREEN_STATE",payload:null}),h(!0),u()):f({type:"SET_SELECTED_NODE",payload:x});return}u&&(f({type:"SET_SCREEN_STATE",payload:null}),h(!0),u())},Om=({selectedNodes:l,visible:d,onClose:r})=>{const[f,u]=E.useState(0),[h,p]=E.useState({Steps:!0,CFG:!0,sampler_name:!0,threshold:!1,prompt:!1}),[x,w]=E.useState(qe()),[N,_]=E.useState(!1),[b,I]=E.useState(!1),[P,O]=E.useState(0),[G,q]=E.useState(12),[F,D]=E.useState(null),[B,C]=E.useState(()=>Array(12).fill(null).map((T,W)=>({url:`https://source.unsplash.com/random/300x300?sig=${Math.random()}`,params:{step:W%3===0?5:W%3===1?10:15,sampler_name:"euler",cfg:1}}))),[M,z]=E.useState({}),[V,je]=E.useState({}),[U,ae]=E.useState({}),[ge,R]=E.useState({}),[xe,le]=E.useState(1),se=6,[ve,Q]=E.useState(null),[K,ce]=E.useState(!1),[J,Z]=E.useState(!1),[ye,ke]=E.useState(""),[Oe,Ie]=E.useState(null),[Be,rt]=E.useState({}),[gt,lt]=E.useState(!1),[Ge,pt]=E.useState(""),[Mt,Bt]=E.useState([]),[Xe,st]=E.useState(!1),[en,ct]=E.useState(""),[gn,kn]=E.useState(""),[Gt,Ze]=E.useState(null),[Lt,Ot]=E.useState({}),[Y,re]=E.useState(!1),[we,_e]=E.useState([]),[Fe,Me]=E.useState(null),{dispatch:Te}=En(),Pe=E.useRef(null),Je=E.useRef(null),[Tt,_t]=E.useState(()=>d);E.useEffect(()=>{if(Y){const T=kl();_e(T)}},[Y]);const Kn=async()=>{jm(Ge,x,st,Ze,Bt,Ot)},qn=(T,W,Ee,et)=>{const rn=im(T,W,Ee,et,Be,rt);tn(T,W,rn)},Jn=(T,W)=>{const Ee=om(T,W,Be,rt);tn(T,W,Ee)},ps=(T,W,Ee)=>{const et=am(T,W,Ee,Be,rt);tn(T,W,et)},ms=T=>{Em(T,Ot)},xs=()=>{Cm(en,gn,Lt,Mt,Ge,x,Be,rt,tn,lt)},yr=(T,W)=>{km(T,W,lt,ct,kn,pt,Bt,Ot,st,Ze)},Yn=T=>{T&&(T.preventDefault(),T.stopPropagation()),re(W=>!W)},vs=T=>{Me(T),re(!1),C(T.generatedImages||[]),D(null),le(1)},ys=T=>{T&&(T.preventDefault(),T.stopPropagation()),Me(null)};E.useEffect(()=>{if(!l||l.length===0)return;const T={...M},W=l.map(et=>et.id.toString());Object.keys(T).forEach(et=>{W.includes(et)||delete T[et]}),l.forEach(et=>{const rn=et.id.toString();T[rn]||(T[rn]={})}),JSON.stringify(T)!==JSON.stringify(M)&&z(T)},[l,M]),E.useEffect(()=>{Te({type:"SET_SCREEN_STATE",payload:{currentScreen:f,isProcessing:N,isCompleted:b}})},[f,N,b,Te]),E.useEffect(()=>{const T=document.createElement("style");return T.textContent=nm,document.head.appendChild(T),()=>{document.head.removeChild(T)}},[]),E.useEffect(()=>{const T=W=>{if(Object.values(V).some(Ee=>Ee)){const Ee=W.target,et=!!Ee.closest(".dropdown-menu"),rn=!!Ee.closest("[data-dropdown]");!et&&!rn&&je({})}};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[V]),E.useEffect(()=>{d&&(JSON.parse(localStorage.getItem(xr)||"{}").task_id||w(qe()))},[d]),E.useEffect(()=>{if(d){_t(!0);try{const T=localStorage.getItem(xr);if(T){const W=JSON.parse(T);if(!l||l.length===0){console.log("Not restoring parameter debug state: no nodes selected"),_t(!1);return}W.currentScreen!==void 0&&u(W.currentScreen),W.selectedParams&&p(W.selectedParams),W.task_id&&w(W.task_id);const Ee=W.generatedImages&&W.generatedImages.length>0;W.isProcessing!==void 0&&!W.isProcessing&&_(!1),W.isCompleted!==void 0&&Ee&&I(W.isCompleted),W.completedCount!==void 0&&O(W.completedCount),W.totalCount!==void 0&&q(W.totalCount),W.selectedImageIndex!==void 0&&D(W.selectedImageIndex),W.generatedImages&&C(W.generatedImages),W.paramTestValues&&z(W.paramTestValues),W.searchTerms&&ae(W.searchTerms),W.inputValues&&R(W.inputValues),W.currentPage!==void 0&&le(W.currentPage),W.textInputs&&rt(W.textInputs)}}catch(T){console.error("Error loading parameter debug state:",T)}finally{setTimeout(()=>{_t(!1)},50)}}else _t(!0);return()=>{if(!d)return;bl({currentScreen:f,selectedParams:h,task_id:x,isProcessing:N,isCompleted:b,completedCount:P,totalCount:G,selectedImageIndex:F,generatedImages:B,paramTestValues:M,searchTerms:U,inputValues:ge,currentPage:xe,textInputs:Be})}},[d]);const bs=(T=!1)=>{Am(u,p,w,Vn,_,I,O,q,D,C,z,je,ae,R,le,Q,ce,Z,ke,Ie,rt,lt,pt,Bt,st,ct,kn,Ze,Ot,T),re(!1),Me(null)};E.useEffect(()=>{if(!d)return;const T=setTimeout(()=>{bl({currentScreen:f,selectedParams:h,task_id:x,isProcessing:N,isCompleted:b,completedCount:P,totalCount:G,selectedImageIndex:F,generatedImages:B,paramTestValues:M,searchTerms:U,inputValues:ge,currentPage:xe,textInputs:Be})},500);return()=>clearTimeout(T)},[d,f,h,x,N,b,P,G,F,B,M,U,ge,xe,Be]);const br=T=>{mm(f,u,h,M,z,Be,l,q,Q,Di,T)},An=T=>{xm(f,u,l,M,z,Be,b,I,Q,T)},ws=(T,W)=>{hm(T,h,p,M,z,W)},_s=(T,W,Ee)=>{lm(T,W,Ee,V,je)},tn=(T,W,Ee)=>{cm(T,W,Ee,M,z)},Xn=(T,W,Ee,et)=>{um(T,W,Ee,M,z,et)},Ss=(T,W,Ee)=>{dm(T,W,Ee,U,ae)},Zn=(T,W,Ee)=>{fm(T,W,Ee,M,tn)},wr=(T,W)=>{vm(T,se,B,le,W)},Vn=()=>{Ml(Pe,Je)};E.useEffect(()=>()=>{Vn()},[]);const Ns=async(T,W)=>{Nm(M,x,_,O,Q,C,I,le,Je,Pe,Di,We,T,W)},_r=(T,W)=>{Im(T,D,W)},Sr=(T,W,Ee)=>{gm(T,W,l,ke,Ie,Z,Ee)},pn=T=>{pm(Z,T)},js=async T=>{Mm(F,B,We,x,M,ce,T)},nn=(T,W)=>{Lm(f,l,W,Te,r,bs,T)},mn=()=>i.jsx(i.Fragment,{children:i.jsx(mr,{visible:J,imageUrl:ye,params:Oe||{},onClose:pn})});return Fe?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:i.jsx(tm,{historyItem:Fe,selectedImageIndex:F,handleSelectImage:_r,handleClose:ys,currentPage:xe,handlePageChange:wr,imagesPerPage:se,modalVisible:J,modalImageUrl:ye,modalImageParams:Oe,openImageModal:Sr,closeImageModal:pn})}):Y?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:i.jsx(em,{historyItems:we,onViewHistoryItem:vs,onClose:Yn})}):Tt&&d&&l.length>0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:T=>T.stopPropagation(),children:[i.jsxs("div",{className:"p-8 rounded-lg shadow-sm relative flex flex-col items-center",children:[i.jsx("div",{className:"w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin"}),i.jsx("div",{className:"mt-4 text-gray-600 text-sm",children:"Loading interface..."})]}),i.jsx(mr,{visible:J,imageUrl:ye,params:Oe||{},onClose:pn})]}):!d||l.length===0?i.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gray-50 overflow-y-auto",onClick:T=>T.stopPropagation(),children:[i.jsxs("div",{className:"max-w-lg p-8 rounded-lg shadow-sm border border-blue-100 relative",children:[i.jsxs("div",{className:"absolute top-3 right-3 flex",children:[i.jsx("button",{className:"text-blue-500 hover:text-blue-700 mr-2",onClick:Yn,title:"Show History",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z",clipRule:"evenodd"})})}),i.jsx("button",{className:"text-gray-400 hover:text-gray-600",onClick:nn,children:i.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{className:"mb-6 text-center",children:[i.jsx("h3",{className:"text-base font-bold text-blue-600 mb-2",children:"GenLab"}),i.jsx("div",{className:"h-1 w-16 bg-blue-500 mx-auto rounded-full mb-4"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"text-left mb-4",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-800 mb-3",children:"Batch-test parameters & find the best combo in one click."}),i.jsx("div",{className:"h-px w-full bg-gray-200 my-4"})]}),i.jsxs("div",{className:"text-left",children:[i.jsx("h4",{className:"text-base font-medium text-gray-800 mb-4",children:"How to use"}),i.jsxs("div",{className:"space-y-2 mb-4",children:[i.jsxs("p",{className:"text-sm text-gray-700",children:[i.jsx("span",{className:"font-bold",children:"1 - "}),"Click any node(hold Shift to select multiple nodes)"]}),i.jsxs("p",{className:"text-sm text-gray-700",children:[i.jsx("span",{className:"font-bold",children:"2 - "}),"Set parameter ranges and start batch generation."]})]}),i.jsx("div",{className:"h-px w-full bg-gray-200 my-4"}),i.jsx("p",{className:"text-sm text-blue-600 mt-6",children:"Let's select a node to begin!"})]})]})]}),i.jsx(mr,{visible:J,imageUrl:ye,params:Oe||{},onClose:pn})]}):b?i.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:i.jsx(Zp,{generatedImages:B,selectedImageIndex:F,handleSelectImage:_r,handleApplySelected:js,handlePrevious:An,handleClose:nn,currentPage:xe,handlePageChange:wr,imagesPerPage:se,notificationVisible:K,modalVisible:J,modalImageUrl:ye,modalImageParams:Oe,openImageModal:Sr,closeImageModal:pn})}):N?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4",onClick:T=>T.stopPropagation(),children:[i.jsx(Wp,{selectedNodes:l,paramTestValues:M,selectedParams:h,totalCount:G,completedCount:P,errorMessage:ve,handleClose:nn,setIsProcessing:_,setCurrentScreen:u,cleanupPolling:Vn}),i.jsx(mn,{})]}):f===0?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[i.jsx(Pp,{selectedNodes:l,handleParamSelect:ws,selectedParams:h,handleNext:br,handleClose:nn}),i.jsx(mn,{})]}):f===1?i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[i.jsx(Rp,{selectedNodes:l,paramTestValues:M,selectedParams:h,updateParamTestValues:tn,toggleDropdown:_s,openDropdowns:V,handleTestValueSelect:Xn,searchTerms:U,handleSearch:Ss,handleSelectAll:Zn,handleNext:br,handlePrevious:An,handleClose:nn,inputValues:ge,setInputValues:R,textInputs:Be,handleTextInputChange:qn,handleAddTextInput:Jn,handleRemoveTextInput:ps,openAiWritingModal:yr}),i.jsx(Vp,{visible:gt,aiWritingModalText:Ge,setAiWritingModalText:pt,aiGeneratedTexts:Mt,aiSelectedTexts:Lt,aiWritingLoading:Xe,aiWritingError:Gt,handleAiWriting:Kn,toggleTextSelection:ms,addSelectedTexts:xs,onClose:()=>lt(!1)}),i.jsx(mn,{})]}):i.jsxs("div",{className:"flex-1 overflow-y-auto bg-gray-50 p-4 flex flex-col h-full max-h-[80vh]",onClick:T=>T.stopPropagation(),children:[i.jsx(Dp,{selectedNodes:l,paramTestValues:M,selectedParams:h,totalCount:G,errorMessage:ve,handlePrevious:An,handleStartGeneration:Ns,handleClose:nn}),i.jsx(mn,{})]})},Tm=l=>{const{dispatch:d}=En(),[r,f]=E.useState(!1);return E.useEffect(()=>{if(l.visible&&!r){const u=rm();u&&u.screenState&&d({type:"SET_SCREEN_STATE",payload:{currentScreen:u.currentScreen,isProcessing:u.isProcessing,isCompleted:u.isCompleted}}),f(!0)}},[l.visible,r,d]),E.useEffect(()=>()=>{l.visible||d({type:"SET_SCREEN_STATE",payload:null})},[l.visible,d]),i.jsx(Om,{...l})},Pm=({message:l,onClose:d})=>l?i.jsxs("div",{className:`bg-gradient-to-r from-gray-50 to-gray-100
border border-gray-300 px-2 py-1 mt-2 ml-2 mr-2 relative shadow-sm rounded-sm`,children:[i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"flex-shrink-0 mr-1",children:i.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:i.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),i.jsx("div",{className:"text-gray-700 font-medium leading-relaxed pr-6 markdown-content",style:{fontSize:"11px"},children:i.jsx(Yg,{rehypePlugins:[[Ug,{target:"_blank",rel:["noopener","noreferrer"]}]],remarkPlugins:[zg],className:"prose !text-[11px] prose-a:text-gray-700 prose-a:underline prose-a:font-medium hover:prose-a:text-gray-800",components:{a:({node:r,...f})=>i.jsx("a",{...f,className:"text-gray-700 underline hover:text-gray-800 transition-colors",style:{fontSize:"11px"}}),p:({children:r})=>i.jsx("span",{className:"inline",style:{fontSize:"11px"},children:r}),span:({children:r})=>i.jsx("span",{style:{fontSize:"11px"},children:r}),li:({children:r})=>i.jsx("li",{style:{fontSize:"11px"},children:r}),ul:({children:r})=>i.jsx("ul",{style:{fontSize:"11px"},children:r}),ol:({children:r})=>i.jsx("ol",{style:{fontSize:"11px"},children:r})},children:l})})]}),i.jsx("button",{onClick:d,className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-700 hover:text-gray-800 transition-colors p-1 rounded-full hover:bg-gray-800","aria-label":"Close announcement",children:i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):null,Rm=()=>{const{state:l,dispatch:d}=En(),{selectedNode:r,screenState:f}=l,u=r||[],h=()=>{d({type:"SET_SELECTED_NODE",payload:null}),d({type:"SET_SCREEN_STATE",payload:null}),localStorage.removeItem("screenState")};return i.jsx("div",{className:"flex-1 flex flex-col overflow-y-auto",children:i.jsx(Tm,{selectedNodes:u,visible:!0,onClose:h})})},_l=({active:l,onClick:d,children:r})=>i.jsx("button",{onClick:d,className:`px-4 py-2 font-medium text-xs transition-colors duration-200 border-b-2 ${l?"text-[#71A3F2] border-[#71A3F2]":"text-gray-600 border-transparent hover:!text-[#71A3F2] hover:!border-[#71A3F2]"}`,children:r});function Um({onClose:l,visible:d=!0,triggerUsage:r=!1,onUsageTriggered:f}){const{state:u,dispatch:h}=En(),{messages:p,installedNodes:x,loading:w,sessionId:N,selectedNode:_,activeTab:b,guiding:I}=u;E.useRef(null);const[P,O]=E.useState(""),[G,q]=E.useState(""),[F,D]=E.useState(window.innerWidth/3),[B,C]=E.useState(!1),[M,z]=E.useState([]),[V,je]=E.useState("gpt-4o-mini"),[U,ae]=E.useState(window.innerHeight),[ge,R]=E.useState(0),[xe,le]=E.useState(""),[se,ve]=E.useState(!1),Q=E.useRef(null);E.useRef(_);const[K,ce]=E.useState("None");Op(d&&b==="chat"),Tp(d),E.useEffect(()=>{switch(K){case"Usage":Mt();break;case"Parameters":Bt();break;case"DownstreamNodes":st();break}ce("None")},[K]),E.useEffect(()=>{if(b!=="chat")return;(async()=>{const re=await kp();console.log("[WorkflowChat] Received installed nodes:",re.length),h({type:"SET_INSTALLED_NODES",payload:re})})()},[b]);const J=()=>{h({type:"SET_GUIDING",payload:!0}),h({type:"SET_MESSAGES",payload:[{id:qe(),role:"question_title",content:""}]})},Z=async Y=>{try{const re=await $t.fetchMessages(Y);re?.length>0?h({type:"SET_MESSAGES",payload:re}):J()}catch(re){console.error("Error fetching messages:",re)}};E.useEffect(()=>{if(b!=="chat")return;let Y=localStorage.getItem("sessionId");Y?(h({type:"SET_SESSION_ID",payload:Y}),Z(Y)):(Y=qe(),h({type:"SET_SESSION_ID",payload:Y}),localStorage.setItem("sessionId",Y))},[b]),E.useEffect(()=>{const Y=localStorage.getItem("activeTab");Y&&h({type:"SET_ACTIVE_TAB",payload:Y});const re=localStorage.getItem("screenState");re&&h({type:"SET_SCREEN_STATE",payload:JSON.parse(re)});const we=()=>{ce("Usage")},_e=()=>{ce("Parameters")},Fe=()=>{ce("DownstreamNodes")};return window.addEventListener(Gn.TOOLBOX_USAGE,we),window.addEventListener(Gn.TOOLBOX_PARAMETERS,_e),window.addEventListener(Gn.TOOLBOX_DOWNSTREAMNODES,Fe),()=>{window.removeEventListener(Gn.TOOLBOX_USAGE,we),window.removeEventListener(Gn.TOOLBOX_PARAMETERS,_e),window.removeEventListener(Gn.TOOLBOX_DOWNSTREAMNODES,Fe)}},[]),E.useEffect(()=>{localStorage.setItem("activeTab",b)},[b]),E.useEffect(()=>{u.screenState&&localStorage.setItem("screenState",JSON.stringify(u.screenState))},[u.screenState]);const ye=pr.useCallback(Y=>{if(!B)return;const re=window.innerWidth-Y.clientX,we=Math.min(Math.max(300,re),window.innerWidth*.8);D(we)},[B]),ke=pr.useMemo(()=>Wi.debounce(ye,16),[ye]);E.useEffect(()=>(B&&(document.addEventListener("mousemove",ke),document.addEventListener("mouseup",gn)),()=>{document.removeEventListener("mousemove",ke),document.removeEventListener("mouseup",gn),ke.cancel()}),[B,ke]);const Oe=Y=>{O(Y.target.value)},Ie=()=>{Q.current&&(Q.current.abort(),Q.current=null,h({type:"SET_LOADING",payload:!1}))},Be=async()=>{if(I&&(h({type:"SET_GUIDING",payload:!1}),h({type:"CLEAR_MESSAGES"})),h({type:"SET_LOADING",payload:!0}),P.trim()===""&&!_||!N)return;q(P);const Y=qe(),re={id:qe(),role:"user",content:P,trace_id:Y};h({type:"ADD_MESSAGE",payload:re}),O(""),Q.current=new AbortController;try{const we={type:"model_select",data:[V]};let _e=qe(),Fe=!0;for await(const Me of $t.streamInvokeServer(N,P,M.map(Te=>Te.file),null,we,Y,Q.current.signal)){const Te={id:_e,role:"ai",content:JSON.stringify(Me),format:Me.format,finished:Me.finished,name:"Assistant"};if(Fe)h({type:"ADD_MESSAGE",payload:Te}),Fe=!1;else{h({type:"UPDATE_MESSAGE",payload:Te});const Pe=u.messages.map(Je=>Je.id===Te.id&&!Je.finished?Te:Je);en(Pe)}Me.finished&&(h({type:"SET_LOADING",payload:!1}),Q.current=null)}}catch(we){we instanceof Error&&we.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",we),h({type:"SET_LOADING",payload:!1}),Q.current=null}finally{z([])}},rt=async Y=>{if(!N)return;h({type:"SET_LOADING",payload:!0}),q(Y);const re=qe(),we={id:qe(),role:"user",content:Y,trace_id:re};h({type:"ADD_MESSAGE",payload:we}),Q.current=new AbortController;try{const _e={type:"model_select",data:[V]};let Fe=qe(),Me=!0;for await(const Te of $t.streamInvokeServer(N,Y,M.map(Pe=>Pe.file),null,_e,re,Q.current.signal)){const Pe={id:Fe,role:"ai",content:JSON.stringify(Te),format:Te.format,finished:Te.finished,name:"Assistant"};if(Me)h({type:"ADD_MESSAGE",payload:Pe}),Me=!1;else{h({type:"UPDATE_MESSAGE",payload:Pe});const Je=u.messages.map(Tt=>Tt.id===Pe.id&&!Tt.finished?Pe:Tt);en(Je)}Te.finished&&(h({type:"SET_LOADING",payload:!1}),Q.current=null)}}catch(_e){_e instanceof Error&&_e.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",_e),h({type:"SET_LOADING",payload:!1}),Q.current=null}finally{z([])}},gt=Y=>{Y.metaKey&&Y.key==="Enter"&&Be()},lt=()=>{h({type:"CLEAR_MESSAGES"});const Y=u.sessionId;Y&&localStorage.removeItem(`messages_${Y}`),localStorage.removeItem("sessionId");const re=qe();h({type:"SET_SESSION_ID",payload:re}),localStorage.setItem("sessionId",re),setTimeout(()=>{J()},500)},Ge=Y=>{O(Y)},pt=async(Y,re)=>{if(!N||!_)return;h({type:"SET_LOADING",payload:!0});const we=_[0].comfyClass||_[0].type,_e=qe(),Fe={id:qe(),role:"user",content:we,trace_id:_e};h({type:"ADD_MESSAGE",payload:Fe}),Q.current=new AbortController;try{let Me=qe(),Te=!0;for await(const Pe of $t.streamInvokeServer(N,we,[],Y,re,_e,Q.current.signal)){const Je={id:Me,role:"ai",content:JSON.stringify(Pe),format:Pe.format,finished:Pe.finished,name:"Assistant"};if(Y&&Y!==""&&(Je.metadata={intent:Y}),Te)h({type:"ADD_MESSAGE",payload:Je}),Te=!1;else{h({type:"UPDATE_MESSAGE",payload:Je});const Tt=u.messages.map(_t=>_t.id===Je.id&&!_t.finished?Je:_t);en(Tt)}Pe.finished&&(h({type:"SET_LOADING",payload:!1}),Q.current=null)}}catch(Me){Me instanceof Error&&Me.name==="AbortError"?console.log("User aborted the request"):console.error("Error sending message:",Me),h({type:"SET_LOADING",payload:!1}),Q.current=null}},Mt=()=>{rt(`Reply in ${navigator.language} language: How does the ${_?.[0]?.type} node work? I need its official usage guide.`)},Bt=()=>{rt(`Reply in ${navigator.language} language: Show me the technical specifications for the ${_?.[0].type} node's inputs and outputs.`)},Xe=()=>{const Y=new Set;function re(we,_e){if(!(!we||_e>=1)&&we.inputs)for(const Fe of Object.values(we.inputs)){const Me=Fe.link;if(Me&&We.graph.links[Me]){const Te=We.graph.links[Me].origin_id,Pe=We.graph._nodes_by_id[Te];Pe&&(Y.add(Pe.type),re(Pe,_e+1))}}}return _[0]?(re(_[0],0),[{type:"upstream_node_types",data:Array.from(Y)}]):null},st=()=>{pt("downstream_subgraph_search",Xe())},en=Y=>{u.sessionId&&localStorage.setItem(`messages_${u.sessionId}`,JSON.stringify(Y))},ct=Y=>{console.log("[WorkflowChat] Adding new message:",Y);const re=[...u.messages,Y];h({type:"ADD_MESSAGE",payload:Y}),en(re)},gn=()=>{C(!1)},kn=Y=>{const re=Array.from(Y).map(we=>({id:Math.random().toString(36).substr(2,9),file:we,preview:URL.createObjectURL(we)}));z(we=>[...we,...re])},Gt=Y=>{z(re=>re.filter(_e=>_e.id!==Y))};pr.useEffect(()=>()=>{M.forEach(Y=>URL.revokeObjectURL(Y.preview))},[M]),E.useEffect(()=>{r&&f&&b==="chat"&&(pt("node_explain"),f())},[r,b]),E.useEffect(()=>{if(!d||b!=="chat")return;(async()=>{try{const re=new Date().toDateString();if(localStorage.getItem("announcementLastShownDate")!==re){const _e=await $t.fetchAnnouncement();_e&&_e.trim()!==""&&(le(_e),ve(!0),localStorage.setItem("announcementLastShownDate",re))}}catch(re){console.error("Error fetching announcement:",re)}})()},[d,b]);const Ze=()=>{ve(!1)},Lt=Y=>{h({type:"SET_ACTIVE_TAB",payload:Y})},Ot=pr.useMemo(()=>i.jsx(Rm,{}),[]);return d?i.jsxs("div",{className:"flex flex-col h-full w-full bg-white relative",style:{display:d?"flex":"none"},children:[i.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-gray-300"}),i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsx(gp,{onClose:l,onClear:lt,hasMessages:p.length>0,title:"ComfyUI-Copilot"}),i.jsxs("div",{className:"flex border-b border-gray-200 mt-2",children:[i.jsx(_l,{active:b==="chat",onClick:()=>Lt("chat"),children:"Chat"}),i.jsx(_l,{active:b==="parameter-debug",onClick:()=>Lt("parameter-debug"),children:"GenLab"})]}),se&&xe&&b==="chat"&&i.jsx(Pm,{message:xe,onClose:Ze}),i.jsx(Ep,{messages:p,latestInput:G,onOptionClick:Ge,installedNodes:x,onAddMessage:ct,loading:w,isActive:b==="chat"}),i.jsx("div",{className:"border-t px-4 py-3 border-gray-200 bg-white sticky bottom-0",style:{display:b==="chat"?"block":"none"},children:i.jsx(mp,{input:P,loading:w,onChange:Oe,onSend:Be,onKeyPress:gt,onUploadImages:kn,uploadedImages:M,onRemoveImage:Gt,selectedModel:V,onModelChange:je,onStop:Ie})}),i.jsx("div",{className:"flex-1 flex flex-col h-0",style:{display:b==="parameter-debug"?"flex":"none"},children:Ot})]})]}):null}export{Um as default};