import{i as e,n as t,t as n}from"./jsx-runtime-CXrijb2r.js";var r=e(t(),1),i=n();function a(e){return e?new Date(e).toLocaleString():`—`}function o({projects:e,activeProjectId:t,sessionPromptSettings:n,onSelectProject:o,onSaveSessionPromptTemplate:s}){let[c,l]=(0,r.useState)(``),u=(0,r.useMemo)(()=>e.find(e=>e.id===t)??null,[t,e]),d=u?.slug===n?.projectSlug?n:null,f=e.length>0;return(0,r.useEffect)(()=>{l(d?.template??``)},[d?.template]),(0,i.jsxs)(`section`,{className:`panel prompting-panel`,children:[(0,i.jsx)(`div`,{className:`panel__header panel__header--stacked`,children:(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`p`,{className:`eyebrow`,children:`Prompting`}),(0,i.jsx)(`h3`,{children:`Task session context prompt`})]})}),(0,i.jsxs)(`section`,{className:`task-section task-section--compact`,"data-role":`prompting-project-scope`,children:[(0,i.jsx)(`div`,{className:`task-section__header`,children:(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`p`,{className:`eyebrow`,children:`Project scope`}),(0,i.jsx)(`h4`,{children:u?.name??(f?`Select a project`:`No projects available`)})]})}),(0,i.jsxs)(`label`,{className:`field-group`,children:[(0,i.jsx)(`span`,{className:`field-group__label`,children:`Project`}),(0,i.jsxs)(`select`,{className:`select-input`,"data-role":`prompting-project-select`,value:t??``,disabled:!f,onChange:e=>{e.target.value&&o(e.target.value)},children:[t?null:(0,i.jsx)(`option`,{value:``,children:`Select a project`}),e.map(e=>(0,i.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,i.jsx)(`span`,{className:`field-group__hint`,children:f?u?`Prompting settings are saved per project. Switch projects here to edit ${u.name} or another project's task-session prompt.`:`Prompting settings are saved per project. Select a project here to load its task-session prompt.`:`Create a project to edit prompting settings.`})]})]}),d?(0,i.jsxs)(`section`,{className:`task-section task-section--compact`,children:[(0,i.jsxs)(`div`,{className:`task-section__header`,children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`p`,{className:`eyebrow`,children:`Template`}),(0,i.jsx)(`h4`,{children:`Prompt template`})]}),(0,i.jsxs)(`div`,{className:`action-cluster action-cluster--wrap`,children:[(0,i.jsx)(`button`,{className:`secondary-button`,"data-role":`reset-session-prompt-template`,type:`button`,onClick:()=>l(d.defaultTemplate),children:`Reset draft to default`}),(0,i.jsx)(`button`,{className:`secondary-button`,"data-role":`save-session-prompt-template`,type:`button`,onClick:()=>s(c),children:`Save template`})]})]}),(0,i.jsxs)(`label`,{className:`field-group`,children:[(0,i.jsx)(`span`,{className:`field-group__label`,children:`Prompt template`}),(0,i.jsx)(`textarea`,{className:`text-area general-panel__prompt-template`,"data-role":`session-prompt-template`,rows:14,value:c,onChange:e=>l(e.target.value)})]}),(0,i.jsxs)(`p`,{className:`muted-copy`,children:[`Last updated: `,a(d.updatedAt)]}),(0,i.jsx)(`div`,{className:`bridge-diagnostics-table-wrap`,children:(0,i.jsxs)(`table`,{className:`task-table`,"data-role":`session-prompt-token-table`,children:[(0,i.jsx)(`thead`,{children:(0,i.jsxs)(`tr`,{children:[(0,i.jsx)(`th`,{children:`Token`}),(0,i.jsx)(`th`,{children:`Description`})]})}),(0,i.jsx)(`tbody`,{children:d.availableTokens.map(e=>(0,i.jsxs)(`tr`,{"data-role":`session-prompt-token-row`,children:[(0,i.jsx)(`td`,{children:(0,i.jsx)(`code`,{children:e.token})}),(0,i.jsx)(`td`,{children:e.description})]},e.token))})]})})]}):(0,i.jsx)(`p`,{className:`supporting-copy`,"data-role":`prompting-project-status`,children:u?`Loading prompting settings for ${u.name}.`:f?`Select a project to edit prompting settings.`:`Create a project to edit prompting settings.`})]})}export{o as PromptingPanel};