UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

1 lines 3.43 kB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7259],{1287:(e,a,s)=>{Promise.resolve().then(s.bind(s,4302))},3660:e=>{e.exports={fileList:"SettingsSection_fileList__74JVN",headerInfo:"SettingsSection_headerInfo__G2cJ7",unsaved:"SettingsSection_unsaved__g_vV1",editor:"SettingsSection_editor__HeKvz",placeholder:"SettingsSection_placeholder__MHotH"}},4302:(e,a,s)=>{"use strict";s.r(a),s.d(a,{default:()=>g});var n=s(5155),t=s(3330),c=s(64),l=s(4653),r=s(7565),i=s(8720),d=s(3660),o=s.n(d),p=s(1241),u=s(7883),h=s(5695),f=s(5729),x=s(2115),m=s(838);function v(){let e=(0,h.useRouter)(),a=(0,h.useSearchParams)(),s=a.get("tab")||"preferences",d=a.get("file"),{enqueueSnackbar:v}=(0,f.dh)(),[g,b]=(0,x.useState)(""),[j,_]=(0,x.useState)(!1),[k,C]=(0,x.useState)(!1),{data:S}=(0,m.Ay)("preferences",p.FH.getPreferences),{data:y}=(0,m.Ay)("examples",p.FH.getExamples),H=(0,x.useCallback)(async(e,a)=>{try{let s;b(""),"preferences"===a?s=await p.FH.getPreference(e):"examples"===a&&(s=await p.FH.getExample(e)),b((null==s?void 0:s.content)||""),C(!1)}catch(e){b("Failed to load content")}},[]);(0,x.useEffect)(()=>{d&&s&&H(d,s)},[d,s,H]);let N=(0,x.useCallback)(a=>{e.push("/preferences?tab=".concat(a))},[e]),F=(0,x.useCallback)(a=>{e.push("/preferences?tab=".concat(s,"&file=").concat(encodeURIComponent(a)))},[e,s]),E=(0,x.useCallback)(e=>{b(e),C(!0)},[]),w=(0,x.useCallback)(async()=>{if(d){_(!0);try{"preferences"===s?await p.FH.updatePreference(d,g):"examples"===s&&await p.FH.updateExample(d,g),C(!1),v("".concat(s.slice(0,-1).charAt(0).toUpperCase()+s.slice(1,-1)," saved successfully"),{variant:"success"})}catch(e){v("Failed to save ".concat(s.slice(0,-1)),{variant:"error"})}finally{_(!1)}}},[d,s,g,v]),P=(0,x.useCallback)(()=>{N("preferences")},[N]),A=(0,x.useCallback)(()=>{N("examples")},[N]),I=(0,x.useCallback)(e=>()=>F(e),[F]),L=(0,x.useCallback)(()=>{w().catch(()=>{})},[w]),M="preferences"===s?S||[]:"examples"===s&&y||[],U=(0,n.jsxs)(r.a,{children:[(0,n.jsx)(r.o,{onClick:P,active:"preferences"===s,children:"Preferences"}),(0,n.jsx)(r.o,{onClick:A,active:"examples"===s,children:"Examples"})]}),z=(0,n.jsx)("div",{className:o().fileList,children:M.map(e=>{let a="string"==typeof e?e:e.file,s="string"==typeof e?e:e.name||e.file,t="object"==typeof e?e.description:void 0;return(0,n.jsx)(i.H,{icon:u.A4h,title:s,description:t,selected:d===a,onClick:I(a)},a)})});return(0,n.jsx)(l.M,{title:"Your Preferences",subtitle:"Manage preferences your prefrences and examples",variant:"sidebar",sidebarHeader:U,sidebarContent:z,children:d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:o().header,children:[(0,n.jsxs)("div",{className:o().headerInfo,children:[(0,n.jsx)("h2",{children:d}),k?(0,n.jsx)("span",{className:o().unsaved,children:"• Unsaved changes"}):null]}),(0,n.jsx)(t.$,{onClick:L,disabled:j||!k,variant:"primary",size:"medium",children:j?"Saving...":"Save"})]}),(0,n.jsx)("div",{className:o().editor,children:(0,n.jsx)(c.B,{value:g,onChange:E,language:d.endsWith(".json")?"json":"markdown",height:"100%"})})]}):(0,n.jsx)("div",{className:o().placeholder,style:{background:"none"},children:(0,n.jsx)("p",{children:"Select a file to edit"})})})}function g(){return(0,n.jsx)(x.Suspense,{fallback:(0,n.jsx)("div",{className:o().loading,children:"Loading..."}),children:(0,n.jsx)(v,{})})}}},e=>{e.O(0,[2403,6750,1919,838,5729,6874,3044,2112,8441,5964,7358],()=>e(e.s=1287)),_N_E=e.O()}]);