@ashwin-pc/pi-web 0.1.2 → 0.1.14
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/assets/{index-RfnHuF-b.js → index-Hd0Z4pEO.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -128
- package/dist/workbox-ee9d8b34.js +1 -0
- package/package.json +6 -2
- package/dist/workbox-a24bf94b.js +0 -3645
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function t(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=t(a);fetch(a.href,i)}})();function Xi(n){return{headers(){return{"content-type":"application/json",...n.token?{authorization:`Bearer ${n.token}`}:{}}},wsUrl(){const e=new URL("/ws",location.href);return e.protocol=location.protocol==="https:"?"wss:":"ws:",n.token&&e.searchParams.set("token",n.token),n.lastRealtimeSeq>0&&e.searchParams.set("lastSeq",String(n.lastRealtimeSeq)),e}}}function J(n){const e=document.querySelector(n);if(!e)throw new Error(`Missing required DOM node: ${n}`);return e}function Ji(){return{messagesEl:J("#messages"),statusTitleEl:J("#statusTitle"),statusPathEl:J("#statusPath"),connectionStatusEl:J("#connectionStatus"),formEl:J("#promptForm"),contextMeterEl:J("#contextMeter"),contextMeterFillEl:J("#contextMeterFill"),contextMeterLabelEl:J("#contextMeterLabel"),contextMeterPopoverEl:J("#contextMeterPopover"),promptEl:J("#prompt"),slashCommandsEl:J("#slashCommands"),primaryButton:J("#primaryButton"),stopButton:J("#stopButton"),tokenOverlay:J("#tokenOverlay"),tokenForm:J("#tokenForm"),tokenInput:J("#tokenInput"),sessionButton:J("#sessionButton"),expandButton:J("#expandButton"),sessionDrawer:J("#sessionDrawer"),sessionBackdrop:J("#sessionBackdrop"),sessionCloseButton:J("#sessionCloseButton"),sessionNewButton:J("#sessionNewButton"),sessionListEl:J("#sessionList"),sessionBarEl:J("#sessionBar"),queueToggle:J("#queueToggle"),attachButton:J("#attachButton"),imageInput:J("#imageInput"),attachmentsEl:J("#attachments"),modelControl:J("#modelControl"),modelSettingsButton:J("#modelSettingsButton"),modelSettingsLabel:J("#modelSettingsLabel"),modelSettingsThinking:J("#modelSettingsThinking"),modelSettingsPopover:J("#modelSettingsPopover"),modelSelectEl:J("#modelSelect"),thinkingSelectEl:J("#thinkingSelect"),newSessionHeaderButton:J("#newSessionHeaderButton"),conversationTreeButton:J("#conversationTreeButton"),gitButton:J("#gitButton"),settingsButton:J("#settingsButton"),settingsPanel:J("#settingsPanel"),settingsBackdrop:J("#settingsBackdrop"),settingsCloseButton:J("#settingsCloseButton"),settingDensitySelect:J("#settingDensitySelect"),settingQueueModeSelect:J("#settingQueueModeSelect"),settingComposerExpandedCheckbox:J("#settingComposerExpandedCheckbox"),settingModelDefaultsValue:J("#settingModelDefaultsValue"),settingSaveModelDefaultsButton:J("#settingSaveModelDefaultsButton"),settingClearModelDefaultsButton:J("#settingClearModelDefaultsButton"),settingsStatusEl:J("#settingsStatus"),gitPanel:J("#gitPanel"),emptyCwdChooserEl:J("#emptyCwdChooser"),emptyCwdPathEl:J("#emptyCwdChooser .emptyCwdPath"),emptyCwdButton:J("#emptyCwdChooser .emptyCwdButton")}}function Ht(){const n=window.visualViewport?.height||window.innerHeight;document.documentElement.style.setProperty("--app-height",`${n}px`)}function ji(){Ht(),window.addEventListener("resize",Ht),window.visualViewport?.addEventListener("resize",Ht),window.visualViewport?.addEventListener("scroll",Ht)}const es={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};const Ga=([n,e,t])=>{const r=document.createElementNS("http://www.w3.org/2000/svg",n);return Object.keys(e).forEach(a=>{r.setAttribute(a,String(e[a]))}),t?.length&&t.forEach(a=>{const i=Ga(a);r.appendChild(i)}),r},rt=(n,e={})=>{const r={...es,...e};return Ga(["svg",r,n])};const ts=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z"}]];const ns=[["path",{d:"M12 18V5"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77"}]];const rs=[["path",{d:"M20 6 9 17l-5-5"}]];const Ka=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M12 3v18"}]];const Mr=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]];const as=[["path",{d:"m15 10 5 5-5 5"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12"}]];const is=[["path",{d:"M12 15V3"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}],["path",{d:"m7 10 5 5 5-5"}]];const ss=[["path",{d:"M15 3h6v6"}],["path",{d:"M10 14 21 3"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}]];const os=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];const cs=[["circle",{cx:"12",cy:"18",r:"3"}],["circle",{cx:"6",cy:"6",r:"3"}],["circle",{cx:"18",cy:"6",r:"3"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9"}],["path",{d:"M12 12v3"}]];const ls=[["circle",{cx:"5",cy:"6",r:"3"}],["path",{d:"M5 9v12"}],["circle",{cx:"19",cy:"18",r:"3"}],["path",{d:"m15 9-3-3 3-3"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7"}]];const ds=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor"}]];const Wa=[["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]];const us=[["path",{d:"M4 5h16"}],["path",{d:"M4 12h16"}],["path",{d:"M4 19h16"}]];const ps=[["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]];const ms=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]];const gs=[["circle",{cx:"6",cy:"19",r:"3"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15"}],["circle",{cx:"18",cy:"5",r:"3"}]];const Za=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}],["path",{d:"M3 12h18"}]];const fs=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z"}],["path",{d:"M6 12h16"}]];const hs=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];const bs=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"}]];const Es=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];const _s=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];const ys=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]],ws={bookmark:ts,brain:ns,"corner-down-right":as,"git-branch":os,"git-fork":cs,"key-round":ds,menu:us,paperclip:ms,route:gs,"send-horizontal":fs,settings:hs,square:Es,"square-pen":bs,star:_s,"maximize-2":Wa,"minimize-2":ps,x:ys};function Ya(n){return rt(ws[n],{"aria-hidden":"true"})}function Le(n,e){n.textContent="",n.append(Ya(e))}const Or=4,Va="pi-web-pinned-sessions";function vs(){try{const n=JSON.parse(localStorage.getItem(Va)||"[]");return Array.isArray(n)?n.filter(e=>typeof e?.id=="string"&&typeof e?.label=="string"):[]}catch{return[]}}function Lr(n){localStorage.setItem(Va,JSON.stringify(n))}const Qa=1500,Ss=2500,ks=15e3,Ir=8,ir={version:1,appearance:{density:"comfortable"},composer:{queueMode:"steer",expanded:!1},defaults:{}},Xt="pi-web-token",Xa="pi-web-collapsed-session-folders";function Ns(){const n=new URLSearchParams(location.search).get("token");if(!n)return;localStorage.setItem(Xt,n);const e=new URL(location.href);e.searchParams.delete("token"),history.replaceState(null,"",e.toString())}function Ts(){try{const n=JSON.parse(localStorage.getItem(Xa)||"[]");return Array.isArray(n)?n.filter(e=>typeof e=="string"):[]}catch{return[]}}function xs(n){localStorage.setItem(Xa,JSON.stringify(Array.from(n)))}function Cs(){return Ns(),{token:localStorage.getItem(Xt)||"",currentModelKey:"",currentModelDisplay:"No model",currentThinkingLevel:"off",currentSessionId:"",currentCwd:"",currentSessionTitle:"New session",statusTitleEditing:!1,isStreaming:!1,wsHasOpened:!1,wsDisconnected:!1,lastRealtimeSeq:0,reconnectNoticeTimer:void 0,connectionLostTimer:void 0,reconnectedClearTimer:void 0,pinnedSessions:vs(),collapsedSessionFolders:new Set(Ts()),expandedSessionFolders:new Set,queueMode:"steer",attachedImages:[],editorExpanded:ir.composer.expanded,settings:ir,stats:void 0}}function Rs(n){localStorage.setItem(Xt,n)}function As(){localStorage.removeItem(Xt)}function Ms(n){return new Promise((e,t)=>{const r=new FileReader;r.addEventListener("load",()=>{const a=String(r.result||""),i=a.includes(",")?a.slice(a.indexOf(",")+1):a;e({type:"image",data:i,mimeType:n.type,name:n.name})}),r.addEventListener("error",()=>t(r.error||new Error(`Could not read ${n.name}`))),r.readAsDataURL(n)})}function Os(n){const{state:e,elements:t,api:r,addMessage:a,updateMeta:i,updateThinkingOptions:o,refreshModels:c,refreshMessages:d,refreshState:s,beginStreamFollow:l,endStreamFollow:u}=n,g=new Set(["help","?","commands","reload","model","models","thinking","new","compact","abort","stop","logout"]),f=5e3;let p=[],y=0,b=0;function N(){const E=!!t.promptEl.value.trim()||e.attachedImages.length>0;t.primaryButton.disabled=!E,t.stopButton.style.display=e.isStreaming?"":"none"}function M(){const E=e.queueMode==="steer";t.queueToggle.setAttribute("aria-pressed",String(E)),t.queueToggle.title=E?"Queue mode: steer while running":"Queue mode: follow up after running",t.queueToggle.setAttribute("aria-label",t.queueToggle.title),Le(t.queueToggle,E?"route":"corner-down-right")}function L(E){t.promptEl.value=E,N(),Y(),t.promptEl.focus()}function Z(E){return E.trim().replace(/^\/+/,"").split(/\s+/,1)[0]?.toLowerCase()||""}function R(){const E=t.promptEl.value.trimStart();if(!E.startsWith("/")||e.attachedImages.length>0)return;const S=E.slice(1);if(!(/\s/.test(S)||S.includes(`
|
|
2
|
-
`)))return S.toLowerCase()}function I(){t.slashCommandsEl.hidden=!0,t.promptEl.setAttribute("aria-expanded","false")}async function P(E=!1){const S=Date.now();if(!E&&p.length>0&&S-y<f)return p;const T=await fetch(`/api/commands?sessionId=${encodeURIComponent(e.currentSessionId)}`,{headers:r.headers()});if(!T.ok)throw new Error(await T.text());const $=await T.json();return p=Array.isArray($.commands)?$.commands:[],y=S,p}function B(){const E=R();if(E===void 0)return[];const S=new Map([["web",0],["extension",1],["prompt",2],["skill",3]]);return p.filter(T=>{const $=T.name.toLowerCase(),w=T.description?.toLowerCase()||"";return!E||$.includes(E)||w.includes(E)}).sort((T,$)=>{const w=T.name.toLowerCase(),A=$.name.toLowerCase(),_=w.startsWith(E)?0:1,z=A.startsWith(E)?0:1;return _-z||(S.get(T.source)??99)-(S.get($.source)??99)||T.name.localeCompare($.name)}).slice(0,12)}function D(E){const S=t.promptEl.value.match(/^\s*/)?.[0]||"";t.promptEl.value=`${S}/${E.name} `,t.promptEl.setSelectionRange(t.promptEl.value.length,t.promptEl.value.length),N(),I(),t.promptEl.focus()}function Y(){if(R()===void 0){I();return}const S=B();if(b=Math.min(b,Math.max(S.length-1,0)),t.slashCommandsEl.textContent="",S.length===0){const T=document.createElement("div");T.className="slashCommandsEmpty",T.textContent=p.length===0?"Loading slash commands…":"No matching slash commands",t.slashCommandsEl.append(T)}else S.forEach((T,$)=>{const w=document.createElement("button");w.type="button",w.className=`slashCommandItem${$===b?" active":""}`,w.setAttribute("role","option"),w.setAttribute("aria-selected",String($===b)),w.addEventListener("mousedown",_=>_.preventDefault()),w.addEventListener("mouseenter",()=>{b!==$&&(b=$,Y())}),w.addEventListener("click",()=>D(T));const A=document.createElement("span");if(A.className="slashCommandName",A.textContent=`/${T.name}`,w.append(A),T.source!=="web"){const _=document.createElement("span");_.className="slashCommandSource",_.textContent=T.source,w.append(_)}if(T.description){const _=document.createElement("span");_.className="slashCommandDescription",_.textContent=T.description,w.append(_)}t.slashCommandsEl.append(w)});t.slashCommandsEl.hidden=!1,t.promptEl.setAttribute("aria-expanded","true")}async function H(E=!1){if(R()===void 0){I();return}try{await P(E),Y()}catch{I()}}async function h(E){await P();const S=Z(E);return p.find(T=>T.name.toLowerCase()===S)}function v(){t.attachmentsEl.textContent="",t.attachmentsEl.hidden=e.attachedImages.length===0,e.attachedImages.forEach((E,S)=>{const T=document.createElement("div");T.className="attachmentChip";const $=document.createElement("img");$.src=`data:${E.mimeType};base64,${E.data}`,$.alt="";const w=document.createElement("span");w.textContent=E.name;const A=document.createElement("button");A.type="button",A.className="removeAttachment",A.title=`Remove ${E.name}`,A.setAttribute("aria-label",A.title),A.addEventListener("click",()=>{e.attachedImages.splice(S,1),v(),N()}),Le(A,"x"),T.append($,w,A),t.attachmentsEl.append(T)})}async function k(E){const S=E.trim().replace(/^\/+/,"").split(/\s+/,1)[0]?.toLowerCase();if(S==="logout"){e.token="",As(),t.tokenInput.value="",t.tokenOverlay.hidden=!1,t.tokenInput.focus();return}const T=await fetch("/api/command",{method:"POST",headers:r.headers(),body:JSON.stringify({command:E})}),$=await T.text(),w=$?JSON.parse($):{};if(!T.ok||w.ok===!1)throw new Error(w.error||$);w.state&&(i(w.state),e.isStreaming=!!w.state.isStreaming,N(),w.state.thinkingLevels&&o(w.state.thinkingLevels)),await c(),(S==="reload"||S==="commands")&&await P(!0).catch(()=>{}),S==="new"&&await d(),w.message&&a("system",w.message)}function C(){t.formEl.addEventListener("submit",async E=>{if(E.preventDefault(),e.isStreaming&&!t.promptEl.value.trim()&&e.attachedImages.length===0)return;const S=t.promptEl.value.trim(),T=e.attachedImages.map(({type:$,data:w,mimeType:A,name:_})=>({type:$,data:w,mimeType:A,name:_}));if(!(!S&&T.length===0)){if(S.startsWith("/")&&T.length===0){let $;try{$=await h(S)}catch{$=g.has(Z(S))?{name:Z(S),source:"web"}:void 0}if(!$||$.source==="web"){t.promptEl.value="",I(),N(),a("system",`› ${S}`);try{await k(S)}catch(w){a("system",w instanceof Error?w.message:String(w),"error")}finally{t.promptEl.focus()}return}}t.promptEl.value="",I(),e.attachedImages=[],v(),N(),l?.(),a("user",S||"","",T.map($=>({data:$.data,mimeType:$.mimeType})));try{const $=await fetch("/api/prompt",{method:"POST",headers:r.headers(),body:JSON.stringify({sessionId:e.currentSessionId,message:S,mode:e.queueMode,images:T})});if(!$.ok)throw new Error(await $.text())}catch($){u?.(),a("system",$ instanceof Error?$.message:String($),"error")}finally{t.promptEl.focus()}}}),t.promptEl.addEventListener("keydown",E=>{if(!t.slashCommandsEl.hidden){const S=B();if(E.key==="ArrowDown"&&S.length>0){E.preventDefault(),b=(b+1)%S.length,Y();return}if(E.key==="ArrowUp"&&S.length>0){E.preventDefault(),b=(b-1+S.length)%S.length,Y();return}if((E.key==="Enter"&&!E.metaKey&&!E.ctrlKey||E.key==="Tab")&&S[b]){E.preventDefault(),D(S[b]);return}if(E.key==="Escape"){E.preventDefault(),I();return}}E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&t.formEl.requestSubmit()}),t.promptEl.addEventListener("focus",()=>{H()}),t.promptEl.addEventListener("blur",()=>window.setTimeout(I,100)),t.promptEl.addEventListener("input",()=>{N(),b=0,Y(),H()}),t.attachButton.addEventListener("click",()=>t.imageInput.click()),t.imageInput.addEventListener("change",async()=>{const E=Array.from(t.imageInput.files||[]).filter(S=>S.type.startsWith("image/"));t.imageInput.value="";try{const S=await Promise.all(E.map(Ms));e.attachedImages.push(...S),v(),N()}catch(S){a("system",S instanceof Error?S.message:String(S),"error")}}),t.stopButton.addEventListener("click",async()=>{await fetch("/api/abort",{method:"POST",headers:r.headers(),body:JSON.stringify({sessionId:e.currentSessionId})})}),t.queueToggle.addEventListener("click",()=>{e.queueMode=e.queueMode==="steer"?"followUp":"steer",M()}),t.tokenForm.addEventListener("submit",E=>{E.preventDefault();const S=t.tokenInput.value.trim();S&&(e.token=S,Rs(e.token),t.tokenOverlay.hidden=!0,s().catch(T=>a("system",T instanceof Error?T.message:String(T),"error")))}),t.expandButton.addEventListener("click",()=>{e.editorExpanded=!e.editorExpanded,t.formEl.classList.toggle("expanded",e.editorExpanded),Le(t.expandButton,e.editorExpanded?"minimize-2":"maximize-2"),t.expandButton.title=e.editorExpanded?"Collapse editor":"Expand editor",t.expandButton.setAttribute("aria-label",t.expandButton.title),t.promptEl.focus()})}return{init:C,renderAttachments:v,setPromptText:L,updatePrimaryAction:N,updateQueueToggle:M}}function gt(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Dr(n){const e=gt(n);if(e===void 0)return"—";if(Math.abs(e)<1e3)return Math.round(e).toLocaleString();if(Math.abs(e)<1e6){const r=e/1e3;return`${r>=10?r.toFixed(0):r.toFixed(1)}k`}const t=e/1e6;return`${t>=10?t.toFixed(0):t.toFixed(1)}m`}function Ke(n){const e=gt(n);return e===void 0?"unknown":Math.round(e).toLocaleString()}function Ja(n){const e=gt(n);return e===void 0?"unknown":`$${e.toFixed(e<1?3:2)}`}function sr(n){const e=n?.contextUsage,t=gt(e?.percent);if(t!==void 0)return t;const r=gt(e?.tokens),a=gt(e?.contextWindow);if(!(r===void 0||a===void 0||a<=0))return r/a*100}function Ls(n){return n===void 0?"unknown":n>=95?"danger":n>=80?"warning":n>=50?"active":"normal"}function Is(n){const e=n?.contextUsage,t=sr(n);if(!n||t===void 0||e?.tokens===null)return"Context usage unavailable until the next model response.";const r=n.tokens||{};return[`Context: ${Ke(e?.tokens)} / ${Ke(e?.contextWindow)} tokens (${Math.round(t)}%)`,`Input: ${Ke(r.input)} · Output: ${Ke(r.output)}`,`Cache read: ${Ke(r.cacheRead)} · Cache write: ${Ke(r.cacheWrite)}`,`Cost: ${Ja(n.cost)}`].join(`
|
|
2
|
+
`)))return S.toLowerCase()}function I(){t.slashCommandsEl.hidden=!0,t.promptEl.setAttribute("aria-expanded","false")}async function P(E=!1){const S=Date.now();if(!E&&p.length>0&&S-y<f)return p;const T=await fetch(`/api/commands?sessionId=${encodeURIComponent(e.currentSessionId)}`,{headers:r.headers()});if(!T.ok)throw new Error(await T.text());const $=await T.json();return p=Array.isArray($.commands)?$.commands:[],y=S,p}function B(){const E=R();if(E===void 0)return[];const S=new Map([["web",0],["extension",1],["prompt",2],["skill",3]]);return p.filter(T=>{const $=T.name.toLowerCase(),w=T.description?.toLowerCase()||"";return!E||$.includes(E)||w.includes(E)}).sort((T,$)=>{const w=T.name.toLowerCase(),A=$.name.toLowerCase(),_=w.startsWith(E)?0:1,z=A.startsWith(E)?0:1;return _-z||(S.get(T.source)??99)-(S.get($.source)??99)||T.name.localeCompare($.name)}).slice(0,12)}function D(E){const S=t.promptEl.value.match(/^\s*/)?.[0]||"";t.promptEl.value=`${S}/${E.name} `,t.promptEl.setSelectionRange(t.promptEl.value.length,t.promptEl.value.length),N(),I(),t.promptEl.focus()}function Y(){if(R()===void 0){I();return}const S=B();if(b=Math.min(b,Math.max(S.length-1,0)),t.slashCommandsEl.textContent="",S.length===0){const T=document.createElement("div");T.className="slashCommandsEmpty",T.textContent=p.length===0?"Loading slash commands…":"No matching slash commands",t.slashCommandsEl.append(T)}else S.forEach((T,$)=>{const w=document.createElement("button");w.type="button",w.className=`slashCommandItem${$===b?" active":""}`,w.setAttribute("role","option"),w.setAttribute("aria-selected",String($===b)),w.addEventListener("mousedown",_=>_.preventDefault()),w.addEventListener("mouseenter",()=>{b!==$&&(b=$,Y())}),w.addEventListener("click",()=>D(T));const A=document.createElement("span");if(A.className="slashCommandName",A.textContent=`/${T.name}`,w.append(A),T.source!=="web"){const _=document.createElement("span");_.className="slashCommandSource",_.textContent=T.source,w.append(_)}if(T.description){const _=document.createElement("span");_.className="slashCommandDescription",_.textContent=T.description,w.append(_)}t.slashCommandsEl.append(w)});t.slashCommandsEl.hidden=!1,t.promptEl.setAttribute("aria-expanded","true")}async function H(E=!1){if(R()===void 0){I();return}try{await P(E),Y()}catch{I()}}async function h(E){await P();const S=Z(E);return p.find(T=>T.name.toLowerCase()===S)}function v(){t.attachmentsEl.textContent="",t.attachmentsEl.hidden=e.attachedImages.length===0,e.attachedImages.forEach((E,S)=>{const T=document.createElement("div");T.className="attachmentChip";const $=document.createElement("img");$.src=`data:${E.mimeType};base64,${E.data}`,$.alt="";const w=document.createElement("span");w.textContent=E.name;const A=document.createElement("button");A.type="button",A.className="removeAttachment",A.title=`Remove ${E.name}`,A.setAttribute("aria-label",A.title),A.addEventListener("click",()=>{e.attachedImages.splice(S,1),v(),N()}),Le(A,"x"),T.append($,w,A),t.attachmentsEl.append(T)})}async function k(E){const S=E.trim().replace(/^\/+/,"").split(/\s+/,1)[0]?.toLowerCase();if(S==="logout"){e.token="",As(),t.tokenInput.value="",t.tokenOverlay.hidden=!1,t.tokenInput.focus();return}const T=await fetch("/api/command",{method:"POST",headers:r.headers(),body:JSON.stringify({command:E})}),$=await T.text(),w=$?JSON.parse($):{};if(!T.ok||w.ok===!1)throw new Error(w.error||$);w.state&&(i(w.state),e.isStreaming=!!w.state.isStreaming,N(),w.state.thinkingLevels&&o(w.state.thinkingLevels)),await c(),(S==="reload"||S==="commands")&&await P(!0).catch(()=>{}),S==="new"&&await d(),w.message&&a("system",w.message)}function C(){t.formEl.addEventListener("submit",async E=>{if(E.preventDefault(),e.isStreaming&&!t.promptEl.value.trim()&&e.attachedImages.length===0)return;const S=t.promptEl.value.trim(),T=e.attachedImages.map(({type:$,data:w,mimeType:A,name:_})=>({type:$,data:w,mimeType:A,name:_}));if(!(!S&&T.length===0)){if(S.startsWith("/")&&T.length===0){let $;try{$=await h(S)}catch{$=g.has(Z(S))?{name:Z(S),source:"web"}:void 0}if(!$||$.source==="web"){t.promptEl.value="",I(),N(),a("system",`› ${S}`);try{await k(S)}catch(w){a("system",w instanceof Error?w.message:String(w),"error")}finally{t.promptEl.focus()}return}}t.promptEl.value="",I(),e.attachedImages=[],v(),e.isStreaming=!0,N(),l?.(),a("user",S||"","",T.map($=>({data:$.data,mimeType:$.mimeType})));try{const $=await fetch("/api/prompt",{method:"POST",headers:r.headers(),body:JSON.stringify({sessionId:e.currentSessionId,message:S,mode:e.queueMode,images:T})});if(!$.ok)throw new Error(await $.text())}catch($){e.isStreaming=!1,N(),u?.(),a("system",$ instanceof Error?$.message:String($),"error")}finally{t.promptEl.focus()}}}),t.promptEl.addEventListener("keydown",E=>{if(!t.slashCommandsEl.hidden){const S=B();if(E.key==="ArrowDown"&&S.length>0){E.preventDefault(),b=(b+1)%S.length,Y();return}if(E.key==="ArrowUp"&&S.length>0){E.preventDefault(),b=(b-1+S.length)%S.length,Y();return}if((E.key==="Enter"&&!E.metaKey&&!E.ctrlKey||E.key==="Tab")&&S[b]){E.preventDefault(),D(S[b]);return}if(E.key==="Escape"){E.preventDefault(),I();return}}E.key==="Enter"&&(E.metaKey||E.ctrlKey)&&t.formEl.requestSubmit()}),t.promptEl.addEventListener("focus",()=>{H()}),t.promptEl.addEventListener("blur",()=>window.setTimeout(I,100)),t.promptEl.addEventListener("input",()=>{N(),b=0,Y(),H()}),t.attachButton.addEventListener("click",()=>t.imageInput.click()),t.imageInput.addEventListener("change",async()=>{const E=Array.from(t.imageInput.files||[]).filter(S=>S.type.startsWith("image/"));t.imageInput.value="";try{const S=await Promise.all(E.map(Ms));e.attachedImages.push(...S),v(),N()}catch(S){a("system",S instanceof Error?S.message:String(S),"error")}}),t.stopButton.addEventListener("click",async()=>{await fetch("/api/abort",{method:"POST",headers:r.headers(),body:JSON.stringify({sessionId:e.currentSessionId})})}),t.queueToggle.addEventListener("click",()=>{e.queueMode=e.queueMode==="steer"?"followUp":"steer",M()}),t.tokenForm.addEventListener("submit",E=>{E.preventDefault();const S=t.tokenInput.value.trim();S&&(e.token=S,Rs(e.token),t.tokenOverlay.hidden=!0,s().catch(T=>a("system",T instanceof Error?T.message:String(T),"error")))}),t.expandButton.addEventListener("click",()=>{e.editorExpanded=!e.editorExpanded,t.formEl.classList.toggle("expanded",e.editorExpanded),Le(t.expandButton,e.editorExpanded?"minimize-2":"maximize-2"),t.expandButton.title=e.editorExpanded?"Collapse editor":"Expand editor",t.expandButton.setAttribute("aria-label",t.expandButton.title),t.promptEl.focus()})}return{init:C,renderAttachments:v,setPromptText:L,updatePrimaryAction:N,updateQueueToggle:M}}function gt(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Dr(n){const e=gt(n);if(e===void 0)return"—";if(Math.abs(e)<1e3)return Math.round(e).toLocaleString();if(Math.abs(e)<1e6){const r=e/1e3;return`${r>=10?r.toFixed(0):r.toFixed(1)}k`}const t=e/1e6;return`${t>=10?t.toFixed(0):t.toFixed(1)}m`}function Ke(n){const e=gt(n);return e===void 0?"unknown":Math.round(e).toLocaleString()}function Ja(n){const e=gt(n);return e===void 0?"unknown":`$${e.toFixed(e<1?3:2)}`}function sr(n){const e=n?.contextUsage,t=gt(e?.percent);if(t!==void 0)return t;const r=gt(e?.tokens),a=gt(e?.contextWindow);if(!(r===void 0||a===void 0||a<=0))return r/a*100}function Ls(n){return n===void 0?"unknown":n>=95?"danger":n>=80?"warning":n>=50?"active":"normal"}function Is(n){const e=n?.contextUsage,t=sr(n);if(!n||t===void 0||e?.tokens===null)return"Context usage unavailable until the next model response.";const r=n.tokens||{};return[`Context: ${Ke(e?.tokens)} / ${Ke(e?.contextWindow)} tokens (${Math.round(t)}%)`,`Input: ${Ke(r.input)} · Output: ${Ke(r.output)}`,`Cache read: ${Ke(r.cacheRead)} · Cache write: ${Ke(r.cacheWrite)}`,`Cost: ${Ja(n.cost)}`].join(`
|
|
3
3
|
`)}function yt(n,e,t){const r=document.createElement("div");r.className="contextMeterRow";const a=document.createElement("span");a.textContent=e;const i=document.createElement("strong");i.textContent=t,r.append(a,i),n.append(r)}function Ds(n){const{state:e,elements:t}=n;function r(){t.contextMeterPopoverEl.hidden=!0,t.contextMeterEl.setAttribute("aria-expanded","false")}function a(c){const d=sr(c),s=c?.contextUsage,l=c?.tokens||{},u=t.contextMeterPopoverEl;u.textContent="";const g=document.createElement("div");if(g.className="contextMeterPopoverTitle",g.textContent="Context usage",u.append(g),!c||d===void 0||s?.tokens===null){const p=document.createElement("p");p.className="contextMeterEmpty",p.textContent="Usage will appear after the next model response.",u.append(p);return}const f=document.createElement("div");f.className="contextMeterSummary",f.textContent=`${Dr(s?.tokens)} / ${Dr(s?.contextWindow)} tokens · ${Math.round(d)}%`,u.append(f),yt(u,"Input",Ke(l.input)),yt(u,"Output",Ke(l.output)),yt(u,"Cache read",Ke(l.cacheRead)),yt(u,"Cache write",Ke(l.cacheWrite)),yt(u,"Cost",Ja(c.cost))}function i(c){e.stats=c||void 0;const d=sr(c),s=Math.max(0,Math.min(100,d??0)),l=Ls(d),u=Is(c);t.contextMeterEl.className=`contextMeter ${l}`,t.contextMeterEl.style.setProperty("--context-percent",`${s}%`),t.contextMeterEl.title=u,t.contextMeterEl.setAttribute("aria-label",u.replace(/\n/g,". ")),t.contextMeterLabelEl.textContent=d!==void 0&&d>=80?`ctx ${Math.round(d)}%`:"",a(c)}function o(){t.contextMeterEl.addEventListener("click",()=>{const c=t.contextMeterPopoverEl.hidden;a(e.stats),t.contextMeterPopoverEl.hidden=!c,t.contextMeterEl.setAttribute("aria-expanded",String(c))}),document.addEventListener("click",c=>{const d=c.target;!d||t.contextMeterEl.contains(d)||t.contextMeterPopoverEl.contains(d)||r()}),document.addEventListener("keydown",c=>{c.key==="Escape"&&r()}),i(e.stats)}return{init:o,update:i}}async function Ct(n,e){const t=await fetch(n,{headers:e});if(!t.ok)throw new Error(await t.text());return t.json()}async function Bs(n,e){const t=await fetch(n,{method:"POST",headers:e});if(!t.ok)throw new Error(await t.text());return t.json()}function Rt(n={},e){const t=new URLSearchParams(n);return e&&t.set("repo",e),t}function Br(n){return Ct("/api/git/repos",n)}function Pr(n,e,t=!1){const r=Rt(t?{fetch:"1"}:{},e);return Ct(`/api/git/status?${r}`,n)}function $r(n,e){const t=Rt({},e);return Ct(`/api/git/log?${t}`,n)}function Ps(n,e,t,r){const a=Rt({path:e,staged:t?"1":"0"},r);return Ct(`/api/git/diff?${a}`,n)}function $s(n,e,t){const r=Rt({hash:e},t);return Ct(`/api/git/commit?${r}`,n)}function Fs(n,e){const t=Rt({},e);return Bs(`/api/git/sync?${t}`,n)}function Us(n){return n.match(/^diff --git a\/(.*?) b\/(.*)$/)?.[2]||n.replace(/^diff --git /,"")}function zs(n){const e=[];let t;for(const r of n.split(`
|
|
4
4
|
`))r.startsWith("diff --git ")?(t={name:Us(r),lines:[r]},e.push(t)):t?t.lines.push(r):r.trim()&&(t={name:"Diff",lines:[r]},e.push(t));return e}function Fr(n){return String(n??"").match(/\w+|\s+|[^\w\s]+/g)||[]}function ja(n,e){const t=Array.from({length:n.length+1},()=>Array(e.length+1).fill(0));for(let a=n.length-1;a>=0;a--)for(let i=e.length-1;i>=0;i--)t[a][i]=n[a]===e[i]?t[a+1][i+1]+1:Math.max(t[a+1][i],t[a][i+1]);const r=[];for(let a=0,i=0;a<n.length&&i<e.length;)n[a]===e[i]?r.push([a++,i++]):t[a+1][i]>=t[a][i+1]?a++:i++;return r}function Zt(n){return String(n??"").split(`
|
|
5
5
|
`)}function qs(n,e){const t=Zt(n),r=Zt(e),a=ja(t,r),i=[];let o=0,c=0;for(const[d,s]of a){for(;o<d||c<s;)o<d&&c<s?i.push({op:"del",oldLine:t[o++]},{op:"add",newLine:r[c++]}):o<d?i.push({op:"del",oldLine:t[o++]}):i.push({op:"add",newLine:r[c++]});i.push({op:"same",oldLine:t[o++],newLine:r[c++]})}for(;o<t.length||c<r.length;)o<t.length&&c<r.length?i.push({op:"del",oldLine:t[o++]},{op:"add",newLine:r[c++]}):o<t.length?i.push({op:"del",oldLine:t[o++]}):i.push({op:"add",newLine:r[c++]});return i}function Ur(n,e,t,r){const a=Fr(e),i=Fr(t),o=new Set(ja(a,i).map(([d,s])=>r==="old"?d:s));(r==="old"?a:i).forEach((d,s)=>{const l=document.createElement("span");l.textContent=d,o.has(s)||(l.className=`diffWord diffWord--${r==="old"?"del":"add"}`),n.append(l)})}function zr(n){return n.startsWith("+")&&!n.startsWith("+++")?"add":n.startsWith("-")&&!n.startsWith("---")?"del":n.startsWith("@@")||n.startsWith("diff --git")||n.startsWith("index ")||n.startsWith("---")||n.startsWith("+++")?"meta":"same"}function Ye(n,e="",t=""){const r=document.createElement("tr");r.className=`diffLine diffLine--${n==="meta"?"same gitPatchMeta":n}`;const a=document.createElement("td");a.className="diffGutter";const i=document.createElement("td");i.className="diffCode diffCode--old";const o=document.createElement("td");o.className="diffGutter";const c=document.createElement("td");return c.className="diffCode diffCode--new",n==="add"?(o.textContent="+",c.textContent=t):n==="del"?(a.textContent="-",i.textContent=e):n==="changed"?(a.textContent="-",o.textContent="+",Ur(i,e,t,"old"),Ur(c,e,t,"new")):(a.textContent=n==="same"?" ":"",o.textContent=n==="same"?" ":"",i.textContent=e,c.textContent=t||e),r.append(a,i,o,c),r}function Hs(n,e){e.forEach((t,r)=>{t.op==="del"&&e[r+1]?.op==="add"?n.append(Ye("changed",t.oldLine||"",e[r+1].newLine||"")):t.op==="add"&&e[r-1]?.op==="del"||(t.op==="add"?n.append(Ye("add","",t.newLine||"")):t.op==="del"?n.append(Ye("del",t.oldLine||"","")):n.append(Ye("same",t.oldLine||"",t.newLine||t.oldLine||"")))})}function Gs(n,e){for(let t=0;t<e.length;t++){const r=e[t],a=zr(r);a==="del"&&zr(e[t+1]||"")==="add"?(n.append(Ye("changed",r.slice(1),e[t+1].slice(1))),t++):a==="add"?n.append(Ye("add","",r.slice(1))):a==="del"?n.append(Ye("del",r.slice(1),"")):a==="meta"?n.append(Ye("meta",r,r)):n.append(Ye("same",r.startsWith(" ")?r.slice(1):r,r.startsWith(" ")?r.slice(1):r))}}function Jt(n,e){n.classList.toggle("diffContainer--stacked",e),n.classList.toggle("diffContainer--sideBySide",!e)}function Ks(n,e={}){const t=document.createElement("div");return t.className="diffContainer",Jt(t,!!e.stacked),n.forEach((r,a)=>{if(a>0){const o=document.createElement("div");o.className="diffSep",t.append(o)}const i=document.createElement("table");i.className="diffTable",Hs(i,qs(r.oldText,r.newText)),t.append(i)}),t}function Ws(n){return n.reduce((e,t)=>e+Zt(t.oldText).length+Zt(t.newText).length,0)}function Zs(n,e={}){const t=document.createElement("div");t.className="diffContainer gitPatchFiles",Jt(t,!!e.stacked);const r=zs(n);if(!r.length){const a=document.createElement("div");return a.className="gitEmpty",a.textContent="No diff available.",t.append(a),t}for(const a of r){const i=document.createElement("details");i.className="gitPatchFile",i.open=!0;const o=document.createElement("summary");o.textContent=a.name;const c=document.createElement("table");c.className="diffTable",Gs(c,a.lines),i.append(o,c),t.append(i)}return t}const Ys=new Set([".png",".jpg",".jpeg",".gif",".webp"]);function Vs(){return window.matchMedia("(max-width: 700px)").matches}function qr(n){const e=n.toLowerCase();return[...Ys].some(t=>e.endsWith(t))}function fn(n){return n.split("/").filter(Boolean).at(-1)||n}function Hr(n,e,t){const r=new URLSearchParams({path:n.path,version:t,staged:n.staged&&n.worktreeStatus===" "?"1":"0"});return n.oldPath&&r.set("oldPath",n.oldPath),e&&r.set("repo",e),`/api/git/image?${r}`}async function Gr(n,e,t,r){try{const a=await fetch(e,{headers:t});if(!a.ok)throw new Error(await a.text());const i=await a.blob(),o=URL.createObjectURL(i),c=document.createElement("img");c.src=o,c.alt=r,c.addEventListener("load",()=>n.classList.add("loaded"),{once:!0}),n.textContent="",n.append(c)}catch{n.textContent="No image"}}function Qs(n){const{file:e,repo:t,apiHeaders:r}=n,a=document.createElement("div");a.className="gitImageDiff";const i=Kr("Before",e.oldPath?fn(e.oldPath):fn(e.path)),o=Kr("After",fn(e.path));return a.append(i.pane,o.pane),Gr(i.preview,Hr(e,t,"before"),r(),`Before ${e.path}`),Gr(o.preview,Hr(e,t,"after"),r(),`After ${e.path}`),a}function Kr(n,e){const t=document.createElement("section");t.className="gitImagePane";const r=document.createElement("h4");r.textContent=n;const a=document.createElement("div");a.className="gitImageName",a.textContent=e;const i=document.createElement("div");return i.className="gitImagePreview",i.textContent="Loading image…",t.append(r,a,i),{pane:t,preview:i}}function ei(n){const e=document.createElement("div"),t=document.createElement("div");t.className="diffToolbar gitDiffToolbar";const r=document.createElement("span"),a=(n.match(/^diff --git /gm)||[]).length;r.textContent=`${a||1} file${a===1?"":"s"}`;const i=document.createElement("button");i.type="button",i.className="diffLayoutToggle";let o=Vs();const c=Zs(n,{stacked:o}),d=()=>{i.replaceChildren(rt(o?Ka:Za,{"aria-hidden":"true"}));const s=o?"Switch to side-by-side diff view":"Switch to top/bottom diff view";i.title=s,i.setAttribute("aria-label",s)};return i.addEventListener("click",()=>{o=!o,Jt(c,o),d()}),d(),t.append(r,i),e.append(t,c),e}function Xs(n){const{container:e,file:t,repo:r,diff:a,loading:i,apiHeaders:o,onBack:c}=n;e.textContent="";const d=document.createElement("div");if(d.className="gitDetailHeader",c){const l=document.createElement("button");l.type="button",l.className="gitBackButton",l.textContent="← Back",l.addEventListener("click",c),d.append(l)}const s=document.createElement("h3");if(s.textContent=t?t.path:"Diff",d.append(s),e.append(d),!t){const l=document.createElement("div");l.className="gitEmpty",l.textContent="Select a file to view its diff.",e.append(l);return}if(i){const l=document.createElement("div");l.className="gitEmpty",l.textContent="Loading diff…",e.append(l);return}if(qr(t.path)||t.oldPath&&qr(t.oldPath)){e.append(Qs({file:t,repo:r,apiHeaders:o}));return}if(!a){const l=document.createElement("div");l.className="gitEmpty",l.textContent="No diff available.",e.append(l);return}e.append(ei(a))}function Js(n){const{container:e,commit:t,files:r=[],diff:a="",loading:i,onBack:o}=n;e.textContent="";const c=document.createElement("div");if(c.className="gitDetailHeader",o){const b=document.createElement("button");b.type="button",b.className="gitBackButton",b.textContent="← Back",b.addEventListener("click",o),c.append(b)}const d=document.createElement("h3");if(d.textContent="Commit",c.append(d),e.append(c),!t){const b=document.createElement("div");b.className="gitEmpty",b.textContent="Select a commit to view details.",e.append(b);return}const s=document.createElement("div");s.className="gitCommitDetails";const l=document.createElement("h4");l.textContent=t.subject;const u=document.createElement("code");u.textContent=t.hash;const g=document.createElement("p");if(g.textContent=`${t.author} · ${new Date(t.date).toLocaleString()}`,s.append(l,u,g),t.refs.length){const b=document.createElement("p");b.textContent=`Refs: ${t.refs.join(", ")}`,s.append(b)}if(e.append(s),i){const b=document.createElement("div");b.className="gitEmpty",b.textContent="Loading commit diff…",e.append(b);return}const f=document.createElement("h3");f.className="gitSectionTitle",f.textContent=`Changed files (${r.length})`,e.append(f);const p=document.createElement("div");p.className="gitCommitFiles";for(const b of r){const N=document.createElement("div");N.className="gitCommitFile";const M=document.createElement("span");M.className="gitCommitFileStatus",M.textContent=b.status;const L=document.createElement("span");L.className="gitCommitFilePath",L.textContent=b.path;const Z=document.createElement("span");Z.className="gitCommitFileStats";const R=b.additions??0,I=b.deletions??0;Z.textContent=R||I?`+${R} -${I}`:"",N.append(M,L,Z),p.append(N)}e.append(p);const y=document.createElement("h3");y.className="gitSectionTitle",y.textContent="Diff",e.append(y,ei(a))}function js(n){const e=new Date(n);return Number.isNaN(e.getTime())?"":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(e)}function eo(n){const{container:e,commits:t,selectedHash:r,onSelectCommit:a}=n;if(e.textContent="",!t.length){const o=document.createElement("div");o.className="gitEmpty",o.textContent="No commits found.",e.append(o);return}const i=document.createElement("div");i.className="gitCommitList";for(const o of t){const c=document.createElement("button");c.type="button",c.className=`gitCommitItem${o.hash===r?" selected":""}`;const d=document.createElement("span");d.className="gitCommitRail";const s=document.createElement("span");s.className="gitCommitDot",d.append(s);const l=document.createElement("span");l.className="gitCommitBody";const u=document.createElement("span");u.className="gitCommitSubject",u.textContent=o.subject;const g=document.createElement("span");if(g.className="gitCommitMeta",g.textContent=`${o.shortHash} · ${o.author} · ${js(o.date)}`,l.append(u),o.refs.length){const f=document.createElement("span");f.className="gitCommitRefs",f.textContent=o.refs.join(" "),l.append(f)}l.append(g),c.append(d,l),c.addEventListener("click",()=>a(o)),i.append(c)}e.append(i)}function to(n){return n.label==="untracked"?"U":n.label==="modified"?"M":n.label==="added"?"A":n.label==="deleted"?"D":n.label==="renamed"?"R":n.label==="conflicted"?"!":`${n.indexStatus||" "}${n.worktreeStatus||" "}`.trim()||n.label[0].toUpperCase()}function no(n){const e={name:"",children:new Map};for(const t of n){const r=t.path.split("/").filter(Boolean);let a=e;for(const i of r){let o=a.children.get(i);o||(o={name:i,children:new Map},a.children.set(i,o)),a=o}a.file=t}return e}function ro(n){return[...n.children.values()].sort((e,t)=>{const r=e.children.size>0&&!e.file,a=t.children.size>0&&!t.file;return r!==a?r?-1:1:e.name.localeCompare(t.name)})}function ti(n){return n.split(/[\\/]/).filter(Boolean).at(-1)||n}function ni(n){return ti(n.root||n.path)||"Repository"}function ri(n,e){return{branch:e?.branch||n.branch||"detached",upstream:e?.upstream||n.upstream,ahead:e?.ahead??n.ahead,behind:e?.behind??n.behind,dirtyCount:e?.files.length??n.dirtyCount}}function wt(n,e){const t=document.createElement("span");t.className="gitRepoMetaItem",t.textContent=e,n.append(t)}function ao(n,e,t){const r=ri(e,t);wt(n,r.branch),r.upstream&&wt(n,`⇄ ${r.upstream}`),r.ahead>0&&wt(n,`↑${r.ahead}`),r.behind>0&&wt(n,`↓${r.behind}`),wt(n,r.dirtyCount?`${r.dirtyCount} changed`:"clean")}function io(n,e){const t=ri(n,e);return!!(t.upstream&&t.behind>0)}function so(n,e,t,r){if(!io(n,e))return;const a=document.createElement("button");return a.type="button",a.className="gitRebaseButton",a.title="Fetch and rebase onto upstream",a.setAttribute("aria-label",`Fetch and rebase ${ni(n)} onto upstream`),a.disabled=t===n.path,a.append(rt(ls,{"aria-hidden":"true"})),a.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),r(n)}),a}function oo(n,e,t,r,a){const i=document.createElement("button");i.type="button",i.className=`gitFileItem gitTreeFile${n.path===t&&e.path===r?" selected":""}`;const o=document.createElement("span");o.className=`gitStatusBadge ${n.label}`,o.textContent=to(n);const c=document.createElement("span");return c.className="gitFilePath",c.textContent=n.oldPath?`${n.oldPath} → ${n.path}`:ti(n.path),i.append(o,c),i.addEventListener("click",()=>a(n,e)),i}function ai(n){const{container:e,node:t,repo:r,selectedPath:a,selectedRepoPath:i,onSelectFile:o}=n;for(const c of ro(t)){if(c.file&&c.children.size===0){e.append(oo(c.file,r,a,i,o));continue}const d=document.createElement("details");d.className="gitTreeDir",d.open=!0;const s=document.createElement("summary"),l=document.createElement("span");l.className="gitTreeDirName",l.textContent=c.name,s.append(l),d.append(s);const u=document.createElement("div");u.className="gitTreeChildren",ai({container:u,node:c,repo:r,selectedPath:a,selectedRepoPath:i,onSelectFile:o}),d.append(u),e.append(d)}}function co(n){const{repo:e,status:t,selectedPath:r,selectedRepoPath:a,syncingRepo:i,onSelectFile:o,onRebase:c}=n,d=t?.files||[],s=document.createElement("details");s.className="gitRepoChangesAccordion",s.open=d.length>0||e.path===a;const l=document.createElement("summary"),u=document.createElement("span");u.className="gitRepoDisclosure",u.textContent="›";const g=document.createElement("span");g.className="gitRepoHeaderText";const f=document.createElement("span");f.className="gitRepoName",f.textContent=ni(e),f.title=e.path==="."?e.root:e.path;const p=document.createElement("span");p.className="gitRepoMeta",ao(p,e,t),g.append(f,p),l.append(u,g);const y=so(e,t,i,c);y&&l.append(y),s.append(l);const b=document.createElement("div");if(b.className="gitRepoChangesBody",t)if(d.length)ai({container:b,node:no(d),repo:e,selectedPath:r,selectedRepoPath:a,onSelectFile:o});else{const N=document.createElement("div");N.className="gitEmpty",N.textContent="Working tree clean.",b.append(N)}else{const N=document.createElement("div");N.className="gitEmpty",N.textContent="Loading status…",b.append(N)}return s.append(b),s}function lo(n){const{container:e,repos:t,statusesByRepo:r,selectedPath:a,selectedRepoPath:i,syncingRepo:o,onSelectFile:c,onRebase:d}=n;e.textContent="";const s=document.createElement("section");s.className="gitChangesOverview";const l=document.createElement("h3");l.textContent="Repositories",s.append(l);const u=document.createElement("div");u.className="gitRepoChangesList";for(const g of t)u.append(co({repo:g,status:r[g.path],selectedPath:a,selectedRepoPath:i,syncingRepo:o,onSelectFile:c,onRebase:d}));s.append(u),e.append(s)}function uo(n){const{button:e,panel:t,apiHeaders:r}=n,a=t.querySelector("#gitPrimaryPane"),i=t.querySelector("#gitDetailPane"),o=t.querySelector("#gitStatusTab"),c=t.querySelector("#gitGraphTab"),d=t.querySelector("#gitCloseButton"),s={isOpen:!1,loading:!1,syncing:!1,statusesByRepo:{},commits:[],repos:[],repoPickerOpen:!1,primaryView:"status",mobileView:"status",diffLoading:!1,commitLoading:!1};function l(h=s.repoCwd){return h?`pi-web.git.selectedRepo:${h}`:"pi-web.git.selectedRepo"}function u(h){try{return localStorage.getItem(l(h))}catch{return}}function g(h){try{localStorage.setItem(l(),h.path)}catch{}}function f(){return s.selectedRepo?.path}function p(h){s.isOpen=h,t.hidden=!h,e.classList.toggle("active",h),h&&L()}function y(h,v){const k=s.selectedRepo?.path||u(v);return h.find(C=>C.path===k)||h.find(C=>C.isCurrent)||h[0]}async function b(h){const v=await Promise.all(h.map(async k=>[k.path,await Pr(r(),k.path,!0)]));return Object.fromEntries(v)}function N(h=s.statusesByRepo){const v=s.selectedRepo?h[s.selectedRepo.path]?.files[0]:void 0;if(v&&s.selectedRepo)return{repo:s.selectedRepo,file:v};for(const k of s.repos){const C=h[k.path]?.files[0];if(C)return{repo:k,file:C}}}async function M(){if(!s.selectedRepo){s.status={ok:!0,isRepo:!1,ahead:0,behind:0,files:[]},s.statusesByRepo={},s.commits=[],s.selectedFile=void 0,s.selectedFileRepo=void 0,s.selectedCommit=void 0,s.diff=void 0,s.commitDiff=void 0;return}const h=f(),[v,k]=await Promise.all([b(s.repos),$r(r(),h)]);s.statusesByRepo=v,s.status=h?v[h]:void 0,s.commits=k.commits||[],s.selectedCommit=s.commits[0],s.diff=void 0,s.commitDiff=void 0,s.commitFiles=void 0;const C=s.selectedFileRepo?s.repos.find(T=>T.path===s.selectedFileRepo):void 0,E=C&&s.selectedFile?v[C.path]?.files.find(T=>T.path===s.selectedFile?.path):void 0,S=C&&E?{repo:C,file:E}:N(v);S?await R(S.file,S.repo,!1):(s.selectedFile=void 0,s.selectedFileRepo=void 0,s.diff=void 0)}async function L(){s.loading=!0,s.error=void 0,H();try{const h=await Br(r());s.repos=h.repos,s.repoCwd=h.cwd,s.selectedRepo=y(h.repos,h.cwd),await M()}catch(h){s.error=h instanceof Error?h.message:String(h)}finally{s.loading=!1,H()}}async function Z(h){s.selectedRepo=h,s.repoPickerOpen=!1,s.loading=!0,s.error=void 0,s.selectedFile=void 0,s.selectedFileRepo=void 0,s.selectedCommit=void 0,s.diff=void 0,s.commitDiff=void 0,g(h),H();try{const[v,k]=await Promise.all([s.statusesByRepo[h.path]?Promise.resolve(s.statusesByRepo[h.path]):Pr(r(),h.path,!0),$r(r(),h.path)]);s.statusesByRepo={...s.statusesByRepo,[h.path]:v},s.status=v,s.commits=k.commits||[],s.selectedCommit=s.commits[0],v.files[0]&&await R(v.files[0],h,!1)}catch(v){s.error=v instanceof Error?v.message:String(v)}finally{s.loading=!1,H()}}async function R(h,v,k=!0){s.selectedRepo=v,s.status=s.statusesByRepo[v.path],s.selectedFile=h,s.selectedFileRepo=v.path,s.diffLoading=!0,s.diff=void 0,k&&(s.mobileView="diff"),H();try{const C=await Ps(r(),h.path,h.staged&&h.worktreeStatus===" ",v.path);s.diff=C.diff}catch(C){s.diff=C instanceof Error?C.message:String(C)}finally{s.diffLoading=!1,H()}}async function I(h,v=!0){s.selectedCommit=h,s.commitLoading=!0,s.commitFiles=void 0,s.commitDiff=void 0,v&&(s.mobileView="commit"),H();try{const k=await $s(r(),h.hash,f());s.commitFiles=k.files,s.commitDiff=k.diff}catch(k){s.commitDiff=k instanceof Error?k.message:String(k)}finally{s.commitLoading=!1,H()}}function P(h){s.primaryView=h,s.mobileView=h,H()}async function B(h){s.syncing=!0,s.syncingRepo=h.path,s.error=void 0,H();try{await Fs(r(),h.path);const v=await Br(r());s.repos=v.repos,s.repoCwd=v.cwd,s.selectedRepo=s.repos.find(k=>k.path===s.selectedRepo?.path)||s.repos.find(k=>k.path===h.path)||y(s.repos,v.cwd),await M()}catch(v){s.error=v instanceof Error?v.message:String(v)}finally{s.syncing=!1,s.syncingRepo=void 0,H()}}function D(h){return h.path==="."?".":h.path}function Y(h){if(s.repos.length<=1)return;const v=document.createElement("details");v.className="gitRepoAccordion",v.open=s.repoPickerOpen||!s.selectedRepo&&s.repos.length>0,v.addEventListener("toggle",()=>{s.repoPickerOpen=v.open});const k=document.createElement("summary");k.textContent=s.selectedRepo?`Repository: ${D(s.selectedRepo)}`:"Repository: none found",v.append(k);const C=document.createElement("div");if(C.className="gitRepoList",s.repos.length)for(const E of s.repos){const S=document.createElement("button");S.type="button",S.className=`gitRepoItem${E.path===s.selectedRepo?.path?" selected":""}`,S.disabled=s.loading||s.syncing,S.addEventListener("click",()=>{Z(E)});const T=document.createElement("span");T.className="gitRepoName",T.textContent=D(E),S.append(T);const $=document.createElement("span");$.className="gitRepoMeta";const w=E.dirtyCount?`${E.dirtyCount} changed`:"clean",A=E.upstream?` ⇄ ${E.upstream}`:"";$.textContent=`${E.branch||"detached"}${A} · ↑${E.ahead} ↓${E.behind} · ${w}`,S.append($),C.append(S)}else{const E=document.createElement("div");E.className="gitRepoEmpty",E.textContent="No repos at the current folder or one level down.",C.append(E)}v.append(C),h.append(v)}function H(){t.dataset.view=s.mobileView,t.dataset.primaryView=s.primaryView,o.classList.toggle("active",s.primaryView==="status"),c.classList.toggle("active",s.primaryView==="graph"),a.textContent="",s.primaryView==="graph"&&Y(a);const h=document.createElement("div");h.className="gitPrimaryContent",a.append(h),s.loading?h.textContent="Loading Git data…":s.error?h.textContent=s.error:s.repos.length?s.primaryView==="status"?lo({container:h,repos:s.repos,statusesByRepo:s.statusesByRepo,selectedPath:s.selectedFile?.path,selectedRepoPath:s.selectedFileRepo||s.selectedRepo?.path,syncingRepo:s.syncingRepo,onSelectFile:(v,k)=>{R(v,k)},onRebase:v=>{B(v)}}):s.status?.isRepo?eo({container:h,commits:s.commits,selectedHash:s.selectedCommit?.hash,onSelectCommit:v=>{I(v)}}):h.textContent="Selected folder is not a Git repository.":h.textContent="No Git repositories found in the current folder or one level down.",s.mobileView==="commit"?Js({container:i,commit:s.selectedCommit,files:s.commitFiles,diff:s.commitDiff,loading:s.commitLoading,onBack:()=>P("graph")}):Xs({container:i,file:s.selectedFile,repo:s.selectedFileRepo,diff:s.diff,loading:s.diffLoading,apiHeaders:r,onBack:()=>P("status")})}e.addEventListener("click",()=>p(!s.isOpen)),d.addEventListener("click",()=>p(!1)),o.addEventListener("click",()=>P("status")),c.addEventListener("click",()=>P("graph")),H()}function po(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var hn,Wr;function mo(){if(Wr)return hn;Wr=1;function n(m){return m instanceof Map?m.clear=m.delete=m.set=function(){throw new Error("map is read-only")}:m instanceof Set&&(m.add=m.clear=m.delete=function(){throw new Error("set is read-only")}),Object.freeze(m),Object.getOwnPropertyNames(m).forEach(x=>{const U=m[x],ee=typeof U;(ee==="object"||ee==="function")&&!Object.isFrozen(U)&&n(U)}),m}class e{constructor(x){x.data===void 0&&(x.data={}),this.data=x.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function t(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(m,...x){const U=Object.create(null);for(const ee in m)U[ee]=m[ee];return x.forEach(function(ee){for(const ye in ee)U[ye]=ee[ye]}),U}const a="</span>",i=m=>!!m.scope,o=(m,{prefix:x})=>{if(m.startsWith("language:"))return m.replace("language:","language-");if(m.includes(".")){const U=m.split(".");return[`${x}${U.shift()}`,...U.map((ee,ye)=>`${ee}${"_".repeat(ye+1)}`)].join(" ")}return`${x}${m}`};class c{constructor(x,U){this.buffer="",this.classPrefix=U.classPrefix,x.walk(this)}addText(x){this.buffer+=t(x)}openNode(x){if(!i(x))return;const U=o(x.scope,{prefix:this.classPrefix});this.span(U)}closeNode(x){i(x)&&(this.buffer+=a)}value(){return this.buffer}span(x){this.buffer+=`<span class="${x}">`}}const d=(m={})=>{const x={children:[]};return Object.assign(x,m),x};class s{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(x){this.top.children.push(x)}openNode(x){const U=d({scope:x});this.add(U),this.stack.push(U)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(x){return this.constructor._walk(x,this.rootNode)}static _walk(x,U){return typeof U=="string"?x.addText(U):U.children&&(x.openNode(U),U.children.forEach(ee=>this._walk(x,ee)),x.closeNode(U)),x}static _collapse(x){typeof x!="string"&&x.children&&(x.children.every(U=>typeof U=="string")?x.children=[x.children.join("")]:x.children.forEach(U=>{s._collapse(U)}))}}class l extends s{constructor(x){super(),this.options=x}addText(x){x!==""&&this.add(x)}startScope(x){this.openNode(x)}endScope(){this.closeNode()}__addSublanguage(x,U){const ee=x.root;U&&(ee.scope=`language:${U}`),this.add(ee)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(m){return m?typeof m=="string"?m:m.source:null}function g(m){return y("(?=",m,")")}function f(m){return y("(?:",m,")*")}function p(m){return y("(?:",m,")?")}function y(...m){return m.map(U=>u(U)).join("")}function b(m){const x=m[m.length-1];return typeof x=="object"&&x.constructor===Object?(m.splice(m.length-1,1),x):{}}function N(...m){return"("+(b(m).capture?"":"?:")+m.map(ee=>u(ee)).join("|")+")"}function M(m){return new RegExp(m.toString()+"|").exec("").length-1}function L(m,x){const U=m&&m.exec(x);return U&&U.index===0}const Z=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function R(m,{joinWith:x}){let U=0;return m.map(ee=>{U+=1;const ye=U;let we=u(ee),V="";for(;we.length>0;){const W=Z.exec(we);if(!W){V+=we;break}V+=we.substring(0,W.index),we=we.substring(W.index+W[0].length),W[0][0]==="\\"&&W[1]?V+="\\"+String(Number(W[1])+ye):(V+=W[0],W[0]==="("&&U++)}return V}).map(ee=>`(${ee})`).join(x)}const I=/\b\B/,P="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",D="\\b\\d+(\\.\\d+)?",Y="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",h="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",v=(m={})=>{const x=/^#![ ]*\//;return m.binary&&(m.begin=y(x,/.*\b/,m.binary,/\b.*/)),r({scope:"meta",begin:x,end:/$/,relevance:0,"on:begin":(U,ee)=>{U.index!==0&&ee.ignoreMatch()}},m)},k={begin:"\\\\[\\s\\S]",relevance:0},C={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[k]},E={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[k]},S={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},T=function(m,x,U={}){const ee=r({scope:"comment",begin:m,end:x,contains:[]},U);ee.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const ye=N("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ee.contains.push({begin:y(/[ ]+/,"(",ye,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ee},$=T("//","$"),w=T("/\\*","\\*/"),A=T("#","$"),_={scope:"number",begin:D,relevance:0},z={scope:"number",begin:Y,relevance:0},G={scope:"number",begin:H,relevance:0},ne={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[k,{begin:/\[/,end:/\]/,relevance:0,contains:[k]}]},ce={scope:"title",begin:P,relevance:0},re={scope:"title",begin:B,relevance:0},ie={begin:"\\.\\s*"+B,relevance:0};var ve=Object.freeze({__proto__:null,APOS_STRING_MODE:C,BACKSLASH_ESCAPE:k,BINARY_NUMBER_MODE:G,BINARY_NUMBER_RE:H,COMMENT:T,C_BLOCK_COMMENT_MODE:w,C_LINE_COMMENT_MODE:$,C_NUMBER_MODE:z,C_NUMBER_RE:Y,END_SAME_AS_BEGIN:function(m){return Object.assign(m,{"on:begin":(x,U)=>{U.data._beginMatch=x[1]},"on:end":(x,U)=>{U.data._beginMatch!==x[1]&&U.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:P,MATCH_NOTHING_RE:I,METHOD_GUARD:ie,NUMBER_MODE:_,NUMBER_RE:D,PHRASAL_WORDS_MODE:S,QUOTE_STRING_MODE:E,REGEXP_MODE:ne,RE_STARTERS_RE:h,SHEBANG:v,TITLE_MODE:ce,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:re});function _e(m,x){m.input[m.index-1]==="."&&x.ignoreMatch()}function Ce(m,x){m.className!==void 0&&(m.scope=m.className,delete m.className)}function Ie(m,x){x&&m.beginKeywords&&(m.begin="\\b("+m.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",m.__beforeBegin=_e,m.keywords=m.keywords||m.beginKeywords,delete m.beginKeywords,m.relevance===void 0&&(m.relevance=0))}function Ue(m,x){Array.isArray(m.illegal)&&(m.illegal=N(...m.illegal))}function ht(m,x){if(m.match){if(m.begin||m.end)throw new Error("begin & end are not supported with match");m.begin=m.match,delete m.match}}function F(m,x){m.relevance===void 0&&(m.relevance=1)}const K=(m,x)=>{if(!m.beforeMatch)return;if(m.starts)throw new Error("beforeMatch cannot be used with starts");const U=Object.assign({},m);Object.keys(m).forEach(ee=>{delete m[ee]}),m.keywords=U.keywords,m.begin=y(U.beforeMatch,g(U.begin)),m.starts={relevance:0,contains:[Object.assign(U,{endsParent:!0})]},m.relevance=0,delete U.beforeMatch},le=["of","and","for","in","not","or","if","then","parent","list","value"],se="keyword";function Se(m,x,U=se){const ee=Object.create(null);return typeof m=="string"?ye(U,m.split(" ")):Array.isArray(m)?ye(U,m):Object.keys(m).forEach(function(we){Object.assign(ee,Se(m[we],x,we))}),ee;function ye(we,V){x&&(V=V.map(W=>W.toLowerCase())),V.forEach(function(W){const j=W.split("|");ee[j[0]]=[we,Me(j[0],j[1])]})}}function Me(m,x){return x?Number(x):Re(m)?0:1}function Re(m){return le.includes(m.toLowerCase())}const Je={},$e=m=>{console.error(m)},Be=(m,...x)=>{console.log(`WARN: ${m}`,...x)},ge=(m,x)=>{Je[`${m}/${x}`]||(console.log(`Deprecated as of ${m}. ${x}`),Je[`${m}/${x}`]=!0)},ut=new Error;function Lt(m,x,{key:U}){let ee=0;const ye=m[U],we={},V={};for(let W=1;W<=x.length;W++)V[W+ee]=ye[W],we[W+ee]=!0,ee+=M(x[W-1]);m[U]=V,m[U]._emit=we,m[U]._multi=!0}function It(m){if(Array.isArray(m.begin)){if(m.skip||m.excludeBegin||m.returnBegin)throw $e("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ut;if(typeof m.beginScope!="object"||m.beginScope===null)throw $e("beginScope must be object"),ut;Lt(m,m.begin,{key:"beginScope"}),m.begin=R(m.begin,{joinWith:""})}}function bt(m){if(Array.isArray(m.end)){if(m.skip||m.excludeEnd||m.returnEnd)throw $e("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ut;if(typeof m.endScope!="object"||m.endScope===null)throw $e("endScope must be object"),ut;Lt(m,m.end,{key:"endScope"}),m.end=R(m.end,{joinWith:""})}}function rn(m){m.scope&&typeof m.scope=="object"&&m.scope!==null&&(m.beginScope=m.scope,delete m.scope)}function Dt(m){rn(m),typeof m.beginScope=="string"&&(m.beginScope={_wrap:m.beginScope}),typeof m.endScope=="string"&&(m.endScope={_wrap:m.endScope}),It(m),bt(m)}function an(m){function x(V,W){return new RegExp(u(V),"m"+(m.case_insensitive?"i":"")+(m.unicodeRegex?"u":"")+(W?"g":""))}class U{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(W,j){j.position=this.position++,this.matchIndexes[this.matchAt]=j,this.regexes.push([j,W]),this.matchAt+=M(W)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const W=this.regexes.map(j=>j[1]);this.matcherRe=x(R(W,{joinWith:"|"}),!0),this.lastIndex=0}exec(W){this.matcherRe.lastIndex=this.lastIndex;const j=this.matcherRe.exec(W);if(!j)return null;const xe=j.findIndex((_t,ln)=>ln>0&&_t!==void 0),ke=this.matchIndexes[xe];return j.splice(0,xe),Object.assign(j,ke)}}class ee{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(W){if(this.multiRegexes[W])return this.multiRegexes[W];const j=new U;return this.rules.slice(W).forEach(([xe,ke])=>j.addRule(xe,ke)),j.compile(),this.multiRegexes[W]=j,j}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(W,j){this.rules.push([W,j]),j.type==="begin"&&this.count++}exec(W){const j=this.getMatcher(this.regexIndex);j.lastIndex=this.lastIndex;let xe=j.exec(W);if(this.resumingScanAtSamePosition()&&!(xe&&xe.index===this.lastIndex)){const ke=this.getMatcher(0);ke.lastIndex=this.lastIndex+1,xe=ke.exec(W)}return xe&&(this.regexIndex+=xe.position+1,this.regexIndex===this.count&&this.considerAll()),xe}}function ye(V){const W=new ee;return V.contains.forEach(j=>W.addRule(j.begin,{rule:j,type:"begin"})),V.terminatorEnd&&W.addRule(V.terminatorEnd,{type:"end"}),V.illegal&&W.addRule(V.illegal,{type:"illegal"}),W}function we(V,W){const j=V;if(V.isCompiled)return j;[Ce,ht,Dt,K].forEach(ke=>ke(V,W)),m.compilerExtensions.forEach(ke=>ke(V,W)),V.__beforeBegin=null,[Ie,Ue,F].forEach(ke=>ke(V,W)),V.isCompiled=!0;let xe=null;return typeof V.keywords=="object"&&V.keywords.$pattern&&(V.keywords=Object.assign({},V.keywords),xe=V.keywords.$pattern,delete V.keywords.$pattern),xe=xe||/\w+/,V.keywords&&(V.keywords=Se(V.keywords,m.case_insensitive)),j.keywordPatternRe=x(xe,!0),W&&(V.begin||(V.begin=/\B|\b/),j.beginRe=x(j.begin),!V.end&&!V.endsWithParent&&(V.end=/\B|\b/),V.end&&(j.endRe=x(j.end)),j.terminatorEnd=u(j.end)||"",V.endsWithParent&&W.terminatorEnd&&(j.terminatorEnd+=(V.end?"|":"")+W.terminatorEnd)),V.illegal&&(j.illegalRe=x(V.illegal)),V.contains||(V.contains=[]),V.contains=[].concat(...V.contains.map(function(ke){return sn(ke==="self"?V:ke)})),V.contains.forEach(function(ke){we(ke,j)}),V.starts&&we(V.starts,W),j.matcher=ye(j),j}if(m.compilerExtensions||(m.compilerExtensions=[]),m.contains&&m.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return m.classNameAliases=r(m.classNameAliases||{}),we(m)}function Bt(m){return m?m.endsWithParent||Bt(m.starts):!1}function sn(m){return m.variants&&!m.cachedVariants&&(m.cachedVariants=m.variants.map(function(x){return r(m,{variants:null},x)})),m.cachedVariants?m.cachedVariants:Bt(m)?r(m,{starts:m.starts?r(m.starts):null}):Object.isFrozen(m)?r(m):m}var on="11.11.1";class cn extends Error{constructor(x,U){super(x),this.name="HTMLInjectionError",this.html=U}}const Et=t,Pt=r,pe=Symbol("nomatch"),pt=7,je=function(m){const x=Object.create(null),U=Object.create(null),ee=[];let ye=!0;const we="Could not find the language '{}', did you forget to load/include a language module?",V={disableAutodetect:!0,name:"Plain text",contains:[]};let W={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:l};function j(O){return W.noHighlightRe.test(O)}function xe(O){let X=O.className+" ";X+=O.parentNode?O.parentNode.className:"";const oe=W.languageDetectRe.exec(X);if(oe){const fe=tt(oe[1]);return fe||(Be(we.replace("{}",oe[1])),Be("Falling back to no-highlight mode for this block.",O)),fe?oe[1]:"no-highlight"}return X.split(/\s+/).find(fe=>j(fe)||tt(fe))}function ke(O,X,oe){let fe="",Te="";typeof X=="object"?(fe=O,oe=X.ignoreIllegals,Te=X.language):(ge("10.7.0","highlight(lang, code, ...args) has been deprecated."),ge("10.7.0",`Please use highlight(code, options) instead.
|
package/dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="apple-mobile-web-app-title" content="pi" />
|
|
11
11
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
12
12
|
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-Hd0Z4pEO.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-BNqFbA4l.css">
|
|
15
15
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
16
16
|
<body>
|
package/dist/sw.js
CHANGED
|
@@ -1,128 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright 2018 Google Inc. All Rights Reserved.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
8
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
-
* See the License for the specific language governing permissions and
|
|
11
|
-
* limitations under the License.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// If the loader is already loaded, just stop.
|
|
15
|
-
if (!self.define) {
|
|
16
|
-
let registry = {};
|
|
17
|
-
|
|
18
|
-
// Used for `eval` and `importScripts` where we can't get script URL by other means.
|
|
19
|
-
// In both cases, it's safe to use a global var because those functions are synchronous.
|
|
20
|
-
let nextDefineUri;
|
|
21
|
-
|
|
22
|
-
const singleRequire = (uri, parentUri) => {
|
|
23
|
-
uri = new URL(uri + ".js", parentUri).href;
|
|
24
|
-
return registry[uri] || (
|
|
25
|
-
|
|
26
|
-
new Promise(resolve => {
|
|
27
|
-
if ("document" in self) {
|
|
28
|
-
const script = document.createElement("script");
|
|
29
|
-
script.src = uri;
|
|
30
|
-
script.onload = resolve;
|
|
31
|
-
document.head.appendChild(script);
|
|
32
|
-
} else {
|
|
33
|
-
nextDefineUri = uri;
|
|
34
|
-
importScripts(uri);
|
|
35
|
-
resolve();
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
.then(() => {
|
|
40
|
-
let promise = registry[uri];
|
|
41
|
-
if (!promise) {
|
|
42
|
-
throw new Error(`Module ${uri} didn’t register its module`);
|
|
43
|
-
}
|
|
44
|
-
return promise;
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
self.define = (depsNames, factory) => {
|
|
50
|
-
const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
|
|
51
|
-
if (registry[uri]) {
|
|
52
|
-
// Module is already loading or loaded.
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
let exports = {};
|
|
56
|
-
const require = depUri => singleRequire(depUri, uri);
|
|
57
|
-
const specialDeps = {
|
|
58
|
-
module: { uri },
|
|
59
|
-
exports,
|
|
60
|
-
require
|
|
61
|
-
};
|
|
62
|
-
registry[uri] = Promise.all(depsNames.map(
|
|
63
|
-
depName => specialDeps[depName] || require(depName)
|
|
64
|
-
)).then(deps => {
|
|
65
|
-
factory(...deps);
|
|
66
|
-
return exports;
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
define(['./workbox-a24bf94b'], (function (workbox) { 'use strict';
|
|
71
|
-
|
|
72
|
-
self.skipWaiting();
|
|
73
|
-
workbox.clientsClaim();
|
|
74
|
-
/**
|
|
75
|
-
* The precacheAndRoute() method efficiently caches and responds to
|
|
76
|
-
* requests for URLs in the manifest.
|
|
77
|
-
* See https://goo.gl/S9QRab
|
|
78
|
-
*/
|
|
79
|
-
workbox.precacheAndRoute([{
|
|
80
|
-
"url": "registerSW.js",
|
|
81
|
-
"revision": "1872c500de691dce40960bb85481de07"
|
|
82
|
-
}, {
|
|
83
|
-
"url": "pwa-512x512.png",
|
|
84
|
-
"revision": "a3b6e257d5f88d21847670b8a945414d"
|
|
85
|
-
}, {
|
|
86
|
-
"url": "pwa-192x192.png",
|
|
87
|
-
"revision": "f31b8a5e9d558a2705b4aa105bf0746d"
|
|
88
|
-
}, {
|
|
89
|
-
"url": "index.html",
|
|
90
|
-
"revision": "9d33046e5c8053fa498e1119ba755d65"
|
|
91
|
-
}, {
|
|
92
|
-
"url": "icon.svg",
|
|
93
|
-
"revision": "6d0b7529947ef4fc567cf4d4753c7f28"
|
|
94
|
-
}, {
|
|
95
|
-
"url": "apple-touch-icon.png",
|
|
96
|
-
"revision": "e7f5e0d5552e5ba16aceb226e2eb7f65"
|
|
97
|
-
}, {
|
|
98
|
-
"url": "assets/index-RfnHuF-b.js",
|
|
99
|
-
"revision": null
|
|
100
|
-
}, {
|
|
101
|
-
"url": "assets/index-BNqFbA4l.css",
|
|
102
|
-
"revision": null
|
|
103
|
-
}, {
|
|
104
|
-
"url": "apple-touch-icon.png",
|
|
105
|
-
"revision": "e7f5e0d5552e5ba16aceb226e2eb7f65"
|
|
106
|
-
}, {
|
|
107
|
-
"url": "icon.svg",
|
|
108
|
-
"revision": "6d0b7529947ef4fc567cf4d4753c7f28"
|
|
109
|
-
}, {
|
|
110
|
-
"url": "pwa-192x192.png",
|
|
111
|
-
"revision": "f31b8a5e9d558a2705b4aa105bf0746d"
|
|
112
|
-
}, {
|
|
113
|
-
"url": "pwa-512x512.png",
|
|
114
|
-
"revision": "a3b6e257d5f88d21847670b8a945414d"
|
|
115
|
-
}, {
|
|
116
|
-
"url": "manifest.webmanifest",
|
|
117
|
-
"revision": "7b2c8583d476b0aca4076855a98fac4b"
|
|
118
|
-
}], {});
|
|
119
|
-
workbox.cleanupOutdatedCaches();
|
|
120
|
-
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("/index.html")));
|
|
121
|
-
workbox.registerRoute(({
|
|
122
|
-
request
|
|
123
|
-
}) => request.mode === "navigate", new workbox.NetworkFirst({
|
|
124
|
-
"cacheName": "pages",
|
|
125
|
-
plugins: []
|
|
126
|
-
}), 'GET');
|
|
127
|
-
|
|
128
|
-
}));
|
|
1
|
+
if(!self.define){let e,i={};const n=(n,s)=>(n=new URL(n+".js",s).href,i[n]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=i,document.head.appendChild(e)}else e=n,importScripts(n),i()}).then(()=>{let e=i[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(s,r)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(i[o])return;let c={};const d=e=>n(e,o),a={module:{uri:o},exports:c,require:d};i[o]=Promise.all(s.map(e=>a[e]||d(e))).then(e=>(r(...e),c))}}define(["./workbox-ee9d8b34"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"pwa-512x512.png",revision:"a3b6e257d5f88d21847670b8a945414d"},{url:"pwa-192x192.png",revision:"f31b8a5e9d558a2705b4aa105bf0746d"},{url:"index.html",revision:"cf55dd7b04c9f617e9b7c1e43f7fe7a6"},{url:"icon.svg",revision:"6d0b7529947ef4fc567cf4d4753c7f28"},{url:"apple-touch-icon.png",revision:"e7f5e0d5552e5ba16aceb226e2eb7f65"},{url:"assets/index-Hd0Z4pEO.js",revision:null},{url:"assets/index-BNqFbA4l.css",revision:null},{url:"apple-touch-icon.png",revision:"e7f5e0d5552e5ba16aceb226e2eb7f65"},{url:"icon.svg",revision:"6d0b7529947ef4fc567cf4d4753c7f28"},{url:"pwa-192x192.png",revision:"f31b8a5e9d558a2705b4aa105bf0746d"},{url:"pwa-512x512.png",revision:"a3b6e257d5f88d21847670b8a945414d"},{url:"manifest.webmanifest",revision:"7b2c8583d476b0aca4076855a98fac4b"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html"))),e.registerRoute(({request:e})=>"navigate"===e.mode,new e.NetworkFirst({cacheName:"pages",plugins:[]}),"GET")});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
define(["exports"],function(t){"use strict";try{self["workbox:core:7.4.0"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:7.4.0"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class i{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class r extends i{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=r&&r.handler;const a=t.method;if(!o&&this.i.has(a)&&(o=this.i.get(a)),!o)return;let c;try{c=o.handle({url:s,request:t,event:e,params:i})}catch(t){c=Promise.reject(t)}const h=r&&r.catchHandler;return c instanceof Promise&&(this.o||h)&&(c=c.catch(async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:i})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n})),c}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const i=this.t.get(s.method)||[];for(const r of i){let i;const o=r.match({url:t,sameOrigin:e,request:s,event:n});if(o)return i=o,(Array.isArray(i)&&0===i.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(i=void 0),{route:r,params:i}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let a;const c=()=>(a||(a=new o,a.addFetchListener(),a.addCacheListener()),a);function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new i(({url:t})=>t.href===s.href,e,n)}else if(t instanceof RegExp)o=new r(t,e,n);else if("function"==typeof t)o=new i(t,e,n);else{if(!(t instanceof i))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return c().registerRoute(o),o}try{self["workbox:strategies:7.4.0"]&&_()}catch(t){}const u={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null},l={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},f=t=>[l.prefix,t,l.suffix].filter(t=>t&&t.length>0).join("-"),w=t=>t||f(l.precache),d=t=>t||f(l.runtime);function p(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class y{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}const g=new Set;function m(t){return"string"==typeof t?new Request(t):t}class R{constructor(t,e){this.h={},Object.assign(this,e),this.event=e.event,this.u=t,this.l=new y,this.p=[],this.m=[...t.plugins],this.R=new Map;for(const t of this.m)this.R.set(t,{});this.event.waitUntil(this.l.promise)}async fetch(t){const{event:e}=this;let n=m(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const i=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const r=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.u.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:r,response:t});return t}catch(t){throw i&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:i.clone(),request:r.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=m(t);let s;const{cacheName:n,matchOptions:i}=this.u,r=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},i),{cacheName:n});s=await caches.match(r,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:i,cachedResponse:s,request:r,event:this.event})||void 0;return s}async cachePut(t,e){const n=m(t);var i;await(i=0,new Promise(t=>setTimeout(t,i)));const r=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(o=r.url,new URL(String(o),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var o;const a=await this.v(e);if(!a)return!1;const{cacheName:c,matchOptions:h}=this.u,u=await self.caches.open(c),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const i=p(e.url,s);if(e.url===i)return t.match(e,n);const r=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,r);for(const e of o)if(i===p(e.url,s))return t.match(e,n)}(u,r.clone(),["__WB_REVISION__"],h):null;try{await u.put(r,l?a.clone():a)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of g)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:c,oldResponse:f,newResponse:a.clone(),request:r,event:this.event});return!0}async getCacheKey(t,e){const s=`${t.url} | ${e}`;if(!this.h[s]){let n=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))n=m(await t({mode:e,request:n,event:this.event,params:this.params}));this.h[s]=n}return this.h[s]}hasCallback(t){for(const e of this.u.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.u.plugins)if("function"==typeof e[t]){const s=this.R.get(e),n=n=>{const i=Object.assign(Object.assign({},n),{state:s});return e[t](i)};yield n}}waitUntil(t){return this.p.push(t),t}async doneWaiting(){for(;this.p.length;){const t=this.p.splice(0),e=(await Promise.allSettled(t)).find(t=>"rejected"===t.status);if(e)throw e.reason}}destroy(){this.l.resolve(null)}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class v{constructor(t={}){this.cacheName=d(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,i=new R(this,{event:e,request:s,params:n}),r=this.q(i,s,e);return[r,this.U(r,i,s,e)]}async q(t,e,n){let i;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(i=await this.L(e,t),!i||"error"===i.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const r of t.iterateCallbacks("handlerDidError"))if(i=await r({error:s,event:n,request:e}),i)break;if(!i)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))i=await s({event:n,request:e,response:i});return i}async U(t,e,s,n){let i,r;try{i=await t}catch(r){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:i}),await e.doneWaiting()}catch(t){t instanceof Error&&(r=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:i,error:r}),e.destroy(),r)throw r}}function q(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:7.4.0"]&&_()}catch(t){}function U(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const i=new URL(n,location.href),r=new URL(n,location.href);return i.searchParams.set("__WB_REVISION__",e),{cacheKey:i.href,url:r.href}}class L{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class b{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=(null==e?void 0:e.cacheKey)||this._.getCacheKeyForURL(t.url);return s?new Request(s,{headers:t.headers}):t},this._=t}}let E,C;async function x(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const i=t.clone(),r={headers:new Headers(i.headers),status:i.status,statusText:i.statusText},o=function(){if(void 0===E){const t=new Response("");if("body"in t)try{new Response(t.body),E=!0}catch(t){E=!1}E=!1}return E}()?i.body:await i.blob();return new Response(o,r)}class O extends v{constructor(t={}){t.cacheName=w(t.cacheName),super(t),this.C=!1!==t.fallbackToNetwork,this.plugins.push(O.copyRedirectedCacheableResponsesPlugin)}async L(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.O(t,e):await this.N(t,e))}async N(t,e){let n;const i=e.params||{};if(!this.C)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});{const s=i.integrity,r=t.integrity,o=!r||r===s;n=await e.fetch(new Request(t,{integrity:"no-cors"!==t.mode?r||s:void 0})),s&&o&&"no-cors"!==t.mode&&(this.P(),await e.cachePut(t,n.clone()))}return n}async O(t,e){this.P();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}P(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==O.copyRedirectedCacheableResponsesPlugin&&(n===O.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(O.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}O.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},O.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await x(t):t};class N{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.T=new Map,this.W=new Map,this.k=new Map,this.u=new O({cacheName:w(t),plugins:[...e,new b({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.u}precache(t){this.addToCacheList(t),this.j||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.j=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:i}=U(n),r="string"!=typeof n&&n.revision?"reload":"default";if(this.T.has(i)&&this.T.get(i)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.T.get(i),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.k.has(t)&&this.k.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:i});this.k.set(t,n.integrity)}if(this.T.set(i,t),this.W.set(i,r),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return q(t,async()=>{const e=new L;this.strategy.plugins.push(e);for(const[e,s]of this.T){const n=this.k.get(s),i=this.W.get(e),r=new Request(e,{integrity:n,cache:i,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:r,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}})}activate(t){return q(t,async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.T.values()),n=[];for(const i of e)s.has(i.url)||(await t.delete(i),n.push(i.url));return{deletedURLs:n}})}getURLsToCacheKeys(){return this.T}getCachedURLs(){return[...this.T.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.T.get(e.href)}getIntegrityForCacheKey(t){return this.k.get(t)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}const P=()=>(C||(C=new N),C);class T extends i{constructor(t,e){super(({request:s})=>{const n=t.getURLsToCacheKeys();for(const i of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:i}={}){const r=new URL(t,location.href);r.hash="",yield r.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some(t=>t.test(s))&&t.searchParams.delete(s);return t}(r,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(i){const t=i({url:r});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(i);if(e){return{cacheKey:e,integrity:t.getIntegrityForCacheKey(e)}}}},t.strategy)}}t.NavigationRoute=class extends i{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.K(t),t),this.M=e,this.S=s}K({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.S)if(t.test(s))return!1;return!!this.M.some(t=>t.test(s))}},t.NetworkFirst=class extends v{constructor(t={}){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(u),this.D=t.networkTimeoutSeconds||0}async L(t,e){const n=[],i=[];let r;if(this.D){const{id:s,promise:o}=this.I({request:t,logs:n,handler:e});r=s,i.push(o)}const o=this.F({timeoutId:r,request:t,logs:n,handler:e});i.push(o);const a=await e.waitUntil((async()=>await e.waitUntil(Promise.race(i))||await o)());if(!a)throw new s("no-response",{url:t.url});return a}I({request:t,logs:e,handler:s}){let n;return{promise:new Promise(e=>{n=setTimeout(async()=>{e(await s.cacheMatch(t))},1e3*this.D)}),id:n}}async F({timeoutId:t,request:e,logs:s,handler:n}){let i,r;try{r=await n.fetchAndCachePut(e)}catch(t){t instanceof Error&&(i=t)}return t&&clearTimeout(t),!i&&r||(r=await n.cacheMatch(e)),r}},t.cleanupOutdatedCaches=function(){self.addEventListener("activate",t=>{const e=w();t.waitUntil((async(t,e="-precache-")=>{const s=(await self.caches.keys()).filter(s=>s.includes(e)&&s.includes(self.registration.scope)&&s!==t);return await Promise.all(s.map(t=>self.caches.delete(t))),s})(e).then(t=>{}))})},t.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},t.createHandlerBoundToURL=function(t){return P().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){P().precache(t)}(t),function(t){const e=P();h(new T(e,t))}(e)},t.registerRoute=h});
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ashwin-pc/pi-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Local/Tailscale web UI for pi coding agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ashwin-pc/pi-web"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"bin": {
|
|
8
|
-
"pi-web": "
|
|
12
|
+
"pi-web": "bin/pi-web.js"
|
|
9
13
|
},
|
|
10
14
|
"files": [
|
|
11
15
|
".pi/extensions/",
|