1import{r as d,j as e,p as g,e as w,a4 as v,i as N,ad as C,c as h}from"../index.js";import{C as f}from"./communityHub-aba61686.js";import{C as L}from"./index-ced7b2a1.js";import{a as A,r as p,b}from"./index-586359a4.js";import"./truncate-65acbd89.js";const H={createdByMe:{agentSkills:{items:[]},systemPrompts:{items:[]},slashCommands:{items:[]},agentFlows:{items:[]}},teamItems:[]};function I({connectionKey:i}){const[r,c]=d.useState(!0),[n,o]=d.useState(H);return d.useEffect(()=>{(async()=>{if(console.log("fetching user items",i),!!i){c(!0);try{const{success:s,createdByMe:t,teamItems:a}=await f.fetchUserItems();s&&o({createdByMe:t,teamItems:a})}catch(s){console.error("Error fetching user items:",s)}finally{c(!1)}}})()},[i]),{loading:r,userItems:n}}function M({connectionKey:i}){const{loading:r,userItems:c}=I({connectionKey:i}),{createdByMe:n={},teamItems:o=[]}=c||{};if(r)return e.jsx(A,{});const l=s=>Object.values(s).some(t=>{var a;return((a=t==null?void 0:t.items)==null?void 0:a.length)>0});return e.jsxs("div",{className:"flex flex-col gap-y-8",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Created by me"}),e.jsx("a",{href:g.communityHub.noPrivateItems(),target:"_blank",rel:"noreferrer",className:"text-primary-button hover:text-primary-button/80 text-sm",children:"Why can't I see my private items?"})]}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Items you have created and shared publicly on the AnythingLLM Community Hub."}),e.jsxs("div",{className:"flex flex-col gap-4 mt-4",children:[Object.keys(n).map(s=>{var t,a;return(a=(t=n[s])==null?void 0:t.items)!=null&&a.length?e.jsxs("div",{className:"rounded-lg w-full",children:[e.jsx("h3",{className:"text-white capitalize font-medium mb-3",children:p(s)}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:n[s].items.map(u=>e.jsx(b,{type:s,item:u},u.id))})]},s):null}),!l(n)&&e.jsx("p",{className:"text-white/60 text-xs text-center mt-4",children:"You haven't created any items yet."})]})]}),e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-white",children:"Items by team"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-white text-opacity-60",children:"Public and private items shared with teams you belong to."}),e.jsx("div",{className:"flex flex-col gap-4 mt-4",children:o.map(s=>e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsx("h3",{className:"text-white text-sm font-medium",children:s.teamName}),Object.keys(s.items).map(t=>{var a,u;return(u=(a=s.items[t])==null?void 0:a.items)!=null&&u.length?e.jsxs("div",{className:"rounded-lg w-full",children:[e.jsx("h3",{className:"text-white capitalize font-medium mb-3",children:p(t)}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:s.items[t].items.map(y=>e.jsx(b,{type:t,item:y},y.id))})]},t):null}),!l(s.items)&&e.jsx("p",{className:"text-white/60 text-xs text-center mt-4",children:"No items shared with this team yet."})]},s.teamId))})]})]})}function S(){const[i,r]=d.useState(""),[c,n]=d.useState(!1),[o,l]=d.useState(""),[s,t]=d.useState(!0);async function a(){l(i),n(!1)}async function u(m){const x=m.target.value;l(x),n(!0)}async function y(){if(o!==i){t(!0);try{if(!(await f.updateSettings({hub_api_key:o})).success)return h("Failed to save API key","error");n(!1),h("API key saved successfully","success"),r(o)}catch(m){console.error(m),h("Failed to save API key","error")}finally{t(!1)}}}async function j(){t(!0);try{if(!(await f.updateSettings({hub_api_key:""})).success)return h("Failed to disconnect from hub","error");n(!1),h("Disconnected from AnythingLLM Community Hub","success"),r(""),l("")}catch(m){console.error(m),h("Failed to disconnect from hub","error")}finally{t(!1)}}return d.useEffect(()=>{(async()=>{t(!0);try{const{connectionKey:x}=await f.getSettings();r(x||""),l(x||"")}catch(x){console.error("Error fetching data:",x)}finally{t(!1)}})()},[]),{connectionKey:o,originalConnectionKey:i,loading:s,onConnectionKeyChange:u,updateConnectionKey:y,hasChanges:c,resetChanges:a,disconnectHub:j}}function D(){const{connectionKey:i,originalConnectionKey:r,loading:c,onConnectionKeyChange:n,updateConnectionKey:o,hasChanges:l,resetChanges:s,disconnectHub:t}=S();return c?e.jsx(w,{}):e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg
1-container flex",children:[e.jsx(v,{}),e.jsx(L,{showing:l,onSave:o,onCancel:s}),e.jsx("div",{style:{height:N?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[86px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white light:border-theme-sidebar-border border-b-2 border-opacity-10",children:[e.jsx("div",{className:"items-center",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Your AnythingLLM Community Hub Account"})}),e.jsxs("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:["Connecting your AnythingLLM Community Hub account allows you to access your ",e.jsx("b",{children:"private"})," AnythingLLM Community Hub items as well as upload your own items to the AnythingLLM Community Hub."]})]}),!i&&e.jsx("div",{className:"border border-theme-border my-2 flex flex-col md:flex-row md:items-center gap-x-2 text-theme-text-primary mb-4 bg-theme-settings-input-bg w-1/2 rounded-lg px-4 py-2",children:e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsxs("div",{className:"gap-x-2 flex items-center",children:[e.jsx(C,{size:25}),e.jsx("h1",{className:"text-lg font-semibold",children:"Why connect my AnythingLLM Community Hub account?"})]}),e.jsxs("p",{className:"text-sm text-theme-text-secondary",children:["Connecting your AnythingLLM Community Hub account allows you to pull in your ",e.jsx("b",{children:"private"})," items from the AnythingLLM Community Hub as well as upload your own items to the AnythingLLM Community Hub.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("i",{children:"You do not need to connect your AnythingLLM Community Hub account to pull in public items from the AnythingLLM Community Hub."})]})]})}),e.jsx("div",{className:"mt-6 mb-12",children:e.jsxs("div",{className:"flex flex-col w-full max-w-[400px]",children:[e.jsx("label",{className:"text-theme-text-primary text-sm font-semibold block mb-2",children:"AnythingLLM Hub API Key"}),e.jsx("input",{type:"password",value:i||"",onChange:n,className:"border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5",placeholder:"Enter your AnythingLLM Hub API key"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("p",{className:"text-theme-text-secondary text-xs",children:["You can get your API key from your"," ",e.jsx("a",{href:g.communityHub.profile(),className:"underline text-primary-button",children:"AnythingLLM Community Hub profile page"}),"."]}),!!r&&e.jsx("button",{onClick:t,className:"border-none text-red-500 hover:text-red-600 text-sm font-medium transition-colors duration-200",children:"Disconnect"})]})]})}),!!r&&e.jsx("div",{className:"mt-6",children:e.jsx(M,{connectionKey:r})})]})})]})}export{D as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.