@fabrika/builder 0.2.0 → 0.3.2
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.
- package/BUILD-CONTRACT.md +8 -0
- package/README.md +9 -0
- package/cli/src/bin.ts +35 -2
- package/cli/src/build-status.ts +7 -15
- package/cli/src/commands/advance.ts +3 -2
- package/cli/src/commands/ensure-daemon.ts +3 -3
- package/cli/src/commands/gate.ts +4 -10
- package/cli/src/commands/init.ts +44 -7
- package/cli/src/commands/next.ts +3 -3
- package/cli/src/commands/platform.ts +81 -0
- package/cli/src/config.ts +4 -11
- package/cli/src/context.ts +4 -1
- package/cli/src/daemon-client.ts +36 -185
- package/cli/src/daemon-lifecycle.ts +63 -142
- package/cli/src/derive.ts +4 -8
- package/cli/src/errors.ts +1 -0
- package/cli/src/index.ts +2 -3
- package/cli/src/inject-skills.ts +8 -31
- package/cli/src/layout.ts +8 -18
- package/cli/src/packet.ts +18 -17
- package/cli/src/platform-client.ts +40 -0
- package/daemon/src/admission.ts +21 -0
- package/daemon/src/bin.ts +12 -14
- package/daemon/src/handlers.ts +84 -81
- package/daemon/src/index.ts +16 -6
- package/daemon/src/paths.ts +5 -6
- package/daemon/src/phases.ts +27 -126
- package/daemon/src/platform-compiler.ts +21 -0
- package/daemon/src/platform-remote.ts +146 -0
- package/daemon/src/platform-routes.ts +46 -0
- package/daemon/src/platform-source.ts +147 -0
- package/daemon/src/platform-storage.ts +222 -0
- package/daemon/src/platform.ts +481 -0
- package/decisions/README.md +4 -0
- package/decisions/patterns/zerops-control-deploy.md +49 -0
- package/decisions/patterns/zerops-local-app.md +57 -0
- package/decisions/patterns/zerops-postgres-seeds.md +37 -0
- package/decisions/technologies/zerops-fabrika-auth.md +53 -0
- package/decisions/technologies/zerops-platform.md +64 -0
- package/package.json +13 -5
- package/shared/index.ts +365 -0
- package/{cli/src → shared}/phases.ts +42 -50
- package/shared/urls.ts +48 -0
- package/skill/SKILL.md +34 -0
- package/stacks/README.md +2 -0
- package/stacks/zerops-app.md +66 -0
- package/ui/dist/assets/client.css +1 -1
- package/ui/dist/assets/client.krrpk10y.js +214 -0
- package/ui/dist/assets/components.js +57 -57
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/client.fhjppkvr.js +0 -214
package/ui/dist/index.html
CHANGED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import{createRoot as ew}from"react-dom/client";import{useEffect as Z0,useMemo as ny,useRef as ey,useState as df}from"react";import{useState as Kw}from"react";import{AnnotationCtx as hN,AnnotationHostContext as rN,SessionContext as kN,useAnnotationHost as AN,useAnnotations as CN}from"@fabrika/annotations/runtime";function Hm(f,m){let y=[],w=y1(f);for(let N of w){let $=document.createRange();if($.selectNodeContents(N),N===f.startContainer)$.setStart(N,f.startOffset);if(N===f.endContainer)$.setEnd(N,f.endOffset);let u=$.toString();if(!u||!u.trim())continue;let X=document.createElement("mark");X.setAttribute("data-annotation-id",m);try{$.surroundContents(X)}catch{let J=$.extractContents();X.appendChild(J),$.insertNode(X)}y.push(X)}return y}function wm(f){let m=f.parentElement;if(m?.classList.contains("select-none"))return!1;if(m?.closest("[data-annotation-id]"))return!1;return!0}function y1(f){let m=[],y=f.commonAncestorContainer;if(y.nodeType===Node.TEXT_NODE)return m.push(y),m;let w=document.createTreeWalker(y,NodeFilter.SHOW_TEXT),N;while(N=w.nextNode()){if(!wm(N))continue;if(f.intersectsNode(N))m.push(N)}return m}function P0(f,m){let y=document.createRange();if(y.selectNodeContents(f),f===m.startContainer)y.setStart(f,m.startOffset);if(f===m.endContainer)y.setEnd(f,m.endOffset);return y.toString()}function w1(f){let m="";for(let y of y1(f))m+=P0(y,f);return m}function jf(f,m){let y=document.querySelectorAll(`[data-annotation-id="${f}"]`);for(let w of y)w.classList.toggle("mark-active",m)}function em(f,m){if(m!=null&&m!==f)jf(m,!1);if(f!=null)jf(f,!0)}function fy(f,m){let y=document.querySelectorAll(`[data-annotation-id="${f}"]`);for(let w of y)w.setAttribute("data-annotation-id",m)}function my(f,m){for(let y of m){if(f.querySelector(`[data-annotation-id="${y.id}"]`))continue;let w=y.snippet;if(!w)continue;let{fullText:N,textNodes:$}=L0(f),u=[],X=0;while(!0){let W=N.indexOf(w,X);if(W===-1)break;u.push(W),X=W+1}let[J]=u;if(J===void 0)continue;let b=J;if(u.length>1&&y.context){let W=-1;for(let F of u){let c=0;if(y.context.before){let z=N.slice(Math.max(0,F-80),F);if(z.includes(y.context.before))c+=2;else if(y.context.before.length>10&&z.includes(y.context.before.slice(-10)))c+=1}if(y.context.after){let z=N.slice(F+w.length,F+w.length+80);if(z.includes(y.context.after))c+=2;else if(y.context.after.length>10&&z.includes(y.context.after.slice(0,10)))c+=1}if(c>W)W=c,b=F}}let U=b,Q=b+w.length,_=m1($,U),Y=m1($,Q);if(!_||!Y)continue;try{let W=document.createRange();W.setStart(_.node,_.offset),W.setEnd(Y.node,Y.offset),Hm(W,y.id)}catch{}}}function L0(f){let m=[],y="",w=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),N;while(N=w.nextNode()){if(!wm(N))continue;m.push({node:N,start:y.length}),y+=N.textContent||""}return{fullText:y,textNodes:m}}function m1(f,m){for(let y=f.length-1;y>=0;y--){let w=f[y];if(!w||w.start>m)continue;let N=m-w.start,$=w.node.textContent?.length??0;if(N<=$)return{node:w.node,offset:N}}return null}function yy(f){let m=document.querySelectorAll(`[data-annotation-id="${f}"]`);for(let y of m){let w=y.parentNode;if(!w)continue;if(y.tagName!=="MARK"){w.removeChild(y);continue}while(y.firstChild)w.insertBefore(y.firstChild,y);w.removeChild(y),w.normalize()}}function wy(f,m){let y=N1(f,"before",60),w=N1(f,"after",60),N=p0(f.startContainer,m);return{before:y,after:w,hierarchy:N}}function N1(f,m,y){let w=B0(m==="before"?f.startContainer:f.endContainer);if(!w)return"";let N="";if(m==="before"){let $=document.createTreeWalker(w,NodeFilter.SHOW_TEXT),u;while(u=$.nextNode()){if(u===f.startContainer){N+=(u.textContent||"").slice(0,f.startOffset);break}if(!wm(u))continue;N+=u.textContent||""}if(N.length>y){N=N.slice(-y);let X=N.indexOf(" ");if(X>0)N=N.slice(X+1)}}else{let $=document.createTreeWalker(w,NodeFilter.SHOW_TEXT),u=!1,X;while(X=$.nextNode()){if(X===f.endContainer){N+=(X.textContent||"").slice(f.endOffset),u=!0;continue}if(u){if(!wm(X))continue;N+=X.textContent||""}}if(N.length>y){N=N.slice(0,y);let J=N.lastIndexOf(" ");if(J>0)N=N.slice(0,J)}}return N.trim()}function B0(f){let m=new Set(["DIV","P","LI","PRE","BLOCKQUOTE","SECTION","ARTICLE"]),y=f.parentElement;while(y){if(m.has(y.tagName))return y;y=y.parentElement}return null}function p0(f,m){let y=[],w=f instanceof Element?f:f.parentElement;while(w&&w!==m){let N=w.getAttribute?.("data-task-id");if(N){let u=w.querySelector(".font-semibold");if(u)y.unshift(u.textContent?.trim()||N)}let $=M0(w);if($)y.unshift($);w=w.parentElement}return y}function M0(f){if(f.getAttribute("data-md")==="section"){let y=f.getAttribute("data-md-title");if(y)return y}if(f.tagName!=="DIV")return null;return f.querySelector(":scope > button > .font-heading, :scope > div > .font-heading")?.textContent?.trim()||null}function Km(f){let m=f.snippet.trim(),y=f.context,w=m.length<30;if(y&&w&&(y.before||y.after)){let N=[];if(y.before)N.push(`...${y.before} `);if(N.push(`**${m}**`),y.after)N.push(` ${y.after}...`);return N.join("")}return m}function Nm(f){return{kind:f.kind,owns:(m)=>f.parse(m)!==null,find:(m,y)=>{let w=f.parse(m);return w===null?null:f.find(w,y)},restore:(m,y)=>{let w=f.parse(y.snippet);if(w===null)return;f.restore?.(w,m,y)},describe:(m)=>{let y=f.parse(m);if(y===null||!f.describe)return null;return f.describe(y)}}}function u1(f){let m=document.createTreeWalker(f,NodeFilter.SHOW_TEXT),y="";for(let w=m.nextNode();w;w=m.nextNode()){let N=w.parentElement?.closest("[aria-hidden='true']");if(N&&f.contains(N))continue;y+=w.textContent??""}return y.trim()}function Tm(f,m,y){return{selector:f,snippet:(w)=>{let N=w.getAttribute(y);return N?`${m} ${N}`:null}}}var Ny=[Tm("[data-md='item']","[Item]","data-md-label"),Tm("[data-md='section']","[Section]","data-md-title"),Tm("[data-md='checklist-item']","[Checklist]","data-md-label"),Tm("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(f)=>{return`[Callout:${f.getAttribute("data-md-type")||"info"}] ${u1(f).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:(f)=>`[Note] ${u1(f).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(f)=>{let m=Array.from(f.querySelectorAll("td")).map((y)=>y.textContent?.trim()).filter(Boolean);return m.length?`[Row] ${m.join(" | ")}`:null}}],O0=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],Tf=Ny.map((f)=>f.selector).join(", "),Vf=[...Ny.map((f)=>f.selector),...O0].join(", ");function _f(f){for(let m of Ny)if(f.matches(m.selector))return m.snippet(f);return null}var uy={kind:"block",parse:(f)=>f.startsWith("[")?{snippet:f}:null,format:(f)=>f.snippet,find:(f,m)=>{for(let y of m.querySelectorAll(Tf)){if(!(y instanceof HTMLElement))continue;if(_f(y)===f.snippet)return y}return null}};var Jy="data-annotation-image",h0=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function r0(f){if(f==="rect")return"rect";if(f==="ellipse")return"ellipse";return null}function zm(f){if(f===void 0)return null;let m=Number(f);if(!Number.isInteger(m)||m<0||m>1e4)return null;return m}function $1(f){return Math.min(1e4,Math.max(0,f))}function Xy(f,m,y){if(!(f.width>0)||!(f.height>0))return null;return{x:$1(Math.round(m/f.width*1e4)),y:$1(Math.round(y/f.height*1e4))}}function Lm(f,m){let y=Math.min(f.x,m.x),w=Math.min(f.y,m.y);return{x:y,y:w,w:Math.min(1e4-y,Math.abs(f.x-m.x)),h:Math.min(1e4-w,Math.abs(f.y-m.y))}}function by(f){return f.w>=30&&f.h>=30}function J1(f){return{left:`${f.x/100}%`,top:`${f.y/100}%`,width:`${f.w/100}%`,height:`${f.h/100}%`}}function Pm(f){return`${(f/100).toFixed(1).replace(/\.0$/,"")}%`}function Bm(f){let m=`${Pm(f.x)}-${Pm(f.x+f.w)}`,y=`${Pm(f.y)}-${Pm(f.y+f.h)}`;return`[Region] ${f.src} — ${f.shape} x ${m}, y ${y} of the image`}function $y(f,m){for(let y of m.querySelectorAll("[data-md='image']")){if(!(y instanceof HTMLElement))continue;if(y.getAttribute("data-md-src")!==f)continue;let w=y.querySelector("[data-annotation-image]");if(w instanceof HTMLElement)return w}return null}function pm(f,m){let y=J1(m);f.style.left=y.left,f.style.top=y.top,f.style.width=y.width,f.style.height=y.height}function Mm(f,m,y){let w=document.createElement("div");return w.className="ann-region",w.setAttribute("data-annotation-id",y),w.setAttribute("data-annotation-region",m),pm(w,f),w}var um={kind:"region",parse:(f)=>{let m=h0.exec(f);if(!m)return null;let y=r0(m[1]),w=m[2],N=zm(m[3]),$=zm(m[4]),u=zm(m[5]),X=zm(m[6]);if(y===null||w===void 0)return null;if(N===null||$===null||u===null||X===null)return null;if(u<1||X<1)return null;return{src:w,shape:y,x:N,y:$,w:u,h:X}},format:(f)=>`[Region:${f.shape}] ${f.src} @${f.x},${f.y},${f.w},${f.h}`,find:(f,m)=>$y(f.src,m),restore:(f,m,y)=>{if(m.querySelector(`[data-annotation-id="${y.id}"]`))return;let w=$y(f.src,m);if(!w)return;w.appendChild(Mm(f,f.shape,y.id))},describe:Bm};var Yy={kind:"text",parse:(f)=>f?{text:f}:null,format:(f)=>f.text,find:()=>null,restore:(f,m,y)=>{my(m,[y])}};var Om=[Nm(um),Nm(uy),Nm(Yy)];function Uy(f,m){for(let y of Om){let w=y.find(f,m);if(w)return w}return null}function Qy(f,m){for(let y of m){if(!y.snippet)continue;for(let w of Om)w.restore(f,y)}}function $m(f){for(let m of Om){let y=m.describe(f);if(y!==null)return y}return f}import{AnnotationCtx as Z5,SessionContext as H5,useAnnotationHost as K5}from"@fabrika/annotations/runtime";import{useEffect as P5,useState as L5}from"react";import{useCallback as Of,useMemo as k0,useState as A0}from"react";var Df="__agent-response__";function Mf(f){return f.filePath&&f.filePath!=="__agent-response__"?f.filePath:void 0}function Jm(f){return f.uploadUrl!==null}function Ff(){return`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function zf(f,m){f.style.height="auto",f.style.height=(m?Math.max(m,f.scrollHeight):f.scrollHeight)+"px"}function X1(f){let m=f?`[data-annotation-id="${CSS.escape(f)}"]`:"[data-annotation-id]";for(let y of document.querySelectorAll(m))if(y.tagName==="MARK"){let w=y.parentNode;y.replaceWith(document.createTextNode(y.textContent||"")),w?.normalize()}else y.remove()}function hm({annotations:f,setAnnotations:m,generalNote:y,setGeneralNote:w,remoteAnnotations:N,isReadOnly:$,onClear:u}){let[X,J]=A0(null),b=k0(()=>{if(!N?.length)return f;let z=new Set(f.map((q)=>q.id)),S=N.filter((q)=>!z.has(q.id));return[...f,...S.map((q)=>({...q,source:"remote"}))]},[f,N]),U=Of((z,S,q,K,T,A,O)=>{m((r)=>[...r,{id:z,snippet:S,note:q,createdAt:new Date().toISOString(),filePath:K,context:T,...A?.length?{images:A}:{},...O?{canvasFile:O}:{}}])},[m]),Q=Of((z,S,q)=>{U(Ff(),z,S,q)},[U]),_=Of((z,S)=>{m((q)=>q.map((K)=>K.id===z?{...K,note:S}:K))},[m]),Y=Of((z)=>{if(!f.some((S)=>S.id===z))return;X1(z),m((S)=>S.filter((q)=>q.id!==z)),J((S)=>S===z?null:S)},[f,m]),W=Of((z,S)=>{m((q)=>q.map((K)=>K.id===z?{...K,images:[...K.images||[],S]}:K))},[m]),F=Of((z,S)=>{m((q)=>q.map((K)=>K.id===z?{...K,images:(K.images||[]).filter((T)=>T!==S)}:K))},[m]),c=Of(()=>{X1(),m([]),w(""),J(null),u?.()},[m,w,u]);return{annotations:b,generalNote:y,setGeneralNote:w,activeAnnotationId:X,setActiveAnnotationId:J,addAnnotation:Q,addAnnotationWithId:U,updateAnnotation:_,removeAnnotation:Y,addAnnotationImage:W,removeAnnotationImage:F,clearAll:c,isReadOnly:$}}import{useAnnotations as Pf}from"@fabrika/annotations/runtime";import{jsxDEV as O5}from"react/jsx-dev-runtime";import{jsxDEV as hf,Fragment as C0}from"react/jsx-dev-runtime";function Wy({hasContent:f,onSubmit:m,onSubmitEmpty:y,notice:w,secondaryAction:N,placeholder:$="General notes...",submitLabel:u="Submit",emptyLabel:X="Submit without feedback"}){let{generalNote:J,setGeneralNote:b}=Pf();return hf(C0,{children:[hf("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:hf("textarea",{value:J,onChange:(U)=>b(U.currentTarget.value),className:"w-full bg-transparent text-[13px] font-body text-text-primary resize-none leading-relaxed p-0 border-none ring-0 shadow-none outline-none focus:outline-none focus:ring-0 focus:border-none placeholder:text-text-disabled min-h-[40px]",placeholder:$,onInput:(U)=>zf(U.currentTarget,40),ref:(U)=>{if(U)zf(U,40)}},void 0,!1,void 0,this)},void 0,!1,void 0,this),w,hf("div",{className:"px-4 py-3 border-t border-border-subtle flex-shrink-0",children:f?hf("div",{className:"flex gap-2",children:[N,hf("button",{onClick:m,className:"flex-1 py-2 rounded-lg font-body text-[13px] font-medium transition-all bg-btn-primary text-btn-primary-text hover:opacity-90 hover:-translate-y-px shadow-sm",children:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this):hf("button",{onClick:y,className:"w-full py-2 rounded-lg font-body text-[13px] font-medium border border-border-medium text-text-secondary hover:text-text-primary hover:border-border-hover hover:bg-bg-input transition-all",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useAnnotationHost as g0}from"@fabrika/annotations/runtime";import{useCallback as Zf,useEffect as v0,useRef as qy,useState as Gy}from"react";import{jsxDEV as wf}from"react/jsx-dev-runtime";function _y(f){if(f.startsWith("/s/")||f.startsWith("http://")||f.startsWith("https://"))return f;return`/api/uploads/${f.split("/").pop()}`}async function R0(f,m){let y=f.uploadUrl;if(!y)return null;let w=new FormData;w.append("image",m);try{let $=await(await fetch(y(),{method:"POST",body:w})).json();if(f.isShared)return $.url||null;return $.path||null}catch{return null}}function Ef({note:f,onNoteChange:m,images:y,onAddImage:w,onRemoveImage:N,sessionId:$,placeholder:u="Add your note...",autoFocus:X=!1,autoResize:J=!1,readOnly:b=!1,onKeyDown:U,onTextareaClick:Q,textareaRef:_,textareaClassName:Y,textareaStyle:W,minHeight:F,attachButton:c="always",openFilePickerRef:z}){let S=g0(),q=!b&&Jm(S),[K,T]=Gy(!1),[A,O]=Gy(!1),[r,C]=Gy(!1),g=qy(0),D=qy(null),o=qy(null),E=Zf(()=>o.current?.click(),[]);if(z)z.current=E;let Jf=Zf((G)=>{if(D.current=G,_)_.current=G;if(G&&J)zf(G,F)},[_,J,F]);v0(()=>{if(X&&D.current){let G=D.current;if(G.focus(),G.value)G.setSelectionRange(G.value.length,G.value.length)}},[X]);let k=Zf(async(G)=>{if(!G.type.startsWith("image/"))return;O(!0);try{let M=await R0(S,G);if(M)w(M)}finally{O(!1)}},[S,w]),V=Zf((G)=>{for(let M of G.clipboardData?.items??[])if(M.type.startsWith("image/")){G.preventDefault();let j=M.getAsFile();if(j)k(j);return}},[k]),i=Zf((G)=>{if(G.preventDefault(),g.current++,g.current===1)T(!0)},[]),s=Zf((G)=>{G.preventDefault()},[]),d=Zf((G)=>{if(G.preventDefault(),g.current--,g.current===0)T(!1)},[]),L=Zf((G)=>{G.preventDefault(),g.current=0,T(!1);for(let M of G.dataTransfer?.files??[])if(M.type.startsWith("image/"))k(M)},[k]),B=Zf((G)=>{if(m(G.currentTarget.value),J)G.currentTarget.style.height="auto",G.currentTarget.style.height=(F?Math.max(F,G.currentTarget.scrollHeight):G.currentTarget.scrollHeight)+"px"},[m,J,F]),p="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",R={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...J?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},e=q&&(c==="always"||c==="on-focus"&&r);return wf("div",{style:{position:"relative"},onDragEnter:q?i:void 0,onDragOver:q?s:void 0,onDragLeave:q?d:void 0,onDrop:q?L:void 0,children:[wf("textarea",{ref:Jf,value:f,onChange:b?void 0:B,onPaste:q?V:void 0,onKeyDown:U,onClick:Q,onFocus:()=>C(!0),onBlur:()=>{setTimeout(()=>C(!1),150)},readOnly:b,placeholder:u,className:Y??p,style:W??R,rows:J?1:void 0},void 0,!1,void 0,this),q&&wf("input",{ref:o,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(G)=>{let M=G.currentTarget.files;if(M)for(let j of M)k(j);G.currentTarget.value=""}},void 0,!1,void 0,this),(y.length>0||e)&&wf("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[y.map((G)=>wf("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[wf("img",{src:_y(G),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!b&&wf("button",{onClick:(M)=>{M.stopPropagation(),N(G)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},G,!0,void 0,this)),e&&wf(rm,{onClick:E},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A&&wf("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),K&&wf("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function rm({onClick:f,size:m=16}){return wf("button",{onClick:(y)=>{y.stopPropagation(),f()},style:{width:`${m*2}px`,height:`${m*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(y)=>{y.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(y)=>{y.currentTarget.style.color="var(--color-text-tertiary)"},children:wf("svg",{width:m,height:m,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[wf("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),wf("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),wf("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function cy({images:f}){if(!f.length)return null;return wf("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px"},children:f.map((m)=>wf("div",{style:{width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:wf("img",{src:_y(m),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this)},m,!1,void 0,this))},void 0,!1,void 0,this)}import{SessionContext as I0}from"@fabrika/annotations/runtime";import{useContext as x0,useEffect as d0,useRef as j0}from"react";import{jsxDEV as ff,Fragment as b1}from"react/jsx-dev-runtime";function V0(f){let m=$m(f);return m.length>80?m.slice(0,80)+"...":m}function Xm({annotations:f,readOnly:m=!1,onSelect:y,onReveal:w,includedRemoteIds:N,onToggleRemoteId:$}){let{updateAnnotation:u,removeAnnotation:X,addAnnotationImage:J,removeAnnotationImage:b,activeAnnotationId:U,setActiveAnnotationId:Q}=Pf(),_=x0(I0),Y=j0(new Map);d0(()=>{if(m||!U)return;let q=Y.current.get(U);if(q)q.scrollIntoView({behavior:"smooth",block:"nearest"})},[U,m]);let W=(q)=>{Q(q),jf(q,!0)},F=(q)=>{Q(null),jf(q,!1)},c=(q)=>{if(q.id===U){Q(null);return}Q(q.id),y?.(q)},z=!!N&&!!$,S=(q)=>{let K=z&&q.source==="remote";return ff("div",{ref:(T)=>{if(T)Y.current.set(q.id,T);else Y.current.delete(q.id)},className:`group/ann relative px-3 py-2.5 transition-colors duration-150 ${m?"cursor-pointer ":""}${U===q.id?"bg-highlight-selected":K?"bg-accent-purple-muted/30 hover:bg-accent-purple-muted/50":"odd:bg-bg-elevated-half hover:bg-bg-input"}`,onMouseEnter:()=>W(q.id),onMouseLeave:()=>F(q.id),onClick:()=>c(q),children:[K&&q.author&&ff("div",{className:"flex items-center gap-1.5 mb-1.5",children:[ff("input",{type:"checkbox",checked:N.has(q.id),onChange:(T)=>{T.stopPropagation(),$(q.id)},onClick:(T)=>T.stopPropagation(),className:"accent-accent-purple flex-shrink-0",title:"Include in submission"},void 0,!1,void 0,this),ff("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-accent-purple text-white text-[9px] font-medium uppercase",children:q.author.name.charAt(0)},void 0,!1,void 0,this),ff("span",{className:"text-[11px] font-medium text-accent-purple font-body",children:q.author.name},void 0,!1,void 0,this),ff("span",{className:"text-[10px] text-text-tertiary font-body uppercase tracking-widest",children:"Remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ff("div",{className:"text-[11px] text-text-tertiary italic line-clamp-2 mb-1.5 leading-snug font-body border-l-2 border-border-medium pl-2",children:V0(q.snippet)},void 0,!1,void 0,this),m?ff(b1,{children:[q.note.trim()&&ff("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:q.note},void 0,!1,void 0,this),ff(cy,{images:q.images||[]},void 0,!1,void 0,this)]},void 0,!0,void 0,this):K?ff("div",{className:"text-[13px] font-body text-text-primary leading-relaxed whitespace-pre-wrap",children:q.note},void 0,!1,void 0,this):ff("div",{onClick:(T)=>T.stopPropagation(),children:ff(Ef,{note:q.note,onNoteChange:(T)=>u(q.id,T),images:q.images||[],onAddImage:(T)=>J(q.id,T),onRemoveImage:(T)=>b(q.id,T),sessionId:_,autoResize:!0,minHeight:20,textareaClassName:"w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none min-h-[20px]",textareaStyle:{height:"auto",overflow:"hidden"},placeholder:"Add your note...",attachButton:"on-focus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ff("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover/ann:opacity-100 transition-opacity duration-100 flex items-center gap-0.5",children:[w&&ff("button",{onClick:(T)=>{T.stopPropagation(),w(q)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-text-secondary hover:bg-bg-input transition-colors",title:"Scroll to annotation",children:ff("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ff("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),ff("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!m&&!K&&ff("button",{onClick:(T)=>{T.stopPropagation(),X(q.id)},className:"w-5 h-5 flex items-center justify-center rounded text-text-tertiary hover:text-accent-red hover:bg-accent-red-muted transition-colors",title:"Delete annotation",children:ff("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[ff("polyline",{points:"3 6 5 6 21 6"},void 0,!1,void 0,this),ff("path",{d:"M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},q.id,!0,void 0,this)};return ff(b1,{children:f.map(S)},void 0,!1,void 0,this)}function bm(f){let m=[],y=f.snippet.trim(),w=f.context,N=$m(y);if(N!==y)m.push(`> ${N}`);else if(f.filePath&&w&&w.lineStart!=null){let X=w.lineStart,J=w.lineEnd??X,b=y.split(`
|
|
2
|
-
`);if(y.length<30&&X===J&&(w.before||w.after)){let Q=Km(f);m.push(`> L${X}: ${Q}`)}else if(b.length<=6)for(let Q=0;Q<b.length;Q++)m.push(`> ${X+Q} | ${b[Q]}`);else{for(let Q=0;Q<3;Q++)m.push(`> ${X+Q} | ${b[Q]}`);m.push(`> ... (${b.length} lines)`);for(let Q=b.length-3;Q<b.length;Q++)m.push(`> ${X+Q} | ${b[Q]}`)}}else{let X=Km(f);if(y.split(`
|
|
3
|
-
`).length<=3)m.push(`> ${X.split(`
|
|
4
|
-
`).join(`
|
|
5
|
-
> `)}`);else{let J=y.split(`
|
|
6
|
-
`);m.push(`> ${J[0]}`),m.push(`> ... (${J.length} lines)`),m.push(`> ${J[J.length-1]}`)}}if(f.note.trim())m.push(""),m.push(f.note.trim());let $=[...f.images??[]],u=new Set($);for(let X of f.attachments??[]){if(u.has(X.url))continue;u.add(X.url),$.push(X.url)}if($.length){m.push("");for(let X of $)m.push(``)}return m.push(""),m.join(`
|
|
7
|
-
`)}import{SessionContext as i0,useAnnotationHost as D0}from"@fabrika/annotations/runtime";import{useCallback as km,useContext as E0,useEffect as l0,useMemo as Q1,useRef as Am,useState as lf}from"react";import{createPortal as t0}from"react-dom";function Y1(f){let m=/^(\d+(?:\.\d+)?)px$/.exec(f.trim());return m?Number(m[1]):void 0}function U1(f,m,y=280){let N=m||document.body,$=f.getBoundingClientRect(),u=N.getBoundingClientRect(),X=N===document.body?0:N.scrollTop,J=$.bottom-u.top+X+8,b=Math.max(0,Math.min($.left-u.left,u.width-y-12));return N.style.position="relative",{style:{position:"absolute",top:`${J}px`,left:`${b}px`},parent:N}}import{jsxDEV as Nf,Fragment as s0}from"react/jsx-dev-runtime";function q1({anchorEl:f,scrollContainer:m,onClose:y,ignoreSelector:w,zIndex:N="50",padding:$="12px",width:u="280px",children:X}){let J=Am(null),b=Am(y);b.current=y;let{style:U,parent:Q}=U1(f,m,Y1(u));return l0(()=>{let _=setTimeout(()=>{let Y=(W)=>{if(J.current&&!J.current.contains(W.target)){if(w&&W.target.closest?.(w))return;b.current(),document.removeEventListener("mousedown",Y)}};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},0);return()=>clearTimeout(_)},[w]),t0(Nf("div",{ref:J,style:{...U,zIndex:N,width:u,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:$,fontFamily:"'Inter', sans-serif"},children:X},void 0,!1,void 0,this),Q)}var G1=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],W1=G1.flatMap((f)=>f.items);function Sy({anchorEl:f,scrollContainer:m,snippet:y,truncateAt:w=100,header:N,initialNote:$="",initialImages:u,onConfirm:X,onCancel:J,onDelete:b}){let U=E0(i0),Q=D0(),_=Jm(Q),Y=$!==""||!!b,[W,F]=lf($),[c,z]=lf(u||[]),[S,q]=lf(null),[K,T]=lf(Y),[A,O]=lf(!1),r=Am(null),C=Am(null),g=km(()=>{if(W.trim()||c.length>0)X(W.trim(),c);else if(Y&&b)b();else J()},[W,c,X,J,Y,b]),D=km(()=>{if(Y){if(!W.trim()&&c.length===0&&b){b(),J();return}X(W,c);return}J()},[W,c,Y,X,J,b]),o=!Y,E=W.trim().length>0?W1.filter((H)=>H.toLowerCase().startsWith(W.trim().toLowerCase())):W1,Jf=!o||K?[]:E.length===1&&E[0]?.toLowerCase()===W.trim().toLowerCase()?[]:E,k=new Set(Jf),V=G1.map((H)=>({label:H.label,items:H.items.filter((h)=>k.has(h))})).filter((H)=>H.items.length>0),i=V.map((H)=>H.items),s=(H)=>i[H]?.length??0,d=i.flat(),L=Q1(()=>{if(S===null)return 0;let H=0;for(let h=0;h<i.length;h++){if(S<H+s(h))return h;H+=s(h)}return 0},[S,i]),B=Q1(()=>{if(S===null)return 0;let H=0;for(let h=0;h<L;h++)H+=s(h);return S-H},[S,L,i]),p=(H,h)=>{let v=0;for(let a=0;a<H;a++)v+=s(a);return v+h},[R,e]=lf(W);if(W!==R)e(W),q(null),T(Y);let G=km((H)=>{F(H)},[]),M=y.length>w?y.slice(0,w)+"...":y,j=km((H)=>{if(d.length>0&&(H.key==="ArrowDown"||H.key==="ArrowUp"||H.key==="ArrowLeft"||H.key==="ArrowRight")){if(H.preventDefault(),S===null){q(0);return}if(H.key==="ArrowDown"){let v=Math.min(B+1,s(L)-1);q(p(L,v))}else if(H.key==="ArrowUp"){let v=Math.max(B-1,0);q(p(L,v))}else if(H.key==="ArrowRight"){let v=Math.min(L+1,i.length-1),a=Math.min(B,s(v)-1);q(p(v,a))}else if(H.key==="ArrowLeft"){let v=Math.max(L-1,0),a=Math.min(B,s(v)-1);q(p(v,a))}return}let h=S===null?void 0:d[S];if(h!==void 0){if(H.key==="Tab"){H.preventDefault(),G(h);return}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),X(h,c);return}}if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),g();return}if(H.key==="Escape")if(d.length>0&&!K)T(!0);else if(Y)D();else J()},[d,S,B,L,i,p,G,X,c,g,K,Y,D,J]);return Nf(q1,{anchorEl:f,scrollContainer:m,onClose:Y?D:J,ignoreSelector:Y?"[data-annotation-id]":void 0,zIndex:Y?"60":"50",padding:Y?"10px 12px":"12px",width:"420px",children:[!Y&&(N??Nf("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",M,"”"]},void 0,!0,void 0,this)),Nf(Ef,{note:W,onNoteChange:F,images:c,onAddImage:(H)=>z((h)=>[...h,H]),onRemoveImage:(H)=>z((h)=>h.filter((v)=>v!==H)),sessionId:U,autoFocus:!0,autoResize:Y,textareaRef:r,onKeyDown:j,attachButton:"none",openFilePickerRef:C,textareaStyle:Y?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),Nf("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:Y?"6px":"8px"},children:[_&&Nf(rm,{onClick:()=>C.current?.(),size:14},void 0,!1,void 0,this),Nf("div",{style:{flex:1}},void 0,!1,void 0,this),Y?Nf("button",{onClick:()=>{if(b)b();J()},onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),style:{fontSize:"11px",color:A?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):Nf(s0,{children:[Nf("button",{onClick:J,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),Nf("button",{onClick:g,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d.length>0&&Nf("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:V.map((H)=>Nf("div",{style:{flex:1},children:[Nf("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:H.label},void 0,!1,void 0,this),H.items.map((h)=>{let v=d.indexOf(h);return Nf("div",{onMouseDown:(a)=>{a.preventDefault(),a.stopPropagation(),G(h)},onMouseEnter:()=>q(v),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:v===S?"var(--color-text-primary)":"var(--color-text-secondary)",background:v===S?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[Nf("span",{style:{fontWeight:500},children:h.slice(0,W.trim().length)},void 0,!1,void 0,this),h.slice(W.trim().length)]},h,!0,void 0,this)})]},H.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Lf({anchorEl:f,scrollContainer:m,snippet:y,truncateAt:w,header:N,onAdd:$,onCancel:u}){return Nf(Sy,{anchorEl:f,scrollContainer:m,snippet:y,truncateAt:w,header:N,onConfirm:(X,J)=>$(X,J),onCancel:u},void 0,!1,void 0,this)}function Ym({anchorEl:f,scrollContainer:m,initialNote:y,initialImages:w,onUpdate:N,onDelete:$,onClose:u}){return Nf(Sy,{anchorEl:f,scrollContainer:m,snippet:"",initialNote:y,initialImages:w,onConfirm:(X,J)=>{N(X,J),u()},onDelete:$,onCancel:u},void 0,!1,void 0,this)}import{useEffect as o0,useRef as Fy,useState as _1}from"react";import{jsxDEV as a0}from"react/jsx-dev-runtime";function Zy(f){let{containerRef:m,restoreKey:y,shape:w="rect",canvasFile:N,scrollContainer:$}=f,{addAnnotationWithId:u}=Pf(),[X,J]=_1(null),[b,U]=_1(!1),Q=Fy(u);Q.current=u;let _=Fy(N);_.current=N;let Y=Fy(w);return Y.current=w,o0(()=>{let F=m.current;if(!F)return;let c=null;function z(O,r){let C=O.getBoundingClientRect();return Xy(C,r.clientX-C.left,r.clientY-C.top)}function S(){if(!c)return;let{host:O,pointerId:r}=c;if(O.hasPointerCapture(r))O.releasePointerCapture(r);O.removeEventListener("pointermove",K),O.removeEventListener("pointerup",T),O.removeEventListener("pointercancel",A),c=null,U(!1)}function q(O){if(c||O.button!==0)return;let r=O.target;if(!(r instanceof Element))return;if(r.closest("[data-block-comment-btn]"))return;if(r.closest("[data-annotation-id]"))return;let C=r.closest(`[${Jy}]`);if(!(C instanceof HTMLElement)||!F?.contains(C))return;let g=C.closest("[data-md='image']")?.getAttribute("data-md-src");if(!g)return;let D=z(C,O);if(!D)return;O.preventDefault(),C.setPointerCapture(O.pointerId);let o=Ff(),E=Mm({...D,w:0,h:0},Y.current,o);E.classList.add("ann-region-draft"),C.appendChild(E),c={pointerId:O.pointerId,host:C,src:g,start:D,shape:Y.current,overlay:E,id:o},C.addEventListener("pointermove",K),C.addEventListener("pointerup",T),C.addEventListener("pointercancel",A),U(!0)}function K(O){if(!c||c.pointerId!==O.pointerId)return;let r=z(c.host,O);if(!r)return;pm(c.overlay,Lm(c.start,r))}function T(O){if(!c||c.pointerId!==O.pointerId)return;let{overlay:r,id:C,src:g,shape:D}=c,o=z(c.host,O)??c.start,E=Lm(c.start,o);if(S(),!by(E)){r.remove();return}pm(r,E);let Jf={src:g,shape:D,...E};J({overlay:r,id:C,snippet:um.format(Jf),label:Bm(Jf)})}function A(O){if(!c||c.pointerId!==O.pointerId)return;c.overlay.remove(),S()}return F.addEventListener("pointerdown",q),()=>{if(F.removeEventListener("pointerdown",q),c)c.overlay.remove(),S()}},[y]),{popovers:X?a0(Lf,{anchorEl:X.overlay,scrollContainer:$,snippet:X.label,truncateAt:80,onAdd:(F,c)=>{X.overlay.classList.remove("ann-region-draft"),Q.current(X.id,X.snippet,F,void 0,void 0,c,_.current),J(null)},onCancel:()=>{X.overlay.remove(),J(null)}},void 0,!1,void 0,this):null,isDrawing:b,isPopoverOpen:!!X}}import{useCallback as c1,useEffect as Cm,useRef as rf,useState as S1}from"react";import{jsxDEV as Hy,Fragment as n0}from"react/jsx-dev-runtime";function Ky(f){let{containerRef:m,restoreKey:y,restoreAnnotations:w,extractContext:N,filePath:$,canvasFile:u,scrollContainer:X}=f,{annotations:J,addAnnotationWithId:b,removeAnnotation:U,updateAnnotation:Q,addAnnotationImage:_,removeAnnotationImage:Y,activeAnnotationId:W,setActiveAnnotationId:F}=Pf(),[c,z]=S1(null),[S,q]=S1(null),K=rf(N);K.current=N;let T=rf($);T.current=$;let A=rf(u);A.current=u;let O=rf(b);O.current=b;let r=rf(W);r.current=W;let C=rf(F);C.current=F;let g=w.length;Cm(()=>{if(!m.current)return;let k=setTimeout(()=>{if(m.current)Qy(m.current,w)},50);return()=>clearTimeout(k)},[y,g]);let D=rf(null);Cm(()=>{em(W,D.current),D.current=W},[W]),Cm(()=>{let k=m.current;if(!k)return;let V=(d)=>{let L=d.target.closest("[data-annotation-id]");if(!L)return;d.stopPropagation();let B=L.getAttribute("data-annotation-id");if(B===r.current)z({anchorEl:L,annId:B});else C.current(B)},i=(d)=>{let L=d.target.closest("[data-annotation-id]");if(L)C.current(L.getAttribute("data-annotation-id"))},s=(d)=>{let L=d.target.closest("[data-annotation-id]"),B=d.relatedTarget?.closest?.("[data-annotation-id]");if(L&&!B&&!document.getElementById("ann-inline-popover"))C.current(null)};return k.addEventListener("click",V),k.addEventListener("mouseover",i),k.addEventListener("mouseout",s),()=>{k.removeEventListener("click",V),k.removeEventListener("mouseover",i),k.removeEventListener("mouseout",s)}},[y]),Cm(()=>{let k=()=>o();return document.addEventListener("mouseup",k),()=>document.removeEventListener("mouseup",k)},[]);let o=c1(()=>{let k=window.getSelection();if(!k||k.isCollapsed||!k.toString().trim())return;if(!m.current)return;let V=k.getRangeAt(0);if(!m.current.contains(V.startContainer))return;if(V.startContainer.parentElement?.closest?.("[data-annotation-id]"))return;let i=w1(V).trim();if(i.length<2)return;let s=K.current(V),d=V.cloneRange(),L=`__pending_${Date.now()}`;try{Hm(d,L)}catch{}window.getSelection()?.removeAllRanges();let B=document.querySelectorAll(`[data-annotation-id="${L}"]`),p=B[B.length-1];if(!p)return;q({anchorEl:p,tempId:L,snippet:i,ctx:s})},[]),E=c1((k,V,i,s)=>{q({anchorEl:k,tempId:V,snippet:i,ctx:s})},[]);return{popovers:Hy(n0,{children:[c&&(()=>{let k=J.find((V)=>V.id===c.annId);if(!k)return null;return Hy(Ym,{anchorEl:c.anchorEl,scrollContainer:X,initialNote:k.note,initialImages:k.images,onUpdate:(V,i)=>{Q(c.annId,V);let s=k.images||[];for(let d of i)if(!s.includes(d))_(c.annId,d);for(let d of s)if(!i.includes(d))Y(c.annId,d)},onDelete:()=>{U(c.annId),F(null)},onClose:()=>z(null)},void 0,!1,void 0,this)})(),S&&Hy(Lf,{anchorEl:S.anchorEl,scrollContainer:X,snippet:S.snippet,truncateAt:80,onAdd:(k,V)=>{let i=Ff();fy(S.tempId,i),O.current(i,S.snippet,k,T.current,S.ctx,V,A.current),q(null)},onCancel:()=>{yy(S.tempId),q(null)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),openCreatePopover:E,isPopoverOpen:!!(c||S)}}import{AnnotationCtx as N2}from"#canvas/runtime";import{AnnotationCtx as u2,AnnotationHostContext as $2}from"@fabrika/annotations/runtime";import{useCallback as of,useEffect as P1,useMemo as J2,useRef as L1,useState as af}from"react";function kf(f,m,y="current"){let w=`canvas:${f}:rev:${m}`;return y==="next"?`${w}:next-draft`:w}function e0(f,m){return`${kf(f,m)}:draft-handled`}function Ty(f,m,y){try{f.removeItem(kf(m,y)),f.removeItem(e0(m,y))}catch{}}function zy(f,m){let y=new Map;for(let[w,N]of f)if(m.has(w))y.set(w,N);return y}function Py(f,m){if(!f||f.length===0)return!1;return f.every((y)=>m.has(y))}function tf(f,m,y,w,N){let $=[],u=f.filter((Y)=>Y.source!=="remote"||N&&N.has(Y.id)),X=u.filter((Y)=>Y.filePath===Df),J=u.filter((Y)=>!Y.filePath),b=u.filter((Y)=>Y.filePath&&Y.filePath!==Df),U=y?Array.from(y.values()).filter((Y)=>gm(Y)):[],Q=w?Array.from(w.values()).filter((Y)=>Y.markdown.trim()):[];if(U.length>0||Q.length>0){$.push("## Responses"),$.push("");for(let Y of U)$.push(f2(Y));for(let Y of Q)$.push(Y.markdown.trim()),$.push("")}if(X.length>0){$.push("## Annotations on agent response"),$.push("");for(let Y of X)$.push(bm(Y))}if(J.length>0){$.push("## Canvas annotations"),$.push("");let Y=new Map;for(let c of J){let z=c.canvasFile||"";if(!Y.has(z))Y.set(z,[]);Y.get(z).push(c)}let W=[...Y.keys()].sort(),F=W.length>1||W.length===1&&W[0]!=="";for(let c of W){let z=Y.get(c);if(F&&c)$.push(`### ${c.replace(/\.jsx$/,"")}`),$.push("");let S=m2(z);$.push(H1(S))}}if(b.length>0){let Y={};for(let W of b){let F=W.filePath;if(!Y[F])Y[F]=[];Y[F].push(W)}$.push("## File annotations"),$.push("");for(let[W,F]of Object.entries(Y)){$.push(`### ${W}`),$.push("");for(let c of F)$.push(bm(c))}}if(m.trim())$.push("## General notes"),$.push(""),$.push(m.trim()),$.push("");return $.join(`
|
|
8
|
-
`).trim()+`
|
|
9
|
-
`}function gm(f){if(f.note?.trim())return!0;if(f.value===null||f.value===void 0)return!1;if(f.type==="text"&&!f.value.trim())return!1;if(f.type==="checkbox"&&f.value.length===0)return!1;return!0}function F1(f){let m=[];for(let y of f.values()){if(!y.required)continue;if(y.value===null||y.value===void 0){m.push(y);continue}if(y.type==="text"&&!y.value.trim()){m.push(y);continue}if(y.type==="checkbox"&&y.value.length===0){m.push(y);continue}}return m}function Z1(f){let m=[];for(let y of f.values())if(y.required&&!y.markdown.trim())m.push(y);return m}function sf(f,m){let y=F1(f),w=Z1(m);return[...y.map((N)=>N.label),...w.map((N)=>N.label||N.id)]}function f2(f){let m=[];switch(m.push(`**${f.label}**`),f.type){case"radio":case"select":m.push(`Answer: ${f.value}`);break;case"checkbox":for(let y of f.value)m.push(`- [x] ${y}`);break;case"text":m.push(""),m.push(f.value.trim());break;case"range":m.push(`Answer: ${f.value}`);break}if(f.note?.trim())m.push(""),m.push(`Note: ${f.note.trim()}`);return m.push(""),m.join(`
|
|
10
|
-
`)}function m2(f){let m={label:"",annotations:[],children:new Map};for(let y of f){let w=y.context?.hierarchy||[],N=m;for(let $ of w){if(!N.children.has($))N.children.set($,{label:$,annotations:[],children:new Map});N=N.children.get($)}N.annotations.push(y)}return m}function H1(f,m=0){let y=[];for(let w of f.annotations)y.push(bm(w));for(let[,w]of f.children){let N=m===0?"###":"####";y.push(`${N} ${w.label}`),y.push(""),y.push(H1(w,m+1))}return y.join(`
|
|
11
|
-
`)}import{createContext as y2,useContext as w2}from"react";function K1(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var T1={get sessionId(){return K1()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:(f,m)=>{let y=f.replace(/\.jsx$/,".js"),w=m?`?rev=${m}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${K1()}/canvas/${encodeURIComponent(y)}${w}`)}},z1=y2(T1);function Hf(){return w2(z1)}import{useAnnotations as Af}from"#canvas/runtime";import{jsxDEV as By}from"react/jsx-dev-runtime";function B1(f,m,y){try{let w=localStorage.getItem(kf(f,m,y));if(!w)return null;return JSON.parse(w)}catch{return null}}function X2(f,m,y,w){try{localStorage.setItem(kf(f,m,y),JSON.stringify(w))}catch{}}function Ly(f){return{draft:f,responseIds:new Set,canvases:new Set}}function vm({sessionId:f,revision:m,isReadOnly:y,draftPhase:w,remoteAnnotations:N,canvasFiles:$,loadState:u,saveState:X,children:J}){let b=!!u,U=b?null:B1(f,m,w),[Q,_]=af(()=>(U?.annotations??[]).map((B)=>({...B,source:B.source??"local"}))),[Y,W]=af(()=>U?.generalNote??""),[F,c]=af(()=>U?.responses?new Map(U.responses):new Map),z=`${f}:${m}:${w}`,S=L1(z);S.current=z;let[q,K]=af(()=>Ly(z)),[T,A]=af(()=>U?.feedbackEntries?new Map(U.feedbackEntries):new Map),[O,r]=af(!b);P1(()=>{let B=(p)=>{_((p?.annotations??[]).map((R)=>({...R,source:R.source??"local"}))),W(p?.generalNote??""),c(p?.responses?new Map(p.responses):new Map),A(p?.feedbackEntries?new Map(p.feedbackEntries):new Map),d(null)};if(b){let p=!1;return r(!1),u(f,m,w).then((R)=>{if(p)return;B(R),r(!0)}),()=>{p=!0}}B(B1(f,m,w)),r(!0);return},[f,m,w,b,u]);let C=L1(null);P1(()=>{if(y&&w!=="next")return;if(!O)return;if(C.current)clearTimeout(C.current);let B={annotations:Q,generalNote:Y,responses:Array.from(F.entries()),feedbackEntries:Array.from(T.entries())},p=()=>{if(X)X(f,m,B,w);else X2(f,m,w,B)};if(w==="next"){p();return}return C.current=setTimeout(p,300),()=>{if(C.current)clearTimeout(C.current)}},[Q,Y,F,T,f,m,y,w,O,X]);let g=of((B,p)=>{c((R)=>{let e=new Map(R);return e.set(B,p),e})},[]),D=of((B)=>{K((p)=>{let R=p.draft===S.current?p:Ly(S.current);if(R.responseIds.has(B))return R;return{...R,responseIds:new Set(R.responseIds).add(B)}})},[]),o=of((B)=>{K((p)=>{let R=p.draft===S.current?p:Ly(S.current);if(R.canvases.has(B))return R;return{...R,canvases:new Set(R.canvases).add(B)}})},[]),E=q.draft===z?q:null,Jf=J2(()=>{if(!E||!Py($,E.canvases))return F;return zy(F,E.responseIds)},[E,$,F]),k=of((B,p)=>{A((R)=>{let e=R.get(B);if(e&&e.markdown===p.markdown&&e.label===p.label&&e.required===p.required)return R;let G=new Map(R);return G.set(B,p),G})},[]),V=of((B)=>{A((p)=>{if(!p.has(B))return p;let R=new Map(p);return R.delete(B),R})},[]),i=of(()=>{if(c(new Map),A(new Map),X)X(f,m,{annotations:[],generalNote:"",responses:[],feedbackEntries:[]},w);else if(w==="next")localStorage.removeItem(kf(f,m,w));else Ty(localStorage,f,m)},[f,m,w,X]),s=hm({annotations:Q,setAnnotations:_,generalNote:Y,setGeneralNote:W,remoteAnnotations:N,isReadOnly:y,onClear:i}),{setActiveAnnotationId:d}=s,L=Hf();return By($2.Provider,{value:L,children:By(u2.Provider,{value:s,children:By(N2.Provider,{value:{...s,responses:F,setResponse:g,submittableResponses:Jf,registerResponse:D,registerCanvasRendered:o,feedbackEntries:T,setFeedbackEntry:k,removeFeedbackEntry:V},children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{ActiveViewCtx as cw,AnnotationCtx as Sw,CanvasFileCtx as Fw,SessionContext as Ey,useAnnotations as Zw,useCanvasFile as b$,useFeedback as Hw,useResponseRegistration as Y$}from"#canvas/runtime";function Um(f){let m=document.querySelector(`[data-annotation-id="${f.id}"]`);if(m instanceof HTMLElement)return m;let y=f.canvasFile?document.querySelector(`[data-canvas-file="${f.canvasFile}"]`):document;if(!y)return null;return Uy(f.snippet,y)}function p1(f){f.classList.remove("ann-flash"),f.offsetWidth,f.classList.add("ann-flash"),f.addEventListener("animationend",()=>{f.classList.remove("ann-flash")},{once:!0})}function py(f,m){let y=Mf(f);if(y)m({type:"file",path:y}),setTimeout(()=>{let w=Um(f);if(w)w.scrollIntoView({behavior:"smooth",block:"center"}),p1(w)},150);else{let w=Um(f);if(w)w.scrollIntoView({behavior:"smooth",block:"center"}),p1(w)}}import{SessionContext as mw}from"#canvas/runtime";import{useCallback as jy,useContext as Vy,useEffect as t1,useMemo as yw,useState as mm}from"react";import{createContext as M1}from"react";var nf=M1({activeView:{type:"overview"},setActiveView:()=>{},openFiles:[],closeFile:()=>{},canvasFiles:[]}),ef=M1({currentRevision:1,selectedRevision:1,revisions:[],setSelectedRevision:()=>{},isReadOnly:!1,compareRevision:null,setCompareRevision:()=>{},agentWatching:!1});import{jsxDEV as Cf}from"react/jsx-dev-runtime";var b2={ts:"#3178c6",tsx:"#3178c6",js:"#e8a32e",jsx:"#4ba0c8",html:"#e34c26",css:"#264de4",scss:"#c69",json:"#7a7568",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",rs:"#dea584",go:"#00add8",c:"#6a6a6a",cpp:"#f34b7d",h:"#6a6a6a",py:"#3572a5",rb:"#cc342d",sh:"#5a8c3c",bash:"#5a8c3c",md:"#3573b5",txt:"#6b6560",lock:"#6b6560",gitignore:"#6b6560",svg:"#d9952e",png:"#6a9c2e",jpg:"#6a9c2e",gif:"#6a9c2e"},Y2={ts:"TS",tsx:"TX",js:"JS",jsx:"JX",py:"PY",rs:"RS",go:"GO",rb:"RB",json:"{}",yaml:"YM",yml:"YM",toml:"TM",html:"<>",css:"#",scss:"#",md:"M↓",sh:"$",bash:"$",c:"C",cpp:"C+",h:"H",svg:"◇",png:"▣",jpg:"▣"};function My({name:f,type:m,expanded:y,className:w=""}){if(m==="dir")return Cf("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",className:`flex-shrink-0 ${w}`,children:y?Cf("path",{d:"M1.5 3.5h5l1.5 1.5h6.5v8h-13z",style:{fill:"var(--color-folder-fill-active)",stroke:"var(--color-folder-stroke-active)"},strokeWidth:"1"},void 0,!1,void 0,this):Cf("path",{d:"M1.5 3.5h5l1.5 1.5h6.5v8h-13z",style:{fill:"var(--color-folder-fill)",stroke:"var(--color-folder-stroke)"},strokeWidth:"1"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let N=f.includes(".")?f.split(".").pop().toLowerCase():"",$=b2[N]||"#6b6560",u=Y2[N];return Cf("svg",{width:"14",height:"14",viewBox:"0 0 16 16",className:`flex-shrink-0 ${w}`,children:[Cf("path",{d:"M2 1.5h8l3.5 3.5v9.5a1 1 0 01-1 1H3a1 1 0 01-1-1v-12a1 1 0 011-1z",fill:$,opacity:"0.85"},void 0,!1,void 0,this),Cf("path",{d:"M10 1.5v2.5a1 1 0 001 1h2.5",fill:"none",stroke:"white",strokeWidth:"0.5",opacity:"0.5"},void 0,!1,void 0,this),u&&Cf("text",{x:"8",y:"11.5",textAnchor:"middle",fill:"white",fontSize:"5.5",fontFamily:"monospace",fontWeight:"600",children:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function hy(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Rf=hy();function g1(f){Rf=f}var gf={exec:()=>null};function x(f,m=""){let y=typeof f=="string"?f:f.source,w={replace:(N,$)=>{let u=typeof $=="string"?$:$.source;return u=u.replace(Xf.caret,"$1"),y=y.replace(N,u),w},getRegex:()=>new RegExp(y,m)};return w}var U2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Xf={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(f)=>new RegExp(`^( {0,3}${f})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}#`),htmlBeginRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(f)=>new RegExp(`^ {0,${Math.min(3,f-1)}}>`)},Q2=/^(?:[ \t]*(?:\n|$))+/,W2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,q2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gm=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,G2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ry=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,v1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,R1=x(v1).replace(/bull/g,ry).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),_2=x(v1).replace(/bull/g,ry).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ky=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,c2=/^[^\n]+/,Ay=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,S2=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ay).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),F2=x(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ry).getRegex(),jm="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Cy=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Z2=x("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Cy).replace("tag",jm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),I1=x(ky).replace("hr",Gm).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jm).getRegex(),H2=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",I1).getRegex(),gy={blockquote:H2,code:W2,def:S2,fences:q2,heading:G2,hr:Gm,html:Z2,lheading:R1,list:F2,newline:Q2,paragraph:I1,table:gf,text:c2},O1=x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gm).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jm).getRegex(),K2={...gy,lheading:_2,table:O1,paragraph:x(ky).replace("hr",Gm).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",O1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",jm).getRegex()},T2={...gy,html:x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Cy).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gf,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:x(ky).replace("hr",Gm).replace("heading",` *#{1,6} *[^
|
|
12
|
-
]`).replace("lheading",R1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},z2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,P2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,x1=/^( {2,}|\\)\n(?!\s*$)/,L2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,fm=/[\p{P}\p{S}]/u,Vm=/[\s\p{P}\p{S}]/u,vy=/[^\s\p{P}\p{S}]/u,B2=x(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Vm).getRegex(),d1=/(?!~)[\p{P}\p{S}]/u,p2=/(?!~)[\s\p{P}\p{S}]/u,M2=/(?:[^\s\p{P}\p{S}]|~)/u,O2=x(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",U2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),j1=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,h2=x(j1,"u").replace(/punct/g,fm).getRegex(),r2=x(j1,"u").replace(/punct/g,d1).getRegex(),V1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",k2=x(V1,"gu").replace(/notPunctSpace/g,vy).replace(/punctSpace/g,Vm).replace(/punct/g,fm).getRegex(),A2=x(V1,"gu").replace(/notPunctSpace/g,M2).replace(/punctSpace/g,p2).replace(/punct/g,d1).getRegex(),C2=x("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,vy).replace(/punctSpace/g,Vm).replace(/punct/g,fm).getRegex(),g2=x(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,fm).getRegex(),v2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",R2=x(v2,"gu").replace(/notPunctSpace/g,vy).replace(/punctSpace/g,Vm).replace(/punct/g,fm).getRegex(),I2=x(/\\(punct)/,"gu").replace(/punct/g,fm).getRegex(),x2=x(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),d2=x(Cy).replace("(?:-->|$)","-->").getRegex(),j2=x("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",d2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Im=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,V2=x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Im).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),i1=x(/^!?\[(label)\]\[(ref)\]/).replace("label",Im).replace("ref",Ay).getRegex(),D1=x(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ay).getRegex(),i2=x("reflink|nolink(?!\\()","g").replace("reflink",i1).replace("nolink",D1).getRegex(),h1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ry={_backpedal:gf,anyPunctuation:I2,autolink:x2,blockSkip:O2,br:x1,code:P2,del:gf,delLDelim:gf,delRDelim:gf,emStrongLDelim:h2,emStrongRDelimAst:k2,emStrongRDelimUnd:C2,escape:z2,link:V2,nolink:D1,punctuation:B2,reflink:i1,reflinkSearch:i2,tag:j2,text:L2,url:gf},D2={...Ry,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",Im).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Im).getRegex()},Oy={...Ry,emStrongRDelimAst:A2,emStrongLDelim:r2,delLDelim:g2,delRDelim:R2,url:x(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",h1).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:x(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",h1).getRegex()},E2={...Oy,br:x(x1).replace("{2,}","*").getRegex(),text:x(Oy.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Rm={normal:gy,gfm:K2,pedantic:T2},Qm={normal:Ry,gfm:Oy,breaks:E2,pedantic:D2},l2={"&":"&","<":"<",">":">",'"':""","'":"'"},r1=(f)=>l2[f];function cf(f,m){if(m){if(Xf.escapeTest.test(f))return f.replace(Xf.escapeReplace,r1)}else if(Xf.escapeTestNoEncode.test(f))return f.replace(Xf.escapeReplaceNoEncode,r1);return f}function k1(f){try{f=encodeURI(f).replace(Xf.percentDecode,"%")}catch{return null}return f}function A1(f,m){let y=f.replace(Xf.findPipe,($,u,X)=>{let J=!1,b=u;for(;--b>=0&&X[b]==="\\";)J=!J;return J?"|":" |"}),w=y.split(Xf.splitPipe),N=0;if(w[0].trim()||w.shift(),w.length>0&&!w.at(-1)?.trim()&&w.pop(),m)if(w.length>m)w.splice(m);else for(;w.length<m;)w.push("");for(;N<w.length;N++)w[N]=w[N].trim().replace(Xf.slashPipe,"|");return w}function Wm(f,m,y){let w=f.length;if(w===0)return"";let N=0;for(;N<w;){let $=f.charAt(w-N-1);if($===m&&!y)N++;else if($!==m&&y)N++;else break}return f.slice(0,w-N)}function t2(f,m){if(f.indexOf(m[1])===-1)return-1;let y=0;for(let w=0;w<f.length;w++)if(f[w]==="\\")w++;else if(f[w]===m[0])y++;else if(f[w]===m[1]&&(y--,y<0))return w;return y>0?-2:-1}function s2(f,m=0){let y=m,w="";for(let N of f)if(N==="\t"){let $=4-y%4;w+=" ".repeat($),y+=$}else w+=N,y++;return w}function C1(f,m,y,w,N){let $=m.href,u=m.title||null,X=f[1].replace(N.other.outputLinkReplace,"$1");w.state.inLink=!0;let J={type:f[0].charAt(0)==="!"?"image":"link",raw:y,href:$,title:u,text:X,tokens:w.inlineTokens(X)};return w.state.inLink=!1,J}function o2(f,m,y){let w=f.match(y.other.indentCodeCompensation);if(w===null)return m;let N=w[1];return m.split(`
|
|
13
|
-
`).map(($)=>{let u=$.match(y.other.beginningSpace);if(u===null)return $;let[X]=u;return X.length>=N.length?$.slice(N.length):$}).join(`
|
|
14
|
-
`)}var xm=class{options;rules;lexer;constructor(f){this.options=f||Rf}space(f){let m=this.rules.block.newline.exec(f);if(m&&m[0].length>0)return{type:"space",raw:m[0]}}code(f){let m=this.rules.block.code.exec(f);if(m){let y=m[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:m[0],codeBlockStyle:"indented",text:this.options.pedantic?y:Wm(y,`
|
|
15
|
-
`)}}}fences(f){let m=this.rules.block.fences.exec(f);if(m){let y=m[0],w=o2(y,m[3]||"",this.rules);return{type:"code",raw:y,lang:m[2]?m[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):m[2],text:w}}}heading(f){let m=this.rules.block.heading.exec(f);if(m){let y=m[2].trim();if(this.rules.other.endingHash.test(y)){let w=Wm(y,"#");(this.options.pedantic||!w||this.rules.other.endingSpaceChar.test(w))&&(y=w.trim())}return{type:"heading",raw:m[0],depth:m[1].length,text:y,tokens:this.lexer.inline(y)}}}hr(f){let m=this.rules.block.hr.exec(f);if(m)return{type:"hr",raw:Wm(m[0],`
|
|
16
|
-
`)}}blockquote(f){let m=this.rules.block.blockquote.exec(f);if(m){let y=Wm(m[0],`
|
|
17
|
-
`).split(`
|
|
18
|
-
`),w="",N="",$=[];for(;y.length>0;){let u=!1,X=[],J;for(J=0;J<y.length;J++)if(this.rules.other.blockquoteStart.test(y[J]))X.push(y[J]),u=!0;else if(!u)X.push(y[J]);else break;y=y.slice(J);let b=X.join(`
|
|
19
|
-
`),U=b.replace(this.rules.other.blockquoteSetextReplace,`
|
|
20
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");w=w?`${w}
|
|
21
|
-
${b}`:b,N=N?`${N}
|
|
22
|
-
${U}`:U;let Q=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(U,$,!0),this.lexer.state.top=Q,y.length===0)break;let _=$.at(-1);if(_?.type==="code")break;if(_?.type==="blockquote"){let Y=_,W=Y.raw+`
|
|
23
|
-
`+y.join(`
|
|
24
|
-
`),F=this.blockquote(W);$[$.length-1]=F,w=w.substring(0,w.length-Y.raw.length)+F.raw,N=N.substring(0,N.length-Y.text.length)+F.text;break}else if(_?.type==="list"){let Y=_,W=Y.raw+`
|
|
25
|
-
`+y.join(`
|
|
26
|
-
`),F=this.list(W);$[$.length-1]=F,w=w.substring(0,w.length-_.raw.length)+F.raw,N=N.substring(0,N.length-Y.raw.length)+F.raw,y=W.substring($.at(-1).raw.length).split(`
|
|
27
|
-
`);continue}}return{type:"blockquote",raw:w,tokens:$,text:N}}}list(f){let m=this.rules.block.list.exec(f);if(m){let y=m[1].trim(),w=y.length>1,N={type:"list",raw:"",ordered:w,start:w?+y.slice(0,-1):"",loose:!1,items:[]};y=w?`\\d{1,9}\\${y.slice(-1)}`:`\\${y}`,this.options.pedantic&&(y=w?y:"[*+-]");let $=this.rules.other.listItemRegex(y),u=!1;for(;f;){let J=!1,b="",U="";if(!(m=$.exec(f))||this.rules.block.hr.test(f))break;b=m[0],f=f.substring(b.length);let Q=s2(m[2].split(`
|
|
28
|
-
`,1)[0],m[1].length),_=f.split(`
|
|
29
|
-
`,1)[0],Y=!Q.trim(),W=0;if(this.options.pedantic?(W=2,U=Q.trimStart()):Y?W=m[1].length+1:(W=Q.search(this.rules.other.nonSpaceChar),W=W>4?1:W,U=Q.slice(W),W+=m[1].length),Y&&this.rules.other.blankLine.test(_)&&(b+=_+`
|
|
30
|
-
`,f=f.substring(_.length+1),J=!0),!J){let F=this.rules.other.nextBulletRegex(W),c=this.rules.other.hrRegex(W),z=this.rules.other.fencesBeginRegex(W),S=this.rules.other.headingBeginRegex(W),q=this.rules.other.htmlBeginRegex(W),K=this.rules.other.blockquoteBeginRegex(W);for(;f;){let T=f.split(`
|
|
31
|
-
`,1)[0],A;if(_=T,this.options.pedantic?(_=_.replace(this.rules.other.listReplaceNesting," "),A=_):A=_.replace(this.rules.other.tabCharGlobal," "),z.test(_)||S.test(_)||q.test(_)||K.test(_)||F.test(_)||c.test(_))break;if(A.search(this.rules.other.nonSpaceChar)>=W||!_.trim())U+=`
|
|
32
|
-
`+A.slice(W);else{if(Y||Q.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||z.test(Q)||S.test(Q)||c.test(Q))break;U+=`
|
|
33
|
-
`+_}Y=!_.trim(),b+=T+`
|
|
34
|
-
`,f=f.substring(T.length+1),Q=A.slice(W)}}N.loose||(u?N.loose=!0:this.rules.other.doubleBlankLine.test(b)&&(u=!0)),N.items.push({type:"list_item",raw:b,task:!!this.options.gfm&&this.rules.other.listIsTask.test(U),loose:!1,text:U,tokens:[]}),N.raw+=b}let X=N.items.at(-1);if(X)X.raw=X.raw.trimEnd(),X.text=X.text.trimEnd();else return;N.raw=N.raw.trimEnd();for(let J of N.items){if(this.lexer.state.top=!1,J.tokens=this.lexer.blockTokens(J.text,[]),J.task){if(J.text=J.text.replace(this.rules.other.listReplaceTask,""),J.tokens[0]?.type==="text"||J.tokens[0]?.type==="paragraph"){J.tokens[0].raw=J.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),J.tokens[0].text=J.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let U=this.lexer.inlineQueue.length-1;U>=0;U--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[U].src)){this.lexer.inlineQueue[U].src=this.lexer.inlineQueue[U].src.replace(this.rules.other.listReplaceTask,"");break}}let b=this.rules.other.listTaskCheckbox.exec(J.raw);if(b){let U={type:"checkbox",raw:b[0]+" ",checked:b[0]!=="[ ]"};J.checked=U.checked,N.loose?J.tokens[0]&&["paragraph","text"].includes(J.tokens[0].type)&&"tokens"in J.tokens[0]&&J.tokens[0].tokens?(J.tokens[0].raw=U.raw+J.tokens[0].raw,J.tokens[0].text=U.raw+J.tokens[0].text,J.tokens[0].tokens.unshift(U)):J.tokens.unshift({type:"paragraph",raw:U.raw,text:U.raw,tokens:[U]}):J.tokens.unshift(U)}}if(!N.loose){let b=J.tokens.filter((Q)=>Q.type==="space"),U=b.length>0&&b.some((Q)=>this.rules.other.anyLine.test(Q.raw));N.loose=U}}if(N.loose)for(let J of N.items){J.loose=!0;for(let b of J.tokens)b.type==="text"&&(b.type="paragraph")}return N}}html(f){let m=this.rules.block.html.exec(f);if(m)return{type:"html",block:!0,raw:m[0],pre:m[1]==="pre"||m[1]==="script"||m[1]==="style",text:m[0]}}def(f){let m=this.rules.block.def.exec(f);if(m){let y=m[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),w=m[2]?m[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",N=m[3]?m[3].substring(1,m[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):m[3];return{type:"def",tag:y,raw:m[0],href:w,title:N}}}table(f){let m=this.rules.block.table.exec(f);if(!m||!this.rules.other.tableDelimiter.test(m[2]))return;let y=A1(m[1]),w=m[2].replace(this.rules.other.tableAlignChars,"").split("|"),N=m[3]?.trim()?m[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
35
|
-
`):[],$={type:"table",raw:m[0],header:[],align:[],rows:[]};if(y.length===w.length){for(let u of w)this.rules.other.tableAlignRight.test(u)?$.align.push("right"):this.rules.other.tableAlignCenter.test(u)?$.align.push("center"):this.rules.other.tableAlignLeft.test(u)?$.align.push("left"):$.align.push(null);for(let u=0;u<y.length;u++)$.header.push({text:y[u],tokens:this.lexer.inline(y[u]),header:!0,align:$.align[u]});for(let u of N)$.rows.push(A1(u,$.header.length).map((X,J)=>({text:X,tokens:this.lexer.inline(X),header:!1,align:$.align[J]})));return $}}lheading(f){let m=this.rules.block.lheading.exec(f);if(m){let y=m[1].trim();return{type:"heading",raw:m[0],depth:m[2].charAt(0)==="="?1:2,text:y,tokens:this.lexer.inline(y)}}}paragraph(f){let m=this.rules.block.paragraph.exec(f);if(m){let y=m[1].charAt(m[1].length-1)===`
|
|
36
|
-
`?m[1].slice(0,-1):m[1];return{type:"paragraph",raw:m[0],text:y,tokens:this.lexer.inline(y)}}}text(f){let m=this.rules.block.text.exec(f);if(m)return{type:"text",raw:m[0],text:m[0],tokens:this.lexer.inline(m[0])}}escape(f){let m=this.rules.inline.escape.exec(f);if(m)return{type:"escape",raw:m[0],text:m[1]}}tag(f){let m=this.rules.inline.tag.exec(f);if(m)return!this.lexer.state.inLink&&this.rules.other.startATag.test(m[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(m[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(m[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(m[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:m[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:m[0]}}link(f){let m=this.rules.inline.link.exec(f);if(m){let y=m[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(y)){if(!this.rules.other.endAngleBracket.test(y))return;let $=Wm(y.slice(0,-1),"\\");if((y.length-$.length)%2===0)return}else{let $=t2(m[2],"()");if($===-2)return;if($>-1){let u=(m[0].indexOf("!")===0?5:4)+m[1].length+$;m[2]=m[2].substring(0,$),m[0]=m[0].substring(0,u).trim(),m[3]=""}}let w=m[2],N="";if(this.options.pedantic){let $=this.rules.other.pedanticHrefTitle.exec(w);$&&(w=$[1],N=$[3])}else N=m[3]?m[3].slice(1,-1):"";return w=w.trim(),this.rules.other.startAngleBracket.test(w)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(y)?w=w.slice(1):w=w.slice(1,-1)),C1(m,{href:w&&w.replace(this.rules.inline.anyPunctuation,"$1"),title:N&&N.replace(this.rules.inline.anyPunctuation,"$1")},m[0],this.lexer,this.rules)}}reflink(f,m){let y;if((y=this.rules.inline.reflink.exec(f))||(y=this.rules.inline.nolink.exec(f))){let w=(y[2]||y[1]).replace(this.rules.other.multipleSpaceGlobal," "),N=m[w.toLowerCase()];if(!N){let $=y[0].charAt(0);return{type:"text",raw:$,text:$}}return C1(y,N,y[0],this.lexer,this.rules)}}emStrong(f,m,y=""){let w=this.rules.inline.emStrongLDelim.exec(f);if(!w||!w[1]&&!w[2]&&!w[3]&&!w[4]||w[4]&&y.match(this.rules.other.unicodeAlphaNumeric))return;if(!(w[1]||w[3])||!y||this.rules.inline.punctuation.exec(y)){let N=[...w[0]].length-1,$,u,X=N,J=0,b=w[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(b.lastIndex=0,m=m.slice(-1*f.length+N);(w=b.exec(m))!==null;){if($=w[1]||w[2]||w[3]||w[4]||w[5]||w[6],!$)continue;if(u=[...$].length,w[3]||w[4]){X+=u;continue}else if((w[5]||w[6])&&N%3&&!((N+u)%3)){J+=u;continue}if(X-=u,X>0)continue;u=Math.min(u,u+X+J);let U=[...w[0]][0].length,Q=f.slice(0,N+w.index+U+u);if(Math.min(N,u)%2){let Y=Q.slice(1,-1);return{type:"em",raw:Q,text:Y,tokens:this.lexer.inlineTokens(Y)}}let _=Q.slice(2,-2);return{type:"strong",raw:Q,text:_,tokens:this.lexer.inlineTokens(_)}}}}codespan(f){let m=this.rules.inline.code.exec(f);if(m){let y=m[2].replace(this.rules.other.newLineCharGlobal," "),w=this.rules.other.nonSpaceChar.test(y),N=this.rules.other.startingSpaceChar.test(y)&&this.rules.other.endingSpaceChar.test(y);return w&&N&&(y=y.substring(1,y.length-1)),{type:"codespan",raw:m[0],text:y}}}br(f){let m=this.rules.inline.br.exec(f);if(m)return{type:"br",raw:m[0]}}del(f,m,y=""){let w=this.rules.inline.delLDelim.exec(f);if(!w)return;if(!w[1]||!y||this.rules.inline.punctuation.exec(y)){let N=[...w[0]].length-1,$,u,X=N,J=this.rules.inline.delRDelim;for(J.lastIndex=0,m=m.slice(-1*f.length+N);(w=J.exec(m))!==null;){if($=w[1]||w[2]||w[3]||w[4]||w[5]||w[6],!$||(u=[...$].length,u!==N))continue;if(w[3]||w[4]){X+=u;continue}if(X-=u,X>0)continue;u=Math.min(u,u+X);let b=[...w[0]][0].length,U=f.slice(0,N+w.index+b+u),Q=U.slice(N,-N);return{type:"del",raw:U,text:Q,tokens:this.lexer.inlineTokens(Q)}}}}autolink(f){let m=this.rules.inline.autolink.exec(f);if(m){let y,w;return m[2]==="@"?(y=m[1],w="mailto:"+y):(y=m[1],w=y),{type:"link",raw:m[0],text:y,href:w,tokens:[{type:"text",raw:y,text:y}]}}}url(f){let m;if(m=this.rules.inline.url.exec(f)){let y,w;if(m[2]==="@")y=m[0],w="mailto:"+y;else{let N;do N=m[0],m[0]=this.rules.inline._backpedal.exec(m[0])?.[0]??"";while(N!==m[0]);y=m[0],m[1]==="www."?w="http://"+m[0]:w=m[0]}return{type:"link",raw:m[0],text:y,href:w,tokens:[{type:"text",raw:y,text:y}]}}}inlineText(f){let m=this.rules.inline.text.exec(f);if(m){let y=this.lexer.state.inRawBlock;return{type:"text",raw:m[0],text:m[0],escaped:y}}}},Qf=class f{tokens;options;state;inlineQueue;tokenizer;constructor(m){this.tokens=[],this.tokens.links=Object.create(null),this.options=m||Rf,this.options.tokenizer=this.options.tokenizer||new xm,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let y={other:Xf,block:Rm.normal,inline:Qm.normal};this.options.pedantic?(y.block=Rm.pedantic,y.inline=Qm.pedantic):this.options.gfm&&(y.block=Rm.gfm,this.options.breaks?y.inline=Qm.breaks:y.inline=Qm.gfm),this.tokenizer.rules=y}static get rules(){return{block:Rm,inline:Qm}}static lex(m,y){return new f(y).lex(m)}static lexInline(m,y){return new f(y).inlineTokens(m)}lex(m){m=m.replace(Xf.carriageReturn,`
|
|
37
|
-
`),this.blockTokens(m,this.tokens);for(let y=0;y<this.inlineQueue.length;y++){let w=this.inlineQueue[y];this.inlineTokens(w.src,w.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(m,y=[],w=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(m=m.replace(Xf.tabCharGlobal," ").replace(Xf.spaceLine,""));m;){let N;if(this.options.extensions?.block?.some((u)=>(N=u.call({lexer:this},m,y))?(m=m.substring(N.raw.length),y.push(N),!0):!1))continue;if(N=this.tokenizer.space(m)){m=m.substring(N.raw.length);let u=y.at(-1);N.raw.length===1&&u!==void 0?u.raw+=`
|
|
38
|
-
`:y.push(N);continue}if(N=this.tokenizer.code(m)){m=m.substring(N.raw.length);let u=y.at(-1);u?.type==="paragraph"||u?.type==="text"?(u.raw+=(u.raw.endsWith(`
|
|
39
|
-
`)?"":`
|
|
40
|
-
`)+N.raw,u.text+=`
|
|
41
|
-
`+N.text,this.inlineQueue.at(-1).src=u.text):y.push(N);continue}if(N=this.tokenizer.fences(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.heading(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.hr(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.blockquote(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.list(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.html(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.def(m)){m=m.substring(N.raw.length);let u=y.at(-1);u?.type==="paragraph"||u?.type==="text"?(u.raw+=(u.raw.endsWith(`
|
|
42
|
-
`)?"":`
|
|
43
|
-
`)+N.raw,u.text+=`
|
|
44
|
-
`+N.raw,this.inlineQueue.at(-1).src=u.text):this.tokens.links[N.tag]||(this.tokens.links[N.tag]={href:N.href,title:N.title},y.push(N));continue}if(N=this.tokenizer.table(m)){m=m.substring(N.raw.length),y.push(N);continue}if(N=this.tokenizer.lheading(m)){m=m.substring(N.raw.length),y.push(N);continue}let $=m;if(this.options.extensions?.startBlock){let u=1/0,X=m.slice(1),J;this.options.extensions.startBlock.forEach((b)=>{J=b.call({lexer:this},X),typeof J=="number"&&J>=0&&(u=Math.min(u,J))}),u<1/0&&u>=0&&($=m.substring(0,u+1))}if(this.state.top&&(N=this.tokenizer.paragraph($))){let u=y.at(-1);w&&u?.type==="paragraph"?(u.raw+=(u.raw.endsWith(`
|
|
45
|
-
`)?"":`
|
|
46
|
-
`)+N.raw,u.text+=`
|
|
47
|
-
`+N.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):y.push(N),w=$.length!==m.length,m=m.substring(N.raw.length);continue}if(N=this.tokenizer.text(m)){m=m.substring(N.raw.length);let u=y.at(-1);u?.type==="text"?(u.raw+=(u.raw.endsWith(`
|
|
48
|
-
`)?"":`
|
|
49
|
-
`)+N.raw,u.text+=`
|
|
50
|
-
`+N.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=u.text):y.push(N);continue}if(m){let u="Infinite loop on byte: "+m.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw Error(u)}}return this.state.top=!0,y}inline(m,y=[]){return this.inlineQueue.push({src:m,tokens:y}),y}inlineTokens(m,y=[]){this.tokenizer.lexer=this;let w=m,N=null;if(this.tokens.links){let J=Object.keys(this.tokens.links);if(J.length>0)for(;(N=this.tokenizer.rules.inline.reflinkSearch.exec(w))!==null;)J.includes(N[0].slice(N[0].lastIndexOf("[")+1,-1))&&(w=w.slice(0,N.index)+"["+"a".repeat(N[0].length-2)+"]"+w.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(N=this.tokenizer.rules.inline.anyPunctuation.exec(w))!==null;)w=w.slice(0,N.index)+"++"+w.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let $;for(;(N=this.tokenizer.rules.inline.blockSkip.exec(w))!==null;)$=N[2]?N[2].length:0,w=w.slice(0,N.index+$)+"["+"a".repeat(N[0].length-$-2)+"]"+w.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);w=this.options.hooks?.emStrongMask?.call({lexer:this},w)??w;let u=!1,X="";for(;m;){u||(X=""),u=!1;let J;if(this.options.extensions?.inline?.some((U)=>(J=U.call({lexer:this},m,y))?(m=m.substring(J.raw.length),y.push(J),!0):!1))continue;if(J=this.tokenizer.escape(m)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.tag(m)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.link(m)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.reflink(m,this.tokens.links)){m=m.substring(J.raw.length);let U=y.at(-1);J.type==="text"&&U?.type==="text"?(U.raw+=J.raw,U.text+=J.text):y.push(J);continue}if(J=this.tokenizer.emStrong(m,w,X)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.codespan(m)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.br(m)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.del(m,w,X)){m=m.substring(J.raw.length),y.push(J);continue}if(J=this.tokenizer.autolink(m)){m=m.substring(J.raw.length),y.push(J);continue}if(!this.state.inLink&&(J=this.tokenizer.url(m))){m=m.substring(J.raw.length),y.push(J);continue}let b=m;if(this.options.extensions?.startInline){let U=1/0,Q=m.slice(1),_;this.options.extensions.startInline.forEach((Y)=>{_=Y.call({lexer:this},Q),typeof _=="number"&&_>=0&&(U=Math.min(U,_))}),U<1/0&&U>=0&&(b=m.substring(0,U+1))}if(J=this.tokenizer.inlineText(b)){m=m.substring(J.raw.length),J.raw.slice(-1)!=="_"&&(X=J.raw.slice(-1)),u=!0;let U=y.at(-1);U?.type==="text"?(U.raw+=J.raw,U.text+=J.text):y.push(J);continue}if(m){let U="Infinite loop on byte: "+m.charCodeAt(0);if(this.options.silent){console.error(U);break}else throw Error(U)}}return y}},dm=class{options;parser;constructor(f){this.options=f||Rf}space(f){return""}code({text:f,lang:m,escaped:y}){let w=(m||"").match(Xf.notSpaceStart)?.[0],N=f.replace(Xf.endingNewline,"")+`
|
|
51
|
-
`;return w?'<pre><code class="language-'+cf(w)+'">'+(y?N:cf(N,!0))+`</code></pre>
|
|
52
|
-
`:"<pre><code>"+(y?N:cf(N,!0))+`</code></pre>
|
|
53
|
-
`}blockquote({tokens:f}){return`<blockquote>
|
|
54
|
-
${this.parser.parse(f)}</blockquote>
|
|
55
|
-
`}html({text:f}){return f}def(f){return""}heading({tokens:f,depth:m}){return`<h${m}>${this.parser.parseInline(f)}</h${m}>
|
|
56
|
-
`}hr(f){return`<hr>
|
|
57
|
-
`}list(f){let{ordered:m,start:y}=f,w="";for(let u=0;u<f.items.length;u++){let X=f.items[u];w+=this.listitem(X)}let N=m?"ol":"ul",$=m&&y!==1?' start="'+y+'"':"";return"<"+N+$+`>
|
|
58
|
-
`+w+"</"+N+`>
|
|
59
|
-
`}listitem(f){return`<li>${this.parser.parse(f.tokens)}</li>
|
|
60
|
-
`}checkbox({checked:f}){return"<input "+(f?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:f}){return`<p>${this.parser.parseInline(f)}</p>
|
|
61
|
-
`}table(f){let m="",y="";for(let N=0;N<f.header.length;N++)y+=this.tablecell(f.header[N]);m+=this.tablerow({text:y});let w="";for(let N=0;N<f.rows.length;N++){let $=f.rows[N];y="";for(let u=0;u<$.length;u++)y+=this.tablecell($[u]);w+=this.tablerow({text:y})}return w&&(w=`<tbody>${w}</tbody>`),`<table>
|
|
62
|
-
<thead>
|
|
63
|
-
`+m+`</thead>
|
|
64
|
-
`+w+`</table>
|
|
65
|
-
`}tablerow({text:f}){return`<tr>
|
|
66
|
-
${f}</tr>
|
|
67
|
-
`}tablecell(f){let m=this.parser.parseInline(f.tokens),y=f.header?"th":"td";return(f.align?`<${y} align="${f.align}">`:`<${y}>`)+m+`</${y}>
|
|
68
|
-
`}strong({tokens:f}){return`<strong>${this.parser.parseInline(f)}</strong>`}em({tokens:f}){return`<em>${this.parser.parseInline(f)}</em>`}codespan({text:f}){return`<code>${cf(f,!0)}</code>`}br(f){return"<br>"}del({tokens:f}){return`<del>${this.parser.parseInline(f)}</del>`}link({href:f,title:m,tokens:y}){let w=this.parser.parseInline(y),N=k1(f);if(N===null)return w;f=N;let $='<a href="'+f+'"';return m&&($+=' title="'+cf(m)+'"'),$+=">"+w+"</a>",$}image({href:f,title:m,text:y,tokens:w}){w&&(y=this.parser.parseInline(w,this.parser.textRenderer));let N=k1(f);if(N===null)return cf(y);f=N;let $=`<img src="${f}" alt="${cf(y)}"`;return m&&($+=` title="${cf(m)}"`),$+=">",$}text(f){return"tokens"in f&&f.tokens?this.parser.parseInline(f.tokens):("escaped"in f)&&f.escaped?f.text:cf(f.text)}},Iy=class{strong({text:f}){return f}em({text:f}){return f}codespan({text:f}){return f}del({text:f}){return f}html({text:f}){return f}text({text:f}){return f}link({text:f}){return""+f}image({text:f}){return""+f}br(){return""}checkbox({raw:f}){return f}},Wf=class f{options;renderer;textRenderer;constructor(m){this.options=m||Rf,this.options.renderer=this.options.renderer||new dm,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Iy}static parse(m,y){return new f(y).parse(m)}static parseInline(m,y){return new f(y).parseInline(m)}parse(m){this.renderer.parser=this;let y="";for(let w=0;w<m.length;w++){let N=m[w];if(this.options.extensions?.renderers?.[N.type]){let u=N,X=this.options.extensions.renderers[u.type].call({parser:this},u);if(X!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){y+=X||"";continue}}let $=N;switch($.type){case"space":{y+=this.renderer.space($);break}case"hr":{y+=this.renderer.hr($);break}case"heading":{y+=this.renderer.heading($);break}case"code":{y+=this.renderer.code($);break}case"table":{y+=this.renderer.table($);break}case"blockquote":{y+=this.renderer.blockquote($);break}case"list":{y+=this.renderer.list($);break}case"checkbox":{y+=this.renderer.checkbox($);break}case"html":{y+=this.renderer.html($);break}case"def":{y+=this.renderer.def($);break}case"paragraph":{y+=this.renderer.paragraph($);break}case"text":{y+=this.renderer.text($);break}default:{let u='Token with "'+$.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw Error(u)}}}return y}parseInline(m,y=this.renderer){this.renderer.parser=this;let w="";for(let N=0;N<m.length;N++){let $=m[N];if(this.options.extensions?.renderers?.[$.type]){let X=this.options.extensions.renderers[$.type].call({parser:this},$);if(X!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes($.type)){w+=X||"";continue}}let u=$;switch(u.type){case"escape":{w+=y.text(u);break}case"html":{w+=y.html(u);break}case"link":{w+=y.link(u);break}case"image":{w+=y.image(u);break}case"checkbox":{w+=y.checkbox(u);break}case"strong":{w+=y.strong(u);break}case"em":{w+=y.em(u);break}case"codespan":{w+=y.codespan(u);break}case"br":{w+=y.br(u);break}case"del":{w+=y.del(u);break}case"text":{w+=y.text(u);break}default:{let X='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(X),"";throw Error(X)}}}return w}},qm=class{options;block;constructor(f){this.options=f||Rf}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(f){return f}postprocess(f){return f}processAllTokens(f){return f}emStrongMask(f){return f}provideLexer(f=this.block){return f?Qf.lex:Qf.lexInline}provideParser(f=this.block){return f?Wf.parse:Wf.parseInline}},a2=class{defaults=hy();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Wf;Renderer=dm;TextRenderer=Iy;Lexer=Qf;Tokenizer=xm;Hooks=qm;constructor(...f){this.use(...f)}walkTokens(f,m){let y=[];for(let w of f)switch(y=y.concat(m.call(this,w)),w.type){case"table":{let N=w;for(let $ of N.header)y=y.concat(this.walkTokens($.tokens,m));for(let $ of N.rows)for(let u of $)y=y.concat(this.walkTokens(u.tokens,m));break}case"list":{let N=w;y=y.concat(this.walkTokens(N.items,m));break}default:{let N=w;this.defaults.extensions?.childTokens?.[N.type]?this.defaults.extensions.childTokens[N.type].forEach(($)=>{let u=N[$].flat(1/0);y=y.concat(this.walkTokens(u,m))}):N.tokens&&(y=y.concat(this.walkTokens(N.tokens,m)))}}return y}use(...f){let m=this.defaults.extensions||{renderers:{},childTokens:{}};return f.forEach((y)=>{let w={...y};if(w.async=this.defaults.async||w.async||!1,y.extensions&&(y.extensions.forEach((N)=>{if(!N.name)throw Error("extension name required");if("renderer"in N){let $=m.renderers[N.name];$?m.renderers[N.name]=function(...u){let X=N.renderer.apply(this,u);return X===!1&&(X=$.apply(this,u)),X}:m.renderers[N.name]=N.renderer}if("tokenizer"in N){if(!N.level||N.level!=="block"&&N.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let $=m[N.level];$?$.unshift(N.tokenizer):m[N.level]=[N.tokenizer],N.start&&(N.level==="block"?m.startBlock?m.startBlock.push(N.start):m.startBlock=[N.start]:N.level==="inline"&&(m.startInline?m.startInline.push(N.start):m.startInline=[N.start]))}"childTokens"in N&&N.childTokens&&(m.childTokens[N.name]=N.childTokens)}),w.extensions=m),y.renderer){let N=this.defaults.renderer||new dm(this.defaults);for(let $ in y.renderer){if(!($ in N))throw Error(`renderer '${$}' does not exist`);if(["options","parser"].includes($))continue;let u=$,X=y.renderer[u],J=N[u];N[u]=(...b)=>{let U=X.apply(N,b);return U===!1&&(U=J.apply(N,b)),U||""}}w.renderer=N}if(y.tokenizer){let N=this.defaults.tokenizer||new xm(this.defaults);for(let $ in y.tokenizer){if(!($ in N))throw Error(`tokenizer '${$}' does not exist`);if(["options","rules","lexer"].includes($))continue;let u=$,X=y.tokenizer[u],J=N[u];N[u]=(...b)=>{let U=X.apply(N,b);return U===!1&&(U=J.apply(N,b)),U}}w.tokenizer=N}if(y.hooks){let N=this.defaults.hooks||new qm;for(let $ in y.hooks){if(!($ in N))throw Error(`hook '${$}' does not exist`);if(["options","block"].includes($))continue;let u=$,X=y.hooks[u],J=N[u];qm.passThroughHooks.has($)?N[u]=(b)=>{if(this.defaults.async&&qm.passThroughHooksRespectAsync.has($))return(async()=>{let Q=await X.call(N,b);return J.call(N,Q)})();let U=X.call(N,b);return J.call(N,U)}:N[u]=(...b)=>{if(this.defaults.async)return(async()=>{let Q=await X.apply(N,b);return Q===!1&&(Q=await J.apply(N,b)),Q})();let U=X.apply(N,b);return U===!1&&(U=J.apply(N,b)),U}}w.hooks=N}if(y.walkTokens){let N=this.defaults.walkTokens,$=y.walkTokens;w.walkTokens=function(u){let X=[];return X.push($.call(this,u)),N&&(X=X.concat(N.call(this,u))),X}}this.defaults={...this.defaults,...w}}),this}setOptions(f){return this.defaults={...this.defaults,...f},this}lexer(f,m){return Qf.lex(f,m??this.defaults)}parser(f,m){return Wf.parse(f,m??this.defaults)}parseMarkdown(f){return(m,y)=>{let w={...y},N={...this.defaults,...w},$=this.onError(!!N.silent,!!N.async);if(this.defaults.async===!0&&w.async===!1)return $(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof m>"u"||m===null)return $(Error("marked(): input parameter is undefined or null"));if(typeof m!="string")return $(Error("marked(): input parameter is of type "+Object.prototype.toString.call(m)+", string expected"));if(N.hooks&&(N.hooks.options=N,N.hooks.block=f),N.async)return(async()=>{let u=N.hooks?await N.hooks.preprocess(m):m,X=await(N.hooks?await N.hooks.provideLexer(f):f?Qf.lex:Qf.lexInline)(u,N),J=N.hooks?await N.hooks.processAllTokens(X):X;N.walkTokens&&await Promise.all(this.walkTokens(J,N.walkTokens));let b=await(N.hooks?await N.hooks.provideParser(f):f?Wf.parse:Wf.parseInline)(J,N);return N.hooks?await N.hooks.postprocess(b):b})().catch($);try{N.hooks&&(m=N.hooks.preprocess(m));let u=(N.hooks?N.hooks.provideLexer(f):f?Qf.lex:Qf.lexInline)(m,N);N.hooks&&(u=N.hooks.processAllTokens(u)),N.walkTokens&&this.walkTokens(u,N.walkTokens);let X=(N.hooks?N.hooks.provideParser(f):f?Wf.parse:Wf.parseInline)(u,N);return N.hooks&&(X=N.hooks.postprocess(X)),X}catch(u){return $(u)}}}onError(f,m){return(y)=>{if(y.message+=`
|
|
69
|
-
Please report this to https://github.com/markedjs/marked.`,f){let w="<p>An error occurred:</p><pre>"+cf(y.message+"",!0)+"</pre>";return m?Promise.resolve(w):w}if(m)return Promise.reject(y);throw y}}},vf=new a2;function I(f,m){return vf.parse(f,m)}I.options=I.setOptions=function(f){return vf.setOptions(f),I.defaults=vf.defaults,g1(I.defaults),I};I.getDefaults=hy;I.defaults=Rf;I.use=function(...f){return vf.use(...f),I.defaults=vf.defaults,g1(I.defaults),I};I.walkTokens=function(f,m){return vf.walkTokens(f,m)};I.parseInline=vf.parseInline;I.Parser=Wf;I.parser=Wf.parse;I.Renderer=dm;I.TextRenderer=Iy;I.Lexer=Qf;I.lexer=Qf.lex;I.Tokenizer=xm;I.Hooks=qm;I.parse=I;var{options:H4,setOptions:K4,use:T4,walkTokens:z4,parseInline:P4}=I;var L4=Wf.parse,B4=Qf.lex;import{useEffect as E1,useMemo as xy,useRef as n2,useState as _m}from"react";import{jsxDEV as mf}from"react/jsx-dev-runtime";function dy({open:f,onClose:m,onSubmit:y,includedRemoteIds:w,onToggleRemoteId:N}){let{annotations:$,generalNote:u,submittableResponses:X,feedbackEntries:J}=Af(),[b,U]=_m(""),[Q,_]=_m(!1),[Y,W]=_m(!1),[F,c]=_m(null),z=n2(null),[S,q]=_m(!1),K=xy(()=>$.filter((r)=>r.source==="remote"),[$]);if(f&&!S)_(!1),W(!1),c(null);if(!f&&S)_(!1),W(!1),c(null);if(f!==S)q(f);let T=xy(()=>tf($,u,X,J,w),[$,u,X,J,w]),A=Q?b:T;if(E1(()=>{if(f&&Y&&z.current)z.current.focus()},[f,Y]),E1(()=>{if(!f)return;let r=(C)=>{if(C.key==="Escape")m()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[f,m]),!f)return null;let O=A.trim().length>0;return mf("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-8",onClick:m,children:mf("div",{className:"bg-bg-surface border border-border-medium rounded-xl shadow-lg w-full max-w-2xl flex flex-col",style:{height:"80vh"},onClick:(r)=>r.stopPropagation(),children:[mf("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border-subtle flex-shrink-0",children:[mf("div",{className:"flex items-center gap-3",children:[mf("span",{className:"text-[13px] font-medium text-text-primary font-body",children:"Response preview"},void 0,!1,void 0,this),Q&&mf("button",{onClick:()=>{_(!1),W(!1)},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body",children:"Reset"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),mf("div",{className:"flex items-center gap-2",children:[mf("div",{className:"flex items-center bg-bg-base rounded-md p-0.5",children:[mf("button",{onClick:()=>W(!1),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${!Y?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Preview"},void 0,!1,void 0,this),mf("button",{onClick:()=>W(!0),className:`px-2.5 py-1 rounded text-[11px] font-body font-medium transition-colors ${Y?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),mf("button",{onClick:m,className:"text-text-tertiary hover:text-text-secondary w-7 h-7 flex items-center justify-center rounded-md hover:bg-border-subtle transition-colors",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y?mf("textarea",{ref:z,value:A,onChange:(r)=>{U(r.currentTarget.value),_(!0)},className:"flex-1 w-full bg-bg-base p-5 text-[13px] font-mono text-text-code resize-none focus:outline-none leading-relaxed placeholder:text-text-disabled",placeholder:"Your feedback will appear here..."},void 0,!1,void 0,this):mf("div",{className:"flex-1 overflow-y-auto p-5",children:mf(im,{text:A},void 0,!1,void 0,this)},void 0,!1,void 0,this),K.length>0&&mf("div",{className:"px-5 py-2 border-t border-border-subtle flex-shrink-0",children:mf("span",{className:"text-[12px] text-text-secondary font-body",children:["Reviewer feedback: ",w.size,"/",K.length," included"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),F&&mf("div",{className:"px-5 py-2 text-[12px] text-accent-red font-body border-t border-border-subtle flex-shrink-0 flex items-center justify-between gap-2",children:[mf("span",{children:F},void 0,!1,void 0,this),mf("button",{onClick:()=>{c(null),y(A)},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body whitespace-nowrap underline",children:"Submit anyway"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),mf("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border-subtle flex-shrink-0",children:[mf("button",{onClick:m,className:"px-4 py-2 rounded-lg text-[13px] font-body text-text-tertiary hover:text-text-secondary transition-colors",children:"Cancel"},void 0,!1,void 0,this),mf("button",{onClick:()=>{let r=sf(X,J);if(r.length>0){c(`Please answer: ${r.join(", ")}`);return}c(null),y(A)},disabled:!O,className:`px-6 py-2 rounded-lg font-body text-[13px] font-medium transition-all ${O?"bg-btn-primary text-btn-primary-text hover:opacity-90":"bg-bg-input text-text-disabled cursor-default"}`,children:"Submit feedback"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var e2=/!\[([^\]]*)\]\((\/tmp\/agent-canvas\/uploads\/([^)]+))\)/g;function fw(f){return f.replace(e2,(m,y,w,N)=>``)}function im({text:f}){let m=xy(()=>I.parse(fw(f),{async:!1}),[f]);return mf("div",{className:"prose-canvas font-body text-body text-text-primary leading-relaxed",dangerouslySetInnerHTML:{__html:m}},void 0,!1,void 0,this)}import{jsxDEV as P,Fragment as Dm}from"react/jsx-dev-runtime";function Em({onSubmit:f,collapseButton:m}){let{isReadOnly:y,selectedRevision:w,currentRevision:N,revisions:$,agentWatching:u}=Vy(ef),X=Vy(mw),J=$.find((_)=>_.revision===w),b=y&&w===N,U=!!J?.feedbackConsumed,Q=J?.label||`Round ${w}`;if(y)return P(Nw,{sessionId:X,revision:w,label:Q,waitingForUpdate:b,feedbackConsumed:U,agentWatching:u,collapseButton:m},void 0,!1,void 0,this);return P($w,{onSubmit:f,agentWatching:u,collapseButton:m},void 0,!1,void 0,this)}function ww({sessionId:f,revision:m,label:y,waitingForUpdate:w,feedbackConsumed:N,agentWatching:$,collapseButton:u}){let J=Hf().isShared;return P("div",{className:"flex flex-col h-full",children:[P("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[P("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body",children:w?"Feedback sent":`Feedback — ${y}`},void 0,!1,void 0,this),u]},void 0,!0,void 0,this),w&&!J&&P(s1,{feedbackConsumed:N,agentWatching:$},void 0,!1,void 0,this),P(o1,{sessionId:f,revision:m},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function s1({feedbackConsumed:f,agentWatching:m}){if(f)return P("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-green-muted flex items-center gap-2 flex-shrink-0",children:[P("span",{className:"w-2 h-2 rounded-full bg-accent-green animate-pulse"},void 0,!1,void 0,this),P("span",{className:"text-[12px] font-body text-accent-green",children:"Feedback received — waiting for next revision..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(m)return P("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-blue-muted flex items-center gap-2 flex-shrink-0",children:[P("span",{className:"w-2 h-2 rounded-full bg-accent-blue animate-pulse"},void 0,!1,void 0,this),P("span",{className:"text-[12px] font-body text-accent-blue",children:"Waiting for agent to pick up feedback..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return P("div",{className:"mx-4 mb-3 px-3 py-2.5 rounded-lg bg-accent-amber-muted flex items-center gap-2 flex-shrink-0",children:[P("span",{className:"w-2 h-2 rounded-full bg-accent-amber"},void 0,!1,void 0,this),P("span",{className:"text-[12px] font-body text-accent-amber",children:"Agent disconnected — tell Claude to check feedback"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Nw({sessionId:f,revision:m,label:y,waitingForUpdate:w,feedbackConsumed:N,agentWatching:$,collapseButton:u}){let{annotations:X,generalNote:J}=Af(),b=X.length>0||J.trim().length>0,[U,Q]=mm("feedback");if(!b)return P(ww,{sessionId:f,revision:m,label:y,waitingForUpdate:w,feedbackConsumed:N,agentWatching:$,collapseButton:u},void 0,!1,void 0,this);return P("div",{className:"flex flex-col h-full",children:[P("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[P("div",{className:"flex items-center gap-1 bg-bg-input rounded-md p-0.5",children:[P("button",{onClick:()=>Q("feedback"),className:`px-2.5 py-1 rounded text-[11px] font-medium font-body transition-colors ${U==="feedback"?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:"Feedback"},void 0,!1,void 0,this),P("button",{onClick:()=>Q("annotations"),className:`px-2.5 py-1 rounded text-[11px] font-medium font-body transition-colors flex items-center gap-1.5 ${U==="annotations"?"bg-bg-elevated text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:["Annotations",P("span",{className:"inline-flex items-center justify-center min-w-[16px] h-[16px] px-1 rounded-full bg-border-subtle text-[10px] font-medium",children:X.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u]},void 0,!0,void 0,this),w&&P(s1,{feedbackConsumed:N,agentWatching:$},void 0,!1,void 0,this),U==="feedback"?P(o1,{sessionId:f,revision:m},void 0,!1,void 0,this):P(Dm,{children:[P("div",{className:"flex-1 overflow-y-auto",children:P(a1,{annotations:X,readOnly:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),J.trim()&&P("div",{className:"border-t border-border-subtle px-4 py-3 flex-shrink-0",children:P("div",{className:"text-[13px] font-body text-text-primary leading-relaxed",children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function o1({sessionId:f,revision:m}){let y=Hf(),[w,N]=mm(null),[$,u]=mm(!0);return t1(()=>{if(u(!0),!y.fsAvailable){N(null),u(!1);return}fetch(`/api/session/${f}/revision/${m}/feedback`).then((X)=>X.json()).then((X)=>{N(X.feedback||null),u(!1)}).catch(()=>{N(null),u(!1)})},[f,m]),P("div",{className:"flex-1 overflow-y-auto px-4",children:$?P("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"Loading..."},void 0,!1,void 0,this):w?P(im,{text:w},void 0,!1,void 0,this):P("p",{className:"text-[12px] text-text-tertiary font-body py-4",children:"No feedback was submitted for this revision."},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function uw(f){let m=f.filter((u)=>u.filePath===Df),y=f.filter((u)=>!u.filePath),w=f.filter((u)=>Mf(u)!==void 0),N={};for(let u of w){let X=Mf(u);if(!X)continue;let J=N[X];if(J)J.push(u);else N[X]=[u]}let $=[m,y,w].filter((u)=>u.length>0).length>1;return{response:m,plan:y,fileGroups:N,hasMultipleGroups:$}}function l1({children:f}){return P("div",{className:"text-[10px] uppercase tracking-widest text-text-tertiary font-body px-3 mb-1 mt-1",children:f},void 0,!1,void 0,this)}function a1({annotations:f,readOnly:m,includedRemoteIds:y,onToggleRemoteId:w}){let{setActiveView:N}=Vy(nf),{response:$,plan:u,fileGroups:X,hasMultipleGroups:J}=uw(f),b=jy((_)=>{let Y=Mf(_);if(!Y)return;N({type:"file",path:Y}),setTimeout(()=>{let W=Um(_);if(W)W.scrollIntoView({behavior:"smooth",block:"center"})},150)},[N]),U=jy((_)=>py(_,N),[N]),Q={readOnly:m,onSelect:b,onReveal:U,includedRemoteIds:y,onToggleRemoteId:w};return P(Dm,{children:[$.length>0&&P(Dm,{children:[J&&P(l1,{children:"Agent Response"},void 0,!1,void 0,this),P(Xm,{annotations:$,...Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.length>0&&P(Dm,{children:[J&&P(l1,{children:"Canvas"},void 0,!1,void 0,this),P(Xm,{annotations:u,...Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Object.entries(X).map(([_,Y])=>P("div",{children:[P("button",{onClick:()=>N({type:"file",path:_}),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-widest text-text-tertiary hover:text-text-secondary font-body px-3 pt-3 pb-1 truncate transition-colors w-full text-left",title:_,children:[P(My,{name:_.split("/").pop()||_,type:"file"},void 0,!1,void 0,this),P("span",{className:"truncate",children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P(Xm,{annotations:Y,...Q},void 0,!1,void 0,this)]},_,!0,void 0,this))]},void 0,!0,void 0,this)}function $w({onSubmit:f,agentWatching:m,collapseButton:y}){let w=Hf(),[N,$]=mm(!1),{annotations:u,generalNote:X,submittableResponses:J,feedbackEntries:b}=Af(),U=yw(()=>u.filter((K)=>K.source==="remote"),[u]),[Q,_]=mm(()=>new Set);t1(()=>{if(U.length===0)return;_((K)=>{let T=new Set(K);for(let A of U)T.add(A.id);return T.size===K.size?K:T})},[U]);let Y=jy((K)=>{_((T)=>{let A=new Set(T);if(A.has(K))A.delete(K);else A.add(K);return A})},[]),W=Array.from(J.values()).some(gm),F=b.size>0,c=u.length>0||X.trim().length>0||W||F,[z,S]=mm(null),q=()=>{let K=tf(u,X,J,b,Q);f(K)};return P("div",{className:"flex flex-col h-full",children:[P("div",{className:"px-4 py-3 flex items-center justify-between flex-shrink-0",children:[P("span",{className:"text-[11px] font-medium uppercase tracking-widest text-text-tertiary font-body flex items-center gap-2",children:["Annotations",u.length>0&&P("span",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-border-subtle text-[10px] font-medium text-text-secondary",children:u.length},void 0,!1,void 0,this),!w.isShared&&P("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${m?"bg-accent-green":"bg-accent-amber"}`,title:m?"Agent connected":"Agent disconnected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y]},void 0,!0,void 0,this),P("div",{className:"flex-1 overflow-y-auto",children:[u.length===0&&P("p",{className:"text-[12px] text-text-tertiary px-3 py-4 leading-relaxed font-body",children:"Select text in the canvas or in files to add annotations."},void 0,!1,void 0,this),P(a1,{annotations:u,includedRemoteIds:Q,onToggleRemoteId:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P(Wy,{hasContent:c,onSubmit:()=>{let K=sf(J,b);if(K.length>0){S(`Please answer: ${K.join(", ")}`);return}S(null),q()},onSubmitEmpty:()=>f("No feedback — looks good."),notice:z&&P("div",{className:"px-4 py-2 text-[12px] text-accent-red font-body border-t border-border-subtle flex-shrink-0 flex items-center justify-between gap-2",children:[P("span",{children:z},void 0,!1,void 0,this),P("button",{onClick:()=>{S(null),q()},className:"text-[11px] text-text-tertiary hover:text-text-secondary font-body whitespace-nowrap underline",children:"Submit anyway"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),secondaryAction:P("button",{onClick:()=>$(!0),className:"flex-1 py-2 rounded-lg font-body text-[13px] font-medium transition-all bg-border-subtle text-text-secondary hover:bg-border-medium hover:text-text-primary",children:"Preview"},void 0,!1,void 0,this)},void 0,!1,void 0,this),P(dy,{open:N,onClose:()=>$(!1),onSubmit:f,includedRemoteIds:Q,onToggleRemoteId:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as ru}from"#canvas/runtime";import w3 from"react";import{jsxDEV as u3}from"react/jsx-dev-runtime";I.setOptions({gfm:!0,breaks:!1});import{jsxDEV as b3}from"react/jsx-dev-runtime";import{jsxDEV as Q3}from"react/jsx-dev-runtime";import{useAnnotations as F3,useResponseRegistration as Z3}from"#canvas/runtime";import{useEffect as T3,useMemo as z3,useRef as P3,useState as L3}from"react";import{jsxDEV as _3}from"react/jsx-dev-runtime";import{jsxDEV as M3}from"react/jsx-dev-runtime";import{useEffect as k3,useRef as A3}from"react";import{jsxDEV as g3}from"react/jsx-dev-runtime";import{jsxDEV as j3}from"react/jsx-dev-runtime";import{ActiveViewCtx as D3,SessionContext as E3}from"#canvas/runtime";import{useContext as s3,useEffect as o3,useRef as a3,useState as n3}from"react";import{jsxDEV as f6}from"react/jsx-dev-runtime";import{SessionContext as w6}from"#canvas/runtime";import{useContext as $6,useState as J6}from"react";import{jsxDEV as b6}from"react/jsx-dev-runtime";import{useMemo as q6}from"react";import{jsxDEV as _6}from"react/jsx-dev-runtime";I.setOptions({gfm:!0,breaks:!1});import{useAnnotations as F6,useCanvasFile as Z6}from"#canvas/runtime";import{useCallback as z6,useEffect as P6,useRef as L6,useState as B6}from"react";import M6 from"react-dom";import{jsxDEV as h6,Fragment as r6}from"react/jsx-dev-runtime";import{jsxDEV as g6}from"react/jsx-dev-runtime";import{jsxDEV as I6}from"react/jsx-dev-runtime";import{useState as V6}from"react";import{jsxDEV as E6}from"react/jsx-dev-runtime";import{jsxDEV as s6}from"react/jsx-dev-runtime";import{jsxDEV as e6}from"react/jsx-dev-runtime";import{useAnnotations as yu,useResponseRegistration as wu}from"#canvas/runtime";import{useRef as Ju,useState as Xu}from"react";import{jsxDEV as Uu}from"react/jsx-dev-runtime";import{CanvasFileCtx as bw,SessionContext as Yw}from"#canvas/runtime";import lm,{useContext as e1,useEffect as Bf,useMemo as cm,useRef as Uw,useState as Sf}from"react";import{createPortal as Qw}from"react-dom";import{createContext as Xw}from"react";var Dy=Xw(()=>{});import{jsxDEV as l,Fragment as _w}from"react/jsx-dev-runtime";class f0 extends lm.Component{state={error:null};static getDerivedStateFromError(f){return{error:f}}componentDidCatch(f,m){this.props.reportError({revision:this.props.revision,filename:this.props.filename,message:f.message,...f.stack?{stack:f.stack}:{},...m.componentStack?{componentStack:m.componentStack}:{}})}render(){if(!this.state.error)return this.props.children;return l(m0,{message:this.state.error.message},void 0,!1,void 0,this)}}function m0({message:f}){return l("div",{className:"bg-accent-red-muted rounded-lg p-5",children:[l("h3",{className:"font-body font-semibold text-accent-red mb-2",children:"Canvas render failed"},void 0,!1,void 0,this),l("pre",{className:"text-code font-mono text-text-secondary whitespace-pre-wrap",children:f},void 0,!1,void 0,this),l("p",{className:"text-meta font-body text-text-tertiary mt-3",children:"The error was sent back to the canvas author."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function tm({revision:f,filename:m}){let y=e1(Yw),w=Hf(),N=e1(Dy),[$,u]=Sf(null),[X,J]=Sf(null),[b,U]=Sf(!0),Q=Uw(null),{annotations:_,addAnnotationWithId:Y,removeAnnotation:W,updateAnnotation:F,addAnnotationImage:c,removeAnnotationImage:z,activeAnnotationId:S,setActiveAnnotationId:q,registerCanvasRendered:K}=Af(),T=cm(()=>_.filter((G)=>!G.filePath&&(!G.canvasFile||G.canvasFile===m)),[_,m]),[A,O]=Sf(null),[r,C]=Sf(null),[g,D]=Sf(null),[o,E]=Sf(null),[Jf,k]=Sf(!1);Bf(()=>{U(!0),J(null),E(null),w.loadCanvasModule(m,f).then((G)=>{u(()=>G.default),U(!1)}).catch((G)=>{let M=G instanceof Error?G:Error(String(G));J(M.message),U(!1),N({revision:f,filename:m,message:M.message,...M.stack?{stack:M.stack}:{}})})},[y,f,m,N]),Bf(()=>{if($)K(m)},[$,m,K]);let V=document.getElementById("plan-scroll-container"),{popovers:i,isPopoverOpen:s}=Ky({containerRef:Q,restoreKey:$,restoreAnnotations:T,extractContext:(G)=>wy(G,Q.current),canvasFile:m,scrollContainer:V}),{popovers:d,isDrawing:L,isPopoverOpen:B}=Zy({containerRef:Q,restoreKey:$,canvasFile:m,scrollContainer:V}),p=s||B,R=cm(()=>{let G=new Map;for(let M of T)if(M.snippet.startsWith("["))G.set(M.snippet,M.id);return G},[T]);Bf(()=>{let G=Q.current;if(!G)return;let M=(H)=>{if(g||p||L)return;let h=H.target;if(h.closest("[data-block-comment-btn]"))return;k(!1);let v=h.closest(Vf);if(v&&G.contains(v)){let Uf=If(G).indexOf(v);E(Uf>=0?Uf:null)}else E(null);let a=h.closest(Tf);if(a&&G.contains(a)){C(a);let yf=_f(a),Uf=yf?R.get(yf):void 0;if(Uf&&Uf!==S)q(Uf)}else C(null)},j=(H)=>{if(g||p)return;if(H.relatedTarget?.closest("[data-block-comment-btn]"))return;C(null),q(null)};return G.addEventListener("mousemove",M),G.addEventListener("mouseleave",j),()=>{G.removeEventListener("mousemove",M),G.removeEventListener("mouseleave",j)}},[$,g,p,L,R,S]),Bf(()=>{let G=(M)=>{let j=M.target.tagName;if(j==="INPUT"||j==="TEXTAREA"||M.target.isContentEditable)return;if(g||p)return;let H=Q.current;if(!H)return;if(M.key==="ArrowDown"){M.preventDefault(),k(!0);let h=If(H);if(h.length===0)return;E((v)=>{if(v===null)return 0;return Math.min(v+1,h.length-1)})}else if(M.key==="ArrowUp"){M.preventDefault(),k(!0);let h=If(H);if(h.length===0)return;E((v)=>{if(v===null)return h.length-1;return Math.max(v-1,0)})}else if(M.key==="a"||M.key==="A"){if(o===null||!H)return;let v=If(H)[o];if(!v)return;if(!v.matches(Tf))return;M.preventDefault();let a=_f(v);if(!a)return;let yf=R.get(a);if(yf)q(yf),D({anchorEl:v,snippet:a,annId:yf});else D({anchorEl:v,snippet:a})}else if(M.key===" "||M.key==="Enter"){if(o===null)return;let v=If(H)[o];if(!v)return;let a=v.getAttribute("data-md");if(a==="choice-option"||a==="multichoice-option")M.preventDefault(),v.dispatchEvent(new CustomEvent("kb-select",{bubbles:!0}));else if(a==="userinput"){M.preventDefault();let yf=v.querySelector("textarea");if(yf){yf.focus();let Uf=(pf)=>{if(pf.key==="Escape")pf.preventDefault(),yf.blur(),k(!0)};yf.addEventListener("keydown",Uf),yf.addEventListener("blur",()=>yf.removeEventListener("keydown",Uf),{once:!0})}}else if(a==="rangeinput"){M.preventDefault();let yf=v.querySelector("input[type='range']");if(yf){yf.focus();let Uf=(pf)=>{if(pf.key==="Escape"||pf.key==="ArrowUp"||pf.key==="ArrowDown")pf.preventDefault(),yf.blur(),k(!0)};yf.addEventListener("keydown",Uf),yf.addEventListener("blur",()=>yf.removeEventListener("keydown",Uf),{once:!0})}}}else if(M.key==="Escape")E(null),k(!1),q(null)};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[o,g,p,R]),Bf(()=>{let G=Q.current;if(!G||o===null||!Jf)return;let j=If(G)[o];if(!j)return;j.style.outline="2px solid var(--color-accent-blue)",j.style.outlineOffset="-2px",j.style.borderRadius="8px",j.scrollIntoView({block:"nearest",behavior:"smooth"});let H=_f(j),h=H?R.get(H):void 0;if(h)q(h);return()=>{j.style.outline="",j.style.outlineOffset="",j.style.borderRadius=""}},[o,Jf,R]);let e=cm(()=>$?l($,{},void 0,!1,void 0,this):null,[$]);if(b)return l("div",{className:"flex items-center justify-center h-64 text-text-tertiary font-body text-body",children:"Loading canvas..."},void 0,!1,void 0,this);if(X)return l(m0,{message:X},void 0,!1,void 0,this);if(!$)return l("div",{className:"text-text-tertiary text-center py-8 font-body text-body",children:"No canvas loaded"},void 0,!1,void 0,this);return l(bw.Provider,{value:m,children:[l("div",{ref:Q,className:"plan-content plan-updated","data-canvas-file":m,children:l(f0,{revision:f,filename:m,reportError:N,children:e},`${f}:${m}`,!1,void 0,this)},void 0,!1,void 0,this),A&&l(Gw,{note:A.note,onSave:(G)=>{F(A.id,G),O(null)},onCancel:()=>O(null)},void 0,!1,void 0,this),i,d,l(Ww,{containerRef:Q,hoveredBlock:r,focusedBlockIndex:o,blockPopover:g,blockAnnotationMap:R,activeAnnotationId:S,onOpen:(G,M,j)=>{if(j)q(j),D({anchorEl:G,snippet:M,annId:j});else D({anchorEl:G,snippet:M})}},void 0,!1,void 0,this),g&&!g.annId&&l(Lf,{anchorEl:g.anchorEl,scrollContainer:V,snippet:g.snippet,truncateAt:80,onAdd:(G,M)=>{let j=Ff();Y(j,g.snippet,G,void 0,void 0,M,m),D(null)},onCancel:()=>D(null)},void 0,!1,void 0,this),g?.annId&&(()=>{let G=T.find((M)=>M.id===g.annId);if(!G)return null;return l(Ym,{anchorEl:g.anchorEl,scrollContainer:V,initialNote:G.note,initialImages:G.images,onUpdate:(M,j)=>{F(g.annId,M);let H=G.images||[];for(let h of j)if(!H.includes(h))c(g.annId,h);for(let h of H)if(!j.includes(h))z(g.annId,h)},onDelete:()=>{W(g.annId),q(null),D(null)},onClose:()=>D(null)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)}function If(f){return Array.from(f.querySelectorAll(Vf))}function Ww({containerRef:f,hoveredBlock:m,focusedBlockIndex:y,blockPopover:w,blockAnnotationMap:N,activeAnnotationId:$,onOpen:u}){let[X,J]=Sf([]);Bf(()=>{let Y=f.current;if(!Y||N.size===0){J([]);return}let W=[];for(let F of Y.querySelectorAll(Tf)){let c=_f(F);if(c&&N.has(c))W.push(F)}J(W)},[N,f.current]);let[b,U]=Sf(null);Bf(()=>{if(!$||!f.current){U(null);return}for(let Y of f.current.querySelectorAll(Vf)){let W=_f(Y);if(W&&N.get(W)===$){U(Y);return}}U(null)},[$,N]),Bf(()=>{if(!b)return;return b.style.boxShadow="inset 0 0 0 1.5px var(--color-highlight-bg)",b.style.borderRadius="8px",()=>{b.style.boxShadow="",b.style.borderRadius=""}},[b]);let Q=cm(()=>{if(y===null||!f.current)return null;let Y=If(f.current)[y];if(!Y)return null;return Y.matches(Tf)?Y:null},[y,f.current]),_=cm(()=>{let Y=new Set(X);if(m)Y.add(m);if(Q)Y.add(Q);if(w?.anchorEl)Y.add(w.anchorEl);return Array.from(Y)},[X,m,Q,w]);return l(_w,{children:_.map((Y)=>l(qw,{block:Y,isHovered:Y===m||Y===Q||Y===w?.anchorEl,blockAnnotationMap:N,activeAnnotationId:$,onOpen:u},Y.getAttribute("data-task-id")||Y.getAttribute("data-md-title")||Y.textContent?.slice(0,30)||"block",!1,void 0,this))},void 0,!1,void 0,this)}function qw({block:f,isHovered:m,blockAnnotationMap:y,activeAnnotationId:w,onOpen:N}){let $=_f(f);if(!$)return null;let u=y.get($),X=!!u;return Qw(l("button",{"data-block-comment-btn":!0,onClick:(b)=>{b.stopPropagation(),N(b.currentTarget,$,u)},className:`absolute top-1 right-1 z-10 w-6 h-6 flex items-center justify-center rounded transition-all duration-150 ${X?u===w?"text-accent-amber bg-accent-amber-muted":"text-accent-amber opacity-60 hover:opacity-100":m?"text-text-disabled hover:text-text-tertiary opacity-50 hover:opacity-100":"text-text-disabled opacity-0 group-hover/section:opacity-20 hover:!opacity-80"}`,title:X?"Edit annotation":"Add annotation",children:l("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:X?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),f)}function Gw({note:f,onSave:m,onCancel:y}){let[w,N]=lm.useState(f),$=lm.useRef(null);return lm.useEffect(()=>{$.current?.focus(),$.current?.select()},[]),l("div",{className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center",onClick:y,children:l("div",{className:"bg-bg-elevated border border-border-hover rounded-lg shadow-md p-4 w-80",onClick:(u)=>u.stopPropagation(),children:[l("div",{className:"text-tiny uppercase tracking-widest text-text-tertiary font-body mb-2",children:"Edit annotation"},void 0,!1,void 0,this),l("textarea",{ref:$,value:w,onChange:(u)=>N(u.currentTarget.value),className:"w-full bg-transparent border-none text-body font-body text-text-primary resize-vertical focus:outline-none min-h-[60px]",onKeyDown:(u)=>{if(u.key==="Enter"&&(u.ctrlKey||u.metaKey))m(w.trim());if(u.key==="Escape")y()}},void 0,!1,void 0,this),l("div",{className:"flex justify-end gap-2 mt-2",children:[l("button",{onClick:y,className:"text-meta text-text-tertiary font-body px-3 py-1",children:"Cancel"},void 0,!1,void 0,this),l("button",{onClick:()=>m(w.trim()),className:"text-meta font-medium font-body px-3 py-1 rounded-md bg-highlight-bg text-text-primary border border-highlight-border",children:"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as bf,Fragment as ly}from"react/jsx-dev-runtime";function y0({gateName:f,hasGate:m,isCurrentGate:y,onSubmit:w}){let[N,$]=Kw(!0);if(!N)return bf("button",{onClick:()=>$(!0),className:"flex w-9 flex-col items-center gap-2 border-l border-border-subtle bg-bg-surface py-3 text-text-tertiary hover:text-text-secondary",title:"Open review panel",children:bf("span",{className:"[writing-mode:vertical-rl] text-tiny uppercase tracking-wide",children:"review"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let u=bf("button",{onClick:()=>$(!1),className:"text-text-tertiary hover:text-text-secondary",title:"Collapse",children:bf("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:bf("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return bf("aside",{className:"flex h-full w-72 flex-col border-l border-border-subtle bg-bg-surface",children:m?bf(Em,{onSubmit:w,collapseButton:u},void 0,!1,void 0,this):bf(ly,{children:[bf("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[bf("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"review & annotate"},void 0,!1,void 0,this),u]},void 0,!0,void 0,this),bf("div",{className:"flex-1 px-4 py-6 text-center text-tiny text-text-tertiary",children:y&&f?bf(ly,{children:["gate ",bf("span",{className:"font-mono",children:f},void 0,!1,void 0,this)," open — connect to a live daemon to review the pushed canvas."]},void 0,!0,void 0,this):f?bf(ly,{children:["this phase's ",bf("span",{className:"font-mono",children:f},void 0,!1,void 0,this)," gate opens once the earlier phases are approved."]},void 0,!0,void 0,this):"no gate on this phase — nothing to review here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as Kf}from"react/jsx-dev-runtime";var Tw={connecting:"connecting…",live:"live",offline:"offline",fixture:"fixture"},zw={connecting:"bg-accent-amber",live:"bg-accent-green",offline:"bg-accent-red",fixture:"bg-accent-blue"};function w0({sessionId:f,status:m,watching:y}){return Kf("header",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border-subtle bg-bg-surface px-4",children:[Kf("div",{className:"flex items-center gap-2 text-body text-text-secondary",children:[Kf("span",{className:"text-text-tertiary",children:"session"},void 0,!1,void 0,this),Kf("span",{className:"rounded bg-bg-elevated px-2 py-0.5 font-mono text-code text-text-primary",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Kf("div",{className:"flex items-center gap-4",children:[y&&Kf("span",{className:"flex items-center gap-1.5 text-tiny text-text-tertiary",children:[Kf("span",{className:"inline-flex h-1.5 w-1.5 animate-pulse rounded-full bg-accent-blue"},void 0,!1,void 0,this),"agent watching"]},void 0,!0,void 0,this),Kf("span",{className:"flex items-center gap-1.5 text-tiny text-text-secondary",children:[Kf("span",{className:`inline-flex h-2 w-2 rounded-full ${zw[m]}`},void 0,!1,void 0,this),Tw[m]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Sm=[{id:"intake",title:"Intake",reads:"init brief, supplied untrusted docs (spotlight)",produces:"intent/brief.md",gate:!0},{id:"vision",title:"Vision + scope + principles",reads:"intent/brief.md",produces:"intent/glossary.md, principles/principles.md",gate:!0},{id:"flows",title:"User flows",reads:"intent/*, principles/*",produces:"architecture/flows/*.flow.md",gate:!0},{id:"tech",title:"Tech + scaffold decision",reads:"architecture/flows/*, stack",produces:"architecture/tech.md",gate:!0},{id:"design",title:"Design tokens + mockups",reads:"architecture/flows/*, architecture/tech.md",produces:"architecture/design.md, pages/*.jsx",gate:!0},{id:"skeletons",title:"Opice skeletons",reads:"architecture/flows/*, architecture/spec/*",produces:"tests/browser/*.test.ts (outside .fabrika)",gate:!0},{id:"issues",title:"Induce issues",reads:"tests/browser/* metadata, named-seeds decision",produces:"issues/ISSUE-*.md",gate:!1},{id:"build",title:"Build (agent-assisted)",reads:"issues/*, tests/browser/*",produces:"green bun test per issue",gate:!0}],sm=Sm.length;function N0(f){return Sm.findIndex((m)=>m.id===f)}function u0(f){return Sm.find((m)=>m.id===f)}function Fm(f,m,y){if(m.includes(f))return"done";if(f===y)return"current";return"upcoming"}import{jsxDEV as n}from"react/jsx-dev-runtime";function Pw({status:f}){if(f==="done")return n("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-accent-green-muted text-accent-green",children:n("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:n("path",{d:"M2.5 6.2L4.8 8.5L9.5 3.5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(f==="current")return n("span",{className:"relative flex h-5 w-5 items-center justify-center",children:[n("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent-amber opacity-40"},void 0,!1,void 0,this),n("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-accent-amber"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return n("span",{className:"flex h-5 w-5 items-center justify-center rounded-full border border-border-medium"},void 0,!1,void 0,this)}function $0({state:f,focused:m,onFocus:y}){return n("nav",{className:"flex h-full flex-col border-r border-border-subtle bg-bg-surface",children:[n("div",{className:"border-b border-border-subtle px-4 py-3",children:[n("div",{className:"font-heading text-xl text-text-primary",children:"fabrika"},void 0,!1,void 0,this),n("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"guided app build"},void 0,!1,void 0,this),n("p",{className:"mt-2 text-tiny leading-snug text-text-tertiary",children:"8 phases from brief to build. Each ends in a review gate — click a phase to see its canvas."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),n("ol",{className:"flex-1 overflow-y-auto py-2",children:Sm.map((w,N)=>{let $=Fm(w.id,f.completed,f.current),u=m===w.id,X=$!=="upcoming";return n("li",{children:n("button",{disabled:!X,onClick:()=>X&&y(w.id),className:["group flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors",u?"bg-bg-elevated":"hover:bg-bg-elevated-half",X?"cursor-pointer":"cursor-not-allowed opacity-55"].join(" "),children:[n("div",{className:"mt-0.5 shrink-0",children:n(Pw,{status:$},void 0,!1,void 0,this)},void 0,!1,void 0,this),n("div",{className:"min-w-0",children:[n("div",{className:"flex items-center gap-1.5",children:[n("span",{className:"text-tiny tabular-nums text-text-tertiary",children:[N+1,"/",sm]},void 0,!0,void 0,this),w.gate&&n("span",{title:"canvas gate",className:"rounded bg-badge-bg px-1 text-[10px] uppercase tracking-wide text-accent-amber",children:"gate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),n("div",{className:["truncate text-task-label",$==="current"?"font-semibold text-text-primary":$==="done"?"text-text-secondary":"text-text-tertiary"].join(" "),children:w.title},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},w.id,!1,void 0,this)})},void 0,!1,void 0,this),n("div",{className:"border-t border-border-subtle px-4 py-2 text-tiny text-text-tertiary",children:["phase derived from ",n("span",{className:"font-mono",children:"GET /api/phase"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as gw,useState as X0}from"react";function uf(f){return typeof f==="object"&&f!==null&&!Array.isArray(f)}function om(f){return f!==null}function Zm(f){if(!Array.isArray(f)||!f.every((m)=>typeof m==="string"))return null;return f}function Yf(f){return typeof f==="string"?f:void 0}function Lw(f){if(!uf(f)||typeof f.added!=="number"||typeof f.removed!=="number")return;return{added:f.added,removed:f.removed}}function ty(f){if(!Array.isArray(f))return[];return f.map((m)=>{if(typeof m==="string")return{filename:m};if(!uf(m)||typeof m.filename!=="string")return null;let y=Yf(m.label),w=Lw(m.diffStats);return{filename:m.filename,...y===void 0?{}:{label:y},...w===void 0?{}:{diffStats:w}}}).filter(om).filter((m)=>m.filename.length>0)}function Bw(f){if(!Array.isArray(f))return[];return f.map((m)=>{if(!uf(m)||typeof m.revision!=="number")return null;let y=m.canvasScope,w;if(uf(y)&&y.kind==="directory")w={kind:"directory"};else if(uf(y)&&y.kind==="view"&&typeof y.filename==="string")w={kind:"view",filename:y.filename};let N=Yf(m.label),$=Yf(m.createdAt);return{revision:m.revision,label:N??null,canvasFiles:ty(m.canvasFiles),hasFeedback:m.hasFeedback===!0,feedbackConsumed:m.feedbackConsumed===!0,...$===void 0?{}:{createdAt:$},...w===void 0?{}:{canvasScope:w}}}).filter(om).filter((m)=>m.revision>0)}var pw=["intake","vision","flows","tech","design","skeletons","issues","build"];function J0(f){return typeof f==="string"&&pw.some((m)=>m===f)}function Mw(f){if(!uf(f)||!J0(f.current)||typeof f.index!=="number")throw Error("Invalid phase response");let m=f.completed,y=Array.isArray(m)?m.filter(J0):[],w=Zm(f.reads),N=Zm(f.produces);if(!Array.isArray(m)||y.length!==m.length||w===null||N===null)throw Error("Invalid phase response");if(typeof f.gate!=="boolean"||typeof f.satisfied!=="boolean")throw Error("Invalid phase response");let $=f.gateName===null?null:Yf(f.gateName);return{current:f.current,index:f.index,completed:y,reads:w,produces:N,gate:f.gate,satisfied:f.satisfied,...$===void 0?{}:{gateName:$}}}function Ow(f){if(!uf(f)||typeof f.id!=="string")return null;let m=Yf(f.label);return{id:f.id,...m===void 0?{}:{label:m}}}function hw(f){if(!uf(f)||typeof f.file!=="string"||typeof f.name!=="string")return null;let m=Zm(f.seeds),y=Zm(f.roles);if(m===null||y===null||typeof f.steps!=="number"||typeof f.invariants!=="number")return null;if(typeof f.pending!=="number")return null;let w=Yf(f.url),N=Yf(f.feature);return{file:f.file,name:f.name,seeds:m,roles:y,steps:f.steps,invariants:f.invariants,pending:f.pending,...w===void 0?{}:{url:w},...N===void 0?{}:{feature:N}}}function rw(f){if(!uf(f)||typeof f.type!=="string")return null;switch(f.type){case"plan-updated":{if(typeof f.currentRevision!=="number")return null;let m=Array.isArray(f.canvasFiles)?f.canvasFiles:void 0,y=f.gate===null?null:Yf(f.gate);return{type:"plan-updated",currentRevision:f.currentRevision,...m===void 0?{}:{canvasFiles:ty(m)},...y===void 0?{}:{gate:y}}}case"revision-updated":return typeof f.currentRevision==="number"?{type:"revision-updated",currentRevision:f.currentRevision}:null;case"watcher-status":return typeof f.watching==="boolean"?{type:"watcher-status",watching:f.watching}:null;case"phase-updated":return{type:"phase-updated"};case"submit-ack":return typeof f.revision==="number"?{type:"submit-ack",revision:f.revision}:null;default:return null}}function kw(f){return f==="queued"||f==="running"||f==="passed"||f==="failed"||f==="blocked"||f==="info"}function Aw(f){if(!uf(f)||!kw(f.status))return null;let m=Yf(f.issue),y=Yf(f.message),w=Yf(f.at),N=uf(f.data)?f.data:void 0;return{status:f.status,...m===void 0?{}:{issue:m},...y===void 0?{}:{message:y},...w===void 0?{}:{at:w},...N===void 0?{}:{data:N}}}function xf(){return new URLSearchParams(location.search).get("daemon")??location.origin}function sy(){return location.pathname.match(/\/s\/([^/]+)/)?.[1]??null}function Cw(){return new URLSearchParams(location.search).get("root")}async function ym(f){let m=await fetch(xf()+f,{headers:{accept:"application/json"}});if(!m.ok)throw Error(`${f} -> ${m.status}`);return m.json()}var $f={async health(){let f=await ym("/health");if(!uf(f)||f.ok!==!0)throw Error("Invalid health response");let m=Yf(f.version),y=Zm(f.sessions);return{ok:!0,...m===void 0?{}:{version:m},...y===null?{}:{sessions:y}}},async phase(f){let m=f??Cw(),y=sy(),w=new URLSearchParams;if(m)w.set("root",m);if(y)w.set("session",y);let N=w.toString();return Mw(await ym(`/api/phase${N?`?${N}`:""}`))},async meta(f){let m=await ym(`/api/session/${encodeURIComponent(f)}/meta`);if(!uf(m))throw Error("Invalid session response");let y=Yf(m.projectRoot),w=Yf(m.label),N=m.gate===null?null:Yf(m.gate);return{id:f,...y===void 0?{}:{projectRoot:y},currentRevision:typeof m.currentRevision==="number"?m.currentRevision:0,canvasFiles:ty(m.canvasFiles),revisions:Bw(m.revisions),gate:N??null,...w===void 0?{}:{label:w}}},async artifact(f,m){try{let y=await fetch(`${xf()}/api/session/${encodeURIComponent(f)}/artifact?path=${encodeURIComponent(m)}`,{headers:{accept:"application/json"}});if(!y.ok)return null;let w=await y.json();return uf(w)&&typeof w.content==="string"?w.content:null}catch{return null}},async sessions(){let f=await ym("/api/sessions");return Array.isArray(f)?f.map(Ow).filter(om):[]},canvasUrl(f,m,y){let w=y!=null?`?rev=${y}`:"";return`${xf()}/api/session/${encodeURIComponent(f)}/canvas/${encodeURIComponent(m)}${w}`},async skeletons(f){let m=await ym(`/api/session/${encodeURIComponent(f)}/skeletons`);if(!uf(m)||!Array.isArray(m.skeletons))return[];return m.skeletons.map(hw).filter(om)},async feedback(f,m){let y=await fetch(`${xf()}/api/session/${encodeURIComponent(f)}/revision/${m}/feedback`);if(!y.ok)throw Error(`feedback -> ${y.status}`);return y.text()},async getResponses(f,m,y){try{let w=await ym(`/api/session/${encodeURIComponent(f)}/revision/${m}/responses`);if(!uf(w))return null;let N=w.responses;return y(N)?N:null}catch{return null}},async saveResponses(f,m,y){try{await fetch(`${xf()}/api/session/${encodeURIComponent(f)}/revision/${m}/responses`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(y)})}catch{}},openSocket(f,m){let y=location.protocol==="https:"?"wss:":"ws:",w=xf().replace(/^https?:/,y),N=new WebSocket(`${w}/ws/session/${encodeURIComponent(f)}`);return N.onmessage=($)=>{try{let u=rw(JSON.parse(String($.data)));if(u!==null)m(u)}catch{}},N},submitGate(f,m){if(f.readyState===WebSocket.OPEN)return f.send(JSON.stringify({type:"submit",feedback:m})),!0;return!1},buildStream(f){try{let m=new EventSource(`${xf()}/api/build/stream`);return m.onmessage=(y)=>{try{let w=Aw(JSON.parse(y.data));if(w!==null)f(w)}catch{}},m}catch{return null}}};import{jsxDEV as t,Fragment as am}from"react/jsx-dev-runtime";var vw=".fabrika/architecture/design.md",Rw=".fabrika/pages/_preview.html",oy=`:root{
|
|
70
|
-
--color-brand:#6f4e37; --color-brand-strong:#573c2a;
|
|
71
|
-
--color-surface:#fbf7f0; --color-surface-sunken:#f1e9dd;
|
|
72
|
-
--color-text:#2a1e16; --color-muted:#8a7866; --color-accent:#c8853a;
|
|
73
|
-
--color-border:#e7dccd; --color-on-brand:#fbf7f0;
|
|
74
|
-
--space-gutter:16px; --radius-card:12px;
|
|
75
|
-
--font-heading:"Instrument Serif",Georgia,serif;
|
|
76
|
-
--font-body:system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
77
|
-
}`;function Iw(f){if(!f)return oy;let m=f.match(/:root\s*\{[^}]*\}/);return m?m[0]:oy}function xw(f){return`<!DOCTYPE html>
|
|
78
|
-
<html lang="cs">
|
|
79
|
-
<head>
|
|
80
|
-
<meta charset="utf-8" />
|
|
81
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
82
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
83
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
84
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Instrument+Serif&display=swap" />
|
|
85
|
-
<style>
|
|
86
|
-
${f}
|
|
87
|
-
* { box-sizing: border-box; margin: 0; }
|
|
88
|
-
html, body { height: 100%; }
|
|
89
|
-
body {
|
|
90
|
-
background: var(--color-surface);
|
|
91
|
-
color: var(--color-text);
|
|
92
|
-
font-family: var(--font-body);
|
|
93
|
-
padding: 14px 16px;
|
|
94
|
-
display: flex; justify-content: center; align-items: flex-start;
|
|
95
|
-
-webkit-font-smoothing: antialiased;
|
|
96
|
-
}
|
|
97
|
-
.screen { width: 100%; max-width: 340px; }
|
|
98
|
-
.brand {
|
|
99
|
-
display: flex; align-items: center; gap: 8px;
|
|
100
|
-
font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
|
|
101
|
-
color: var(--color-muted); margin-bottom: 8px;
|
|
102
|
-
}
|
|
103
|
-
.brand .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--color-brand); }
|
|
104
|
-
h1 {
|
|
105
|
-
font-family: var(--font-heading);
|
|
106
|
-
font-weight: 400; font-size: 26px; line-height: 1.1;
|
|
107
|
-
margin-bottom: 2px;
|
|
108
|
-
}
|
|
109
|
-
.sub { color: var(--color-muted); font-size: 13px; margin-bottom: 12px; }
|
|
110
|
-
.card {
|
|
111
|
-
background: #fff;
|
|
112
|
-
border: 1px solid var(--color-border);
|
|
113
|
-
border-radius: var(--radius-card);
|
|
114
|
-
padding: var(--space-gutter);
|
|
115
|
-
box-shadow: 0 1px 2px rgba(42,30,22,.04);
|
|
116
|
-
}
|
|
117
|
-
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; }
|
|
118
|
-
.row + .row { border-top: 1px solid var(--color-border); }
|
|
119
|
-
.row .name { font-size: 14px; }
|
|
120
|
-
.row .qty { color: var(--color-muted); font-size: 12px; margin-left: 6px; }
|
|
121
|
-
.row .price { color: var(--color-accent); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
|
|
122
|
-
.total { margin-top: 4px; padding-top: 12px; border-top: 2px solid var(--color-border); }
|
|
123
|
-
.total .name { font-weight: 600; font-size: 15px; }
|
|
124
|
-
.total .price { font-size: 17px; }
|
|
125
|
-
.field { margin-top: 14px; }
|
|
126
|
-
.field label { display: block; font-size: 12px; color: var(--color-muted); margin-bottom: 6px; }
|
|
127
|
-
.field input {
|
|
128
|
-
width: 100%; padding: 10px 12px;
|
|
129
|
-
border: 1px solid var(--color-border); border-radius: var(--radius-card);
|
|
130
|
-
font-size: 14px; font-family: inherit; color: var(--color-text); background: #fff;
|
|
131
|
-
}
|
|
132
|
-
.field input::placeholder { color: var(--color-muted); opacity: .7; }
|
|
133
|
-
.cta {
|
|
134
|
-
width: 100%; margin-top: 14px; padding: 12px 16px;
|
|
135
|
-
background: var(--color-brand); color: var(--color-on-brand);
|
|
136
|
-
border: none; border-radius: var(--radius-card);
|
|
137
|
-
font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
|
|
138
|
-
}
|
|
139
|
-
.cta:hover { background: var(--color-brand-strong); }
|
|
140
|
-
.pickup {
|
|
141
|
-
display: flex; align-items: center; gap: 7px; justify-content: center;
|
|
142
|
-
margin-top: 12px; font-size: 12px; color: var(--color-muted);
|
|
143
|
-
}
|
|
144
|
-
.pickup .pill { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }
|
|
145
|
-
</style>
|
|
146
|
-
</head>
|
|
147
|
-
<body>
|
|
148
|
-
<div className="screen">
|
|
149
|
-
<div className="brand"><span className="dot"></span> Kávovar</div>
|
|
150
|
-
<h1>Tvoje objednávka</h1>
|
|
151
|
-
<div className="sub">2 položky · vyzvednutí na pobočce</div>
|
|
152
|
-
<div className="card">
|
|
153
|
-
<div className="row"><div><span className="name">Flat white</span><span className="qty">×1</span></div><span className="price">62 Kč</span></div>
|
|
154
|
-
<div className="row"><div><span className="name">Croissant</span><span className="qty">×2</span></div><span className="price">98 Kč</span></div>
|
|
155
|
-
<div className="row total"><span className="name">Celkem</span><span className="price">160 Kč</span></div>
|
|
156
|
-
<div className="field">
|
|
157
|
-
<label for="name">Jméno pro vyzvednutí</label>
|
|
158
|
-
<input id="name" placeholder="např. Matěj" />
|
|
159
|
-
</div>
|
|
160
|
-
<button className="cta">Potvrdit objednávku</button>
|
|
161
|
-
<div className="pickup"><span className="pill"></span> Připraveno k vyzvednutí ~ 8 min</div>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
</body>
|
|
165
|
-
</html>`}function dw(f,m){let y=`<style>${m}</style>`,w=f.indexOf("<head>");if(w!==-1)return f.slice(0,w+6)+y+f.slice(w+6);return`${y}${f}`}function b0({url:f,children:m}){return t("div",{className:"flex h-full flex-col overflow-hidden rounded-md border border-border-medium bg-bg-base",children:[t("div",{className:"flex items-center gap-1.5 border-b border-border-subtle bg-bg-elevated px-3 py-2",children:[t("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-red/60"},void 0,!1,void 0,this),t("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-amber/60"},void 0,!1,void 0,this),t("span",{className:"h-2.5 w-2.5 rounded-full bg-accent-green/60"},void 0,!1,void 0,this),t("span",{className:"ml-2 truncate font-mono text-tiny text-text-tertiary",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m]},void 0,!0,void 0,this)}function jw({sessionId:f,live:m}){let[y,w]=X0(oy),[N,$]=X0(null);gw(()=>{if(!m)return;let J=!1;return $f.artifact(f,vw).then((b)=>{if(!J)w(Iw(b))}),$f.artifact(f,Rw).then((b)=>{if(!J)$(b&&b.trim()?b:null)}).catch(()=>{}),()=>{J=!0}},[f,m]);let u=N!==null,X=u?dw(N,y):xw(y);return t(am,{children:[t(b0,{url:u?"pages/_preview.html":"pages/checkout.jsx",children:t("iframe",{srcDoc:X,className:"min-h-0 flex-1 bg-white",title:"screen mockup",sandbox:"allow-same-origin"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:u?t(am,{children:["Primary screen mockup (",t("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this),"), themed live by"," ",t("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens."]},void 0,!0,void 0,this):t(am,{children:["Built-in demo screen, themed live by ",t("span",{className:"font-mono",children:"architecture/design.md"},void 0,!1,void 0,this)," tokens — drop a"," ",t("span",{className:"font-mono",children:"pages/_preview.html"},void 0,!1,void 0,this)," to preview your own."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vw(){return t(am,{children:[t(b0,{url:"http://localhost:5173",children:t("iframe",{src:"http://localhost:5173",className:"min-h-0 flex-1 bg-white",title:"running app"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("p",{className:"mt-2 px-0.5 text-tiny text-text-tertiary",children:"The real app once an issue is in flight (localhost:5173). The element→source tagger lands here next."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Y0({phase:f,sessionId:m,live:y}){return t("aside",{className:"flex h-full flex-col border-l border-border-subtle bg-bg-surface",children:[t("div",{className:"flex items-center justify-between border-b border-border-subtle px-4 py-3",children:[t("div",{className:"text-tiny uppercase tracking-wide text-text-tertiary",children:"live preview"},void 0,!1,void 0,this),t("span",{className:"rounded bg-bg-elevated px-2 py-0.5 text-tiny text-text-secondary",children:f==="build"?"app":"mockup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:f==="build"?t(Vw,{},void 0,!1,void 0,this):t(jw,{sessionId:m,live:y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as Q0,useState as W0}from"react";import{jsxDEV as qf}from"react/jsx-dev-runtime";function nm(f){let m=[],y=/(`[^`]+`|\*\*[^*]+\*\*)/g,w=0,N,$=0;while(N=y.exec(f)){if(N.index>w)m.push(f.slice(w,N.index));let u=N[0];if(u.startsWith("`"))m.push(qf("code",{className:"rounded bg-bg-code px-1 py-0.5 font-mono text-code text-text-code",children:u.slice(1,-1)},$++,!1,void 0,this));else m.push(qf("strong",{className:"font-semibold text-text-primary",children:u.slice(2,-2)},$++,!1,void 0,this));w=N.index+u.length}if(w<f.length)m.push(f.slice(w));return m}function U0({source:f}){let m=f.split(`
|
|
166
|
-
`),y=[],w=0,N=0;while(w<m.length){let $=m[w];if($.startsWith("```")){let X=[];w++;while(w<m.length&&!m[w].startsWith("```"))X.push(m[w++]);w++,y.push(qf("pre",{className:"my-3 overflow-auto rounded-md border border-border-subtle bg-bg-code p-3 font-mono text-code text-text-code",children:qf("code",{children:X.join(`
|
|
167
|
-
`)},void 0,!1,void 0,this)},N++,!1,void 0,this));continue}let u=$.match(/^(#{1,4})\s+(.*)$/);if(u){let X=u[1].length,J=X===1?"mt-2 mb-3 font-heading text-section text-text-primary":X===2?"mt-5 mb-2 font-heading text-xl text-text-primary":"mt-4 mb-1 text-task-label font-semibold text-text-secondary uppercase tracking-wide";y.push(qf("div",{className:J,children:nm(u[2])},N++,!1,void 0,this)),w++;continue}if(/^[-*]\s+/.test($)){let X=[];while(w<m.length&&/^[-*]\s+/.test(m[w]))X.push(m[w].replace(/^[-*]\s+/,"")),w++;y.push(qf("ul",{className:"my-2 list-disc space-y-1 pl-5 text-body text-text-secondary",children:X.map((J,b)=>qf("li",{children:nm(J)},b,!1,void 0,this))},N++,!1,void 0,this));continue}if(/^\d+\.\s+/.test($)){let X=[];while(w<m.length&&/^\d+\.\s+/.test(m[w]))X.push(m[w].replace(/^\d+\.\s+/,"")),w++;y.push(qf("ol",{className:"my-2 list-decimal space-y-1 pl-5 text-body text-text-secondary",children:X.map((J,b)=>qf("li",{children:nm(J)},b,!1,void 0,this))},N++,!1,void 0,this));continue}if($.trim()===""){w++;continue}y.push(qf("p",{className:"my-2 text-body leading-relaxed text-text-secondary",children:nm($)},N++,!1,void 0,this)),w++}return qf("div",{className:"select-text",children:y},void 0,!1,void 0,this)}import{jsxDEV as Z,Fragment as G0}from"react/jsx-dev-runtime";function iw({state:f,focused:m,isCurrentGate:y}){let w=u0(m),N=N0(m),$=Fm(m,f.completed,f.current),u=$==="current",X=u&&f.reads.length?f.reads.join(", "):w.reads,J=u&&f.produces.length?f.produces.join(", "):w.produces;return Z("div",{className:"border-b border-border-subtle px-6 py-4",children:[Z("div",{className:"flex items-center gap-3",children:[Z("h1",{className:"font-heading text-section text-text-primary",children:["Phase ",N+1,"/",sm," — ",w.title]},void 0,!0,void 0,this),Z("span",{className:["rounded px-2 py-0.5 text-tiny uppercase tracking-wide",$==="done"?"bg-accent-green-muted text-accent-green":$==="current"?"bg-accent-amber-muted text-accent-amber":"border border-border-medium text-text-tertiary"].join(" "),children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z("dl",{className:"mt-3 grid grid-cols-[5rem_1fr] gap-x-3 gap-y-1.5 text-body",children:[Z("dt",{className:"text-text-tertiary",children:"Read"},void 0,!1,void 0,this),Z("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:X},void 0,!1,void 0,this),Z("dt",{className:"text-text-tertiary",children:"Goal"},void 0,!1,void 0,this),Z("dd",{className:"min-w-0 break-words text-text-secondary",children:J},void 0,!1,void 0,this),Z("dt",{className:"text-text-tertiary",children:"Gate"},void 0,!1,void 0,this),Z("dd",{className:"min-w-0 break-words font-mono text-code text-text-secondary",children:w.gate?Z(G0,{children:["fabrika builder gate open ",m," --view view.jsx && fabrika builder gate wait"]},void 0,!0,void 0,this):Z("span",{className:"text-text-tertiary",children:"— (ungated compile step)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y&&Z("div",{className:"mt-3 flex items-start gap-2 rounded-md bg-accent-amber-muted/60 px-3 py-2 text-tiny text-accent-amber",children:[Z("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",className:"mt-px shrink-0",children:Z("path",{d:"M12 9v4m0 4h.01M10.3 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.7 3.86a2 2 0 0 0-3.42 0Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z("span",{children:[Z("strong",{className:"font-semibold",children:"Gate open."},void 0,!1,void 0,this)," Review the canvas — select text or hover a block to annotate, answer the choices, then"," ",Z("strong",{className:"font-semibold",children:"Submit"},void 0,!1,void 0,this)," in the panel on the right. That feedback is what"," ",Z("span",{className:"font-mono",children:"fabrika builder gate wait"},void 0,!1,void 0,this)," hands back to the active agent."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Dw({sessionId:f,live:m,upcoming:y}){let[w,N]=W0(null);Q0(()=>{if(!m)return;let u=!1;return $f.skeletons(f).then((X)=>{if(!u)N(X)}),()=>{u=!0}},[f,m]);let $=w??[];return Z("div",{className:"p-6",children:[y&&Z("p",{className:"mb-4 text-body text-text-tertiary",children:["Not reached yet — once the design gate is approved, this phase turns each user flow into an opice ",Z("span",{className:"font-mono",children:"*.test.ts"},void 0,!1,void 0,this)," ","skeleton (the acceptance contract), reviewed here as a grid."]},void 0,!0,void 0,this),m&&$.length===0&&Z("p",{className:"text-body text-text-tertiary",children:["No skeletons in ",Z("span",{className:"font-mono",children:"tests/browser/"},void 0,!1,void 0,this)," yet. Author them with the ",Z("span",{className:"font-mono",children:"opice-plan"},void 0,!1,void 0,this)," ","skill, then ",Z("span",{className:"font-mono",children:"fabrika builder induce"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),Z("div",{className:"grid grid-cols-2 gap-3",children:$.map((u)=>Z("div",{className:"rounded-md border border-border-subtle bg-bg-surface p-4 transition-colors hover:border-border-hover",children:[Z("div",{className:"font-mono text-code text-text-primary",children:u.file},void 0,!1,void 0,this),Z("div",{className:"mt-1 truncate text-body text-text-secondary",children:u.name},void 0,!1,void 0,this),Z("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-tiny text-text-tertiary",children:[u.url&&Z("span",{className:"font-mono",children:u.url},void 0,!1,void 0,this),Z("span",{children:[u.steps," steps"]},void 0,!0,void 0,this),Z("span",{children:[u.invariants," invariants"]},void 0,!0,void 0,this),u.pending>0?Z("span",{className:"text-accent-amber",children:[u.pending," pending"]},void 0,!0,void 0,this):Z("span",{className:"text-accent-green",children:"authored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(u.seeds.length>0||u.roles.length>0)&&Z("div",{className:"mt-2 flex flex-wrap gap-1",children:[u.seeds.map((X)=>Z("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["seed:",X]},X,!0,void 0,this)),u.roles.map((X)=>Z("span",{className:"rounded bg-bg-elevated px-1.5 py-0.5 text-tiny text-text-secondary",children:["role:",X]},X,!0,void 0,this))]},void 0,!0,void 0,this)]},u.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ew({live:f}){let[m,y]=W0([]);Q0(()=>{if(!f)return;let N=$f.buildStream(($)=>y((u)=>[...u.slice(-200),$]));return()=>N?.close()},[f]);let w={queued:"bg-text-tertiary",running:"bg-accent-blue",passed:"bg-accent-green",failed:"bg-accent-red",blocked:"bg-accent-amber",info:"bg-text-tertiary"};return Z("div",{className:"p-6",children:[Z("h2",{className:"mb-3 font-heading text-section text-text-primary",children:"Build"},void 0,!1,void 0,this),m.length===0?Z("p",{className:"text-body text-text-tertiary",children:["Waiting for build events. Run ",Z("span",{className:"font-mono",children:"fabrika builder build"},void 0,!1,void 0,this)," to drive the per-issue pipeline; each"," ",Z("span",{className:"font-mono",children:"build done/block"},void 0,!1,void 0,this)," posts here."]},void 0,!0,void 0,this):Z("ul",{className:"space-y-1.5 font-mono text-code",children:m.map((N,$)=>Z("li",{className:"flex items-center gap-2",children:[Z("span",{className:`inline-flex h-2 w-2 shrink-0 rounded-full ${w[N.status]}`},void 0,!1,void 0,this),N.issue&&Z("span",{className:"text-text-secondary",children:N.issue},void 0,!1,void 0,this),Z("span",{className:"text-text-tertiary",children:N.status},void 0,!1,void 0,this),N.message&&Z("span",{className:"truncate text-text-secondary",children:["— ",N.message]},void 0,!0,void 0,this)]},$,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lw({canvas:f}){return Z(G0,{children:f.files.map((m)=>Z("div",{className:"mb-8",children:[f.files.length>1&&Z("div",{className:"mb-2 text-tiny uppercase tracking-wide text-text-tertiary",children:m.label??m.filename},void 0,!1,void 0,this),Z(tm,{revision:f.revision,filename:m.filename},void 0,!1,void 0,this)]},m.filename,!0,void 0,this))},void 0,!1,void 0,this)}function q0({state:f,focused:m,canvas:y,artifact:w,isCurrentGate:N,sessionId:$,live:u}){let J=Fm(m,f.completed,f.current)==="upcoming";return Z("section",{className:"flex h-full min-w-0 flex-col bg-bg-base",children:[Z(iw,{state:f,focused:m,isCurrentGate:N},void 0,!1,void 0,this),Z("div",{id:"plan-scroll-container",className:"flex-1 overflow-y-auto",children:y?Z("div",{className:"mx-auto max-w-3xl px-6 py-5",children:Z(lw,{canvas:y},void 0,!1,void 0,this)},void 0,!1,void 0,this):m==="skeletons"?Z(Dw,{sessionId:$,live:u,upcoming:J},void 0,!1,void 0,this):m==="build"?Z(Ew,{live:u},void 0,!1,void 0,this):Z("div",{className:"mx-auto max-w-3xl px-6 py-5",children:[J&&Z("p",{className:"mb-4 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-tiny text-text-tertiary",children:"This phase hasn't started yet — it unlocks once the earlier gates are approved. Here's what it will produce:"},void 0,!1,void 0,this),Z(U0,{source:w},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _0(f){if(!f)return[];if(f.canvasScope?.kind==="view"){let y=f.canvasScope.filename;return f.canvasFiles.filter((w)=>w.filename===y)}if(f.canvasScope?.kind==="directory")return f.canvasFiles;let m=f.canvasFiles.filter((y)=>!y.diffStats||y.diffStats.added!==0||y.diffStats.removed!==0);return m.length>0?m:f.canvasFiles}var c0="fixture-session",ay={current:"design",index:4,completed:["intake","vision","flows","tech"],reads:[".fabrika/architecture/flows/checkout.flow.md",".fabrika/architecture/flows/browse.flow.md",".fabrika/architecture/tech.md"],produces:[".fabrika/architecture/design.md",".fabrika/pages/*.jsx"],gate:!0,satisfied:!1},S0={id:"fixture-session",currentRevision:5,canvasFiles:[{filename:"checkout-mockup.jsx",label:"Checkout mockup"},{filename:"design-tokens.jsx",label:"Design tokens"}],revisions:[{revision:1,label:"intake",canvasFiles:[{filename:"intake.jsx"}]},{revision:2,label:"vision",canvasFiles:[{filename:"vision.jsx"}]},{revision:3,label:"flows",canvasFiles:[{filename:"flows.jsx"}]},{revision:4,label:"tech",canvasFiles:[{filename:"tech.jsx"}]},{revision:5,label:"design",canvasFiles:[{filename:"checkout-mockup.jsx"},{filename:"design-tokens.jsx"}]}],gate:"design",label:"Design tokens + mockups"};var F0={intake:`# Brief
|
|
168
|
-
|
|
169
|
-
A local-first storefront for a small roastery. Sells whole-bean coffee, supports a cart and checkout, and a lightweight admin to manage the catalog.
|
|
170
|
-
|
|
171
|
-
## Users
|
|
172
|
-
- Shopper — browses, adds to cart, checks out.
|
|
173
|
-
- Owner — manages products and reviews orders.
|
|
174
|
-
|
|
175
|
-
## Success
|
|
176
|
-
- A shopper can complete a purchase end-to-end.
|
|
177
|
-
- The owner can add a product without touching code.
|
|
178
|
-
|
|
179
|
-
## Non-goals
|
|
180
|
-
- No multi-tenant. No payment provider integration in v1 (mock checkout).`,vision:`# Glossary
|
|
181
|
-
|
|
182
|
-
- **Product** — a single SKU with a price and inventory count.
|
|
183
|
-
- **Cart** — the shopper's pending selection, persisted locally.
|
|
184
|
-
- **Order** — a submitted cart, immutable once placed.
|
|
185
|
-
|
|
186
|
-
# Principles
|
|
187
|
-
|
|
188
|
-
- MUST keep the catalog readable without an account.
|
|
189
|
-
- MUST persist the cart across reloads.
|
|
190
|
-
- MUST NOT block checkout on network for the mock flow.
|
|
191
|
-
- PREFERENCE: optimistic UI on add-to-cart.`,flows:`# Flow: checkout
|
|
192
|
-
|
|
193
|
-
1. Shopper opens \`/cart\`.
|
|
194
|
-
2. Reviews line items, adjusts quantities.
|
|
195
|
-
3. Submits → \`/order/confirmation\`.
|
|
196
|
-
|
|
197
|
-
# Flow: browse
|
|
198
|
-
|
|
199
|
-
1. Shopper lands on \`/\`.
|
|
200
|
-
2. Filters by roast level.
|
|
201
|
-
3. Opens a product → adds to cart.`,tech:`# Tech
|
|
202
|
-
|
|
203
|
-
Stack: **cf-lightweight** (lopata + oblaka + vite/react).
|
|
204
|
-
|
|
205
|
-
- Routes via the cf-lightweight stack conventions.
|
|
206
|
-
- Data layer: D1 + seed infra from skeleton metadata.
|
|
207
|
-
- Reasoning: matches the team's deployment target; opice harness wires in cleanly.`,design:"# Design tokens\n\nSemantic layer → Tailwind/CSS vars.\n\n- `--surface` → warm off-black\n- `--accent` → roast amber\n- `--text` → bone\n\nMockups: `pages/checkout.jsx`, `pages/product.jsx`. See the live-preview pane → it renders the kernel-compiled JSX with these tokens applied.",skeletons:"# Opice skeletons\n\nOne `*.test.ts` per flow, each a metadata-first `browserTest` with pending `step{intent,hint}` stubs and `invariant.todo` acceptances. Reviewed as a grid in the workspace.",issues:`# Issues (induced)
|
|
208
|
-
|
|
209
|
-
Deterministic compile step — issues induced from skeleton metadata.
|
|
210
|
-
|
|
211
|
-
- ISSUE-001 Foundation: routes + seed infra.
|
|
212
|
-
- ISSUE-002 Feature: cart + checkout vertical slice.`,build:`# Build
|
|
213
|
-
|
|
214
|
-
Per-issue assisted pipeline. The live-preview pane (right) will host the real running app (localhost:5173) once an issue is in flight.`};import{jsxDEV as Gf}from"react/jsx-dev-runtime";function K0(f){return typeof f==="object"&&f!==null&&!Array.isArray(f)}function f1(f,m){return K0(f)&&m.every((y)=>typeof f[y]==="string")}function tw(f){return Array.isArray(f)&&f.length===2&&typeof f[0]==="string"&&f1(f[1],["id","type","label"])}function sw(f){return Array.isArray(f)&&f.length===2&&typeof f[0]==="string"&&f1(f[1],["id","markdown"])}function ow(f){if(!K0(f)||typeof f.generalNote!=="string")return!1;if(!Array.isArray(f.annotations)||!f.annotations.every((y)=>f1(y,["id","snippet","note","createdAt"])))return!1;if(!Array.isArray(f.responses)||!f.responses.every(tw))return!1;let m=f.feedbackEntries;return m===void 0||Array.isArray(m)&&m.every(sw)}function aw(f){return f==="design"||f==="build"}var H0={current:"intake",index:0,completed:[],reads:[],produces:[],gate:!1,satisfied:!1},nw="_Nový projekt — zatím žádný krok. Otevři první gate z agenta._";function T0(){let f=sy()??c0,[m,y]=df("connecting"),[w,N]=df(H0),[$,u]=df(null),[X,J]=df(!1),[b,U]=df(H0.current),[Q,_]=df(!1),Y=ey(!1),W=ey(null),F=ey(void 0);Z0(()=>{let L=!1;return(async()=>{try{if(await $f.health(),L)return;let B=await $f.meta(f).catch(()=>null);if(L)return;if(B)u(B),F.current=B.projectRoot?`${B.projectRoot}/.fabrika`:void 0;let p=await $f.phase(F.current).catch(()=>null);if(L)return;if(p){if(N(p),!Y.current)U(p.current)}y("live")}catch{if(!L){if(u(S0),N(ay),!Y.current)U(ay.current);y("fixture")}}})(),()=>{L=!0}},[f]),Z0(()=>{if(m!=="live")return;let L=!1,B=null,p=()=>{$f.meta(f).then((e)=>u(e)).catch(()=>{}),$f.phase(F.current).then((e)=>{if(N(e),!Y.current)U(e.current)}).catch(()=>{})},R=()=>{let e=$f.openSocket(f,(G)=>{if(G.type==="plan-updated"||G.type==="revision-updated")_(!1),p();else if(G.type==="watcher-status")J(G.watching);else if(G.type==="phase-updated")_(!1),p();else if(G.type==="submit-ack")_(!1),p()});W.current=e,e.onopen=()=>y("live"),e.onclose=()=>{if(L)return;y("offline"),B=setTimeout(R,2000)}};return R(),()=>{if(L=!0,B)clearTimeout(B);W.current?.close(),W.current=null}},[m,f]);let[c,z]=df({type:"overview"}),S=(L)=>{Y.current=!0,U(L)},q=(L)=>{let B=W.current;if(B&&$f.submitGate(B,L))_(!0)},K=m==="live",T=ny(()=>{if(!$)return null;for(let L=$.revisions.length-1;L>=0;L--)if($.revisions[L].label===b)return $.revisions[L];return null},[$,b]),A=w.gateName??$?.gate??null,O=K&&b===w.current&&!!A,r=ny(()=>{return _0(T)},[T]),C=K&&!!T&&r.length>0,g=T?.revision??$?.currentRevision??0,D=$?.currentRevision??0,o=O&&!!T?.hasFeedback&&!T?.feedbackConsumed,Jf=!O||O&&(Q||o),k=m==="fixture"?F0[b]??"_No artifact for this phase yet._":nw,V=ny(()=>($?.revisions??[]).map((L)=>({revision:L.revision,label:L.label??void 0,canvasFiles:L.canvasFiles.map((B)=>({filename:B.filename})),createdAt:L.createdAt??new Date().toISOString(),hasFeedback:!!L.hasFeedback,feedbackConsumed:!!L.feedbackConsumed})),[$]),i=aw(b),d=Gf("div",{className:`grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] ${i?"grid-cols-[14rem_minmax(0,1fr)_22rem_auto]":"grid-cols-[14rem_minmax(0,1fr)_auto]"}`,children:[Gf($0,{state:w,focused:b,onFocus:S},void 0,!1,void 0,this),Gf(q0,{state:w,focused:b,canvas:C?{revision:g,files:r}:null,artifact:k,isCurrentGate:O,sessionId:f,live:K},void 0,!1,void 0,this),i&&Gf(Y0,{phase:b,sessionId:f,live:K},void 0,!1,void 0,this),Gf(y0,{gateName:A,hasGate:C,isCurrentGate:O,onSubmit:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return Gf("div",{className:"flex h-screen w-screen flex-col overflow-hidden bg-bg-base text-text-primary",children:[Gf(w0,{sessionId:f,status:m,watching:X},void 0,!1,void 0,this),C?Gf(Ey.Provider,{value:f,children:Gf(ef.Provider,{value:{currentRevision:D,selectedRevision:g,revisions:V,setSelectedRevision:()=>{},isReadOnly:Jf,compareRevision:null,setCompareRevision:()=>{},agentWatching:X},children:Gf(nf.Provider,{value:{activeView:c,setActiveView:z,openFiles:[],closeFile:()=>{},canvasFiles:r.map((L)=>L.filename)},children:Gf(vm,{sessionId:f,revision:g,isReadOnly:Jf,draftPhase:"current",loadState:(L,B)=>$f.getResponses(L,B,ow),saveState:(L,B,p)=>{$f.saveResponses(L,B,p)},children:d},g,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this):d]},void 0,!0,void 0,this)}import{jsxDEV as f5}from"react/jsx-dev-runtime";var z0=document.getElementById("root");if(z0===null)throw Error("Builder dashboard root element is missing");ew(z0).render(f5(T0,{},void 0,!1,void 0,this));
|