.`,A=`You are a helpful assistant that helps users refine GitHub issue descriptions.
Your task is to take the user's input and the current issue body, and improve it.

For the issue body:

${P}

Return your response as a JSON object with "title" and "body" fields. The "title" field should be the same as the current title provided in the context.`;function E({isOpen:e,onClose:l,onGenerate:n,repoOwner:o,repoName:P,title:E,body:D,className:M,onPendingChange:O,onStateChange:B,anchorPosition:U="top",onHeightChange:$,editorRef:H,generateTitle:q=!0}){let[W,z]=(0,_.useState)(""),[G,Q]=(0,_.useState)("initial"),[Y,Z]=(0,_.useState)(""),J=(0,_.useRef)(E),X=(0,_.useRef)(D),ee=(0,_.useRef)(e),el=(0,_.useRef)(E),en=(0,_.useRef)(D),ea=(0,_.useRef)(null),et=(0,_.useRef)(null),ei=(0,_.useRef)(new s.JR([])),es=(0,p.S)(),er=(0,_.useRef)(null),{sendAnalyticsEvent:eo}=(0,c.s)(),ed=(0,_.useRef)(null),eu=(0,_.useRef)(null),ec=(0,_.useMemo)(()=>(0,u.Xl)(),[]),em=(0,m.S)({minHeightLines:1,maxHeightLines:10,elementRef:ed,value:W}),[eg,ep]=(0,_.useState)(void 0);(0,_.useLayoutEffect)(()=>{if(!e)return;let l=H?.current?.inputRef.current;if(!l)return;let n=()=>{let e=eu.current?.offsetParent;if(!e)return;let n=l.getBoundingClientRect(),a=e.getBoundingClientRect();if("top"===U)ep(n.top-a.top);else{let e=parseFloat(getComputedStyle(l).paddingBottom)||0;ep(n.bottom-a.top-e-16)}};n();let a=new ResizeObserver(()=>{n()});return l.parentElement&&a.observe(l.parentElement),eu.current&&a.observe(eu.current),()=>{a.disconnect()}},[U,H,e]),(0,_.useEffect)(()=>{e&&!ee.current&&(J.current=E,X.current=D),ee.current=e},[e,E,D]),(0,_.useEffect)(()=>{B?.(G)},[G,B]);let ey=(0,_.useMemo)(()=>{switch(G){case"initial":return"How can I help you write your issue?";case"suggested":return"I've updated the issue title and description above.";case"error":return S;default:return""}},[G]),{mutate:ef,isPending:ek}=(0,d.n)({mutationFn:async e=>{er.current=new AbortController;let l=`${(0,t._$)().copilotApiOverrideUrl||"https://api.githubcopilot.com"}/chat/completions`,n={Authorization:(await ei.current.getAuthToken()).authorizationHeaderValue,"copilot-integration-id":"copilot-embedded-experience","Content-Type":"application/json"},a=`Current title: ${E||"(empty)"}
Current body: ${D||"(empty)"}

