@av-pi-studio/web-client 0.0.119 → 0.0.120
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/dist/web/assets/{BinaryFallbackViewer-DZ6fyGsu.js → BinaryFallbackViewer-Ct7gB8Zj.js} +1 -1
- package/dist/web/assets/{ChatPanel-yRv-CSyg.js → ChatPanel-Bw7Hb7zc.js} +1 -1
- package/dist/web/assets/{CodeView-HA63pf1I.js → CodeView-BWjIMXx_.js} +1 -1
- package/dist/web/assets/{FilePanel-KbN8R1q4.js → FilePanel-nx2ZNCzw.js} +1 -1
- package/dist/web/assets/{HtmlViewer-BlBKng1E.js → HtmlViewer-CNhiAwz_.js} +1 -1
- package/dist/web/assets/{ImageViewer-CSOSyfvS.js → ImageViewer-5NK0vbNf.js} +1 -1
- package/dist/web/assets/{MarkdownFileViewer-lxpM7SOl.js → MarkdownFileViewer-C9TjyaOy.js} +1 -1
- package/dist/web/assets/{ModelProvidersPanel-CB3LnoWb.js → ModelProvidersPanel-DaSeQAGS.js} +1 -1
- package/dist/web/assets/{MoleculeViewerPanel-B2E7mzSf.js → MoleculeViewerPanel-DCSVt-5q.js} +1 -1
- package/dist/web/assets/{PdfViewer-DhWWrlIg.js → PdfViewer-D3wY27_O.js} +1 -1
- package/dist/web/assets/{SaveFileButton-B7-DaZRk.js → SaveFileButton-D4L2yJ4C.js} +1 -1
- package/dist/web/assets/{SettingsDialog-PvCzy46o.js → SettingsDialog-SEYpCTXv.js} +1 -1
- package/dist/web/assets/{SkillsPanel-BAOCx8Mk.js → SkillsPanel-i5O4j8TT.js} +1 -1
- package/dist/web/assets/{TerminalPanel-D7OImgct.js → TerminalPanel-teco8hQm.js} +1 -1
- package/dist/web/assets/{TextViewer-BYKfoK_A.js → TextViewer-Dc4_Pm2d.js} +1 -1
- package/dist/web/assets/{VideoViewer-D5zXCCTy.js → VideoViewer-DKa99m9b.js} +1 -1
- package/dist/web/assets/{ViewersPanel-CcXyTny7.js → ViewersPanel-TDwABaMu.js} +1 -1
- package/dist/web/assets/{href-resolution-73JOZBv8.js → href-resolution-pg8AZoGq.js} +1 -1
- package/dist/web/assets/{index-DFue5iwi.js → index-B6VaYU8s.js} +5 -5
- package/dist/web/assets/{markdown-CIs21q13.js → markdown-CPP5yk_k.js} +1 -1
- package/dist/web/assets/{use-file-download-DXQ8x6cp.js → use-file-download-Db9Jkq8L.js} +1 -1
- package/dist/web/assets/{use-file-watch-Bi_rtv7D.js → use-file-watch-D3DZUhpX.js} +1 -1
- package/dist/web/assets/{use-provider-auth-list-Bxn9HTsw.js → use-provider-auth-list-B3AMWkI0.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +3 -3
package/dist/web/assets/{BinaryFallbackViewer-DZ6fyGsu.js → BinaryFallbackViewer-Ct7gB8Zj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./vendor-react-Dka9ZH0B.js";import{S as o}from"./SaveFileButton-
|
|
1
|
+
import{j as i}from"./vendor-react-Dka9ZH0B.js";import{S as o}from"./SaveFileButton-D4L2yJ4C.js";import{F as n}from"./vendor-icons-CSCeICuX.js";import"./index-B6VaYU8s.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const t="_wrap_inn1j_1",a="_name_inn1j_12",e={wrap:t,name:a};function _({path:r,workspaceCwd:m}){const s=r.split("/").pop()||r;return i.jsxs("div",{className:e.wrap,children:[i.jsx(n,{size:32}),i.jsx("div",{className:e.name,children:s}),i.jsx("div",{children:"No preview available for this file type."}),i.jsx(o,{path:r})]})}export{_ as BinaryFallbackViewer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,j as t}from"./vendor-react-Dka9ZH0B.js";import{a as cn,b as ln,m as dn,u as Le}from"./vendor-query-CDNPrdQ8.js";import{O as Be,Q as M,R as un,u as J,U as mn,I as O,W as fn,X as pn,B as z,y as hn,Y as _t,S as ne,J as _n,D as gn,z as xn,Z as gt,s as xt,n as kt,_ as kn,$ as vn,a0 as jn,q as vt,a1 as yn,E as bn,a2 as ve,r as Oe,a3 as Ie,a4 as Nn,a5 as fe,k as Sn,a6 as Cn,a7 as ke,a8 as wn,a9 as Dn,aa as Tn,ab as rt,ac as En,K as Bn,ad as Rn,ae as An,af as it,ag as Ln,P as ct}from"./index-
|
|
1
|
+
import{r as h,j as t}from"./vendor-react-Dka9ZH0B.js";import{a as cn,b as ln,m as dn,u as Le}from"./vendor-query-CDNPrdQ8.js";import{O as Be,Q as M,R as un,u as J,U as mn,I as O,W as fn,X as pn,B as z,y as hn,Y as _t,S as ne,J as _n,D as gn,z as xn,Z as gt,s as xt,n as kt,_ as kn,$ as vn,a0 as jn,q as vt,a1 as yn,E as bn,a2 as ve,r as Oe,a3 as Ie,a4 as Nn,a5 as fe,k as Sn,a6 as Cn,a7 as ke,a8 as wn,a9 as Dn,aa as Tn,ab as rt,ac as En,K as Bn,ad as Rn,ae as An,af as it,ag as Ln,P as ct}from"./index-B6VaYU8s.js";import{L as On,G as In,S as Pn,e as qn,P as zn,f as Fn,g as jt,h as ye,C as pe,B as Mn,i as yt,b as he,A as $n,j as Kn,k as Hn,U as Wn,l as bt,m as Un,n as Gn,o as Vn,p as Xn,q as lt,r as Yn,N as Jn,s as Qn,t as Zn}from"./vendor-icons-CSCeICuX.js";import{u as es}from"./use-provider-auth-list-B3AMWkI0.js";import{N as w}from"./vendor-z183l2lP.js";import{S as Nt,M as Pe,r as ts}from"./markdown-CPP5yk_k.js";import{D as ns,p as ss}from"./DiffView-Bp1YwIcs.js";import{R as qe,T as ze,I as St}from"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";import"./vendor-highlight-DaCUEPaW.js";import"./vendor-markdown-Bo-Xpsuy.js";import"./href-resolution-pg8AZoGq.js";function Ct(e,n){if(n.trim()==="")return e;const s=n.toLowerCase();return e.filter(o=>o.label.toLowerCase().includes(s)||o.description!==void 0&&o.description.toLowerCase().includes(s))}function os(e,n={}){const s=new Map;for(const m of e){const u=m.group??"",f=s.get(u);f?f.push(m):s.set(u,[m])}const o=s.get("");s.delete("");const a=[...s.keys()],{priorityGroup:i,ungroupedLabel:c}=n;i!==void 0&&s.has(i)&&(a.splice(a.indexOf(i),1),a.unshift(i));const l=a.map(m=>({key:m,label:m,options:s.get(m)??[]}));return o&&l.push({key:"",label:c,options:o}),l}const as={shell:jt,read:Fn,edit:zn,write:qn,search:Pn,fetch:In,task:On};function rs(e){return as[e.kind]??jt}function wt(e){switch(e.kind){case"read":case"write":case"edit":return e.path??null;default:return null}}function is(e){return e.kind==="write"||e.kind==="edit"||e.kind==="shell"}function cs(e){const n=[];if(e.kind==="edit"&&e.diff)n.push({kind:"diff",patch:e.diff});else{const s=Be(e);s&&n.push({kind:"code",text:s})}return e.output&&n.push({kind:"code",text:e.output}),n}const dt={shell:{label:"SHELL",token:"statusInfo"},read:{label:"READ",token:"statusInfo"},write:{label:"WRITE",token:"statusSuccess"},edit:{label:"EDIT",token:"statusWarning"},search:{label:"SEARCH",token:"statusInfo"},fetch:{label:"FETCH",token:"statusInfo"},task:{label:"TASK",token:"foregroundMuted"}};function ls(e){return dt[e.kind]??dt.task}function ds(e){if(!e)return{added:0,removed:0};let n=0,s=0;for(const o of e.split(`
|
|
2
2
|
`))o.startsWith("+++")||o.startsWith("---")||(o.startsWith("+")?n++:o.startsWith("-")&&s++);return{added:n,removed:s}}function us(e){return e?(e.endsWith(`
|
|
3
3
|
`)?e.slice(0,-1):e).split(`
|
|
4
4
|
`).length:0}const ms=500;let we;function fs(e,n,s,o){clearTimeout(we),we=setTimeout(()=>{we=void 0,e.invalidateQueries({queryKey:["file"]}),e.invalidateQueries({queryKey:["explorer"]}),n&&s&&n.connection.request("checkout_refresh_request",{cwd:s}).catch(()=>{})},ms)}function ps({sessionId:e,event:n,timestamp:s,client:o,queryClient:a}){const i=M.getState();switch(i.applyStreamEvent(e,n,s),n.kind){case"turn_started":i.setStatus(e,"running");break;case"turn_completed":i.setStatus(e,"idle");break;case"turn_failed":i.setStatus(e,"error");break;case"turn_canceled":i.setStatus(e,"idle");break;case"compaction":n.phase==="completed"&&n.estimatedTokensAfter!==void 0&&un(e,n.estimatedTokensAfter);break;case"tool_call":{if(n.status==="completed"&&is(n.tool)){const c=i.sessions[e],l=(c==null?void 0:c.cwd)||null;fs(a,o,l,wt(n.tool))}break}}}function hs(e){const n=J(a=>a.client),s=M(a=>{var i;return((i=a.sessions[e])==null?void 0:i.agentId)??null}),o=cn();h.useEffect(()=>!n||!s?void 0:n.agent(s).timeline.subscribe((i,c)=>{const l=typeof c.timestamp=="number"?new Date(c.timestamp).toISOString():c.timestamp;ps({sessionId:e,event:i,timestamp:l,client:n,queryClient:o})}),[n,s,e,o])}const Dt=64;function De(e){return e.clientHeight>0}function _s(e,n,s,o=Dt){switch(n.kind){case"scroll":return De(s)?s.scrollHeight-s.scrollTop-s.clientHeight<=o?{pinned:!0,stick:!1}:{pinned:n.gesture?!1:e,stick:!1}:{pinned:e,stick:!1};case"tail":return{pinned:e,stick:e&&De(s)};case"shown":return{pinned:e,stick:e};case"pin":return{pinned:!0,stick:De(s)}}}function gs(e){const n=e[e.length-1];return(n==null?void 0:n.kind)==="user"?n.id:null}const xs="_shellRow_1kabp_2",ks="_rail_1kabp_10",vs="_disc_1kabp_18",js="_connector_1kabp_28",ys="_content_1kabp_2",bs="_metaLine_1kabp_40",Ns="_metaTime_1kabp_52",Ss="_forkButton_1kabp_66",U={shellRow:xs,rail:ks,disc:vs,connector:js,content:ys,metaLine:bs,metaTime:Ns,forkButton:Ss};function X({disc:e,discClassName:n,connector:s,meta:o,metaTrailing:a,className:i,children:c}){return t.jsxs("div",{className:U.shellRow,children:[t.jsxs("div",{className:U.rail,children:[t.jsx("span",{className:w(U.disc,n),children:e}),s&&t.jsx("span",{className:U.connector})]}),t.jsxs("div",{className:w(U.content,i),children:[o&&t.jsxs("div",{className:U.metaLine,children:[o,a]}),c]})]})}function ut(e){return typeof e=="number"?e:Date.parse(e)}function Cs(e,n){const s=ut(e.entry.createdAt),o=ut(n.entry.createdAt);return s!==o?s-o:e.entry.requestId<n.entry.requestId?-1:e.entry.requestId>n.entry.requestId?1:0}function ws(e,n){return[...e.map(o=>({kind:"pending",entry:o})),...n.map(o=>({kind:"resolved",entry:o}))].toSorted(Cs)}function Ds(e){return e.entry.requestId}function Tt(e){return e.receivedAt===void 0}const Ts=4;function Es(e,n){let s=0;const o=e.map(l=>l.kind!=="pending"?{item:l,collapsed:!1}:(s++,{item:l,collapsed:!n&&s>Ts})),a=o.filter(l=>l.collapsed).length,i=o.findIndex(l=>l.collapsed),c=[];return o.forEach((l,m)=>{m===i&&c.push({kind:"more",count:a}),c.push({kind:"card",item:l.item,collapsed:l.collapsed})}),c}function Bs(e,n){if(e.timeoutMs===void 0)return{show:!1,fraction:0,approximate:!1};const s=mn(e,n)??0;return{show:!0,fraction:Math.max(0,Math.min(1,s/e.timeoutMs)),approximate:e.receivedAt===void 0}}function Et(e){return e==="editor"}const Rs="Esc again to dismiss — the extension gets an empty answer";function As(e,n){return n?{kind:"warning",text:Rs}:{kind:"keys",segments:[{key:Et(e)?"⇧↵":"↵",label:"submit"},{key:"Esc",label:"dismiss"}]}}function Ls(e){return e?{armed:!1,resolve:!0}:{armed:!0,resolve:!1}}const Os=5,Is=40,Ps=6;function qs(e){return{mode:e.length>=Os||e.some(s=>s.length>Is)?"stack":"row",scrolls:e.length>Ps}}function Re(e){const n=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var L=Object.defineProperty;var w=(r,t,e)=>t in r?L(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t,e)=>w(r,typeof t!="symbol"?t+"":t,e);import{u as g}from"./vendor-query-CDNPrdQ8.js";import{u as p,r as m}from"./index-
|
|
1
|
+
var L=Object.defineProperty;var w=(r,t,e)=>t in r?L(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t,e)=>w(r,typeof t!="symbol"?t+"":t,e);import{u as g}from"./vendor-query-CDNPrdQ8.js";import{u as p,r as m}from"./index-B6VaYU8s.js";import{u as y}from"./use-file-download-Db9Jkq8L.js";import{j as c,r as u}from"./vendor-react-Dka9ZH0B.js";import{Q as x,S as h,T as k,U as F,V as _,W as B}from"./vendor-z183l2lP.js";function S(r){const{maxDisplayBytes:t,inline:e,streamed:n}=r;if(e.isLoading)return{kind:"loading"};if(e.tooLarge){const{size:o}=e.tooLarge;return o>t?{kind:"too-large",size:o,maxDisplayBytes:t}:n.isLoading?{kind:"streaming",size:o}:n.isError?{kind:"stream-error",size:o,message:n.errorMessage??"stream failed"}:n.content!==null?{kind:"streamed",size:o,content:n.content}:{kind:"loading"}}return e.isError?{kind:"error",message:e.errorMessage??"unknown error"}:e.content!==null?{kind:"inline",content:e.content}:{kind:"loading"}}class E extends Error{constructor(e,n){super("file_too_large");a(this,"size");a(this,"maxBytes");this.name="FileTooLargeError",this.size=e,this.maxBytes=n}}function z(r){if(!r.ok)throw r.error==="file_too_large"?new E(r.size??0,r.maxBytes):new Error(r.error??"file read failed");return{content:r.content??"",size:r.size??0}}function b(r,t=!0){const e=p(n=>n.client);return g({queryKey:m.fileRead(r),queryFn:async()=>{if(!e)throw new Error("not connected");const n=await e.connection.request("file_read_request",{path:r});return z(n)},enabled:!!e&&!!r&&t})}function j(r){const{enabled:t,download:e,decode:n}=r;return{isLoading:t&&(e.isLoading||e.hasObjectUrl&&n.isLoading),isError:e.isError||n.isError,error:e.isError?e.error:n.error,data:n.data}}function T(r,t=!0){var i;const e=y(r,t),n=(i=e.data)==null?void 0:i.objectUrl,o=g({queryKey:m.fileText(r,n??null),queryFn:async()=>({content:await(await fetch(n)).text()}),enabled:t&&!!n});return j({enabled:t,download:{isLoading:e.isLoading,isError:e.isError,error:e.error,hasObjectUrl:!!n},decode:{isLoading:o.isLoading,isError:o.isError,error:o.error,data:o.data}})}const d=30*1024*1024;function A(r,t=!0){var s,l;const e=b(r,t),n=e.error instanceof E?e.error:null,o=n!==null&&n.size<=d,i=T(r,t&&o);return S({maxDisplayBytes:d,inline:{isLoading:e.isLoading,isError:e.isError,tooLarge:n?{size:n.size}:null,errorMessage:e.error instanceof Error?e.error.message:null,content:((s=e.data)==null?void 0:s.content)??null},streamed:{isLoading:i.isLoading,isError:i.isError,errorMessage:i.error instanceof Error?i.error.message:null,content:((l=i.data)==null?void 0:l.content)??null}})}const M="_wrap_1feu3_1",q={wrap:M},f=new Map;function D(r){const[t,e]=u.useState(null);return u.useEffect(()=>{const n=_.matchFilename(B,r);if(!n){e(null);return}const o=f.get(n.name);if(o){e(o);return}let i=!1;return e(null),n.load().then(s=>{f.set(n.name,s),i||e(s)}),()=>{i=!0}},[r]),t?[t]:[]}function O({path:r,content:t}){const e=D(r),n=[x.lineWrapping,h(),...e];return c.jsx("div",{className:q.wrap,children:c.jsx(k,{value:t,theme:F,extensions:n,editable:!1,readOnly:!0,basicSetup:{highlightActiveLine:!1,foldGutter:!1,searchKeymap:!1},height:"100%"})})}export{O as C,A as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as s}from"./vendor-react-Dka9ZH0B.js";import{N as _}from"./vendor-z183l2lP.js";import{u as j,r as f,L as w,a as E,f as D,V as K,P as N,B as x,E as l,S as y,i as S}from"./index-
|
|
1
|
+
import{r as d,j as s}from"./vendor-react-Dka9ZH0B.js";import{N as _}from"./vendor-z183l2lP.js";import{u as j,r as f,L as w,a as E,f as D,V as K,P as N,B as x,E as l,S as y,i as S}from"./index-B6VaYU8s.js";import{u as b,a as k}from"./vendor-query-CDNPrdQ8.js";import{u as q}from"./use-file-watch-D3DZUhpX.js";import{D as z}from"./DiffView-Bp1YwIcs.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";function V(e,t,n,i=!0){const a=j(r=>r.client);return b({queryKey:f.fileDiff(e,t,n),queryFn:async()=>{if(!a)throw new Error("not connected");return{patch:(await a.connection.request("file_diff_request",{path:e,cwd:t,staged:n})).patch??""}},enabled:!!a&&!!e&&!!t&&i})}function B(e,t,n){const i=k(),a=w.has(n)?E(e,t):null,{changedAt:r}=q(a);d.useEffect(()=>{r!==null&&(i.invalidateQueries({queryKey:f.fileRead(e)}),i.invalidateQueries({queryKey:f.fileDownload(e)}),i.invalidateQueries({queryKey:f.fileDiffByPath(e)}))},[r,e,i])}const C="_header_10rse_1",F="_path_10rse_11",L="_size_10rse_18",P="_viewToggle_10rse_23",Q="_body_10rse_28",c={header:C,path:F,size:L,viewToggle:P,body:Q};function g(e){return"path"in e}function R(e){return"staged"in e}function U({tab:e}){var m;const t=e.kind==="diff",n=e.data,i=g(n)?n.path:"",a=g(n)&&R(n)?n.staged:!1,[r,h]=d.useState(t?"diff":"file"),u=e.workspaceCwd||"~",[p]=d.useState(()=>D(i,S));B(i,u,p);const o=V(i,u,a,r==="diff"),v=K[p];return s.jsxs(N,{children:[s.jsxs("div",{className:c.header,children:[s.jsx("span",{className:c.path,children:i}),s.jsx("span",{className:c.size,children:r==="diff"?a?"staged":"unstaged":null}),s.jsxs("div",{className:c.viewToggle,children:[s.jsx(x,{size:"xs",variant:r==="file"?"default":"ghost",onClick:()=>h("file"),children:"File"}),s.jsx(x,{size:"xs",variant:r==="diff"?"default":"ghost",onClick:()=>h("diff"),children:"Diff"})]})]}),s.jsx("div",{className:_(c.body,"file-body"),children:r==="file"?s.jsx(d.Suspense,{fallback:s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading..."]}),children:s.jsx(v,{path:i,workspaceCwd:u})}):o.isLoading?s.jsxs(l,{children:[s.jsx(y,{size:"sm"})," Loading diff..."]}):o.isError?s.jsxs(l,{children:["Error: ",o.error instanceof Error?o.error.message:"unknown error"]}):(m=o.data)!=null&&m.patch?s.jsx(z,{patch:o.data.patch}):s.jsx(l,{style:{padding:"var(--pi-spacing-30)"},children:"No changes (file matches HEAD)"})})]})}export{U as FilePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v,j as i}from"./vendor-react-Dka9ZH0B.js";import{a as ie,u as ae}from"./vendor-query-CDNPrdQ8.js";import{n as ce,a as G,c as le,e as X,u as F,s as ue,E as A,S as z,B as P,r as T,t as de}from"./index-DFue5iwi.js";import{u as fe,C as me}from"./CodeView-HA63pf1I.js";import{p as pe,S as he}from"./href-resolution-73JOZBv8.js";import{S as ge}from"./SaveFileButton-B7-DaZRk.js";import{S as xe}from"./Switch-DvBJf8Rd.js";import"./vendor-z183l2lP.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";import"./use-file-download-DXQ8x6cp.js";const I={maxCount:64,maxBytesPerAsset:2*1024*1024,maxBytesTotal:16*1024*1024};function K(s,t,e){return!(s>=I.maxCount||e>I.maxBytesPerAsset||t+e>I.maxBytesTotal)}function Y(s){return s===""||s.startsWith("#")?"unsupported":s.startsWith("//")||he.test(s)?"external":null}function we(s,t,e){return e!==null&&t===e?s:t}function J(s,t,e,n,r=null){const o=s.trim(),l=Y(o);if(l)return{kind:"skip",raw:s,reason:l};const a=pe(o);let p;if(a.startsWith("/")?p=a:a==="~"||a.startsWith("~/")?p=r!==null?ce(a,r):null:p=G(a,t),!p)return{kind:"skip",raw:s,reason:"unsupported"};const h=le(p);return h!==e&&!h.startsWith(`${e}/`)?{kind:"skip",raw:s,reason:"outside-workspace"}:{kind:"local",raw:s,path:h,context:n}}const _e={css:"text/css",js:"text/javascript",mjs:"text/javascript",html:"text/html",htm:"text/html",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",bmp:"image/bmp",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",m4v:"video/x-m4v",ogv:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",m4a:"audio/mp4",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"};function ve(s){const t=s.lastIndexOf("/"),e=s.lastIndexOf(".");return e<=t?"application/octet-stream":_e[s.slice(e+1).toLowerCase()]??"application/octet-stream"}function ye(s){let t="";for(let n=0;n<s.length;n+=32768)t+=String.fromCharCode(...s.subarray(n,n+32768));return btoa(t)}function q(s,t){return`data:${s};base64,${ye(t)}`}const B=/<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g,O=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;function ee(s){const t=new Map;O.lastIndex=0;let e;for(;e=O.exec(s);){const n=e[1].toLowerCase();t.has(n)||t.set(n,e[2]??e[3]??e[4]??"")}return t}function te(s,t){switch(s){case"link":{const e=t.get("rel")??"";return/(^|\s)stylesheet(\s|$)/i.test(e)?t.has("href")?[{name:"href",context:"style",multi:!1}]:[]:[]}case"script":return t.has("src")?[{name:"src",context:"script",multi:!1}]:[];case"img":{const e=[];return t.has("src")&&e.push({name:"src",context:"image",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"image",multi:!0}),e}case"source":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"media",multi:!0}),e}case"video":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("poster")&&e.push({name:"poster",context:"media",multi:!1}),e}case"audio":return t.has("src")?[{name:"src",context:"media",multi:!1}]:[];default:return[]}}function se(s){return s.split(",").map(t=>t.trim()).filter(t=>t!=="").map(t=>{const e=t.search(/\s/);return e===-1?{url:t,descriptor:""}:{url:t.slice(0,e),descriptor:t.slice(e).trim()}})}function ke(s){return s.map(t=>t.descriptor?`${t.url} ${t.descriptor}`:t.url).join(", ")}function $(s,t,e){Y(t.trim())||s.has(t)||s.set(t,{raw:t,context:e})}function be(s){const t=new Map;B.lastIndex=0;let e;for(;e=B.exec(s);){const n=e[1].toLowerCase(),r=ee(e[2]??"");for(const o of te(n,r)){const l=r.get(o.name)??"";if(o.multi)for(const a of se(l))$(t,a.url,o.context);else $(t,l,o.context)}}return[...t.values()]}function je(s,t){let e=!1;const n=se(s).map(r=>{const o=t[r.url];return o===void 0?r:(e=!0,{url:o,descriptor:r.descriptor})});return e?ke(n):null}function Se(s,t){return Object.keys(t).length===0?s:(B.lastIndex=0,s.replace(B,(e,n,r,o)=>{const l=ee(r),a=te(n.toLowerCase(),l);if(a.length===0)return e;const p=new Map(a.map(d=>[d.name,d]));let h=!1;const E=r.replace(O,(d,f,c,w,y)=>{const _=p.get(f.toLowerCase());if(!_)return d;const g=c??w??y??"",j=_.multi?je(g,t):t[g]??null;return j===null?d:(h=!0,`${f}="${j}"`)});return h?`<${n}${E}${o}`:e}))}const M=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi,V=/@font-face\s*\{[^}]*\}/gi;function ne(s,t,e){return s??t??e??""}function Ee(s){const t=[];V.lastIndex=0;let e;for(;e=V.exec(s);)t.push([e.index,e.index+e[0].length]);return t}function Le(s){const t=Ee(s),e=new Map;M.lastIndex=0;let n;for(;n=M.exec(s);){const r=ne(n[1],n[2],n[3]),o=t.some(([l,a])=>n.index>=l&&n.index<a)?"font":"image";$(e,r,o)}return[...e.values()]}function Ae(s,t){return Object.keys(t).length===0?s:(M.lastIndex=0,s.replace(M,(e,n,r,o)=>{const l=t[ne(n,r,o)];return l===void 0?e:`url("${l}")`}))}const Ce=Object.freeze(["allow-scripts"]),Ne="https://pi-studio-preview.invalid/",Te="default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:",Re=`<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`,Be=/<head(\s[^>]*)?>/i,Me=/<html(\s[^>]*)?>/i,ze=/<base[\s/>]/i;function Pe(s,t){const e=Se(s,t.assets??{}),n=[];t.blockRemote&&n.push(`<meta http-equiv="Content-Security-Policy" content="${Te}">`),ze.test(e)||(n.push(`<base href="${Ne}">`),n.push(Re));const r=n.join("");if(r==="")return e;const o=Be.exec(e);if(o){const a=o.index+o[0].length;return e.slice(0,a)+r+e.slice(a)}const l=Me.exec(e);if(l){const a=l.index+l[0].length;return e.slice(0,a)+`<head>${r}</head>`+e.slice(a)}return`<head>${r}</head>`+e}const W=6;async function Q(s,t,e){let n=0;async function r(){for(;n<s.length;){const o=s[n];n+=1,await e(o)}}await Promise.all(Array.from({length:Math.min(t,s.length)},r))}function U(s){const t=new Map;for(const e of s){const n=t.get(e.path);n?n.push(e):t.set(e.path,[e])}return t}async function Ie(s,t){const e={},n=[];let r=0,o=0,l=!1;const a=[];for(const d of s)d.kind==="skip"?n.push({raw:d.raw,reason:d.reason}):a.push(d);function p(d,f){for(const c of d)n.push({raw:c.raw,reason:f})}async function h(d,f){if(l){p(f,"over-cap");return}let c;try{c=await t.fetchBytes(d)}catch{p(f,"fetch-failed");return}if(!K(r,o,c.byteLength)){l=!0,p(f,"over-cap");return}if(r+=1,o+=c.byteLength,f[0].context!=="style"){const m=q(ve(d),c);for(const b of f)e[b.raw]=m;return}const w=new TextDecoder().decode(c),y=X(d),_=Le(w).map(m=>J(m.raw,y,t.root,m.context,t.homeDir)),g=[];for(const m of _)m.kind==="skip"?n.push({raw:m.raw,reason:m.reason}):g.push(m);const j=U(g);await Q([...j.entries()],W,([m,b])=>h(m,b));const C={};for(const m of g){const b=e[m.raw];b!==void 0&&(C[m.raw]=b)}const L=Ae(w,C),S=new TextEncoder().encode(L),k=S.byteLength-c.byteLength;if(k>0&&!K(r-1,o-c.byteLength,S.byteLength)){l=!0,p(f,"over-cap");return}o+=k;const N=q("text/css",S);for(const m of f)e[m.raw]=N}const E=U(a);return await Q([...E.entries()],W,([d,f])=>h(d,f)),{assets:e,skipped:n}}const Oe="_wrap_1et27_1",$e="_toolbar_1et27_7",He="_modeToggle_1et27_20",De="_controls_1et27_24",Fe="_switchLabel_1et27_29",Ke="_streamedNote_1et27_37",qe="_skippedNote_1et27_45",Ve="_skippedToggle_1et27_52",We="_skippedList_1et27_64",Qe="_body_1et27_69",Ue="_frame_1et27_73",Ze="_tooLarge_1et27_79",x={wrap:Oe,toolbar:$e,modeToggle:He,controls:De,switchLabel:Fe,streamedNote:Ke,skippedNote:qe,skippedToggle:Ve,skippedList:We,body:Qe,frame:Ue,tooLarge:Ze},Ge=Ce.join(" "),Z=Object.freeze({}),Xe=Object.freeze([]),oe={external:"external","outside-workspace":"outside workspace",unsupported:"unsupported","over-cap":"over cap","fetch-failed":"not found"};function Ye(s){const t=new Map;for(const e of s){const n=oe[e.reason];t.set(n,(t.get(n)??0)+1)}return[...t.entries()].map(([e,n])=>`${n} ${e}`).join(", ")}function Je(s){let t=2166136261;for(let e=0;e<s.length;e++)t^=s.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function R(s){return`${(s/(1024*1024)).toFixed(1)} MB`}function pt({path:s,workspaceCwd:t}){var H,D;const e=fe(s),[n,r]=v.useState("preview"),[o,l]=v.useState(!1),[a,p]=v.useState(!1),h=ie(),E=F(u=>u.client),d=F(u=>u.daemon),f=ue(),c=e.kind==="inline"||e.kind==="streamed"?e.content:null,w=v.useMemo(()=>{const u=G(s,t);return u?X(u):null},[s,t]),y=v.useMemo(()=>w!==null?we(w,t,f):null,[w,t,f]),_=v.useMemo(()=>c===null||w===null||y===null?[]:be(c).map(u=>J(u.raw,w,y,u.context,f)),[c,w,y,f]),g=v.useMemo(()=>_.some(u=>u.kind==="local"),[_]),j=v.useMemo(()=>_.flatMap(u=>u.kind==="skip"?[{raw:u.raw,reason:u.reason}]:[]),[_]),C=v.useMemo(()=>g&&c!==null?Je(c):"",[c,g]),L=ae({queryKey:T.htmlAssetBundle(s,C),queryFn:()=>y===null?Promise.resolve({assets:{},skipped:[]}):Ie(_,{root:y,homeDir:f,fetchBytes:async re=>{if(!E||!d)throw new Error("not connected");return(await de(d).download(re)).bytes}}),enabled:g,staleTime:1/0}),S=g?((H=L.data)==null?void 0:H.assets)??Z:Z,k=g?((D=L.data)==null?void 0:D.skipped)??Xe:j,N=v.useMemo(()=>c===null?null:Pe(c,{assets:S,blockRemote:o}),[c,S,o]);function m(){h.invalidateQueries({queryKey:T.fileRead(s)}),h.invalidateQueries({queryKey:T.fileDownload(s)}),h.invalidateQueries({queryKey:T.htmlAssetBundleByPath(s)})}switch(e.kind){case"loading":return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Loading..."]});case"streaming":return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Streaming ",R(e.size)," file..."]});case"stream-error":case"error":return i.jsxs(A,{children:["Error: ",e.message]});case"too-large":return i.jsx(A,{children:i.jsxs("div",{className:x.tooLarge,children:[i.jsxs("div",{children:[R(e.size)," — too large to display (display ceiling is"," ",R(e.maxDisplayBytes),")."]}),i.jsx(ge,{path:s})]})})}if(c===null||N===null)return null;if(g&&L.data===void 0)return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Loading assets..."]});const b=s.split("/").pop()||s;return i.jsxs("div",{className:x.wrap,children:[i.jsxs("div",{className:x.toolbar,children:[i.jsxs("div",{className:x.modeToggle,children:[i.jsx(P,{size:"xs",variant:n==="preview"?"default":"ghost",onClick:()=>r("preview"),children:"Preview"}),i.jsx(P,{size:"xs",variant:n==="source"?"default":"ghost",onClick:()=>r("source"),children:"Source"})]}),i.jsxs("div",{className:x.controls,children:[i.jsxs("label",{className:x.switchLabel,children:[i.jsx(xe,{checked:o,onCheckedChange:l,"aria-label":"Block remote resources"}),"Block remote resources"]}),i.jsx(P,{size:"xs",variant:"ghost",onClick:m,children:"Reload"})]})]}),e.kind==="streamed"?i.jsxs("div",{className:x.streamedNote,children:[R(e.size)," file streamed"]}):null,k.length>0?i.jsxs("div",{className:x.skippedNote,children:[i.jsxs("button",{type:"button",className:x.skippedToggle,onClick:()=>p(u=>!u),children:[k.length," reference",k.length===1?"":"s"," not inlined (",Ye(k),")"]}),a?i.jsx("ul",{className:x.skippedList,children:k.map(u=>i.jsxs("li",{children:[u.raw," — ",oe[u.reason]]},u.raw))}):null]}):null,i.jsxs("div",{className:x.body,children:[i.jsx("iframe",{sandbox:Ge,srcDoc:N,referrerPolicy:"no-referrer",allow:"",className:x.frame,style:n==="preview"?void 0:{display:"none"},title:b}),n==="source"?i.jsx(me,{path:s,content:c}):null]})]})}export{pt as HtmlViewer};
|
|
1
|
+
import{r as v,j as i}from"./vendor-react-Dka9ZH0B.js";import{a as ie,u as ae}from"./vendor-query-CDNPrdQ8.js";import{n as ce,a as G,c as le,e as X,u as F,s as ue,E as A,S as z,B as P,r as T,t as de}from"./index-B6VaYU8s.js";import{u as fe,C as me}from"./CodeView-BWjIMXx_.js";import{p as pe,S as he}from"./href-resolution-pg8AZoGq.js";import{S as ge}from"./SaveFileButton-D4L2yJ4C.js";import{S as xe}from"./Switch-DvBJf8Rd.js";import"./vendor-z183l2lP.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";import"./use-file-download-Db9Jkq8L.js";const I={maxCount:64,maxBytesPerAsset:2*1024*1024,maxBytesTotal:16*1024*1024};function K(s,t,e){return!(s>=I.maxCount||e>I.maxBytesPerAsset||t+e>I.maxBytesTotal)}function Y(s){return s===""||s.startsWith("#")?"unsupported":s.startsWith("//")||he.test(s)?"external":null}function we(s,t,e){return e!==null&&t===e?s:t}function J(s,t,e,n,r=null){const o=s.trim(),l=Y(o);if(l)return{kind:"skip",raw:s,reason:l};const a=pe(o);let p;if(a.startsWith("/")?p=a:a==="~"||a.startsWith("~/")?p=r!==null?ce(a,r):null:p=G(a,t),!p)return{kind:"skip",raw:s,reason:"unsupported"};const h=le(p);return h!==e&&!h.startsWith(`${e}/`)?{kind:"skip",raw:s,reason:"outside-workspace"}:{kind:"local",raw:s,path:h,context:n}}const _e={css:"text/css",js:"text/javascript",mjs:"text/javascript",html:"text/html",htm:"text/html",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",bmp:"image/bmp",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",m4v:"video/x-m4v",ogv:"video/ogg",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",m4a:"audio/mp4",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"};function ve(s){const t=s.lastIndexOf("/"),e=s.lastIndexOf(".");return e<=t?"application/octet-stream":_e[s.slice(e+1).toLowerCase()]??"application/octet-stream"}function ye(s){let t="";for(let n=0;n<s.length;n+=32768)t+=String.fromCharCode(...s.subarray(n,n+32768));return btoa(t)}function q(s,t){return`data:${s};base64,${ye(t)}`}const B=/<([a-zA-Z][a-zA-Z0-9]*)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)(\s*\/?>)/g,O=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+))/g;function ee(s){const t=new Map;O.lastIndex=0;let e;for(;e=O.exec(s);){const n=e[1].toLowerCase();t.has(n)||t.set(n,e[2]??e[3]??e[4]??"")}return t}function te(s,t){switch(s){case"link":{const e=t.get("rel")??"";return/(^|\s)stylesheet(\s|$)/i.test(e)?t.has("href")?[{name:"href",context:"style",multi:!1}]:[]:[]}case"script":return t.has("src")?[{name:"src",context:"script",multi:!1}]:[];case"img":{const e=[];return t.has("src")&&e.push({name:"src",context:"image",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"image",multi:!0}),e}case"source":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("srcset")&&e.push({name:"srcset",context:"media",multi:!0}),e}case"video":{const e=[];return t.has("src")&&e.push({name:"src",context:"media",multi:!1}),t.has("poster")&&e.push({name:"poster",context:"media",multi:!1}),e}case"audio":return t.has("src")?[{name:"src",context:"media",multi:!1}]:[];default:return[]}}function se(s){return s.split(",").map(t=>t.trim()).filter(t=>t!=="").map(t=>{const e=t.search(/\s/);return e===-1?{url:t,descriptor:""}:{url:t.slice(0,e),descriptor:t.slice(e).trim()}})}function ke(s){return s.map(t=>t.descriptor?`${t.url} ${t.descriptor}`:t.url).join(", ")}function $(s,t,e){Y(t.trim())||s.has(t)||s.set(t,{raw:t,context:e})}function be(s){const t=new Map;B.lastIndex=0;let e;for(;e=B.exec(s);){const n=e[1].toLowerCase(),r=ee(e[2]??"");for(const o of te(n,r)){const l=r.get(o.name)??"";if(o.multi)for(const a of se(l))$(t,a.url,o.context);else $(t,l,o.context)}}return[...t.values()]}function je(s,t){let e=!1;const n=se(s).map(r=>{const o=t[r.url];return o===void 0?r:(e=!0,{url:o,descriptor:r.descriptor})});return e?ke(n):null}function Se(s,t){return Object.keys(t).length===0?s:(B.lastIndex=0,s.replace(B,(e,n,r,o)=>{const l=ee(r),a=te(n.toLowerCase(),l);if(a.length===0)return e;const p=new Map(a.map(d=>[d.name,d]));let h=!1;const E=r.replace(O,(d,f,c,w,y)=>{const _=p.get(f.toLowerCase());if(!_)return d;const g=c??w??y??"",j=_.multi?je(g,t):t[g]??null;return j===null?d:(h=!0,`${f}="${j}"`)});return h?`<${n}${E}${o}`:e}))}const M=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^'")\s]*))\s*\)/gi,V=/@font-face\s*\{[^}]*\}/gi;function ne(s,t,e){return s??t??e??""}function Ee(s){const t=[];V.lastIndex=0;let e;for(;e=V.exec(s);)t.push([e.index,e.index+e[0].length]);return t}function Le(s){const t=Ee(s),e=new Map;M.lastIndex=0;let n;for(;n=M.exec(s);){const r=ne(n[1],n[2],n[3]),o=t.some(([l,a])=>n.index>=l&&n.index<a)?"font":"image";$(e,r,o)}return[...e.values()]}function Ae(s,t){return Object.keys(t).length===0?s:(M.lastIndex=0,s.replace(M,(e,n,r,o)=>{const l=t[ne(n,r,o)];return l===void 0?e:`url("${l}")`}))}const Ce=Object.freeze(["allow-scripts"]),Ne="https://pi-studio-preview.invalid/",Te="default-src 'none'; img-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:; font-src data:; media-src data:",Re=`<script>(function(){document.addEventListener("click",function(e){var a=e.target&&e.target.closest&&e.target.closest('a[href^="#"]');if(!a)return;var frag=a.getAttribute("href").slice(1);e.preventDefault();if(!frag){window.scrollTo(0,0);return;}var el=document.getElementById(frag)||document.getElementsByName(frag)[0];if(el)el.scrollIntoView();},true);})();<\/script>`,Be=/<head(\s[^>]*)?>/i,Me=/<html(\s[^>]*)?>/i,ze=/<base[\s/>]/i;function Pe(s,t){const e=Se(s,t.assets??{}),n=[];t.blockRemote&&n.push(`<meta http-equiv="Content-Security-Policy" content="${Te}">`),ze.test(e)||(n.push(`<base href="${Ne}">`),n.push(Re));const r=n.join("");if(r==="")return e;const o=Be.exec(e);if(o){const a=o.index+o[0].length;return e.slice(0,a)+r+e.slice(a)}const l=Me.exec(e);if(l){const a=l.index+l[0].length;return e.slice(0,a)+`<head>${r}</head>`+e.slice(a)}return`<head>${r}</head>`+e}const W=6;async function Q(s,t,e){let n=0;async function r(){for(;n<s.length;){const o=s[n];n+=1,await e(o)}}await Promise.all(Array.from({length:Math.min(t,s.length)},r))}function U(s){const t=new Map;for(const e of s){const n=t.get(e.path);n?n.push(e):t.set(e.path,[e])}return t}async function Ie(s,t){const e={},n=[];let r=0,o=0,l=!1;const a=[];for(const d of s)d.kind==="skip"?n.push({raw:d.raw,reason:d.reason}):a.push(d);function p(d,f){for(const c of d)n.push({raw:c.raw,reason:f})}async function h(d,f){if(l){p(f,"over-cap");return}let c;try{c=await t.fetchBytes(d)}catch{p(f,"fetch-failed");return}if(!K(r,o,c.byteLength)){l=!0,p(f,"over-cap");return}if(r+=1,o+=c.byteLength,f[0].context!=="style"){const m=q(ve(d),c);for(const b of f)e[b.raw]=m;return}const w=new TextDecoder().decode(c),y=X(d),_=Le(w).map(m=>J(m.raw,y,t.root,m.context,t.homeDir)),g=[];for(const m of _)m.kind==="skip"?n.push({raw:m.raw,reason:m.reason}):g.push(m);const j=U(g);await Q([...j.entries()],W,([m,b])=>h(m,b));const C={};for(const m of g){const b=e[m.raw];b!==void 0&&(C[m.raw]=b)}const L=Ae(w,C),S=new TextEncoder().encode(L),k=S.byteLength-c.byteLength;if(k>0&&!K(r-1,o-c.byteLength,S.byteLength)){l=!0,p(f,"over-cap");return}o+=k;const N=q("text/css",S);for(const m of f)e[m.raw]=N}const E=U(a);return await Q([...E.entries()],W,([d,f])=>h(d,f)),{assets:e,skipped:n}}const Oe="_wrap_1et27_1",$e="_toolbar_1et27_7",He="_modeToggle_1et27_20",De="_controls_1et27_24",Fe="_switchLabel_1et27_29",Ke="_streamedNote_1et27_37",qe="_skippedNote_1et27_45",Ve="_skippedToggle_1et27_52",We="_skippedList_1et27_64",Qe="_body_1et27_69",Ue="_frame_1et27_73",Ze="_tooLarge_1et27_79",x={wrap:Oe,toolbar:$e,modeToggle:He,controls:De,switchLabel:Fe,streamedNote:Ke,skippedNote:qe,skippedToggle:Ve,skippedList:We,body:Qe,frame:Ue,tooLarge:Ze},Ge=Ce.join(" "),Z=Object.freeze({}),Xe=Object.freeze([]),oe={external:"external","outside-workspace":"outside workspace",unsupported:"unsupported","over-cap":"over cap","fetch-failed":"not found"};function Ye(s){const t=new Map;for(const e of s){const n=oe[e.reason];t.set(n,(t.get(n)??0)+1)}return[...t.entries()].map(([e,n])=>`${n} ${e}`).join(", ")}function Je(s){let t=2166136261;for(let e=0;e<s.length;e++)t^=s.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function R(s){return`${(s/(1024*1024)).toFixed(1)} MB`}function pt({path:s,workspaceCwd:t}){var H,D;const e=fe(s),[n,r]=v.useState("preview"),[o,l]=v.useState(!1),[a,p]=v.useState(!1),h=ie(),E=F(u=>u.client),d=F(u=>u.daemon),f=ue(),c=e.kind==="inline"||e.kind==="streamed"?e.content:null,w=v.useMemo(()=>{const u=G(s,t);return u?X(u):null},[s,t]),y=v.useMemo(()=>w!==null?we(w,t,f):null,[w,t,f]),_=v.useMemo(()=>c===null||w===null||y===null?[]:be(c).map(u=>J(u.raw,w,y,u.context,f)),[c,w,y,f]),g=v.useMemo(()=>_.some(u=>u.kind==="local"),[_]),j=v.useMemo(()=>_.flatMap(u=>u.kind==="skip"?[{raw:u.raw,reason:u.reason}]:[]),[_]),C=v.useMemo(()=>g&&c!==null?Je(c):"",[c,g]),L=ae({queryKey:T.htmlAssetBundle(s,C),queryFn:()=>y===null?Promise.resolve({assets:{},skipped:[]}):Ie(_,{root:y,homeDir:f,fetchBytes:async re=>{if(!E||!d)throw new Error("not connected");return(await de(d).download(re)).bytes}}),enabled:g,staleTime:1/0}),S=g?((H=L.data)==null?void 0:H.assets)??Z:Z,k=g?((D=L.data)==null?void 0:D.skipped)??Xe:j,N=v.useMemo(()=>c===null?null:Pe(c,{assets:S,blockRemote:o}),[c,S,o]);function m(){h.invalidateQueries({queryKey:T.fileRead(s)}),h.invalidateQueries({queryKey:T.fileDownload(s)}),h.invalidateQueries({queryKey:T.htmlAssetBundleByPath(s)})}switch(e.kind){case"loading":return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Loading..."]});case"streaming":return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Streaming ",R(e.size)," file..."]});case"stream-error":case"error":return i.jsxs(A,{children:["Error: ",e.message]});case"too-large":return i.jsx(A,{children:i.jsxs("div",{className:x.tooLarge,children:[i.jsxs("div",{children:[R(e.size)," — too large to display (display ceiling is"," ",R(e.maxDisplayBytes),")."]}),i.jsx(ge,{path:s})]})})}if(c===null||N===null)return null;if(g&&L.data===void 0)return i.jsxs(A,{children:[i.jsx(z,{size:"sm"})," Loading assets..."]});const b=s.split("/").pop()||s;return i.jsxs("div",{className:x.wrap,children:[i.jsxs("div",{className:x.toolbar,children:[i.jsxs("div",{className:x.modeToggle,children:[i.jsx(P,{size:"xs",variant:n==="preview"?"default":"ghost",onClick:()=>r("preview"),children:"Preview"}),i.jsx(P,{size:"xs",variant:n==="source"?"default":"ghost",onClick:()=>r("source"),children:"Source"})]}),i.jsxs("div",{className:x.controls,children:[i.jsxs("label",{className:x.switchLabel,children:[i.jsx(xe,{checked:o,onCheckedChange:l,"aria-label":"Block remote resources"}),"Block remote resources"]}),i.jsx(P,{size:"xs",variant:"ghost",onClick:m,children:"Reload"})]})]}),e.kind==="streamed"?i.jsxs("div",{className:x.streamedNote,children:[R(e.size)," file streamed"]}):null,k.length>0?i.jsxs("div",{className:x.skippedNote,children:[i.jsxs("button",{type:"button",className:x.skippedToggle,onClick:()=>p(u=>!u),children:[k.length," reference",k.length===1?"":"s"," not inlined (",Ye(k),")"]}),a?i.jsx("ul",{className:x.skippedList,children:k.map(u=>i.jsxs("li",{children:[u.raw," — ",oe[u.reason]]},u.raw))}):null]}):null,i.jsxs("div",{className:x.body,children:[i.jsx("iframe",{sandbox:Ge,srcDoc:N,referrerPolicy:"no-referrer",allow:"",className:x.frame,style:n==="preview"?void 0:{display:"none"},title:b}),n==="source"?i.jsx(me,{path:s,content:c}):null]})]})}export{pt as HtmlViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./vendor-react-Dka9ZH0B.js";import{E as i,S as t}from"./index-
|
|
1
|
+
import{j as o}from"./vendor-react-Dka9ZH0B.js";import{E as i,S as t}from"./index-B6VaYU8s.js";import{u as a}from"./use-file-download-Db9Jkq8L.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const m="_wrap_1vzo5_1",n="_image_1vzo5_15",s={wrap:m,image:n};function E({path:e,workspaceCwd:p}){const r=a(e);return r.isLoading?o.jsxs(i,{children:[o.jsx(t,{size:"sm"})," Loading image..."]}):r.isError?o.jsxs(i,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:s.wrap,children:o.jsx("img",{className:s.image,src:r.data.objectUrl,alt:e.split("/").pop()||e})}):null}export{E as ImageViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./vendor-react-Dka9ZH0B.js";import{a as g,e as j,B as l,E as i,S as p}from"./index-
|
|
1
|
+
import{r as d,j as e}from"./vendor-react-Dka9ZH0B.js";import{a as g,e as j,B as l,E as i,S as p}from"./index-B6VaYU8s.js";import{u as v,C as _}from"./CodeView-BWjIMXx_.js";import{M as f}from"./markdown-CPP5yk_k.js";import{S as h}from"./SaveFileButton-D4L2yJ4C.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";import"./use-file-download-Db9Jkq8L.js";import"./vendor-highlight-DaCUEPaW.js";import"./vendor-markdown-Bo-Xpsuy.js";import"./href-resolution-pg8AZoGq.js";const y="_wrap_g5iym_1",w="_toolbar_g5iym_6",N="_rendered_g5iym_17",S="_streamedNote_g5iym_21",z="_tooLarge_g5iym_29",o={wrap:y,toolbar:w,rendered:N,streamedNote:S,tooLarge:z};function a(r){return`${(r/(1024*1024)).toFixed(1)} MB`}function q({path:r,workspaceCwd:n}){const s=v(r),[m,c]=d.useState("preview"),x=d.useMemo(()=>{const t=g(r,n);return t?j(t):null},[r,n]);switch(s.kind){case"loading":return e.jsxs(i,{children:[e.jsx(p,{size:"sm"})," Loading..."]});case"streaming":return e.jsxs(i,{children:[e.jsx(p,{size:"sm"})," Streaming ",a(s.size)," file..."]});case"stream-error":case"error":return e.jsxs(i,{children:["Error: ",s.message]});case"too-large":return e.jsx(i,{children:e.jsxs("div",{className:o.tooLarge,children:[e.jsxs("div",{children:[a(s.size)," — too large to display (display ceiling is"," ",a(s.maxDisplayBytes),")."]}),e.jsx(h,{path:r})]})});case"inline":case"streamed":{const t=s.content,u=s.kind==="streamed";return e.jsxs("div",{className:o.wrap,children:[e.jsxs("div",{className:o.toolbar,children:[e.jsx(l,{size:"xs",variant:m==="preview"?"default":"ghost",onClick:()=>c("preview"),children:"Preview"}),e.jsx(l,{size:"xs",variant:m==="source"?"default":"ghost",onClick:()=>c("source"),children:"Source"})]}),u?e.jsxs("div",{className:o.streamedNote,children:[a(s.size)," file streamed"]}):null,m==="preview"?e.jsx("div",{className:o.rendered,children:e.jsx(f,{text:t,assetBase:x,workspaceCwd:n})}):e.jsx(_,{path:r,content:t})]})}}}export{q as MarkdownFileViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as b,j as e}from"./vendor-react-Dka9ZH0B.js";import{a as E}from"./vendor-query-CDNPrdQ8.js";import{u as P,E as d,S as C,B as w,g as R,r as x}from"./index-
|
|
1
|
+
import{r as b,j as e}from"./vendor-react-Dka9ZH0B.js";import{a as E}from"./vendor-query-CDNPrdQ8.js";import{u as P,E as d,S as C,B as w,g as R,r as x}from"./index-B6VaYU8s.js";import{u as I}from"./use-provider-auth-list-B3AMWkI0.js";import{u as y}from"./provider-auth-store-CpmUGwuu.js";import{S as p}from"./StatusBadge-eoBBn7zF.js";import"./vendor-z183l2lP.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const N="env:";function M(n){var i;return n.configured==="unknown"?{label:"Unknown",variant:"warning"}:n.configured===!1?{label:"Not configured",variant:"muted"}:(i=n.configuredSource)!=null&&i.startsWith(N)?{label:`env: ${n.configuredSource.slice(N.length)}`,variant:"success"}:n.configuredType==="oauth"?{label:"OAuth",variant:"success"}:{label:"API key",variant:"success"}}function q(n){const i=n.configured===!0?"Re-login":"Log in";if(n.authTypes.length<=1){const s=n.authTypes[0]??"api_key";return[{authType:s,label:s==="oauth"?n.oauthLoginLabel??i:i}]}return n.authTypes.map(s=>s==="oauth"?{authType:s,label:n.oauthLoginLabel??"Log in with OAuth"}:{authType:s,label:"API key"})}const O="_list_vm1k7_1",T="_row_vm1k7_7",B="_rowMain_vm1k7_18",z="_name_vm1k7_25",F="_tag_vm1k7_33",K="_rowActions_vm1k7_37",Q="_pendingNote_vm1k7_44",U="_note_vm1k7_49",$="_errorState_vm1k7_55",a={list:O,row:T,rowMain:B,name:z,tag:F,rowActions:K,pendingNote:Q,note:U,errorState:$};function nt(){const n=P(t=>t.client),i=E(),s=y(t=>t.pendingLogin),j=y(t=>t.requestLogin),[g,m]=b.useState(null),[k,f]=b.useState({}),{data:l,isLoading:L,isError:S,error:h}=I();async function A(t){if(!(!n||!await R().dialogs.confirm(`Log out of ${t.name}? Running agents keep working until their current credential use fails.`))){f(o=>({...o,[t.id]:""})),m(t.id);try{const o=await n.logoutProvider(t.id);f(r=>({...r,[t.id]:o.stillConfigured?"Removed the stored credential — still configured via an environment variable.":""})),await i.invalidateQueries({queryKey:x.providerAuthList()}),i.invalidateQueries({queryKey:x.providerModelsAll()})}finally{m(null)}}}return L?e.jsxs(d,{children:[e.jsx(C,{size:"sm"})," Loading providers…"]}):S?e.jsx(d,{className:a.errorState,children:h instanceof Error?h.message:"Failed to load providers."}):!l||l.length===0?e.jsx(d,{children:"No providers available."}):e.jsx("div",{className:a.list,children:l.map(t=>{const c=M(t),o=q(t),r=(s==null?void 0:s.provider)===t.id,_=s!==null&&!r,v=k[t.id];return e.jsxs("div",{className:a.row,children:[e.jsxs("div",{className:a.rowMain,children:[e.jsx("span",{className:a.name,children:t.name}),t.oauthIsSubscription&&e.jsx(p,{label:"Subscription",variant:"muted",className:a.tag}),e.jsx(p,{label:c.label,variant:c.variant,className:a.tag})]}),e.jsx("div",{className:a.rowActions,children:r?e.jsx("span",{className:a.pendingNote,children:"Logging in…"}):e.jsxs(e.Fragment,{children:[o.map(u=>e.jsx(w,{size:"xs",variant:"secondary",disabled:_,onClick:()=>j(t.id,t.name,u.authType),children:u.label},u.authType)),t.configured!==!1&&e.jsx(w,{size:"xs",variant:"ghost",disabled:_||g===t.id,loading:g===t.id,onClick:()=>void A(t),children:"Log out"})]})}),v&&e.jsx("div",{className:a.note,children:v})]},t.id)})})}export{nt as ModelProvidersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as t}from"./vendor-react-Dka9ZH0B.js";import{u as k,b as I,P as w,E as N,S as W,q,v as C,e as U,w as X,C as Y,x as z,k as D}from"./index-
|
|
1
|
+
import{r as c,j as t}from"./vendor-react-Dka9ZH0B.js";import{u as k,b as I,P as w,E as N,S as W,q,v as C,e as U,w as X,C as Y,x as z,k as D}from"./index-B6VaYU8s.js";import{F as G}from"./vendor-molviewer-7FbONJs2.js";import{u as H}from"./use-file-download-Db9Jkq8L.js";import{u as K}from"./use-file-watch-D3DZUhpX.js";import{S as v}from"./StatusBadge-eoBBn7zF.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";function J(e,r){return!e||!r?null:{url:r,name:e.split("/").pop()||e}}function Q({changedAt:e,lastAppliedAt:r,modified:n}){return!(e===null||n||e===r)}const Z={empty_path:"Nothing to save.",too_large:"File is too large to save (over 5 MiB).",not_found:"The file no longer exists.",unreadable:"The file could not be read.",not_a_file:"That path is not a file."};async function ee(e,r,n){const a=await e.connection.request("file_write_request",{path:r,content:n});if(!a.ok){const l=a.error??"";throw new Error(Z[l]??l??"Failed to save")}}const re="mol2";function oe(e){const{sourcePath:r,monomers:n,attempt:a}=e,l=a>0?`_${a+1}`:"";return`${te(r)}_polymer_${n}${l}.${re}`}function te(e){return(e.split("/").pop()??"").replace(/\.[^.]+$/,"").trim()||"polymer"}const se={"--canvas":"var(--pi-color-surface0)","--well":"var(--pi-color-surface0)","--recess":"var(--pi-color-surface1)","--chrome":"var(--pi-color-surface1)","--control":"var(--pi-color-surface2)","--control-hover":"var(--pi-color-surface3)","--control-strong-hover":"var(--pi-color-surface4)","--border-control":"var(--pi-color-border)","--border-input":"var(--pi-color-border)","--popover":"var(--pi-color-surface1)","--popover-item-hover":"var(--pi-color-surface2)","--row-hover":"var(--pi-color-surface2)","--border-popover":"var(--pi-color-border)","--text-primary":"var(--pi-color-foreground)","--text-on-control":"var(--pi-color-foreground)"},ne="_wrap_tixu9_1",ae="_molViewer_tixu9_4",le="_badges_tixu9_8",g={wrap:ne,molViewer:ae,badges:le},ie=50;async function ce(e){const{client:r,upload:n,sourcePath:a,monomers:l,text:f}=e,p=U(a);let s=null,i="";for(let u=0;u<ie&&s===null;u+=1){i=oe({sourcePath:a,monomers:l,attempt:u});try{s=await X(r,p,i,"file")}catch(m){if(m instanceof Y&&m.code==="exists")continue;throw m}}if(s===null)throw new Error(`No free name for ${i} — too many builds in this folder.`);try{await n(p,new File([f],i,{type:"chemical/x-mol2"}))}catch(u){throw await z(r,s).catch(()=>{}),u}return s}function ue({path:e,workspaceCwd:r,tabId:n,isActive:a,onModifiedChange:l}){var T;const f=k(o=>o.client),{upload:p}=I(),s=H(e??"",!!e),{changedAt:i}=K(e),u=c.useRef(null),m=c.useRef(!1),[E,_]=c.useState(null),[h,A]=c.useState(!1),[S,x]=c.useState(null),[j,y]=c.useState(null),[M,P]=c.useState(null),b=c.useRef(null),R=((T=s.data)==null?void 0:T.objectUrl)??null,$=c.useMemo(()=>J(e,R),[e,R]);c.useEffect(()=>{Q({changedAt:i,lastAppliedAt:b.current,modified:h})&&(b.current=i,s.refetch())},[i,h,s.refetch]);const L=i!==null&&i!==b.current&&h;async function V(o){if(e){if(!f){x("Not connected — cannot save.");return}x(null);try{await ee(f,e,o.text()),o.saved()}catch(d){x(d instanceof Error?d.message:"Failed to save")}}}async function B(o){if(e){if(!f){y("Not connected — cannot save the polymer.");return}y(null),P(null);try{const d=await ce({client:f,upload:p,sourcePath:e,monomers:o.monomers,text:o.text()});o.report.clashes>0&&P(`${o.report.clashes} close contacts — relax the geometry before simulating`);const O=q.getState().paneOfTab(r,n);C(d,r,O??void 0)}catch(d){y(d instanceof Error?d.message:"Failed to save the polymer")}}}const F=(s.isError?s.error instanceof Error?s.error.message:"download failed":null)??(E==null?void 0:E.message)??null;return e&&s.isPending?t.jsx(w,{children:t.jsxs(N,{children:[t.jsx(W,{size:"sm"})," Loading..."]})}):F?t.jsx(w,{children:t.jsxs(N,{children:["Error: ",F]})}):t.jsxs(w,{className:g.wrap,"data-molecule-active":a?"true":"false",children:[t.jsxs("div",{className:g.badges,children:[L&&t.jsx(v,{label:"File changed on disk",variant:"muted"}),S&&t.jsx(v,{label:`Save failed: ${S}`,variant:"error"}),j&&t.jsx(v,{label:`Polymer build: ${j}`,variant:"error"}),M&&t.jsx(v,{label:M,variant:"warning"})]}),t.jsx(G,{ref:u,className:g.molViewer,theme:se,source:$,sourceMode:m.current?"update":"replace",onLoad:()=>{m.current=!0,_(null)},onLoadError:o=>_(o.error),onModifiedChange:o=>{A(o),l==null||l(o)},onSave:e?V:void 0,onPolymerBuild:e?B:void 0})]})}function Se({tab:e}){const{path:r}=e.data,n=D(e.id);return t.jsx(w,{children:t.jsx(ue,{path:r,workspaceCwd:e.workspaceCwd,tabId:e.id,isActive:n})})}export{Se as MoleculeViewerPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Q=Object.defineProperty;var Y=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var I=(e,t,r)=>Y(e,typeof t!="symbol"?t+"":t,r);import{r as a,j as n}from"./vendor-react-Dka9ZH0B.js";import{g as O,b as ee,E as T,B as S,S as te}from"./index-
|
|
1
|
+
var Q=Object.defineProperty;var Y=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var I=(e,t,r)=>Y(e,typeof t!="symbol"?t+"":t,r);import{r as a,j as n}from"./vendor-react-Dka9ZH0B.js";import{g as O,b as ee,E as T,B as S,S as te}from"./index-B6VaYU8s.js";import{u as se}from"./use-file-download-Db9Jkq8L.js";import{G as re,p as ne}from"./vendor-pdfjs-BSchhGel.js";import{Z as oe,a as ae,M as ie,D as ce}from"./vendor-icons-CSCeICuX.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";class Z extends Error{constructor(){super("PDF preview is not available in this application.");I(this,"name","PdfUnavailableError")}}function le(e,t){const r=new URL(e.endsWith("/")?e:`${e}/`,t);return{cMapUrl:new URL("cmaps/",r).href,cMapPacked:!0,standardFontDataUrl:new URL("standard_fonts/",r).href,wasmUrl:new URL("wasm/",r).href,iccUrl:new URL("iccs/",r).href}}function G(){var t;const e=O().pdf;if(!e)throw new Z;return(t=re).workerPort??(t.workerPort=e.createWorker()),{pdfjs:ne,assetUrls:le(e.assetBaseUrl,document.baseURI)}}const y=[.25,.5,.75,1,1.25,1.5,2,3,4],W=y[0],$=y[y.length-1],de=16777216,V=1e-6;function ue(e){return y.find(t=>t>e+V)??$}function fe(e){return y.findLast(t=>t<e-V)??W}function he(e,t,r){const s=e-t;return s<=0||r<=0?1:Math.min($,Math.max(W,s/r))}function me(e,t,r,s,d=de){const c=e*r*(t*r);return c<=0?s:Math.min(s,Math.sqrt(d/c))}function pe(e,t,r,s){const d=[];let c=s;for(const x of e)d.push(c),c+=x*t+r;return d}function ge(e,t,r){const s=t+r/2,d=e.findIndex(c=>c>s);return Math.max(0,(d===-1?e.length:d)-1)}const we="_viewer_16fdq_1",ve="_toolbar_16fdq_7",xe="_pageIndicator_16fdq_18",_e="_zoom_16fdq_19",Ee="_controls_16fdq_23",je="_scroller_16fdq_32",Pe="_stack_16fdq_40",Se="_page_16fdq_18",be="_canvas_16fdq_56",Me="_pageError_16fdq_61",ye="_failure_16fdq_71",De="_textLayer_16fdq_86",u={viewer:we,toolbar:ve,pageIndicator:xe,zoom:_e,controls:Ee,scroller:je,stack:Pe,page:Se,canvas:be,pageError:Me,failure:ye,textLayer:De},Fe=12,q=16,ze="100% 0px",Ce=120,ke={invalid:"This file could not be opened as a PDF.",password:"This PDF is password-protected.",unavailable:"PDF preview is not available in this application.",failed:"This PDF could not be loaded."};function Ae(e){if(e instanceof Z)return"unavailable";const t=e instanceof Error?e.name:"";return t==="PasswordException"?"password":t==="InvalidPDFException"||t==="FormatError"||t==="MissingPDFException"?"invalid":"failed"}function Le(e){return e instanceof Error&&/Cancelled|destroyed/i.test(`${e.name} ${e.message}`)}function Xe({path:e}){var R;const t=se(e),{saveToDisk:r}=ee(),[s,d]=a.useState(null),[c,x]=a.useState(null),[l,C]=a.useState(null),[D,p]=a.useState(0),[h,f]=a.useState(!0),[j,_]=a.useState(1),[b,P]=a.useState(0),g=(R=t.data)==null?void 0:R.objectUrl;a.useEffect(()=>{if(!g)return;let o=!1,v=!1,w=null;return(async()=>{try{const E=new Uint8Array(await(await fetch(g)).arrayBuffer());if(o)return;const{pdfjs:z,assetUrls:X}=G();w=z.getDocument({data:E,enableXfa:!1,...X});const L=await w.promise,B=await Promise.all(Array.from({length:L.numPages},async(Ue,H)=>{const{width:K,height:J}=(await L.getPage(H+1)).getViewport({scale:1});return{width:K,height:J}}));if(o)return;v=!0,x(null),d({task:w,doc:L,sizes:B})}catch(E){o||x(Ae(E))}})(),()=>{o=!0,v||w==null||w.destroy()}},[g]),a.useEffect(()=>{const o=s==null?void 0:s.task;return()=>void(o==null?void 0:o.destroy())},[s==null?void 0:s.task]),a.useEffect(()=>{if(!l)return;let o,v=!0;const w=new ResizeObserver(([E])=>{const z=(E==null?void 0:E.contentRect.width)??0;if(clearTimeout(o),v){v=!1,p(z);return}o=setTimeout(()=>p(z),Ce)});return w.observe(l),()=>{clearTimeout(o),w.disconnect()}},[l]);const m=s==null?void 0:s.sizes,F=a.useMemo(()=>Math.max(0,...(m??[]).map(o=>o.width)),[m]),i=h?he(D,q*2,F):j,M=a.useMemo(()=>pe((m??[]).map(o=>o.height),i,Fe,q),[m,i]),N=()=>{l&&P(ge(M,l.scrollTop,l.clientHeight))},k=a.useRef(i);a.useLayoutEffect(()=>{l&&k.current!==i&&(l.scrollTop=l.scrollTop*i/k.current),k.current=i},[i,l]),a.useEffect(N,[M,l]);const A=()=>void r(e).catch(o=>O().dialogs.alert(`Failed to download: ${o instanceof Error?o.message:String(o)}`));if(t.isError)return n.jsxs(T,{children:["Error: ",t.error instanceof Error?t.error.message:"unknown error"]});if(c&&!s)return n.jsxs("div",{className:u.failure,children:[n.jsx("span",{children:ke[c]}),n.jsx(S,{size:"sm",onClick:A,children:"Download"})]});if(!s)return n.jsxs(T,{children:[n.jsx(te,{size:"sm"})," Loading PDF..."]});if(s.sizes.length===0)return n.jsxs("div",{className:u.failure,children:[n.jsx("span",{children:"This PDF has no pages."}),n.jsx(S,{size:"sm",onClick:A,children:"Download"})]});const U=o=>{_(o(i)),f(!1)};return n.jsxs("div",{className:u.viewer,children:[n.jsxs("div",{className:u.toolbar,children:[n.jsxs("span",{className:u.pageIndicator,"aria-live":"polite",children:[b+1," / ",s.sizes.length]}),n.jsxs("div",{className:u.controls,children:[n.jsx(S,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Zoom out",onClick:()=>U(fe),children:n.jsx(oe,{size:14})}),n.jsxs("span",{className:u.zoom,children:[Math.round(i*100),"%"]}),n.jsx(S,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Zoom in",onClick:()=>U(ue),children:n.jsx(ae,{size:14})}),n.jsx(S,{size:"xs",variant:h?"default":"ghost",iconOnly:!0,"aria-label":"Fit width","aria-pressed":h,onClick:()=>f(o=>!o),children:n.jsx(ie,{size:14})}),n.jsx(S,{size:"xs",variant:"ghost",iconOnly:!0,"aria-label":"Download PDF",onClick:A,children:n.jsx(ce,{size:14})})]})]}),n.jsx("div",{ref:C,className:u.scroller,onScroll:N,children:n.jsx("div",{className:u.stack,children:s.sizes.map((o,v)=>n.jsx(Ne,{doc:s.doc,pageNumber:v+1,size:o,scale:i,root:l},v))})})]})}function Ne({doc:e,pageNumber:t,size:r,scale:s,root:d}){const c=a.useRef(null),[x,l]=a.useState(!1),[C,D]=a.useState(null);return a.useEffect(()=>{const p=c.current;if(!d||!p)return;const h=new IntersectionObserver(([f])=>l((f==null?void 0:f.isIntersecting)??!1),{root:d,rootMargin:ze});return h.observe(p),()=>h.disconnect()},[d]),a.useEffect(()=>{const p=c.current;if(!p)return;if(!x){p.replaceChildren();return}let h=!1,f=null,j=null;return(async()=>{try{const{pdfjs:_}=G(),b=await e.getPage(t),P=b.getViewport({scale:s}),g=me(r.width,r.height,s,window.devicePixelRatio||1),m=document.createElement("canvas");m.width=Math.floor(P.width*g),m.height=Math.floor(P.height*g),m.className=u.canvas??"";const F=b.render({canvas:m,viewport:P,transform:g===1?void 0:[g,0,0,g,0,0]});f=F,await F.promise;const i=document.createElement("div");i.className=`textLayer ${u.textLayer??""}`,i.style.setProperty("--total-scale-factor",String(s));const M=new _.TextLayer({textContentSource:b.streamTextContent(),container:i,viewport:P});if(j=M,await M.render(),h)return;p.replaceChildren(m,i),D(null)}catch(_){!h&&!Le(_)&&D(_ instanceof Error?_.message:"render failed")}})(),()=>{h=!0,f==null||f.cancel(),j==null||j.cancel()}},[x,e,t,s,r.width,r.height]),n.jsx("div",{ref:c,className:u.page,style:{width:r.width*s,height:r.height*s},"data-page":t,children:C&&n.jsxs("span",{className:u.pageError,children:["Page ",t," failed to render."]})})}export{Xe as PdfViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-Dka9ZH0B.js";import{b as f,S as d,B as m}from"./index-
|
|
1
|
+
import{r as s,j as e}from"./vendor-react-Dka9ZH0B.js";import{b as f,S as d,B as m}from"./index-B6VaYU8s.js";function S({path:i}){const{saveToDisk:c}=f(),[u,t]=s.useState(!1),[n,a]=s.useState(null),r=s.useRef(!0);s.useEffect(()=>()=>{r.current=!1},[]);async function l(){t(!0),a(null);try{await c(i)}catch(o){r.current&&a(o instanceof Error?o.message:"download failed")}finally{r.current&&t(!1)}}return e.jsxs(e.Fragment,{children:[n&&e.jsxs("div",{children:["Error: ",n]}),u?e.jsx(d,{size:"sm"}):e.jsx(m,{size:"sm",onClick:()=>void l(),children:"Download"})]})}export{S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as l,a as ye,r as v}from"./vendor-react-Dka9ZH0B.js";import{af as Ce,N as Ee}from"./vendor-z183l2lP.js";import{g as ie,u as se,r as Lt,D as ae,B as G,S as It,y as Ne,z as Be,M as Se,N as Ie,I as Re,E as Tt}from"./index-DFue5iwi.js";import{a as Ae}from"./vendor-query-CDNPrdQ8.js";import{u as O}from"./provider-auth-store-CpmUGwuu.js";import{E as ue,C as be,d as _e}from"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";function Le(t,n){const i=ie().links.openExternal;i&&(t.preventDefault(),i(n))}function Rt({href:t,onClick:n,...i}){return l.jsx("a",{...i,href:t,target:"_blank",rel:"noreferrer",onClick:r=>{n==null||n(r),r.defaultPrevented||Le(r,t)}})}function Te(t,n){return{provider:t,authType:n,phase:"starting",statusLines:[]}}function Me(t,n,i){return{...t,phase:t.phase==="starting"?"waiting":t.phase,statusLines:[...t.statusLines,{kind:"info",message:n,links:i}]}}function Pe(t,n){const i=t.statusLines.filter(r=>r.kind!=="progress");return{...t,phase:t.phase==="starting"?"waiting":t.phase,statusLines:[...i,{kind:"progress",message:n}]}}function ve(t,n,i){return{...t,authUrl:{url:n,instructions:i}}}function je(t,n,i,r,e){return{...t,deviceCode:{userCode:n,verificationUri:i,intervalSeconds:r,expiresInSeconds:e}}}function De(t,n){return{...t,phase:"prompt",prompt:n}}function xe(t,n){var i;return((i=t.prompt)==null?void 0:i.promptId)!==n?t:{...t,phase:"waiting",prompt:void 0}}function ke(t,n,i){return{...t,phase:"done",result:{ok:n,error:i}}}function Ue(t,n){if(t.phase==="done")return t;switch(n.kind){case"info":return Me(t,n.message,n.links);case"progress":return Pe(t,n.message);case"auth_url":return ve(t,n.url,n.instructions);case"device_code":return je(t,n.userCode,n.verificationUri,n.intervalSeconds,n.expiresInSeconds);case"prompt":return De(t,n);case"prompt_cancelled":return xe(t,n.promptId);case"done":return ke(t,n.ok,n.error)}}var V={},nt,Mt;function qe(){return Mt||(Mt=1,nt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),nt}var rt={},U={},Pt;function F(){if(Pt)return U;Pt=1;let t;const n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return U.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},U.getSymbolTotalCodewords=function(r){return n[r]},U.getBCHDigit=function(i){let r=0;for(;i!==0;)r++,i>>>=1;return r},U.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},U.isKanjiModeEnabled=function(){return typeof t<"u"},U.toSJIS=function(r){return t(r)},U}var ot={},vt;function At(){return vt||(vt=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+i)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,e){if(t.isValid(r))return r;try{return n(r)}catch{return e}}})(ot)),ot}var it,jt;function Fe(){if(jt)return it;jt=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(n){const i=Math.floor(n/8);return(this.buffer[i]>>>7-n%8&1)===1},put:function(n,i){for(let r=0;r<i;r++)this.putBit((n>>>i-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),n&&(this.buffer[i]|=128>>>this.length%8),this.length++}},it=t,it}var st,Dt;function ze(){if(Dt)return st;Dt=1;function t(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}return t.prototype.set=function(n,i,r,e){const o=n*this.size+i;this.data[o]=r,e&&(this.reservedBit[o]=!0)},t.prototype.get=function(n,i){return this.data[n*this.size+i]},t.prototype.xor=function(n,i,r){this.data[n*this.size+i]^=r},t.prototype.isReserved=function(n,i){return this.reservedBit[n*this.size+i]},st=t,st}var at={},xt;function Ke(){return xt||(xt=1,(function(t){const n=F().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const e=Math.floor(r/7)+2,o=n(r),s=o===145?26:Math.ceil((o-13)/(2*e-2))*2,a=[o-7];for(let u=1;u<e-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},t.getPositions=function(r){const e=[],o=t.getRowColCoords(r),s=o.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||e.push([o[a],o[u]]);return e}})(at)),at}var ut={},kt;function Ve(){if(kt)return ut;kt=1;const t=F().getSymbolSize,n=7;return ut.getPositions=function(r){const e=t(r);return[[0,0],[e-n,0],[0,e-n]]},ut}var ct={},Ut;function Oe(){return Ut||(Ut=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){const o=e.size;let s=0,a=0,u=0,c=null,m=null;for(let E=0;E<o;E++){a=u=0,c=m=null;for(let S=0;S<o;S++){let h=e.get(E,S);h===c?a++:(a>=5&&(s+=n.N1+(a-5)),c=h,a=1),h=e.get(S,E),h===m?u++:(u>=5&&(s+=n.N1+(u-5)),m=h,u=1)}a>=5&&(s+=n.N1+(a-5)),u>=5&&(s+=n.N1+(u-5))}return s},t.getPenaltyN2=function(e){const o=e.size;let s=0;for(let a=0;a<o-1;a++)for(let u=0;u<o-1;u++){const c=e.get(a,u)+e.get(a,u+1)+e.get(a+1,u)+e.get(a+1,u+1);(c===4||c===0)&&s++}return s*n.N2},t.getPenaltyN3=function(e){const o=e.size;let s=0,a=0,u=0;for(let c=0;c<o;c++){a=u=0;for(let m=0;m<o;m++)a=a<<1&2047|e.get(c,m),m>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|e.get(m,c),m>=10&&(u===1488||u===93)&&s++}return s*n.N3},t.getPenaltyN4=function(e){let o=0;const s=e.data.length;for(let u=0;u<s;u++)o+=e.data[u];return Math.abs(Math.ceil(o*100/s/5)-10)*n.N4};function i(r,e,o){switch(r){case t.Patterns.PATTERN000:return(e+o)%2===0;case t.Patterns.PATTERN001:return e%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(e+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return e*o%2+e*o%3===0;case t.Patterns.PATTERN110:return(e*o%2+e*o%3)%2===0;case t.Patterns.PATTERN111:return(e*o%3+(e+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(e,o){const s=o.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)o.isReserved(u,a)||o.xor(u,a,i(e,u,a))},t.getBestMask=function(e,o){const s=Object.keys(t.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){o(c),t.applyMask(c,e);const m=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(c,e),m<u&&(u=m,a=c)}return a}})(ct)),ct}var W={},qt;function ce(){if(qt)return W;qt=1;const t=At(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return W.getBlocksCount=function(e,o){switch(o){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},W.getTotalCodewordsCount=function(e,o){switch(o){case t.L:return i[(e-1)*4+0];case t.M:return i[(e-1)*4+1];case t.Q:return i[(e-1)*4+2];case t.H:return i[(e-1)*4+3];default:return}},W}var lt={},Q={},Ft;function He(){if(Ft)return Q;Ft=1;const t=new Uint8Array(512),n=new Uint8Array(256);return(function(){let r=1;for(let e=0;e<255;e++)t[e]=r,n[r]=e,r<<=1,r&256&&(r^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),Q.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},Q.exp=function(r){return t[r]},Q.mul=function(r,e){return r===0||e===0?0:t[n[r]+n[e]]},Q}var zt;function Qe(){return zt||(zt=1,(function(t){const n=He();t.mul=function(r,e){const o=new Uint8Array(r.length+e.length-1);for(let s=0;s<r.length;s++)for(let a=0;a<e.length;a++)o[s+a]^=n.mul(r[s],e[a]);return o},t.mod=function(r,e){let o=new Uint8Array(r);for(;o.length-e.length>=0;){const s=o[0];for(let u=0;u<e.length;u++)o[u]^=n.mul(e[u],s);let a=0;for(;a<o.length&&o[a]===0;)a++;o=o.slice(a)}return o},t.generateECPolynomial=function(r){let e=new Uint8Array([1]);for(let o=0;o<r;o++)e=t.mul(e,new Uint8Array([1,n.exp(o)]));return e}})(lt)),lt}var dt,Kt;function Je(){if(Kt)return dt;Kt=1;const t=Qe();function n(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return n.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},n.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(r.length+this.degree);e.set(r);const o=t.mod(e,this.genPoly),s=this.degree-o.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(o,s),a}return o},dt=n,dt}var ft={},ht={},gt={},Vt;function le(){return Vt||(Vt=1,gt.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),gt}var D={},Ot;function de(){if(Ot)return D;Ot=1;const t="[0-9]+",n="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
1
|
+
import{j as l,a as ye,r as v}from"./vendor-react-Dka9ZH0B.js";import{af as Ce,N as Ee}from"./vendor-z183l2lP.js";import{g as ie,u as se,r as Lt,D as ae,B as G,S as It,y as Ne,z as Be,M as Se,N as Ie,I as Re,E as Tt}from"./index-B6VaYU8s.js";import{a as Ae}from"./vendor-query-CDNPrdQ8.js";import{u as O}from"./provider-auth-store-CpmUGwuu.js";import{E as ue,C as be,d as _e}from"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";function Le(t,n){const i=ie().links.openExternal;i&&(t.preventDefault(),i(n))}function Rt({href:t,onClick:n,...i}){return l.jsx("a",{...i,href:t,target:"_blank",rel:"noreferrer",onClick:r=>{n==null||n(r),r.defaultPrevented||Le(r,t)}})}function Te(t,n){return{provider:t,authType:n,phase:"starting",statusLines:[]}}function Me(t,n,i){return{...t,phase:t.phase==="starting"?"waiting":t.phase,statusLines:[...t.statusLines,{kind:"info",message:n,links:i}]}}function Pe(t,n){const i=t.statusLines.filter(r=>r.kind!=="progress");return{...t,phase:t.phase==="starting"?"waiting":t.phase,statusLines:[...i,{kind:"progress",message:n}]}}function ve(t,n,i){return{...t,authUrl:{url:n,instructions:i}}}function je(t,n,i,r,e){return{...t,deviceCode:{userCode:n,verificationUri:i,intervalSeconds:r,expiresInSeconds:e}}}function De(t,n){return{...t,phase:"prompt",prompt:n}}function xe(t,n){var i;return((i=t.prompt)==null?void 0:i.promptId)!==n?t:{...t,phase:"waiting",prompt:void 0}}function ke(t,n,i){return{...t,phase:"done",result:{ok:n,error:i}}}function Ue(t,n){if(t.phase==="done")return t;switch(n.kind){case"info":return Me(t,n.message,n.links);case"progress":return Pe(t,n.message);case"auth_url":return ve(t,n.url,n.instructions);case"device_code":return je(t,n.userCode,n.verificationUri,n.intervalSeconds,n.expiresInSeconds);case"prompt":return De(t,n);case"prompt_cancelled":return xe(t,n.promptId);case"done":return ke(t,n.ok,n.error)}}var V={},nt,Mt;function qe(){return Mt||(Mt=1,nt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),nt}var rt={},U={},Pt;function F(){if(Pt)return U;Pt=1;let t;const n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return U.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},U.getSymbolTotalCodewords=function(r){return n[r]},U.getBCHDigit=function(i){let r=0;for(;i!==0;)r++,i>>>=1;return r},U.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},U.isKanjiModeEnabled=function(){return typeof t<"u"},U.toSJIS=function(r){return t(r)},U}var ot={},vt;function At(){return vt||(vt=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function n(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+i)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,e){if(t.isValid(r))return r;try{return n(r)}catch{return e}}})(ot)),ot}var it,jt;function Fe(){if(jt)return it;jt=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(n){const i=Math.floor(n/8);return(this.buffer[i]>>>7-n%8&1)===1},put:function(n,i){for(let r=0;r<i;r++)this.putBit((n>>>i-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const i=Math.floor(this.length/8);this.buffer.length<=i&&this.buffer.push(0),n&&(this.buffer[i]|=128>>>this.length%8),this.length++}},it=t,it}var st,Dt;function ze(){if(Dt)return st;Dt=1;function t(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}return t.prototype.set=function(n,i,r,e){const o=n*this.size+i;this.data[o]=r,e&&(this.reservedBit[o]=!0)},t.prototype.get=function(n,i){return this.data[n*this.size+i]},t.prototype.xor=function(n,i,r){this.data[n*this.size+i]^=r},t.prototype.isReserved=function(n,i){return this.reservedBit[n*this.size+i]},st=t,st}var at={},xt;function Ke(){return xt||(xt=1,(function(t){const n=F().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const e=Math.floor(r/7)+2,o=n(r),s=o===145?26:Math.ceil((o-13)/(2*e-2))*2,a=[o-7];for(let u=1;u<e-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},t.getPositions=function(r){const e=[],o=t.getRowColCoords(r),s=o.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||e.push([o[a],o[u]]);return e}})(at)),at}var ut={},kt;function Ve(){if(kt)return ut;kt=1;const t=F().getSymbolSize,n=7;return ut.getPositions=function(r){const e=t(r);return[[0,0],[e-n,0],[0,e-n]]},ut}var ct={},Ut;function Oe(){return Ut||(Ut=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const n={N1:3,N2:3,N3:40,N4:10};t.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){const o=e.size;let s=0,a=0,u=0,c=null,m=null;for(let E=0;E<o;E++){a=u=0,c=m=null;for(let S=0;S<o;S++){let h=e.get(E,S);h===c?a++:(a>=5&&(s+=n.N1+(a-5)),c=h,a=1),h=e.get(S,E),h===m?u++:(u>=5&&(s+=n.N1+(u-5)),m=h,u=1)}a>=5&&(s+=n.N1+(a-5)),u>=5&&(s+=n.N1+(u-5))}return s},t.getPenaltyN2=function(e){const o=e.size;let s=0;for(let a=0;a<o-1;a++)for(let u=0;u<o-1;u++){const c=e.get(a,u)+e.get(a,u+1)+e.get(a+1,u)+e.get(a+1,u+1);(c===4||c===0)&&s++}return s*n.N2},t.getPenaltyN3=function(e){const o=e.size;let s=0,a=0,u=0;for(let c=0;c<o;c++){a=u=0;for(let m=0;m<o;m++)a=a<<1&2047|e.get(c,m),m>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|e.get(m,c),m>=10&&(u===1488||u===93)&&s++}return s*n.N3},t.getPenaltyN4=function(e){let o=0;const s=e.data.length;for(let u=0;u<s;u++)o+=e.data[u];return Math.abs(Math.ceil(o*100/s/5)-10)*n.N4};function i(r,e,o){switch(r){case t.Patterns.PATTERN000:return(e+o)%2===0;case t.Patterns.PATTERN001:return e%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(e+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return e*o%2+e*o%3===0;case t.Patterns.PATTERN110:return(e*o%2+e*o%3)%2===0;case t.Patterns.PATTERN111:return(e*o%3+(e+o)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(e,o){const s=o.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)o.isReserved(u,a)||o.xor(u,a,i(e,u,a))},t.getBestMask=function(e,o){const s=Object.keys(t.Patterns).length;let a=0,u=1/0;for(let c=0;c<s;c++){o(c),t.applyMask(c,e);const m=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(c,e),m<u&&(u=m,a=c)}return a}})(ct)),ct}var W={},qt;function ce(){if(qt)return W;qt=1;const t=At(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return W.getBlocksCount=function(e,o){switch(o){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},W.getTotalCodewordsCount=function(e,o){switch(o){case t.L:return i[(e-1)*4+0];case t.M:return i[(e-1)*4+1];case t.Q:return i[(e-1)*4+2];case t.H:return i[(e-1)*4+3];default:return}},W}var lt={},Q={},Ft;function He(){if(Ft)return Q;Ft=1;const t=new Uint8Array(512),n=new Uint8Array(256);return(function(){let r=1;for(let e=0;e<255;e++)t[e]=r,n[r]=e,r<<=1,r&256&&(r^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),Q.log=function(r){if(r<1)throw new Error("log("+r+")");return n[r]},Q.exp=function(r){return t[r]},Q.mul=function(r,e){return r===0||e===0?0:t[n[r]+n[e]]},Q}var zt;function Qe(){return zt||(zt=1,(function(t){const n=He();t.mul=function(r,e){const o=new Uint8Array(r.length+e.length-1);for(let s=0;s<r.length;s++)for(let a=0;a<e.length;a++)o[s+a]^=n.mul(r[s],e[a]);return o},t.mod=function(r,e){let o=new Uint8Array(r);for(;o.length-e.length>=0;){const s=o[0];for(let u=0;u<e.length;u++)o[u]^=n.mul(e[u],s);let a=0;for(;a<o.length&&o[a]===0;)a++;o=o.slice(a)}return o},t.generateECPolynomial=function(r){let e=new Uint8Array([1]);for(let o=0;o<r;o++)e=t.mul(e,new Uint8Array([1,n.exp(o)]));return e}})(lt)),lt}var dt,Kt;function Je(){if(Kt)return dt;Kt=1;const t=Qe();function n(i){this.genPoly=void 0,this.degree=i,this.degree&&this.initialize(this.degree)}return n.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},n.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(r.length+this.degree);e.set(r);const o=t.mod(e,this.genPoly),s=this.degree-o.length;if(s>0){const a=new Uint8Array(this.degree);return a.set(o,s),a}return o},dt=n,dt}var ft={},ht={},gt={},Vt;function le(){return Vt||(Vt=1,gt.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}),gt}var D={},Ot;function de(){if(Ot)return D;Ot=1;const t="[0-9]+",n="[A-Z $%*+\\-./:]+";let i="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";i=i.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+i+`)(?:.|[\r
|
|
2
2
|
]))+`;D.KANJI=new RegExp(i,"g"),D.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),D.BYTE=new RegExp(r,"g"),D.NUMERIC=new RegExp(t,"g"),D.ALPHANUMERIC=new RegExp(n,"g");const e=new RegExp("^"+i+"$"),o=new RegExp("^"+t+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return D.testKanji=function(u){return e.test(u)},D.testNumeric=function(u){return o.test(u)},D.testAlphanumeric=function(u){return s.test(u)},D}var Ht;function z(){return Ht||(Ht=1,(function(t){const n=le(),i=de();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(o,s){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!n.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?o.ccBits[0]:s<27?o.ccBits[1]:o.ccBits[2]},t.getBestModeForData=function(o){return i.testNumeric(o)?t.NUMERIC:i.testAlphanumeric(o)?t.ALPHANUMERIC:i.testKanji(o)?t.KANJI:t.BYTE},t.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},t.isValid=function(o){return o&&o.bit&&o.ccBits};function r(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}t.from=function(o,s){if(t.isValid(o))return o;try{return r(o)}catch{return s}}})(ht)),ht}var Qt;function Ye(){return Qt||(Qt=1,(function(t){const n=F(),i=ce(),r=At(),e=z(),o=le(),s=7973,a=n.getBCHDigit(s);function u(S,h,_){for(let d=1;d<=40;d++)if(h<=t.getCapacity(d,_,S))return d}function c(S,h){return e.getCharCountIndicator(S,h)+4}function m(S,h){let _=0;return S.forEach(function(d){const P=c(d.mode,h);_+=P+d.getBitsLength()}),_}function E(S,h){for(let _=1;_<=40;_++)if(m(S,_)<=t.getCapacity(_,h,e.MIXED))return _}t.from=function(h,_){return o.isValid(h)?parseInt(h,10):_},t.getCapacity=function(h,_,d){if(!o.isValid(h))throw new Error("Invalid QR Code version");typeof d>"u"&&(d=e.BYTE);const P=n.getSymbolTotalCodewords(h),b=i.getTotalCodewordsCount(h,_),L=(P-b)*8;if(d===e.MIXED)return L;const A=L-c(d,h);switch(d){case e.NUMERIC:return Math.floor(A/10*3);case e.ALPHANUMERIC:return Math.floor(A/11*2);case e.KANJI:return Math.floor(A/13);case e.BYTE:default:return Math.floor(A/8)}},t.getBestVersionForData=function(h,_){let d;const P=r.from(_,r.M);if(Array.isArray(h)){if(h.length>1)return E(h,P);if(h.length===0)return 1;d=h[0]}else d=h;return u(d.mode,d.getLength(),P)},t.getEncodedBits=function(h){if(!o.isValid(h)||h<7)throw new Error("Invalid QR Code version");let _=h<<12;for(;n.getBCHDigit(_)-a>=0;)_^=s<<n.getBCHDigit(_)-a;return h<<12|_}})(ft)),ft}var pt={},Jt;function $e(){if(Jt)return pt;Jt=1;const t=F(),n=1335,i=21522,r=t.getBCHDigit(n);return pt.getEncodedBits=function(o,s){const a=o.bit<<3|s;let u=a<<10;for(;t.getBCHDigit(u)-r>=0;)u^=n<<t.getBCHDigit(u)-r;return(a<<10|u)^i},pt}var mt={},wt,Yt;function Ge(){if(Yt)return wt;Yt=1;const t=z();function n(i){this.mode=t.NUMERIC,this.data=i.toString()}return n.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let e,o,s;for(e=0;e+3<=this.data.length;e+=3)o=this.data.substr(e,3),s=parseInt(o,10),r.put(s,10);const a=this.data.length-e;a>0&&(o=this.data.substr(e),s=parseInt(o,10),r.put(s,a*3+1))},wt=n,wt}var yt,$t;function We(){if($t)return yt;$t=1;const t=z(),n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(r){this.mode=t.ALPHANUMERIC,this.data=r}return i.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let o;for(o=0;o+2<=this.data.length;o+=2){let s=n.indexOf(this.data[o])*45;s+=n.indexOf(this.data[o+1]),e.put(s,11)}this.data.length%2&&e.put(n.indexOf(this.data[o]),6)},yt=i,yt}var Ct,Gt;function Xe(){if(Gt)return Ct;Gt=1;const t=z();function n(i){this.mode=t.BYTE,typeof i=="string"?this.data=new TextEncoder().encode(i):this.data=new Uint8Array(i)}return n.getBitsLength=function(r){return r*8},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){for(let r=0,e=this.data.length;r<e;r++)i.put(this.data[r],8)},Ct=n,Ct}var Et,Wt;function Ze(){if(Wt)return Et;Wt=1;const t=z(),n=F();function i(r){this.mode=t.KANJI,this.data=r}return i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(r){let e;for(e=0;e<this.data.length;e++){let o=n.toSJIS(this.data[e]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+`
|
|
3
3
|
Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),r.put(o,13)}},Et=i,Et}var Xt;function tn(){return Xt||(Xt=1,(function(t){const n=z(),i=Ge(),r=We(),e=Xe(),o=Ze(),s=de(),a=F(),u=Ce();function c(b){return unescape(encodeURIComponent(b)).length}function m(b,L,A){const R=[];let M;for(;(M=b.exec(A))!==null;)R.push({data:M[0],index:M.index,mode:L,length:M[0].length});return R}function E(b){const L=m(s.NUMERIC,n.NUMERIC,b),A=m(s.ALPHANUMERIC,n.ALPHANUMERIC,b);let R,M;return a.isKanjiModeEnabled()?(R=m(s.BYTE,n.BYTE,b),M=m(s.KANJI,n.KANJI,b)):(R=m(s.BYTE_KANJI,n.BYTE,b),M=[]),L.concat(A,R,M).sort(function(N,w){return N.index-w.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function S(b,L){switch(L){case n.NUMERIC:return i.getBitsLength(b);case n.ALPHANUMERIC:return r.getBitsLength(b);case n.KANJI:return o.getBitsLength(b);case n.BYTE:return e.getBitsLength(b)}}function h(b){return b.reduce(function(L,A){const R=L.length-1>=0?L[L.length-1]:null;return R&&R.mode===A.mode?(L[L.length-1].data+=A.data,L):(L.push(A),L)},[])}function _(b){const L=[];for(let A=0;A<b.length;A++){const R=b[A];switch(R.mode){case n.NUMERIC:L.push([R,{data:R.data,mode:n.ALPHANUMERIC,length:R.length},{data:R.data,mode:n.BYTE,length:R.length}]);break;case n.ALPHANUMERIC:L.push([R,{data:R.data,mode:n.BYTE,length:R.length}]);break;case n.KANJI:L.push([R,{data:R.data,mode:n.BYTE,length:c(R.data)}]);break;case n.BYTE:L.push([{data:R.data,mode:n.BYTE,length:c(R.data)}])}}return L}function d(b,L){const A={},R={start:{}};let M=["start"];for(let p=0;p<b.length;p++){const N=b[p],w=[];for(let g=0;g<N.length;g++){const I=N[g],y=""+p+g;w.push(y),A[y]={node:I,lastCount:0},R[y]={};for(let B=0;B<M.length;B++){const C=M[B];A[C]&&A[C].node.mode===I.mode?(R[C][y]=S(A[C].lastCount+I.length,I.mode)-S(A[C].lastCount,I.mode),A[C].lastCount+=I.length):(A[C]&&(A[C].lastCount=I.length),R[C][y]=S(I.length,I.mode)+4+n.getCharCountIndicator(I.mode,L))}}M=w}for(let p=0;p<M.length;p++)R[M[p]].end=0;return{map:R,table:A}}function P(b,L){let A;const R=n.getBestModeForData(b);if(A=n.from(L,R),A!==n.BYTE&&A.bit<R.bit)throw new Error('"'+b+'" cannot be encoded with mode '+n.toString(A)+`.
|
|
4
4
|
Suggested mode is: `+n.toString(R));switch(A===n.KANJI&&!a.isKanjiModeEnabled()&&(A=n.BYTE),A){case n.NUMERIC:return new i(b);case n.ALPHANUMERIC:return new r(b);case n.KANJI:return new o(b);case n.BYTE:return new e(b)}}t.fromArray=function(L){return L.reduce(function(A,R){return typeof R=="string"?A.push(P(R,null)):R.data&&A.push(P(R.data,R.mode)),A},[])},t.fromString=function(L,A){const R=E(L,a.isKanjiModeEnabled()),M=_(R),p=d(M,A),N=u.find_path(p.map,"start","end"),w=[];for(let g=1;g<N.length-1;g++)w.push(p.table[N[g]].node);return t.fromArray(h(w))},t.rawSplit=function(L){return t.fromArray(E(L,a.isKanjiModeEnabled()))}})(mt)),mt}var Zt;function en(){if(Zt)return rt;Zt=1;const t=F(),n=At(),i=Fe(),r=ze(),e=Ke(),o=Ve(),s=Oe(),a=ce(),u=Je(),c=Ye(),m=$e(),E=z(),S=tn();function h(p,N){const w=p.size,g=o.getPositions(N);for(let I=0;I<g.length;I++){const y=g[I][0],B=g[I][1];for(let C=-1;C<=7;C++)if(!(y+C<=-1||w<=y+C))for(let f=-1;f<=7;f++)B+f<=-1||w<=B+f||(C>=0&&C<=6&&(f===0||f===6)||f>=0&&f<=6&&(C===0||C===6)||C>=2&&C<=4&&f>=2&&f<=4?p.set(y+C,B+f,!0,!0):p.set(y+C,B+f,!1,!0))}}function _(p){const N=p.size;for(let w=8;w<N-8;w++){const g=w%2===0;p.set(w,6,g,!0),p.set(6,w,g,!0)}}function d(p,N){const w=e.getPositions(N);for(let g=0;g<w.length;g++){const I=w[g][0],y=w[g][1];for(let B=-2;B<=2;B++)for(let C=-2;C<=2;C++)B===-2||B===2||C===-2||C===2||B===0&&C===0?p.set(I+B,y+C,!0,!0):p.set(I+B,y+C,!1,!0)}}function P(p,N){const w=p.size,g=c.getEncodedBits(N);let I,y,B;for(let C=0;C<18;C++)I=Math.floor(C/3),y=C%3+w-8-3,B=(g>>C&1)===1,p.set(I,y,B,!0),p.set(y,I,B,!0)}function b(p,N,w){const g=p.size,I=m.getEncodedBits(N,w);let y,B;for(y=0;y<15;y++)B=(I>>y&1)===1,y<6?p.set(y,8,B,!0):y<8?p.set(y+1,8,B,!0):p.set(g-15+y,8,B,!0),y<8?p.set(8,g-y-1,B,!0):y<9?p.set(8,15-y-1+1,B,!0):p.set(8,15-y-1,B,!0);p.set(g-8,8,1,!0)}function L(p,N){const w=p.size;let g=-1,I=w-1,y=7,B=0;for(let C=w-1;C>0;C-=2)for(C===6&&C--;;){for(let f=0;f<2;f++)if(!p.isReserved(I,C-f)){let j=!1;B<N.length&&(j=(N[B]>>>y&1)===1),p.set(I,C-f,j),y--,y===-1&&(B++,y=7)}if(I+=g,I<0||w<=I){I-=g,g=-g;break}}}function A(p,N,w){const g=new i;w.forEach(function(f){g.put(f.mode.bit,4),g.put(f.getLength(),E.getCharCountIndicator(f.mode,p)),f.write(g)});const I=t.getSymbolTotalCodewords(p),y=a.getTotalCodewordsCount(p,N),B=(I-y)*8;for(g.getLengthInBits()+4<=B&&g.put(0,4);g.getLengthInBits()%8!==0;)g.putBit(0);const C=(B-g.getLengthInBits())/8;for(let f=0;f<C;f++)g.put(f%2?17:236,8);return R(g,p,N)}function R(p,N,w){const g=t.getSymbolTotalCodewords(N),I=a.getTotalCodewordsCount(N,w),y=g-I,B=a.getBlocksCount(N,w),C=g%B,f=B-C,j=Math.floor(g/B),q=Math.floor(y/B),Y=q+1,H=j-q,me=new u(H);let X=0;const $=new Array(B),bt=new Array(B);let Z=0;const we=new Uint8Array(p.buffer);for(let K=0;K<B;K++){const et=K<f?q:Y;$[K]=we.slice(X,X+et),bt[K]=me.encode($[K]),X+=et,Z=Math.max(Z,et)}const tt=new Uint8Array(g);let _t=0,x,k;for(x=0;x<Z;x++)for(k=0;k<B;k++)x<$[k].length&&(tt[_t++]=$[k][x]);for(x=0;x<H;x++)for(k=0;k<B;k++)tt[_t++]=bt[k][x];return tt}function M(p,N,w,g){let I;if(Array.isArray(p))I=S.fromArray(p);else if(typeof p=="string"){let j=N;if(!j){const q=S.rawSplit(p);j=c.getBestVersionForData(q,w)}I=S.fromString(p,j||40)}else throw new Error("Invalid data");const y=c.getBestVersionForData(I,w);if(!y)throw new Error("The amount of data is too big to be stored in a QR Code");if(!N)N=y;else if(N<y)throw new Error(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as s}from"./vendor-react-Dka9ZH0B.js";import{u as T,r as j,y as J,I,D as se,B as C,S as O,E as $,g as M,z as te}from"./index-DFue5iwi.js";import"./vendor-z183l2lP.js";import{a as D,u as ne}from"./vendor-query-CDNPrdQ8.js";import{C as re,T as q,b as ae,c as le}from"./vendor-icons-CSCeICuX.js";import{S as z}from"./StatusBadge-eoBBn7zF.js";import{S as oe}from"./Switch-DvBJf8Rd.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const ie=/^npm:\S+$/,ce=/^git:\S+$/,ue=/^ssh:\/\/\S+$/,de=/^git@[^\s:/]+:\S+$/,pe=/^https?:\/\/(?:[^\s/]*\.)?(?:github|gitlab)\.com\/\S+$/i,ge=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/\S+\.git$/,_e=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,G="[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?",he=new RegExp(`^${G}/${G}(?:@${G})?$`);function me(e){const t=e.trim();return t.length===0?null:ie.test(t)?{kind:"pi_npm",normalized:t}:ce.test(t)?{kind:"pi_git",normalized:t}:t==="~"||t.startsWith("~/")||t.startsWith("/")?{kind:"local_path",normalized:t}:de.test(t)||ue.test(t)||pe.test(t)||ge.test(t)?{kind:"skills_repo",normalized:t}:_e.test(t)?null:he.test(t)?{kind:"skills_repo",normalized:t}:null}const ke="_wrapper_14joh_3",fe="_box_14joh_18",Se="_checkmark_14joh_38",we="_nativeInput_14joh_43",F={wrapper:ke,box:fe,checkmark:Se,nativeInput:we},K=h.forwardRef(function({label:t,checked:a=!1,disabled:r,className:l,onChange:o,...c},g){return s.jsxs("label",{className:F.wrapper,"data-disabled":r||void 0,children:[s.jsx("input",{ref:g,type:"checkbox",className:F.nativeInput,checked:a,disabled:r,onChange:o,...c}),s.jsx("span",{className:F.box,"data-checked":a,"aria-hidden":!0,children:a&&s.jsx(re,{size:12,className:F.checkmark})}),t&&s.jsx("span",{children:t})]})}),Q={agent_dir:"Pi skills",agents_dir:"Agent Skills",settings_path:"Skill paths"},W=new Set(["agent_dir","agents_dir"]);function ve(e,t){return W.has(e.origin)&&t.some(r=>r!==e&&r.name===e.name&&W.has(r.origin))?`Pi applies this setting to every '${e.name}' skill folder.`:null}function xe(e,t,a){var o;const r=!!e.shadowedBy,l=[];if(r){const c=e.shadowedBy?a.get(e.shadowedBy):void 0;l.push({label:`shadowed by ${(c==null?void 0:c.originLabel)??e.shadowedBy}`,variant:"warning"})}return e.symlinkTarget&&l.push({label:`→ ${e.symlinkTarget}`,variant:"muted"}),e.disableModelInvocation&&l.push({label:"manual only",variant:"muted"}),(o=e.provenance)!=null&&o.source&&l.push({label:e.provenance.source,variant:"muted"}),{skill:e,muted:r,toggleDisabled:r,badges:l,warnings:e.warnings??[],sharedPatternTooltip:ve(e,t)}}function Re(e){const t=[{label:e.kind,variant:"muted"}];return e.curated&&t.push({label:"curated",variant:"success"}),e.pinned&&t.push({label:"pinned",variant:"muted"}),t}function be(e,t){const a=new Map(e.map(u=>[u.path,u])),r=u=>xe(u,e,a),l=[],o=e.filter(u=>u.origin==="agent_dir").map(r);o.length>0&&l.push({id:"agent_dir",label:Q.agent_dir,rows:o});const c=e.filter(u=>u.origin==="agents_dir").map(r);c.length>0&&l.push({id:"agents_dir",label:Q.agents_dir,rows:c});const g=e.filter(u=>u.origin==="package"),d=new Set;for(const u of t){d.add(u.source);const v=g.filter(w=>w.packageSource===u.source).map(r);v.length>0&&l.push({id:`package:${u.source}`,label:u.source,rows:v,packageInfo:u})}const n=Array.from(new Set(g.filter(u=>u.packageSource&&!d.has(u.packageSource)).map(u=>u.packageSource)));for(const u of n){const v=g.filter(w=>w.packageSource===u).map(r);v.length>0&&l.push({id:`package:${u}`,label:u,rows:v})}const i=e.filter(u=>u.origin==="settings_path").map(r);i.length>0&&l.push({id:"settings_path",label:Q.settings_path,rows:i});const k=new Set(["agent_dir","agents_dir","package","settings_path"]),f=Array.from(new Set(e.filter(u=>!k.has(u.origin)).map(u=>u.origin)));for(const u of f){const v=e.filter(w=>w.origin===u).map(r);v.length>0&&l.push({id:u,label:u,rows:v})}return l}function je(e,t){const a=t.trim().toLowerCase();return a?e.map(r=>({...r,rows:r.rows.filter(l=>l.skill.name.toLowerCase().includes(a)||(l.skill.description??"").toLowerCase().includes(a))})).filter(r=>r.rows.length>0):e}function Ee(e,t){if(e.origin!=="package"||!e.packageSource)return!1;const a=t.find(r=>r.source===e.packageSource);return!!(a!=null&&a.curated)}function ye(e){return e.symlinkTarget?`Removes the link only; ${e.symlinkTarget} is kept.`:e.origin==="agents_dir"&&e.provenance?`Removes '${e.name}' for every agent on this machine.`:e.origin==="settings_path"?`Removes the Pi settings entry that provides ${e.path} (other skills from the same folder stop loading too); files are kept.`:`Deletes ${e.path}.`}function Ne(e){const t=e.skillCount;return`Remove ${e.source}? This removes ${t} skill${t===1?"":"s"}.`}const Ae="Updates every Agent Skills skill and every unpinned Pi package; may take several minutes",Ce={"agent-skills":"Agent Skills","pi-packages":"Pi packages"};function ze(e){return Ce[e]??e}const Te={settings_unreadable:"Can't read settings.json — skills can't be loaded or changed until this is fixed.",invalid_source:"That source isn't recognized.",not_found:"That skill could not be found.",not_removable:"That skill can't be removed from here.",spawn_failed:"Could not run the skills command.",timeout:"Timed out."};function V(e){return{...e,ok:!0,error:void 0,message:void 0}}function Y(e){return e.results.length>0}function L(e,t){return e?t||(Te[e]??e):null}const Le={pi_npm:"npm package",pi_git:"git package",skills_repo:"Agent Skills repo",local_path:"Folder on daemon host"};function Pe(e){return e?Le[e.kind]:"Unrecognized"}function Z(e){return e==="pi_npm"||e==="pi_git"}function Ie(e){return e!==null}const De="Installs the package's skills only; its extensions stay disabled. Pi packages run with full system access — review the source before installing.";function Be(e){return e.installResult?"results":e.installPending?"running":e.previewPending?"previewing":e.previewResult?"pick":"source"}function $e(e){return e.map(t=>({skill:t,checked:t.valid,replace:!1}))}function X(e){return e.filter(t=>t.skill.valid&&t.checked&&(!t.skill.exists||t.replace)).map(t=>t.skill.name)}function Me(e){return e.some(t=>t.skill.valid&&t.checked&&t.skill.exists&&t.replace)}function Fe(e,t,a){return{...e,skills:e.skills.map(r=>r.path===t?{...r,enabled:a}:r)}}function Oe(){const e=T(a=>a.client),t=D();return h.useEffect(()=>{if(e)return e.onSkillsChanged(()=>{t.invalidateQueries({queryKey:j.skillsList()})})},[e,t]),ne({queryKey:j.skillsList(),queryFn:()=>{if(!e)throw new Error("not connected");return e.listSkills()},enabled:!!e})}function He(){const e=T(d=>d.client),t=D(),[a,r]=h.useState({}),[l,o]=h.useState({});function c(d){r(n=>{if(!(d in n))return n;const i={...n};return delete i[d],i})}async function g(d,n){if(!e)return;const i=d.path;c(i),o(f=>({...f,[i]:!0}));const k=t.getQueryData(j.skillsList());k&&t.setQueryData(j.skillsList(),Fe(k,i,n));try{const f=await e.setSkillEnabled(i,n);if(!f.ok){k&&t.setQueryData(j.skillsList(),k),r(u=>({...u,[i]:L(f.error,f.message)??"Failed to update skill."}));return}t.setQueryData(j.skillsList(),f)}catch(f){k&&t.setQueryData(j.skillsList(),k),r(u=>({...u,[i]:f instanceof Error?f.message:"Failed to update skill."}))}finally{o(f=>{const u={...f};return delete u[i],u})}}return{rowErrors:a,pending:l,toggle:g,clearRowError:c}}function Ue(e){return e.path??`package:${e.packageSource}`}function Ge(){const e=T(d=>d.client),t=D(),[a,r]=h.useState({}),[l,o]=h.useState({});function c(d){o(n=>{if(!(d in n))return n;const i={...n};return delete i[d],i})}async function g(d){if(!e)return;const n=Ue(d);c(n),r(i=>({...i,[n]:!0}));try{const i=await e.removeSkill(d);if(!i.ok){o(k=>({...k,[n]:L(i.error,i.message)??"Failed to remove."}));return}t.setQueryData(j.skillsList(),i)}catch(i){o(k=>({...k,[n]:i instanceof Error?i.message:"Failed to remove."}))}finally{r(i=>{const k={...i};return delete k[n],k})}}return{pending:a,errors:l,clearError:c,removeSkill:d=>g({path:d.path}),removePackage:d=>g({packageSource:d.source})}}function Qe(){const e=T(n=>n.client),t=D(),[a,r]=h.useState(!1),[l,o]=h.useState(null),[c,g]=h.useState(null);async function d(){if(e){r(!0),g(null);try{const n=await e.updateAllSkills();if(!n.ok&&!Y(n)){g(L(n.error,n.message)??"Failed to update skills.");return}o(n),t.setQueryData(j.skillsList(),V(n))}catch(n){g(n instanceof Error?n.message:"Failed to update skills.")}finally{r(!1)}}}return{pending:a,result:l,error:c,updateAll:d,clearResult:()=>o(null)}}function qe(){const e=T(d=>d.client),[t,a]=h.useState(!1),[r,l]=h.useState(null),[o,c]=h.useState(null);async function g(d){if(e){a(!0),c(null);try{const n=await e.previewSkillSource(d);if(!n.ok){c(L(n.error,n.message)??"Failed to preview.");return}l(n)}catch(n){c(n instanceof Error?n.message:"Failed to preview.")}finally{a(!1)}}}return{pending:t,result:r,error:o,preview:g,reset:()=>{l(null),c(null)}}}function Ke(){const e=T(n=>n.client),t=D(),[a,r]=h.useState(!1),[l,o]=h.useState(null),[c,g]=h.useState(null);async function d(n){if(e){r(!0),g(null);try{const i=await e.installSkills(n);if(!i.ok&&!Y(i)){g(L(i.error,i.message)??"Failed to install.");return}o(i),t.setQueryData(j.skillsList(),V(i))}catch(i){g(i instanceof Error?i.message:"Failed to install.")}finally{r(!1)}}}return{pending:a,result:l,error:c,install:d,reset:()=>{o(null),g(null)}}}const We="_sourceStep_1n0el_6",Ze="_sourceLabel_1n0el_13",Xe="_notice_1n0el_18",Je="_error_1n0el_30",Ve="_statusStep_1n0el_35",Ye="_pickStep_1n0el_45",es="_pickRows_1n0el_52",ss="_pickRow_1n0el_52",ts="_pickRowMain_1n0el_73",ns="_pickRowTop_1n0el_80",rs="_pickRowName_1n0el_87",as="_pickRowDescription_1n0el_95",ls="_backButton_1n0el_103",os="_results_1n0el_107",is="_resultRow_1n0el_116",cs="_resultHeader_1n0el_125",us="_resultTarget_1n0el_132",ds="_resultError_1n0el_140",ps="_resultToggle_1n0el_148",gs="_resultStderr_1n0el_159",m={sourceStep:We,sourceLabel:Ze,notice:Xe,error:Je,statusStep:Ve,pickStep:Ye,pickRows:es,pickRow:ss,pickRowMain:ts,pickRowTop:ns,pickRowName:rs,pickRowDescription:as,backButton:ls,results:os,resultRow:is,resultHeader:cs,resultTarget:us,resultError:ds,resultToggle:ps,resultStderr:gs};function _s({open:e,onOpenChange:t}){var B;const a=qe(),r=Ke(),[l,o]=h.useState(""),[c,g]=h.useState([]),d=h.useRef(!1),n=me(l),i=Be({previewPending:a.pending,previewResult:a.result,installPending:r.pending,installResult:r.result});h.useEffect(()=>{e&&!d.current&&!r.pending&&!r.result&&(o(""),g([]),a.reset()),d.current=e},[e]),h.useEffect(()=>{a.result&&g($e(a.result.skills))},[a.result]);async function k(){if(n){if(Z(n.kind)){await r.install({source:n.normalized});return}await a.preview(n.normalized)}}function f(x,N){g(P=>P.map((_,b)=>b===x?{..._,...N}:_))}async function u(){var N;const x=X(c);x.length!==0&&await r.install({source:((N=a.result)==null?void 0:N.source)??(n==null?void 0:n.normalized)??l,skills:x,replace:Me(c)})}function v(){a.reset(),g([])}function w(){r.reset(),t(!1)}const H=((B=a.result)==null?void 0:B.source)??(n==null?void 0:n.normalized)??l,U=X(c).length;let y,E;return i==="source"?(y=s.jsxs("div",{className:m.sourceStep,children:[s.jsx(J,{autoFocus:!0,placeholder:"npm:<name>, git:<url>, owner/repo, or a daemon-host path",value:l,onChange:x=>o(x.target.value),"aria-label":"Install source"}),s.jsx("div",{className:m.sourceLabel,children:Pe(n)}),n&&Z(n.kind)&&s.jsxs("div",{className:m.notice,children:[s.jsx(I,{icon:q,size:"xs"}),s.jsx("span",{children:De})]}),a.error&&s.jsx("div",{className:m.error,children:a.error})]}),E=s.jsx(C,{size:"sm",disabled:!Ie(n),loading:r.pending,onClick:()=>void k(),children:"Next"})):i==="previewing"?(y=s.jsxs("div",{className:m.statusStep,children:[s.jsx(O,{size:"sm"})," Looking up the source…"]}),E=null):i==="pick"?(y=s.jsxs("div",{className:m.pickStep,children:[c.length===0?s.jsx("div",{className:m.statusStep,children:"No installable skills found."}):s.jsx("div",{className:m.pickRows,children:c.map((x,N)=>s.jsx(hs,{row:x,onChange:P=>f(N,P)},x.skill.relPath))}),r.error&&s.jsx("div",{className:m.error,children:r.error})]}),E=s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"sm",variant:"ghost",className:m.backButton,onClick:v,children:"‹ Back"}),s.jsxs(C,{size:"sm",disabled:U===0,loading:r.pending,onClick:()=>void u(),children:["Install from ",H]})]})):i==="running"?(y=s.jsxs("div",{className:m.statusStep,children:[s.jsx(O,{size:"sm"})," Installing… this may take several minutes"]}),E=null):(y=r.result?s.jsx(ms,{result:r.result}):null,E=s.jsx(C,{size:"sm",onClick:w,children:"Done"})),s.jsx(se,{open:e,onOpenChange:x=>{if(!x&&i==="results"){w();return}t(x)},title:"Install skill…",width:480,footer:E,children:y})}function hs({row:e,onChange:t}){const{skill:a,checked:r,replace:l}=e,o=!a.valid;return s.jsxs("div",{className:m.pickRow,"data-disabled":o||void 0,children:[s.jsx(K,{checked:r&&a.valid,disabled:o,onChange:c=>t({checked:c.target.checked}),"aria-label":a.name}),s.jsxs("div",{className:m.pickRowMain,children:[s.jsxs("div",{className:m.pickRowTop,children:[s.jsx("span",{className:m.pickRowName,children:a.name}),!a.valid&&s.jsx(z,{label:"Invalid",variant:"error"}),a.exists&&s.jsx(z,{label:"Already installed",variant:"warning"}),a.warnings&&a.warnings.length>0&&s.jsx(I,{icon:q,size:"xs",color:"var(--pi-color-statusWarning)","aria-label":a.warnings.join("; ")})]}),a.description&&s.jsx("span",{className:m.pickRowDescription,children:a.description}),a.exists&&a.valid&&s.jsx(K,{label:"Already installed — replace",checked:l,onChange:c=>t({replace:c.target.checked})})]})]})}function ms({result:e}){const[t,a]=h.useState(()=>new Set);function r(l){a(o=>{const c=new Set(o);return c.has(l)?c.delete(l):c.add(l),c})}return s.jsx("div",{className:m.results,children:e.results.map((l,o)=>{const c=t.has(o);return s.jsxs("div",{className:m.resultRow,children:[s.jsxs("div",{className:m.resultHeader,children:[s.jsx(z,{label:l.ok?"Installed":"Failed",variant:l.ok?"success":"error"}),s.jsx("span",{className:m.resultTarget,children:l.target}),l.error&&s.jsx("span",{className:m.resultError,children:l.error}),l.stderr&&s.jsx("button",{type:"button",className:m.resultToggle,onClick:()=>r(o),children:c?"Hide details":"Show details"})]}),c&&l.stderr&&s.jsx("pre",{className:m.resultStderr,children:l.stderr})]},`${l.target}-${o}`)})})}const ks="_panel_1tczp_1",fs="_toolbar_1tczp_7",Ss="_search_1tczp_14",ws="_groups_1tczp_19",vs="_group_1tczp_19",xs="_groupHeader_1tczp_30",Rs="_chevronExpanded_1tczp_47",bs="_groupLabel_1tczp_51",js="_groupBadges_1tczp_62",Es="_groupCount_1tczp_68",ys="_rows_1tczp_74",Ns="_row_1tczp_74",As="_rowMain_1tczp_91",Cs="_rowTop_1tczp_98",zs="_name_1tczp_105",Ts="_nameMuted_1tczp_113 _name_1tczp_105",Ls="_badge_1tczp_118",Ps="_description_1tczp_122",Is="_descriptionMuted_1tczp_130 _description_1tczp_122",Ds="_rowError_1tczp_135",Bs="_footnote_1tczp_147",$s="_errorState_1tczp_153",Ms="_removePackageBtn_1tczp_157",Fs="_rowActions_1tczp_161",Os="_updateAllResults_1tczp_168",Hs="_updateAllResultRow_1tczp_178",Us="_updateAllResultHeader_1tczp_184",Gs="_updateAllResultLabel_1tczp_191",Qs="_updateAllResultError_1tczp_196",qs="_updateAllResultToggle_1tczp_204",Ks="_updateAllResultStderr_1tczp_215",p={panel:ks,toolbar:fs,search:Ss,groups:ws,group:vs,groupHeader:xs,chevronExpanded:Rs,groupLabel:bs,groupBadges:js,groupCount:Es,rows:ys,row:Ns,rowMain:As,rowTop:Cs,name:zs,nameMuted:Ts,badge:Ls,description:Ps,descriptionMuted:Is,rowError:Ds,footnote:Bs,errorState:$s,removePackageBtn:Ms,rowActions:Fs,updateAllResults:Os,updateAllResultRow:Hs,updateAllResultHeader:Us,updateAllResultLabel:Gs,updateAllResultError:Qs,updateAllResultToggle:qs,updateAllResultStderr:Ks};function lt(){const{data:e,isLoading:t,isError:a,error:r}=Oe(),{rowErrors:l,pending:o,toggle:c,clearRowError:g}=He(),d=Ge(),n=Qe(),[i,k]=h.useState(""),[f,u]=h.useState(()=>new Set),[v,w]=h.useState(!1),[H,U]=h.useState(()=>new Set);function y(_){u(b=>{const R=new Set(b);return R.has(_)?R.delete(_):R.add(_),R})}if(t)return s.jsxs($,{children:[s.jsx(O,{size:"sm"})," Loading skills…"]});if(a)return s.jsx($,{className:p.errorState,children:r instanceof Error?r.message:"Failed to load skills."});if(!e)return null;if(!e.ok)return s.jsx($,{className:p.errorState,children:L(e.error,e.message)??"Could not load skills."});const E=je(be(e.skills,e.packages),i);async function B(_,b){if(b&&_.packageSource&&Ee(_,e.packages)&&!H.has(_.packageSource)){if(!await M().dialogs.confirm("Pi-Studio will stop managing this package's updates."))return;U(A=>new Set(A).add(_.packageSource))}c(_,b)}async function x(_){await M().dialogs.confirm(ye(_))&&d.removeSkill(_)}async function N(_){await M().dialogs.confirm(Ne(_))&&d.removePackage(_)}async function P(){await M().dialogs.confirm(Ae)&&n.updateAll()}return s.jsxs("div",{className:p.panel,children:[s.jsxs("div",{className:p.toolbar,children:[s.jsx(J,{className:p.search,placeholder:"Search skills…",value:i,onChange:_=>k(_.target.value),"aria-label":"Search skills"}),s.jsx(C,{size:"sm",variant:"outline",loading:n.pending,onClick:P,children:"Update all"}),s.jsx(C,{size:"sm",onClick:()=>w(!0),children:"Install skill…"})]}),n.error&&s.jsx("button",{type:"button",className:p.rowError,onClick:()=>n.updateAll().catch(()=>{}),children:n.error}),n.result&&s.jsx(Ws,{result:n.result,onDismiss:n.clearResult}),E.length===0?s.jsx($,{children:i?"No skills match your search.":"No skills found."}):s.jsx("div",{className:p.groups,children:E.map(_=>{const b=f.has(_.id),R=_.packageInfo,A=R?`package:${R.source}`:void 0;return s.jsxs("div",{className:p.group,children:[s.jsxs("button",{type:"button",className:p.groupHeader,onClick:()=>y(_.id),"aria-expanded":!b,children:[s.jsx(I,{icon:ae,size:"xs",className:b?void 0:p.chevronExpanded}),s.jsx("span",{className:p.groupLabel,children:_.label}),R&&s.jsx("span",{className:p.groupBadges,children:Re(R).map(S=>s.jsx(z,{label:S.label,variant:S.variant},S.label))}),s.jsx("span",{className:p.groupCount,children:_.rows.length}),R&&s.jsx(C,{size:"xs",variant:"ghost",className:p.removePackageBtn,loading:A?!!d.pending[A]:!1,onClick:S=>{S.stopPropagation(),N(R)},children:"Remove package"})]}),A&&d.errors[A]&&s.jsx("button",{type:"button",className:p.rowError,onClick:()=>d.clearError(A),children:d.errors[A]}),!b&&s.jsx("div",{className:p.rows,children:_.rows.map(S=>s.jsx(Zs,{row:S,error:l[S.skill.path],pending:!!o[S.skill.path],removeError:d.errors[S.skill.path],removePending:!!d.pending[S.skill.path],onToggle:ee=>B(S.skill,ee),onDismissError:()=>g(S.skill.path),onRemove:()=>x(S.skill),onDismissRemoveError:()=>d.clearError(S.skill.path)},S.skill.path))})]},_.id)})}),s.jsx("p",{className:p.footnote,children:"Changes apply to newly started agent sessions."}),s.jsx(_s,{open:v,onOpenChange:w})]})}function Ws({result:e,onDismiss:t}){const[a,r]=h.useState(()=>new Set);function l(o){r(c=>{const g=new Set(c);return g.has(o)?g.delete(o):g.add(o),g})}return s.jsxs("div",{className:p.updateAllResults,children:[e.results.map(o=>{const c=a.has(o.target);return s.jsxs("div",{className:p.updateAllResultRow,children:[s.jsxs("div",{className:p.updateAllResultHeader,children:[s.jsx(z,{label:o.ok?"Succeeded":"Failed",variant:o.ok?"success":"error"}),s.jsx("span",{className:p.updateAllResultLabel,children:ze(o.target)}),o.error&&s.jsx("span",{className:p.updateAllResultError,children:o.error}),o.stderr&&s.jsx("button",{type:"button",className:p.updateAllResultToggle,onClick:()=>l(o.target),children:c?"Hide details":"Show details"})]}),c&&o.stderr&&s.jsx("pre",{className:p.updateAllResultStderr,children:o.stderr})]},o.target)}),s.jsx("button",{type:"button",className:p.rowError,onClick:t,children:"Dismiss"})]})}function Zs({row:e,error:t,pending:a,removeError:r,removePending:l,onToggle:o,onDismissError:c,onRemove:g,onDismissRemoveError:d}){const{skill:n,muted:i,toggleDisabled:k,badges:f,warnings:u,sharedPatternTooltip:v}=e;return s.jsxs("div",{className:p.row,title:v??void 0,children:[s.jsxs("div",{className:p.rowMain,children:[s.jsxs("div",{className:p.rowTop,children:[s.jsx("span",{className:i?p.nameMuted:p.name,children:n.name}),u.length>0&&s.jsx(I,{icon:q,size:"xs",color:"var(--pi-color-statusWarning)","aria-label":u.join("; ")}),f.map(w=>s.jsx(z,{label:w.label,variant:w.variant,className:p.badge},w.label))]}),n.description&&s.jsx("span",{className:i?p.descriptionMuted:p.description,children:n.description}),t&&s.jsx("button",{type:"button",className:p.rowError,onClick:c,children:t}),r&&s.jsx("button",{type:"button",className:p.rowError,onClick:d,children:r})]}),s.jsxs("div",{className:p.rowActions,children:[s.jsx(oe,{checked:n.enabled,disabled:k||a,onCheckedChange:o,"aria-label":n.name}),n.removable&&s.jsx(te,{"aria-label":`Remove ${n.name}`,disabled:l,onClick:g,children:l?s.jsx(O,{size:"xs"}):s.jsx(I,{icon:le,size:"xs"})})]})]})}export{lt as SkillsPanel};
|
|
1
|
+
import{r as h,j as s}from"./vendor-react-Dka9ZH0B.js";import{u as T,r as j,y as J,I,D as se,B as C,S as O,E as $,g as M,z as te}from"./index-B6VaYU8s.js";import"./vendor-z183l2lP.js";import{a as D,u as ne}from"./vendor-query-CDNPrdQ8.js";import{C as re,T as q,b as ae,c as le}from"./vendor-icons-CSCeICuX.js";import{S as z}from"./StatusBadge-eoBBn7zF.js";import{S as oe}from"./Switch-DvBJf8Rd.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const ie=/^npm:\S+$/,ce=/^git:\S+$/,ue=/^ssh:\/\/\S+$/,de=/^git@[^\s:/]+:\S+$/,pe=/^https?:\/\/(?:[^\s/]*\.)?(?:github|gitlab)\.com\/\S+$/i,ge=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/\S+\.git$/,_e=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,G="[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?",he=new RegExp(`^${G}/${G}(?:@${G})?$`);function me(e){const t=e.trim();return t.length===0?null:ie.test(t)?{kind:"pi_npm",normalized:t}:ce.test(t)?{kind:"pi_git",normalized:t}:t==="~"||t.startsWith("~/")||t.startsWith("/")?{kind:"local_path",normalized:t}:de.test(t)||ue.test(t)||pe.test(t)||ge.test(t)?{kind:"skills_repo",normalized:t}:_e.test(t)?null:he.test(t)?{kind:"skills_repo",normalized:t}:null}const ke="_wrapper_14joh_3",fe="_box_14joh_18",Se="_checkmark_14joh_38",we="_nativeInput_14joh_43",F={wrapper:ke,box:fe,checkmark:Se,nativeInput:we},K=h.forwardRef(function({label:t,checked:a=!1,disabled:r,className:l,onChange:o,...c},g){return s.jsxs("label",{className:F.wrapper,"data-disabled":r||void 0,children:[s.jsx("input",{ref:g,type:"checkbox",className:F.nativeInput,checked:a,disabled:r,onChange:o,...c}),s.jsx("span",{className:F.box,"data-checked":a,"aria-hidden":!0,children:a&&s.jsx(re,{size:12,className:F.checkmark})}),t&&s.jsx("span",{children:t})]})}),Q={agent_dir:"Pi skills",agents_dir:"Agent Skills",settings_path:"Skill paths"},W=new Set(["agent_dir","agents_dir"]);function ve(e,t){return W.has(e.origin)&&t.some(r=>r!==e&&r.name===e.name&&W.has(r.origin))?`Pi applies this setting to every '${e.name}' skill folder.`:null}function xe(e,t,a){var o;const r=!!e.shadowedBy,l=[];if(r){const c=e.shadowedBy?a.get(e.shadowedBy):void 0;l.push({label:`shadowed by ${(c==null?void 0:c.originLabel)??e.shadowedBy}`,variant:"warning"})}return e.symlinkTarget&&l.push({label:`→ ${e.symlinkTarget}`,variant:"muted"}),e.disableModelInvocation&&l.push({label:"manual only",variant:"muted"}),(o=e.provenance)!=null&&o.source&&l.push({label:e.provenance.source,variant:"muted"}),{skill:e,muted:r,toggleDisabled:r,badges:l,warnings:e.warnings??[],sharedPatternTooltip:ve(e,t)}}function Re(e){const t=[{label:e.kind,variant:"muted"}];return e.curated&&t.push({label:"curated",variant:"success"}),e.pinned&&t.push({label:"pinned",variant:"muted"}),t}function be(e,t){const a=new Map(e.map(u=>[u.path,u])),r=u=>xe(u,e,a),l=[],o=e.filter(u=>u.origin==="agent_dir").map(r);o.length>0&&l.push({id:"agent_dir",label:Q.agent_dir,rows:o});const c=e.filter(u=>u.origin==="agents_dir").map(r);c.length>0&&l.push({id:"agents_dir",label:Q.agents_dir,rows:c});const g=e.filter(u=>u.origin==="package"),d=new Set;for(const u of t){d.add(u.source);const v=g.filter(w=>w.packageSource===u.source).map(r);v.length>0&&l.push({id:`package:${u.source}`,label:u.source,rows:v,packageInfo:u})}const n=Array.from(new Set(g.filter(u=>u.packageSource&&!d.has(u.packageSource)).map(u=>u.packageSource)));for(const u of n){const v=g.filter(w=>w.packageSource===u).map(r);v.length>0&&l.push({id:`package:${u}`,label:u,rows:v})}const i=e.filter(u=>u.origin==="settings_path").map(r);i.length>0&&l.push({id:"settings_path",label:Q.settings_path,rows:i});const k=new Set(["agent_dir","agents_dir","package","settings_path"]),f=Array.from(new Set(e.filter(u=>!k.has(u.origin)).map(u=>u.origin)));for(const u of f){const v=e.filter(w=>w.origin===u).map(r);v.length>0&&l.push({id:u,label:u,rows:v})}return l}function je(e,t){const a=t.trim().toLowerCase();return a?e.map(r=>({...r,rows:r.rows.filter(l=>l.skill.name.toLowerCase().includes(a)||(l.skill.description??"").toLowerCase().includes(a))})).filter(r=>r.rows.length>0):e}function Ee(e,t){if(e.origin!=="package"||!e.packageSource)return!1;const a=t.find(r=>r.source===e.packageSource);return!!(a!=null&&a.curated)}function ye(e){return e.symlinkTarget?`Removes the link only; ${e.symlinkTarget} is kept.`:e.origin==="agents_dir"&&e.provenance?`Removes '${e.name}' for every agent on this machine.`:e.origin==="settings_path"?`Removes the Pi settings entry that provides ${e.path} (other skills from the same folder stop loading too); files are kept.`:`Deletes ${e.path}.`}function Ne(e){const t=e.skillCount;return`Remove ${e.source}? This removes ${t} skill${t===1?"":"s"}.`}const Ae="Updates every Agent Skills skill and every unpinned Pi package; may take several minutes",Ce={"agent-skills":"Agent Skills","pi-packages":"Pi packages"};function ze(e){return Ce[e]??e}const Te={settings_unreadable:"Can't read settings.json — skills can't be loaded or changed until this is fixed.",invalid_source:"That source isn't recognized.",not_found:"That skill could not be found.",not_removable:"That skill can't be removed from here.",spawn_failed:"Could not run the skills command.",timeout:"Timed out."};function V(e){return{...e,ok:!0,error:void 0,message:void 0}}function Y(e){return e.results.length>0}function L(e,t){return e?t||(Te[e]??e):null}const Le={pi_npm:"npm package",pi_git:"git package",skills_repo:"Agent Skills repo",local_path:"Folder on daemon host"};function Pe(e){return e?Le[e.kind]:"Unrecognized"}function Z(e){return e==="pi_npm"||e==="pi_git"}function Ie(e){return e!==null}const De="Installs the package's skills only; its extensions stay disabled. Pi packages run with full system access — review the source before installing.";function Be(e){return e.installResult?"results":e.installPending?"running":e.previewPending?"previewing":e.previewResult?"pick":"source"}function $e(e){return e.map(t=>({skill:t,checked:t.valid,replace:!1}))}function X(e){return e.filter(t=>t.skill.valid&&t.checked&&(!t.skill.exists||t.replace)).map(t=>t.skill.name)}function Me(e){return e.some(t=>t.skill.valid&&t.checked&&t.skill.exists&&t.replace)}function Fe(e,t,a){return{...e,skills:e.skills.map(r=>r.path===t?{...r,enabled:a}:r)}}function Oe(){const e=T(a=>a.client),t=D();return h.useEffect(()=>{if(e)return e.onSkillsChanged(()=>{t.invalidateQueries({queryKey:j.skillsList()})})},[e,t]),ne({queryKey:j.skillsList(),queryFn:()=>{if(!e)throw new Error("not connected");return e.listSkills()},enabled:!!e})}function He(){const e=T(d=>d.client),t=D(),[a,r]=h.useState({}),[l,o]=h.useState({});function c(d){r(n=>{if(!(d in n))return n;const i={...n};return delete i[d],i})}async function g(d,n){if(!e)return;const i=d.path;c(i),o(f=>({...f,[i]:!0}));const k=t.getQueryData(j.skillsList());k&&t.setQueryData(j.skillsList(),Fe(k,i,n));try{const f=await e.setSkillEnabled(i,n);if(!f.ok){k&&t.setQueryData(j.skillsList(),k),r(u=>({...u,[i]:L(f.error,f.message)??"Failed to update skill."}));return}t.setQueryData(j.skillsList(),f)}catch(f){k&&t.setQueryData(j.skillsList(),k),r(u=>({...u,[i]:f instanceof Error?f.message:"Failed to update skill."}))}finally{o(f=>{const u={...f};return delete u[i],u})}}return{rowErrors:a,pending:l,toggle:g,clearRowError:c}}function Ue(e){return e.path??`package:${e.packageSource}`}function Ge(){const e=T(d=>d.client),t=D(),[a,r]=h.useState({}),[l,o]=h.useState({});function c(d){o(n=>{if(!(d in n))return n;const i={...n};return delete i[d],i})}async function g(d){if(!e)return;const n=Ue(d);c(n),r(i=>({...i,[n]:!0}));try{const i=await e.removeSkill(d);if(!i.ok){o(k=>({...k,[n]:L(i.error,i.message)??"Failed to remove."}));return}t.setQueryData(j.skillsList(),i)}catch(i){o(k=>({...k,[n]:i instanceof Error?i.message:"Failed to remove."}))}finally{r(i=>{const k={...i};return delete k[n],k})}}return{pending:a,errors:l,clearError:c,removeSkill:d=>g({path:d.path}),removePackage:d=>g({packageSource:d.source})}}function Qe(){const e=T(n=>n.client),t=D(),[a,r]=h.useState(!1),[l,o]=h.useState(null),[c,g]=h.useState(null);async function d(){if(e){r(!0),g(null);try{const n=await e.updateAllSkills();if(!n.ok&&!Y(n)){g(L(n.error,n.message)??"Failed to update skills.");return}o(n),t.setQueryData(j.skillsList(),V(n))}catch(n){g(n instanceof Error?n.message:"Failed to update skills.")}finally{r(!1)}}}return{pending:a,result:l,error:c,updateAll:d,clearResult:()=>o(null)}}function qe(){const e=T(d=>d.client),[t,a]=h.useState(!1),[r,l]=h.useState(null),[o,c]=h.useState(null);async function g(d){if(e){a(!0),c(null);try{const n=await e.previewSkillSource(d);if(!n.ok){c(L(n.error,n.message)??"Failed to preview.");return}l(n)}catch(n){c(n instanceof Error?n.message:"Failed to preview.")}finally{a(!1)}}}return{pending:t,result:r,error:o,preview:g,reset:()=>{l(null),c(null)}}}function Ke(){const e=T(n=>n.client),t=D(),[a,r]=h.useState(!1),[l,o]=h.useState(null),[c,g]=h.useState(null);async function d(n){if(e){r(!0),g(null);try{const i=await e.installSkills(n);if(!i.ok&&!Y(i)){g(L(i.error,i.message)??"Failed to install.");return}o(i),t.setQueryData(j.skillsList(),V(i))}catch(i){g(i instanceof Error?i.message:"Failed to install.")}finally{r(!1)}}}return{pending:a,result:l,error:c,install:d,reset:()=>{o(null),g(null)}}}const We="_sourceStep_1n0el_6",Ze="_sourceLabel_1n0el_13",Xe="_notice_1n0el_18",Je="_error_1n0el_30",Ve="_statusStep_1n0el_35",Ye="_pickStep_1n0el_45",es="_pickRows_1n0el_52",ss="_pickRow_1n0el_52",ts="_pickRowMain_1n0el_73",ns="_pickRowTop_1n0el_80",rs="_pickRowName_1n0el_87",as="_pickRowDescription_1n0el_95",ls="_backButton_1n0el_103",os="_results_1n0el_107",is="_resultRow_1n0el_116",cs="_resultHeader_1n0el_125",us="_resultTarget_1n0el_132",ds="_resultError_1n0el_140",ps="_resultToggle_1n0el_148",gs="_resultStderr_1n0el_159",m={sourceStep:We,sourceLabel:Ze,notice:Xe,error:Je,statusStep:Ve,pickStep:Ye,pickRows:es,pickRow:ss,pickRowMain:ts,pickRowTop:ns,pickRowName:rs,pickRowDescription:as,backButton:ls,results:os,resultRow:is,resultHeader:cs,resultTarget:us,resultError:ds,resultToggle:ps,resultStderr:gs};function _s({open:e,onOpenChange:t}){var B;const a=qe(),r=Ke(),[l,o]=h.useState(""),[c,g]=h.useState([]),d=h.useRef(!1),n=me(l),i=Be({previewPending:a.pending,previewResult:a.result,installPending:r.pending,installResult:r.result});h.useEffect(()=>{e&&!d.current&&!r.pending&&!r.result&&(o(""),g([]),a.reset()),d.current=e},[e]),h.useEffect(()=>{a.result&&g($e(a.result.skills))},[a.result]);async function k(){if(n){if(Z(n.kind)){await r.install({source:n.normalized});return}await a.preview(n.normalized)}}function f(x,N){g(P=>P.map((_,b)=>b===x?{..._,...N}:_))}async function u(){var N;const x=X(c);x.length!==0&&await r.install({source:((N=a.result)==null?void 0:N.source)??(n==null?void 0:n.normalized)??l,skills:x,replace:Me(c)})}function v(){a.reset(),g([])}function w(){r.reset(),t(!1)}const H=((B=a.result)==null?void 0:B.source)??(n==null?void 0:n.normalized)??l,U=X(c).length;let y,E;return i==="source"?(y=s.jsxs("div",{className:m.sourceStep,children:[s.jsx(J,{autoFocus:!0,placeholder:"npm:<name>, git:<url>, owner/repo, or a daemon-host path",value:l,onChange:x=>o(x.target.value),"aria-label":"Install source"}),s.jsx("div",{className:m.sourceLabel,children:Pe(n)}),n&&Z(n.kind)&&s.jsxs("div",{className:m.notice,children:[s.jsx(I,{icon:q,size:"xs"}),s.jsx("span",{children:De})]}),a.error&&s.jsx("div",{className:m.error,children:a.error})]}),E=s.jsx(C,{size:"sm",disabled:!Ie(n),loading:r.pending,onClick:()=>void k(),children:"Next"})):i==="previewing"?(y=s.jsxs("div",{className:m.statusStep,children:[s.jsx(O,{size:"sm"})," Looking up the source…"]}),E=null):i==="pick"?(y=s.jsxs("div",{className:m.pickStep,children:[c.length===0?s.jsx("div",{className:m.statusStep,children:"No installable skills found."}):s.jsx("div",{className:m.pickRows,children:c.map((x,N)=>s.jsx(hs,{row:x,onChange:P=>f(N,P)},x.skill.relPath))}),r.error&&s.jsx("div",{className:m.error,children:r.error})]}),E=s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"sm",variant:"ghost",className:m.backButton,onClick:v,children:"‹ Back"}),s.jsxs(C,{size:"sm",disabled:U===0,loading:r.pending,onClick:()=>void u(),children:["Install from ",H]})]})):i==="running"?(y=s.jsxs("div",{className:m.statusStep,children:[s.jsx(O,{size:"sm"})," Installing… this may take several minutes"]}),E=null):(y=r.result?s.jsx(ms,{result:r.result}):null,E=s.jsx(C,{size:"sm",onClick:w,children:"Done"})),s.jsx(se,{open:e,onOpenChange:x=>{if(!x&&i==="results"){w();return}t(x)},title:"Install skill…",width:480,footer:E,children:y})}function hs({row:e,onChange:t}){const{skill:a,checked:r,replace:l}=e,o=!a.valid;return s.jsxs("div",{className:m.pickRow,"data-disabled":o||void 0,children:[s.jsx(K,{checked:r&&a.valid,disabled:o,onChange:c=>t({checked:c.target.checked}),"aria-label":a.name}),s.jsxs("div",{className:m.pickRowMain,children:[s.jsxs("div",{className:m.pickRowTop,children:[s.jsx("span",{className:m.pickRowName,children:a.name}),!a.valid&&s.jsx(z,{label:"Invalid",variant:"error"}),a.exists&&s.jsx(z,{label:"Already installed",variant:"warning"}),a.warnings&&a.warnings.length>0&&s.jsx(I,{icon:q,size:"xs",color:"var(--pi-color-statusWarning)","aria-label":a.warnings.join("; ")})]}),a.description&&s.jsx("span",{className:m.pickRowDescription,children:a.description}),a.exists&&a.valid&&s.jsx(K,{label:"Already installed — replace",checked:l,onChange:c=>t({replace:c.target.checked})})]})]})}function ms({result:e}){const[t,a]=h.useState(()=>new Set);function r(l){a(o=>{const c=new Set(o);return c.has(l)?c.delete(l):c.add(l),c})}return s.jsx("div",{className:m.results,children:e.results.map((l,o)=>{const c=t.has(o);return s.jsxs("div",{className:m.resultRow,children:[s.jsxs("div",{className:m.resultHeader,children:[s.jsx(z,{label:l.ok?"Installed":"Failed",variant:l.ok?"success":"error"}),s.jsx("span",{className:m.resultTarget,children:l.target}),l.error&&s.jsx("span",{className:m.resultError,children:l.error}),l.stderr&&s.jsx("button",{type:"button",className:m.resultToggle,onClick:()=>r(o),children:c?"Hide details":"Show details"})]}),c&&l.stderr&&s.jsx("pre",{className:m.resultStderr,children:l.stderr})]},`${l.target}-${o}`)})})}const ks="_panel_1tczp_1",fs="_toolbar_1tczp_7",Ss="_search_1tczp_14",ws="_groups_1tczp_19",vs="_group_1tczp_19",xs="_groupHeader_1tczp_30",Rs="_chevronExpanded_1tczp_47",bs="_groupLabel_1tczp_51",js="_groupBadges_1tczp_62",Es="_groupCount_1tczp_68",ys="_rows_1tczp_74",Ns="_row_1tczp_74",As="_rowMain_1tczp_91",Cs="_rowTop_1tczp_98",zs="_name_1tczp_105",Ts="_nameMuted_1tczp_113 _name_1tczp_105",Ls="_badge_1tczp_118",Ps="_description_1tczp_122",Is="_descriptionMuted_1tczp_130 _description_1tczp_122",Ds="_rowError_1tczp_135",Bs="_footnote_1tczp_147",$s="_errorState_1tczp_153",Ms="_removePackageBtn_1tczp_157",Fs="_rowActions_1tczp_161",Os="_updateAllResults_1tczp_168",Hs="_updateAllResultRow_1tczp_178",Us="_updateAllResultHeader_1tczp_184",Gs="_updateAllResultLabel_1tczp_191",Qs="_updateAllResultError_1tczp_196",qs="_updateAllResultToggle_1tczp_204",Ks="_updateAllResultStderr_1tczp_215",p={panel:ks,toolbar:fs,search:Ss,groups:ws,group:vs,groupHeader:xs,chevronExpanded:Rs,groupLabel:bs,groupBadges:js,groupCount:Es,rows:ys,row:Ns,rowMain:As,rowTop:Cs,name:zs,nameMuted:Ts,badge:Ls,description:Ps,descriptionMuted:Is,rowError:Ds,footnote:Bs,errorState:$s,removePackageBtn:Ms,rowActions:Fs,updateAllResults:Os,updateAllResultRow:Hs,updateAllResultHeader:Us,updateAllResultLabel:Gs,updateAllResultError:Qs,updateAllResultToggle:qs,updateAllResultStderr:Ks};function lt(){const{data:e,isLoading:t,isError:a,error:r}=Oe(),{rowErrors:l,pending:o,toggle:c,clearRowError:g}=He(),d=Ge(),n=Qe(),[i,k]=h.useState(""),[f,u]=h.useState(()=>new Set),[v,w]=h.useState(!1),[H,U]=h.useState(()=>new Set);function y(_){u(b=>{const R=new Set(b);return R.has(_)?R.delete(_):R.add(_),R})}if(t)return s.jsxs($,{children:[s.jsx(O,{size:"sm"})," Loading skills…"]});if(a)return s.jsx($,{className:p.errorState,children:r instanceof Error?r.message:"Failed to load skills."});if(!e)return null;if(!e.ok)return s.jsx($,{className:p.errorState,children:L(e.error,e.message)??"Could not load skills."});const E=je(be(e.skills,e.packages),i);async function B(_,b){if(b&&_.packageSource&&Ee(_,e.packages)&&!H.has(_.packageSource)){if(!await M().dialogs.confirm("Pi-Studio will stop managing this package's updates."))return;U(A=>new Set(A).add(_.packageSource))}c(_,b)}async function x(_){await M().dialogs.confirm(ye(_))&&d.removeSkill(_)}async function N(_){await M().dialogs.confirm(Ne(_))&&d.removePackage(_)}async function P(){await M().dialogs.confirm(Ae)&&n.updateAll()}return s.jsxs("div",{className:p.panel,children:[s.jsxs("div",{className:p.toolbar,children:[s.jsx(J,{className:p.search,placeholder:"Search skills…",value:i,onChange:_=>k(_.target.value),"aria-label":"Search skills"}),s.jsx(C,{size:"sm",variant:"outline",loading:n.pending,onClick:P,children:"Update all"}),s.jsx(C,{size:"sm",onClick:()=>w(!0),children:"Install skill…"})]}),n.error&&s.jsx("button",{type:"button",className:p.rowError,onClick:()=>n.updateAll().catch(()=>{}),children:n.error}),n.result&&s.jsx(Ws,{result:n.result,onDismiss:n.clearResult}),E.length===0?s.jsx($,{children:i?"No skills match your search.":"No skills found."}):s.jsx("div",{className:p.groups,children:E.map(_=>{const b=f.has(_.id),R=_.packageInfo,A=R?`package:${R.source}`:void 0;return s.jsxs("div",{className:p.group,children:[s.jsxs("button",{type:"button",className:p.groupHeader,onClick:()=>y(_.id),"aria-expanded":!b,children:[s.jsx(I,{icon:ae,size:"xs",className:b?void 0:p.chevronExpanded}),s.jsx("span",{className:p.groupLabel,children:_.label}),R&&s.jsx("span",{className:p.groupBadges,children:Re(R).map(S=>s.jsx(z,{label:S.label,variant:S.variant},S.label))}),s.jsx("span",{className:p.groupCount,children:_.rows.length}),R&&s.jsx(C,{size:"xs",variant:"ghost",className:p.removePackageBtn,loading:A?!!d.pending[A]:!1,onClick:S=>{S.stopPropagation(),N(R)},children:"Remove package"})]}),A&&d.errors[A]&&s.jsx("button",{type:"button",className:p.rowError,onClick:()=>d.clearError(A),children:d.errors[A]}),!b&&s.jsx("div",{className:p.rows,children:_.rows.map(S=>s.jsx(Zs,{row:S,error:l[S.skill.path],pending:!!o[S.skill.path],removeError:d.errors[S.skill.path],removePending:!!d.pending[S.skill.path],onToggle:ee=>B(S.skill,ee),onDismissError:()=>g(S.skill.path),onRemove:()=>x(S.skill),onDismissRemoveError:()=>d.clearError(S.skill.path)},S.skill.path))})]},_.id)})}),s.jsx("p",{className:p.footnote,children:"Changes apply to newly started agent sessions."}),s.jsx(_s,{open:v,onOpenChange:w})]})}function Ws({result:e,onDismiss:t}){const[a,r]=h.useState(()=>new Set);function l(o){r(c=>{const g=new Set(c);return g.has(o)?g.delete(o):g.add(o),g})}return s.jsxs("div",{className:p.updateAllResults,children:[e.results.map(o=>{const c=a.has(o.target);return s.jsxs("div",{className:p.updateAllResultRow,children:[s.jsxs("div",{className:p.updateAllResultHeader,children:[s.jsx(z,{label:o.ok?"Succeeded":"Failed",variant:o.ok?"success":"error"}),s.jsx("span",{className:p.updateAllResultLabel,children:ze(o.target)}),o.error&&s.jsx("span",{className:p.updateAllResultError,children:o.error}),o.stderr&&s.jsx("button",{type:"button",className:p.updateAllResultToggle,onClick:()=>l(o.target),children:c?"Hide details":"Show details"})]}),c&&o.stderr&&s.jsx("pre",{className:p.updateAllResultStderr,children:o.stderr})]},o.target)}),s.jsx("button",{type:"button",className:p.rowError,onClick:t,children:"Dismiss"})]})}function Zs({row:e,error:t,pending:a,removeError:r,removePending:l,onToggle:o,onDismissError:c,onRemove:g,onDismissRemoveError:d}){const{skill:n,muted:i,toggleDisabled:k,badges:f,warnings:u,sharedPatternTooltip:v}=e;return s.jsxs("div",{className:p.row,title:v??void 0,children:[s.jsxs("div",{className:p.rowMain,children:[s.jsxs("div",{className:p.rowTop,children:[s.jsx("span",{className:i?p.nameMuted:p.name,children:n.name}),u.length>0&&s.jsx(I,{icon:q,size:"xs",color:"var(--pi-color-statusWarning)","aria-label":u.join("; ")}),f.map(w=>s.jsx(z,{label:w.label,variant:w.variant,className:p.badge},w.label))]}),n.description&&s.jsx("span",{className:i?p.descriptionMuted:p.description,children:n.description}),t&&s.jsx("button",{type:"button",className:p.rowError,onClick:c,children:t}),r&&s.jsx("button",{type:"button",className:p.rowError,onClick:d,children:r})]}),s.jsxs("div",{className:p.rowActions,children:[s.jsx(oe,{checked:n.enabled,disabled:k||a,onCheckedChange:o,"aria-label":n.name}),n.removable&&s.jsx(te,{"aria-label":`Remove ${n.name}`,disabled:l,onClick:g,children:l?s.jsx(O,{size:"xs"}):s.jsx(I,{icon:le,size:"xs"})})]})]})}export{lt as SkillsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var ce=Object.defineProperty;var ie=(n,e,t)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var U=(n,e,t)=>ie(n,typeof e!="symbol"?e+"":e,t);import{r as s,j as b}from"./vendor-react-Dka9ZH0B.js";import{x as ue,a as le}from"./vendor-terminal-BhzX2_ts.js";import{h as X,j as ae,T as J,u as fe,k as de,l as me,m as pe,o as Q,S as he,p as Re,q as we}from"./index-
|
|
1
|
+
var ce=Object.defineProperty;var ie=(n,e,t)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var U=(n,e,t)=>ie(n,typeof e!="symbol"?e+"":e,t);import{r as s,j as b}from"./vendor-react-Dka9ZH0B.js";import{x as ue,a as le}from"./vendor-terminal-BhzX2_ts.js";import{h as X,j as ae,T as J,u as fe,k as de,l as me,m as pe,o as Q,S as he,p as Re,q as we}from"./index-B6VaYU8s.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";class Se{constructor(e){U(this,"subscribers",new Map);U(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onTerminalFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null}subscribeSlot(e,t){return this.subscribers.set(e,t),()=>{this.subscribers.get(e)===t&&this.subscribers.delete(e)}}hasSlot(e){return this.subscribers.has(e)}sendInput(e,t){this.daemon.sendBinary(X({opcode:"Input",slot:e,data:t}))}sendResize(e,t,d){this.daemon.sendBinary(X({opcode:"Resize",slot:e,rows:t,cols:d}))}dispatch(e){var d,R,p;const t=this.subscribers.get(e.slot);if(t)switch(e.opcode){case"Output":(d=t.onOutput)==null||d.call(t,e.data);return;case"Snapshot":(R=t.onSnapshot)==null||R.call(t,e.data);return;case"Restore":(p=t.onRestore)==null||p.call(t,e.data);return;default:return}}}const ye=3e3,Z=`${ae.sm}px ${J}`,ee="M";function te(){if(typeof document>"u"||!document.fonts)return!0;try{return document.fonts.check(Z,ee)}catch{return!0}}const Te=(async()=>{if(typeof document>"u"||!document.fonts||te())return;let n;try{await Promise.race([document.fonts.load(Z,ee),new Promise(e=>{n=window.setTimeout(e,ye)})])}catch{}finally{window.clearTimeout(n)}})(),_e=2,ve=1;function y(n){if(n==null)return!1;const{cols:e,rows:t}=n;return typeof e=="number"&&Number.isInteger(e)&&e>=_e&&typeof t=="number"&&Number.isInteger(t)&&t>=ve}function ge(n,e){return n===null||e===null?n===e:n.cols===e.cols&&n.rows===e.rows}function xe(n,e){return y(n)?!ge(n,e):!1}function be(n,e){if(e===null)return;const t=n.find(R=>R.slot===e);if(!t)return;const d={cols:t.cols,rows:t.rows};return y(d)?d:void 0}const Fe="_wrap_1fx2h_1",Ee="_terminal_1fx2h_12",Ae="_statusOverlay_1fx2h_19",ze="_exitedBanner_1fx2h_30",z={wrap:Fe,terminal:Ee,statusOverlay:Ae,exitedBanner:ze},Oe=64*1024,$=new TextEncoder,K=new WeakMap;function Ne(n){let e=K.get(n);return e||(e=new Se(n),e.start(),K.set(n,e)),e}function Y(n){const e=Q.getState(),t=e.tabs.find(d=>d.id===n);return!t||t.workspaceCwd!==e.activeWorkspaceCwd?!1:Re(we.getState().layouts[t.workspaceCwd],n)}function Ge({tab:n}){const e=n.data,t=fe(r=>r.client),d=de(n.id),{settings:R,resolvedTheme:p}=me(),B=R.monoFont&&R.monoFont.trim()!==""?p.fontFamily.mono:J,W=s.useRef(null),w=s.useRef(null),T=s.useRef(null),_=s.useRef(e.slot),O=s.useRef(null),N=s.useRef([]),I=s.useRef(0),F=s.useRef(null),ne=s.useRef(null),E=s.useRef(null),v=s.useRef(null),A=s.useRef(null),k=s.useRef(!1),H=s.useRef(null),V=s.useRef(t);V.current=t;const D=s.useRef(e.exited??!1);D.current=e.exited??!1;const[g,re]=s.useState(e.slot),[j,q]=s.useState({isAttaching:!0,error:null}),[M,se]=s.useState(te);s.useEffect(()=>{if(M)return;let r=!1;return Te.then(()=>{r||se(!0)}),()=>{r=!0}},[M]);const C=()=>{var o,c;const r=(o=T.current)==null?void 0:o.proposeDimensions();(c=E.current)==null||c.call(E,y(r)?r:null)},oe=()=>{var r;A.current=null,k.current=!0,(r=T.current)==null||r.fit(),C(),requestAnimationFrame(()=>{k.current=!1})},P=()=>{v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{v.current=null,A.current===null&&(A.current=requestAnimationFrame(oe))},60)};s.useEffect(()=>{const r=W.current;if(!r||!M)return;const o=new ue.Terminal({cursorBlink:!0,fontFamily:B,fontSize:p.fontSize.code,scrollback:5e3,theme:p.colors.terminal,allowProposedApi:!0}),c=new le.FitAddon;o.loadAddon(c),o.open(r);const f=u=>{if(!Y(n.id))return;const l=_.current,S=O.current;l===null||!S||xe(u,F.current)&&(F.current=u,S.sendResize(l,u.rows,u.cols))},a=o.onData(u=>{if(D.current)return;const l=_.current,S=O.current;if(l===null||!S){const G=$.encode(u);I.current+G.length<=Oe&&(N.current.push(G),I.current+=G.length);return}S.sendInput(l,$.encode(u))}),m=o.onResize(({cols:u,rows:l})=>{f({cols:u,rows:l})}),h=()=>{c.fit(),C()};r.addEventListener("focusin",h),c.fit(),w.current=o,T.current=c,E.current=f;const i=new ResizeObserver(u=>{if(k.current)return;const l=u[0];l&&(l.contentRect.width===0||l.contentRect.height===0)||P()});return i.observe(r),()=>{i.disconnect(),v.current!==null&&window.clearTimeout(v.current),A.current!==null&&cancelAnimationFrame(A.current),r.removeEventListener("focusin",h),a.dispose(),m.dispose(),o.dispose(),w.current=null,T.current=null,E.current=null}},[M]),s.useEffect(()=>{const r=w.current;if(!r)return;r.options.theme=p.colors.terminal;const o=p.fontSize.code,c=B,f=H.current,a=f!==null&&(f.size!==o||f.family!==c);r.options.fontSize=o,r.options.fontFamily=c,H.current={size:o,family:c},a&&P()},[p,B]),s.useEffect(()=>{if(!e.exited)return;const r=w.current;r&&(r.options.cursorBlink=!1,r.blur())},[e.exited]),s.useEffect(()=>{if(t)return t.connection.onSessionMessage(r=>{const o=r;if(!pe(o))return;const c=be(o.terminals,_.current);c!==void 0&&(F.current=c)})},[t]);const x=s.useRef(!1),L=s.useRef(!1);return s.useEffect(()=>{var f;if(x.current=!0,!t||_.current!==null||L.current)return()=>{x.current=!1};L.current=!0;const r=e.cwd||"~",o=(f=T.current)==null?void 0:f.proposeDimensions(),c=y(o)?o:null;return t.connection.request("create_terminal_request",{workspaceId:"",cwd:r,...c?{cols:c.cols,rows:c.rows}:{}}).then(a=>{const m=a.terminal.slot;if(!x.current){t.connection.request("kill_terminal_request",{slot:m}).catch(()=>{});return}_.current=m,re(m),Q.getState().updateData(n.id,{slot:m});const h={cols:a.terminal.cols,rows:a.terminal.rows};F.current=y(h)?h:null}).catch(a=>{x.current&&q({isAttaching:!1,error:a instanceof Error?a.message:String(a)})}).finally(()=>{L.current=!1}),()=>{x.current=!1}},[t,n.id]),s.useEffect(()=>()=>{const r=_.current;r!==null&&setTimeout(()=>{var o;x.current||D.current||(o=V.current)==null||o.connection.request("kill_terminal_request",{slot:r}).catch(()=>{})},0)},[]),s.useEffect(()=>{var h;if(!t||g===null)return;q({isAttaching:!0,error:null});const r=Ne(t.connection);O.current=r;const o=i=>{var u,l;(u=w.current)==null||u.reset(),(l=w.current)==null||l.write(i)},c=r.subscribeSlot(g,{onOutput:i=>{var u;return(u=w.current)==null?void 0:u.write(i)},onSnapshot:o,onRestore:o});let f=!1;const a=(h=T.current)==null?void 0:h.proposeDimensions(),m=y(a)&&Y(n.id)?a:null;return t.connection.request("subscribe_terminal_request",{slot:g,restoreMode:"reflowable",...m?{cols:m.cols,rows:m.rows}:{}}).then(i=>{if(f)return;q({isAttaching:!1,error:null}),ne.current=(i==null?void 0:i.restoreMode)??"basic";const u=N.current;N.current=[],I.current=0;for(const S of u)r.sendInput(g,S);const l={cols:i==null?void 0:i.cols,rows:i==null?void 0:i.rows};F.current=y(l)?l:m,C()}).catch(i=>{f||(N.current=[],I.current=0,q({isAttaching:!1,error:i instanceof Error?i.message:String(i)}))}),()=>{f=!0,c(),O.current=null,t.connection.request("unsubscribe_terminal_request",{slot:g}).catch(()=>{})}},[t,g]),s.useEffect(()=>{d&&P()},[d]),b.jsxs("div",{className:z.wrap,children:[b.jsx("div",{ref:W,className:z.terminal}),j.error?b.jsxs("div",{className:z.statusOverlay,children:["Terminal error: ",j.error]}):j.isAttaching?b.jsxs("div",{className:z.statusOverlay,children:[b.jsx(he,{size:"sm"})," Starting terminal…"]}):null,e.exited?b.jsx("div",{className:z.exitedBanner,children:"Terminal exited"}):null]})}export{Ge as TerminalPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-Dka9ZH0B.js";import{E as t,P as c,S as n}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-react-Dka9ZH0B.js";import{E as t,P as c,S as n}from"./index-B6VaYU8s.js";import{u as m,C as a}from"./CodeView-BWjIMXx_.js";import{S as d}from"./SaveFileButton-D4L2yJ4C.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";import"./use-file-download-Db9Jkq8L.js";const l="_note_1g5yz_1",x="_body_1g5yz_9",g="_tooLarge_1g5yz_13",i={note:l,body:x,tooLarge:g};function o(r){return`${(r/(1024*1024)).toFixed(1)} MB`}function E({path:r}){const s=m(r);switch(s.kind){case"loading":return e.jsxs(t,{children:[e.jsx(n,{size:"sm"})," Loading..."]});case"inline":return e.jsx(a,{path:r,content:s.content});case"streaming":return e.jsxs(t,{children:[e.jsx(n,{size:"sm"})," Streaming ",o(s.size)," file..."]});case"stream-error":return e.jsxs(t,{children:["Error: ",s.message]});case"streamed":return e.jsxs(c,{children:[e.jsxs("div",{className:i.note,children:[o(s.size)," file streamed"]}),e.jsx("div",{className:i.body,children:e.jsx(a,{path:r,content:s.content})})]});case"too-large":return e.jsx(t,{children:e.jsxs("div",{className:i.tooLarge,children:[e.jsxs("div",{children:[o(s.size)," — too large to display (display ceiling is"," ",o(s.maxDisplayBytes),")."]}),e.jsx(d,{path:r})]})});case"error":return e.jsxs(t,{children:["Error: ",s.message]})}}export{E as TextViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./vendor-react-Dka9ZH0B.js";import{E as e,S as t}from"./index-
|
|
1
|
+
import{j as o}from"./vendor-react-Dka9ZH0B.js";import{E as e,S as t}from"./index-B6VaYU8s.js";import{u as n}from"./use-file-download-Db9Jkq8L.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const a="_wrap_gy3e6_1",m="_video_gy3e6_10",i={wrap:a,video:m};function E({path:s,workspaceCwd:p}){const r=n(s);return r.isLoading?o.jsxs(e,{children:[o.jsx(t,{size:"sm"})," Loading video..."]}):r.isError?o.jsxs(e,{children:["Error: ",r.error instanceof Error?r.error.message:"unknown error"]}):r.data?o.jsx("div",{className:i.wrap,children:o.jsx("video",{className:i.video,src:r.data.objectUrl,controls:!0})}):null}export{E as VideoViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-Dka9ZH0B.js";import{d as a}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-react-Dka9ZH0B.js";import{d as a}from"./index-B6VaYU8s.js";import{S as d}from"./Switch-DvBJf8Rd.js";import"./vendor-z183l2lP.js";import"./vendor-query-CDNPrdQ8.js";import"./vendor-icons-CSCeICuX.js";import"./vendor-overlays-DjMT65Ip.js";import"./vendor-dnd-vJGfGIIi.js";import"./vendor-pdfjs-BSchhGel.js";const p="_list_x2x5z_1",m="_row_x2x5z_7",x="_rowMain_x2x5z_17",w="_name_x2x5z_24",_="_description_x2x5z_29",f="_note_x2x5z_34",n={list:p,row:m,rowMain:x,name:w,description:_,note:f},b=[{id:"molviewer",name:"Molecule Viewer",description:"Open molecular structure files (.cif, .pdb, .xyz, and similar) in the 3D viewer instead of as plain text."},{id:"pdfviewer",name:"PDF Viewer",description:"Render PDF files in place instead of offering only a download."}];function h({id:o,name:i,description:r}){const t=a(s=>s.capable),c=a(s=>s.isViewerEnabled(o)),l=a(s=>s.setEnabled);return e.jsxs("div",{className:n.row,children:[e.jsxs("div",{className:n.rowMain,children:[e.jsx("span",{className:n.name,children:i}),e.jsx("span",{className:n.description,children:r})]}),e.jsx(d,{checked:c,disabled:!t,onCheckedChange:s=>void l(o,s),"aria-label":i})]})}function S(){const o=a(i=>i.capable);return e.jsxs("div",{className:n.list,children:[b.map(i=>e.jsx(h,{...i},i.id)),!o&&e.jsx("p",{className:n.note,children:"Requires a newer daemon."})]})}export{S as ViewersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as l,a as o,c as i}from"./index-
|
|
1
|
+
import{n as l,a as o,c as i}from"./index-B6VaYU8s.js";const u=/^([a-zA-Z][a-zA-Z0-9+.-]*):/;function d(n){try{return decodeURIComponent(n)}catch{return n}}function p(n,a,r){const s=n.trim();if(!s)return null;const e=s.split(/[?#]/,1)[0];if(!e||u.exec(e))return null;let t;if(e.startsWith("/")?t=e:e==="~"||e.startsWith("~/")?t=r?l(e,r):null:t=o(e,a??""),!t)return null;const c=i(t);return d(c)}export{u as S,d as p,p as r};
|