@farero-ai/ui 0.0.0-stage → 0.4.1
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/LICENSE +21 -0
- package/README.md +150 -2
- package/dist/activity/orrery.d.ts +6 -0
- package/dist/activity/orrery.js +1 -0
- package/dist/activity.css +2 -0
- package/dist/activity.d.ts +10 -0
- package/dist/activity.js +1 -0
- package/dist/chunks/ActivityGlyph-tlf4hwl8.d.ts +44 -0
- package/dist/chunks/DataTable-GR4HPUOJ.js +1 -0
- package/dist/chunks/IsolatedPreview-HJ6B36KF.js +1 -0
- package/dist/chunks/MathEquation-7ZVYQFEK.js +1 -0
- package/dist/chunks/chunk-3I4YBQX6.js +1 -0
- package/dist/chunks/chunk-5SBKMKFB.js +1 -0
- package/dist/chunks/chunk-756GM57N.js +1 -0
- package/dist/chunks/chunk-CMWS5PI4.js +2 -0
- package/dist/chunks/chunk-CXEEHWHD.js +3 -0
- package/dist/chunks/chunk-E7KN7CHM.js +5 -0
- package/dist/chunks/chunk-FW2QVWXL.js +1 -0
- package/dist/chunks/chunk-HGN4GN2E.js +1 -0
- package/dist/chunks/chunk-ITKN2ASJ.js +1 -0
- package/dist/chunks/chunk-LHMFMBHY.js +2 -0
- package/dist/chunks/chunk-LNOXROHT.js +1 -0
- package/dist/chunks/chunk-ONVWTQLU.js +1 -0
- package/dist/chunks/chunk-RR7BB4EQ.js +2 -0
- package/dist/chunks/chunk-RWFARXSG.js +1 -0
- package/dist/chunks/chunk-S3DX6DGB.js +1 -0
- package/dist/chunks/chunk-T3JXEXIJ.js +1 -0
- package/dist/chunks/chunk-UNO25KYE.js +1 -0
- package/dist/chunks/chunk-WMKRKKIS.js +1 -0
- package/dist/chunks/chunk-WQZ3EUKA.js +1 -0
- package/dist/chunks/chunk-YPRVAH5G.js +1 -0
- package/dist/chunks/chunk-Z3Z6LSG4.js +2 -0
- package/dist/chunks/chunk-ZVJQ5X63.js +2 -0
- package/dist/chunks/d2-S4ICDZEQ.js +1 -0
- package/dist/chunks/download-K6ZKYCHG.js +1 -0
- package/dist/chunks/mermaid-CQ4QMBLA.js +7 -0
- package/dist/chunks/readonly-components-1cDZu8D0.d.ts +26 -0
- package/dist/cn.d.ts +5 -0
- package/dist/cn.js +1 -0
- package/dist/code.d.ts +44 -0
- package/dist/code.js +1 -0
- package/dist/commands.d.ts +159 -0
- package/dist/commands.js +1 -0
- package/dist/controls.d.ts +233 -0
- package/dist/controls.js +1 -0
- package/dist/diagram.d.ts +83 -0
- package/dist/diagram.js +1 -0
- package/dist/fence.d.ts +41 -0
- package/dist/fence.js +1 -0
- package/dist/icons.d.ts +18 -0
- package/dist/icons.js +1 -0
- package/dist/markdown.d.ts +133 -0
- package/dist/markdown.js +1 -0
- package/dist/styles.css +2 -0
- package/dist/table.d.ts +41 -0
- package/dist/table.js +1 -0
- package/dist/theme.d.ts +4 -0
- package/dist/theme.js +1 -0
- package/dist/transcript.d.ts +849 -0
- package/dist/transcript.js +17 -0
- package/package.json +91 -4
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as n}from"./chunk-3I4YBQX6.js";import{z as f}from"zod";var O=f.object({sessionId:f.string().min(1),workspaceId:f.string().min(1),title:f.string(),through:f.number().int().positive().optional(),entryId:f.string().optional()}),C=f.object({version:f.literal(1),kind:f.enum(["fork","continue","reference"]),scope:f.enum(["chat","reply"]),sources:f.array(O).min(1)});function S(e){let t=[];for(let r of e.matchAll(/^<farero-chat-handoff>\n([^\n]+)\n[\s\S]*?^<\/farero-chat-handoff>/gm))try{let s=C.safeParse(JSON.parse(r[1]));if(!s.success)continue;t.push({handoff:s.data,token:r[0],start:r.index,end:r.index+r[0].length})}catch{}return t}n(S,"chatHandoffTokens");function I(e){let t=S(e),r=e;for(let s of[...t].reverse()){let i=r.slice(0,s.start).replace(/\n{1,2}$/,""),c=r.slice(s.end).replace(/^\n{1,2}/,"");r=i&&c?`${i}
|
|
2
|
+
|
|
3
|
+
${c}`:i+c}return{handoffs:t,text:r}}n(I,"splitChatHandoffs");function v(e){let t=e.sources.at(-1),r=new URLSearchParams({session:t.sessionId,source:t.sessionId,handoff:e.scope});return t.entryId&&r.set("entry",t.entryId),`/w/${encodeURIComponent(t.workspaceId)}?${r}`}n(v,"chatHandoffHref");var P=["AskUserQuestion","question","request_user_input","request_user_input_async","functions.request_user_input","functions.request_user_input_async","item/tool/requestUserInput","codex/request_user_input_async"],Y=new Set(P.map(e=>e.toLowerCase().replace(/[_-]/g,"")));var M=1,Ge=`<farero-workflow-private version="${M}">`;function L(e){let t=/^\s*(me|agent)\s*:\s*([\s\S]*)$/i.exec(e);return t?{scope:t[1].toLowerCase(),text:t[2]}:{scope:null,text:e}}n(L,"parseSearchOperator");function Xe(e){let{text:t}=L(e);return t.toLowerCase().match(/[\p{L}\p{N}_]+/gu)??[]}n(Xe,"queryTokens");function Qe(e,t){let r=e.toLowerCase(),s=[...new Set(t.map(a=>a.toLowerCase()).filter(Boolean))];if(!s.length)return null;let i=s.map(a=>{let l=[];for(let d=0;d<=r.length-a.length;){let p=r.indexOf(a,d);if(p<0)break;l.push(p),d=p+1}return l});if(i.some(a=>!a.length))return null;let c=Number.POSITIVE_INFINITY;for(let a of i[0]){let l=a+s[0].length,d=0,p=!0;for(let g=1;g<s.length;g++){let _=i[g].find(T=>T>=l);if(_==null){p=!1;break}d+=_-l,l=_+s[g].length}p&&(c=Math.min(c,d))}if(Number.isFinite(c))return c;let o=i.flatMap((a,l)=>a.map(d=>({start:d,end:d+s[l].length,token:l}))).sort((a,l)=>a.start-l.start||a.end-l.end),u=new Array(s.length).fill(0),h=0,b=0,m=Number.POSITIVE_INFINITY;for(let a=0;a<o.length;a++){let l=o[a];for(u[l.token]++===0&&h++;h===s.length;){let d=0;for(let g=b;g<=a;g++)d=Math.max(d,o[g].end);m=Math.min(m,d-o[b].start);let p=o[b++];--u[p.token]===0&&h--}}let k=s.reduce((a,l)=>a+l.length,0);return 1e9+Math.max(0,m-k)}n(Qe,"textMatchRank");function Ye(e){let t=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(e);return Date.parse(t?`${e.replace(" ","T")}Z`:e)}n(Ye,"timestampMs");var E=".context/attachments/",Je=25*1024*1024;function N(e){return/^(?:[A-Za-z0-9]{6}|native_[a-f0-9]{64}|workflow_[a-f0-9]{40})$/.test(e)}n(N,"isAttachmentId");function Ze(e){let t=[],r=0;for(;r<e.length;){let s=e.indexOf("@\u27E6",r);if(s<0)break;let i=e.indexOf("\u27E7(",s+2);if(i<0||/[\r\n]/.test(e.slice(s,i))){r=s+2;continue}let c=e.slice(s+2,i),o=i+2,u=o,h=!1;for(;!h&&(u=e.indexOf(")",u),!(u<0));){let b=e.slice(o,u);try{let m=decodeURIComponent(b),k=m.startsWith(E)?m.slice(E.length):"",a=k.indexOf("/"),l=a<0?"":k.slice(0,a),d=a<0?"":k.slice(a+1);if(N(l)&&d===c&&!d.includes("/")){t.push({start:s,end:u+1,name:c,path:m}),r=u+1,h=!0;continue}}catch{}u+=1}h||(r=s+2)}return t}n(Ze,"attachmentTokens");var D=new Set([".avif",".gif",".jpeg",".jpg",".png",".webp"]);function F(e){let t=e.split(/[\\/]/).pop()??"",r=t.lastIndexOf(".");return r===-1?null:t.slice(r).toLowerCase()}n(F,"fileExtension");function et(e){let t=F(e);return t!==null&&D.has(t)}n(et,"isPreviewableImage");var x="Skill",w=["farero_host","farero","native"],$=new Set(["plugin_guide","plugin_prepare","plugin_run","plugin_status","workspace_overview","search_chats","read_chat","list_voice_calls","search_voice_calls","read_voice_call","list_workspaces","list_chats","list_roles","get_role","update_roles","update_workflows","delegate_task","cancel_delegation","ask_delegation_question","answer_delegation_question","list_delegations","workspace_diff","list_repos","plan_usage","create_workspace","create_chat","send_prompt","render_ui","create_tab","split","stop_turn","close_chat","rename_chat","list_models","set_default_model","set_agent_options","set_workspace_status","create_workspace_status","rename_workspace_status","delete_workspace_status","reorder_workspace_statuses","pin_workspace","set_workspace_webhooks","rename_workspace","dev_server","continue_workspace","archive_workspace","unarchive_workspace","dismiss_prompt","keep_awake","relay_logs","request_mcp_sign_in"]),U={read:"Read",edit:"Edit",multiedit:"MultiEdit",write:"Write",grep:"Grep",glob:"Glob",ls:"LS",list:"LS",bash:"Bash",websearch:"WebSearch",webfetch:"WebFetch",agent:"Agent",task:"Agent",subagent:"Agent",skill:x,todowrite:"TodoWrite",todoread:"TodoRead",question:"AskUserQuestion",askuserquestion:"AskUserQuestion",toolsearch:"ToolSearch",notebookedit:"NotebookEdit"};function tt(e,t=""){let r=n((o,u)=>({name:o?`mcp__${o}__${u}`:`mcp__${u}`,label:u,server:o}),"mcp"),s=n(o=>w.includes(o)?"farero_host":o,"host");if(e.startsWith("mcp__")){let o=e.slice(5).split("__");return o.length>1&&o.every(Boolean)?r(s(o.slice(0,-1).join("__")),o.at(-1)):{name:e,label:e,server:null}}if(e==="mcpToolCall"){let o=t&&t!==e?t:"";return o?r($.has(o)?"farero_host":null,o):{name:e,label:e,server:null}}for(let o of w){let u=e[o.length];if(e.startsWith(o)&&(u==="_"||u===".")&&e.length>o.length+1)return r("farero_host",e.slice(o.length+1))}let i=e.toLowerCase().replace(/[_-]/g,""),c=i.endsWith("spawnagent")?"Agent":U[i];return{name:c??e,label:c??e,server:null}}n(tt,"toolIdentity");function nt(e){return e.role==="tool"&&e.tool===x}n(nt,"isSkillUse");function rt(e){let t=e;for(let r=0;r<3;r++){let s=/^(?:\S+\/)?(zsh|bash|sh|dash|ksh|fish)\s+-l?c\s+([\s\S]+)$/.exec(t.trim());if(!s)return t.trim()||e;let i=s[2].trim();if(i.length>=2){let c=i[0],o=i[i.length-1];(c==='"'&&o==='"'||c==="'"&&o==="'")&&(i=i.slice(1,-1).trim())}if(!i)return e;t=i}return t.trim()||e}n(rt,"unwrapShellCommand");var W=/^(?:\s*<(command-name|command-message|command-args|local-command-stdout|local-command-stderr|local-command-caveat)>[\s\S]*?<\/\1>\s*)+$/;function ot(e){return!!e&&W.test(e.trim())}n(ot,"isLocalCommandNoise");var q=/^(Delegated|Workflow) (\S+) task (\S+) (completed|failed)/m,H="For earlier investigation, use read_chat(";function st(e){return e.role!=="user"?!1:e.id.startsWith("return-")&&!e.id.includes("-retry")?!0:(e.id.startsWith("workflow_")||e.id.startsWith("return-"))&&q.test(e.text)&&e.text.includes(H)}n(st,"isDelegationReturnEntry");function it(e){return e.origin==="agent"}n(it,"isAgentAuthored");var V="[Automatic retry] ";function at(e){return e.role==="user"&&e.id.includes("-retry")&&e.text.startsWith(V)}n(at,"isAutomaticRetryEntry");function lt(e){return/^Background task \w*:/.test(e)}n(lt,"isBackgroundTaskNotice");var A=String.raw`fb\.\d{1,2}\.\d{13}\.`,R=String.raw`(?:\.(?:[A-Za-z0-9_-]{2}|[A-Za-z0-9_-]{8}))?`,ct=new RegExp(`^${A}\\d{1,32}${R}$`),ut=new RegExp(`^${A}[A-Za-z0-9_-]{1,500}${R}$`);var dt=720*60*60*1e3;var ft=10*6e4;function y(e){return t=>e[t]===!0}n(y,"statusQuestion");var pt=y({disconnected:!1,connecting:!1,idle:!1,working:!0,waiting:!0,error:!1}),gt=y({disconnected:!1,connecting:!0,idle:!1,working:!0,waiting:!0,error:!1}),ht=y({disconnected:!1,connecting:!0,idle:!1,working:!0,waiting:!1,error:!1}),mt=y({disconnected:!0,connecting:!1,idle:!0,working:!1,waiting:!1,error:!1}),bt=y({disconnected:!1,connecting:!1,idle:!1,working:!1,waiting:!0,error:!0});export{S as a,I as b,v as c,Xe as d,Qe as e,Ye as f,Ze as g,et as h,tt as i,nt as j,rt as k,ot as l,q as m,H as n,st as o,it as p,at as q,lt as r};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as B}from"./chunk-756GM57N.js";import{a as k,b as v}from"./chunk-ONVWTQLU.js";import{a as _,j as D}from"./chunk-WMKRKKIS.js";import{e as N}from"./chunk-RR7BB4EQ.js";import{b as W,c as z}from"./chunk-Z3Z6LSG4.js";import{e as w,i as O}from"./chunk-CMWS5PI4.js";import{a as H,c as $,g as y,h as b}from"./chunk-CXEEHWHD.js";import{d as I}from"./chunk-HGN4GN2E.js";import{a as S}from"./chunk-5SBKMKFB.js";import{a as s}from"./chunk-3I4YBQX6.js";function U(e,t=null){return e.startsWith("~/")||/^[A-Za-z]:[\\/]/.test(e)||t&&(e===t||e.startsWith(`${t}/`))?!0:e.startsWith("/Users/")||e.startsWith("/home/")||e.startsWith("/private/")}s(U,"isAbsoluteFilePath");function q(e){if(!e.startsWith("file://"))return null;let t=e.slice(7),n=t.startsWith("/")?t:t.startsWith("localhost/")?t.slice(9):null;return n?/^\/[A-Za-z]:[\\/]/.test(n)?n.slice(1):n:null}s(q,"fileUrlToLocalPath");var x="farero-attachment.invalid";function C(e){return`https://${x}/?path=${encodeURIComponent(e)}`}s(C,"attachmentHref");function E(e,t=!1){let n=H(e);for(let a=n.length-1;a>=0;a--){let l=n[a],u=n[a+1],c=u&&!e.slice(l.end,u.start).trim()?`
|
|
2
|
+
${e.slice(u.start)}`:e.slice(l.end),p=l.handoff.sources.at(-1).title.replace(/[\\`*_[\]<>]/g,"\\$&");e=`${e.slice(0,l.start)}[${p}](${$(l.handoff)})${c}`}let r=y(e);if(!r.length)return e;let i="",o=0;for(let a of r){if(i+=e.slice(o,a.start),!t||!/^Transcript of .+\.md$/.test(a.name)){let l=a.name.replace(/[\\`*_[\]<>]/g,"\\$&");i+=`[${l}](${C(a.path)})`}o=a.end}return i+e.slice(o)}s(E,"markdownSource");function Be(e){return/\.(?:md|markdown|mdown|mkd|mkdn)$/i.test(e)}s(Be,"isMarkdownFile");function G(e){let t="",n=s(r=>{for(let i of r)i.type==="text"?t+=i.value:i.type==="element"&&n(i.children)},"walk");return n(e.children),t.replace(/\n$/,"")}s(G,"fenceSource");function h(e){if(!e)return null;try{let t=new URL(e);return t.hostname===x?t.searchParams.get("path"):null}catch{return null}}s(h,"attachmentPath");function P(e){if(!e)return!1;try{let t=new URL(e,location.origin);return t.origin===location.origin&&t.pathname.startsWith("/w/")&&t.searchParams.has("handoff")&&!!t.searchParams.get("session")}catch{return!1}}s(P,"isChatHandoffHref");function T(e){let t=e&&(q(e)??e);if(!t?.startsWith("/")||!U(t))return null;let n=t.match(/:([1-9]\d*)(?::\d+)?$/),r=n?t.slice(0,-n[0].length):t;return b(r)?null:r.slice(r.lastIndexOf("/")+1).includes(".")?t:null}s(T,"sourceReference");function Ze(e){if(!e)return null;let t=e.split(/\r?\n/).filter(Boolean);if(t.length<2)return null;let n=t.map(T);return n.every(r=>r!==null)?n:null}s(Ze,"sourceReferences");function je({reference:e,external:t,externalPreview:n,button:r,metaKey:i,ctrlKey:o,shiftKey:a,altKey:l,defaultPrevented:u}){return u?"browser":r===0&&!i&&!o&&!a&&!l&&!e&&t&&n?"external-preview":e&&(r===0||r===1)?"preview":"browser"}s(je,"chatLinkAction");var le=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,ce=/^[\d.]+$/,ue=/(?:^|\.)(?:corp|example|home|home\.arpa|internal|intranet|invalid|lan|local|localhost|onion|private|test|ts\.net)$/;function Ye(e){let t;try{t=new URL(e).hostname}catch{return null}return!le.test(t)||ce.test(t)||ue.test(t)||t===location.hostname?null:`https://icons.duckduckgo.com/ip3/${t}.ico`}s(Ye,"linkFaviconUrl");function Je(e){return typeof e=="string"?e:Array.isArray(e)&&e.filter(n=>typeof n=="string").join("")||null}s(Je,"linkText");import{Children as de,isValidElement as Z}from"react";import{jsx as L,jsxs as X}from"react/jsx-runtime";function K(e){return typeof e=="string"&&!e.trim()}s(K,"isBlank");function pe(e){return Z(e)&&e.type==="br"}s(pe,"isLineBreak");function V(e){if(!Z(e))return null;let{href:t}=e.props;return typeof t!="string"?null:h(t)!==null||P(t)?t:null}s(V,"referenceHref");var j=s(({children:e,node:t,...n})=>{let r=de.toArray(e),i=[],o=[],a=[],l=0;for(let c=0;c<=r.length;c++){if(c<r.length&&!pe(r[c])){a.push(r[c]);continue}if(!a.every(p=>K(p)||V(p)))break;for(let p of a){let f=V(p);if(!f)continue;let m=h(f);m&&b(m)?i.push(p):o.push(p)}a=[],l=c+1}if(!i.length&&!o.length)return L("p",{...n,children:e});let u=r.slice(l);return X("p",{...n,children:[X("span",{className:S("flex flex-col gap-1",u.some(c=>!K(c))&&"mb-[0.5em]"),children:[i.length?L("span",{className:"flex flex-wrap items-start gap-2",children:i}):null,o.length?L("span",{className:"flex flex-wrap items-center gap-1.5",children:o}):null]}),u]})},"ChatParagraph");import{useCallback as fe,useEffect as me,useRef as Y,useState as ge}from"react";import{createPortal as he}from"react-dom";import{Fragment as ye,jsx as R,jsxs as J}from"react/jsx-runtime";var Q=s(({href:e,children:t,...n})=>{let[r,i]=ge(),o=Y(null),a=Y(null),l=fe(()=>{i(void 0),o.current?.focus({preventScroll:!0})},[]);return me(()=>{if(!r)return;a.current?.querySelector("button")?.focus({preventScroll:!0});let u=s(f=>{let m=f.target;!o.current?.contains(m)&&!a.current?.contains(m)&&i(void 0)},"dismiss"),c=s(f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),i(void 0),o.current?.focus({preventScroll:!0}))},"onEscape"),p=s(f=>{a.current?.contains(f.target)||i(void 0)},"scroll");return document.addEventListener("pointerdown",u),document.addEventListener("keydown",c,!0),document.addEventListener("scroll",p,!0),window.addEventListener("resize",l),()=>{document.removeEventListener("pointerdown",u),document.removeEventListener("keydown",c,!0),document.removeEventListener("scroll",p,!0),window.removeEventListener("resize",l)}},[r,l]),J(ye,{children:[R("a",{...n,ref:o,href:e,"aria-expanded":!!r,"aria-haspopup":"dialog",onClick:u=>{let c=u.currentTarget.closest(".md"),p=e?.slice(1),f=p?Array.from(c?.querySelectorAll("[id]")??[]).find(g=>g.id===p):void 0;if(!f)return;u.preventDefault();let m=f.cloneNode(!0);for(let g of m.querySelectorAll("[data-footnote-backref]"))g.remove();let F=u.currentTarget.getBoundingClientRect();i(g=>g?void 0:{text:m.textContent?.trim()??"",left:Math.max(8,Math.min(F.left,window.innerWidth-272)),top:Math.max(8,Math.min(F.bottom+6,window.innerHeight-208))})},children:t}),r?he(J("div",{ref:a,role:"dialog","aria-label":"Footnote","data-document-controls":!0,className:"farero-ui fixed z-50 max-h-48 w-64 max-w-[calc(100vw-1rem)] overflow-auto overscroll-contain rounded-lg border border-border bg-surface p-3 text-text text-xs shadow-xl",style:{left:r.left,top:r.top},children:[R("p",{className:"whitespace-pre-wrap",children:r.text}),R("a",{href:e,className:"mt-2 inline-block text-accent underline",onClick:()=>{let u=e?document.getElementById(e.slice(1)):null;for(let c=u?.closest("details");c;c=c.parentElement?.closest("details")??null)c.open=!0;i(void 0)},children:"Go to note"}),R("button",{type:"button",className:"ml-3 rounded px-1 text-muted",onClick:l,children:"Close"})]}),document.body):null]})},"FootnoteReference");import{useId as be,useMemo as ie}from"react";import xe from"react-markdown";import Ce from"remark-breaks";import Pe from"remark-gfm";import Re from"remark-math";function M({foldHeadings:e=!0}={}){return t=>{let n=s(r=>{for(let i of r){if(i.type!=="element")continue;let o=i.position?.start.offset;if(o!==void 0&&/^(h[1-6]|p|table|pre)$/.test(i.tagName)&&(i.properties["data-block-id"]=`b${o}`),i.tagName==="pre"){let a=i.children.find(l=>l.type==="element"&&l.tagName==="code");a?.type==="element"&&(i.properties["data-fence-complete"]=a.properties["data-fence-complete"])}n(i.children)}},"anchor");n(t.children),e&&(t.children=ee(t.children))}}s(M,"documentStructure");function ee(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.type!=="element"||!/^h[1-6]$/.test(r.tagName)){t.push(r);continue}let i=Number(r.tagName[1]),o=n+1;for(;o<e.length;){let l=e[o];if(l.type==="element"&&/^h[1-6]$/.test(l.tagName)&&Number(l.tagName[1])<=i)break;o++}let a={type:"element",tagName:"summary",properties:{},children:[r]};t.push({type:"element",tagName:"details",properties:{open:!0,"data-document-section":!0},children:[a,...ee(e.slice(n+1,o)).filter(l=>l.type!=="doctype")]}),n=o-1}return t}s(ee,"sections");function te(){let e="",t,n=!1;return s(function(){let i=this.parser;i&&(this.parser=(o,a)=>{let l,u=o.startsWith(e);u||(n=!1);let c=t&&u&&!n?t.children.slice(0,-2):[],p=t?.children[c.length],f=c.length?p?.position?.start:void 0;f?.offset!==void 0?(l=i(o.slice(f.offset),a),oe(l,f),l.children=[...c,...l.children]):l=i(o,a),!n&&l.children.slice(c.length).some(ne)&&(n=!0,c.length&&(l=i(o,a)));for(let m of l.children.slice(n?0:c.length))re(m,o);return e=o,t=l,l})},"plugin")}s(te,"incrementalMarkdown");function ne(e){return["definition","footnoteDefinition","linkReference","imageReference","footnoteReference"].includes(e.type)||e.type==="text"&&/\[[^\]\n]+\]/.test(e.value)?!0:(e.children??[]).some(ne)}s(ne,"hasReferences");function oe(e,t){if(e.position)for(let n of[e.position.start,e.position.end])n.line===1&&(n.column+=t.column-1),n.line+=t.line-1,n.offset!==void 0&&(n.offset+=t.offset??0);for(let n of e.children??[])oe(n,t)}s(oe,"shiftPositions");function re(e,t){if(e.type==="code"){let n=t.slice(e.position?.start.offset,e.position?.end.offset),r=n.match(/^ {0,3}(`{3,}|~{3,})/),i=n.slice(n.lastIndexOf(`
|
|
3
|
+
`)+1).replace(/^\s*(?:>\s*)+/,"").trimStart(),o=!r||n.includes(`
|
|
4
|
+
`)&&new RegExp(`^ {0,3}${r[1][0]}{${r[1].length},}[ \\t]*$`).test(i);e.data={...e.data,hProperties:{...e.data?.hProperties,"data-fence-complete":o?"true":"false"}}}for(let n of e.children??[])re(n,t)}s(re,"markFence");import{jsx as se}from"react/jsx-runtime";var we=[M],ke=[[M,{foldHeadings:!1}]],vt=s(({children:e,components:t,foldHeadings:n=!0,hideTranscriptAttachments:r=!1,onContextMenu:i})=>{let o=ie(()=>[Pe,[Re,{singleDollarTextMath:!1}],te(),Ce],[]),a=be(),l=ie(()=>({clobberPrefix:`note-${a}-`}),[a]);return se("div",{className:"md farero-ui",onContextMenu:i,children:se(xe,{remarkPlugins:o,rehypePlugins:n?we:ke,remarkRehypeOptions:l,components:t,children:E(e,r)})})},"MarkdownBody");import{MessageSquare as ve,Paperclip as Ne}from"lucide-react";import{lazy as Ee,Suspense as Te}from"react";import{jsx as d,jsxs as A}from"react/jsx-runtime";var Le=Ee(()=>import("./MathEquation-7ZVYQFEK.js")),Me=/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;function ae(e){return e.startsWith("http://")||e.startsWith("https://")}s(ae,"isHttpUrl");function Ae(e){return typeof e=="string"?e:Array.isArray(e)&&e.every(t=>typeof t=="string")?e.join(""):null}s(Ae,"fenceText");var Fe=s(({href:e,children:t,onOpenFile:n,filePaths:r,node:i,...o})=>{if(i?.properties.dataFootnoteRef)return d(Q,{href:e,...o,children:t});if(!e)return d("span",{title:o.title,children:t});let a=h(e);if(a){let[u]=y(C(a)),c=u?u.name:a.slice(a.lastIndexOf("/")+1),p=[N(t??c),o.title,a].filter(Boolean).join(`
|
|
5
|
+
`);return d("span",{title:a,className:k(),children:d(v,{icon:Ne,title:p,children:t??c})})}if(P(e))return d("span",{className:k(),children:d(v,{icon:ve,title:N(t),children:t})});let l=T(e)??(r?.includes(e)?e:null);return l?n?d("button",{type:"button",title:`Open ${l}`,onClick:()=>n(l),className:"inline select-text text-left text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent focus-visible:outline-2 focus-visible:outline-accent",children:t}):d("code",{title:l,className:"text-accent underline decoration-dotted underline-offset-2",children:t}):ae(e)?d("a",{href:e,target:"_blank",rel:"noopener noreferrer",...o,children:t}):d("a",{href:e,...o,children:t})},"ReadonlyLink"),Se=s(({className:e,children:t,node:n,...r})=>{let i=w(e),o=Ae(t);return e?.includes("language-math")&&o!==null?d(Te,{fallback:d("code",{children:o}),children:d(Le,{source:o.replace(/\n$/,""),display:e.includes("math-display")})}):!e&&o!==null&&Me.test(o)?A("code",{...r,children:[d("span",{"aria-hidden":"true",style:{backgroundColor:o},className:"mr-1 inline-block size-[0.85em] shrink-0 translate-y-[0.1em] rounded-[3px] border border-black/25 dark:border-white/25"}),t]}):d("code",{className:e,...r,children:i&&o!==null?d(O,{text:o,language:i}):t})},"ReadonlyCode"),He=s(({src:e,alt:t,node:n,images:r,...i})=>{if(typeof e=="string"&&ae(e))return d("img",{src:e,alt:t??"",...i});let o=typeof e=="string"?r?.[e]:void 0;return o?d("img",{...i,src:o.src,width:o.width,height:o.height,alt:t??"",decoding:"async",className:"border border-border-soft"}):A("span",{className:"my-2 block rounded-lg border border-border-soft px-3 py-2 text-muted text-xs",children:[t||"Image"," unavailable in preview"]})},"ReadonlyImage"),$e=s(({node:e,children:t,...n})=>{let r=e?G(e):"",i=e?.children.find(c=>c.type==="element"&&c.tagName==="code"),o=i?.type==="element"?i.properties.className:void 0,a=_(o),l=e?.properties["data-fence-complete"]!=="false";if(r&&a&&l)return d("div",{children:d(D,{source:r,language:a},a)});let u=Array.isArray(o)?o.join(" "):typeof o=="string"?o:void 0;if(r&&!u?.includes("language-math")){let c=u?.match(/language-([\w+-]+)/)?.[1]?.toLowerCase()??"";return d(z,{source:r,language:w(u)??(c||null),kind:W(c,r),complete:l})}return A("div",{className:"group relative my-3 overflow-hidden rounded-xl border border-border-soft bg-bg",children:[d("pre",{...n,className:"!m-0 !rounded-none !border-0 overflow-x-auto overscroll-x-contain",children:t}),r?d("div",{className:"absolute top-1 right-1 rounded-md border border-border-soft bg-bg/90 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100",children:d(I,{text:r,label:"code",size:12,className:"size-6 rounded-md"})}):null]})},"ReadonlyPre");function Oe(e={}){let{onOpenFile:t,filePaths:n,images:r}=e;return{a:s(a=>d(Fe,{...a,onOpenFile:t,filePaths:n}),"link"),code:Se,img:s(a=>d(He,{...a,images:r}),"image"),p:j,pre:$e,table:B}}s(Oe,"createReadonlyComponents");var Kt=Oe();export{U as a,q as b,x as c,C as d,E as e,Be as f,G as g,h,P as i,T as j,Ze as k,je as l,Ye as m,Je as n,j as o,Q as p,vt as q,Oe as r,Kt as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"./chunk-5SBKMKFB.js";import{a as u}from"./chunk-3I4YBQX6.js";import{useEffect as v,useRef as d}from"react";import{jsx as P}from"react/jsx-runtime";var T=500,y=10,x=u(({onLongPress:r,onClick:b,onContextMenu:m,className:i,type:h="button",...f})=>{let n=d(null),t=d(null),o=d(!1),a=d(r);a.current=f.disabled?void 0:r,v(()=>()=>{n.current!==null&&clearTimeout(n.current)},[]);let s=u(()=>{n.current!==null&&clearTimeout(n.current),n.current=null,t.current=null},"cancel"),p=u(()=>{s();let e=a.current;if(!e)return!1;o.current=!0;try{navigator.vibrate?.(10)}catch{}return e(),!0},"fire");return P("button",{type:h,...f,onTouchStart:e=>{if(o.current=!1,s(),!a.current||e.touches.length!==1)return;let c=e.touches[0];t.current={x:c.clientX,y:c.clientY},n.current=setTimeout(p,T)},onTouchMove:e=>{let c=t.current;if(!c||e.touches.length!==1)return;let g=e.touches[0];Math.hypot(g.clientX-c.x,g.clientY-c.y)>y&&s()},onTouchEnd:s,onTouchCancel:()=>{s(),o.current=!1},onContextMenu:e=>{if(n.current!==null&&p()||o.current){e.preventDefault();return}m?.(e)},onClick:e=>{if(o.current){o.current=!1,e.preventDefault(),e.stopPropagation();return}b?.(e)},className:l(r&&"select-none [-webkit-touch-callout:none]",i)})},"LongPressButton");import{jsx as C,jsxs as k}from"react/jsx-runtime";function w({value:r,options:b,onChange:m,onLongPress:i,disabled:h=!1,wrap:f=!1,touchReach:n=!1}){return C("div",{className:l("flex rounded-lg border border-border bg-surface p-0.5",f?"min-w-0 flex-wrap":"shrink-0"),children:b.map(t=>{let o=h||t.disabled;return k(x,{"aria-pressed":r===t.id,disabled:o,onClick:a=>m(t.id,a),onLongPress:i&&(()=>i(t.id)),className:l("rounded-md px-2 py-1 text-xs transition focus-visible:outline-2 focus-visible:outline-accent",t.icon&&"inline-flex items-center gap-1 whitespace-nowrap",n&&"relative touch-manipulation before:absolute before:inset-x-0 pointer-coarse:before:-inset-y-2 before:content-[''] max-md:before:-inset-y-2",r===t.id?"bg-accent-soft text-accent":t.marked?"bg-[color:light-dark(color-mix(in_oklab,var(--color-accent-soft)_60%,transparent),color-mix(in_oklab,var(--color-accent-soft)_40%,transparent))] text-muted":"text-muted active:bg-surface-2",o&&"opacity-45"),children:[t.icon,t.label]},t.id)})})}u(w,"Segments");export{x as a,w as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-5SBKMKFB.js";import{a as n}from"./chunk-3I4YBQX6.js";async function d(o){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(o);return}catch{}let t=document.createElement("textarea");t.value=o,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0",document.body.append(t),t.select();let e=document.execCommand("copy");if(t.remove(),!e)throw new Error("Clipboard unavailable")}n(d,"copyText");async function P(o,t){if(navigator.clipboard?.write&&typeof ClipboardItem<"u")try{return await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([o],{type:"text/plain"}),"text/html":Promise.resolve(t).then(e=>new Blob([e],{type:"text/html"}))})]),"formatted"}catch{}return Promise.resolve(t).catch(()=>{}),await d(o),"text"}n(P,"copyFormatted");function k(o){let t=document.createElement("div");t.append(o.cloneNode(!0));for(let e of t.querySelectorAll('[data-document-controls], [hidden], [aria-hidden="true"], .sr-only, button:not([data-markdown-destination]), script, style, iframe, object, embed'))e.remove();for(let e of t.querySelectorAll("*"))for(let r of Array.from(e.attributes))(/^(on|data-)/i.test(r.name)||["id","class","tabindex","style"].includes(r.name))&&e.removeAttribute(r.name);return t.innerHTML}n(k,"formattedFragment");import{Check as y,Copy as x,Minus as C,Plus as v,Scaling as g}from"lucide-react";import{useState as w}from"react";import{Fragment as h,jsx as i,jsxs as m}from"react/jsx-runtime";var A=n(({text:o,label:t,className:e,size:r=14,showLabel:c,onCopyError:a,...l})=>{let[s,u]=w(!1),b=n(async()=>{try{await d(o),u(!0),window.setTimeout(()=>u(!1),1800)}catch(f){u(!1),a?.(f)}},"copy");return m("button",{...l,type:"button",onClick:()=>void b(),"aria-label":s?`Copied ${t}`:`Copy ${t}`,className:p("flex items-center justify-center text-muted transition active:bg-surface-2",e),children:[s?i(y,{size:r,className:"text-accent"}):i(x,{size:r}),c?i("span",{"aria-live":"polite",children:s?"Copied":`Copy ${t}`}):null]})},"CopyButton"),I=n(({scale:o,onZoom:t,onFit:e,disabled:r=!1})=>{let c=[{label:"Zoom out",icon:C,action:n(()=>t(.8333333333333334),"action")},{label:"Zoom in",icon:v,action:n(()=>t(1.2),"action")},{label:"Fit diagram to view",icon:g,action:e}];return m(h,{children:[m("span",{className:"w-10 text-center text-muted text-xs tabular-nums",children:[i("span",{className:"sr-only",children:"Zoom "}),Math.round(o*100),"%"]}),c.map(({label:a,icon:l,action:s})=>i("button",{type:"button",onClick:s,disabled:r,"aria-label":a,title:a,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted transition hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent active:bg-surface-2 disabled:opacity-40",children:i(l,{size:16})},a))]})},"ZoomControls"),E=n(({open:o,className:t,...e})=>i("button",{type:"button",...e,className:p("relative flex size-9 shrink-0 items-center justify-center rounded-full text-muted transition active:bg-surface-2",o&&"bg-surface-2 text-text",t)}),"HeaderIconButton");export{d as a,P as b,k as c,A as d,I as e,E as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as h}from"./chunk-5SBKMKFB.js";import{a as e}from"./chunk-3I4YBQX6.js";import{jsx as C}from"react/jsx-runtime";var S={primary:"bg-accent text-on-solid hover:bg-accent/90 active:bg-accent/80",secondary:"border border-border text-muted hover:bg-surface-2 hover:text-text active:bg-surface-2",ghost:"text-muted hover:bg-surface-2 hover:text-text active:bg-surface-2",danger:"border border-del/40 text-del hover:bg-surface-2 active:bg-surface-2"},M={sm:"h-7 rounded-md px-2 text-xs",md:"h-9 rounded-lg px-3 text-xs"};function E(n,o,r,i=!1){return h("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap font-medium transition focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-50",M[o],S[n],i&&n==="ghost"&&"hover:underline hover:underline-offset-2",r)}e(E,"buttonClass");var G=e(n=>{if("href"in n){let{href:s,children:a,variant:c="secondary",size:m="md",className:y,...f}=n;return C("a",{...f,href:s,className:E(c,m,y,!0),children:a})}let{type:o="button",children:r,variant:i="secondary",size:w="md",className:d,...p}=n;return C("button",{...p,type:o,className:E(i,w,d),children:r})},"Button");import{useEffect as D,useLayoutEffect as A,useRef as g,useState as L}from"react";import{createPortal as F}from"react-dom";import{jsx as V,jsxs as k}from"react/jsx-runtime";var _=450,H=600,N=6,v=4,T=0,J=e(({label:n,detail:o,side:r="bottom",className:i,children:w})=>{let d=g(null),p=g(null),s=g(void 0),a=g(!1),[c,m]=L(!1),[y,f]=L(null),x=e(()=>{clearTimeout(s.current);let t=e(()=>{a.current=!0,m(!0)},"reveal");Date.now()<T?t():s.current=setTimeout(t,_)},"show"),u=e(()=>{clearTimeout(s.current),a.current&&(T=Date.now()+H),a.current=!1,m(!1)},"hide");return D(()=>()=>clearTimeout(s.current),[]),A(()=>{if(!c){f(null);return}let t=d.current?.getBoundingClientRect(),l=p.current?.getBoundingClientRect();if(!t||!l)return;let z=t.top-N-l.height,P=t.bottom+N,R=P+l.height<=window.innerHeight-v;f({left:Math.max(v,Math.min(t.left+(t.width-l.width)/2,window.innerWidth-l.width-v)),top:r==="top"||!R?Math.max(v,z):P});let b=e(()=>u(),"close"),B=e(O=>{O.key==="Escape"&&u()},"onEscape");return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),document.addEventListener("keydown",B),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b),document.removeEventListener("keydown",B)}},[c,r,n,o]),k("span",{ref:d,className:h("inline-flex",i),onPointerEnter:t=>{t.pointerType!=="touch"&&x()},onPointerLeave:u,onPointerDown:u,onFocus:t=>{t.target instanceof Element&&t.target.matches(":focus-visible")&&x()},onBlur:u,children:[w,c?F(k("div",{ref:p,"aria-hidden":"true",style:y??{left:0,top:0,visibility:"hidden"},className:"farero-ui pointer-events-none fixed z-[90] max-w-64 rounded-md border border-border bg-surface px-2 py-1 text-text text-xs shadow-black/30 shadow-lg",children:[n,o?V("span",{className:"block text-muted",children:o}):null]}),document.body):null]})},"Tooltip");export{G as a,J as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as p,b as T}from"./chunk-ITKN2ASJ.js";import{c as d}from"./chunk-RR7BB4EQ.js";import{c as y}from"./chunk-ZVJQ5X63.js";import{b as u,c as f,f as b}from"./chunk-HGN4GN2E.js";import{a}from"./chunk-3I4YBQX6.js";import{createContext as E}from"react";var F=E(null);function $(l,o){let t=a(r=>Array.from(r.replace(/[<>:"/\\|?*]/g,"-")).filter(n=>n.codePointAt(0)>=32&&n.codePointAt(0)!==127).slice(0,60).join("").replace(/\s+/g," ").replace(/^[ .]+|[ .]+$/g,""),"stem"),e=t(l??"")||t(o.join(" - "))||"Untitled table";return/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e)&&(e=`_${e}`),`${e}.csv`}a($,"tableCsvFilename");function I(l,o){let t=l.cloneNode(!0);if(o){let n=Array.from(t.tBodies[0]?.rows??[]);t.tBodies[0]?.replaceChildren(...o.flatMap(i=>n[i]?[n[i]]:[]))}let e=document.createDocumentFragment();e.append(t);let r=document.createElement("template");return r.innerHTML=f(e),r.content.querySelector("table")}a(I,"tableExportView");function v(l){let o=l.cloneNode(!0);for(let t of o.querySelectorAll("a[href]")){let e=t.getAttribute("href"),r=t.textContent?.trim()??"";t.replaceWith(r&&r!==e?`${r} (${e})`:e)}for(let t of o.querySelectorAll("br"))t.replaceWith(`
|
|
2
|
+
`);return o.textContent?.trim()??""}a(v,"cellText");function C(l){return Array.from(l.rows,o=>Array.from(o.cells,v))}a(C,"tableTextWithLinks");import{Check as L,Copy as A}from"lucide-react";import{useEffect as B,useState as g}from"react";import{jsx as c,jsxs as H}from"react/jsx-runtime";var _=a(({getTable:l,compact:o})=>{let[t,e]=g(!1),[r,n]=g(null);B(()=>{if(!t)return;let s=setTimeout(()=>e(!1),1800);return()=>clearTimeout(s)},[t]);let i=a(async()=>{n(null),e(!1);try{let s=l();if(!s)throw new Error("Table unavailable");let x=y(C(s)," "),h=await u(x,s.outerHTML);e(!0),h==="text"&&n("Copied text with URLs; formatted clipboard unavailable.")}catch{n("Could not copy the table.")}},"copy"),m=t?"Copied table":"Copy table";return H("span",{className:"inline-flex shrink-0","data-document-controls":!0,children:[o?c(T,{label:m,children:c(b,{"aria-label":m,onClick:()=>void i(),className:"size-6 rounded-md hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent",children:c(t?L:A,{size:14,"aria-hidden":!0})})}):c(p,{variant:"ghost",size:"sm",onClick:()=>void i(),children:m}),c(d,{error:r,onDismiss:()=>n(null)})]})},"TableCopyButton");export{F as a,$ as b,I as c,C as d,_ as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-5SBKMKFB.js";import{a as s}from"./chunk-3I4YBQX6.js";import{useEffect as m,useMemo as f,useState as u}from"react";import{jsx as a}from"react/jsx-runtime";var p="default-src 'none'; script-src 'none'; connect-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src 'none'; media-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'";function v(r){let e=document.createElement("template");e.innerHTML=r;for(let t of e.content.querySelectorAll("script, iframe, object, embed, link, meta, base, form, svg, math, template"))t.remove();for(let t of e.content.querySelectorAll("*"))for(let o of Array.from(t.attributes)){let n=o.name.toLowerCase();if(["href","src","srcset","poster","background","action","formaction","ping","data","srcdoc","is","autofocus"].includes(n)||n.startsWith("on")){if(n==="src"&&t.tagName==="IMG"&&/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(o.value))continue;t.removeAttribute(o.name)}}return e.innerHTML}s(v,"staticHtml");function b({source:r,kind:e,className:t="h-80 w-full bg-bg"}){let[o,n]=u(),l=f(()=>e==="html"?v(r):"",[r,e]);return m(()=>{if(e!=="svg")return;let c=URL.createObjectURL(new Blob([r],{type:"image/svg+xml"}));return n(c),()=>URL.revokeObjectURL(c)},[r,e]),e==="svg"?a("div",{className:"farero-ui flex h-64 items-center justify-center overflow-auto overscroll-contain p-4",children:o?a("img",{src:o,alt:"SVG preview",className:"max-h-full max-w-full"}):null}):a("iframe",{title:"Isolated HTML preview",sandbox:"",referrerPolicy:"no-referrer",className:i("farero-ui",t),srcDoc:`<!doctype html><html style="overscroll-behavior:contain!important"><head><meta http-equiv="Content-Security-Policy" content="${p}"></head><body style="overscroll-behavior:contain!important">${l}</body></html>`})}s(b,"IsolatedPreview");export{b as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk-5SBKMKFB.js";import{a as i}from"./chunk-3I4YBQX6.js";import{Fragment as c,jsx as r,jsxs as s}from"react/jsx-runtime";function l({action:e=!1,className:t}={}){return n("inline-flex max-w-full select-text items-center gap-1 rounded-md bg-surface-2 px-1.5 py-0.5 align-baseline font-medium text-muted text-xs leading-5 no-underline",e&&"transition hover:text-text focus-visible:outline-2 focus-visible:outline-accent active:bg-surface disabled:cursor-default",t)}i(l,"referenceChipClass");var p=i(({icon:e,title:t,children:a})=>s(c,{children:[r(e,{size:12,className:"shrink-0","aria-hidden":!0}),r("span",{title:t,className:"truncate",children:a})]}),"ReferenceChipLabel");export{l as a,p as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as d}from"./chunk-HGN4GN2E.js";import{a as s}from"./chunk-5SBKMKFB.js";import{a as r}from"./chunk-3I4YBQX6.js";import{X as f}from"lucide-react";import{createPortal as b}from"react-dom";import{jsx as n,jsxs as u}from"react/jsx-runtime";var x=r(({error:e,onDismiss:t,dismissLabel:o="Dismiss error",className:i,children:p,...l})=>u("div",{...l,role:"alert",className:s("flex items-start gap-2 text-del text-xs",i),children:[n("span",{className:"min-w-0 flex-1 cursor-text select-text whitespace-pre-line break-words",children:e}),p,n(g,{label:o,onClick:t})]}),"DismissibleError"),g=r(({label:e,type:t="button",className:o,...i})=>n("button",{...i,type:t,"aria-label":e,className:s("flex size-6 shrink-0 items-center justify-center rounded-md text-del/70 transition hover:bg-del/10 hover:text-del active:bg-del/10",o),children:n(f,{size:14})}),"DismissButton"),P=r(({error:e,onDismiss:t})=>e?b(n(x,{error:e,onDismiss:t,className:"farero-ui fixed bottom-4 left-1/2 z-[70] w-[min(22rem,calc(100vw-2rem))] -translate-x-1/2 rounded-lg border border-del/40 bg-surface px-3 py-2 shadow-xl"}),document.body):null,"CopyErrorToast"),w=r(({label:e,className:t,...o})=>u("div",{...o,className:s("fade-in flex items-center justify-center gap-2 py-16 text-muted text-sm",t),children:[n("span",{className:"size-4 animate-spin rounded-full border-2 border-border border-t-accent"}),e]}),"Spinner");import{isValidElement as v}from"react";function c(e){return typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(c).join(""):v(e)?e.type==="br"?`
|
|
2
|
+
`:c(e.props.children):""}r(c,"reactText");import{X as N}from"lucide-react";import{jsx as a,jsxs as m}from"react/jsx-runtime";var T=r(({label:e,title:t=e,onClick:o,children:i})=>a(d,{onClick:o,"aria-label":e,title:t,className:"size-8 hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent",children:i}),"ViewerAction"),S=r(({title:e,subtitle:t,actions:o,onClose:i,closeLabel:p,compact:l})=>m("header",{className:s("flex shrink-0 items-center border-border-soft border-b bg-bg",l?"h-10 gap-2 pr-2 pl-3":"gap-3 px-4 py-3"),children:[m("div",{className:"min-w-0 flex-1",children:[e?a("h2",{className:s("font-semibold",l?"truncate text-sm":"text-base"),children:e}):null,t?a("p",{className:"truncate font-mono text-muted text-xs",title:c(t)||void 0,children:t}):null]}),m("div",{className:"flex shrink-0 items-center gap-0.5",children:[o,i?a("button",{type:"button",onClick:i,"aria-label":p,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted transition hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent active:bg-surface-2",children:a(N,{size:18})}):null]})]}),"ViewerHeader");export{x as a,g as b,P as c,w as d,c as e,T as f,S as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-3I4YBQX6.js";import{jsx as d}from"react/jsx-runtime";var s=a(({size:i=20,strokeWidth:e,variant:n,cycle:c,paused:p=!1,className:y,style:v,label:r,children:l})=>d("svg",{className:y?`fr-activity ${y}`:"fr-activity",viewBox:"0 0 24 24",width:i,height:i,"data-activity-variant":n,"data-paused":p||void 0,role:r?"img":void 0,"aria-label":r,"aria-hidden":r?void 0:!0,focusable:"false",style:{...e===void 0?{}:{"--activity-stroke":e},...c===void 0?{}:{"--activity-cycle":`${c}s`},...v},children:l}),"ActivityGlyph");import{Fragment as m,jsx as t,jsxs as o}from"react/jsx-runtime";var A=a(({variant:i="orrery",...e})=>t(s,{...e,variant:i,children:o(m,{children:[t("path",{className:"activity-guide activity-faint",d:"M12 .5v23M.5 12h23"}),t("path",{className:"activity-guide",d:"M12 0v1.6M22.4 12H24M12 22.4V24M0 12h1.6"}),t("circle",{className:"activity-guide",cx:"12",cy:"12",r:"9.5"}),t("circle",{className:"activity-guide",cx:"12",cy:"12",r:"6.3"}),t("circle",{className:"activity-guide activity-faint",cx:"12",cy:"12",r:"2"}),o("g",{className:"activity-moving orbital-turn",children:[t("path",{className:"activity-guide",d:"M12 12V2.5"}),t("circle",{className:"activity-point",cx:"12",cy:"2.5",r:"1.05"})]}),t("g",{className:"activity-moving orbital-turn orbital-reverse orbital-slow",children:t("circle",{className:"activity-point",cx:"12",cy:"5.7",r:"0.8"})}),t("circle",{className:"activity-point",cx:"12",cy:"12",r:"0.55"})]})}),"Orrery");export{s as a,A as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-5SBKMKFB.js";import{a as o}from"./chunk-3I4YBQX6.js";import{createElement as s}from"react";import{jsx as p}from"react/jsx-runtime";function c({as:e,tone:t="muted",className:n,...a}){return s(e??"span",{...a,className:r("font-medium font-sans text-[11px] uppercase leading-4 tracking-wide",t==="danger"?"text-del":"text-muted",n)})}o(c,"Eyebrow");var x=o(({className:e,...t})=>p("mark",{...t,className:r("rounded bg-accent/25 px-0.5 text-text",e)}),"SearchHit"),i=o(({className:e,tone:t="cap",...n})=>p("kbd",{...n,className:r("inline-block min-w-5 text-center font-normal font-sans text-[11px] leading-4",t==="cap"?"rounded border border-border bg-surface-2 px-1 py-0.5 text-muted":"text-faint",e)}),"KeyboardHint");export{c as a,x as b,i as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./chunk-3I4YBQX6.js";import{createContext as x,useLayoutEffect as m,useRef as y,useState as E}from"react";import{createPortal as g}from"react-dom";import{jsx as p}from"react/jsx-runtime";function f(l){return Array.from(l.querySelectorAll('button[role="menuitem"]'))}u(f,"menuButtons");var M=u(({label:l,x:s,y:c,trigger:a,items:b,onClose:o})=>{let i=y(null),[w,v]=E({left:s,top:c});return m(()=>{let e=i.current;if(!e)return;let t=e.getBoundingClientRect();v({left:Math.max(8,Math.min(s,window.innerWidth-t.width-8)),top:Math.max(8,Math.min(c,window.innerHeight-t.height-8))}),f(e)[0]?.focus({preventScroll:!0})},[s,c]),m(()=>{let e=u(n=>{let r=n.target instanceof Node?n.target:null;r&&(i.current?.contains(r)||a.contains(r))||o()},"outside"),t=u(()=>o(),"close");return document.addEventListener("pointerdown",e,!0),document.addEventListener("scroll",e,!0),window.addEventListener("resize",t),window.addEventListener("blur",t),()=>{document.removeEventListener("pointerdown",e,!0),document.removeEventListener("scroll",e,!0),window.removeEventListener("resize",t),window.removeEventListener("blur",t)}},[o,a]),g(p("div",{ref:i,role:"menu","aria-label":l,tabIndex:-1,className:"farero-ui fixed z-[80] w-56 max-w-[calc(100vw-1rem)] rounded-xl border border-border bg-surface p-1 text-text shadow-black/40 shadow-xl",style:w,onKeyDown:e=>{let t=i.current;if(!t)return;if(e.key==="Escape"||e.key==="Tab"){e.preventDefault(),o(),a.focus({preventScroll:!0});return}let n=f(t),r=n.indexOf(document.activeElement),d=e.key==="ArrowDown"?(r+1)%n.length:e.key==="ArrowUp"?(r-1+n.length)%n.length:e.key==="Home"?0:e.key==="End"?n.length-1:void 0;d!==void 0&&(e.preventDefault(),n[d]?.focus({preventScroll:!0}))},children:b.map(e=>p("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-sm text-text transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none active:bg-surface-2",onClick:()=>{o(),e.onSelect()},children:e.label},e.label))}),document.body)},"PopoverMenu"),k=x(M);export{M as a,k as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as O,b as q,c as G,e as K}from"./chunk-LHMFMBHY.js";import{g as A}from"./chunk-RR7BB4EQ.js";import{a as I,c as N}from"./chunk-ZVJQ5X63.js";import{a as R}from"./chunk-HGN4GN2E.js";import{a as b}from"./chunk-3I4YBQX6.js";import{useContext as Y,useEffect as ee,useMemo as Q,useRef as k,useState as d}from"react";import{createPortal as te}from"react-dom";import{jsx as t,jsxs as s}from"react/jsx-runtime";var m=100,r="rounded-md px-2 py-1 text-xs text-muted hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-40";function oe({columns:y,rows:g,sourceRows:T,sourceTable:x,totalRows:v,onClose:S}){let Z=Y(O),[h,E]=d(""),[l,M]=d(null),[c,w]=d(()=>new Set),[_,f]=d(0),[i,C]=d(!1),[L,P]=d(),H=k(null),$=k(null),[j,J]=d(0),B=k(null),z=Q(()=>T??g.map(e=>e.map(o=>typeof o=="string"?o:String(o??""))),[T,g]),a=Q(()=>{let e=h.toLocaleLowerCase(),o=z.map((n,p)=>({cells:n,index:p})).filter(n=>!e||n.cells.some(p=>p.toLocaleLowerCase().includes(e)));return l&&o.sort((n,p)=>(n.cells[l.column]??"").localeCompare(p.cells[l.column]??"",void 0,{numeric:!0})*(l.descending?-1:1)||n.index-p.index),o},[z,h,l]),u=Math.min(_,Math.max(0,Math.ceil(a.length/m)-1)),U=a.slice(u*m,(u+1)*m),W=a.filter(e=>c.has(e.index)).length;ee(()=>{if(i)return H.current?.showModal(),()=>B.current?.focus({preventScroll:!0})},[i]);let D=b(()=>a.filter(e=>!c.size||c.has(e.index)),"exportMatches"),X=b(()=>x?G(x,D().map(e=>e.index)):null,"exportTable"),F=b(()=>[y,...D().map(e=>e.cells)],"exported"),V=s("div",{className:"flex min-h-0 flex-col rounded-lg border border-border-soft bg-bg text-xs",children:[s("div",{className:"flex flex-wrap items-center gap-1 border-border-soft border-b p-2","data-document-controls":!0,children:[t("input",{type:"search","aria-label":"Filter table rows",placeholder:"Filter rows\u2026",value:h,onChange:e=>{E(e.target.value),f(0)},className:"min-w-0 flex-1 rounded-md border border-border-soft bg-bg px-2 py-1 text-base sm:text-xs"}),t("button",{type:"button",className:r,onClick:()=>{M(null),E(""),f(0),w(new Set)},children:"Original order"}),t("button",{type:"button",className:r,onClick:b(()=>{P(void 0),R(N(F()," ")).catch(()=>P("Could not copy rows. Try again."))},"copy"),children:c.size?`Copy ${W} selected in view`:"Copy for spreadsheet"}),x?t(K,{getTable:X}):null,c.size?t("button",{type:"button",className:r,onClick:()=>w(new Set),children:"Clear selection"}):null,t("button",{type:"button",className:r,onClick:()=>I(new Blob([N(F(),",")],{type:"text/csv;charset=utf-8"}),q(Z,y)),children:"CSV"}),t("button",{ref:B,type:"button",className:r,onClick:()=>{i||J($.current?.getBoundingClientRect().height??0),C(e=>!e)},children:i?"Exit fullscreen":"Fullscreen"}),S&&!i?t("button",{type:"button",className:r,onClick:S,children:"Authored view"}):null]}),s("p",{className:"!m-0 px-2 py-1 text-muted tabular-nums","data-document-controls":!0,children:[a.length," supplied rows",v!==void 0&&v>g.length?` of ${v}; remaining rows not supplied`:"; dataset completeness unknown",". ",l?"Sorted view":"Original order",h?" \xB7 filtered":"",". Exports use the current view",c.size?" and selection":"","."]}),t("div",{className:"max-h-[60dvh] min-h-0 overflow-auto overscroll-contain",children:s("table",{className:"!m-0 w-full",children:[t("thead",{className:"sticky top-0 z-10 bg-surface",children:s("tr",{children:[t("th",{scope:"col",children:t("span",{className:"sr-only",children:"Select row"})}),y.map((e,o)=>t("th",{scope:"col","aria-sort":l?.column===o?l.descending?"descending":"ascending":"none",children:s("button",{type:"button",className:"w-full text-left",onClick:()=>{M(n=>({column:o,descending:n?.column===o&&!n.descending})),f(0)},children:[e,l?.column===o?l.descending?" \u2193":" \u2191":""]})},`${o}:${e}`))]})}),t("tbody",{children:U.map(({index:e})=>s("tr",{children:[t("td",{children:t("input",{type:"checkbox","aria-label":`Select supplied row ${e+1}`,checked:c.has(e),onChange:()=>w(o=>{let n=new Set(o);return n.has(e)?n.delete(e):n.add(e),n})})}),g[e].map((o,n)=>t("td",{children:o},`${e}:${n}`))]},e))})]})}),a.length>m?s("div",{className:"flex items-center justify-end gap-2 p-2","data-document-controls":!0,children:[t("button",{type:"button",className:r,disabled:!u,onClick:()=>f(u-1),children:"Previous"}),s("span",{className:"tabular-nums",children:["Page ",u+1," of ",Math.ceil(a.length/m)]}),t("button",{type:"button",className:r,disabled:(u+1)*m>=a.length,onClick:()=>f(u+1),children:"Next"})]}):null,L?t("p",{role:"status",className:"px-2 text-del",children:L}):null]});return t("div",{ref:$,className:"farero-ui",style:i?{height:j}:void 0,children:i?te(s("dialog",{ref:H,onCancel:()=>C(!1),"aria-label":"Table exploration",className:"farero-ui fixed inset-0 m-auto max-h-[90dvh] w-[96vw] max-w-6xl overflow-hidden overscroll-contain rounded-xl border border-border bg-bg p-0 text-text backdrop:bg-black/60",children:[t(A,{title:"Table",closeLabel:"Close fullscreen table",onClose:()=>C(!1)}),V]}),document.body):V})}b(oe,"DataTable");export{oe as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as _}from"./chunk-YPRVAH5G.js";import{b as Q}from"./chunk-T3JXEXIJ.js";import{d as H,g as ee}from"./chunk-RR7BB4EQ.js";import{b as K}from"./chunk-FW2QVWXL.js";import{d as B,e as q}from"./chunk-HGN4GN2E.js";import{a as o}from"./chunk-3I4YBQX6.js";var fe=[{id:"auto",label:"Auto"},{id:"elk",label:"ELK"},{id:"dagre",label:"Dagre"}],pe=[{id:"tala",label:"TALA"},{id:"elk",label:"ELK"},{id:"dagre",label:"Dagre"}];function Pe(t){if(Array.isArray(t))for(let r of t){if(String(r).toLowerCase()==="language-mermaid")return"mermaid";if(String(r).toLowerCase()==="language-d2")return"d2"}}o(Pe,"diagramLanguage");function A(t){return t==="d2"?pe:fe}o(A,"diagramLayouts");function te(t){return A(t)[0].id}o(te,"defaultDiagramLayout");async function re(t,r,n,s,c,a){if(!A(n).some(i=>i.id===s))throw new Error("Unsupported diagram layout");if(c.throwIfAborted(),n==="d2"){let{renderD2:i}=await import("./d2-S4ICDZEQ.js");return c.throwIfAborted(),i(t,r,s==="auto"?"tala":s,c,a)}let{renderMermaid:l}=await import("./mermaid-CQ4QMBLA.js");return c.throwIfAborted(),l(t,r,s==="tala"?"auto":s)}o(re,"renderDiagram");function I(t,r){let n=Math.min(Math.max(1,r.width-48)/t.width,Math.max(1,r.height-48)/t.height,1);return{scale:n,x:(r.width-t.width*n)/2,y:(r.height-t.height*n)/2}}o(I,"fitDiagram");function ae(t,r,n){let s=o((c,a,l)=>{let i=a*t.scale;return i+48<=l?(l-i)/2:Math.min(24,Math.max(l-24-i,c))},"offset");return{...t,x:s(t.x,r.width,n.width),y:s(t.y,r.height,n.height)}}o(ae,"containDiagram");function j(t,r,n){let s=r/t.scale;return{scale:r,x:n.x-(n.x-t.x)*s,y:n.y-(n.y-t.y)*s}}o(j,"zoomDiagramAt");import{useCallback as ne,useLayoutEffect as he,useRef as oe,useState as be}from"react";function ie(t){let[r,n]=t.values();return r&&n?{center:{x:(r.x+n.x)/2,y:(r.y+n.y)/2},distance:Math.hypot(r.x-n.x,r.y-n.y)}:null}o(ie,"pointerPair");function se(t){let r=oe(null),[n,s]=be({x:0,y:0,scale:1}),c=oe({fit:o(()=>{},"fit"),zoom:o(a=>{},"zoom")});return he(()=>{let a=r.current;if(!a)return;let l={width:a.clientWidth,height:a.clientHeight},i=I(t,l),g=!0,f=new Map,D=!1,T=1,v=o(()=>({x:l.width/2,y:l.height/2}),"center"),S=o((e,d)=>{let C=a.getBoundingClientRect();return{x:e-C.left,y:d-C.top}},"localPoint"),N=o(e=>{i=ae(e,t,l),s(i)},"commit"),P=o(e=>Math.max(Math.min(I(t,l).scale,.1),Math.min(8,e)),"scaleWithinBounds"),w=o((e,d=v())=>{g=!1,N(j(i,P(i.scale*e),d))},"zoom"),M=o(()=>{g=!0,N(I(t,l))},"fitView"),y=o((e,d)=>{g=!1,N({...i,x:i.x+e,y:i.y+d})},"pan");c.current={fit:M,zoom:w},N(i);let F=new ResizeObserver(()=>{let e=l;l={width:a.clientWidth,height:a.clientHeight},N(g?I(t,l):{...i,x:i.x+(l.width-e.width)/2,y:i.y+(l.height-e.height)/2})});F.observe(a);let R=o(e=>{e.preventDefault(),e.stopPropagation();let d=e.deltaMode===1?16:e.deltaMode===2?l.height:1;e.ctrlKey||e.metaKey?D||w(Math.exp(-e.deltaY*d*.01),S(e.clientX,e.clientY)):e.shiftKey&&e.deltaX===0?y(-e.deltaY*d,0):y(-e.deltaX*d,-e.deltaY*d)},"wheel"),m=o(e=>{e.pointerType==="mouse"&&e.button!==0||(e.preventDefault(),a.focus({preventScroll:!0}),f.set(e.pointerId,S(e.clientX,e.clientY)),a.setPointerCapture(e.pointerId))},"down"),L=o(e=>{let d=f.get(e.pointerId);if(!d)return;let C=ie(f),W=S(e.clientX,e.clientY);f.set(e.pointerId,W);let U=ie(f);if(C&&U&&C.distance>0){g=!1;let X=j(i,P(i.scale*U.distance/C.distance),C.center);N({...X,x:X.x+U.center.x-C.center.x,y:X.y+U.center.y-C.center.y})}else f.size===1&&y(W.x-d.x,W.y-d.y)},"move"),u=o(e=>f.delete(e.pointerId),"up"),h=o(e=>{e.preventDefault(),D=f.size===0,T=1},"gestureStart"),E=o(e=>{if(e.preventDefault(),!D)return;let d=e;if(!(d.scale>0))return;let C=Number.isFinite(d.clientX)&&Number.isFinite(d.clientY)?S(d.clientX,d.clientY):v();w(d.scale/T,C),T=d.scale},"gestureChange"),p=o(e=>{e.preventDefault(),D=!1},"gestureEnd"),z=o(e=>{if(!(e.metaKey||e.ctrlKey||e.altKey)){if(e.key==="+"||e.key==="=")w(1.2);else if(e.key==="-")w(1/1.2);else if(e.key==="0")M();else if(e.key==="ArrowLeft")y(40,0);else if(e.key==="ArrowRight")y(-40,0);else if(e.key==="ArrowUp")y(0,40);else if(e.key==="ArrowDown")y(0,-40);else return;e.preventDefault(),e.stopPropagation()}},"key");return a.addEventListener("wheel",R,{passive:!1}),a.addEventListener("pointerdown",m),a.addEventListener("pointermove",L),a.addEventListener("pointerup",u),a.addEventListener("pointercancel",u),a.addEventListener("lostpointercapture",u),a.addEventListener("gesturestart",h,{passive:!1}),a.addEventListener("gesturechange",E,{passive:!1}),a.addEventListener("gestureend",p,{passive:!1}),a.addEventListener("keydown",z),()=>{F.disconnect(),c.current={fit:o(()=>{},"fit"),zoom:o(()=>{},"zoom")},a.removeEventListener("wheel",R),a.removeEventListener("pointerdown",m),a.removeEventListener("pointermove",L),a.removeEventListener("pointerup",u),a.removeEventListener("pointercancel",u),a.removeEventListener("lostpointercapture",u),a.removeEventListener("gesturestart",h),a.removeEventListener("gesturechange",E),a.removeEventListener("gestureend",p),a.removeEventListener("keydown",z)}},[t]),{canvas:r,view:n,fit:ne(()=>c.current.fit(),[]),zoom:ne(a=>c.current.zoom(a),[])}}o(se,"useDiagramViewport");function le(t){let r=document.documentElement,n=document.createElement("span");n.style.display="none",t.append(n);let s=getComputedStyle(n),c=s.colorScheme??"",a=c.split(/\s+/),l=c?a.includes("dark")&&(!a.includes("light")||window.matchMedia("(prefers-color-scheme: dark)").matches):r.dataset.theme==="dark"||r.dataset.theme!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches,i=o((f,D)=>{n.style.color=`var(--color-${f})`;let T=getComputedStyle(n).color.match(/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);return T?`#${T.slice(1,4).map(v=>Number(v).toString(16).padStart(2,"0")).join("")}`:D},"color"),g={dark:l,background:i("bg",l?"#171a20":"#f7f3eb"),surface:i("surface",l?"#21262e":"#fffcf6"),surface2:i("surface-2",l?"#2c333d":"#eee7dc"),border:i("border",l?"#444d58":"#d2c6b8"),borderSoft:i("border-soft",l?"#333b46":"#e3d9cb"),text:i("text",l?"#f6eee0":"#262d36"),muted:i("muted",l?"#b9afa4":"#6f665d"),fontFamily:s.getPropertyValue("--font-sans").trim()||"ui-sans-serif, system-ui, sans-serif"};return n.remove(),g}o(le,"readDiagramTheme");import{Maximize2 as Me}from"lucide-react";import{useCallback as de,useEffect as Z,useRef as J,useState as k}from"react";import{flushSync as ze}from"react-dom";import{Download as ye}from"lucide-react";import{useContext as xe,useState as me}from"react";import{Fragment as De,jsx as O,jsxs as ve}from"react/jsx-runtime";var Y=o(({url:t})=>{let[r,n]=me(),[s,c]=me(),a=xe(Q),l=o(g=>{t&&(c("Exporting\u2026"),import("./download-K6ZKYCHG.js").then(f=>f.exportDiagram(t,g)).then(()=>c(void 0),()=>c("Could not export diagram. Try again.")))},"save"),i=["svg","png"].map(g=>({label:`Download ${g.toUpperCase()}`,onSelect:o(()=>l(g),"onSelect")}));return ve(De,{children:[O("button",{type:"button",disabled:!t||s==="Exporting\u2026","aria-label":"Export diagram",title:"Export diagram",className:"flex size-6 items-center justify-center rounded-md text-muted hover:bg-surface-2 disabled:opacity-40",onClick:g=>{let f=g.currentTarget.getBoundingClientRect();n({x:f.left,y:f.bottom,trigger:g.currentTarget})},children:O(ye,{size:14})}),r?O(a,{...r,label:"Diagram exports",items:i,onClose:()=>n(void 0)}):null,s?O("span",{role:"status",className:"text-muted text-xs",children:s}):null]})},"DiagramExport");import{useLayoutEffect as Le,useRef as Ee,useState as Te}from"react";import{createPortal as Se}from"react-dom";import{jsx as ce,jsxs as we}from"react/jsx-runtime";var V=o(({language:t,layout:r,onChange:n})=>we("fieldset",{"aria-label":"Diagram layout",className:"flex shrink-0 items-center gap-2",title:r==="auto"?"Layout: source setting or ELK default":`Layout: ${A(t).find(s=>s.id===r)?.label??r}`,children:[ce("span",{className:"text-muted text-xs",children:"Layout"}),ce(K,{value:r,options:[...A(t)],onChange:s=>n(s)})]}),"DiagramLayoutButtons");import{Fragment as Ne,jsx as x,jsxs as $}from"react/jsx-runtime";var Ce={width:300,height:150},ue=o(({surface:t,onReturnFocus:r,url:n,size:s,error:c,notice:a,progress:l="Rendering diagram\u2026",source:i,language:g,diagramType:f,layout:D,onLayoutChange:T,onClose:v})=>{let S=Ee(null),[N,P]=Te(Ce),w=s??N,{canvas:M,view:y,fit:F,zoom:R}=se(w);return Le(()=>{let m=S.current;if(!m)return;m.showModal();let L=t.current,u=!1,h=o(()=>{document.fullscreenElement===L?u=!0:u&&v()},"fullscreenChanged");return document.addEventListener("fullscreenchange",h),()=>{document.removeEventListener("fullscreenchange",h),L&&document.fullscreenElement===L&&document.exitFullscreen().catch(()=>{}),m.close(),r()}},[t,r,v]),Se(x("dialog",{ref:S,onCancel:v,onKeyDown:m=>m.stopPropagation(),onTouchStart:m=>m.stopPropagation(),onTouchMove:m=>m.stopPropagation(),"aria-label":"Fullscreen diagram",className:"farero-ui fixed inset-0 m-0 h-full max-h-none w-full max-w-none overflow-hidden overscroll-contain border-0 bg-bg p-0 text-text backdrop:bg-bg",children:$("div",{ref:t,className:"flex h-full w-full flex-col overflow-hidden bg-bg pt-safe pb-safe",children:[x(ee,{title:"Diagram",actions:$(Ne,{children:[x(q,{scale:y.scale,onZoom:R,onFit:F,disabled:!n||!!c}),x(B,{text:i,label:"diagram source",className:"size-8 rounded-full hover:bg-surface-2"}),x(Y,{url:n})]}),onClose:v,closeLabel:"Close fullscreen diagram"}),g==="d2"||f?.startsWith("flowchart")?x("div",{className:"flex shrink-0 items-center border-border-soft border-b px-4 py-2",children:x(V,{language:g,layout:D,onChange:T})}):null,a?x("p",{className:"m-0 px-4 py-2 text-muted text-xs",children:a}):null,x("section",{ref:M,"aria-label":"Diagram canvas","aria-description":"Pinch to zoom and drag or scroll to pan. Keyboard: plus and minus zoom, 0 fits, arrow keys pan.",tabIndex:0,hidden:!!c,className:"relative min-h-0 flex-1 touch-none overflow-hidden overscroll-contain outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",style:{cursor:"grab"},children:n?x("img",{src:n,alt:g==="d2"?"D2 diagram":"Mermaid diagram",draggable:!1,className:"pointer-events-none absolute top-0 left-0 max-w-none origin-top-left select-none",style:{width:w.width,height:w.height,willChange:"transform",transform:`translate(${y.x}px, ${y.y}px) scale(${y.scale})`},onLoad:m=>{let{naturalWidth:L,naturalHeight:u}=m.currentTarget;!s&&L>0&&u>0&&P({width:L,height:u})}}):x("div",{className:"flex h-full items-center justify-center",children:x(H,{label:l,role:"status"})})}),c?$("div",{className:"min-h-0 flex-1 overflow-auto overscroll-contain p-4 text-xs",children:[$("p",{className:"mb-2 whitespace-pre-wrap text-del",children:["Could not render diagram. ",c]}),x("pre",{className:"whitespace-pre-wrap break-words",children:i})]}):null]})}),document.body)},"DiagramFullscreen");import{jsx as b,jsxs as G}from"react/jsx-runtime";function ke(t){let r=t.match(/\bviewBox="([^"]+)"/)?.[1].trim().split(/[\s,]+/),n=r?.length===4?Number(r[2]):NaN,s=r?.length===4?Number(r[3]):NaN;return Number.isFinite(n)&&n>0&&Number.isFinite(s)&&s>0?{width:n,height:s}:void 0}o(ke,"diagramSize");var ge="size-6 shrink-0 rounded-md text-muted transition hover:text-text active:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent",Lt=o(({source:t,language:r})=>{let n=J(null),s=J(null),c=J(null),[a,l]=k(!1),[i,g]=k(null),[f,D]=k(null),[T,v]=k("Rendering diagram\u2026"),[S,N]=k(!1),[P,w]=k(!1),[M,y]=k(()=>te(r)),F=de(()=>w(!1),[]),R=de(()=>{(s.current??n.current)?.focus({preventScroll:!0})},[]);Z(()=>{let u=n.current;if(!u||typeof IntersectionObserver>"u"){l(!0);return}let h=new IntersectionObserver(E=>{E.some(p=>p.isIntersecting)&&(l(!0),h.disconnect())},{rootMargin:"400px"});return h.observe(u),()=>h.disconnect()},[]),Z(()=>{let u=n.current;if(!a||!u)return;let h=o(()=>{let p=le(u);g(z=>JSON.stringify(z)===JSON.stringify(p)?z:p)},"update");h();let E=window.matchMedia("(prefers-color-scheme: dark)");return window.addEventListener(_,h),E.addEventListener("change",h),()=>{window.removeEventListener(_,h),E.removeEventListener("change",h)}},[a]),Z(()=>{if(!a||!i||!t.trim())return;let u=!0,h=new AbortController,E;return D(p=>({source:t,diagramType:p?.source===t?p.diagramType:void 0})),v("Rendering diagram\u2026"),re(t,i,r,M,h.signal,p=>{u&&v(p)}).then(({svg:p,diagramType:z,notice:e})=>{u&&(E=URL.createObjectURL(new Blob([p],{type:"image/svg+xml"})),D({source:t,diagramType:z,url:E,size:ke(p),notice:e}))},p=>{u&&D(z=>({...z,source:t,error:p instanceof Error&&p.message.trim()?p.message:String(p)||"Unknown error"}))}),()=>{u=!1,h.abort(),E&&URL.revokeObjectURL(E)}},[a,t,i,r,M]);let m=f?.source===t?f:null,L=!!m?.url&&!S;return G("figure",{ref:n,tabIndex:-1,className:"chat-diagram farero-ui my-3 overflow-hidden rounded-xl border border-border-soft bg-bg",children:[G("figcaption",{className:"flex min-h-10 flex-wrap items-center gap-2 border-border-soft border-b bg-surface px-2.5 py-1.5 text-muted text-xs",children:[b(K,{value:S||m?.error?"source":"diagram",options:[{id:"diagram",label:"Diagram",disabled:!m?.url},{id:"source",label:"Source"}],onChange:u=>N(u==="source")}),b("span",{children:r==="d2"?"D2":"Mermaid"}),G("div",{className:"ml-auto flex items-center gap-1",children:[r==="d2"||m?.diagramType?.startsWith("flowchart")?b(V,{language:r,layout:M,onChange:y}):null,L?b("button",{ref:s,type:"button",onClick:()=>{ze(()=>w(!0)),document.fullscreenEnabled&&!document.fullscreenElement&&c.current?.requestFullscreen({navigationUI:"hide"}).catch(()=>{})},"aria-label":"Open diagram fullscreen",title:"Fullscreen",className:`flex items-center justify-center ${ge}`,children:b(Me,{size:14})}):null,b(B,{text:t,label:"diagram source",size:14,title:"Copy source",className:ge}),b(Y,{url:m?.url})]})]}),m?.notice?b("p",{className:"!m-0 px-3 pt-2 text-muted text-xs",children:m.notice}):null,m?.error?G("div",{className:"px-3 pt-2 text-xs",children:[b("p",{className:"!mb-1 text-del",children:"Could not render diagram."}),b("p",{className:"!mt-0 max-h-32 overflow-auto overscroll-contain whitespace-pre-wrap break-words text-muted",children:m.error})]}):null,L?b("div",{className:"overflow-x-auto overscroll-x-contain p-4",children:b("img",{src:m.url,alt:r==="d2"?"D2 diagram":"Mermaid diagram",style:{width:m.size?Math.min(m.size.width,4e3):"100%",maxWidth:"100%"},draggable:!1})}):S||m?.error?b("pre",{className:"!m-0 !rounded-none !border-0 overscroll-x-contain",children:b("code",{className:`language-${r}`,children:t})}):b(H,{label:T,className:"min-h-48 py-8 text-xs",role:"status"}),P?b(ue,{surface:c,onReturnFocus:R,url:m?.url,size:m?.size,error:m?.error,notice:m?.notice,progress:T,source:t,language:r,diagramType:m?.diagramType,layout:M,onLayoutChange:y,onClose:F}):null]})},"Diagram");export{Pe as a,A as b,te as c,re as d,I as e,ae as f,j as g,se as h,le as i,Lt as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as t}from"./chunk-5SBKMKFB.js";import{a as e}from"./chunk-3I4YBQX6.js";import{WrapText as l}from"lucide-react";import{jsx as o}from"react/jsx-runtime";var b=e(({pressed:r,onToggle:a,className:i,size:n=16})=>o("button",{type:"button",onClick:a,"aria-pressed":r,"aria-label":r?"Disable word wrap":"Enable word wrap",title:r?"Disable word wrap":"Enable word wrap",className:t("flex size-8 shrink-0 items-center justify-center rounded-full transition active:bg-surface-2",r?"bg-surface-2 text-text":"text-muted",i),children:o(l,{size:n})}),"WordWrapToggle");export{b as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e="farero-theme-settings";export{e as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b}from"./chunk-ZVJQ5X63.js";import{i as g}from"./chunk-CMWS5PI4.js";import{a as x}from"./chunk-WQZ3EUKA.js";import{b as v}from"./chunk-FW2QVWXL.js";import{d as h}from"./chunk-HGN4GN2E.js";import{a as i}from"./chunk-5SBKMKFB.js";import{a as s}from"./chunk-3I4YBQX6.js";import{jsx as w}from"react/jsx-runtime";function z(e){return e.startsWith("+")&&!e.startsWith("+++")?"text-add":e.startsWith("-")&&!e.startsWith("---")?"text-del":e.startsWith("@@")?"text-accent":e.startsWith("diff ")||e.startsWith("index ")||e.startsWith("+++")||e.startsWith("---")?"text-faint":"text-muted"}s(z,"diffLineClass");var y=s(({patch:e})=>w("pre",{className:"!m-0 !rounded-none !border-0 overflow-x-auto overscroll-x-contain font-mono text-[11.5px] leading-[1.5]",children:e.split(`
|
|
2
|
+
`).map((r,o)=>w("div",{className:i("whitespace-pre",z(r)),children:r||" "},o))}),"PlainDiff");function _(e,r){let o=e.toLowerCase();return o==="diff"||o==="patch"?"diff":(o==="svg"||o==="xml")&&/^\s*(?:<\?xml[^>]*>\s*)?<svg\b/i.test(r.slice(0,512))&&/<\/svg>\s*$/i.test(r.slice(-512))?"svg":o==="html"&&/^\s*(?:<!doctype html[^>]*>\s*)?<html\b/i.test(r.slice(0,512))&&/<\/html>\s*$/i.test(r.slice(-512))?"html":"source"}s(_,"fenceKind");import{Download as R}from"lucide-react";import{lazy as S,Suspense as K,useState as N}from"react";import{jsx as t,jsxs as a}from"react/jsx-runtime";var L=S(()=>import("./IsolatedPreview-HJ6B36KF.js")),U=s(({source:e,language:r,kind:o,complete:n,actions:F,renderDiff:p})=>{let[c,W]=N("source"),[f,C]=N(!1),m=e.length<=1048576,d=o!=="source"&&m&&n,P=o==="diff"?"Diff":"Preview",l=t("pre",{className:i("!m-0 !rounded-none !border-0 overflow-x-auto overscroll-x-contain",f&&"whitespace-pre-wrap [overflow-wrap:anywhere]"),children:t("code",{className:r?`language-${r}`:void 0,children:t(g,{text:e,language:n?r:null})})}),u=a("div",{className:"ml-auto flex items-center gap-1","data-document-controls":!0,children:[c==="source"||!d?t(x,{pressed:f,onToggle:()=>C(D=>!D),size:12,className:"size-6 rounded-md hover:bg-surface-2"}):null,F,t("button",{type:"button",title:"Download source","aria-label":"Download code block",className:"flex size-6 items-center justify-center rounded-md text-muted hover:bg-surface-2",onClick:()=>b(e,o==="svg"?"svg":r??"txt"),children:t(R,{size:12})}),t(h,{text:e,label:"code",size:12,className:"size-6 rounded-md"})]});return o==="source"||!n?a("div",{className:"farero-ui group relative my-3 overflow-hidden rounded-xl border border-border-soft bg-bg",children:[l,t("div",{className:"absolute top-1 right-1 rounded-md border border-border-soft bg-bg/90 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100",children:u})]}):a("figure",{className:"farero-ui my-3 overflow-hidden rounded-xl border border-border-soft bg-bg",children:[a("figcaption",{className:"flex min-h-8 flex-wrap items-center gap-2 px-2 py-1 text-muted text-xs","data-document-controls":!0,children:[d?t(v,{value:c,options:[{id:"source",label:"Source"},{id:"rich",label:P}],onChange:W}):t("span",{children:r??"Code"}),u]}),c==="rich"&&d?t(K,{fallback:l,children:o==="diff"?t("div",{className:"max-h-[32rem] overflow-auto overscroll-contain",children:p?p(e):t(y,{patch:e})}):t(L,{source:e,kind:o==="svg"?"svg":"html"})}):l,m?null:t("p",{className:"px-3 text-muted text-xs",children:"Preview unavailable above 1 MiB. Full source can be copied or downloaded."})]})},"RichFence");export{z as a,_ as b,U as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i}from"./chunk-3I4YBQX6.js";function s(a,n){let t=URL.createObjectURL(a),e=document.createElement("a");e.href=t,e.download=n,e.click(),setTimeout(()=>URL.revokeObjectURL(t),3e4)}i(s,"downloadBlob");function m(a,n){let e={javascript:"js",typescript:"ts",shellscript:"sh",python:"py",markdown:"md"}[n]??(n.replace(/[^a-z0-9]/gi,"").slice(0,20)||"txt");s(new Blob([a],{type:"text/plain;charset=utf-8"}),`code.${e}`)}i(m,"downloadSource");function p(a,n){return a.map(t=>t.map(e=>{let r=!/^\s*-?\d+(?:\.\d+)?(?:e[+-]?\d+)?\s*$/i.test(e)&&/^[\s]*[=+@-]/.test(e)?`'${e}`:e;return n===","?`"${r.replace(/"/g,'""')}"`:r.replace(/[\t\r\n]/g," ")}).join(n)).join(`\r
|
|
2
|
+
`)}i(p,"separatedValues");async function h(a,n){if(n==="svg"){s(await(await fetch(a)).blob(),"diagram.svg");return}let t=new Image;t.src=a,await t.decode();let e=Math.min(2,4096/Math.max(t.naturalWidth,t.naturalHeight)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(t.naturalWidth*e)),o.height=Math.max(1,Math.round(t.naturalHeight*e));let r=o.getContext("2d");if(!r)throw new Error("Image export unavailable");r.drawImage(t,0,0,o.width,o.height);let d=await new Promise((g,l)=>o.toBlob(c=>c?g(c):l(new Error("Image export unavailable")),"image/png"));s(d,"diagram.png")}i(h,"exportDiagram");export{s as a,m as b,p as c,h as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-3I4YBQX6.js";var h=class extends Error{static{a(this,"LayoutTimeoutError")}},S=Promise.resolve(),g,T,A,p=new Map;function _(n,s){p.delete(n),p.set(n,s),p.size>4&&p.delete(p.keys().next().value)}a(_,"rememberLayout");function D(){A&&clearTimeout(A),A=void 0}a(D,"clearIdleTimer");function C(n,s){let r=a((e,t)=>e&&Object.hasOwn(t,e)?s[t[e]]:e,"color"),i=a(e=>{e&&(e.color=r(e.color,{N1:"text",N2:"muted"})||s.text,e.labelFill=r(e.labelFill,{B4:"background",B5:"surface",B6:"surface2"}))},"text"),c=a((e,t=!1)=>e?.forEach(m=>{let o=m;if(o.fill=r(o.fill,t?{N7:"background"}:{B4:"background",B5:"surface",B6:"surface2",AA4:"surface",AA5:"surface2",N4:"surface2"})??o.fill,o.stroke=r(o.stroke,{B1:"border",B2:"borderSoft"})??o.stroke,o.color=r(o.color,{N1:"text",N2:"muted"})??o.color,o.labelFill=r(o.labelFill,{B4:"background",B5:"surface",B6:"surface2",AA4:"surface",AA5:"surface2"}),o.type==="image"&&(o.type="rectangle"),o.icon=void 0,o.primaryAccentColor=r(o.primaryAccentColor,{N1:"text",N2:"muted",B1:"text",B2:"text",AA2:"text"}),o.secondaryAccentColor=r(o.secondaryAccentColor,{N1:"text",N2:"muted",B1:"text",B2:"text",AA2:"text"}),o.neutralAccentColor=r(o.neutralAccentColor,{N1:"text",N2:"muted",B1:"border"}),"columns"in o&&Array.isArray(o.columns))for(let y of o.columns)i(y.name),i(y.type)}),"shapes"),l=a(e=>e?.forEach(t=>{t.fill=r(t.fill,{B4:"background",B5:"surface",B6:"surface2",AA4:"surface",AA5:"surface2"}),t.stroke=r(t.stroke,{B1:"muted",B2:"muted"})??t.stroke,t.color=r(t.color,{N1:"text",N2:"muted"})??t.color,t.labelFill=r(t.labelFill,{B4:"background",B5:"surface",B6:"surface2"}),i(t.srcLabel),i(t.dstLabel),t.icon=void 0}),"edges"),u=a((e,t=!1)=>{c(e.shapes),l(e.connections),c(e.legend?.shapes),l(e.legend?.connections),e.root&&c([e.root],t);for(let m of[...e.layers??[],...e.scenarios??[],...e.steps??[]])m&&u(m)},"visit");u(n,!0)}a(C,"recolorDiagram");function N(n){return n.replace(/<\?xml[^>]*>\s*/i,"").replace(/\s(?:href|xlink:href)="https?:[^"]*"/gi,"")}a(N,"passiveSvg");async function O(){D();let n=g;if(g=void 0,!n)return;let s=n.worker,r,i=!1;try{await Promise.race([n.dispose().then(()=>{i=!0},()=>{}),new Promise(l=>{r=setTimeout(l,500)})]);let c=n.worker??s;!i&&typeof Worker<"u"&&c instanceof Worker&&c.terminate()}finally{r&&clearTimeout(r)}}a(O,"disposeWorker");async function v(n){T||(T=import("@d2lang/d2"));let s=T,r;try{r=await s}catch(c){throw T===s&&(T=void 0),c}if(n())throw new DOMException("The operation was aborted","AbortError");g||(g=new r.D2),D();let i=g;if(await i.ready,n())throw new DOMException("The operation was aborted","AbortError");return i}a(v,"getWorker");function x(n,s,r,i){if(n.length>3e4)return Promise.reject(new Error("D2 source exceeds 30000 characters"));if(i?.aborted)return Promise.reject(new DOMException("The operation was aborted","AbortError"));D();let c=S.then(async()=>{if(i?.aborted)throw new DOMException("The operation was aborted","AbortError");let u,e,t,m,o=a(d=>{m=d,t?.(d)},"interrupt"),y=new Promise((d,f)=>{t=f});e=a(()=>o(new DOMException("The operation was aborted","AbortError")),"abort"),i?.addEventListener("abort",e,{once:!0});let k=a(async(d,f,w=2e4)=>{if(m)throw m;u=setTimeout(()=>o(f),w);try{return await Promise.race([d(),y])}finally{clearTimeout(u),u=void 0}},"stage"),E;try{if(E=await k(()=>v(()=>m!==void 0),new Error("D2 engine loading timed out")),i?.aborted)throw new DOMException("The operation was aborted","AbortError");let d=JSON.stringify([r,n]),f=p.get(d);if(f)_(d,f);else{let b=await k(()=>E.compile(n,{layout:r}),new h(`D2 ${r.toUpperCase()} layout timed out`),r==="tala"?6e4:2e4);f={diagram:b.diagram,renderOptions:b.renderOptions},_(d,f)}let w=structuredClone(f.diagram);C(w,s);let{renderOptions:M,notice:L}=f,B=await k(()=>E.render(w,{...M,darkThemeID:void 0,noXMLTag:!0,salt:`farero-${Date.now().toString(36)}`}),new Error("D2 SVG rendering timed out"));return{svg:N(B),diagramType:"d2",notice:L}}catch(d){throw E||(T=void 0),await O(),d}finally{u&&clearTimeout(u),e&&i?.removeEventListener("abort",e)}}),l=c.catch(()=>{});return S=l,c.finally(()=>{S===l&&g&&(D(),A=setTimeout(()=>{O()},3e4))})}a(x,"renderOne");async function R(n,s,r="tala",i,c){try{return await x(n,s,r,i)}catch(l){if(!(l instanceof h)||r!=="tala"||i?.aborted)throw l;c?.("TALA is taking too long. Rendering with ELK\u2026");let u=await x(n,s,"elk",i),e="Showing ELK because TALA took too long.",t=p.get(JSON.stringify(["elk",n]));return t&&_(JSON.stringify([r,n]),{...t,notice:e}),{...u,notice:e}}}a(R,"renderD2");export{R as renderD2};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-ZVJQ5X63.js";import"./chunk-3I4YBQX6.js";export{a as downloadBlob,b as downloadSource,d as exportDiagram,c as separatedValues};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as t}from"./chunk-3I4YBQX6.js";var n=Promise.resolve(),s=0;function g(d,r,e="auto"){let a=n.then(async()=>{let o=(await import("mermaid")).default;o.initialize({startOnLoad:!1,securityLevel:"strict",htmlLabels:!1,suppressErrorRendering:!0,maxTextSize:3e4,maxEdges:300,layout:e==="auto"?"dagre":e,secure:[...o.mermaidAPI.defaultConfig.secure??[],...e==="auto"?[]:["layout"]],look:"classic",theme:"base",fontFamily:r.fontFamily,fontSize:14,elk:{mergeEdges:!1,nodePlacementStrategy:"NETWORK_SIMPLEX",nodePlacementAlignment:"NONE",straightenEdges:!0,lineHops:"gap"},flowchart:{layout:e==="auto"?"elk":e,diagramPadding:8,nodeSpacing:40,rankSpacing:56,padding:12,wrappingWidth:320,curve:"rounded"},themeVariables:{darkMode:r.dark,background:r.background,primaryColor:r.surface,primaryTextColor:r.text,primaryBorderColor:r.border,secondaryColor:r.surface2,secondaryTextColor:r.text,secondaryBorderColor:r.border,tertiaryColor:r.background,tertiaryTextColor:r.text,tertiaryBorderColor:r.borderSoft,clusterBkg:r.background,clusterBorder:r.borderSoft,titleColor:r.muted,edgeLabelBackground:r.background,noteBkgColor:r.surface2,noteTextColor:r.text,noteBorderColor:r.border,lineColor:r.muted,textColor:r.text,fontFamily:r.fontFamily,fontSize:"14px"},themeCSS:`
|
|
2
|
+
.node rect:not([rx]), .node rect[rx="0"] { rx: 8px; ry: 8px; }
|
|
3
|
+
.cluster rect { rx: 12px; ry: 12px; }
|
|
4
|
+
.cluster-label text { font-size: 12px; font-weight: 500; }
|
|
5
|
+
.edgeLabel text { fill: ${r.muted}; font-size: 12px; }
|
|
6
|
+
.flowchart-link { stroke-width: 1.5px; }
|
|
7
|
+
`});let{svg:i,diagramType:l}=await o.render(`farero-diagram-${++s}`,d);return{svg:i,diagramType:l}});return n=a.catch(()=>{}),a}t(g,"renderMermaid");export{g as renderMermaid};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Components } from 'react-markdown';
|
|
2
|
+
|
|
3
|
+
/** Bytes the reader holds for a workspace image, at the size the chat draws it. */
|
|
4
|
+
interface ReadonlyImageSource {
|
|
5
|
+
src: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
interface ReadonlyComponentsOptions {
|
|
10
|
+
/** Open a linked workspace file. Absent, file links render as static code. */
|
|
11
|
+
onOpenFile?: (path: string) => void;
|
|
12
|
+
/** Known relative paths supplied by the reader, without a live workspace lookup. */
|
|
13
|
+
filePaths?: readonly string[];
|
|
14
|
+
/** Workspace images the reader can draw, keyed by the path a message embeds. */
|
|
15
|
+
images?: Readonly<Record<string, ReadonlyImageSource>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The static component map for host-independent readers: the same markdown
|
|
19
|
+
* pipeline as the live chat, with links, code and images that need no relay,
|
|
20
|
+
* store or router. `onOpenFile` lets the host open linked workspace files.
|
|
21
|
+
*/
|
|
22
|
+
declare function createReadonlyComponents(options?: ReadonlyComponentsOptions): Components;
|
|
23
|
+
declare const ReadonlyMarkdownComponents: Components;
|
|
24
|
+
|
|
25
|
+
export { ReadonlyMarkdownComponents as b, createReadonlyComponents as c };
|
|
26
|
+
export type { ReadonlyComponentsOptions as R, ReadonlyImageSource as a };
|
package/dist/cn.d.ts
ADDED
package/dist/cn.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunks/chunk-5SBKMKFB.js";import"./chunks/chunk-3I4YBQX6.js";export{a as cn};
|
package/dist/code.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { ThemedToken } from 'shiki/core';
|
|
4
|
+
|
|
5
|
+
/** Called only for an expanded tool body; closed summaries never inspect the payload. */
|
|
6
|
+
declare function languageForTool(tool: string | undefined, detail?: string): string | null;
|
|
7
|
+
declare function languageForPath(filePath: string): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The CodeMirror language group for a Shiki language, or null for plain text.
|
|
10
|
+
* The editor deliberately ships only three Lezer grammars; read-only surfaces
|
|
11
|
+
* use the wider lazy Shiki registry above.
|
|
12
|
+
*/
|
|
13
|
+
declare function cmLanguageGroup(language: string | null): 'javascript' | 'python' | 'markdown' | null;
|
|
14
|
+
/** Read results use their file's language; structured results from any tool use JSON. */
|
|
15
|
+
declare function languageForToolOutput(tool: string | undefined, detail: string | undefined, output?: string): string | null;
|
|
16
|
+
/** react-markdown gives a fence its info string as `language-<name>` on the code element. */
|
|
17
|
+
declare function languageForFence(className: string | undefined): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Tokenize into Shiki's line-preserving token arrays. Callers keep rendering the
|
|
20
|
+
* original text until this resolves, and retain plain text if a grammar fails.
|
|
21
|
+
*/
|
|
22
|
+
declare function highlightLines(code: string, language: string | null): Promise<ThemedToken[][] | null>;
|
|
23
|
+
/** A single code block flattened without losing the newlines between Shiki rows. */
|
|
24
|
+
declare function highlightCode(code: string, language: string | null): Promise<ThemedToken[] | null>;
|
|
25
|
+
type SyntaxToken = ThemedToken;
|
|
26
|
+
|
|
27
|
+
interface TokensProps {
|
|
28
|
+
tokens: SyntaxToken[];
|
|
29
|
+
}
|
|
30
|
+
declare const Tokens: FC<TokensProps>;
|
|
31
|
+
/**
|
|
32
|
+
* A block of code, coloured when its language is one of the registered few.
|
|
33
|
+
*
|
|
34
|
+
* `memo` keeps transcript polling from restarting async tokenisation for settled rows.
|
|
35
|
+
* Plain text remains visible while the grammar loads; failure leaves that fallback in
|
|
36
|
+
* place rather than blocking or blanking the transcript.
|
|
37
|
+
*/
|
|
38
|
+
declare const Code: react.NamedExoticComponent<{
|
|
39
|
+
text: string;
|
|
40
|
+
language: string | null;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
export { Code, Tokens, cmLanguageGroup, highlightCode, highlightLines, languageForFence, languageForPath, languageForTool, languageForToolOutput };
|
|
44
|
+
export type { SyntaxToken, TokensProps };
|
package/dist/code.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as o,b as e,c as g,d as a,e as n,f as r,g as t,h as l,i as u}from"./chunks/chunk-CMWS5PI4.js";import"./chunks/chunk-CXEEHWHD.js";import"./chunks/chunk-3I4YBQX6.js";export{u as Code,l as Tokens,g as cmLanguageGroup,t as highlightCode,r as highlightLines,n as languageForFence,e as languageForPath,o as languageForTool,a as languageForToolOutput};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ReactNode, FC } from 'react';
|
|
2
|
+
import { LucideIcon } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keyboard chords and how they read on each platform. Pure, so the command palette,
|
|
6
|
+
* the app's tips, the website's tips page and the Studio share one spelling of a
|
|
7
|
+
* chord without loading the command registry.
|
|
8
|
+
*/
|
|
9
|
+
interface Shortcut {
|
|
10
|
+
/** A `KeyboardEvent.key` value, compared case-insensitively. */
|
|
11
|
+
key: string;
|
|
12
|
+
/** ⌘ on Apple platforms, Ctrl elsewhere. */
|
|
13
|
+
mod?: boolean;
|
|
14
|
+
/** The Control key on every platform, Mac included. */
|
|
15
|
+
ctrl?: boolean;
|
|
16
|
+
shift?: boolean;
|
|
17
|
+
alt?: boolean;
|
|
18
|
+
/** A browser handles this chord itself and the page never sees it, so only the desktop window binds it. */
|
|
19
|
+
browserReserved?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The desktop menu's accelerator owns this chord and sends the intent over the bridge.
|
|
22
|
+
* The window listener leaves it alone, or the menu and the listener would both run it;
|
|
23
|
+
* the palette still draws the caps.
|
|
24
|
+
*/
|
|
25
|
+
nativeMenu?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Key-cap glyphs for a `<kbd>` row. Apple's own order is ⌃ ⌥ ⇧ ⌘; everything else
|
|
29
|
+
* spells the words out, Ctrl first. An empty key leaves the modifiers alone, for a
|
|
30
|
+
* modifier-click such as ⌘-click.
|
|
31
|
+
*/
|
|
32
|
+
declare function formatShortcut(shortcut: Shortcut, apple: boolean): string[];
|
|
33
|
+
/** A chord as prose, for copy that names it: ⌃Z on Apple platforms, Alt+Z elsewhere. */
|
|
34
|
+
declare function shortcutText(shortcut: Shortcut, apple: boolean): string;
|
|
35
|
+
/** Mac, iPhone or iPad — where ⌘ exists. Read off the platform string, guarded for tests. */
|
|
36
|
+
declare function isApplePlatform(nav?: {
|
|
37
|
+
platform?: string;
|
|
38
|
+
userAgent?: string;
|
|
39
|
+
} | undefined): boolean;
|
|
40
|
+
/** What decides whether a chord can reach the page. */
|
|
41
|
+
interface ShortcutPlatform {
|
|
42
|
+
/** Mac, iPhone or iPad, where ⌘ exists. */
|
|
43
|
+
apple: boolean;
|
|
44
|
+
/** The trusted desktop window, where no browser takes chords first. */
|
|
45
|
+
desktop: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** The modifier state of a keydown, without dragging the DOM's KeyboardEvent into tests. */
|
|
48
|
+
interface KeyChord {
|
|
49
|
+
key: string;
|
|
50
|
+
metaKey: boolean;
|
|
51
|
+
ctrlKey: boolean;
|
|
52
|
+
shiftKey: boolean;
|
|
53
|
+
altKey: boolean;
|
|
54
|
+
}
|
|
55
|
+
declare function matchesShortcut(chord: KeyChord, shortcut: Shortcut, apple: boolean): boolean;
|
|
56
|
+
/** Whether this chord reaches the page here. The listener and the palette's key caps both ask this. */
|
|
57
|
+
declare function shortcutAvailable(shortcut: Shortcut, platform: ShortcutPlatform): boolean;
|
|
58
|
+
|
|
59
|
+
interface Command {
|
|
60
|
+
/** Stable id — `view.statuses.all`, `app.connect`, `workspace.status.done`. */
|
|
61
|
+
id: string;
|
|
62
|
+
label: string;
|
|
63
|
+
/** Breadcrumb prefix ("View › Show all statuses") and section heading. */
|
|
64
|
+
group?: string;
|
|
65
|
+
/** Extra search terms: ['status filter', 'clear'] on Show all statuses. */
|
|
66
|
+
keywords?: string[];
|
|
67
|
+
icon?: LucideIcon;
|
|
68
|
+
/** Drawn in the icon slot instead of `icon`, for a mark that is not a Lucide icon: a repository's own glyph. */
|
|
69
|
+
glyph?: ReactNode;
|
|
70
|
+
shortcut?: Shortcut;
|
|
71
|
+
/** Toggle or choice state. Set, the row draws a check and reads as a checkbox item. */
|
|
72
|
+
checked?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Submenu rows. Desktop opens an adjacent panel on hover or activation;
|
|
75
|
+
* touch layouts drill into the list. The rows appear only in that submenu: a
|
|
76
|
+
* query that matches one lists this parent, and the submenu marks the row
|
|
77
|
+
* (`submenuHits`).
|
|
78
|
+
*/
|
|
79
|
+
children?: Command[];
|
|
80
|
+
/** A short note beside the label. */
|
|
81
|
+
detail?: string;
|
|
82
|
+
/** False omits the row and silences its shortcut. Default true. */
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
/** Registered for its shortcut alone — the Search command itself is one. */
|
|
85
|
+
hidden?: boolean;
|
|
86
|
+
run: () => void | Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The listed top-level commands that match `query`, best first. An empty query lists
|
|
90
|
+
* everything that can be shown, and that is the browsable menu. Submenu rows stay in
|
|
91
|
+
* their submenu whatever the query: a row that matches lists its parent, ranked by
|
|
92
|
+
* that row, and `submenuHits` names the row inside the submenu. Hidden and disabled
|
|
93
|
+
* commands never appear.
|
|
94
|
+
*/
|
|
95
|
+
declare function matchCommands(commands: Command[], query: string): Command[];
|
|
96
|
+
/**
|
|
97
|
+
* The rows of `parent`'s submenu that `query` names more closely than `parent` itself,
|
|
98
|
+
* in menu order. A row that repeats its parent's words ("group by" on every Group by
|
|
99
|
+
* choice) matches whenever the parent does, so only a closer match counts. A row whose
|
|
100
|
+
* own submenu holds a hit counts too, which keeps the path to a nested hit marked.
|
|
101
|
+
*/
|
|
102
|
+
declare function submenuHits(parent: Command, query: string): Command[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The palette's action rows, above the chat results in the search sheet.
|
|
106
|
+
*
|
|
107
|
+
* Two shapes. Browsing (no query, or a `>` query) draws one section per group, headed
|
|
108
|
+
* by the group's name, so the list reads as the menus it replaces: Workspace, View,
|
|
109
|
+
* App. Searching draws one "Actions" section and puts the group on the row as a
|
|
110
|
+
* breadcrumb ("View › Show all statuses"), because a hit from three groups at once needs to
|
|
111
|
+
* say where each came from.
|
|
112
|
+
*
|
|
113
|
+
* Rows are real buttons carrying `data-palette-row`, which is all the sheet's arrow
|
|
114
|
+
* keys need: focus moves between rows, Enter is the button's own click, and a screen
|
|
115
|
+
* reader hears a menu item with a checked state where there is one. A row with
|
|
116
|
+
* submenu children draws a chevron instead of a check and reads as a menu item
|
|
117
|
+
* with a submenu — the sheet opens a side panel or a touch drilldown rather than running it.
|
|
118
|
+
* Inside a submenu, a row the query named draws its label as a search hit and carries
|
|
119
|
+
* `data-palette-hit`, which is where the sheet sends Enter and focus.
|
|
120
|
+
*
|
|
121
|
+
* The key caps are hidden on narrow screens. A phone without a keyboard has nothing
|
|
122
|
+
* to press, and "⌘K" beside every row is noise on the one screen where width is short.
|
|
123
|
+
* A chord this platform never delivers (⌘T in a browser tab) draws no caps at all; the
|
|
124
|
+
* row still runs from the palette.
|
|
125
|
+
*/
|
|
126
|
+
interface CommandResultsProps {
|
|
127
|
+
commands: Command[];
|
|
128
|
+
grouped: boolean;
|
|
129
|
+
/** Draws ⌘ or Ctrl, and hides the caps of chords this platform never delivers. */
|
|
130
|
+
platform: ShortcutPlatform;
|
|
131
|
+
onRun: CommandRowProps['onRun'];
|
|
132
|
+
onHover?: CommandRowProps['onHover'];
|
|
133
|
+
expandedId?: string;
|
|
134
|
+
}
|
|
135
|
+
declare const CommandResults: FC<CommandResultsProps>;
|
|
136
|
+
/** One heading style for every section of the sheet, actions and chats alike. */
|
|
137
|
+
interface PaletteHeadingProps {
|
|
138
|
+
children: ReactNode;
|
|
139
|
+
}
|
|
140
|
+
declare const PaletteHeading: FC<PaletteHeadingProps>;
|
|
141
|
+
interface CommandRowProps {
|
|
142
|
+
command: Command;
|
|
143
|
+
platform: ShortcutPlatform;
|
|
144
|
+
breadcrumb: boolean;
|
|
145
|
+
onRun: (command: Command, anchor: HTMLButtonElement) => void;
|
|
146
|
+
onHover?: (command: Command, anchor: HTMLButtonElement) => void;
|
|
147
|
+
expanded?: boolean;
|
|
148
|
+
/** A submenu row the query named more closely than its parent (`submenuHits`). */
|
|
149
|
+
hit?: boolean;
|
|
150
|
+
/** Identifies the active option when a listbox keeps keyboard focus in its input. */
|
|
151
|
+
option?: {
|
|
152
|
+
id: string;
|
|
153
|
+
selected: boolean;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
declare const CommandRow: FC<CommandRowProps>;
|
|
157
|
+
|
|
158
|
+
export { CommandResults, CommandRow, PaletteHeading, formatShortcut, isApplePlatform, matchCommands, matchesShortcut, shortcutAvailable, shortcutText, submenuHits };
|
|
159
|
+
export type { Command, CommandResultsProps, CommandRowProps, KeyChord, PaletteHeadingProps, Shortcut, ShortcutPlatform };
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S,b as v,c as H}from"./chunks/chunk-S3DX6DGB.js";import{d as b,e as w}from"./chunks/chunk-CXEEHWHD.js";import{a as h}from"./chunks/chunk-5SBKMKFB.js";import{a as r}from"./chunks/chunk-3I4YBQX6.js";import{Check as z,ChevronRight as E}from"lucide-react";var A={ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192"};function m(e,t){let n=A[e.key]??(e.key.length===1?e.key.toUpperCase():e.key),o=n?[n]:[];return t?[...e.ctrl?["\u2303"]:[],...e.alt?["\u2325"]:[],...e.shift?["\u21E7"]:[],...e.mod?["\u2318"]:[],...o]:[...e.mod||e.ctrl?["Ctrl"]:[],...e.alt?["Alt"]:[],...e.shift?["Shift"]:[],...o]}r(m,"formatShortcut");function L(e,t){return m(e,t).join(t?"":"+")}r(L,"shortcutText");function T(e=typeof navigator>"u"?void 0:navigator){return/Mac|iPhone|iPad|iPod/i.test(`${e?.platform??""} ${e?.userAgent??""}`)}r(T,"isApplePlatform");function $(e,t,n){if(e.key.toLowerCase()!==t.key.toLowerCase())return!1;let o=!!t.mod;return e.metaKey===(n&&o)&&e.ctrlKey===(!n&&o||!!t.ctrl)&&e.shiftKey===!!t.shift&&e.altKey===!!t.alt}r($,"matchesShortcut");function g(e,t){return!(e.browserReserved&&!t.desktop)}r(g,"shortcutAvailable");import{jsx as s,jsxs as p}from"react/jsx-runtime";var F=r(({commands:e,grouped:t,platform:n,onRun:o,onHover:a,expandedId:i})=>{if(!e.length)return null;let c=t?I(e):[{label:"Actions",commands:e}];return s("div",{className:"farero-ui flex flex-col gap-2 pb-2",children:c.map(l=>p("section",{"aria-label":l.label,children:[s(N,{children:l.label}),s("div",{role:"menu","aria-label":l.label,className:"flex flex-col",children:l.commands.map(d=>s(K,{command:d,platform:n,breadcrumb:!t,onRun:o,onHover:a,expanded:i===d.id},d.id))})]},l.label))})},"CommandResults"),N=r(({children:e})=>s(S,{as:"h3",className:"px-2.5 pb-1",children:e}),"PaletteHeading");function I(e){let t=new Map;for(let n of e){let o=n.group??"Actions",a=t.get(o);a?a.push(n):t.set(o,[n])}return[...t].map(([n,o])=>({label:n,commands:o}))}r(I,"groupSections");var K=r(({command:e,platform:t,breadcrumb:n,onRun:o,onHover:a,expanded:i=!1,hit:c=!1,option:l})=>{let d=e.icon,k=e.shortcut&&g(e.shortcut,t)?e.shortcut:void 0,f=!!(e.children?.length?e.children.filter(u=>!u.hidden&&u.enabled!==!1):void 0)?.length,P=!f&&e.checked!==void 0,R=`${n&&e.group?`${e.group} \u203A `:""}${e.label}${e.detail?` \xB7 ${e.detail}`:""}`;return p("button",{type:"button",...l?{id:l.id,role:"option","aria-selected":l.selected,"aria-label":R,tabIndex:-1}:P?{role:"menuitemcheckbox","aria-checked":!!e.checked}:f?{role:"menuitem","aria-haspopup":"menu","aria-expanded":i,"data-palette-submenu":""}:{role:"menuitem"},"data-palette-row":"","data-palette-hit":c?"":void 0,"data-command-id":e.id,onClick:u=>o(e,u.currentTarget),onPointerEnter:u=>{u.pointerType!=="touch"&&a?.(e,u.currentTarget)},className:h("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left text-sm text-text hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none active:bg-surface-2",(i||l?.selected)&&"bg-surface-2"),children:[e.glyph?s("span",{className:"flex size-4 shrink-0 items-center justify-center text-muted","aria-hidden":!0,children:e.glyph}):d?s(d,{size:16,className:"shrink-0 text-muted","aria-hidden":!0}):s("span",{className:"size-4 shrink-0","aria-hidden":!0}),p("span",{className:"min-w-0 flex-1 truncate",title:R,children:[n&&e.group?p("span",{className:"text-muted",children:[e.group," \u203A "]}):null,c?s(v,{className:"-mx-0.5",children:e.label}):e.label,e.detail?s("span",{className:"ml-2 text-faint text-xs",children:e.detail}):null]}),k?s(j,{parts:m(k,t.apple)}):null,P?s(B,{checked:!!e.checked}):null,f?s(E,{size:16,className:"shrink-0 text-faint","aria-hidden":!0}):null]})},"CommandRow"),j=r(({parts:e})=>s("span",{className:"hidden shrink-0 items-center gap-0.5 md:flex",children:e.map(t=>s(H,{children:t},t))}),"KeyCaps"),B=r(({checked:e})=>s("span",{"aria-hidden":!0,className:h("flex size-4 shrink-0 items-center justify-center rounded border",e?"border-accent bg-accent text-on-solid":"border-faint bg-surface"),children:e?s(z,{size:12,strokeWidth:3}):null}),"CheckMark");function U(e){return[e.group,e.label,...e.keywords??[]].filter(Boolean).join(" ").toLowerCase()}r(U,"haystack");function y(e){return!e.hidden&&e.enabled!==!1}r(y,"listed");function M(e,t){let n=w(U(e),t);if(n==null)return;let o=e.label.toLowerCase(),a=o.startsWith(t[0])?0:t.every(i=>o.includes(i))?1:2;return{proximity:n,surface:a}}r(M,"rankCommand");function C(e,t,n){return n.length===1?e.surface-t.surface:e.proximity-t.proximity||e.surface-t.surface}r(C,"compareRanks");function x(e,t){let n=M(e,t);for(let o of e.children??[]){if(!y(o))continue;let a=x(o,t);a&&(!n||C(a,n,t)<0)&&(n=a)}return n}r(x,"branchRank");function W(e,t){let n=e.filter(y),o=b(t);if(!o.length)return n;let a=[];for(let i of n){let c=x(i,o);c&&a.push({command:i,rank:c})}return a.sort((i,c)=>C(i.rank,c.rank,o)).map(i=>i.command)}r(W,"matchCommands");function Y(e,t){let n=b(t);if(!n.length)return[];let o=M(e,n);return(e.children??[]).filter(a=>{if(!y(a))return!1;let i=x(a,n);return!!i&&(!o||C(i,o,n)<0)})}r(Y,"submenuHits");export{F as CommandResults,K as CommandRow,N as PaletteHeading,m as formatShortcut,T as isApplePlatform,W as matchCommands,$ as matchesShortcut,g as shortcutAvailable,L as shortcutText,Y as submenuHits};
|