@ulpi/cli 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/{chunk-F32YQRFR.js → chunk-GSFWS32F.js} +1 -1
  2. package/dist/{ci-QBXWR3GW.js → ci-RMMSML3A.js} +1 -1
  3. package/dist/{doctor-SRJIZM2T.js → doctor-ILXW63Q2.js} +1 -1
  4. package/dist/{history-UGYO7Z3U.js → history-TKPFJAL3.js} +1 -1
  5. package/dist/index.js +8 -8
  6. package/dist/portal/apps/portal/.next/BUILD_ID +1 -1
  7. package/dist/portal/apps/portal/.next/app-build-manifest.json +98 -98
  8. package/dist/portal/apps/portal/.next/app-path-routes-manifest.json +21 -21
  9. package/dist/portal/apps/portal/.next/build-manifest.json +2 -2
  10. package/dist/portal/apps/portal/.next/prerender-manifest.json +106 -106
  11. package/dist/portal/apps/portal/.next/server/app/(dashboard)/billing/page_client-reference-manifest.js +1 -1
  12. package/dist/portal/apps/portal/.next/server/app/(dashboard)/codemap/page_client-reference-manifest.js +1 -1
  13. package/dist/portal/apps/portal/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  14. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/[sha]/transcript/page_client-reference-manifest.js +1 -1
  15. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/page.js +1 -1
  16. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/page_client-reference-manifest.js +1 -1
  17. package/dist/portal/apps/portal/.next/server/app/(dashboard)/jobs/[id]/page_client-reference-manifest.js +1 -1
  18. package/dist/portal/apps/portal/.next/server/app/(dashboard)/jobs/page_client-reference-manifest.js +1 -1
  19. package/dist/portal/apps/portal/.next/server/app/(dashboard)/loop/page.js +1 -1
  20. package/dist/portal/apps/portal/.next/server/app/(dashboard)/loop/page_client-reference-manifest.js +1 -1
  21. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/[name]/page_client-reference-manifest.js +1 -1
  22. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/catalog/page_client-reference-manifest.js +1 -1
  23. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/page_client-reference-manifest.js +1 -1
  24. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/secrets/page_client-reference-manifest.js +1 -1
  25. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/submissions/page_client-reference-manifest.js +1 -1
  26. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/usage/page_client-reference-manifest.js +1 -1
  27. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/page_client-reference-manifest.js +1 -1
  28. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/settings/page_client-reference-manifest.js +1 -1
  29. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/timeline/page_client-reference-manifest.js +1 -1
  30. package/dist/portal/apps/portal/.next/server/app/(dashboard)/notifications/page_client-reference-manifest.js +1 -1
  31. package/dist/portal/apps/portal/.next/server/app/(dashboard)/parallel/page.js +1 -1
  32. package/dist/portal/apps/portal/.next/server/app/(dashboard)/parallel/page_client-reference-manifest.js +1 -1
  33. package/dist/portal/apps/portal/.next/server/app/(dashboard)/prd/page_client-reference-manifest.js +1 -1
  34. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/[id]/guards/page_client-reference-manifest.js +1 -1
  35. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/[id]/page_client-reference-manifest.js +1 -1
  36. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/page_client-reference-manifest.js +1 -1
  37. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/config/page_client-reference-manifest.js +1 -1
  38. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/page_client-reference-manifest.js +1 -1
  39. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/plan/page_client-reference-manifest.js +1 -1
  40. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/queue/page_client-reference-manifest.js +1 -1
  41. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/[id]/page_client-reference-manifest.js +1 -1
  42. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/new/page_client-reference-manifest.js +1 -1
  43. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/page_client-reference-manifest.js +1 -1
  44. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/pipelines/page_client-reference-manifest.js +1 -1
  45. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/[sessionId]/page_client-reference-manifest.js +1 -1
  46. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/page.js +1 -1
  47. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/page_client-reference-manifest.js +1 -1
  48. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/github/page_client-reference-manifest.js +1 -1
  49. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/installations/page_client-reference-manifest.js +1 -1
  50. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/keys/page_client-reference-manifest.js +1 -1
  51. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/members/page_client-reference-manifest.js +1 -1
  52. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/orgs/new/page_client-reference-manifest.js +1 -1
  53. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  54. package/dist/portal/apps/portal/.next/server/app/(dashboard)/skills/page_client-reference-manifest.js +1 -1
  55. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sprints/[batchId]/page_client-reference-manifest.js +1 -1
  56. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sprints/page_client-reference-manifest.js +1 -1
  57. package/dist/portal/apps/portal/.next/server/app/(dashboard)/templates/page_client-reference-manifest.js +1 -1
  58. package/dist/portal/apps/portal/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  59. package/dist/portal/apps/portal/.next/server/app/_not-found.html +1 -1
  60. package/dist/portal/apps/portal/.next/server/app/_not-found.rsc +1 -1
  61. package/dist/portal/apps/portal/.next/server/app/auth/callback/page_client-reference-manifest.js +1 -1
  62. package/dist/portal/apps/portal/.next/server/app/auth/callback.html +1 -1
  63. package/dist/portal/apps/portal/.next/server/app/auth/callback.rsc +1 -1
  64. package/dist/portal/apps/portal/.next/server/app/billing.html +1 -1
  65. package/dist/portal/apps/portal/.next/server/app/billing.rsc +1 -1
  66. package/dist/portal/apps/portal/.next/server/app/codemap.html +1 -1
  67. package/dist/portal/apps/portal/.next/server/app/codemap.rsc +1 -1
  68. package/dist/portal/apps/portal/.next/server/app/dashboard.html +1 -1
  69. package/dist/portal/apps/portal/.next/server/app/dashboard.rsc +1 -1
  70. package/dist/portal/apps/portal/.next/server/app/history.html +1 -1
  71. package/dist/portal/apps/portal/.next/server/app/history.rsc +2 -2
  72. package/dist/portal/apps/portal/.next/server/app/jobs.html +1 -1
  73. package/dist/portal/apps/portal/.next/server/app/jobs.rsc +1 -1
  74. package/dist/portal/apps/portal/.next/server/app/loop.html +1 -1
  75. package/dist/portal/apps/portal/.next/server/app/loop.rsc +2 -2
  76. package/dist/portal/apps/portal/.next/server/app/mcps/catalog.html +1 -1
  77. package/dist/portal/apps/portal/.next/server/app/mcps/catalog.rsc +1 -1
  78. package/dist/portal/apps/portal/.next/server/app/mcps/secrets.html +1 -1
  79. package/dist/portal/apps/portal/.next/server/app/mcps/secrets.rsc +1 -1
  80. package/dist/portal/apps/portal/.next/server/app/mcps/submissions.html +1 -1
  81. package/dist/portal/apps/portal/.next/server/app/mcps/submissions.rsc +1 -1
  82. package/dist/portal/apps/portal/.next/server/app/mcps/usage.html +1 -1
  83. package/dist/portal/apps/portal/.next/server/app/mcps/usage.rsc +1 -1
  84. package/dist/portal/apps/portal/.next/server/app/mcps.html +1 -1
  85. package/dist/portal/apps/portal/.next/server/app/mcps.rsc +1 -1
  86. package/dist/portal/apps/portal/.next/server/app/memory/settings.html +1 -1
  87. package/dist/portal/apps/portal/.next/server/app/memory/settings.rsc +1 -1
  88. package/dist/portal/apps/portal/.next/server/app/memory/timeline.html +1 -1
  89. package/dist/portal/apps/portal/.next/server/app/memory/timeline.rsc +2 -2
  90. package/dist/portal/apps/portal/.next/server/app/memory.html +1 -1
  91. package/dist/portal/apps/portal/.next/server/app/memory.rsc +2 -2
  92. package/dist/portal/apps/portal/.next/server/app/notifications.html +1 -1
  93. package/dist/portal/apps/portal/.next/server/app/notifications.rsc +1 -1
  94. package/dist/portal/apps/portal/.next/server/app/parallel.html +1 -1
  95. package/dist/portal/apps/portal/.next/server/app/parallel.rsc +2 -2
  96. package/dist/portal/apps/portal/.next/server/app/prd.html +1 -1
  97. package/dist/portal/apps/portal/.next/server/app/prd.rsc +2 -2
  98. package/dist/portal/apps/portal/.next/server/app/repos.html +1 -1
  99. package/dist/portal/apps/portal/.next/server/app/repos.rsc +1 -1
  100. package/dist/portal/apps/portal/.next/server/app/review/config.html +1 -1
  101. package/dist/portal/apps/portal/.next/server/app/review/config.rsc +1 -1
  102. package/dist/portal/apps/portal/.next/server/app/review/plan.html +1 -1
  103. package/dist/portal/apps/portal/.next/server/app/review/plan.rsc +2 -2
  104. package/dist/portal/apps/portal/.next/server/app/review/queue.html +1 -1
  105. package/dist/portal/apps/portal/.next/server/app/review/queue.rsc +1 -1
  106. package/dist/portal/apps/portal/.next/server/app/review.html +1 -1
  107. package/dist/portal/apps/portal/.next/server/app/review.rsc +1 -1
  108. package/dist/portal/apps/portal/.next/server/app/rules/new.html +1 -1
  109. package/dist/portal/apps/portal/.next/server/app/rules/new.rsc +1 -1
  110. package/dist/portal/apps/portal/.next/server/app/rules/pipelines.html +1 -1
  111. package/dist/portal/apps/portal/.next/server/app/rules/pipelines.rsc +1 -1
  112. package/dist/portal/apps/portal/.next/server/app/rules.html +1 -1
  113. package/dist/portal/apps/portal/.next/server/app/rules.rsc +1 -1
  114. package/dist/portal/apps/portal/.next/server/app/sessions.html +1 -1
  115. package/dist/portal/apps/portal/.next/server/app/sessions.rsc +2 -2
  116. package/dist/portal/apps/portal/.next/server/app/settings/github.html +1 -1
  117. package/dist/portal/apps/portal/.next/server/app/settings/github.rsc +1 -1
  118. package/dist/portal/apps/portal/.next/server/app/settings/installations.html +1 -1
  119. package/dist/portal/apps/portal/.next/server/app/settings/installations.rsc +1 -1
  120. package/dist/portal/apps/portal/.next/server/app/settings/keys.html +1 -1
  121. package/dist/portal/apps/portal/.next/server/app/settings/keys.rsc +1 -1
  122. package/dist/portal/apps/portal/.next/server/app/settings/members.html +1 -1
  123. package/dist/portal/apps/portal/.next/server/app/settings/members.rsc +1 -1
  124. package/dist/portal/apps/portal/.next/server/app/settings/orgs/new.html +1 -1
  125. package/dist/portal/apps/portal/.next/server/app/settings/orgs/new.rsc +1 -1
  126. package/dist/portal/apps/portal/.next/server/app/settings.html +1 -1
  127. package/dist/portal/apps/portal/.next/server/app/settings.rsc +1 -1
  128. package/dist/portal/apps/portal/.next/server/app/skills.html +1 -1
  129. package/dist/portal/apps/portal/.next/server/app/skills.rsc +1 -1
  130. package/dist/portal/apps/portal/.next/server/app/sprints.html +1 -1
  131. package/dist/portal/apps/portal/.next/server/app/sprints.rsc +1 -1
  132. package/dist/portal/apps/portal/.next/server/app/templates.html +1 -1
  133. package/dist/portal/apps/portal/.next/server/app/templates.rsc +1 -1
  134. package/dist/portal/apps/portal/.next/server/app-paths-manifest.json +21 -21
  135. package/dist/portal/apps/portal/.next/server/next-font-manifest.js +1 -1
  136. package/dist/portal/apps/portal/.next/server/next-font-manifest.json +1 -1
  137. package/dist/portal/apps/portal/.next/server/pages/404.html +1 -1
  138. package/dist/portal/apps/portal/.next/server/pages/500.html +1 -1
  139. package/dist/portal/apps/portal/.next/server/pages-manifest.json +1 -1
  140. package/dist/portal/apps/portal/.next/static/chunks/3958-eebe9ad88e40b2c1.js +1 -0
  141. package/dist/portal/apps/portal/.next/static/chunks/{7525-d6350803a451284c.js → 7525-8d416b046f9add2a.js} +1 -1
  142. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/history/{page-264989cf873cd3de.js → page-0275ca43fdd64bf2.js} +1 -1
  143. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/jobs/[id]/page-dba3c6050ccf9243.js +1 -0
  144. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/loop/page-c3f658ffb8d7397b.js +1 -0
  145. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/page-afe7f7a5b78650f2.js +1 -0
  146. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/timeline/{page-30db4506366d09f4.js → page-4e3dd7e30a9946f0.js} +1 -1
  147. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/parallel/{page-85690140ff82dd58.js → page-49a26690ced20482.js} +1 -1
  148. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/sessions/{page-6b199747e9f587de.js → page-0b140fb8bbc53097.js} +1 -1
  149. package/dist/portal/apps/portal/package.json +1 -0
  150. package/dist/portal/package.json +1 -1
  151. package/dist/{start-DWZHVBUO.js → start-BRB2XW3T.js} +1 -1
  152. package/dist/{update-IBPDEBEK.js → update-HBWHFHUW.js} +1 -1
  153. package/dist/{version-checker-XKFQNN3I.js → version-checker-BQP7DVQ4.js} +1 -1
  154. package/package.json +6 -6
  155. package/dist/portal/apps/portal/.next/static/chunks/3958-9975252472a218aa.js +0 -1
  156. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/jobs/[id]/page-b0ac38d08f846f50.js +0 -1
  157. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/loop/page-faeaacd95742c754.js +0 -1
  158. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/page-79f977cd348c57ae.js +0 -1
  159. /package/dist/portal/apps/portal/.next/static/{02AzZdYDA5HVAwITp37Ql → SG8tUyluXEA9HzEKtf-oo}/_buildManifest.js +0 -0
  160. /package/dist/portal/apps/portal/.next/static/{02AzZdYDA5HVAwITp37Ql → SG8tUyluXEA9HzEKtf-oo}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7525],{33:(e,t,n)=>{n.d(t,{U:()=>s});var r=n(8111);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=100===t?e/10:e;return n>=8?"text-emerald-400":n>=6?"text-amber-400":n>=4?"text-orange-400":"text-red-400"}function s(e){let{score:t,onRequestAiScore:n,aiScoreLoading:s=!1,aiScoringAvailable:o=!1,scale:a=10}=e,i=100===a?Math.round(t.overall).toString():t.overall.toFixed(1);return(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-white",children:"Quality Score"}),(0,r.jsxs)("span",{className:"text-lg font-bold ".concat(l(t.overall,a)),children:[i,"/",100===a?"100":"10"]}),t.isAiScore&&(0,r.jsxs)("span",{className:"rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium text-primary-400 border border-primary-500/20",children:["AI ",t.aiModel?"(".concat(t.aiModel,")"):""]})]}),o&&!t.isAiScore&&n&&(0,r.jsx)("button",{onClick:n,disabled:s,className:"rounded-lg bg-primary-500/10 px-3 py-1.5 text-xs font-medium text-primary-400 transition-colors hover:bg-primary-500/20 disabled:opacity-50",children:s?"Scoring...":"AI Score"})]}),(0,r.jsx)("div",{className:"space-y-2.5",children:t.breakdown.map(e=>(0,r.jsxs)("div",{className:"group",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-xs text-gray-400 capitalize",children:e.name}),(0,r.jsx)("span",{className:"text-xs font-medium ".concat(l(e.score)),children:e.score.toFixed(1)})]}),(0,r.jsx)("div",{className:"h-1.5 w-full rounded-full bg-white/[0.06]",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all ".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=100===t?e/10:e;return n>=8?"bg-emerald-500":n>=6?"bg-amber-500":n>=4?"bg-orange-500":"bg-red-500"}(e.score)),style:{width:"".concat(Math.min(10*e.score,100),"%")}})}),e.details&&(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:e.details})]},e.name))}),t.suggestions.length>0&&(0,r.jsxs)("div",{className:"mt-4 pt-3 border-t border-white/[0.04]",children:[(0,r.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-gray-500 mb-2",children:"Suggestions"}),(0,r.jsx)("ul",{className:"space-y-1",children:t.suggestions.map((e,t)=>(0,r.jsxs)("li",{className:"text-xs text-gray-400 flex gap-2",children:[(0,r.jsx)("span",{className:"text-gray-600 shrink-0",children:"-"}),(0,r.jsx)("span",{children:e})]},t))})]})]})}},64:(e,t,n)=>{n.d(t,{U:()=>s});var r=n(5271),l=n(9396);function s(e){var t,n,s,o,a;let{markdown:i,onMarkdownChange:c,readOnly:d,initialState:u,onExtraKeyDown:x}=e,[m,p]=(0,r.useState)(null!=(t=null==u?void 0:u.annotations)?t:[]),[h,b]=(0,r.useState)(null!=(n=null==u?void 0:u.inlineEdits)?n:[]),[g,f]=(0,r.useState)(null!=(s=null==u?void 0:u.priorities)?s:[]),[y,v]=(0,r.useState)(null!=(o=null==u?void 0:u.risks)?o:[]),[w,j]=(0,r.useState)(null!=(a=null==u?void 0:u.instructions)?a:[]),[N,k]=(0,r.useState)(new Set),[C,E]=(0,r.useState)(""),[S,I]=(0,r.useState)(null),[A,D]=(0,r.useState)(null),[P,M]=(0,r.useState)("notes"),[L,R]=(0,r.useState)(!1),[z,T]=(0,r.useState)(null),[U,q]=(0,r.useState)(null),[F,_]=(0,r.useState)(""),[W,K]=(0,r.useState)(null),[O,B]=(0,r.useState)({visible:!1,x:0,y:0,mode:"block",sectionIdx:null}),[G,H]=(0,r.useState)(null),[J,X]=(0,r.useState)(null),[$,Q]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(!1),[,V]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=setInterval(()=>V(e=>e+1),3e4);return()=>clearInterval(e)},[]);let ee=(0,r.useMemo)(()=>(0,l.Dx)(i),[i]),et=(0,r.useMemo)(()=>{let e=new Map;for(let n of m){var t;if(!n.sectionId||"global"===n.sectionId)continue;let r=null!=(t=e.get(n.sectionId))?t:[];r.push(n),e.set(n.sectionId,r)}return e},[m]),en=(0,r.useMemo)(()=>{if(!C.trim())return m;let e=C.toLowerCase();return m.filter(t=>t.text.toLowerCase().includes(e)||t.type.toLowerCase().includes(e))},[m,C]),er=en.filter(e=>"global"===e.sectionId),el=(0,r.useMemo)(()=>{let e=new Map;for(let t of en)t.sectionId&&"global"!==t.sectionId&&(e.has(t.sectionId)||e.set(t.sectionId,[]),e.get(t.sectionId).push(t));return e},[en]),es=(0,r.useCallback)(e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),eo=(0,r.useCallback)((e,t)=>{var n,r;if(!W)return;let l={id:crypto.randomUUID(),type:W.type,text:W.selectedText?"> ".concat(W.selectedText,"\n\n").concat(e):e,sectionId:null!==W.sectionIdx?null!=(r=null==(n=ee[W.sectionIdx])?void 0:n.id)?r:String(W.sectionIdx):"global",createdAt:Date.now(),imagePaths:t};p(e=>[...e,l]),K(null)},[W,ee]),ea=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim())return void R(!1);let t=e.toString().trim(),n=e.getRangeAt(0),r=n.getBoundingClientRect(),l=n.startContainer,s=null;for(;l;){if(l instanceof HTMLElement){let e=l.getAttribute("data-section-idx");if(null!==e){s=Number(e);break}}l=l.parentNode}_(t),q(s),T(r),R(!0)},[]),ei=(0,r.useCallback)(()=>{R(!1)},[]),ec=(0,r.useCallback)(e=>{var t;R(!1),K({visible:!0,title:"Add ".concat(e),sectionIdx:U,type:"instruction"===e?"instruction":e,selectedText:F}),null==(t=window.getSelection())||t.removeAllRanges()},[U,F]),ed=(0,r.useCallback)((e,t)=>{e.preventDefault();let n=window.getSelection(),r=n&&!n.isCollapsed&&n.toString().trim().length>0;B({visible:!0,x:e.clientX,y:e.clientY,mode:r?"selection":"block",sectionIdx:t}),r&&(_(n.toString().trim()),q(t))},[]),eu=(0,r.useCallback)(e=>{let t=O.sectionIdx;switch(e.type){case"comment":case"suggest":case"concern":case"question":{var n;let r=null!=(n=({comment:"comment",suggest:"suggestion",concern:"concern",question:"question"})[e.type])?n:"comment";K({visible:!0,title:"Add ".concat(r),sectionIdx:t,type:r,selectedText:"selection"===O.mode?F:void 0});break}case"instruction":K({visible:!0,title:"Add Instruction",sectionIdx:t,type:"instruction"});break;case"edit":d||I(t);break;case"priority":H(t);break;case"risk":X(t)}B(e=>({...e,visible:!1}))},[O,F,d]),ex=(0,r.useCallback)(e=>{var t;if(null===S)return;let n=ee[S];if(!n)return;let r=null!=(t=n.id)?t:String(S);b(t=>[...t.filter(e=>e.blockId!==r),{blockId:r,originalContent:n.content,editedContent:e}]);let l=i.split("\n"),s=n.content.split("\n"),o=e.split("\n");l.splice(n.startLine,s.length,...o),null==c||c(l.join("\n")),I(null)},[S,ee,i,c]),em=(0,r.useCallback)((e,t)=>{var n,r;if(null===G)return;let l=null!=(r=null==(n=ee[G])?void 0:n.id)?r:String(G);f(n=>[...n.filter(e=>e.sectionId!==l),{sectionId:l,priority:e,note:t}]),H(null)},[G,ee]),ep=(0,r.useCallback)(()=>{var e,t;if(null===G)return;let n=null!=(t=null==(e=ee[G])?void 0:e.id)?t:String(G);f(e=>e.filter(e=>e.sectionId!==n)),H(null)},[G,ee]),eh=(0,r.useCallback)((e,t)=>{var n,r;if(null===J)return;let l=null!=(r=null==(n=ee[J])?void 0:n.id)?r:String(J);v(n=>[...n.filter(e=>e.sectionId!==l),{sectionId:l,level:e,description:t}]),X(null)},[J,ee]),eb=(0,r.useCallback)(()=>{var e,t;if(null===J)return;let n=null!=(t=null==(e=ee[J])?void 0:e.id)?t:String(J);v(e=>e.filter(e=>e.sectionId!==n)),X(null)},[J,ee]),eg=(0,r.useCallback)((e,t,n)=>{j(r=>[...r,{id:crypto.randomUUID(),sectionId:e,instruction:t,priority:n,createdAt:Date.now()}])},[]),ef=(0,r.useCallback)(e=>{j(t=>t.filter(t=>t.id!==e))},[]),ey=(0,r.useCallback)(()=>{var e;let t={comments:0,questions:0,concerns:0,suggestions:0,approvals:0,instructions:0,globalComments:0};for(let e of m)"comment"===e.type?t.comments++:"question"===e.type?t.questions++:"concern"===e.type?t.concerns++:"suggestion"===e.type?t.suggestions++:"approval"===e.type?t.approvals++:"instruction"===e.type?t.instructions++:"global_comment"===e.type&&t.globalComments++;let n=m.find(e=>"global_comment"===e.type);return{annotationCount:m.length,annotationsByType:t,editCount:h.length,instructionCount:w.length,priorityCount:g.length,riskCount:y.length,globalComment:null==n||null==(e=n.text)?void 0:e.slice(0,200)}},[m,h,w,g,y]),ev=(0,r.useRef)(W);ev.current=W,(0,r.useEffect)(()=>{function e(e){let t=e.target,n="TEXTAREA"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName||"true"===t.contentEditable;if("Escape"===e.key)return Y?void Z(!1):$?void Q(!1):O.visible?void B(e=>({...e,visible:!1})):null!==G?void H(null):null!==J?void X(null):null!==S?void I(null):void 0;if(!n&&!ev.current&&(null==x||!x(e,A)))switch(e.key){case"?":e.preventDefault(),Z(e=>!e);break;case"j":e.preventDefault(),D(e=>{let t=(null!=e?e:-1)+1;return t<ee.length?t:e});break;case"k":e.preventDefault(),D(e=>{let t=(null!=e?e:1)-1;return t>=0?t:e});break;case"a":case"A":e.preventDefault(),K({visible:!0,title:"Add Global Comment",sectionIdx:null,type:"global_comment"});break;case"c":null!==A&&(e.preventDefault(),K({visible:!0,title:"Add Comment",sectionIdx:A,type:"comment"}));break;case"e":null===A||d||(e.preventDefault(),I(A));break;case"i":e.preventDefault(),M(e=>"instructions"===e?"notes":"instructions");break;case"p":null!==A&&(e.preventDefault(),H(e=>e===A?null:A),X(null));break;case"r":null!==A&&(e.preventDefault(),X(e=>e===A?null:A),H(null))}}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Y,$,O.visible,G,J,S,A,ee.length,d,x]);let ew=(0,r.useCallback)(()=>{p([]),b([]),f([]),v([]),j([]),k(new Set),E(""),I(null),D(null),K(null),B({visible:!1,x:0,y:0,mode:"block",sectionIdx:null}),H(null),X(null),Q(!1),Z(!1)},[]);return{sections:ee,annotations:m,setAnnotations:p,sectionAnnotations:et,filteredAnnotations:en,filteredGlobal:er,filteredSectionGroups:el,annotationFilter:C,setAnnotationFilter:E,handleAnnotationSubmit:eo,inlineEdits:h,setInlineEdits:b,editingSectionIdx:S,setEditingSectionIdx:I,handleEditCommit:ex,priorities:g,setPriorities:f,priorityPopoverSection:G,setPriorityPopoverSection:H,handleSetPriority:em,handleRemovePriority:ep,risks:y,setRisks:v,riskPopoverSection:J,setRiskPopoverSection:X,handleSetRisk:eh,handleRemoveRisk:eb,instructions:w,setInstructions:j,handleAddInstruction:eg,handleDeleteInstruction:ef,collapsedSections:N,toggleSection:es,focusedSection:A,setFocusedSection:D,toolbarVisible:L,toolbarRect:z,handleMouseUp:ea,handleContentMouseDown:ei,handleToolbarAction:ec,contextMenu:O,setContextMenu:B,handleContextMenu:ed,handleContextMenuAction:eu,commentDialog:W,setCommentDialog:K,rightPanel:P,setRightPanel:M,showExport:$,setShowExport:Q,showKeyboard:Y,setShowKeyboard:Z,buildConfirmationSummary:ey,resetEditorState:ew}}},422:(e,t,n)=>{n.d(t,{J:()=>s,h:()=>l});var r=n(7811);function l(){return"local"===r.env.NEXT_PUBLIC_ULPI_MODE,"https://ulpi-cloud-api.ngrok.app"}function s(){return"local"===r.env.NEXT_PUBLIC_ULPI_MODE||!0==="https://ulpi-cloud-api.ngrok.app".includes("localhost")}},656:(e,t,n)=>{n.d(t,{w:()=>x});var r=n(8111),l=n(5271),s=n(8054),o=n(8221),a=n(1294),i=n(9156),c=n(3881),d=n(7774);let u=[{type:"comment",icon:o.A,label:"Comment"},{type:"suggestion",icon:a.A,label:"Suggest"},{type:"concern",icon:i.A,label:"Concern"},{type:"question",icon:c.A,label:"Question"},{type:"instruction",icon:d.A,label:"Instruct"}];function x(e){let{visible:t,rect:n,onAction:o}=e,[a,i]=(0,l.useState)({x:0,y:0});return((0,l.useEffect)(()=>{if(!t||!n)return;let e=n.left+(n.width-360)/2,r=n.top-48-8+window.scrollY;e=Math.max(8,Math.min(e,window.innerWidth-360-8)),n.top-48-8<0&&(r=n.bottom+8+window.scrollY),i({x:e,y:r})},[t,n]),t&&n)?(0,s.createPortal)((0,r.jsx)("div",{className:"fixed rounded-xl border border-white/[0.08] bg-surface-900 shadow-xl z-50 p-1.5 flex gap-1",style:{left:"".concat(a.x,"px"),top:"".concat(a.y,"px")},onMouseDown:e=>e.preventDefault(),children:u.map(e=>(0,r.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 transition-colors",onClick:()=>o(e.type),title:e.label,children:[(0,r.jsx)(e.icon,{size:14}),(0,r.jsx)("span",{children:e.label})]},e.type))}),document.body):null}},1224:(e,t,n)=>{n.d(t,{C:()=>m});var r=n(8111),l=n(5271),s=n(2214),o=n(839),a=n(7325),i=n(9413),c=n(4285),d=n(6062);function u(e){let{content:t,isCode:n=!1,onCommit:s,onCancel:o}=e,[a,i]=(0,l.useState)(t),c=(0,l.useRef)(null);return(0,l.useEffect)(()=>{i(t)},[t]),(0,l.useEffect)(()=>{var e,t;null==(e=c.current)||e.focus(),null==(t=c.current)||t.select()},[]),(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),s(a)):"Escape"===e.key&&(e.preventDefault(),o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a,s,o]),(0,r.jsxs)("div",{className:"relative border-2 border-primary-500 rounded-md bg-primary-500/5 p-2 my-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-2 bg-primary-500/15 rounded border border-primary-500/30 mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-primary-300",children:"Editing"}),(0,r.jsx)("span",{className:"text-xs text-gray-500 ml-auto",children:"Cmd+Enter to save, Esc to cancel"})]}),(0,r.jsx)("textarea",{ref:c,className:"w-full min-h-24 p-3 text-sm leading-relaxed bg-surface-800 border border-white/[0.06] rounded-md text-gray-200 focus:outline-none focus:border-primary-500 resize-y transition-colors ".concat(n?"font-mono":""),value:a,onChange:e=>i(e.target.value),spellCheck:!n}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 mt-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border border-white/[0.06] text-gray-400 rounded-md hover:bg-white/[0.04] transition-colors",onClick:o,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-primary-600 text-white rounded-md hover:bg-primary-700 transition-colors",onClick:()=>s(a),children:"Save Changes"})]})]})}var x=n(9396);function m(e){let{sections:t,markdown:n,sectionAnnotations:m,collapsedSections:p,focusedSection:h,editingSectionIdx:b,priorities:g,risks:f,onToggleSection:y,onContextMenu:v,onEditCommit:w,onEditCancel:j,onAddComment:N,renderAnnotationImage:k}=e,C=(0,l.useMemo)(()=>[o.A],[]),E=(0,l.useMemo)(()=>[a.A],[]);return(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-6 md:p-8 space-y-1",children:[t.map((e,t)=>{var n;let l=p.has(t),o=null!=(n=m.get(e.id))?n:[],a=h===t,S=b===t,I=g.find(t=>t.sectionId===e.id),A=f.find(t=>t.sectionId===e.id),D=o.length>0?o[0].type:null,P=D?x.D5[D]:"";return(0,r.jsxs)("div",{"data-section-idx":t,className:"relative group rounded-lg transition-colors duration-150 ".concat(a?"bg-primary-500/5 ring-1 ring-primary-500/30":""," ").concat(P?"border-l-[3px] ".concat(P," pl-3"):""),onContextMenu:e=>v(e,t),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer py-1 hover:bg-white/[0.02] rounded -mx-2 px-2",onClick:()=>y(t),children:[l?(0,r.jsx)(i.A,{size:16,className:"text-gray-600"}):(0,r.jsx)(c.A,{size:16,className:"text-gray-600"}),(0,r.jsx)("span",{className:"font-semibold text-white ".concat(e.level<=2?"text-lg":"text-base"),children:e.title}),o.length>0&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-primary-500/20 text-primary-400",children:o.length}),I&&(0,r.jsx)("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium border ".concat("must-have"===I.priority?"bg-red-500/15 text-red-300 border-red-500/30":"should-have"===I.priority?"bg-amber-500/15 text-amber-300 border-amber-500/30":"nice-to-have"===I.priority?"bg-blue-500/15 text-blue-300 border-blue-500/30":"bg-white/[0.04] text-gray-400 border-white/[0.06]"),children:I.priority}),A&&(0,r.jsxs)("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium border ".concat("high"===A.level?"bg-red-500/15 text-red-300 border-red-500/30":"medium"===A.level?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-green-500/15 text-green-300 border-green-500/30"),children:["risk: ",A.level]}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),N(t)},className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/[0.06]",title:"Add annotation",children:(0,r.jsx)(d.A,{size:14,className:"text-gray-500"})})]}),!l&&(S?(0,r.jsx)("div",{className:"pl-6",children:(0,r.jsx)(u,{content:e.content,isCode:e.content.includes("```"),onCommit:w,onCancel:j})}):(0,r.jsx)("div",{className:"md-render pl-6 prose prose-invert prose-sm max-w-none",children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:E,children:e.content.replace(/^#{1,6}\s+.+\n?/,"")})})),!l&&o.length>0&&!S&&(0,r.jsx)("div",{className:"ml-6 mt-2 space-y-2",children:o.map(e=>(0,r.jsxs)("div",{className:"border-l-2 ".concat(x.D5[e.type]," rounded-r-lg p-3 text-sm"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded border ".concat(x.s0[e.type]),children:e.type}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,x.fF)(e.createdAt)})]}),(0,r.jsx)("p",{className:"text-gray-300 whitespace-pre-wrap text-xs",children:e.text}),e.imagePaths&&e.imagePaths.length>0&&k&&(0,r.jsx)("div",{className:"flex gap-2 mt-2 flex-wrap",children:e.imagePaths.map((e,t)=>k(e,t))})]},e.id))})]},t)}),0===t.length&&n&&(0,r.jsx)("div",{className:"prose prose-invert prose-sm max-w-none",children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:E,children:n})}),!n&&(0,r.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No content available"})})]})}},2630:(e,t,n)=>{n.d(t,{O:()=>i});var r=n(8111),l=n(5271),s=n(8054),o=n(921);let a=[{id:"markdown",label:"Markdown",extension:".md",description:"Annotated markdown with review comments, priorities, and risks."},{id:"github",label:"GitHub Issue",extension:".md",description:"Formatted for GitHub Issues with checklist and annotations."},{id:"jira",label:"Jira",extension:".md",description:"Jira-compatible format with ADF-style headers, tables, and {code} blocks."},{id:"json",label:"JSON",extension:".json",description:"Raw JSON export of all review data."}];function i(e){let{visible:t,title:n,markdown:i,annotations:c,priorities:d,risks:u,sections:x,onClose:m,defaultFormat:p}=e,[h,b]=(0,l.useState)("markdown"),[g,f]=(0,l.useState)(!1),y=(0,l.useCallback)(e=>{"Escape"===e.key&&m()},[m]);(0,l.useEffect)(()=>{if(t)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t,y]),(0,l.useEffect)(()=>{t&&(b(null!=p?p:"markdown"),f(!1))},[t,p]);let v=(0,l.useMemo)(()=>t?function(e,t,n,r,l,s,o){var a,i,c,d,u,x,m,p,h,b,g,f;let y=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)||"review";switch(e){case"markdown":{let e="# Review: ".concat(t,"\n\n");if(r.length>0){for(let t of(e+="## Annotations (".concat(r.length,")\n\n"),r)){let n=t.sectionId&&"global"!==t.sectionId?null==(a=o.find(e=>e.id===t.sectionId))?void 0:a.title:"Global";e+="- **[".concat(t.type,"]** ").concat(n?"(".concat(n,") "):"").concat(t.text,"\n")}e+="\n"}if(l.length>0){for(let t of(e+="## Priorities\n\n",l)){let n=null!=(c=null==(i=o.find(e=>e.id===t.sectionId))?void 0:i.title)?c:t.sectionId;e+="- **".concat(t.priority,"**: ").concat(n).concat(t.note?" - ".concat(t.note):"","\n")}e+="\n"}if(s.length>0){for(let t of(e+="## Risks\n\n",s)){let n=null!=(u=null==(d=o.find(e=>e.id===t.sectionId))?void 0:d.title)?u:t.sectionId;e+="- **".concat(t.level,"**: ").concat(n).concat(t.description?" - ".concat(t.description):"","\n")}e+="\n"}return{content:e+="## Plan\n\n".concat(n),filename:"".concat(y,"-review.md")}}case"github":{let e="## Review Summary\n\n";if(e+="- Annotations: ".concat(r.length,"\n"),e+="- Priorities: ".concat(l.length,"\n"),e+="- Risks: ".concat(s.length,"\n\n"),r.length>0){for(let t of(e+="### Comments\n\n",r))e+="- [ ] **".concat(t.type,"**: ").concat(t.text,"\n");e+="\n"}return e+="<details><summary>Full Plan</summary>\n\n".concat(n,"\n\n</details>"),{content:"# ".concat(t,"\n\n").concat(e),filename:"".concat(y,"-github-issue.md")}}case"jira":{let e="h1. ".concat(t,"\n\n");if(r.length>0){for(let t of(e+="h2. Annotations\n\n",e+="||Type||Section||Comment||\n",r)){let n=t.sectionId&&"global"!==t.sectionId?null==(x=o.find(e=>e.id===t.sectionId))?void 0:x.title:"Global",r=t.text.replace(/\|/g,"\\|").replace(/\n/g," ");e+="|".concat(t.type,"|").concat(null!=n?n:"—","|").concat(r,"|\n")}e+="\n"}if(l.length>0){for(let t of(e+="h2. Priorities\n\n",e+="||Section||Priority||Note||\n",l)){let n=null!=(p=null==(m=o.find(e=>e.id===t.sectionId))?void 0:m.title)?p:t.sectionId;e+="|".concat(n,"|").concat(t.priority,"|").concat(null!=(h=t.note)?h:"—","|\n")}e+="\n"}if(s.length>0){for(let t of(e+="h2. Risks\n\n",e+="||Section||Level||Description||\n",s)){let n=null!=(g=null==(b=o.find(e=>e.id===t.sectionId))?void 0:b.title)?g:t.sectionId,r=(null!=(f=t.description)?f:"—").replace(/\|/g,"\\|").replace(/\n/g," ");e+="|".concat(n,"|").concat(t.level,"|").concat(r,"|\n")}e+="\n"}let a=n.replace(/^### (.+)/gm,"h3. $1").replace(/^## (.+)/gm,"h2. $1").replace(/^# (.+)/gm,"h1. $1").replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>"{code:language=".concat(t||"none","}\n").concat(n,"{code}")).replace(/\*\*(.+?)\*\*/g,"*$1*").replace(/^- /gm,"* ");return{content:e+="h2. Plan\n\n".concat(a),filename:"".concat(y,"-review-jira.md")}}case"json":return{content:JSON.stringify({title:t,annotations:r,priorities:l,risks:s,exportedAt:new Date().toISOString()},null,2),filename:"".concat(y,"-review.json")}}}(h,n,i,c,d,u,x):null,[t,h,n,i,c,d,u,x]);async function w(){if(v){try{await navigator.clipboard.writeText(v.content)}catch(t){let e=document.createElement("textarea");e.value=v.content,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}f(!0),setTimeout(()=>f(!1),2e3)}}if(!t)return null;let j=a.find(e=>e.id===h);return(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/75 backdrop-blur-sm flex items-center justify-center z-50",onClick:e=>{e.target===e.currentTarget&&m()},children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl w-full max-w-lg shadow-2xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-white/[0.06]",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-white",children:"Export Plan"}),(0,r.jsx)("button",{className:"text-gray-500 hover:text-gray-200 transition-colors",onClick:m,children:(0,r.jsx)(o.A,{size:18})})]}),(0,r.jsxs)("div",{className:"p-6 space-y-4",children:[(0,r.jsx)("div",{className:"flex gap-2",children:a.map(e=>(0,r.jsxs)("button",{className:"flex-1 p-3 border rounded-lg text-left transition-colors ".concat(h===e.id?"bg-white/[0.04] ring-2 ring-primary-500 border-primary-500/30":"border-white/[0.06] hover:bg-white/[0.04]"),onClick:()=>{b(e.id),f(!1)},children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-white",children:e.label}),(0,r.jsx)("span",{className:"block text-xs text-gray-500",children:e.extension})]},e.id))}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:j.description}),(0,r.jsxs)("div",{className:"border border-white/[0.06] rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-surface-800 border-b border-white/[0.06]",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"Preview"}),(0,r.jsx)("span",{className:"text-xs text-gray-400 font-mono",children:null==v?void 0:v.filename})]}),(0,r.jsx)("pre",{className:"max-h-60 overflow-y-auto p-4 bg-surface-800 text-xs font-mono text-gray-400 whitespace-pre-wrap",children:(0,r.jsx)("code",{children:null==v?void 0:v.content})})]}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)("button",{className:"flex-1 py-2.5 bg-white/[0.04] hover:bg-white/[0.06] text-gray-400 text-sm font-medium rounded-lg border border-white/[0.06] transition-colors",onClick:w,children:g?"Copied!":"Copy to Clipboard"}),(0,r.jsxs)("button",{className:"flex-1 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-sm font-medium rounded-lg transition-all",onClick:function(){v&&function(e,t){let n=new Blob([e],{type:"text/plain;charset=utf-8"}),r=URL.createObjectURL(n),l=document.createElement("a");l.href=r,l.download=t,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}(v.content,v.filename)},children:["Download ",j.extension]})]})]})]})}),document.body)}},3446:(e,t,n)=>{n.d(t,{Kv:()=>c,HI:()=>x,Xk:()=>d,yC:()=>u});var r=n(8111),l=n(5271),s=n(422),o=n(7811);class a{async request(e,t){let n="".concat(this.baseUrl).concat(e);if(this.repo){let e=n.includes("?")?"&":"?";n="".concat(n).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=o.env.NEXT_PUBLIC_ULPI_API_SECRET,l=await fetch(n,{...t,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==t?void 0:t.headers}});if(!l.ok)throw Error((await l.json().catch(()=>({error:l.statusText}))).error||"API error: ".concat(l.status));return l.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,s.h)()}}let i=(0,l.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,n=(0,l.useMemo)(()=>{let e=(0,s.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new a:null}},[]);return(0,r.jsx)(i,{value:n,children:t})}function d(){return(0,l.useContext)(i).mode}function u(){let{localClient:e}=(0,l.useContext)(i);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function x(){return(0,l.useContext)(i)}},4780:(e,t,n)=>{n.d(t,{_:()=>C});var r=n(8111),l=n(5271),s=n(8054),o=n(921),a=n(1294),i=n(8982),c=n(7666),d=n(1729),u=n(9903),x=n(3163),m=n(6342),p=n(3468),h=n(8786);let b=[{tool:"pen",icon:c.A,label:"Pen"},{tool:"arrow",icon:d.A,label:"Arrow"},{tool:"circle",icon:u.A,label:"Circle"},{tool:"text",icon:x.A,label:"Text"}],g=[{value:"#ef4444",label:"Red"},{value:"#3b82f6",label:"Blue"},{value:"#22c55e",label:"Green"},{value:"#eab308",label:"Yellow"},{value:"#000000",label:"Black"},{value:"#ffffff",label:"White"}],f=[{value:2,label:"Thin"},{value:4,label:"Medium"},{value:8,label:"Thick"}];function y(){return"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9))}function v(e,t){let n=e.getBoundingClientRect(),r=e.width/n.width,l=e.height/n.height;return{x:(t.clientX-n.left)*r,y:(t.clientY-n.top)*l}}function w(e,t,n,r){if(!(t.length<2)){e.strokeStyle=n,e.lineWidth=r,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}function j(e,t,n,r,l){let s=Math.max(4*l,12),o=Math.atan2(n.y-t.y,n.x-t.x);e.strokeStyle=r,e.lineWidth=l,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.stroke(),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-s*Math.cos(o-Math.PI/6),n.y-s*Math.sin(o-Math.PI/6)),e.moveTo(n.x,n.y),e.lineTo(n.x-s*Math.cos(o+Math.PI/6),n.y-s*Math.sin(o+Math.PI/6)),e.stroke()}function N(e,t,n,r,l){let s=Math.abs(n.x-t.x),o=Math.abs(n.y-t.y);e.strokeStyle=r,e.lineWidth=l,e.lineCap="round",e.beginPath(),e.ellipse(t.x,t.y,s,o,0,0,2*Math.PI),e.stroke()}function k(e){let{imageSrc:t,onSave:n,onCancel:a}=e,[i,c]=(0,l.useState)([]),[d,u]=(0,l.useState)("pen"),[x,k]=(0,l.useState)("#ef4444"),[C,E]=(0,l.useState)(4),[S,I]=(0,l.useState)({width:800,height:600}),[A,D]=(0,l.useState)(!1),P=(0,l.useRef)(null),M=(0,l.useRef)(null),L=(0,l.useRef)(null),R=(0,l.useRef)(null),z=(0,l.useRef)({width:0,height:0}),T=(0,l.useRef)([]),U=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=new Image;e.crossOrigin="anonymous",e.onload=()=>{if(R.current=e,z.current={width:e.naturalWidth,height:e.naturalHeight},L.current){let t=L.current.clientWidth;if(t>0){let n=Math.round(t/(e.naturalWidth/e.naturalHeight));I({width:t,height:n})}else I({width:e.naturalWidth,height:e.naturalHeight})}},e.src=t},[t]),(0,l.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(e=>{let{width:t,height:n}=z.current;if(0!==t&&0!==n)for(let r of e){let e=r.contentRect.width;if(e<=0)continue;let l=Math.floor(e),s=Math.round(l/(t/n));I(e=>e.width===l&&e.height===s?e:{width:l,height:s})}});return t.observe(e),()=>t.disconnect()},[]),(0,l.useEffect)(()=>{let e=P.current,t=null==e?void 0:e.getContext("2d"),n=R.current;if(e&&t&&n)for(let r of(t.clearRect(0,0,e.width,e.height),t.drawImage(n,0,0,e.width,e.height),i))switch(r.tool){case"pen":w(t,r.points,r.color,r.lineWidth);break;case"arrow":r.points.length>=2&&j(t,r.points[0],r.points[1],r.color,r.lineWidth);break;case"circle":r.points.length>=2&&N(t,r.points[0],r.points[1],r.color,r.lineWidth);break;case"text":r.points.length>=1&&r.text&&function(e,t,n,r,l){e.fillStyle=r,e.font="".concat(l,"px sans-serif"),e.textBaseline="top";let s=n.split("\n");for(let n=0;n<s.length;n++)e.fillText(s[n],t.x,t.y+n*(l+2))}(t,r.points[0],r.text,r.color,4*r.lineWidth+12)}},[i,S]),(0,l.useEffect)(()=>{if(!A){let e=M.current,t=null==e?void 0:e.getContext("2d");e&&t&&t.clearRect(0,0,e.width,e.height)}},[A,S]),(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"z"===e.key&&(e.preventDefault(),c(e=>e.slice(0,-1))),"Escape"===e.key&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]);let q=(0,l.useCallback)(e=>{let t=M.current;if(!t)return;e.preventDefault();let n=v(t,e.nativeEvent);if("text"===d){let e=prompt("Enter text:");e&&c(t=>[...t,{id:y(),tool:"text",color:x,lineWidth:C,points:[n],text:e}]);return}D(!0),U.current=n,T.current=[n]},[d,x,C]),F=(0,l.useCallback)(e=>{if(!A)return;let t=M.current,n=null==t?void 0:t.getContext("2d");if(!t||!n)return;e.preventDefault();let r=v(t,e.nativeEvent);switch(n.clearRect(0,0,t.width,t.height),d){case"pen":T.current.push(r),w(n,T.current,x,C);break;case"arrow":U.current&&j(n,U.current,r,x,C);break;case"circle":U.current&&N(n,U.current,r,x,C)}},[A,d,x,C]),_=(0,l.useCallback)(e=>{if(!A)return;e.preventDefault();let t=M.current;if(!t)return;let n=v(t,e.nativeEvent),r=null;switch(d){case"pen":T.current.push(n),T.current.length>=2&&(r={id:y(),tool:"pen",color:x,lineWidth:C,points:[...T.current]});break;case"arrow":U.current&&(r={id:y(),tool:"arrow",color:x,lineWidth:C,points:[U.current,n]});break;case"circle":U.current&&(r={id:y(),tool:"circle",color:x,lineWidth:C,points:[U.current,n]})}D(!1),T.current=[],U.current=null,r&&c(e=>[...e,r])},[A,d,x,C]),W=(0,l.useCallback)(()=>{let e=P.current;e&&n(e.toDataURL("image/png"))},[n]),K=i.length>0;return(0,s.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-50 bg-black/90 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-surface-900 border-b border-white/[0.06] flex-wrap shrink-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-1",children:b.map(e=>{let{tool:t,icon:n,label:l}=e;return(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded text-xs font-medium transition-colors ".concat(d===t?"bg-primary-500 text-white":"text-gray-400 hover:bg-white/[0.04] hover:text-gray-200"),onClick:()=>u(t),title:l,children:[(0,r.jsx)(n,{size:14}),(0,r.jsx)("span",{children:l})]},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:g.map(e=>{let{value:t,label:n}=e;return(0,r.jsx)("button",{type:"button",className:"w-5 h-5 rounded-full cursor-pointer transition-all ".concat(x===t?"ring-2 ring-primary-500 ring-offset-1 ring-offset-surface-900 scale-110":"hover:scale-110"),onClick:()=>k(t),title:n,style:{backgroundColor:t,border:"#ffffff"===t?"1px solid #d1d5db":"none"}},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:f.map(e=>{let{value:t,label:n}=e;return(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ".concat(C===t?"bg-primary-500 text-white":"text-gray-400 hover:bg-white/[0.04] hover:text-gray-200"),onClick:()=>E(t),title:"".concat(n," line"),children:[(0,r.jsx)("span",{className:"w-5 rounded-full",style:{height:"".concat(t,"px"),backgroundColor:C===t?"white":x}}),(0,r.jsx)("span",{children:n})]},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs font-medium transition-colors text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 ".concat(K?"":"opacity-40 cursor-not-allowed"),onClick:()=>c(e=>e.slice(0,-1)),disabled:!K,title:"Undo (Ctrl+Z)",children:[(0,r.jsx)(m.A,{size:14}),(0,r.jsx)("span",{children:"Undo"})]}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs font-medium transition-colors text-red-400 hover:bg-red-500/10 hover:text-red-300 ".concat(K?"":"opacity-40 cursor-not-allowed"),onClick:()=>c([]),disabled:!K,title:"Clear all",children:[(0,r.jsx)(p.A,{size:14}),(0,r.jsx)("span",{children:"Clear"})]})]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:a,children:[(0,r.jsx)(o.A,{size:14}),"Cancel"]}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white transition-all",onClick:W,children:[(0,r.jsx)(h.A,{size:14}),"Save"]})]})]}),(0,r.jsx)("div",{ref:L,className:"flex-1 min-h-0 flex items-center justify-center p-4 overflow-auto",children:(0,r.jsxs)("div",{style:{position:"relative",width:"100%",maxWidth:S.width},children:[(0,r.jsx)("canvas",{ref:P,width:S.width,height:S.height,style:{display:"block",width:"100%",height:"auto"}}),(0,r.jsx)("canvas",{ref:M,width:S.width,height:S.height,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"text"===d?"text":"crosshair"},onMouseDown:q,onMouseMove:F,onMouseUp:_,onMouseLeave:_})]})})]}),document.body)}function C(e){let{visible:t,title:n,placeholder:c="Enter your comment...",sessionId:d,onUploadImage:u,imageUrl:x,onSubmit:m,onCancel:p}=e,[h,b]=(0,l.useState)(""),[g,f]=(0,l.useState)([]),[y,v]=(0,l.useState)(null),[w,j]=(0,l.useState)(null),N=(0,l.useRef)(null),C=(0,l.useRef)(null);async function E(e){if(u)try{let t=await u(e);j(null),f(e=>[...e,t.filename])}catch(e){j(e instanceof Error?e.message:"Upload failed"),setTimeout(()=>j(null),3e3)}}async function S(e){var t;let n=null==(t=e.clipboardData)?void 0:t.items;if(n){for(let t of Array.from(n))if(t.type.startsWith("image/")){e.preventDefault();let n=t.getAsFile();if(!n)continue;await E(n);break}}}async function I(e){let t=e.target.files;if(t){for(let e of Array.from(t))await E(e);e.target.value=""}}async function A(e){if(null!==y&&u){try{let t=await fetch(e),n=await t.blob(),r=await u(n);f(e=>e.map((e,t)=>t===y?r.filename:e))}catch(e){j(e instanceof Error?e.message:"Failed to save annotation"),setTimeout(()=>j(null),3e3)}v(null)}}function D(){let e=h.trim();(e||g.length>0)&&(m(e,g.length>0?g:void 0),b(""),f([]))}return((0,l.useEffect)(()=>{t&&(b(""),f([]),v(null),j(null),setTimeout(()=>{var e;return null==(e=N.current)?void 0:e.focus()},50))},[t]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(null!==y?v(null):p())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,y]),t)?null!==y&&g[y]&&x?(0,r.jsx)(k,{imageSrc:x(g[y]),onSave:A,onCancel:()=>v(null)}):(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center",onClick:p,children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-full max-w-md mx-4",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/[0.06]",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-white",children:n}),(0,r.jsx)("button",{className:"text-gray-500 hover:text-gray-200 transition-colors p-1 rounded hover:bg-white/[0.04]",onClick:p,children:(0,r.jsx)(o.A,{size:16})})]}),(0,r.jsxs)("div",{className:"p-5",children:[(0,r.jsx)("textarea",{ref:N,value:h,onChange:e=>b(e.target.value),onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),D())},onPaste:S,placeholder:c,rows:4,className:"w-full bg-surface-800 border border-white/[0.06] rounded-lg px-4 py-3 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 resize-none"}),w&&(0,r.jsx)("p",{className:"text-xs text-red-400 mt-2",children:w}),g.length>0&&x&&(0,r.jsx)("div",{className:"flex gap-2 flex-wrap mt-3",children:g.map((e,t)=>(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("img",{src:x(e),className:"w-16 h-16 object-cover rounded-lg border border-white/[0.06]",alt:""}),(0,r.jsx)("button",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>v(t),title:"Draw on image",children:(0,r.jsx)(a.A,{size:16,className:"text-white"})}),(0,r.jsx)("button",{className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-surface-800 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,r.jsx)(o.A,{size:10})})]},t))})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-t border-white/[0.06]",children:[(0,r.jsx)("span",{className:"text-xs text-gray-600",children:"Shift+Enter for new line"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[d&&u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"p-2 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:()=>{var e;return null==(e=C.current)?void 0:e.click()},title:"Attach image",children:(0,r.jsx)(i.A,{size:16})}),(0,r.jsx)("input",{ref:C,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:I})]}),(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:p,children:"Cancel"}),(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white transition-all disabled:opacity-50",onClick:D,disabled:!h.trim()&&0===g.length,children:"Submit"})]})]})]})}),document.body):null}},7107:(e,t,n)=>{n.d(t,{KK:()=>u,ju:()=>h,mP:()=>m,wL:()=>c});var r=n(8111),l=n(5271),s=n(8054),o=n(6718),a=n(921);let i=[{key:"j",desc:"Next section"},{key:"k",desc:"Previous section"},{key:"a",desc:"Add global comment"},{key:"c",desc:"Comment on focused section"},{key:"e",desc:"Edit focused block"},{key:"i",desc:"Toggle Instructions panel"},{key:"p",desc:"Set priority on section"},{key:"r",desc:"Flag risk on section"},{key:"?",desc:"Toggle this overlay"},{key:"⌘ Enter",desc:"Approve plan"},{key:"d",desc:"Request changes"},{key:"Esc",desc:"Close modal/overlay"}];function c(e){let{onClose:t,shortcuts:n}=e;return(0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.preventDefault(),t())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]),(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm z-50 flex items-center justify-center",onClick:t,children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-full max-w-sm mx-4 p-6",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[(0,r.jsx)(o.A,{size:16})," Keyboard Shortcuts"]}),(0,r.jsx)("button",{onClick:t,className:"text-gray-500 hover:text-gray-200 transition-colors",children:(0,r.jsx)(a.A,{size:16})})]}),(0,r.jsx)("div",{className:"space-y-2",children:(null!=n?n:i).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,r.jsx)("span",{className:"text-gray-400",children:e.desc}),(0,r.jsx)("kbd",{className:"bg-surface-800 px-2 py-0.5 rounded text-gray-200 font-mono border border-white/[0.06]",children:e.key})]},e.key))})]})}),document.body)}function d(e){let{label:t,count:n,color:l}=e;return(0,r.jsxs)("div",{className:"flex items-center justify-between bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400",children:t}),(0,r.jsx)("span",{className:"text-sm font-bold tabular-nums ".concat(l),children:n})]})}function u(e){let{isOpen:t,actionName:n,variant:o,summary:a,onConfirm:i,onCancel:c}=e,u=(0,l.useRef)(null),x=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),c()):"Enter"!==e.key||e.metaKey||e.ctrlKey||(e.preventDefault(),e.stopPropagation(),i())},[i,c]);if((0,l.useEffect)(()=>{if(t){var e;return x.current=document.activeElement,null==(e=u.current)||e.focus(),document.addEventListener("keydown",m,!0),document.body.style.overflow="hidden",()=>{var e;document.removeEventListener("keydown",m,!0),document.body.style.overflow="",null==(e=x.current)||e.focus()}}},[t,m]),!t)return null;let{annotationsByType:p,editCount:h,instructionCount:b,priorityCount:g,riskCount:f,globalComment:y}=a,v=p.comments>0||p.questions>0||p.concerns>0||p.suggestions>0||p.approvals>0||p.globalComments>0,w=v||h>0||b>0||g>0||f>0;return(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[90] flex items-center justify-center",onClick:c,children:(0,r.jsxs)("div",{ref:u,role:"dialog","aria-modal":"true",tabIndex:-1,className:"w-full max-w-md bg-surface-900 border border-white/[0.08] rounded-2xl shadow-2xl flex flex-col focus:outline-none mx-4",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"px-6 py-5 border-b border-white/[0.06]",children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold text-white",children:["Confirm: ",n]}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:w?"The following feedback will be included with your decision.":"No feedback attached. The decision will be submitted as-is."})]}),(0,r.jsxs)("div",{className:"px-6 py-5 space-y-4 max-h-[50vh] overflow-y-auto",children:[v&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Annotations"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[p.comments>0&&(0,r.jsx)(d,{label:"Comments",count:p.comments,color:"text-gray-400"}),p.questions>0&&(0,r.jsx)(d,{label:"Questions",count:p.questions,color:"text-primary-400"}),p.concerns>0&&(0,r.jsx)(d,{label:"Concerns",count:p.concerns,color:"text-amber-400"}),p.suggestions>0&&(0,r.jsx)(d,{label:"Suggestions",count:p.suggestions,color:"text-blue-400"}),p.approvals>0&&(0,r.jsx)(d,{label:"Approvals",count:p.approvals,color:"text-emerald-400"}),p.globalComments>0&&(0,r.jsx)(d,{label:"Global Comments",count:p.globalComments,color:"text-gray-500"})]})]}),(h>0||b>0||g>0||f>0)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Metadata"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[h>0&&(0,r.jsx)(d,{label:"Inline Edits",count:h,color:"text-primary-400"}),b>0&&(0,r.jsx)(d,{label:"Instructions",count:b,color:"text-blue-400"}),g>0&&(0,r.jsx)(d,{label:"Priorities Set",count:g,color:"text-amber-400"}),f>0&&(0,r.jsx)(d,{label:"Risks Flagged",count:f,color:"text-red-400"})]})]}),y&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Global Comment Preview"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 bg-white/[0.02] border border-white/[0.06] rounded-lg p-3 line-clamp-3",children:y})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/[0.06]",children:[(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:c,children:"Cancel"}),(0,r.jsx)("button",{className:"px-5 py-2 rounded-lg text-sm font-bold transition-all ".concat("approve"===o?"bg-emerald-600 text-white hover:bg-emerald-500 shadow-lg shadow-emerald-600/25":"deny"===o?"bg-red-500 text-white hover:bg-red-400 shadow-lg shadow-red-500/25":"bg-primary-500 text-white hover:bg-primary-600"),onClick:i,children:n})]}),(0,r.jsxs)("div",{className:"px-6 pb-3 flex items-center justify-center gap-3 text-xs text-gray-600",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"bg-surface-800 border border-white/[0.06] rounded px-1.5 py-0.5 font-mono text-[0.65rem]",children:"Enter"}),(0,r.jsx)("span",{children:"to confirm"})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"bg-surface-800 border border-white/[0.06] rounded px-1.5 py-0.5 font-mono text-[0.65rem]",children:"Esc"}),(0,r.jsx)("span",{children:"to cancel"})]})]})]})}),document.body)}let x=[{value:"must-have",label:"Must Have",color:"bg-red-500/15 text-red-300 border-red-500/30"},{value:"should-have",label:"Should Have",color:"bg-amber-500/15 text-amber-300 border-amber-500/30"},{value:"nice-to-have",label:"Nice to Have",color:"bg-blue-500/15 text-blue-300 border-blue-500/30"},{value:"out-of-scope",label:"Out of Scope",color:"bg-white/[0.04] text-gray-400 border-white/[0.06]"}];function m(e){let{visible:t,sectionTitle:n,currentLevel:o,currentReason:a,anchorRect:i,onSubmit:c,onRemove:d,onClose:u}=e,[m,p]=(0,l.useState)(null!=o?o:"should-have"),[h,b]=(0,l.useState)(null!=a?a:""),g=(0,l.useRef)(null);if((0,l.useEffect)(()=>{p(null!=o?o:"should-have"),b(null!=a?a:"")},[t,o,a]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&u()},n=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",n)}},[t,u]),!t)return null;let f=i?{position:"fixed",top:i.bottom+4,left:Math.min(i.left,window.innerWidth-300),zIndex:50}:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:50};return(0,s.createPortal)((0,r.jsxs)("div",{ref:g,className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-72 p-4",style:f,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Set Priority"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 truncate mb-3",children:n}),(0,r.jsx)("div",{className:"flex gap-1.5 mb-3",children:x.map(e=>(0,r.jsx)("button",{className:"flex-1 px-2 py-1.5 rounded-lg text-xs font-medium border transition-colors ".concat(m===e.value?e.color+" ring-1 ring-primary-500":"border-white/[0.06] text-gray-500 hover:bg-white/[0.04]"),onClick:()=>p(e.value),children:e.label},e.value))}),(0,r.jsx)("input",{type:"text",value:h,onChange:e=>b(e.target.value),placeholder:"Reason (optional)",className:"w-full px-3 py-2 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 mb-3",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c(m,h||void 0))}}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[o?(0,r.jsx)("button",{className:"text-xs text-red-400 hover:text-red-300 transition-colors",onClick:d,children:"Remove"}):(0,r.jsx)("span",{}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 transition-colors",onClick:u,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all",onClick:()=>c(m,h||void 0),children:"Set"})]})]})]}),document.body)}let p=[{value:"high",label:"High",color:"bg-red-500/15 text-red-300 border-red-500/30"},{value:"medium",label:"Medium",color:"bg-amber-500/15 text-amber-300 border-amber-500/30"},{value:"low",label:"Low",color:"bg-green-500/15 text-green-300 border-green-500/30"}];function h(e){let{visible:t,sectionTitle:n,currentLevel:o,currentDescription:a,anchorRect:i,onSubmit:c,onRemove:d,onClose:u}=e,[x,m]=(0,l.useState)(null!=o?o:"medium"),[h,b]=(0,l.useState)(null!=a?a:""),g=(0,l.useRef)(null);if((0,l.useEffect)(()=>{m(null!=o?o:"medium"),b(null!=a?a:"")},[t,o,a]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&u()},n=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",n)}},[t,u]),!t)return null;let f=i?{position:"fixed",top:i.bottom+4,left:Math.min(i.left,window.innerWidth-300),zIndex:50}:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:50};return(0,s.createPortal)((0,r.jsxs)("div",{ref:g,className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-72 p-4",style:f,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Flag Risk"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 truncate mb-3",children:n}),(0,r.jsx)("div",{className:"flex gap-1.5 mb-3",children:p.map(e=>(0,r.jsx)("button",{className:"flex-1 px-2 py-1.5 rounded-lg text-xs font-medium border transition-colors ".concat(x===e.value?e.color+" ring-1 ring-primary-500":"border-white/[0.06] text-gray-500 hover:bg-white/[0.04]"),onClick:()=>m(e.value),children:e.label},e.value))}),(0,r.jsx)("input",{type:"text",value:h,onChange:e=>b(e.target.value),placeholder:"Description (optional)",className:"w-full px-3 py-2 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 mb-3",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c(x,h||void 0))}}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[o?(0,r.jsx)("button",{className:"text-xs text-red-400 hover:text-red-300 transition-colors",onClick:d,children:"Remove"}):(0,r.jsx)("span",{}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 transition-colors",onClick:u,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all",onClick:()=>c(x,h||void 0),children:"Set"})]})]})]}),document.body)}},9283:(e,t,n)=>{n.d(t,{y:()=>d});var r=n(8111),l=n(5271),s=n(4451),o=n(8183),a=n(6062),i=n(3468),c=n(9396);function d(e){let{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:s,annotationFilter:o,setAnnotationFilter:a,sections:i,priorities:c,risks:d,instructions:m,onRemoveAnnotation:p,onAddGlobalComment:h,onAddInstruction:b,onDeleteInstruction:g,renderAnnotationImage:f,extraTabs:y=[],activeTab:v,onTabChange:w}=e,j=[{id:"notes",label:"Notes (".concat(t.length,")")},{id:"instructions",label:"Instr (".concat(m.length,")")},...y.map(e=>({id:e.id,label:void 0!==e.count?"".concat(e.label," (").concat(e.count,")"):e.label}))];return(0,r.jsxs)("aside",{className:"hidden lg:flex w-80 border-l border-white/[0.06] bg-surface-900 overflow-y-auto flex-shrink-0 flex-col",children:[(0,r.jsx)("div",{className:"flex border-b border-white/[0.06]",children:j.map(e=>(0,r.jsx)("button",{onClick:()=>w(e.id),className:"flex-1 px-3 py-2.5 text-xs font-semibold uppercase tracking-wider transition-colors ".concat(v===e.id?"text-primary-400 border-b-2 border-primary-500":"text-gray-500 hover:text-gray-300"),children:e.label},e.id))}),"notes"===v&&(0,r.jsx)(u,{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:s,annotationFilter:o,setAnnotationFilter:a,sections:i,priorities:c,risks:d,onRemoveAnnotation:p,onAddGlobalComment:h,renderAnnotationImage:f}),"instructions"===v&&(0,r.jsx)(x,{instructions:m,sections:i,onAdd:b,onDelete:g}),y.map(e=>v===e.id&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:e.render()},e.id))]})}function u(e){let{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:i,annotationFilter:c,setAnnotationFilter:d,sections:u,priorities:x,risks:m,onRemoveAnnotation:h,onAddGlobalComment:b,renderAnnotationImage:g}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"p-4 border-b border-white/[0.06] flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-white",children:"Annotations"}),(0,r.jsxs)("button",{onClick:b,className:"flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-medium text-primary-400 hover:bg-primary-500/10 transition-colors",title:"Add global comment",children:[(0,r.jsx)(s.A,{size:12})," Add"]})]}),t.length>0&&(0,r.jsx)("div",{className:"px-4 py-2 border-b border-white/[0.06]",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(o.A,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),(0,r.jsx)("input",{type:"text",placeholder:"Filter annotations...",value:c,onChange:e=>d(e.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50"})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===n.length&&0===x.length&&0===m.length?(0,r.jsxs)("div",{className:"p-6 text-center",children:[(0,r.jsx)(a.A,{size:32,className:"mx-auto text-gray-600 mb-2"}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No annotations yet"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:"Select text or right-click on sections to add annotations"})]}):(0,r.jsxs)("div",{className:"pb-2",children:[l.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Global Comments"}),(0,r.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,r.jsx)(p,{ann:e,onRemove:h,renderImage:g},e.id))})]}),Array.from(i.entries()).map(e=>{var t,n;let[l,s]=e;return(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2 truncate",children:null!=(n=null==(t=u.find(e=>e.id===l))?void 0:t.title)?n:l}),(0,r.jsx)("div",{className:"space-y-2",children:s.map(e=>(0,r.jsx)(p,{ann:e,onRemove:h,renderImage:g},e.id))})]},l)}),x.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Priorities"}),(0,r.jsx)("div",{className:"space-y-2",children:x.map(e=>{var t,n;let l=null!=(n=null==(t=u.find(t=>t.id===e.sectionId))?void 0:t.title)?n:e.sectionId,s="must-have"===e.priority?"bg-red-500/15 text-red-300 border-red-500/30":"should-have"===e.priority?"bg-amber-500/15 text-amber-300 border-amber-500/30":"nice-to-have"===e.priority?"bg-blue-500/15 text-blue-300 border-blue-500/30":"bg-white/[0.04] text-gray-400 border-white/[0.06]";return(0,r.jsxs)("div",{className:"bg-white/[0.02] rounded-xl p-3 border-l-[3px] border-l-amber-400",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 truncate",children:l}),(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ".concat(s),children:e.priority})]}),e.note&&(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.note})]},e.sectionId)})})]}),m.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Risks"}),(0,r.jsx)("div",{className:"space-y-2",children:m.map(e=>{var t,n;let l=null!=(n=null==(t=u.find(t=>t.id===e.sectionId))?void 0:t.title)?n:e.sectionId,s="high"===e.level?"bg-red-500/15 text-red-300 border-red-500/30":"medium"===e.level?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-green-500/15 text-green-300 border-green-500/30";return(0,r.jsxs)("div",{className:"bg-white/[0.02] rounded-xl p-3 border-l-[3px] border-l-red-400",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 truncate",children:l}),(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ".concat(s),children:e.level})]}),e.description&&(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.description})]},e.sectionId)})})]})]})})]})}function x(e){let{instructions:t,sections:n,onAdd:s,onDelete:o}=e,[a,d]=(0,l.useState)(null),u=(0,l.useMemo)(()=>{let e=new Map;for(let r of t){var n;let t=null!=(n=e.get(r.sectionId))?n:[];t.push(r),e.set(r.sectionId,t)}return e},[t]);return(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[n.map((e,t)=>{var n;let l=null!=(n=u.get(e.id))?n:[];return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-gray-500 uppercase tracking-wider truncate",children:e.title}),(0,r.jsx)("button",{className:"w-6 h-6 flex items-center justify-center border border-white/[0.06] rounded text-sm text-gray-500 hover:bg-primary-500 hover:border-primary-500 hover:text-white transition-colors",onClick:()=>d(a===t?null:t),title:"Add instruction",children:a===t?"-":"+"})]}),a===t&&(0,r.jsx)(m,{sectionId:e.id,onSubmit:(e,t,n)=>{s(e,t,n),d(null)},onCancel:()=>d(null)}),l.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,r.jsxs)("div",{className:"bg-white/[0.02] border border-white/[0.06] rounded-lg p-3",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300 leading-relaxed",children:e.instruction}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.priority&&(0,r.jsx)("span",{className:"inline-flex px-2 py-0.5 rounded-full text-xs font-medium border ".concat("must"===e.priority?"text-red-300 bg-red-500/15 border-red-500/30":"should"===e.priority?"text-amber-300 bg-amber-500/15 border-amber-500/30":"text-gray-400 bg-white/[0.04] border-white/[0.06]"),children:e.priority}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,c.fF)(e.createdAt)})]}),(0,r.jsx)("button",{onClick:()=>o(e.id),className:"text-gray-600 hover:text-red-400 transition-colors",title:"Delete",children:(0,r.jsx)(i.A,{size:12})})]})]},e.id))})]},e.id)}),0===t.length&&(0,r.jsxs)("div",{className:"text-center py-8",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No instructions yet"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:"Click + on a section to add implementation directives"})]})]})}function m(e){let{sectionId:t,onSubmit:n,onCancel:s}=e,[o,a]=(0,l.useState)(""),[i,c]=(0,l.useState)("");return(0,r.jsxs)("div",{className:"bg-white/[0.02] border border-white/[0.06] rounded-lg p-3 space-y-3",children:[(0,r.jsx)("textarea",{className:"w-full min-h-16 p-2.5 text-sm bg-surface-800 border border-white/[0.06] rounded-md text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 resize-y transition-colors",value:o,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o.trim()&&n(t,o.trim(),i||void 0)),"Escape"===e.key&&s()},placeholder:"Enter instruction...",rows:3,autoFocus:!0}),(0,r.jsxs)("select",{className:"w-full p-2 text-sm bg-surface-800 border border-white/[0.06] rounded-md text-gray-400 focus:outline-none focus:border-primary-500/50",value:i,onChange:e=>c(e.target.value),children:[(0,r.jsx)("option",{value:"",children:"No priority"}),(0,r.jsx)("option",{value:"must",children:"Must"}),(0,r.jsx)("option",{value:"should",children:"Should"}),(0,r.jsx)("option",{value:"nice-to-have",children:"Nice to have"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border border-white/[0.06] text-gray-400 rounded-md hover:bg-white/[0.04] transition-colors",onClick:s,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-primary-500 text-white rounded-md hover:bg-primary-600 disabled:opacity-40 transition-all",onClick:()=>{o.trim()&&n(t,o.trim(),i||void 0)},disabled:!o.trim(),children:"Add"})]})]})}function p(e){let{ann:t,onRemove:n,renderImage:l}=e;return(0,r.jsxs)("div",{className:"border-l-2 ".concat(c.D5[t.type]," rounded-r-lg p-3 group"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded border ".concat(c.s0[t.type]),children:t.type}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,c.fF)(t.createdAt)})]}),(0,r.jsx)("button",{onClick:()=>n(t.id),className:"text-gray-600 hover:text-red-400 text-xs transition-colors opacity-0 group-hover:opacity-100",children:(0,r.jsx)(i.A,{size:12})})]}),(0,r.jsx)("p",{className:"text-sm text-gray-300 mt-1 whitespace-pre-wrap",children:t.text}),t.imagePaths&&t.imagePaths.length>0&&l&&(0,r.jsx)("div",{className:"flex gap-1.5 mt-2 flex-wrap",children:t.imagePaths.map((e,t)=>l(e,t))})]})}},9396:(e,t,n)=>{n.d(t,{D5:()=>r,Dx:()=>o,fF:()=>s,s0:()=>l});let r={comment:"border-blue-400 bg-blue-500/10",suggestion:"border-violet-400 bg-violet-500/10",concern:"border-amber-400 bg-amber-500/10",question:"border-cyan-400 bg-cyan-500/10",approval:"border-emerald-400 bg-emerald-500/10",instruction:"border-orange-400 bg-orange-500/10",global_comment:"border-blue-400 bg-blue-500/10"},l={comment:"bg-blue-500/10 text-blue-300 border-blue-500/20",suggestion:"bg-violet-500/10 text-violet-300 border-violet-500/20",concern:"bg-amber-500/10 text-amber-300 border-amber-500/20",question:"bg-cyan-500/10 text-cyan-300 border-cyan-500/20",approval:"bg-emerald-500/10 text-emerald-300 border-emerald-500/20",instruction:"bg-orange-500/10 text-orange-300 border-orange-500/20",global_comment:"bg-blue-500/10 text-blue-300 border-blue-500/20"};function s(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return"".concat(n,"m ago");let r=Math.floor(n/60);if(r<24)return"".concat(r,"h ago");let l=Math.floor(r/24);return"".concat(l,"d ago")}function o(e){if(!e)return[];let t=e.split("\n"),n=[],r=null,l=new Set;function s(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"section",n=t,r=2;for(;l.has(n);)n="".concat(t,"-").concat(r++);return l.add(n),n}for(let e=0;e<t.length;e++){var o,a,i;let l=null!=(o=t[e])?o:"",c=l.match(/^(#{1,6})\s+(.+)/);c?(r&&n.push({id:s(r.title),title:r.title,level:r.level,content:r.lines.join("\n"),startLine:r.startLine}),r={title:null!=(a=c[2])?a:"",level:(null!=(i=c[1])?i:"#").length,lines:[l],startLine:e}):r?r.lines.push(l):l.trim()&&(r={title:"Overview",level:1,lines:[l],startLine:e})}return r&&n.push({id:s(r.title),title:r.title,level:r.level,content:r.lines.join("\n"),startLine:r.startLine}),n}},9951:(e,t,n)=>{n.d(t,{t:()=>c});var r=n(8111),l=n(5271),s=n(8054);let o={comment:"\uD83D\uDCAC",suggest:"✏️",concern:"⚠️",question:"❓",annotate:"➕",edit:"✏️",instruction:"\uD83D\uDCCB",priority:"\uD83C\uDFF7️",risk:"⚠️"},a=[{icon:"comment",label:"Add Comment",action:{type:"comment"}},{icon:"suggest",label:"Suggest Change",action:{type:"suggest"}},{icon:"concern",label:"Raise Concern",action:{type:"concern"}},{icon:"question",label:"Ask Question",action:{type:"question"}}],i=[{icon:"annotate",label:"Annotate Block",submenu:[{icon:"comment",label:"Comment",action:{type:"comment"}},{icon:"suggest",label:"Suggest",action:{type:"suggest"}},{icon:"concern",label:"Concern",action:{type:"concern"}},{icon:"question",label:"Question",action:{type:"question"}}]},{separator:!0,icon:"",label:""},{icon:"edit",label:"Edit Block",action:{type:"edit"}},{separator:!0,icon:"",label:""},{icon:"instruction",label:"Add Instruction",action:{type:"instruction"}},{icon:"priority",label:"Set Priority",action:{type:"priority"}},{icon:"risk",label:"Flag Risk",action:{type:"risk"}}];function c(e){let{visible:t,x:n,y:c,mode:d,onAction:u,onClose:x}=e,m=(0,l.useRef)(null),[p,h]=(0,l.useState)({x:n,y:c}),[b,g]=(0,l.useState)(null);return((0,l.useEffect)(()=>{if(t)h({x:Math.max(10,Math.min(n,window.innerWidth-220-10)),y:Math.max(10,Math.min(c,window.innerHeight-400-10))})},[t,n,c]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{m.current&&!m.current.contains(e.target)&&x()},n=e=>{"Escape"===e.key&&x()},r=()=>x();return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n),document.removeEventListener("scroll",r,!0)}},[t,x]),t)?(0,s.createPortal)((0,r.jsx)("div",{ref:m,className:"fixed rounded-xl border border-white/[0.08] bg-surface-900 shadow-2xl z-50 min-w-48 py-1",style:{left:"".concat(p.x,"px"),top:"".concat(p.y,"px")},children:("selection"===d?a:i).map((e,t)=>{var n;if(e.separator)return(0,r.jsx)("div",{className:"h-px bg-white/[0.06] my-1"},"sep-".concat(t));let l=!!e.submenu,s=b===e.label;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{className:"flex items-center gap-3 w-full px-3 py-2 text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 cursor-pointer rounded-lg mx-1 transition-colors duration-150",onClick:()=>{e.submenu?g(b===e.label?null:e.label):e.action&&(u(e.action),x())},children:[(0,r.jsx)("span",{className:"w-5 text-center",children:null!=(n=o[e.icon])?n:"\uD83D\uDCDD"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label}),l&&(0,r.jsx)("span",{className:"text-gray-600 text-xs",children:"▶"})]}),l&&s&&(0,r.jsx)("div",{className:"ml-4 border-l border-white/[0.06]",children:e.submenu.map(e=>{var t;return(0,r.jsxs)("button",{className:"flex items-center gap-3 w-full px-3 py-2 text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 cursor-pointer rounded-lg mx-1 transition-colors duration-150",onClick:()=>{e.action&&(u(e.action),x())},children:[(0,r.jsx)("span",{className:"w-5 text-center",children:null!=(t=o[e.icon])?t:"\uD83D\uDCDD"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label})]},e.label)})})]},e.label)})}),document.body):null}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7525],{33:(e,t,n)=>{n.d(t,{U:()=>s});var r=n(8111);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=100===t?e/10:e;return n>=8?"text-emerald-400":n>=6?"text-amber-400":n>=4?"text-orange-400":"text-red-400"}function s(e){let{score:t,onRequestAiScore:n,aiScoreLoading:s=!1,aiScoringAvailable:o=!1,scale:a=10}=e,i=100===a?Math.round(t.overall).toString():t.overall.toFixed(1);return(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-white",children:"Quality Score"}),(0,r.jsxs)("span",{className:"text-lg font-bold ".concat(l(t.overall,a)),children:[i,"/",100===a?"100":"10"]}),t.isAiScore&&(0,r.jsxs)("span",{className:"rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium text-primary-400 border border-primary-500/20",children:["AI ",t.aiModel?"(".concat(t.aiModel,")"):""]})]}),o&&!t.isAiScore&&n&&(0,r.jsx)("button",{onClick:n,disabled:s,className:"rounded-lg bg-primary-500/10 px-3 py-1.5 text-xs font-medium text-primary-400 transition-colors hover:bg-primary-500/20 disabled:opacity-50",children:s?"Scoring...":"AI Score"})]}),(0,r.jsx)("div",{className:"space-y-2.5",children:t.breakdown.map(e=>(0,r.jsxs)("div",{className:"group",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-xs text-gray-400 capitalize",children:e.name}),(0,r.jsx)("span",{className:"text-xs font-medium ".concat(l(e.score)),children:e.score.toFixed(1)})]}),(0,r.jsx)("div",{className:"h-1.5 w-full rounded-full bg-white/[0.06]",children:(0,r.jsx)("div",{className:"h-full rounded-full transition-all ".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=100===t?e/10:e;return n>=8?"bg-emerald-500":n>=6?"bg-amber-500":n>=4?"bg-orange-500":"bg-red-500"}(e.score)),style:{width:"".concat(Math.min(10*e.score,100),"%")}})}),e.details&&(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity",children:e.details})]},e.name))}),t.suggestions.length>0&&(0,r.jsxs)("div",{className:"mt-4 pt-3 border-t border-white/[0.04]",children:[(0,r.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-wider text-gray-500 mb-2",children:"Suggestions"}),(0,r.jsx)("ul",{className:"space-y-1",children:t.suggestions.map((e,t)=>(0,r.jsxs)("li",{className:"text-xs text-gray-400 flex gap-2",children:[(0,r.jsx)("span",{className:"text-gray-600 shrink-0",children:"-"}),(0,r.jsx)("span",{children:e})]},t))})]})]})}},64:(e,t,n)=>{n.d(t,{U:()=>s});var r=n(5271),l=n(9396);function s(e){var t,n,s,o,a;let{markdown:i,onMarkdownChange:c,readOnly:d,initialState:u,onExtraKeyDown:x}=e,[m,p]=(0,r.useState)(null!=(t=null==u?void 0:u.annotations)?t:[]),[h,b]=(0,r.useState)(null!=(n=null==u?void 0:u.inlineEdits)?n:[]),[g,f]=(0,r.useState)(null!=(s=null==u?void 0:u.priorities)?s:[]),[y,v]=(0,r.useState)(null!=(o=null==u?void 0:u.risks)?o:[]),[w,j]=(0,r.useState)(null!=(a=null==u?void 0:u.instructions)?a:[]),[N,k]=(0,r.useState)(new Set),[C,E]=(0,r.useState)(""),[S,I]=(0,r.useState)(null),[A,D]=(0,r.useState)(null),[P,M]=(0,r.useState)("notes"),[L,R]=(0,r.useState)(!1),[z,T]=(0,r.useState)(null),[U,q]=(0,r.useState)(null),[F,_]=(0,r.useState)(""),[W,K]=(0,r.useState)(null),[O,B]=(0,r.useState)({visible:!1,x:0,y:0,mode:"block",sectionIdx:null}),[G,H]=(0,r.useState)(null),[J,X]=(0,r.useState)(null),[$,Q]=(0,r.useState)(!1),[Y,Z]=(0,r.useState)(!1),[,V]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=setInterval(()=>V(e=>e+1),3e4);return()=>clearInterval(e)},[]);let ee=(0,r.useMemo)(()=>(0,l.Dx)(i),[i]),et=(0,r.useMemo)(()=>{let e=new Map;for(let n of m){var t;if(!n.sectionId||"global"===n.sectionId)continue;let r=null!=(t=e.get(n.sectionId))?t:[];r.push(n),e.set(n.sectionId,r)}return e},[m]),en=(0,r.useMemo)(()=>{if(!C.trim())return m;let e=C.toLowerCase();return m.filter(t=>t.text.toLowerCase().includes(e)||t.type.toLowerCase().includes(e))},[m,C]),er=en.filter(e=>"global"===e.sectionId),el=(0,r.useMemo)(()=>{let e=new Map;for(let t of en)t.sectionId&&"global"!==t.sectionId&&(e.has(t.sectionId)||e.set(t.sectionId,[]),e.get(t.sectionId).push(t));return e},[en]),es=(0,r.useCallback)(e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),eo=(0,r.useCallback)((e,t)=>{var n,r;if(!W)return;let l={id:crypto.randomUUID(),type:W.type,text:W.selectedText?"> ".concat(W.selectedText,"\n\n").concat(e):e,sectionId:null!==W.sectionIdx?null!=(r=null==(n=ee[W.sectionIdx])?void 0:n.id)?r:String(W.sectionIdx):"global",createdAt:Date.now(),imagePaths:t};p(e=>[...e,l]),K(null)},[W,ee]),ea=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||!e.toString().trim())return void R(!1);let t=e.toString().trim(),n=e.getRangeAt(0),r=n.getBoundingClientRect(),l=n.startContainer,s=null;for(;l;){if(l instanceof HTMLElement){let e=l.getAttribute("data-section-idx");if(null!==e){s=Number(e);break}}l=l.parentNode}_(t),q(s),T(r),R(!0)},[]),ei=(0,r.useCallback)(()=>{R(!1)},[]),ec=(0,r.useCallback)(e=>{var t;R(!1),K({visible:!0,title:"Add ".concat(e),sectionIdx:U,type:"instruction"===e?"instruction":e,selectedText:F}),null==(t=window.getSelection())||t.removeAllRanges()},[U,F]),ed=(0,r.useCallback)((e,t)=>{e.preventDefault();let n=window.getSelection(),r=n&&!n.isCollapsed&&n.toString().trim().length>0;B({visible:!0,x:e.clientX,y:e.clientY,mode:r?"selection":"block",sectionIdx:t}),r&&(_(n.toString().trim()),q(t))},[]),eu=(0,r.useCallback)(e=>{let t=O.sectionIdx;switch(e.type){case"comment":case"suggest":case"concern":case"question":{var n;let r=null!=(n=({comment:"comment",suggest:"suggestion",concern:"concern",question:"question"})[e.type])?n:"comment";K({visible:!0,title:"Add ".concat(r),sectionIdx:t,type:r,selectedText:"selection"===O.mode?F:void 0});break}case"instruction":K({visible:!0,title:"Add Instruction",sectionIdx:t,type:"instruction"});break;case"edit":d||I(t);break;case"priority":H(t);break;case"risk":X(t)}B(e=>({...e,visible:!1}))},[O,F,d]),ex=(0,r.useCallback)(e=>{var t;if(null===S)return;let n=ee[S];if(!n)return;let r=null!=(t=n.id)?t:String(S);b(t=>[...t.filter(e=>e.blockId!==r),{blockId:r,originalContent:n.content,editedContent:e}]);let l=i.split("\n"),s=n.content.split("\n"),o=e.split("\n");l.splice(n.startLine,s.length,...o),null==c||c(l.join("\n")),I(null)},[S,ee,i,c]),em=(0,r.useCallback)((e,t)=>{var n,r;if(null===G)return;let l=null!=(r=null==(n=ee[G])?void 0:n.id)?r:String(G);f(n=>[...n.filter(e=>e.sectionId!==l),{sectionId:l,priority:e,note:t}]),H(null)},[G,ee]),ep=(0,r.useCallback)(()=>{var e,t;if(null===G)return;let n=null!=(t=null==(e=ee[G])?void 0:e.id)?t:String(G);f(e=>e.filter(e=>e.sectionId!==n)),H(null)},[G,ee]),eh=(0,r.useCallback)((e,t)=>{var n,r;if(null===J)return;let l=null!=(r=null==(n=ee[J])?void 0:n.id)?r:String(J);v(n=>[...n.filter(e=>e.sectionId!==l),{sectionId:l,level:e,description:t}]),X(null)},[J,ee]),eb=(0,r.useCallback)(()=>{var e,t;if(null===J)return;let n=null!=(t=null==(e=ee[J])?void 0:e.id)?t:String(J);v(e=>e.filter(e=>e.sectionId!==n)),X(null)},[J,ee]),eg=(0,r.useCallback)((e,t,n)=>{j(r=>[...r,{id:crypto.randomUUID(),sectionId:e,instruction:t,priority:n,createdAt:Date.now()}])},[]),ef=(0,r.useCallback)(e=>{j(t=>t.filter(t=>t.id!==e))},[]),ey=(0,r.useCallback)(()=>{var e;let t={comments:0,questions:0,concerns:0,suggestions:0,approvals:0,instructions:0,globalComments:0};for(let e of m)"comment"===e.type?t.comments++:"question"===e.type?t.questions++:"concern"===e.type?t.concerns++:"suggestion"===e.type?t.suggestions++:"approval"===e.type?t.approvals++:"instruction"===e.type?t.instructions++:"global_comment"===e.type&&t.globalComments++;let n=m.find(e=>"global_comment"===e.type);return{annotationCount:m.length,annotationsByType:t,editCount:h.length,instructionCount:w.length,priorityCount:g.length,riskCount:y.length,globalComment:null==n||null==(e=n.text)?void 0:e.slice(0,200)}},[m,h,w,g,y]),ev=(0,r.useRef)(W);ev.current=W,(0,r.useEffect)(()=>{function e(e){let t=e.target,n="TEXTAREA"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName||"true"===t.contentEditable;if("Escape"===e.key)return Y?void Z(!1):$?void Q(!1):O.visible?void B(e=>({...e,visible:!1})):null!==G?void H(null):null!==J?void X(null):null!==S?void I(null):void 0;if(!n&&!ev.current&&(null==x||!x(e,A)))switch(e.key){case"?":e.preventDefault(),Z(e=>!e);break;case"j":e.preventDefault(),D(e=>{let t=(null!=e?e:-1)+1;return t<ee.length?t:e});break;case"k":e.preventDefault(),D(e=>{let t=(null!=e?e:1)-1;return t>=0?t:e});break;case"a":case"A":e.preventDefault(),K({visible:!0,title:"Add Global Comment",sectionIdx:null,type:"global_comment"});break;case"c":null!==A&&(e.preventDefault(),K({visible:!0,title:"Add Comment",sectionIdx:A,type:"comment"}));break;case"e":null===A||d||(e.preventDefault(),I(A));break;case"i":e.preventDefault(),M(e=>"instructions"===e?"notes":"instructions");break;case"p":null!==A&&(e.preventDefault(),H(e=>e===A?null:A),X(null));break;case"r":null!==A&&(e.preventDefault(),X(e=>e===A?null:A),H(null))}}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Y,$,O.visible,G,J,S,A,ee.length,d,x]);let ew=(0,r.useCallback)(()=>{p([]),b([]),f([]),v([]),j([]),k(new Set),E(""),I(null),D(null),K(null),B({visible:!1,x:0,y:0,mode:"block",sectionIdx:null}),H(null),X(null),Q(!1),Z(!1)},[]);return{sections:ee,annotations:m,setAnnotations:p,sectionAnnotations:et,filteredAnnotations:en,filteredGlobal:er,filteredSectionGroups:el,annotationFilter:C,setAnnotationFilter:E,handleAnnotationSubmit:eo,inlineEdits:h,setInlineEdits:b,editingSectionIdx:S,setEditingSectionIdx:I,handleEditCommit:ex,priorities:g,setPriorities:f,priorityPopoverSection:G,setPriorityPopoverSection:H,handleSetPriority:em,handleRemovePriority:ep,risks:y,setRisks:v,riskPopoverSection:J,setRiskPopoverSection:X,handleSetRisk:eh,handleRemoveRisk:eb,instructions:w,setInstructions:j,handleAddInstruction:eg,handleDeleteInstruction:ef,collapsedSections:N,toggleSection:es,focusedSection:A,setFocusedSection:D,toolbarVisible:L,toolbarRect:z,handleMouseUp:ea,handleContentMouseDown:ei,handleToolbarAction:ec,contextMenu:O,setContextMenu:B,handleContextMenu:ed,handleContextMenuAction:eu,commentDialog:W,setCommentDialog:K,rightPanel:P,setRightPanel:M,showExport:$,setShowExport:Q,showKeyboard:Y,setShowKeyboard:Z,buildConfirmationSummary:ey,resetEditorState:ew}}},422:(e,t,n)=>{n.d(t,{J:()=>s,h:()=>l});var r=n(7811);function l(){return"local"===r.env.NEXT_PUBLIC_ULPI_MODE,"https://ulpi-cloud-api.ngrok.app"}function s(){return"local"===r.env.NEXT_PUBLIC_ULPI_MODE||!0==="https://ulpi-cloud-api.ngrok.app".includes("localhost")}},656:(e,t,n)=>{n.d(t,{w:()=>x});var r=n(8111),l=n(5271),s=n(8054),o=n(8221),a=n(8913),i=n(9156),c=n(3881),d=n(7774);let u=[{type:"comment",icon:o.A,label:"Comment"},{type:"suggestion",icon:a.A,label:"Suggest"},{type:"concern",icon:i.A,label:"Concern"},{type:"question",icon:c.A,label:"Question"},{type:"instruction",icon:d.A,label:"Instruct"}];function x(e){let{visible:t,rect:n,onAction:o}=e,[a,i]=(0,l.useState)({x:0,y:0});return((0,l.useEffect)(()=>{if(!t||!n)return;let e=n.left+(n.width-360)/2,r=n.top-48-8+window.scrollY;e=Math.max(8,Math.min(e,window.innerWidth-360-8)),n.top-48-8<0&&(r=n.bottom+8+window.scrollY),i({x:e,y:r})},[t,n]),t&&n)?(0,s.createPortal)((0,r.jsx)("div",{className:"fixed rounded-xl border border-white/[0.08] bg-surface-900 shadow-xl z-50 p-1.5 flex gap-1",style:{left:"".concat(a.x,"px"),top:"".concat(a.y,"px")},onMouseDown:e=>e.preventDefault(),children:u.map(e=>(0,r.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 transition-colors",onClick:()=>o(e.type),title:e.label,children:[(0,r.jsx)(e.icon,{size:14}),(0,r.jsx)("span",{children:e.label})]},e.type))}),document.body):null}},1224:(e,t,n)=>{n.d(t,{C:()=>m});var r=n(8111),l=n(5271),s=n(2214),o=n(839),a=n(7325),i=n(9413),c=n(4285),d=n(6062);function u(e){let{content:t,isCode:n=!1,onCommit:s,onCancel:o}=e,[a,i]=(0,l.useState)(t),c=(0,l.useRef)(null);return(0,l.useEffect)(()=>{i(t)},[t]),(0,l.useEffect)(()=>{var e,t;null==(e=c.current)||e.focus(),null==(t=c.current)||t.select()},[]),(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key?(e.preventDefault(),s(a)):"Escape"===e.key&&(e.preventDefault(),o())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a,s,o]),(0,r.jsxs)("div",{className:"relative border-2 border-primary-500 rounded-md bg-primary-500/5 p-2 my-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-2 bg-primary-500/15 rounded border border-primary-500/30 mb-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-primary-300",children:"Editing"}),(0,r.jsx)("span",{className:"text-xs text-gray-500 ml-auto",children:"Cmd+Enter to save, Esc to cancel"})]}),(0,r.jsx)("textarea",{ref:c,className:"w-full min-h-24 p-3 text-sm leading-relaxed bg-surface-800 border border-white/[0.06] rounded-md text-gray-200 focus:outline-none focus:border-primary-500 resize-y transition-colors ".concat(n?"font-mono":""),value:a,onChange:e=>i(e.target.value),spellCheck:!n}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2 mt-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border border-white/[0.06] text-gray-400 rounded-md hover:bg-white/[0.04] transition-colors",onClick:o,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-primary-600 text-white rounded-md hover:bg-primary-700 transition-colors",onClick:()=>s(a),children:"Save Changes"})]})]})}var x=n(9396);function m(e){let{sections:t,markdown:n,sectionAnnotations:m,collapsedSections:p,focusedSection:h,editingSectionIdx:b,priorities:g,risks:f,onToggleSection:y,onContextMenu:v,onEditCommit:w,onEditCancel:j,onAddComment:N,renderAnnotationImage:k}=e,C=(0,l.useMemo)(()=>[o.A],[]),E=(0,l.useMemo)(()=>[a.A],[]);return(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-6 md:p-8 space-y-1",children:[t.map((e,t)=>{var n;let l=p.has(t),o=null!=(n=m.get(e.id))?n:[],a=h===t,S=b===t,I=g.find(t=>t.sectionId===e.id),A=f.find(t=>t.sectionId===e.id),D=o.length>0?o[0].type:null,P=D?x.D5[D]:"";return(0,r.jsxs)("div",{"data-section-idx":t,className:"relative group rounded-lg transition-colors duration-150 ".concat(a?"bg-primary-500/5 ring-1 ring-primary-500/30":""," ").concat(P?"border-l-[3px] ".concat(P," pl-3"):""),onContextMenu:e=>v(e,t),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer py-1 hover:bg-white/[0.02] rounded -mx-2 px-2",onClick:()=>y(t),children:[l?(0,r.jsx)(i.A,{size:16,className:"text-gray-600"}):(0,r.jsx)(c.A,{size:16,className:"text-gray-600"}),(0,r.jsx)("span",{className:"font-semibold text-white ".concat(e.level<=2?"text-lg":"text-base"),children:e.title}),o.length>0&&(0,r.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full text-[10px] font-medium bg-primary-500/20 text-primary-400",children:o.length}),I&&(0,r.jsx)("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium border ".concat("must-have"===I.priority?"bg-red-500/15 text-red-300 border-red-500/30":"should-have"===I.priority?"bg-amber-500/15 text-amber-300 border-amber-500/30":"nice-to-have"===I.priority?"bg-blue-500/15 text-blue-300 border-blue-500/30":"bg-white/[0.04] text-gray-400 border-white/[0.06]"),children:I.priority}),A&&(0,r.jsxs)("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium border ".concat("high"===A.level?"bg-red-500/15 text-red-300 border-red-500/30":"medium"===A.level?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-green-500/15 text-green-300 border-green-500/30"),children:["risk: ",A.level]}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),N(t)},className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-white/[0.06]",title:"Add annotation",children:(0,r.jsx)(d.A,{size:14,className:"text-gray-500"})})]}),!l&&(S?(0,r.jsx)("div",{className:"pl-6",children:(0,r.jsx)(u,{content:e.content,isCode:e.content.includes("```"),onCommit:w,onCancel:j})}):(0,r.jsx)("div",{className:"md-render pl-6 prose prose-invert prose-sm max-w-none",children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:E,children:e.content.replace(/^#{1,6}\s+.+\n?/,"")})})),!l&&o.length>0&&!S&&(0,r.jsx)("div",{className:"ml-6 mt-2 space-y-2",children:o.map(e=>(0,r.jsxs)("div",{className:"border-l-2 ".concat(x.D5[e.type]," rounded-r-lg p-3 text-sm"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded border ".concat(x.s0[e.type]),children:e.type}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,x.fF)(e.createdAt)})]}),(0,r.jsx)("p",{className:"text-gray-300 whitespace-pre-wrap text-xs",children:e.text}),e.imagePaths&&e.imagePaths.length>0&&k&&(0,r.jsx)("div",{className:"flex gap-2 mt-2 flex-wrap",children:e.imagePaths.map((e,t)=>k(e,t))})]},e.id))})]},t)}),0===t.length&&n&&(0,r.jsx)("div",{className:"prose prose-invert prose-sm max-w-none",children:(0,r.jsx)(s.oz,{remarkPlugins:C,rehypePlugins:E,children:n})}),!n&&(0,r.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No content available"})})]})}},2630:(e,t,n)=>{n.d(t,{O:()=>i});var r=n(8111),l=n(5271),s=n(8054),o=n(921);let a=[{id:"markdown",label:"Markdown",extension:".md",description:"Annotated markdown with review comments, priorities, and risks."},{id:"github",label:"GitHub Issue",extension:".md",description:"Formatted for GitHub Issues with checklist and annotations."},{id:"jira",label:"Jira",extension:".md",description:"Jira-compatible format with ADF-style headers, tables, and {code} blocks."},{id:"json",label:"JSON",extension:".json",description:"Raw JSON export of all review data."}];function i(e){let{visible:t,title:n,markdown:i,annotations:c,priorities:d,risks:u,sections:x,onClose:m,defaultFormat:p}=e,[h,b]=(0,l.useState)("markdown"),[g,f]=(0,l.useState)(!1),y=(0,l.useCallback)(e=>{"Escape"===e.key&&m()},[m]);(0,l.useEffect)(()=>{if(t)return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t,y]),(0,l.useEffect)(()=>{t&&(b(null!=p?p:"markdown"),f(!1))},[t,p]);let v=(0,l.useMemo)(()=>t?function(e,t,n,r,l,s,o){var a,i,c,d,u,x,m,p,h,b,g,f;let y=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)||"review";switch(e){case"markdown":{let e="# Review: ".concat(t,"\n\n");if(r.length>0){for(let t of(e+="## Annotations (".concat(r.length,")\n\n"),r)){let n=t.sectionId&&"global"!==t.sectionId?null==(a=o.find(e=>e.id===t.sectionId))?void 0:a.title:"Global";e+="- **[".concat(t.type,"]** ").concat(n?"(".concat(n,") "):"").concat(t.text,"\n")}e+="\n"}if(l.length>0){for(let t of(e+="## Priorities\n\n",l)){let n=null!=(c=null==(i=o.find(e=>e.id===t.sectionId))?void 0:i.title)?c:t.sectionId;e+="- **".concat(t.priority,"**: ").concat(n).concat(t.note?" - ".concat(t.note):"","\n")}e+="\n"}if(s.length>0){for(let t of(e+="## Risks\n\n",s)){let n=null!=(u=null==(d=o.find(e=>e.id===t.sectionId))?void 0:d.title)?u:t.sectionId;e+="- **".concat(t.level,"**: ").concat(n).concat(t.description?" - ".concat(t.description):"","\n")}e+="\n"}return{content:e+="## Plan\n\n".concat(n),filename:"".concat(y,"-review.md")}}case"github":{let e="## Review Summary\n\n";if(e+="- Annotations: ".concat(r.length,"\n"),e+="- Priorities: ".concat(l.length,"\n"),e+="- Risks: ".concat(s.length,"\n\n"),r.length>0){for(let t of(e+="### Comments\n\n",r))e+="- [ ] **".concat(t.type,"**: ").concat(t.text,"\n");e+="\n"}return e+="<details><summary>Full Plan</summary>\n\n".concat(n,"\n\n</details>"),{content:"# ".concat(t,"\n\n").concat(e),filename:"".concat(y,"-github-issue.md")}}case"jira":{let e="h1. ".concat(t,"\n\n");if(r.length>0){for(let t of(e+="h2. Annotations\n\n",e+="||Type||Section||Comment||\n",r)){let n=t.sectionId&&"global"!==t.sectionId?null==(x=o.find(e=>e.id===t.sectionId))?void 0:x.title:"Global",r=t.text.replace(/\|/g,"\\|").replace(/\n/g," ");e+="|".concat(t.type,"|").concat(null!=n?n:"—","|").concat(r,"|\n")}e+="\n"}if(l.length>0){for(let t of(e+="h2. Priorities\n\n",e+="||Section||Priority||Note||\n",l)){let n=null!=(p=null==(m=o.find(e=>e.id===t.sectionId))?void 0:m.title)?p:t.sectionId;e+="|".concat(n,"|").concat(t.priority,"|").concat(null!=(h=t.note)?h:"—","|\n")}e+="\n"}if(s.length>0){for(let t of(e+="h2. Risks\n\n",e+="||Section||Level||Description||\n",s)){let n=null!=(g=null==(b=o.find(e=>e.id===t.sectionId))?void 0:b.title)?g:t.sectionId,r=(null!=(f=t.description)?f:"—").replace(/\|/g,"\\|").replace(/\n/g," ");e+="|".concat(n,"|").concat(t.level,"|").concat(r,"|\n")}e+="\n"}let a=n.replace(/^### (.+)/gm,"h3. $1").replace(/^## (.+)/gm,"h2. $1").replace(/^# (.+)/gm,"h1. $1").replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>"{code:language=".concat(t||"none","}\n").concat(n,"{code}")).replace(/\*\*(.+?)\*\*/g,"*$1*").replace(/^- /gm,"* ");return{content:e+="h2. Plan\n\n".concat(a),filename:"".concat(y,"-review-jira.md")}}case"json":return{content:JSON.stringify({title:t,annotations:r,priorities:l,risks:s,exportedAt:new Date().toISOString()},null,2),filename:"".concat(y,"-review.json")}}}(h,n,i,c,d,u,x):null,[t,h,n,i,c,d,u,x]);async function w(){if(v){try{await navigator.clipboard.writeText(v.content)}catch(t){let e=document.createElement("textarea");e.value=v.content,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}f(!0),setTimeout(()=>f(!1),2e3)}}if(!t)return null;let j=a.find(e=>e.id===h);return(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/75 backdrop-blur-sm flex items-center justify-center z-50",onClick:e=>{e.target===e.currentTarget&&m()},children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl w-full max-w-lg shadow-2xl",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-white/[0.06]",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-white",children:"Export Plan"}),(0,r.jsx)("button",{className:"text-gray-500 hover:text-gray-200 transition-colors",onClick:m,children:(0,r.jsx)(o.A,{size:18})})]}),(0,r.jsxs)("div",{className:"p-6 space-y-4",children:[(0,r.jsx)("div",{className:"flex gap-2",children:a.map(e=>(0,r.jsxs)("button",{className:"flex-1 p-3 border rounded-lg text-left transition-colors ".concat(h===e.id?"bg-white/[0.04] ring-2 ring-primary-500 border-primary-500/30":"border-white/[0.06] hover:bg-white/[0.04]"),onClick:()=>{b(e.id),f(!1)},children:[(0,r.jsx)("span",{className:"block text-sm font-medium text-white",children:e.label}),(0,r.jsx)("span",{className:"block text-xs text-gray-500",children:e.extension})]},e.id))}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:j.description}),(0,r.jsxs)("div",{className:"border border-white/[0.06] rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-surface-800 border-b border-white/[0.06]",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"Preview"}),(0,r.jsx)("span",{className:"text-xs text-gray-400 font-mono",children:null==v?void 0:v.filename})]}),(0,r.jsx)("pre",{className:"max-h-60 overflow-y-auto p-4 bg-surface-800 text-xs font-mono text-gray-400 whitespace-pre-wrap",children:(0,r.jsx)("code",{children:null==v?void 0:v.content})})]}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)("button",{className:"flex-1 py-2.5 bg-white/[0.04] hover:bg-white/[0.06] text-gray-400 text-sm font-medium rounded-lg border border-white/[0.06] transition-colors",onClick:w,children:g?"Copied!":"Copy to Clipboard"}),(0,r.jsxs)("button",{className:"flex-1 py-2.5 bg-primary-500 hover:bg-primary-600 text-white text-sm font-medium rounded-lg transition-all",onClick:function(){v&&function(e,t){let n=new Blob([e],{type:"text/plain;charset=utf-8"}),r=URL.createObjectURL(n),l=document.createElement("a");l.href=r,l.download=t,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}(v.content,v.filename)},children:["Download ",j.extension]})]})]})]})}),document.body)}},3446:(e,t,n)=>{n.d(t,{Kv:()=>c,HI:()=>x,Xk:()=>d,yC:()=>u});var r=n(8111),l=n(5271),s=n(422),o=n(7811);class a{async request(e,t){let n="".concat(this.baseUrl).concat(e);if(this.repo){let e=n.includes("?")?"&":"?";n="".concat(n).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=o.env.NEXT_PUBLIC_ULPI_API_SECRET,l=await fetch(n,{...t,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==t?void 0:t.headers}});if(!l.ok)throw Error((await l.json().catch(()=>({error:l.statusText}))).error||"API error: ".concat(l.status));return l.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,s.h)()}}let i=(0,l.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,n=(0,l.useMemo)(()=>{let e=(0,s.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new a:null}},[]);return(0,r.jsx)(i,{value:n,children:t})}function d(){return(0,l.useContext)(i).mode}function u(){let{localClient:e}=(0,l.useContext)(i);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function x(){return(0,l.useContext)(i)}},4780:(e,t,n)=>{n.d(t,{_:()=>C});var r=n(8111),l=n(5271),s=n(8054),o=n(921),a=n(8913),i=n(8982),c=n(7666),d=n(1729),u=n(9903),x=n(3163),m=n(6342),p=n(3468),h=n(8786);let b=[{tool:"pen",icon:c.A,label:"Pen"},{tool:"arrow",icon:d.A,label:"Arrow"},{tool:"circle",icon:u.A,label:"Circle"},{tool:"text",icon:x.A,label:"Text"}],g=[{value:"#ef4444",label:"Red"},{value:"#3b82f6",label:"Blue"},{value:"#22c55e",label:"Green"},{value:"#eab308",label:"Yellow"},{value:"#000000",label:"Black"},{value:"#ffffff",label:"White"}],f=[{value:2,label:"Thin"},{value:4,label:"Medium"},{value:8,label:"Thick"}];function y(){return"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9))}function v(e,t){let n=e.getBoundingClientRect(),r=e.width/n.width,l=e.height/n.height;return{x:(t.clientX-n.left)*r,y:(t.clientY-n.top)*l}}function w(e,t,n,r){if(!(t.length<2)){e.strokeStyle=n,e.lineWidth=r,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.stroke()}}function j(e,t,n,r,l){let s=Math.max(4*l,12),o=Math.atan2(n.y-t.y,n.x-t.x);e.strokeStyle=r,e.lineWidth=l,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(n.x,n.y),e.stroke(),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x-s*Math.cos(o-Math.PI/6),n.y-s*Math.sin(o-Math.PI/6)),e.moveTo(n.x,n.y),e.lineTo(n.x-s*Math.cos(o+Math.PI/6),n.y-s*Math.sin(o+Math.PI/6)),e.stroke()}function N(e,t,n,r,l){let s=Math.abs(n.x-t.x),o=Math.abs(n.y-t.y);e.strokeStyle=r,e.lineWidth=l,e.lineCap="round",e.beginPath(),e.ellipse(t.x,t.y,s,o,0,0,2*Math.PI),e.stroke()}function k(e){let{imageSrc:t,onSave:n,onCancel:a}=e,[i,c]=(0,l.useState)([]),[d,u]=(0,l.useState)("pen"),[x,k]=(0,l.useState)("#ef4444"),[C,E]=(0,l.useState)(4),[S,I]=(0,l.useState)({width:800,height:600}),[A,D]=(0,l.useState)(!1),P=(0,l.useRef)(null),M=(0,l.useRef)(null),L=(0,l.useRef)(null),R=(0,l.useRef)(null),z=(0,l.useRef)({width:0,height:0}),T=(0,l.useRef)([]),U=(0,l.useRef)(null);(0,l.useEffect)(()=>{let e=new Image;e.crossOrigin="anonymous",e.onload=()=>{if(R.current=e,z.current={width:e.naturalWidth,height:e.naturalHeight},L.current){let t=L.current.clientWidth;if(t>0){let n=Math.round(t/(e.naturalWidth/e.naturalHeight));I({width:t,height:n})}else I({width:e.naturalWidth,height:e.naturalHeight})}},e.src=t},[t]),(0,l.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(e=>{let{width:t,height:n}=z.current;if(0!==t&&0!==n)for(let r of e){let e=r.contentRect.width;if(e<=0)continue;let l=Math.floor(e),s=Math.round(l/(t/n));I(e=>e.width===l&&e.height===s?e:{width:l,height:s})}});return t.observe(e),()=>t.disconnect()},[]),(0,l.useEffect)(()=>{let e=P.current,t=null==e?void 0:e.getContext("2d"),n=R.current;if(e&&t&&n)for(let r of(t.clearRect(0,0,e.width,e.height),t.drawImage(n,0,0,e.width,e.height),i))switch(r.tool){case"pen":w(t,r.points,r.color,r.lineWidth);break;case"arrow":r.points.length>=2&&j(t,r.points[0],r.points[1],r.color,r.lineWidth);break;case"circle":r.points.length>=2&&N(t,r.points[0],r.points[1],r.color,r.lineWidth);break;case"text":r.points.length>=1&&r.text&&function(e,t,n,r,l){e.fillStyle=r,e.font="".concat(l,"px sans-serif"),e.textBaseline="top";let s=n.split("\n");for(let n=0;n<s.length;n++)e.fillText(s[n],t.x,t.y+n*(l+2))}(t,r.points[0],r.text,r.color,4*r.lineWidth+12)}},[i,S]),(0,l.useEffect)(()=>{if(!A){let e=M.current,t=null==e?void 0:e.getContext("2d");e&&t&&t.clearRect(0,0,e.width,e.height)}},[A,S]),(0,l.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"z"===e.key&&(e.preventDefault(),c(e=>e.slice(0,-1))),"Escape"===e.key&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]);let q=(0,l.useCallback)(e=>{let t=M.current;if(!t)return;e.preventDefault();let n=v(t,e.nativeEvent);if("text"===d){let e=prompt("Enter text:");e&&c(t=>[...t,{id:y(),tool:"text",color:x,lineWidth:C,points:[n],text:e}]);return}D(!0),U.current=n,T.current=[n]},[d,x,C]),F=(0,l.useCallback)(e=>{if(!A)return;let t=M.current,n=null==t?void 0:t.getContext("2d");if(!t||!n)return;e.preventDefault();let r=v(t,e.nativeEvent);switch(n.clearRect(0,0,t.width,t.height),d){case"pen":T.current.push(r),w(n,T.current,x,C);break;case"arrow":U.current&&j(n,U.current,r,x,C);break;case"circle":U.current&&N(n,U.current,r,x,C)}},[A,d,x,C]),_=(0,l.useCallback)(e=>{if(!A)return;e.preventDefault();let t=M.current;if(!t)return;let n=v(t,e.nativeEvent),r=null;switch(d){case"pen":T.current.push(n),T.current.length>=2&&(r={id:y(),tool:"pen",color:x,lineWidth:C,points:[...T.current]});break;case"arrow":U.current&&(r={id:y(),tool:"arrow",color:x,lineWidth:C,points:[U.current,n]});break;case"circle":U.current&&(r={id:y(),tool:"circle",color:x,lineWidth:C,points:[U.current,n]})}D(!1),T.current=[],U.current=null,r&&c(e=>[...e,r])},[A,d,x,C]),W=(0,l.useCallback)(()=>{let e=P.current;e&&n(e.toDataURL("image/png"))},[n]),K=i.length>0;return(0,s.createPortal)((0,r.jsxs)("div",{className:"fixed inset-0 z-50 bg-black/90 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-surface-900 border-b border-white/[0.06] flex-wrap shrink-0",children:[(0,r.jsx)("div",{className:"flex items-center gap-1",children:b.map(e=>{let{tool:t,icon:n,label:l}=e;return(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded text-xs font-medium transition-colors ".concat(d===t?"bg-primary-500 text-white":"text-gray-400 hover:bg-white/[0.04] hover:text-gray-200"),onClick:()=>u(t),title:l,children:[(0,r.jsx)(n,{size:14}),(0,r.jsx)("span",{children:l})]},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:g.map(e=>{let{value:t,label:n}=e;return(0,r.jsx)("button",{type:"button",className:"w-5 h-5 rounded-full cursor-pointer transition-all ".concat(x===t?"ring-2 ring-primary-500 ring-offset-1 ring-offset-surface-900 scale-110":"hover:scale-110"),onClick:()=>k(t),title:n,style:{backgroundColor:t,border:"#ffffff"===t?"1px solid #d1d5db":"none"}},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:f.map(e=>{let{value:t,label:n}=e;return(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-2 py-1.5 rounded text-xs font-medium transition-colors ".concat(C===t?"bg-primary-500 text-white":"text-gray-400 hover:bg-white/[0.04] hover:text-gray-200"),onClick:()=>E(t),title:"".concat(n," line"),children:[(0,r.jsx)("span",{className:"w-5 rounded-full",style:{height:"".concat(t,"px"),backgroundColor:C===t?"white":x}}),(0,r.jsx)("span",{children:n})]},t)})}),(0,r.jsx)("div",{className:"w-px h-5 bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs font-medium transition-colors text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 ".concat(K?"":"opacity-40 cursor-not-allowed"),onClick:()=>c(e=>e.slice(0,-1)),disabled:!K,title:"Undo (Ctrl+Z)",children:[(0,r.jsx)(m.A,{size:14}),(0,r.jsx)("span",{children:"Undo"})]}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1 px-2 py-1.5 rounded text-xs font-medium transition-colors text-red-400 hover:bg-red-500/10 hover:text-red-300 ".concat(K?"":"opacity-40 cursor-not-allowed"),onClick:()=>c([]),disabled:!K,title:"Clear all",children:[(0,r.jsx)(p.A,{size:14}),(0,r.jsx)("span",{children:"Clear"})]})]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:a,children:[(0,r.jsx)(o.A,{size:14}),"Cancel"]}),(0,r.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white transition-all",onClick:W,children:[(0,r.jsx)(h.A,{size:14}),"Save"]})]})]}),(0,r.jsx)("div",{ref:L,className:"flex-1 min-h-0 flex items-center justify-center p-4 overflow-auto",children:(0,r.jsxs)("div",{style:{position:"relative",width:"100%",maxWidth:S.width},children:[(0,r.jsx)("canvas",{ref:P,width:S.width,height:S.height,style:{display:"block",width:"100%",height:"auto"}}),(0,r.jsx)("canvas",{ref:M,width:S.width,height:S.height,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"text"===d?"text":"crosshair"},onMouseDown:q,onMouseMove:F,onMouseUp:_,onMouseLeave:_})]})})]}),document.body)}function C(e){let{visible:t,title:n,placeholder:c="Enter your comment...",sessionId:d,onUploadImage:u,imageUrl:x,onSubmit:m,onCancel:p}=e,[h,b]=(0,l.useState)(""),[g,f]=(0,l.useState)([]),[y,v]=(0,l.useState)(null),[w,j]=(0,l.useState)(null),N=(0,l.useRef)(null),C=(0,l.useRef)(null);async function E(e){if(u)try{let t=await u(e);j(null),f(e=>[...e,t.filename])}catch(e){j(e instanceof Error?e.message:"Upload failed"),setTimeout(()=>j(null),3e3)}}async function S(e){var t;let n=null==(t=e.clipboardData)?void 0:t.items;if(n){for(let t of Array.from(n))if(t.type.startsWith("image/")){e.preventDefault();let n=t.getAsFile();if(!n)continue;await E(n);break}}}async function I(e){let t=e.target.files;if(t){for(let e of Array.from(t))await E(e);e.target.value=""}}async function A(e){if(null!==y&&u){try{let t=await fetch(e),n=await t.blob(),r=await u(n);f(e=>e.map((e,t)=>t===y?r.filename:e))}catch(e){j(e instanceof Error?e.message:"Failed to save annotation"),setTimeout(()=>j(null),3e3)}v(null)}}function D(){let e=h.trim();(e||g.length>0)&&(m(e,g.length>0?g:void 0),b(""),f([]))}return((0,l.useEffect)(()=>{t&&(b(""),f([]),v(null),j(null),setTimeout(()=>{var e;return null==(e=N.current)?void 0:e.focus()},50))},[t]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&(null!==y?v(null):p())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,p,y]),t)?null!==y&&g[y]&&x?(0,r.jsx)(k,{imageSrc:x(g[y]),onSave:A,onCancel:()=>v(null)}):(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center",onClick:p,children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-full max-w-md mx-4",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/[0.06]",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-white",children:n}),(0,r.jsx)("button",{className:"text-gray-500 hover:text-gray-200 transition-colors p-1 rounded hover:bg-white/[0.04]",onClick:p,children:(0,r.jsx)(o.A,{size:16})})]}),(0,r.jsxs)("div",{className:"p-5",children:[(0,r.jsx)("textarea",{ref:N,value:h,onChange:e=>b(e.target.value),onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),D())},onPaste:S,placeholder:c,rows:4,className:"w-full bg-surface-800 border border-white/[0.06] rounded-lg px-4 py-3 text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 resize-none"}),w&&(0,r.jsx)("p",{className:"text-xs text-red-400 mt-2",children:w}),g.length>0&&x&&(0,r.jsx)("div",{className:"flex gap-2 flex-wrap mt-3",children:g.map((e,t)=>(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)("img",{src:x(e),className:"w-16 h-16 object-cover rounded-lg border border-white/[0.06]",alt:""}),(0,r.jsx)("button",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>v(t),title:"Draw on image",children:(0,r.jsx)(a.A,{size:16,className:"text-white"})}),(0,r.jsx)("button",{className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-surface-800 text-white text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>f(e=>e.filter((e,n)=>n!==t)),children:(0,r.jsx)(o.A,{size:10})})]},t))})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-t border-white/[0.06]",children:[(0,r.jsx)("span",{className:"text-xs text-gray-600",children:"Shift+Enter for new line"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[d&&u&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button",className:"p-2 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:()=>{var e;return null==(e=C.current)?void 0:e.click()},title:"Attach image",children:(0,r.jsx)(i.A,{size:16})}),(0,r.jsx)("input",{ref:C,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:I})]}),(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:p,children:"Cancel"}),(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium bg-primary-500 hover:bg-primary-600 text-white transition-all disabled:opacity-50",onClick:D,disabled:!h.trim()&&0===g.length,children:"Submit"})]})]})]})}),document.body):null}},7107:(e,t,n)=>{n.d(t,{KK:()=>u,ju:()=>h,mP:()=>m,wL:()=>c});var r=n(8111),l=n(5271),s=n(8054),o=n(6718),a=n(921);let i=[{key:"j",desc:"Next section"},{key:"k",desc:"Previous section"},{key:"a",desc:"Add global comment"},{key:"c",desc:"Comment on focused section"},{key:"e",desc:"Edit focused block"},{key:"i",desc:"Toggle Instructions panel"},{key:"p",desc:"Set priority on section"},{key:"r",desc:"Flag risk on section"},{key:"?",desc:"Toggle this overlay"},{key:"⌘ Enter",desc:"Approve plan"},{key:"d",desc:"Request changes"},{key:"Esc",desc:"Close modal/overlay"}];function c(e){let{onClose:t,shortcuts:n}=e;return(0,l.useEffect)(()=>{let e=e=>{"Escape"===e.key&&(e.preventDefault(),t())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]),(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm z-50 flex items-center justify-center",onClick:t,children:(0,r.jsxs)("div",{className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-full max-w-sm mx-4 p-6",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[(0,r.jsx)(o.A,{size:16})," Keyboard Shortcuts"]}),(0,r.jsx)("button",{onClick:t,className:"text-gray-500 hover:text-gray-200 transition-colors",children:(0,r.jsx)(a.A,{size:16})})]}),(0,r.jsx)("div",{className:"space-y-2",children:(null!=n?n:i).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,r.jsx)("span",{className:"text-gray-400",children:e.desc}),(0,r.jsx)("kbd",{className:"bg-surface-800 px-2 py-0.5 rounded text-gray-200 font-mono border border-white/[0.06]",children:e.key})]},e.key))})]})}),document.body)}function d(e){let{label:t,count:n,color:l}=e;return(0,r.jsxs)("div",{className:"flex items-center justify-between bg-white/[0.02] border border-white/[0.06] rounded-lg px-3 py-2",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400",children:t}),(0,r.jsx)("span",{className:"text-sm font-bold tabular-nums ".concat(l),children:n})]})}function u(e){let{isOpen:t,actionName:n,variant:o,summary:a,onConfirm:i,onCancel:c}=e,u=(0,l.useRef)(null),x=(0,l.useRef)(null),m=(0,l.useCallback)(e=>{"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),c()):"Enter"!==e.key||e.metaKey||e.ctrlKey||(e.preventDefault(),e.stopPropagation(),i())},[i,c]);if((0,l.useEffect)(()=>{if(t){var e;return x.current=document.activeElement,null==(e=u.current)||e.focus(),document.addEventListener("keydown",m,!0),document.body.style.overflow="hidden",()=>{var e;document.removeEventListener("keydown",m,!0),document.body.style.overflow="",null==(e=x.current)||e.focus()}}},[t,m]),!t)return null;let{annotationsByType:p,editCount:h,instructionCount:b,priorityCount:g,riskCount:f,globalComment:y}=a,v=p.comments>0||p.questions>0||p.concerns>0||p.suggestions>0||p.approvals>0||p.globalComments>0,w=v||h>0||b>0||g>0||f>0;return(0,s.createPortal)((0,r.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[90] flex items-center justify-center",onClick:c,children:(0,r.jsxs)("div",{ref:u,role:"dialog","aria-modal":"true",tabIndex:-1,className:"w-full max-w-md bg-surface-900 border border-white/[0.08] rounded-2xl shadow-2xl flex flex-col focus:outline-none mx-4",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"px-6 py-5 border-b border-white/[0.06]",children:[(0,r.jsxs)("h2",{className:"text-lg font-semibold text-white",children:["Confirm: ",n]}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:w?"The following feedback will be included with your decision.":"No feedback attached. The decision will be submitted as-is."})]}),(0,r.jsxs)("div",{className:"px-6 py-5 space-y-4 max-h-[50vh] overflow-y-auto",children:[v&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Annotations"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[p.comments>0&&(0,r.jsx)(d,{label:"Comments",count:p.comments,color:"text-gray-400"}),p.questions>0&&(0,r.jsx)(d,{label:"Questions",count:p.questions,color:"text-primary-400"}),p.concerns>0&&(0,r.jsx)(d,{label:"Concerns",count:p.concerns,color:"text-amber-400"}),p.suggestions>0&&(0,r.jsx)(d,{label:"Suggestions",count:p.suggestions,color:"text-blue-400"}),p.approvals>0&&(0,r.jsx)(d,{label:"Approvals",count:p.approvals,color:"text-emerald-400"}),p.globalComments>0&&(0,r.jsx)(d,{label:"Global Comments",count:p.globalComments,color:"text-gray-500"})]})]}),(h>0||b>0||g>0||f>0)&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Metadata"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[h>0&&(0,r.jsx)(d,{label:"Inline Edits",count:h,color:"text-primary-400"}),b>0&&(0,r.jsx)(d,{label:"Instructions",count:b,color:"text-blue-400"}),g>0&&(0,r.jsx)(d,{label:"Priorities Set",count:g,color:"text-amber-400"}),f>0&&(0,r.jsx)(d,{label:"Risks Flagged",count:f,color:"text-red-400"})]})]}),y&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xs font-bold text-gray-600 uppercase tracking-widest mb-2",children:"Global Comment Preview"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 bg-white/[0.02] border border-white/[0.06] rounded-lg p-3 line-clamp-3",children:y})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/[0.06]",children:[(0,r.jsx)("button",{className:"px-4 py-2 rounded-lg text-sm font-medium text-gray-400 hover:text-gray-200 hover:bg-white/[0.04] transition-colors",onClick:c,children:"Cancel"}),(0,r.jsx)("button",{className:"px-5 py-2 rounded-lg text-sm font-bold transition-all ".concat("approve"===o?"bg-emerald-600 text-white hover:bg-emerald-500 shadow-lg shadow-emerald-600/25":"deny"===o?"bg-red-500 text-white hover:bg-red-400 shadow-lg shadow-red-500/25":"bg-primary-500 text-white hover:bg-primary-600"),onClick:i,children:n})]}),(0,r.jsxs)("div",{className:"px-6 pb-3 flex items-center justify-center gap-3 text-xs text-gray-600",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"bg-surface-800 border border-white/[0.06] rounded px-1.5 py-0.5 font-mono text-[0.65rem]",children:"Enter"}),(0,r.jsx)("span",{children:"to confirm"})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)("kbd",{className:"bg-surface-800 border border-white/[0.06] rounded px-1.5 py-0.5 font-mono text-[0.65rem]",children:"Esc"}),(0,r.jsx)("span",{children:"to cancel"})]})]})]})}),document.body)}let x=[{value:"must-have",label:"Must Have",color:"bg-red-500/15 text-red-300 border-red-500/30"},{value:"should-have",label:"Should Have",color:"bg-amber-500/15 text-amber-300 border-amber-500/30"},{value:"nice-to-have",label:"Nice to Have",color:"bg-blue-500/15 text-blue-300 border-blue-500/30"},{value:"out-of-scope",label:"Out of Scope",color:"bg-white/[0.04] text-gray-400 border-white/[0.06]"}];function m(e){let{visible:t,sectionTitle:n,currentLevel:o,currentReason:a,anchorRect:i,onSubmit:c,onRemove:d,onClose:u}=e,[m,p]=(0,l.useState)(null!=o?o:"should-have"),[h,b]=(0,l.useState)(null!=a?a:""),g=(0,l.useRef)(null);if((0,l.useEffect)(()=>{p(null!=o?o:"should-have"),b(null!=a?a:"")},[t,o,a]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&u()},n=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",n)}},[t,u]),!t)return null;let f=i?{position:"fixed",top:i.bottom+4,left:Math.min(i.left,window.innerWidth-300),zIndex:50}:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:50};return(0,s.createPortal)((0,r.jsxs)("div",{ref:g,className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-72 p-4",style:f,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Set Priority"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 truncate mb-3",children:n}),(0,r.jsx)("div",{className:"flex gap-1.5 mb-3",children:x.map(e=>(0,r.jsx)("button",{className:"flex-1 px-2 py-1.5 rounded-lg text-xs font-medium border transition-colors ".concat(m===e.value?e.color+" ring-1 ring-primary-500":"border-white/[0.06] text-gray-500 hover:bg-white/[0.04]"),onClick:()=>p(e.value),children:e.label},e.value))}),(0,r.jsx)("input",{type:"text",value:h,onChange:e=>b(e.target.value),placeholder:"Reason (optional)",className:"w-full px-3 py-2 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 mb-3",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c(m,h||void 0))}}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[o?(0,r.jsx)("button",{className:"text-xs text-red-400 hover:text-red-300 transition-colors",onClick:d,children:"Remove"}):(0,r.jsx)("span",{}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 transition-colors",onClick:u,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all",onClick:()=>c(m,h||void 0),children:"Set"})]})]})]}),document.body)}let p=[{value:"high",label:"High",color:"bg-red-500/15 text-red-300 border-red-500/30"},{value:"medium",label:"Medium",color:"bg-amber-500/15 text-amber-300 border-amber-500/30"},{value:"low",label:"Low",color:"bg-green-500/15 text-green-300 border-green-500/30"}];function h(e){let{visible:t,sectionTitle:n,currentLevel:o,currentDescription:a,anchorRect:i,onSubmit:c,onRemove:d,onClose:u}=e,[x,m]=(0,l.useState)(null!=o?o:"medium"),[h,b]=(0,l.useState)(null!=a?a:""),g=(0,l.useRef)(null);if((0,l.useEffect)(()=>{m(null!=o?o:"medium"),b(null!=a?a:"")},[t,o,a]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&u()},n=e=>{g.current&&!g.current.contains(e.target)&&u()};return document.addEventListener("keydown",e),document.addEventListener("mousedown",n),()=>{document.removeEventListener("keydown",e),document.removeEventListener("mousedown",n)}},[t,u]),!t)return null;let f=i?{position:"fixed",top:i.bottom+4,left:Math.min(i.left,window.innerWidth-300),zIndex:50}:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:50};return(0,s.createPortal)((0,r.jsxs)("div",{ref:g,className:"bg-surface-900 border border-white/[0.08] rounded-xl shadow-2xl w-72 p-4",style:f,children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1",children:"Flag Risk"}),(0,r.jsx)("p",{className:"text-sm text-gray-400 truncate mb-3",children:n}),(0,r.jsx)("div",{className:"flex gap-1.5 mb-3",children:p.map(e=>(0,r.jsx)("button",{className:"flex-1 px-2 py-1.5 rounded-lg text-xs font-medium border transition-colors ".concat(x===e.value?e.color+" ring-1 ring-primary-500":"border-white/[0.06] text-gray-500 hover:bg-white/[0.04]"),onClick:()=>m(e.value),children:e.label},e.value))}),(0,r.jsx)("input",{type:"text",value:h,onChange:e=>b(e.target.value),placeholder:"Description (optional)",className:"w-full px-3 py-2 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 mb-3",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c(x,h||void 0))}}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[o?(0,r.jsx)("button",{className:"text-xs text-red-400 hover:text-red-300 transition-colors",onClick:d,children:"Remove"}):(0,r.jsx)("span",{}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs text-gray-400 hover:text-gray-200 transition-colors",onClick:u,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-xs bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition-all",onClick:()=>c(x,h||void 0),children:"Set"})]})]})]}),document.body)}},9283:(e,t,n)=>{n.d(t,{y:()=>d});var r=n(8111),l=n(5271),s=n(4451),o=n(8183),a=n(6062),i=n(3468),c=n(9396);function d(e){let{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:s,annotationFilter:o,setAnnotationFilter:a,sections:i,priorities:c,risks:d,instructions:m,onRemoveAnnotation:p,onAddGlobalComment:h,onAddInstruction:b,onDeleteInstruction:g,renderAnnotationImage:f,extraTabs:y=[],activeTab:v,onTabChange:w}=e,j=[{id:"notes",label:"Notes (".concat(t.length,")")},{id:"instructions",label:"Instr (".concat(m.length,")")},...y.map(e=>({id:e.id,label:void 0!==e.count?"".concat(e.label," (").concat(e.count,")"):e.label}))];return(0,r.jsxs)("aside",{className:"hidden lg:flex w-80 border-l border-white/[0.06] bg-surface-900 overflow-y-auto flex-shrink-0 flex-col",children:[(0,r.jsx)("div",{className:"flex border-b border-white/[0.06]",children:j.map(e=>(0,r.jsx)("button",{onClick:()=>w(e.id),className:"flex-1 px-3 py-2.5 text-xs font-semibold uppercase tracking-wider transition-colors ".concat(v===e.id?"text-primary-400 border-b-2 border-primary-500":"text-gray-500 hover:text-gray-300"),children:e.label},e.id))}),"notes"===v&&(0,r.jsx)(u,{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:s,annotationFilter:o,setAnnotationFilter:a,sections:i,priorities:c,risks:d,onRemoveAnnotation:p,onAddGlobalComment:h,renderAnnotationImage:f}),"instructions"===v&&(0,r.jsx)(x,{instructions:m,sections:i,onAdd:b,onDelete:g}),y.map(e=>v===e.id&&(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:e.render()},e.id))]})}function u(e){let{annotations:t,filteredAnnotations:n,filteredGlobal:l,filteredSectionGroups:i,annotationFilter:c,setAnnotationFilter:d,sections:u,priorities:x,risks:m,onRemoveAnnotation:h,onAddGlobalComment:b,renderAnnotationImage:g}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"p-4 border-b border-white/[0.06] flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-white",children:"Annotations"}),(0,r.jsxs)("button",{onClick:b,className:"flex items-center gap-1 px-2 py-1 rounded-lg text-xs font-medium text-primary-400 hover:bg-primary-500/10 transition-colors",title:"Add global comment",children:[(0,r.jsx)(s.A,{size:12})," Add"]})]}),t.length>0&&(0,r.jsx)("div",{className:"px-4 py-2 border-b border-white/[0.06]",children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(o.A,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-600"}),(0,r.jsx)("input",{type:"text",placeholder:"Filter annotations...",value:c,onChange:e=>d(e.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface-800 border border-white/[0.06] rounded-lg text-sm text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50"})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===n.length&&0===x.length&&0===m.length?(0,r.jsxs)("div",{className:"p-6 text-center",children:[(0,r.jsx)(a.A,{size:32,className:"mx-auto text-gray-600 mb-2"}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No annotations yet"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:"Select text or right-click on sections to add annotations"})]}):(0,r.jsxs)("div",{className:"pb-2",children:[l.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Global Comments"}),(0,r.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,r.jsx)(p,{ann:e,onRemove:h,renderImage:g},e.id))})]}),Array.from(i.entries()).map(e=>{var t,n;let[l,s]=e;return(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2 truncate",children:null!=(n=null==(t=u.find(e=>e.id===l))?void 0:t.title)?n:l}),(0,r.jsx)("div",{className:"space-y-2",children:s.map(e=>(0,r.jsx)(p,{ann:e,onRemove:h,renderImage:g},e.id))})]},l)}),x.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Priorities"}),(0,r.jsx)("div",{className:"space-y-2",children:x.map(e=>{var t,n;let l=null!=(n=null==(t=u.find(t=>t.id===e.sectionId))?void 0:t.title)?n:e.sectionId,s="must-have"===e.priority?"bg-red-500/15 text-red-300 border-red-500/30":"should-have"===e.priority?"bg-amber-500/15 text-amber-300 border-amber-500/30":"nice-to-have"===e.priority?"bg-blue-500/15 text-blue-300 border-blue-500/30":"bg-white/[0.04] text-gray-400 border-white/[0.06]";return(0,r.jsxs)("div",{className:"bg-white/[0.02] rounded-xl p-3 border-l-[3px] border-l-amber-400",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 truncate",children:l}),(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ".concat(s),children:e.priority})]}),e.note&&(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.note})]},e.sectionId)})})]}),m.length>0&&(0,r.jsxs)("div",{className:"px-3 pt-3 pb-1",children:[(0,r.jsx)("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-600 mb-2",children:"Risks"}),(0,r.jsx)("div",{className:"space-y-2",children:m.map(e=>{var t,n;let l=null!=(n=null==(t=u.find(t=>t.id===e.sectionId))?void 0:t.title)?n:e.sectionId,s="high"===e.level?"bg-red-500/15 text-red-300 border-red-500/30":"medium"===e.level?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-green-500/15 text-green-300 border-green-500/30";return(0,r.jsxs)("div",{className:"bg-white/[0.02] rounded-xl p-3 border-l-[3px] border-l-red-400",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 truncate",children:l}),(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ".concat(s),children:e.level})]}),e.description&&(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:e.description})]},e.sectionId)})})]})]})})]})}function x(e){let{instructions:t,sections:n,onAdd:s,onDelete:o}=e,[a,d]=(0,l.useState)(null),u=(0,l.useMemo)(()=>{let e=new Map;for(let r of t){var n;let t=null!=(n=e.get(r.sectionId))?n:[];t.push(r),e.set(r.sectionId,t)}return e},[t]);return(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[n.map((e,t)=>{var n;let l=null!=(n=u.get(e.id))?n:[];return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-gray-500 uppercase tracking-wider truncate",children:e.title}),(0,r.jsx)("button",{className:"w-6 h-6 flex items-center justify-center border border-white/[0.06] rounded text-sm text-gray-500 hover:bg-primary-500 hover:border-primary-500 hover:text-white transition-colors",onClick:()=>d(a===t?null:t),title:"Add instruction",children:a===t?"-":"+"})]}),a===t&&(0,r.jsx)(m,{sectionId:e.id,onSubmit:(e,t,n)=>{s(e,t,n),d(null)},onCancel:()=>d(null)}),l.length>0&&(0,r.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,r.jsxs)("div",{className:"bg-white/[0.02] border border-white/[0.06] rounded-lg p-3",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300 leading-relaxed",children:e.instruction}),(0,r.jsxs)("div",{className:"flex items-center justify-between mt-2 pt-2 border-t border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.priority&&(0,r.jsx)("span",{className:"inline-flex px-2 py-0.5 rounded-full text-xs font-medium border ".concat("must"===e.priority?"text-red-300 bg-red-500/15 border-red-500/30":"should"===e.priority?"text-amber-300 bg-amber-500/15 border-amber-500/30":"text-gray-400 bg-white/[0.04] border-white/[0.06]"),children:e.priority}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,c.fF)(e.createdAt)})]}),(0,r.jsx)("button",{onClick:()=>o(e.id),className:"text-gray-600 hover:text-red-400 transition-colors",title:"Delete",children:(0,r.jsx)(i.A,{size:12})})]})]},e.id))})]},e.id)}),0===t.length&&(0,r.jsxs)("div",{className:"text-center py-8",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No instructions yet"}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:"Click + on a section to add implementation directives"})]})]})}function m(e){let{sectionId:t,onSubmit:n,onCancel:s}=e,[o,a]=(0,l.useState)(""),[i,c]=(0,l.useState)("");return(0,r.jsxs)("div",{className:"bg-white/[0.02] border border-white/[0.06] rounded-lg p-3 space-y-3",children:[(0,r.jsx)("textarea",{className:"w-full min-h-16 p-2.5 text-sm bg-surface-800 border border-white/[0.06] rounded-md text-gray-200 placeholder:text-gray-600 focus:outline-none focus:border-primary-500/50 resize-y transition-colors",value:o,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o.trim()&&n(t,o.trim(),i||void 0)),"Escape"===e.key&&s()},placeholder:"Enter instruction...",rows:3,autoFocus:!0}),(0,r.jsxs)("select",{className:"w-full p-2 text-sm bg-surface-800 border border-white/[0.06] rounded-md text-gray-400 focus:outline-none focus:border-primary-500/50",value:i,onChange:e=>c(e.target.value),children:[(0,r.jsx)("option",{value:"",children:"No priority"}),(0,r.jsx)("option",{value:"must",children:"Must"}),(0,r.jsx)("option",{value:"should",children:"Should"}),(0,r.jsx)("option",{value:"nice-to-have",children:"Nice to have"})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm border border-white/[0.06] text-gray-400 rounded-md hover:bg-white/[0.04] transition-colors",onClick:s,children:"Cancel"}),(0,r.jsx)("button",{className:"px-3 py-1.5 text-sm bg-primary-500 text-white rounded-md hover:bg-primary-600 disabled:opacity-40 transition-all",onClick:()=>{o.trim()&&n(t,o.trim(),i||void 0)},disabled:!o.trim(),children:"Add"})]})]})}function p(e){let{ann:t,onRemove:n,renderImage:l}=e;return(0,r.jsxs)("div",{className:"border-l-2 ".concat(c.D5[t.type]," rounded-r-lg p-3 group"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded border ".concat(c.s0[t.type]),children:t.type}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:(0,c.fF)(t.createdAt)})]}),(0,r.jsx)("button",{onClick:()=>n(t.id),className:"text-gray-600 hover:text-red-400 text-xs transition-colors opacity-0 group-hover:opacity-100",children:(0,r.jsx)(i.A,{size:12})})]}),(0,r.jsx)("p",{className:"text-sm text-gray-300 mt-1 whitespace-pre-wrap",children:t.text}),t.imagePaths&&t.imagePaths.length>0&&l&&(0,r.jsx)("div",{className:"flex gap-1.5 mt-2 flex-wrap",children:t.imagePaths.map((e,t)=>l(e,t))})]})}},9396:(e,t,n)=>{n.d(t,{D5:()=>r,Dx:()=>o,fF:()=>s,s0:()=>l});let r={comment:"border-blue-400 bg-blue-500/10",suggestion:"border-violet-400 bg-violet-500/10",concern:"border-amber-400 bg-amber-500/10",question:"border-cyan-400 bg-cyan-500/10",approval:"border-emerald-400 bg-emerald-500/10",instruction:"border-orange-400 bg-orange-500/10",global_comment:"border-blue-400 bg-blue-500/10"},l={comment:"bg-blue-500/10 text-blue-300 border-blue-500/20",suggestion:"bg-violet-500/10 text-violet-300 border-violet-500/20",concern:"bg-amber-500/10 text-amber-300 border-amber-500/20",question:"bg-cyan-500/10 text-cyan-300 border-cyan-500/20",approval:"bg-emerald-500/10 text-emerald-300 border-emerald-500/20",instruction:"bg-orange-500/10 text-orange-300 border-orange-500/20",global_comment:"bg-blue-500/10 text-blue-300 border-blue-500/20"};function s(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let n=Math.floor(t/60);if(n<60)return"".concat(n,"m ago");let r=Math.floor(n/60);if(r<24)return"".concat(r,"h ago");let l=Math.floor(r/24);return"".concat(l,"d ago")}function o(e){if(!e)return[];let t=e.split("\n"),n=[],r=null,l=new Set;function s(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"section",n=t,r=2;for(;l.has(n);)n="".concat(t,"-").concat(r++);return l.add(n),n}for(let e=0;e<t.length;e++){var o,a,i;let l=null!=(o=t[e])?o:"",c=l.match(/^(#{1,6})\s+(.+)/);c?(r&&n.push({id:s(r.title),title:r.title,level:r.level,content:r.lines.join("\n"),startLine:r.startLine}),r={title:null!=(a=c[2])?a:"",level:(null!=(i=c[1])?i:"#").length,lines:[l],startLine:e}):r?r.lines.push(l):l.trim()&&(r={title:"Overview",level:1,lines:[l],startLine:e})}return r&&n.push({id:s(r.title),title:r.title,level:r.level,content:r.lines.join("\n"),startLine:r.startLine}),n}},9951:(e,t,n)=>{n.d(t,{t:()=>c});var r=n(8111),l=n(5271),s=n(8054);let o={comment:"\uD83D\uDCAC",suggest:"✏️",concern:"⚠️",question:"❓",annotate:"➕",edit:"✏️",instruction:"\uD83D\uDCCB",priority:"\uD83C\uDFF7️",risk:"⚠️"},a=[{icon:"comment",label:"Add Comment",action:{type:"comment"}},{icon:"suggest",label:"Suggest Change",action:{type:"suggest"}},{icon:"concern",label:"Raise Concern",action:{type:"concern"}},{icon:"question",label:"Ask Question",action:{type:"question"}}],i=[{icon:"annotate",label:"Annotate Block",submenu:[{icon:"comment",label:"Comment",action:{type:"comment"}},{icon:"suggest",label:"Suggest",action:{type:"suggest"}},{icon:"concern",label:"Concern",action:{type:"concern"}},{icon:"question",label:"Question",action:{type:"question"}}]},{separator:!0,icon:"",label:""},{icon:"edit",label:"Edit Block",action:{type:"edit"}},{separator:!0,icon:"",label:""},{icon:"instruction",label:"Add Instruction",action:{type:"instruction"}},{icon:"priority",label:"Set Priority",action:{type:"priority"}},{icon:"risk",label:"Flag Risk",action:{type:"risk"}}];function c(e){let{visible:t,x:n,y:c,mode:d,onAction:u,onClose:x}=e,m=(0,l.useRef)(null),[p,h]=(0,l.useState)({x:n,y:c}),[b,g]=(0,l.useState)(null);return((0,l.useEffect)(()=>{if(t)h({x:Math.max(10,Math.min(n,window.innerWidth-220-10)),y:Math.max(10,Math.min(c,window.innerHeight-400-10))})},[t,n,c]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{m.current&&!m.current.contains(e.target)&&x()},n=e=>{"Escape"===e.key&&x()},r=()=>x();return document.addEventListener("mousedown",e),document.addEventListener("keydown",n),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",n),document.removeEventListener("scroll",r,!0)}},[t,x]),t)?(0,s.createPortal)((0,r.jsx)("div",{ref:m,className:"fixed rounded-xl border border-white/[0.08] bg-surface-900 shadow-2xl z-50 min-w-48 py-1",style:{left:"".concat(p.x,"px"),top:"".concat(p.y,"px")},children:("selection"===d?a:i).map((e,t)=>{var n;if(e.separator)return(0,r.jsx)("div",{className:"h-px bg-white/[0.06] my-1"},"sep-".concat(t));let l=!!e.submenu,s=b===e.label;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{className:"flex items-center gap-3 w-full px-3 py-2 text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 cursor-pointer rounded-lg mx-1 transition-colors duration-150",onClick:()=>{e.submenu?g(b===e.label?null:e.label):e.action&&(u(e.action),x())},children:[(0,r.jsx)("span",{className:"w-5 text-center",children:null!=(n=o[e.icon])?n:"\uD83D\uDCDD"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label}),l&&(0,r.jsx)("span",{className:"text-gray-600 text-xs",children:"▶"})]}),l&&s&&(0,r.jsx)("div",{className:"ml-4 border-l border-white/[0.06]",children:e.submenu.map(e=>{var t;return(0,r.jsxs)("button",{className:"flex items-center gap-3 w-full px-3 py-2 text-sm text-gray-400 hover:bg-white/[0.04] hover:text-gray-200 cursor-pointer rounded-lg mx-1 transition-colors duration-150",onClick:()=>{e.action&&(u(e.action),x())},children:[(0,r.jsx)("span",{className:"w-5 text-center",children:null!=(t=o[e.icon])?t:"\uD83D\uDCDD"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label})]},e.label)})})]},e.label)})}),document.body):null}}}]);