User's request: ${e}`;if(a.length>5e4)throw Error("Input is too large. Please reduce the length of your title, description, or request.");let i={messages:[{role:"system",content:q?w:A},{role:"user",content:a}],model:"gpt-4o-mini",stream:!1,temperature:.3,response_format:{type:"json_schema",json_schema:{name:"issue_content",strict:!0,schema:{type:"object",properties:{title:{type:"string",description:"The improved or generated issue title"},body:{type:"string",description:"The improved or generated issue body/description"}},required:["title","body"],additionalProperties:!1}}}},s=await fetch(l,{method:"POST",headers:n,body:JSON.stringify(i),signal:er.current.signal});if(!s.ok)throw Error(`API request failed with status ${s.status}`);let r=await s.json(),o=r.choices?.[0]?.message?.content;if(!o)throw Error("No content in response");let d=JSON.parse(o);if(!d.body)throw Error("Invalid response structure");return d},onSuccess:(e,l)=>{Q("suggested"),ea.current=e.title,et.current=e.body,n(e.title,e.body),z(""),eo("analytics.click","ISSUE_CREATE_GENERATE_DESCRIPTION_WITH_COPILOT_PANEL",{repoNWO:`${o}/${P}`,hasTitle:!!E,hasExistingDescription:!!D,success:!0}),R()},onError:(e,l)=>{"AbortError"===e.name?Q("initial"):(Q("error"),eo("analytics.click","ISSUE_CREATE_GENERATE_DESCRIPTION_WITH_COPILOT_PANEL",{repoNWO:`${o}/${P}`,hasTitle:!!E,hasExistingDescription:!!D,success:!1,error:e.message}),R(e.message))}}),eh=(0,_.useCallback)(e=>{"accepted"===e?V("accepted"):"discarded"===e?V("discarded"):null!==ea.current||null!==et.current?V("closed_with_changes"):V("closed_without_changes"),z(""),Q("initial"),Z(""),el.current=E,en.current=D,ea.current=null,et.current=null,l()},[l,E,D]),eb=(0,_.useCallback)(()=>{er.current?.abort()},[]),eF=(0,_.useCallback)(()=>{W.trim()&&!ek&&(el.current=E,en.current=D,Z(W),Q("loading"),ef(W))},[W,ek,ef,E,D]),e_=(0,_.useCallback)(async()=>{(null===ea.current||null===et.current||E===ea.current&&D===et.current||await es({title:I,content:v,confirmButtonContent:x,confirmButtonType:"danger",cancelButtonContent:j}))&&(n(J.current,X.current),eh("discarded"))},[n,eh,E,D,es]),eS=(0,_.useCallback)(async()=>{!Y||(null===ea.current||null===et.current||E===ea.current&&D===et.current||await es({title:T,content:C,confirmButtonContent:K,confirmButtonType:"danger",cancelButtonContent:L}))&&(V("retried"),n(el.current,en.current),Q("loading"),ef(Y))},[Y,ef,n,E,D,es]),eI=(0,_.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eF())},[eF]);return((0,_.useEffect)(()=>{e&&ed.current&&ed.current.focus()},[e]),(0,_.useEffect)(()=>{O?.(ek)},[ek,O]),(0,_.useEffect)(()=>()=>{O?.(!1)},[]),(0,_.useEffect)(()=>()=>{er.current?.abort()},[]),(0,_.useLayoutEffect)(()=>{if(!e||!eu.current||!$)return;$(eu.current.getBoundingClientRect().height+16);let l=new ResizeObserver(e=>{for(let l of e)$((l.borderBoxSize?.[0]?.blockSize??l.target.getBoundingClientRect().height)+16)});return l.observe(eu.current),()=>{l.disconnect(),$(0)}},[e,$]),e)?(0,a.jsxs)("div",{ref:eu,className:(0,F.$)("CopilotGenerateDescriptionPanel-module__container__7kV52","top"===U?"CopilotGenerateDescriptionPanel-module__anchorTop__nllFv":"bottom"===U?"CopilotGenerateDescriptionPanel-module__anchorBottom___szpO":void 0,M),style:void 0!==eg?{top:`${eg}px`}:void 0,role:"region","aria-label":"Generate with Copilot",children:[!ek&&(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__closeButtonContainer__UHU4i",children:[ec&&(0,a.jsx)("a",{href:"https://gh.io/write-with-copilot-feedback",target:"_blank",rel:"noopener noreferrer",className:"CopilotGenerateDescriptionPanel-module__staffPillLink__U9Eqx",children:(0,a.jsx)(y.A,{variant:"accent",children:"Staff"})}),(0,a.jsx)(f.K,{"aria-label":"Close",icon:g.XIcon,variant:"invisible",onClick:()=>eh()})]}),ey&&(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__messageRow__Ut7UV",children:[(0,a.jsx)("div",{className:"CopilotGenerateDescriptionPanel-module__iconContainer__jDLfX",children:(0,a.jsx)(g.CopilotIcon,{size:16})}),(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__messageContent___SkJ6",children:[(0,a.jsx)("div",{className:"CopilotGenerateDescriptionPanel-module__messageLabel__iK0jz",children:(0,a.jsx)("span",{children:"Copilot"})}),ey===S?(0,a.jsx)("div",{className:"CopilotGenerateDescriptionPanel-module__errorContainer__VYisb",children:(0,a.jsxs)(k.A,{variant:"danger",children:[(0,a.jsx)(g.AlertIcon,{}),ey]})}):(0,a.jsx)("div",{className:"CopilotGenerateDescriptionPanel-module__messageText__Y_Pr3",children:(0,a.jsx)("span",{children:ey})})]})]}),ek&&(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__loadingContainer__a4IX7","aria-live":"polite","aria-atomic":"true",role:"status",children:[(0,a.jsx)(i.N,{animationType:i.L.Thinking,loopAnimation:!0,size:20}),(0,a.jsx)("span",{className:"CopilotGenerateDescriptionPanel-module__loadingLabel__y8mbJ",children:"Copilot"}),(0,a.jsx)(r.b,{className:"CopilotGenerateDescriptionPanel-module__loadingText__F05IH",children:"Writing\u2026"}),(0,a.jsx)(f.K,{"aria-label":"Stop generation",icon:g.SquareFillIcon,size:"small",onClick:eb})]}),"suggested"===G&&!ek&&(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__actionButtons__vKmq1",children:[(0,a.jsx)(h.Q,{size:"small",variant:"invisible",className:N,leadingVisual:g.CheckIcon,onClick:()=>eh("accepted"),children:"Accept"}),(0,a.jsx)(h.Q,{size:"small",variant:"invisible",className:N,leadingVisual:g.XIcon,onClick:e_,children:"Discard"}),(0,a.jsx)(h.Q,{size:"small",variant:"invisible",className:N,leadingVisual:g.SyncIcon,onClick:eS,children:"Try again"})]}),!ek&&(0,a.jsxs)("div",{className:"CopilotGenerateDescriptionPanel-module__inputArea__ZUw58",children:[(0,a.jsx)(b.Ay,{ref:ed,value:W,onChange:e=>z(e.target.value),onKeyPress:eI,placeholder:"Type your message here...",rows:1,resize:"none",block:!0,className:" 