@puddle-code/cli 0.1.6 → 0.1.7
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/CHANGELOG.md +5 -15
- package/dist/index.js +4 -2
- package/dist/public/assets/{Dashboard-CasYFJLz.js → Dashboard-CK6pd6yc.js} +1 -1
- package/dist/public/assets/{EditorTabClose-BmukyEIn.js → EditorTabClose-NXE25Hkk.js} +1 -1
- package/dist/public/assets/{LazyTerminal-Clf8nR-P.js → LazyTerminal-YJYBkGGG.js} +2 -2
- package/dist/public/assets/{ModelRefcount-CFzMkqca.js → ModelRefcount-qiBWxl8V.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-CSwoYrQo.js → PaneEditorBody-CSxRXAbs.js} +1 -1
- package/dist/public/assets/{SettingsDialog-CUmDlrJL.js → SettingsDialog-DA4x9Y9W.js} +1 -1
- package/dist/public/assets/{Terminal-BoN07_WS.js → Terminal-UR8urwx4.js} +1 -1
- package/dist/public/assets/Workspace-DbEp1PKp.js +8 -0
- package/dist/public/assets/{buffer-store-BD_4UWB2.js → buffer-store-C_9Ib5qf.js} +2 -2
- package/dist/public/assets/{context-menu-BlnSnVhp.js → context-menu-Ca0Uv2BE.js} +1 -1
- package/dist/public/assets/{cssMode-B6FSXRRI.js → cssMode-gGXxIWCL.js} +1 -1
- package/dist/public/assets/{drafts-BsCav0PD.js → drafts-DJULaAJ0.js} +1 -1
- package/dist/public/assets/{file-links-dIrC7Vyb.js → file-links-CcWnhnkT.js} +1 -1
- package/dist/public/assets/{htmlMode-Cu5jmkMy.js → htmlMode-C2tT4YRo.js} +1 -1
- package/dist/public/assets/{index-DCwTtEMc.css → index-C_32FmnW.css} +1 -1
- package/dist/public/assets/{index-B6XVjgfK.js → index-fAfi8H1Y.js} +3 -3
- package/dist/public/assets/{jsonMode-D_D00iD1.js → jsonMode-BphVURBo.js} +1 -1
- package/dist/public/assets/{media-refresh-store-BcMhaDMx.js → media-refresh-store-CDq91uhk.js} +1 -1
- package/dist/public/assets/{session-seed-D12F-WVU.js → session-seed-D2FbVBft.js} +1 -1
- package/dist/public/assets/{tsMode-Dt9dvNT6.js → tsMode-B6jh6JrU.js} +1 -1
- package/dist/public/assets/{use-find-controls-CkVGrs9e.js → use-find-controls-B_INkoQ4.js} +1 -1
- package/dist/public/index.html +3 -3
- package/package.json +1 -1
- package/dist/public/assets/Workspace-JGzqUYNn.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -7,21 +7,11 @@ Past releases: see docs/changelogs/.
|
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
|
|
10
|
-
## [0.1.
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
|
|
14
|
-
- Reveal the associated rooted source-editor line when a linked or locked Markdown/HTML preview is Ctrl/Command-clicked.
|
|
15
|
-
- Compile LaTeX sources on demand or eagerly on daemon-observed disk changes when the connected host has a supported local toolchain, keeping every generated file under Puddle’s data directory and opening the PDF as a persistent, globally deduplicated file tab.
|
|
16
|
-
- Navigate from Command/Ctrl-clicked generated PDF positions to the corresponding TeX source through a lazy PDF.js viewer and inverse SyncTeX.
|
|
17
|
-
- Expose a provider-neutral compilation protocol and daemon scheduler so future compiled file types can reuse capability discovery, modes, watchers, status, and artefact handling.
|
|
18
|
-
- Show failed compiler output in expandable notifications and mark normalised source diagnostics in Monaco.
|
|
19
|
-
|
|
20
|
-
### Changed
|
|
21
|
-
|
|
22
|
-
- Align locked Markdown and HTML previews by parser-derived source lines across wrapping, media, and reflow, with proportional progress as a safe fallback.
|
|
23
|
-
- Save the selected source and mounted provider-input buffers before compilation, and refresh eager PDF output without stealing editor focus.
|
|
10
|
+
## [0.1.7] — 2026-08-28
|
|
24
11
|
|
|
25
12
|
### Fixed
|
|
26
13
|
|
|
27
|
-
-
|
|
14
|
+
- Track Tectonic's escaped and continued dependency rules so eager LaTeX builds react to included source and bibliography changes.
|
|
15
|
+
- Keep tab drags live over embedded previews so generated LaTeX PDF tabs can move or split into any pane.
|
|
16
|
+
- Keep LaTeX build intermediates and generated previews in each source root's local `.puddle/latex` directory rather than the daemon's global state directory.
|
|
17
|
+
- Serve bundled `.mjs` assets as JavaScript so generated LaTeX PDFs load their lazy PDF.js worker.
|
package/dist/index.js
CHANGED
|
@@ -19971,7 +19971,7 @@ import { readFileSync } from "node:fs";
|
|
|
19971
19971
|
import { dirname, join as join2 } from "node:path";
|
|
19972
19972
|
import { fileURLToPath } from "node:url";
|
|
19973
19973
|
function cliVersion() {
|
|
19974
|
-
if (true) return "0.1.
|
|
19974
|
+
if (true) return "0.1.7";
|
|
19975
19975
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
19976
19976
|
for (const candidate of [
|
|
19977
19977
|
join2(here, "..", "..", "package.json"),
|
|
@@ -20336,7 +20336,8 @@ var RELEASE_PROTOCOLS = {
|
|
|
20336
20336
|
"0.1.3": { major: 17, minor: 0 },
|
|
20337
20337
|
"0.1.4": { major: 17, minor: 0 },
|
|
20338
20338
|
"0.1.5": { major: 17, minor: 0 },
|
|
20339
|
-
"0.1.6": { major: 17, minor: 2 }
|
|
20339
|
+
"0.1.6": { major: 17, minor: 2 },
|
|
20340
|
+
"0.1.7": { major: 17, minor: 2 }
|
|
20340
20341
|
};
|
|
20341
20342
|
function validProtocol(value) {
|
|
20342
20343
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -21100,6 +21101,7 @@ import { extname, join as join6, normalize, resolve as resolve3, sep } from "nod
|
|
|
21100
21101
|
var MIME = {
|
|
21101
21102
|
".html": "text/html; charset=utf-8",
|
|
21102
21103
|
".js": "text/javascript; charset=utf-8",
|
|
21104
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
21103
21105
|
".css": "text/css; charset=utf-8",
|
|
21104
21106
|
".json": "application/json",
|
|
21105
21107
|
".svg": "image/svg+xml",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r}from"./api-IpGGhtRp.js";import{a as i,h as a,i as o,n as s,o as c,t as l}from"./dialog-CFa2VFV0.js";import{a as u,c as d,l as f,o as p,s as m,t as h}from"./LazyTerminal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r}from"./api-IpGGhtRp.js";import{a as i,h as a,i as o,n as s,o as c,t as l}from"./dialog-CFa2VFV0.js";import{a as u,c as d,l as f,o as p,s as m,t as h}from"./LazyTerminal-YJYBkGGG.js";import{r as g}from"./x-cVj9N3GX.js";import{A as _,M as v,c as y,j as b,k as x,n as S,r as C,t as w}from"./context-menu-Ca0Uv2BE.js";import{r as T}from"./dist-DEu2RD64.js";import{$t as E,Bt as D,Dn as O,En as k,Hn as A,Ln as j,Mn as M,Nt as N,ft as P,kn as F,mt as I,or as L,pt as R,qt as z,ut as B}from"./index-fAfi8H1Y.js";var V=e(t(),1),H=n(),U=!1;function W(){let[e,t]=(0,V.useState)(U),[n,i]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(!e)return;let t=!1;return I.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{U=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&I.killShell(r,n),a()):(U=!0,t(!0))},onExit:a}}function G({term:e,onExit:t}){return(0,H.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,H.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,H.jsx)(h,{stream:`home`,term:e,onExit:t})})})}var K=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function q({projectId:e}){let t=A(e),n=(0,V.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),K.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function J({icon:e,label:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,H.jsx)(e,{className:`size-4`})})}function Y({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:m,onDragEnd:h,onDragOver:_}){let x=O(),[T,E]=(0,V.useState)(!1),[D,k]=(0,V.useState)(e.name),[A,j]=(0,V.useState)(R(e)),M=t=>x.mutate({id:e.id,archived:t},{onError:e=>u(e)}),N=()=>{k(e.name),j(R(e)),E(!0)},F=()=>{let t=D.trim(),n=P(A);if(!t){E(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==R(e)?{abbrev:n}:{}};if(Object.keys(r).length===0){E(!1);return}x.mutate({id:e.id,...r},{onSuccess:()=>E(!1),onError:e=>u(e)})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(w,{children:[(0,H.jsx)(y,{asChild:!0,children:(0,H.jsxs)(`div`,{draggable:n,onDragStart:m,onDragEnd:h,onDragOver:_,className:g(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,H.jsxs)(L,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,H.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,H.jsx)(`div`,{className:`mt-3`,children:(0,H.jsx)(q,{projectId:e.id})})]}),(0,H.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,H.jsx)(J,{icon:v,label:`Reopen project`,onClick:()=>M(!1)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{icon:p,label:`Edit project`,onClick:N}),(0,H.jsx)(J,{icon:b,label:`Archive project`,onClick:()=>M(!0)})]})})]})}),(0,H.jsx)(S,{children:e.archived?(0,H.jsxs)(C,{onSelect:()=>M(!1),children:[(0,H.jsx)(v,{}),` Reopen`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(C,{onSelect:N,children:[(0,H.jsx)(p,{}),` Edit`]}),(0,H.jsxs)(C,{onSelect:()=>M(!0),children:[(0,H.jsx)(b,{}),` Archive`]})]})})]}),(0,H.jsx)(l,{open:T,onOpenChange:E,children:(0,H.jsxs)(s,{children:[(0,H.jsx)(i,{children:(0,H.jsx)(c,{children:`Edit project`})}),(0,H.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),F()},children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(d,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,H.jsx)(f,{id:`project-name-${e.id}`,value:D,onChange:e=>k(e.target.value),autoFocus:!0})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(d,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,H.jsx)(f,{id:`project-abbrev-${e.id}`,maxLength:5,value:A,onChange:e=>j(P(e.target.value)),className:`w-24 uppercase`}),(0,H.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(d,{className:`text-fg-muted`,children:`Path`}),(0,H.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,H.jsxs)(o,{children:[(0,H.jsx)(a,{type:`button`,variant:`ghost`,onClick:()=>E(!1),children:`Cancel`}),(0,H.jsx)(a,{type:`submit`,disabled:!D.trim()||x.isPending,children:`Save`})]})]})]})})]})}function X({icon:e,label:t,hint:n,onClick:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,H.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,H.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function Z(){let e=D(),t=M(e??void 0),n=j(),r=F(e??void 0),i=k(e??``),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=W(),f=N(`palette.toggle`),p=e=>n.data?.find(t=>t.id===e)?.path,h=t.data??[],v=r.data?.projectOrder??[],y=x(h.filter(e=>!e.archived),v),S=h.filter(e=>e.archived),C=(e,t)=>{e!==t&&i.mutate({projectOrder:_(y.map(e=>e.id),e,t)})};return(0,H.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[h.length===0&&(0,H.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,H.jsx)(m,{className:`size-8 text-fg-muted`}),(0,H.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,f,`.`]})]}),(0,H.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[y.map(e=>(0,H.jsx)(Y,{project:e,repoPath:p(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&C(s,e.id)}},e.id)),(0,H.jsx)(X,{icon:E,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,H.jsx)(X,{icon:z,label:d.open?`Close terminal`:`Open terminal`,hint:d.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:d.toggle})]}),S.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,H.jsx)(T,{className:g(`size-3 transition-transform`,l&&`rotate-90`)}),(0,H.jsx)(b,{className:`size-3`}),(0,H.jsx)(`span`,{children:`Archived`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:S.length})]}),l&&(0,H.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:S.map(e=>(0,H.jsx)(Y,{project:e,repoPath:p(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),d.open&&(0,H.jsx)(G,{term:d.term,onExit:d.onExit}),e!==null&&(0,H.jsx)(B,{profileId:e,open:a,onOpenChange:o})]})}export{Z as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,h as i,i as a,n as o,o as s,r as c,t as l}from"./dialog-CFa2VFV0.js";import{n as u,t as d}from"./x-cVj9N3GX.js";import{i as f,t as p,u as m}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,h as i,i as a,n as o,o as s,r as c,t as l}from"./dialog-CFa2VFV0.js";import{n as u,t as d}from"./x-cVj9N3GX.js";import{i as f,t as p,u as m}from"./buffer-store-C_9Ib5qf.js";import{t as h}from"./drafts-DJULaAJ0.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=u(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=p(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>m(r,e),[r]),()=>f(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:u,label:f,onClose:p}){let m=b(e,t,u)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>m?x(!0):p();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${f}`,children:(0,y.jsx)(d,{className:`size-3`})}),(0,y.jsx)(l,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(s,{children:[`Discard changes to `,f,`?`]}),(0,y.jsx)(c,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(a,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{h(e,t,u),g(e,t,u),x(!1),p()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{T as a,t as o}from"./api-IpGGhtRp.js";import{C as s,D as c,S as l,b as u,k as d}from"./dialog-CFa2VFV0.js";import{n as f,r as p}from"./x-cVj9N3GX.js";var m=e(t(),1),h=[`top`,`right`,`bottom`,`left`],g=Math.min,_=Math.max,v=Math.round,y=Math.floor,b=e=>({x:e,y:e}),x={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function S(e,t,n){return _(e,g(t,n))}function C(e,t){return typeof e==`function`?e(t):e}function w(e){return e.split(`-`)[0]}function T(e){return e.split(`-`)[1]}function E(e){return e===`x`?`y`:`x`}function D(e){return e===`y`?`height`:`width`}function O(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function k(e){return E(O(e))}function A(e,t,n){n===void 0&&(n=!1);let r=T(e),i=k(e),a=D(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=z(o)),[o,z(o)]}function j(e){let t=z(e);return[M(e),t,M(t)]}function M(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var N=[`left`,`right`],P=[`right`,`left`],F=[`top`,`bottom`],I=[`bottom`,`top`];function L(e,t,n){switch(e){case`top`:case`bottom`:return n?t?P:N:t?N:P;case`left`:case`right`:return t?F:I;default:return[]}}function R(e,t,n,r){let i=T(e),a=L(w(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(M)))),a}function z(e){let t=w(e);return x[t]+e.slice(t.length)}function ee(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ne(e,t,n){let{reference:r,floating:i}=e,a=O(t),o=k(t),s=D(o),c=w(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=T(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function re(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=C(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ie=50,ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:re},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ne(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ie&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ne(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=C(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=k(i),m=D(p),h=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],w=f[p]-a.reference[p],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),O=E?E[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(E)))&&(O=s.floating[b]||a.floating[m]);let A=x/2-w/2,j=O/2-h[m]/2-1,M=g(d[v],j),N=g(d[y],j),P=O-h[m]-N,F=O/2-h[m]/2+A,I=S(M,F,P),L=!c.arrow&&T(i)!=null&&F!==I&&a.reference[m]/2-(F<M?M:N)-h[m]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=C(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=w(r),_=O(o),v=w(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[z(o)]:j(o)),x=p!==`none`;!d&&x&&b.push(...R(o,m,p,y));let S=[o,...b],T=await s.detectOverflow(t,h),E=[],D=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=A(r,a,y);E.push(T[e[0]],T[e[1]])}if(D=[...D,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==O(t))||D.every(e=>O(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=O(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return h.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=C(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=w(n),s=T(n),c=O(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=C(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=C(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=O(i),p=E(f),m=u[p],h=u[f],g=(e,t)=>S(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=C(e,t),u={x:n,y:r},d=O(i),f=E(d),p=u[f],m=u[d],h=C(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(w(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=C(e,t),c=await i.detectOverflow(t,s),l=w(n),u=T(n),d=O(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=g(p-c[m],v),x=g(f-c[h],y),S=t.middlewareData.shift,E=!S,D=b,k=x;S!=null&&S.enabled.x&&(k=y),S!=null&&S.enabled.y&&(D=v),E&&!u&&(d?k=f-2*_(c.left,c.right):D=p-2*_(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:D});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function V(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return _e()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return _e()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(V(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,Te;function Ee(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Oe()&&(K(t.backdropFilter)||K(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function De(e){let t=Y(e);for(;G(t)&&!q(t);){if(Ee(t))return t;if(Se(t))return null;t=Y(t)}return null}function Oe(){return Te??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Te}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function ke(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||U(e);return ye(t)?t.host:t}function Ae(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&be(t)?t:Ae(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ae(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=je(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Me(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=v(n)!==a||v(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ne(e){return W(e)?e:e.contextElement}function Z(e){let t=Ne(e);if(!G(t))return b(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Me(t),o=(a?v(n.width):n.width)/r,s=(a?v(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Pe=b(0);function Fe(e){let t=H(e);return!Oe()||!t.visualViewport?Pe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ne(e),o=b(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Ie(a,n,r)?Fe(a):b(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=je(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=je(n)}}return B({width:u,height:d,x:c,y:l})}function Le(e,t){let n=ke(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Re(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Le(e,n),y:n.top+t.scrollTop}}function ze(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=b(1),u=b(0),d=G(r);if((d||!a)&&((V(r)!==`body`||be(o))&&(c=ke(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Re(o,c):b(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Be(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ve(e){let t=ke(e),n=e.ownerDocument.body,r=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Le(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=_(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var He=25;function Ue(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Oe()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Le(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=He&&(s-=o)}return{width:s,height:c,x:l,y:u}}function We(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ge(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ue(e,n,t);else if(t===`document`)r=Ve(U(e));else if(W(t))r=We(t,n);else{let n=Fe(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function Ke(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Ee(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:Ke(t,this._c):[].concat(n),r],o=Ge(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ge(t,a[e],i);s=_(n.top,s),c=g(n.right,c),l=g(n.bottom,l),u=_(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Je(e){let{width:t,height:n}=Me(e);return{width:t,height:n}}function Ye(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=b(0);if((r||!a)&&((V(t)!==`body`||be(i))&&(s=ke(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Le(i));let l=i&&!r&&!a?Re(i,s):b(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Xe(e){return J(e).position===`static`}function Ze(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Qe(e,t){let n=H(e);if(Se(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Xe(t))return t;t=Y(t)}return n}let r=Ze(e,t);for(;r&&xe(r)&&Xe(r);)r=Ze(r,t);return r&&q(r)&&Xe(r)&&!Ee(r)?n:r||De(e)||n}var $e=async function(e){let t=this.getOffsetParent||Qe,n=this.getDimensions,r=await n(e.floating);return{reference:Ye(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function et(e){return J(e).direction===`rtl`}var tt={convertOffsetParentRelativeRectToViewportRelativeRect:ze,getDocumentElement:U,getClippingRect:qe,getOffsetParent:Qe,getElementRects:$e,getClientRects:Be,getDimensions:Je,getScale:Z,isElement:W,isRTL:et};function nt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=y(d),h=y(a.clientWidth-(u+f)),v=y(a.clientHeight-(d+p)),b=y(u),x={rootMargin:-m+`px `+-h+`px `+-v+`px `+-b+`px`,threshold:_(0,g(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!nt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function it(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ne(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?rt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!nt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var at=pe,ot=me,st=se,ct=ge,lt=ue,ut=oe,dt=he,ft=(e,t,n)=>{let r=new Map,i=n??{},a={...tt,...i.platform,_c:r};return ae(e,t,{...i,platform:a})},pt=e(n(),1),mt=typeof document<`u`?m.useLayoutEffect:function(){};function ht(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ht(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ht(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function gt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _t(e,t){let n=gt(e);return Math.round(t*n)/n}function vt(e){let t=m.useRef(e);return mt(()=>{t.current=e}),t}function yt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);ht(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=vt(c),O=vt(i),k=vt(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),ft(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ht(T.current,t)&&(T.current=t,pt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);mt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);mt(()=>(j.current=!0,()=>{j.current=!1}),[]),mt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=_t(N.floating,u.x),r=_t(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...gt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var bt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ut({element:r.current,padding:i}).fn(n):r?ut({element:r,padding:i}).fn(n):{}}}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>({fn:dt(e).fn,options:[e,t]}),wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=lt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=bt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=r(),Ot=`Arrow`,kt=m.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});kt.displayName=Ot;var At=kt;function jt(e){let[t,n]=m.useState(void 0);return u(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Mt=`Popper`,[Nt,Pt]=c(Mt),[Ft,It]=Nt(Mt),Lt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,$.jsx)(Ft,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Lt.displayName=Mt;var Rt=`PopperAnchor`,zt=m.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=It(Rt,n),o=m.useRef(null),c=a.onAnchorChange,l=d(t,m.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let f=a.placementState&&Yt(a.placementState),p=f?.[0],h=f?.[1];return r?null:(0,$.jsx)(s.div,{"data-radix-popper-side":p,"data-radix-popper-align":h,...i,ref:l})});zt.displayName=Rt;var Bt=`PopperContent`,[Vt,Ht]=Nt(Bt),Ut=m.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:f=!0,collisionBoundary:p=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=It(Bt,n),[S,C]=m.useState(null),w=d(t,C),[T,E]=m.useState(null),D=jt(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(p)?p:[p],N=M.length>0,P={padding:j,boundary:M.filter(qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=yt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>it(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[xt({mainAxis:i+k,alignmentAxis:o}),f&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),f&&wt({...P}),Tt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Dt({element:T,padding:c}),Jt({arrowWidth:O,arrowHeight:k}),_&&Et({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;u(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=l(y);u(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return u(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Vt,{scope:n,placedSide:te,placedAlign:B,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(s.div,{"data-side":te,"data-align":B,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Ut.displayName=Bt;var Wt=`PopperArrow`,Gt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Kt=m.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ht(Wt,n),a=Gt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(At,{...r,ref:t,style:{...r.style,display:`block`}})})});Kt.displayName=Wt;function qt(e){return e!==null}var Jt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Yt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Yt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Xt=Lt,Zt=zt,Qt=Ut,$t=Kt,en=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,tn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,nn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,rn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function an({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:p(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:p(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(s.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));cn.displayName=sn;var ln=cn;function un({className:e,...t}){return(0,$.jsx)(ln,{className:p(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=f(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),fn=f(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function pn(e){a.error(hn(e),{id:`err:${hn(e)}`})}function mn(e){if(!(e instanceof o)||e.code!==`conversation_live`)return null;let t=e.details?.existing_session_id,n=e.details?.existing_project_id;return typeof t==`string`&&typeof n==`string`?{sessionId:t,projectId:n}:null}function hn(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}function gn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),u(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:p(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>f(t),className:p(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===d,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var _n=(0,m.lazy)(()=>i(()=>import(`./Terminal-BoN07_WS.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),vn=null;async function yn(){vn=(await i(()=>import(`./Terminal-BoN07_WS.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Terminal}function bn(e){return vn?(0,$.jsx)(vn,{...e}):(0,$.jsx)(m.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(_n,{...e})})}export{Qt as _,pn as a,jt as b,un as c,en as d,rn as f,$t as g,Zt as h,mn as i,an as l,tn as m,yn as n,fn as o,nn as p,gn as r,dn as s,bn as t,on as u,Xt as v,Pt as y};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-UR8urwx4.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/api-IpGGhtRp.js","assets/x-cVj9N3GX.js","assets/file-links-CcWnhnkT.js","assets/index-fAfi8H1Y.js","assets/preload-helper-Czpn1I53.js","assets/dialog-CFa2VFV0.js","assets/index-C_32FmnW.css","assets/use-find-controls-B_INkoQ4.js","assets/chevron-down-DNyOBhEl.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{T as a,t as o}from"./api-IpGGhtRp.js";import{C as s,D as c,S as l,b as u,k as d}from"./dialog-CFa2VFV0.js";import{n as f,r as p}from"./x-cVj9N3GX.js";var m=e(t(),1),h=[`top`,`right`,`bottom`,`left`],g=Math.min,_=Math.max,v=Math.round,y=Math.floor,b=e=>({x:e,y:e}),x={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function S(e,t,n){return _(e,g(t,n))}function C(e,t){return typeof e==`function`?e(t):e}function w(e){return e.split(`-`)[0]}function T(e){return e.split(`-`)[1]}function E(e){return e===`x`?`y`:`x`}function D(e){return e===`y`?`height`:`width`}function O(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function k(e){return E(O(e))}function A(e,t,n){n===void 0&&(n=!1);let r=T(e),i=k(e),a=D(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=z(o)),[o,z(o)]}function j(e){let t=z(e);return[M(e),t,M(t)]}function M(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var N=[`left`,`right`],P=[`right`,`left`],F=[`top`,`bottom`],I=[`bottom`,`top`];function L(e,t,n){switch(e){case`top`:case`bottom`:return n?t?P:N:t?N:P;case`left`:case`right`:return t?F:I;default:return[]}}function R(e,t,n,r){let i=T(e),a=L(w(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(M)))),a}function z(e){let t=w(e);return x[t]+e.slice(t.length)}function ee(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function B(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ne(e,t,n){let{reference:r,floating:i}=e,a=O(t),o=k(t),s=D(o),c=w(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=T(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function re(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=C(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=B(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=B(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ie=50,ae=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:re},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ne(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ie&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ne(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},oe=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=C(e,t)||{};if(l==null)return{};let d=te(u),f={x:n,y:r},p=k(i),m=D(p),h=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],w=f[p]-a.reference[p],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),O=E?E[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(E)))&&(O=s.floating[b]||a.floating[m]);let A=x/2-w/2,j=O/2-h[m]/2-1,M=g(d[v],j),N=g(d[y],j),P=O-h[m]-N,F=O/2-h[m]/2+A,I=S(M,F,P),L=!c.arrow&&T(i)!=null&&F!==I&&a.reference[m]/2-(F<M?M:N)-h[m]/2<0,R=L?F<M?F-M:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),se=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=C(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=w(r),_=O(o),v=w(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[z(o)]:j(o)),x=p!==`none`;!d&&x&&b.push(...R(o,m,p,y));let S=[o,...b],T=await s.detectOverflow(t,h),E=[],D=i.flip?.overflows||[];if(l&&E.push(T[g]),u){let e=A(r,a,y);E.push(T[e[0]],T[e[1]])}if(D=[...D,{placement:r,overflows:E}],!E.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==O(t))||D.every(e=>O(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=O(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ce(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function le(e){return h.some(t=>e[t]>=0)}var ue=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=C(e,t);switch(i){case`referenceHidden`:{let e=ce(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:le(e)}}}case`escaped`:{let e=ce(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:le(e)}}}default:return{}}}}},de=new Set([`left`,`top`]);async function fe(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=w(n),s=T(n),c=O(n)===`y`,l=de.has(o)?-1:1,u=a&&c?-1:1,d=C(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var pe=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await fe(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},me=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=C(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=O(i),p=E(f),m=u[p],h=u[f],g=(e,t)=>S(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},he=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=C(e,t),u={x:n,y:r},d=O(i),f=E(d),p=u[f],m=u[d],h=C(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=de.has(w(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ge=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=C(e,t),c=await i.detectOverflow(t,s),l=w(n),u=T(n),d=O(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let v=p-c.top-c.bottom,y=f-c.left-c.right,b=g(p-c[m],v),x=g(f-c[h],y),S=t.middlewareData.shift,E=!S,D=b,k=x;S!=null&&S.enabled.x&&(k=y),S!=null&&S.enabled.y&&(D=v),E&&!u&&(d?k=f-2*_(c.left,c.right):D=p-2*_(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:D});let A=await i.getDimensions(a.floating);return f!==A.width||p!==A.height?{reset:{rects:!0}}:{}}}};function _e(){return typeof window<`u`}function V(e){return ve(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((ve(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ve(e){return _e()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return _e()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return _e()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function ye(e){return!_e()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(V(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,Te;function Ee(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Oe()&&(K(t.backdropFilter)||K(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function De(e){let t=Y(e);for(;G(t)&&!q(t);){if(Ee(t))return t;if(Se(t))return null;t=Y(t)}return null}function Oe(){return Te??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Te}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function ke(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||U(e);return ye(t)?t.host:t}function Ae(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&be(t)?t:Ae(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ae(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=je(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Me(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=v(n)!==a||v(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ne(e){return W(e)?e:e.contextElement}function Z(e){let t=Ne(e);if(!G(t))return b(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Me(t),o=(a?v(n.width):n.width)/r,s=(a?v(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Pe=b(0);function Fe(e){let t=H(e);return!Oe()||!t.visualViewport?Pe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ne(e),o=b(1);t&&(r?W(r)&&(o=Z(r)):o=Z(e));let s=Ie(a,n,r)?Fe(a):b(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=je(n);for(;i&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=je(n)}}return B({width:u,height:d,x:c,y:l})}function Le(e,t){let n=ke(e).scrollLeft;return t?t.left+n:Q(U(e)).left+n}function Re(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Le(e,n),y:n.top+t.scrollTop}}function ze(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=b(1),u=b(0),d=G(r);if((d||!a)&&((V(r)!==`body`||be(o))&&(c=ke(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Re(o,c):b(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Be(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ve(e){let t=ke(e),n=e.ownerDocument.body,r=_(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Le(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=_(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var He=25;function Ue(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Oe()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Le(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=He&&(s-=o)}return{width:s,height:c,x:l,y:u}}function We(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Z(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Ge(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Ue(e,n,t);else if(t===`document`)r=Ve(U(e));else if(W(t))r=We(t,n);else{let n=Fe(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return B(r)}function Ke(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Ee(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:Ke(t,this._c):[].concat(n),r],o=Ge(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Ge(t,a[e],i);s=_(n.top,s),c=g(n.right,c),l=g(n.bottom,l),u=_(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Je(e){let{width:t,height:n}=Me(e);return{width:t,height:n}}function Ye(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=b(0);if((r||!a)&&((V(t)!==`body`||be(i))&&(s=ke(t)),r)){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Le(i));let l=i&&!r&&!a?Re(i,s):b(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Xe(e){return J(e).position===`static`}function Ze(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function Qe(e,t){let n=H(e);if(Se(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!Xe(t))return t;t=Y(t)}return n}let r=Ze(e,t);for(;r&&xe(r)&&Xe(r);)r=Ze(r,t);return r&&q(r)&&Xe(r)&&!Ee(r)?n:r||De(e)||n}var $e=async function(e){let t=this.getOffsetParent||Qe,n=this.getDimensions,r=await n(e.floating);return{reference:Ye(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function et(e){return J(e).direction===`rtl`}var tt={convertOffsetParentRelativeRectToViewportRelativeRect:ze,getDocumentElement:U,getClippingRect:qe,getOffsetParent:Qe,getElementRects:$e,getClientRects:Be,getDimensions:Je,getScale:Z,isElement:W,isRTL:et};function nt(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rt(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=y(d),h=y(a.clientWidth-(u+f)),v=y(a.clientHeight-(d+p)),b=y(u),x={rootMargin:-m+`px `+-h+`px `+-v+`px `+-b+`px`,threshold:_(0,g(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(!nt(l,e.getBoundingClientRect()))return s();if(n!==c){if(!S)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}S=!1}try{r=new IntersectionObserver(C,{...x,root:a.ownerDocument})}catch{r=new IntersectionObserver(C,x)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function it(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ne(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?rt(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!nt(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var at=pe,ot=me,st=se,ct=ge,lt=ue,ut=oe,dt=he,ft=(e,t,n)=>{let r=new Map,i=n??{},a={...tt,...i.platform,_c:r};return ae(e,t,{...i,platform:a})},pt=e(n(),1),mt=typeof document<`u`?m.useLayoutEffect:function(){};function ht(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!ht(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!ht(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function gt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _t(e,t){let n=gt(e);return Math.round(t*n)/n}function vt(e){let t=m.useRef(e);return mt(()=>{t.current=e}),t}function yt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);ht(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=vt(c),O=vt(i),k=vt(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),ft(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!ht(T.current,t)&&(T.current=t,pt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);mt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);mt(()=>(j.current=!0,()=>{j.current=!1}),[]),mt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=_t(N.floating,u.x),r=_t(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...gt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var bt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ut({element:r.current,padding:i}).fn(n):r?ut({element:r,padding:i}).fn(n):{}}}},xt=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=ot(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>({fn:dt(e).fn,options:[e,t]}),wt=(e,t)=>{let n=st(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tt=(e,t)=>{let n=ct(e);return{name:n.name,fn:n.fn,options:[e,t]}},Et=(e,t)=>{let n=lt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=bt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=r(),Ot=`Arrow`,kt=m.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});kt.displayName=Ot;var At=kt;function jt(e){let[t,n]=m.useState(void 0);return u(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Mt=`Popper`,[Nt,Pt]=c(Mt),[Ft,It]=Nt(Mt),Lt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,$.jsx)(Ft,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Lt.displayName=Mt;var Rt=`PopperAnchor`,zt=m.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=It(Rt,n),o=m.useRef(null),c=a.onAnchorChange,l=d(t,m.useCallback(e=>{o.current=e,e&&c(e)},[c])),u=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&c(u.current)});let f=a.placementState&&Yt(a.placementState),p=f?.[0],h=f?.[1];return r?null:(0,$.jsx)(s.div,{"data-radix-popper-side":p,"data-radix-popper-align":h,...i,ref:l})});zt.displayName=Rt;var Bt=`PopperContent`,[Vt,Ht]=Nt(Bt),Ut=m.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:c=0,avoidCollisions:f=!0,collisionBoundary:p=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=It(Bt,n),[S,C]=m.useState(null),w=d(t,C),[T,E]=m.useState(null),D=jt(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(p)?p:[p],N=M.length>0,P={padding:j,boundary:M.filter(qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=yt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>it(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[xt({mainAxis:i+k,alignmentAxis:o}),f&&St({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?Ct():void 0,...P}),f&&wt({...P}),Tt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Dt({element:T,padding:c}),Jt({arrowWidth:O,arrowHeight:k}),_&&Et({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;u(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,B]=Yt(L),ne=l(y);u(()=>{R&&ne?.()},[R,ne]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=m.useState();return u(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Vt,{scope:n,placedSide:te,placedAlign:B,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,$.jsx)(s.div,{"data-side":te,"data-align":B,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Ut.displayName=Bt;var Wt=`PopperArrow`,Gt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Kt=m.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ht(Wt,n),a=Gt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(At,{...r,ref:t,style:{...r.style,display:`block`}})})});Kt.displayName=Wt;function qt(e){return e!==null}var Jt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Yt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Yt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Xt=Lt,Zt=zt,Qt=Ut,$t=Kt,en=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,tn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,nn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,rn=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function an({className:e,type:t,...n}){return(0,$.jsx)(`input`,{type:t,className:p(`flex h-8 w-full px-2.5`,en,e),...n})}function on({className:e,...t}){return(0,$.jsx)(`textarea`,{className:p(`flex min-h-16 w-full px-2.5 py-2`,en,e),...t})}var sn=`Label`,cn=m.forwardRef((e,t)=>(0,$.jsx)(s.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));cn.displayName=sn;var ln=cn;function un({className:e,...t}){return(0,$.jsx)(ln,{className:p(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var dn=f(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),fn=f(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function pn(e){a.error(hn(e),{id:`err:${hn(e)}`})}function mn(e){if(!(e instanceof o)||e.code!==`conversation_live`)return null;let t=e.details?.existing_session_id,n=e.details?.existing_project_id;return typeof t==`string`&&typeof n==`string`?{sessionId:t,projectId:n}:null}function hn(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}function gn({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),h=e=>{n(e.value),r?.(e),u(!1)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(an,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),h(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,$.jsx)(`ul`,{className:p(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),h(e)},onMouseEnter:()=>f(t),className:p(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full text-xs`),"data-selected":t===d,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var _n=(0,m.lazy)(()=>i(()=>import(`./Terminal-UR8urwx4.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),vn=null;async function yn(){vn=(await i(()=>import(`./Terminal-UR8urwx4.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Terminal}function bn(e){return vn?(0,$.jsx)(vn,{...e}):(0,$.jsx)(m.Suspense,{fallback:(0,$.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,$.jsx)(_n,{...e})})}export{Qt as _,pn as a,jt as b,un as c,en as d,rn as f,$t as g,Zt as h,mn as i,an as l,tn as m,yn as n,fn as o,nn as p,gn as r,dn as s,bn as t,on as u,Xt as v,Pt as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-C_9Ib5qf.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PdfViewer-CNMgA3ee.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/preload-helper-Czpn1I53.js","assets/api-IpGGhtRp.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{t as r}from"./jsx-runtime-ffCh33zF.js";import{A as i,B as a,I as o,K as s,N as c,O as l,P as u,R as d,V as f,c as p,g as m,h,i as g,m as _,n as v,p as y,s as b,v as x,w as S,x as ee,z as te}from"./media-refresh-store-BcMhaDMx.js";import{t as ne}from"./preload-helper-Czpn1I53.js";import{T as re,r as ie,t as ae}from"./api-IpGGhtRp.js";import{a as oe,n as se,r as ce,t as le}from"./use-find-controls-CkVGrs9e.js";import{At as ue,B as de,Bt as fe,Gn as C,H as pe,Kn as me,Nt as he,U as ge,V as _e,W as ve,a as ye,fr as be,pn as xe,qn as Se,xt as Ce,z as we}from"./index-B6XVjgfK.js";import{a as Te,c as Ee,i as De,p as Oe,r as ke}from"./editor.api2-4X9Vh9Zw.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,o as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve}from"./buffer-store-BD_4UWB2.js";import{i as He,n as Ue,r as We,t as Ge}from"./drafts-BsCav0PD.js";import{r as Ke}from"./buffer-logic-BAkSBQT7.js";import{a as qe,i as Je,n as Ye,o as Xe,r as Ze}from"./editor-sync-W1bamxAP.js";var w=t(n(),1),Qe=new Map,$e=new Map,et=1;function tt(e){for(let t of $e.get(e)??[])t()}function nt(e,t){Qe.set(e,t),tt(e)}function rt(e){let t={phase:`unresolved`,revision:et++};return nt(e,t),t}function it(e){let t=Qe.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(nt(e,{phase:`loading`,revision:t.revision}),t.revision)}function at(e,t,n,r){let i=Qe.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(nt(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function ot(e,t){let n=Qe.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(nt(e,{...n,phase:`comparing`}),!0)}function st(e,t,n){let r=Qe.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(nt(e,{phase:`load-error`,revision:t,message:n}),!0)}function ct(e,t){return t&&e?.phase===`unresolved`}function lt(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function ut(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function dt(e){return e.phase===`opening`||e.phase===`comparing`}function ft(e){Qe.delete(e)&&tt(e)}function pt(e){return Qe.get(e)??null}function mt(e,t){let n=$e.get(e);return n||(n=new Set,$e.set(e,n)),n.add(t),()=>n.delete(t)}function ht(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var T=r();function gt({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=Se(),l=(0,w.useId)(),u=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,w.useRef)(o);d.current=o;let f=(0,w.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,w.useRef)(p);return m.current=p,(0,w.useEffect)(()=>()=>m.current(),[]),(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,T.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,T.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,T.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(Le,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:Me,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(De.CtrlCmd|ke.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...ht(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function _t({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:dt(i)&&n.model?(0,T.jsx)(gt,{session:e,path:t,conflict:i,model:n.model,onTakeDisk:n.takeDisk,onKeepMine:n.keepMine,onSave:n.save,onReady:r?n.comparisonReady:void 0}):i.phase===`load-error`?(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground px-4 text-center text-sm text-fg-muted`,children:[(0,T.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,T.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,T.jsx)(`button`,{type:`button`,onClick:n.compare,className:`rounded-md bg-elevated px-3 py-1.5 text-xs text-fg-secondary transition-colors hover:bg-border hover:text-fg`,children:`Retry compare`})]}):(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}var vt=`data-puddle-source-line`,yt=`data-puddle-source-end-line`,bt=`data-puddle-source-line-count`;function xt(e){return Number.isFinite(e.line)&&Number.isFinite(e.offset)}function St(e){let t=e.filter(xt).map(({line:e,offset:t})=>({line:Math.max(1,e),offset:Math.max(0,t)})).sort((e,t)=>e.offset-t.offset||e.line-t.line),n=[];for(let e of t){let t=n.at(-1);t&&(e.line<t.line||e.offset<t.offset)||t&&(e.line===t.line||e.offset===t.offset)||n.push(e)}return n}function Ct(e,t,n,r,i){return n<=t?r:r+Math.min(1,Math.max(0,(e-t)/(n-t)))*(i-r)}function wt(e,t,n){if(e.length===0)return null;if(t<=e[0][n])return[e[0],e[0]];let r=e.at(-1);if(t>=r[n])return[r,r];let i=0,a=e.length-1;for(;i+1<a;){let r=Math.floor((i+a)/2);e[r][n]<=t?i=r:a=r}return[e[i],e[a]]}function Tt(e,t){let n=wt(e,t,`line`);return n?Ct(t,n[0].line,n[1].line,n[0].offset,n[1].offset):null}function Et(e,t){let n=wt(e,t,`offset`);return n?Ct(t,n[0].offset,n[1].offset,n[0].line,n[1].line):null}function Dt(e,t){let n=Number(e.getAttribute(t));return Number.isFinite(n)&&n>=1?n:null}function Ot(e,t,n){let r=e.getBoundingClientRect().top,i=[{line:1,offset:0}];for(let a of t.querySelectorAll(`[${vt}]`)){let t=Dt(a,vt);if(t===null||t>n+1||a.getClientRects().length===0)continue;let o=a.getBoundingClientRect(),s=o.top-r+e.scrollTop;i.push({line:t,offset:s});let c=Dt(a,yt);c!==null&&c<=n+1&&c>t&&o.height>0&&i.push({line:c,offset:s+o.height})}return i.push({line:Math.max(1,n+1),offset:e.scrollHeight}),St(i)}function kt(e){return e===``?1:e.split(/\r\n?|\n/).length}function At(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function jt(e,t,n){return At(e/Math.max(1,t-n))}function Mt(e,t,n){return At(e)*Math.max(0,t-n)}function Nt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var Pt=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n,r=null){let i={ratio:At(n),sourceLine:r!==null&&Number.isFinite(r)?Math.max(1,r):null,revision:++this.revision},a=Nt(e,t);this.positions.set(a,i);for(let e of this.listeners.get(a)??[])e(i);return i}get(e,t){return this.positions.get(Nt(e,t))}subscribe(e,t,n){let r=Nt(e,t),i=this.listeners.get(r);i||(i=new Set,this.listeners.set(r,i)),i.add(n);let a=this.positions.get(r);return a&&n(a),()=>{i?.delete(n),i?.size===0&&this.listeners.delete(r)}}};function Ft(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function It(e,t,n,r){let i=Math.max(0,t-n);if(e.ratio<=0)return 0;if(e.ratio>=1)return i;if(e.sourceLine!==null&&r){let t=Tt(r,e.sourceLine);if(t!==null)return Math.min(i,Math.max(0,t))}return Mt(e.ratio,t,n)}function Lt(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??Pt,r,i=t.sourceAnchors?.(),a=()=>void 0,o,s=t=>{r=t,e.scrollTop=It(t,e.scrollHeight,e.clientHeight,i)};t.receiver?a=n.subscribe(t.channel,t.target,s):t.driver&&(o=Ft(()=>{let r=jt(e.scrollTop,e.scrollHeight,e.clientHeight),a=i?Et(i,e.scrollTop):null;n.publish(t.channel,t.target,r,a)}),e.addEventListener(`scroll`,o.schedule,{passive:!0}),o.schedule());let c=new ResizeObserver(()=>{i=t.sourceAnchors?.(),t.receiver&&r?s(r):t.driver&&o?.schedule()});for(let e of t.resizeElements??[])c.observe(e);return()=>{t.driver&&o&&e.removeEventListener(`scroll`,o.schedule),a(),c.disconnect(),o?.dispose()}}function Rt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0)return null;let r=1,i=n;for(;r<i;){let n=Math.ceil((r+i)/2);e.getTopForLineNumber(n)<=t?r=n:i=n-1}let a=e.getTopForLineNumber(r),o=r<n?e.getTopForLineNumber(r+1):e.getScrollHeight();return o<=a?r:r+Math.min(1,Math.max(0,(t-a)/(o-a)))}function zt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0||!Number.isFinite(t))return null;let r=Math.min(n+1,Math.max(1,t)),i=Math.floor(r);if(i>n)return e.getScrollHeight();let a=i+1,o=e.getTopForLineNumber(i),s=a<=n?e.getTopForLineNumber(a):e.getScrollHeight();return o+(r-i)*(s-o)}function Bt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??Pt,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t;let r=t.ratio>0&&t.ratio<1&&t.sourceLine!==null?zt(e,t.sourceLine):null;e.setScrollTop(r??It(t,e.getScrollHeight(),c()),n)};return t.receiver?(o=r.subscribe(t.channel,t.target,l),i.push(e.onDidChangeModel(()=>a&&l(a))),i.push(e.onDidLayoutChange(()=>a&&l(a))),i.push(e.onDidContentSizeChange(()=>a&&l(a)))):t.driver&&(s=Ft(()=>{let n=jt(e.getScrollTop(),e.getScrollHeight(),c());r.publish(t.channel,t.target,n,Rt(e,e.getScrollTop()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidChangeModelContent(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),i.push(e.onDidContentSizeChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function Vt(e){return!e}function Ht(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=De.CtrlCmd:e===`ctrl`?r|=De.WinCtrl:e===`alt`?r|=De.Alt:e===`shift`&&(r|=De.Shift);let i=ke[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function Ut(e,t){let n=Ht(ue(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Ht(ue(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>me({editorWordWrap:Vt(C().editorWordWrap)})})}function Wt(e){return`file-conflict:${e}`}function Gt(e,t,n,r,i){let a=i?.passive===!0,o=i?.focused??!0,s=Be(e,t,r),c=f(e,t,{root:r,live:i?.live}),l=te(e,r),[u,d]=(0,w.useState)(null),[p,m]=(0,w.useState)(!1),h=(0,w.useRef)(!1),g=(0,w.useRef)(null),_=(0,w.useRef)(null),v=(0,w.useRef)(n);v.current=n;let y=(0,w.useRef)(!1),b=(0,w.useCallback)((e,t)=>{_.current?.cancel(),y.current=!0;try{ze(s,e,t)}finally{y.current=!1}},[s]),S=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>Ve(s,e),[s]),()=>Pe(s)),ne=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>Xe(s,e),[s]),()=>qe(s)),ie=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>mt(s,e),[s]),()=>pt(s));(0,w.useEffect)(()=>{let n=c.data;if(!n||n.binary||n.content===null||h.current)return;h.current=!0;let i=Fe(s)!==void 0,a=Re(e,t,n.content,n.mtime_ms,r),o=a.getValue();d(a),!i&&He(e,t,r).then(i=>{if(!i)return;let s=Ue(i,o,n.mtime_ms);s===`discard`?Ge(e,t,r):s===`restore`?Ke(a,i.content)&&m(!0):re(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Ke(a,i.content)&&m(!0)}}})})},[c.data,s,e,t,r]),(0,w.useEffect)(()=>{if(!u||a)return;let n=We(e,t,r);_.current=n;let i=u.onDidChangeContent(()=>{y.current||(n(u.getValue(),Fe(s)??0),Ye(e,t,r))});return()=>{n.flush(),i.dispose(),_.current=null}},[u,s,e,t,r,a]),(0,w.useEffect)(()=>{!u||!ne.savedElsewhere||Pe(s)||c.refetch().then(e=>{Pe(s)||(e.data&&e.data.content!==null&&b(e.data.content,e.data.mtime_ms),Je(s))})},[ne.savedElsewhere,u,s]),(0,w.useEffect)(()=>{let e=c.data;!u||!e||e.content===null||!Pe(s)&&e.mtime_ms!==Fe(s)&&b(e.content,e.mtime_ms)},[c.data,u,s]);let oe=(0,w.useCallback)((n,i)=>{Ae(s,n,i),_.current?.cancel(),Ge(e,t,r),Ze(e,t,i,r),m(!1),ft(s)},[s,e,t,r]),se=(0,w.useCallback)(()=>{let e=it(s);e!==null&&(re.dismiss(Wt(s)),c.refetch({throwOnError:!0}).then(t=>{let n=t.data;if(!n)throw Error(`The disk version did not load.`);if(n.content===null)throw Error(`The file on disk is binary and cannot be compared as text.`);at(s,e,n.content,n.mtime_ms)}).catch(t=>{st(s,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[c,s]),ce=(0,w.useRef)(se);ce.current=se,(0,w.useEffect)(()=>{if(!ct(ie,o))return;let e=Wt(s);return re(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>ce.current()}}),()=>{re.dismiss(e)}},[ie,o,s]);let le=(0,w.useCallback)(()=>{c.refetch().then(n=>{n.data&&n.data.content!==null&&b(n.data.content,n.data.mtime_ms),Ge(e,t,r),m(!1),ft(s)})},[s,e,t,b]),ue=(0,w.useCallback)((e,n)=>{l.mutate({path:t,content:e},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>re.error(e instanceof Error?e.message:`Overwrite failed`)})},[l,t,oe]),de=(0,w.useCallback)(async()=>{if(!u||!Pe(s))return!0;let e=u.getValue(),n=u.getAlternativeVersionId();if(ut(pt(s)))return!1;let r=lt(pt(s))??Fe(s);try{let i=await l.mutateAsync({path:t,content:e,expected_mtime_ms:r});return oe(n,i.mtime_ms),!0}catch(e){return e instanceof ae&&e.status===409&&e.code===`stale_file`?rt(s):re.error(e instanceof Error?e.message:`Save failed`),!1}},[u,s,l,t,oe]),fe=(0,w.useRef)(de);fe.current=de,(0,w.useEffect)(()=>x(ee(e,t,r),()=>fe.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let C=(0,w.useCallback)(()=>{let n=g.current,i=v.current;!n||!i||i.session!==e||i.path!==t||(i.root??void 0)!==(r??void 0)||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus())},[e,t,r]),pe=(0,w.useCallback)(e=>{g.current=e,Ut(e,{onSave:()=>fe.current()}),C()},[C]);(0,w.useEffect)(()=>{C()},[n,u,C]);let me=(0,w.useCallback)(()=>{le()},[le]),he=(0,w.useCallback)(()=>{!u||pt(s)?.phase!==`comparing`||ue(u.getValue(),u.getAlternativeVersionId())},[u,s,ue]),ge=(0,w.useCallback)(e=>{ot(s,e)},[s]),_e,ve=null;c.data?.binary?_e=`binary`:c.error?c.error instanceof ae&&c.error.status===413?_e=`too-large`:(_e=`error`,ve=c.error instanceof Error?c.error.message:`Failed to load file`):_e=u?`ready`:`loading`;let ye=S&&ne.savedElsewhere?`saved-elsewhere`:S&&ne.dirtyElsewhere?`dirty-elsewhere`:null;return{status:_e,errorMessage:ve,model:u,dirty:S,restoredNotice:p,discardRestore:me,peerBadge:ye,conflict:ie,takeDisk:le,keepMine:he,compare:se,comparisonReady:ge,save:de,onMount:pe}}function Kt(e,t,n,r){for(let i of e)if(Zt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function qt(e,t){return Yt(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function Jt(e){let t=Yt(e.originalStartLineNumber,e.originalEndLineNumber),n=Yt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function Yt(e,t){return t===0?0:Math.max(0,t-e+1)}function Xt(e,t){if(e>t)return{startLineNumber:Math.max(1,t),endLineNumber:Math.max(1,t),kind:`deleted-after`};let n=Math.max(1,e);return{startLineNumber:n,endLineNumber:n,kind:`deleted-before`}}function Zt(e,t){let n=[];for(let r of e){let e=Yt(r.originalStartLineNumber,r.originalEndLineNumber),i=Yt(r.modifiedStartLineNumber,r.modifiedEndLineNumber);if(e===0&&i>0){n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedEndLineNumber,kind:`added`});continue}if(i===0&&e>0){n.push(Xt(r.modifiedStartLineNumber,t));continue}let a=Math.min(e,i);a>0&&n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedStartLineNumber+a-1,kind:`modified`}),i>a&&n.push({startLineNumber:r.modifiedStartLineNumber+a,endLineNumber:r.modifiedEndLineNumber,kind:`added`}),e>a&&n.push(Xt(r.modifiedStartLineNumber+i,t))}return n}var Qt=28,$t=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function en(e){if(e){for(let[t,n]of $t)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function tn({editor:e,original:t,modified:n,path:r}){let i=[],a=null,o=!1,s=t=>{try{e.changeViewZones(e=>e.removeZone(t))}catch{}},c=()=>{let e=a;e&&(a=null,e.frame!==null&&cancelAnimationFrame(e.frame),e.diffEditor&&(e.diffEditor.setModel(null),e.diffEditor.dispose()),s(e.zoneId))},l=e=>{let t=e.diffEditor;if(!t)return;let r=Math.max(1,Math.min(n.getLineCount(),e.change.modifiedStartLineNumber));t.getModifiedEditor().revealLineInCenter(r,Oe.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(Oe.EditorOption.lineHeight),d=document.createElement(`div`);d.className=`puddle-dirty-peek`;let f=document.createElement(`div`);f.className=`puddle-dirty-peek-header`;let p=document.createElement(`span`);p.className=`puddle-dirty-peek-title`,p.textContent=`${r.split(`/`).pop()??r} · Local changes against HEAD`;let m=document.createElement(`button`);m.type=`button`,m.className=`puddle-dirty-peek-close`,m.setAttribute(`aria-label`,`Close inline change`),m.title=`Close inline change`,m.textContent=`×`,m.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),c()}),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),c()});let h=document.createElement(`div`);h.className=`puddle-dirty-peek-editor`,f.append(p,m),d.append(f,h);let g=document.createElement(`div`);g.className=`puddle-dirty-peek-margin`;let _={afterLineNumber:qt(s,n.getLineCount()),heightInPx:Qt+Jt(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=Oe.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(Oe.EditorOption.fontFamily),fontSize:e.getOption(Oe.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==Oe.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=Kt(i,t,n.getLineCount(),en(e.target.element));r&&(e.event.preventDefault(),e.event.stopPropagation(),u(t,r))});return{update(t){if(i=t,!a)return;let r=a,o=Kt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=qt(o,n.getLineCount()),r.zone.heightInPx=Qt+Jt(o)*e.getOption(Oe.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var nn={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function rn(e,t,n,r){let i=xe(),a=o(e,t,{root:n,enabled:i.data!==void 0&&Ce(i.data.protocol)&&r!==null}),[s,c]=(0,w.useState)(null),l=(0,w.useCallback)(e=>{c(e)},[]);return(0,w.useEffect)(()=>{let e=a.data;if(!s||!r||!e||e.repository===null||e.ignored||e.binary)return;let n=document.createElement(`div`);n.className=`puddle-hidden-diff-controller`,document.body.appendChild(n);let i=Oe.createModel(e.exists?e.content??``:``,r.getLanguageId()),o=Oe.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();o.setModel({original:i,modified:r});let l=tn({editor:s,original:i,modified:r,path:t}),u=()=>{let e=o.getLineChanges();e&&(l.update(e),c.set(Zt(e,r.getLineCount()).map(e=>({range:new Ee(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:nn[e.kind]}}))))},d=o.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),o.setModel(null),o.dispose(),i.dispose(),n.remove()}},[s,r,a.data]),l}function an({message:e,session:t,path:n,root:r,download:i}){return(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,T.jsx)(`span`,{children:e}),i&&(0,T.jsxs)(`button`,{type:`button`,onClick:()=>void l(t,n,r).catch(e=>re.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,T.jsx)(s,{className:`size-4`}),`Download`]})]})}function on({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=Se(),l=Gt(e,t,n,r,{focused:i}),u=S(e,t,r),d=rn(e,t,r,l.model),f=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[p,m]=(0,w.useState)(null),h=(0,w.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),g=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,w.useEffect)(()=>{if(!(!p||!l.model||g))return Bt(p,{channel:s,target:h,driver:a,receiver:o},Oe.ScrollType.Immediate)},[p,l.model,g,s,h,a,o]),(0,w.useEffect)(()=>{let e=l.model;e&&Oe.setModelMarkers(e,`puddle-compilation`,u.map(t=>{let n=Math.min(t.line,e.getLineCount()),r=e.getLineMaxColumn(n),i=Math.min(t.column??1,r),a=t.end_line??n,o=Math.max(n,Math.min(a,e.getLineCount())),s=e.getLineMaxColumn(o),c=Math.min(t.end_column??(t.column?i+1:s),s);return{severity:t.severity===`error`?Te.Error:t.severity===`warning`?Te.Warning:Te.Info,message:t.message,source:`Puddle compilation`,startLineNumber:n,startColumn:i,endLineNumber:o,endColumn:Math.max(i,c)}}))},[l.model,u]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,T.jsx)(_t,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,T.jsx)(an,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,T.jsx)(an,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,T.jsx)(an,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let _=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,T.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,T.jsx)(`span`,{children:`Restored unsaved changes`}),(0,T.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),_&&(0,T.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:_}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,T.jsx)(Ne,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),d(e),m(e)},loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:f,fontSize:c.editorFontSize,...ht(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function sn({children:e}){return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function cn(e,t){let n=(0,w.useRef)(t);n.current=t,(0,w.useEffect)(()=>(je(e),()=>{n.current?.(),Ie(e)}),[e])}function ln(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function un({session:e,refName:t,path:n,content:r}){let i=Se(),a=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,T.jsx)(Ne,{path:ln(`puddle-view`,e,t,n),defaultValue:r,theme:Me,loading:(0,T.jsx)(sn,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...ht(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function dn({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=u(e,t,n,{root:r,enabled:!i}),o=d(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,T.jsx)(sn,{children:`…`}):s.error?(0,T.jsx)(sn,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,T.jsx)(sn,{children:`Binary file — deleted`}):(0,T.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,T.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(un,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function fn({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=Se(),c=Gt(e,n,null,i,{focused:o}),l=u(e,t,r,{root:i,enabled:!a}),f=d(e,r,{root:i,enabled:a}),p=a?f:l,m=(0,w.useRef)(null);cn(Be(e,n,i),()=>{let e=m.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),m.current=null});let h=(0,w.useRef)(c.save);h.current=c.save;let g=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),_=p.error instanceof ae&&p.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,T.jsx)(_t,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||p.data?.binary?(0,T.jsx)(sn,{children:`Binary file`}):c.status===`too-large`?(0,T.jsx)(sn,{children:`File too large to show`}):c.status===`error`?(0,T.jsx)(sn,{children:c.errorMessage??`Failed to load file`}):_||a&&f.data&&!f.data.exists?(0,T.jsx)(on,{session:e,path:n,reveal:null,root:i,focused:o}):p.isPending||!c.model?(0,T.jsx)(sn,{children:`…`}):p.error?(0,T.jsx)(sn,{children:p.error instanceof Error?p.error.message:`Failed to load base`}):(0,T.jsx)(Le,{modifiedModelPath:c.model.uri.toString(),originalModelPath:ln(`puddle-base`,e,`${t}:${i??``}`,r),original:p.data.content??``,language:c.model.getLanguageId(),theme:Me,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(sn,{children:`…`}),onMount:e=>{m.current=e,e.onDidDispose(()=>{m.current=null}),e.getModifiedEditor().addCommand(De.CtrlCmd|ke.KeyS,()=>h.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...ht(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function pn({session:e,against:t,entry:n,root:r}){let i=Se(),a=n.old_path??n.path,o=u(e,t,a,{root:r,enabled:n.status!==`added`}),s=d(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,T.jsx)(dn,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,T.jsx)(sn,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,T.jsx)(sn,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,T.jsx)(sn,{children:`Binary file`}):n.status===`added`?(0,T.jsx)(un,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,T.jsx)(Le,{originalModelPath:ln(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:ln(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Me,loading:(0,T.jsx)(sn,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...ht(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,T.jsx)(sn,{children:`Failed to load HEAD content`})}function mn({session:e,path:t,root:n,focused:r}){return cn(Be(e,t,n)),(0,T.jsx)(on,{session:e,path:t,reveal:null,root:n,focused:r})}function hn({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,T.jsx)(pn,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,T.jsx)(mn,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,T.jsx)(dn,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,T.jsx)(fn,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function gn({session:e,sha:t,path:n,root:r}){let i=u(e,t,n,{root:r});return i.isPending?(0,T.jsx)(sn,{children:`…`}):i.error?(0,T.jsx)(sn,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,T.jsx)(sn,{children:`Binary file`}):(0,T.jsx)(un,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function _n({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=Se(),l=(0,w.useRef)(null),u=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,w.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,T.jsx)(Le,{originalModelPath:ln(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:ln(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Me,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(sn,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...ht(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function vn({session:e,sha:t,path:n,basePath:r,root:i}){let a=u(e,`${t}^`,r,{root:i}),o=u(e,t,n,{root:i});return a.error instanceof ae&&a.error.status===404?(0,T.jsx)(gn,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,T.jsx)(sn,{children:`…`}):a.error?(0,T.jsx)(sn,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,T.jsx)(sn,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,T.jsx)(sn,{children:`Binary file`}):(0,T.jsx)(_n,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function yn({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(m(n.status,r)){case`added`:return(0,T.jsx)(gn,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,T.jsx)(dn,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,T.jsx)(vn,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function bn({session:e,sha:t,path:n,root:r}){let i=c(e,t,r);if(i.isPending)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,T.jsx)(`div`,{className:`h-full`,children:(0,T.jsx)(yn,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,T.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,T.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function xn({session:e,path:t,root:n,area:r,focused:i=!0}){let o=a(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(o.isPending)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(o.error)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load diff`});let s=o.data.entries.find(e=>e.path===t);return s?(0,T.jsx)(`div`,{className:`h-full`,children:(0,T.jsx)(hn,{session:e,against:o.data.against,entry:s,root:n,area:r,focused:i})}):(0,T.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,T.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Sn=800;function Cn({name:e}){let t=Se(),n=fe(),r=h(n,e),i=be(),a=he(`editor.save`),o=(0,w.useRef)(null),s=(0,w.useRef)(null),c=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,w.useEffect)(()=>{if(n===null)return;let t=ye(t=>{y(n,e,t).catch(e=>re.error(e instanceof Error?e.message:`Draft not saved`))},Sn);return s.current=t,()=>{t.flush(),s.current=null}},[n,e]),n===null)return null;if(r.error)return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load the draft`});if(r.data===void 0)return(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let l=()=>{let t=o.current;t&&(s.current?.flush(),p({name:e,content:t.getValue()}))};return(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,T.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,a,` saves it into one`]}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(Ne,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Me,keepCurrentModel:!1,loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{o.current=t,b(e,t.getValue()),Ut(t,{onSave:l})},onChange:t=>{let r=t??``;b(e,r),_(i,n,e,r),s.current?.(r)},options:{automaticLayout:!0,fontFamily:c,fontSize:t.editorFontSize,...ht(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function wn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Tn(e){if(Array.isArray(e))return e}function En(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Dn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{t as r}from"./jsx-runtime-ffCh33zF.js";import{A as i,B as a,I as o,K as s,N as c,O as l,P as u,R as d,V as f,c as p,g as m,h,i as g,m as _,n as v,p as y,s as b,v as x,w as S,x as ee,z as te}from"./media-refresh-store-CDq91uhk.js";import{t as ne}from"./preload-helper-Czpn1I53.js";import{T as re,r as ie,t as ae}from"./api-IpGGhtRp.js";import{a as oe,n as se,r as ce,t as le}from"./use-find-controls-B_INkoQ4.js";import{At as ue,B as de,Bt as fe,Gn as C,H as pe,Kn as me,Nt as he,U as ge,V as _e,W as ve,a as ye,fr as be,pn as xe,qn as Se,xt as Ce,z as we}from"./index-fAfi8H1Y.js";import{a as Te,c as Ee,i as De,p as Oe,r as ke}from"./editor.api2-4X9Vh9Zw.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,o as Ie,p as Le,r as Re,s as ze,t as Be,u as Ve}from"./buffer-store-C_9Ib5qf.js";import{i as He,n as Ue,r as We,t as Ge}from"./drafts-DJULaAJ0.js";import{r as Ke}from"./buffer-logic-BAkSBQT7.js";import{a as qe,i as Je,n as Ye,o as Xe,r as Ze}from"./editor-sync-W1bamxAP.js";var w=t(n(),1),Qe=new Map,$e=new Map,et=1;function tt(e){for(let t of $e.get(e)??[])t()}function nt(e,t){Qe.set(e,t),tt(e)}function rt(e){let t={phase:`unresolved`,revision:et++};return nt(e,t),t}function it(e){let t=Qe.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(nt(e,{phase:`loading`,revision:t.revision}),t.revision)}function at(e,t,n,r){let i=Qe.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(nt(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function ot(e,t){let n=Qe.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(nt(e,{...n,phase:`comparing`}),!0)}function st(e,t,n){let r=Qe.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(nt(e,{phase:`load-error`,revision:t,message:n}),!0)}function ct(e,t){return t&&e?.phase===`unresolved`}function lt(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function ut(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function dt(e){return e.phase===`opening`||e.phase===`comparing`}function ft(e){Qe.delete(e)&&tt(e)}function pt(e){return Qe.get(e)??null}function mt(e,t){let n=$e.get(e);return n||(n=new Set,$e.set(e,n)),n.add(t),()=>n.delete(t)}function ht(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var T=r();function gt({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=Se(),l=(0,w.useId)(),u=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,w.useRef)(o);d.current=o;let f=(0,w.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,w.useRef)(p);return m.current=p,(0,w.useEffect)(()=>()=>m.current(),[]),(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,T.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,T.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,T.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(Le,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:Me,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(De.CtrlCmd|ke.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...ht(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function _t({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:dt(i)&&n.model?(0,T.jsx)(gt,{session:e,path:t,conflict:i,model:n.model,onTakeDisk:n.takeDisk,onKeepMine:n.keepMine,onSave:n.save,onReady:r?n.comparisonReady:void 0}):i.phase===`load-error`?(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground px-4 text-center text-sm text-fg-muted`,children:[(0,T.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,T.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,T.jsx)(`button`,{type:`button`,onClick:n.compare,className:`rounded-md bg-elevated px-3 py-1.5 text-xs text-fg-secondary transition-colors hover:bg-border hover:text-fg`,children:`Retry compare`})]}):(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}var vt=`data-puddle-source-line`,yt=`data-puddle-source-end-line`,bt=`data-puddle-source-line-count`;function xt(e){return Number.isFinite(e.line)&&Number.isFinite(e.offset)}function St(e){let t=e.filter(xt).map(({line:e,offset:t})=>({line:Math.max(1,e),offset:Math.max(0,t)})).sort((e,t)=>e.offset-t.offset||e.line-t.line),n=[];for(let e of t){let t=n.at(-1);t&&(e.line<t.line||e.offset<t.offset)||t&&(e.line===t.line||e.offset===t.offset)||n.push(e)}return n}function Ct(e,t,n,r,i){return n<=t?r:r+Math.min(1,Math.max(0,(e-t)/(n-t)))*(i-r)}function wt(e,t,n){if(e.length===0)return null;if(t<=e[0][n])return[e[0],e[0]];let r=e.at(-1);if(t>=r[n])return[r,r];let i=0,a=e.length-1;for(;i+1<a;){let r=Math.floor((i+a)/2);e[r][n]<=t?i=r:a=r}return[e[i],e[a]]}function Tt(e,t){let n=wt(e,t,`line`);return n?Ct(t,n[0].line,n[1].line,n[0].offset,n[1].offset):null}function Et(e,t){let n=wt(e,t,`offset`);return n?Ct(t,n[0].offset,n[1].offset,n[0].line,n[1].line):null}function Dt(e,t){let n=Number(e.getAttribute(t));return Number.isFinite(n)&&n>=1?n:null}function Ot(e,t,n){let r=e.getBoundingClientRect().top,i=[{line:1,offset:0}];for(let a of t.querySelectorAll(`[${vt}]`)){let t=Dt(a,vt);if(t===null||t>n+1||a.getClientRects().length===0)continue;let o=a.getBoundingClientRect(),s=o.top-r+e.scrollTop;i.push({line:t,offset:s});let c=Dt(a,yt);c!==null&&c<=n+1&&c>t&&o.height>0&&i.push({line:c,offset:s+o.height})}return i.push({line:Math.max(1,n+1),offset:e.scrollHeight}),St(i)}function kt(e){return e===``?1:e.split(/\r\n?|\n/).length}function At(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function jt(e,t,n){return At(e/Math.max(1,t-n))}function Mt(e,t,n){return At(e)*Math.max(0,t-n)}function Nt(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var Pt=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n,r=null){let i={ratio:At(n),sourceLine:r!==null&&Number.isFinite(r)?Math.max(1,r):null,revision:++this.revision},a=Nt(e,t);this.positions.set(a,i);for(let e of this.listeners.get(a)??[])e(i);return i}get(e,t){return this.positions.get(Nt(e,t))}subscribe(e,t,n){let r=Nt(e,t),i=this.listeners.get(r);i||(i=new Set,this.listeners.set(r,i)),i.add(n);let a=this.positions.get(r);return a&&n(a),()=>{i?.delete(n),i?.size===0&&this.listeners.delete(r)}}};function Ft(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function It(e,t,n,r){let i=Math.max(0,t-n);if(e.ratio<=0)return 0;if(e.ratio>=1)return i;if(e.sourceLine!==null&&r){let t=Tt(r,e.sourceLine);if(t!==null)return Math.min(i,Math.max(0,t))}return Mt(e.ratio,t,n)}function Lt(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??Pt,r,i=t.sourceAnchors?.(),a=()=>void 0,o,s=t=>{r=t,e.scrollTop=It(t,e.scrollHeight,e.clientHeight,i)};t.receiver?a=n.subscribe(t.channel,t.target,s):t.driver&&(o=Ft(()=>{let r=jt(e.scrollTop,e.scrollHeight,e.clientHeight),a=i?Et(i,e.scrollTop):null;n.publish(t.channel,t.target,r,a)}),e.addEventListener(`scroll`,o.schedule,{passive:!0}),o.schedule());let c=new ResizeObserver(()=>{i=t.sourceAnchors?.(),t.receiver&&r?s(r):t.driver&&o?.schedule()});for(let e of t.resizeElements??[])c.observe(e);return()=>{t.driver&&o&&e.removeEventListener(`scroll`,o.schedule),a(),c.disconnect(),o?.dispose()}}function Rt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0)return null;let r=1,i=n;for(;r<i;){let n=Math.ceil((r+i)/2);e.getTopForLineNumber(n)<=t?r=n:i=n-1}let a=e.getTopForLineNumber(r),o=r<n?e.getTopForLineNumber(r+1):e.getScrollHeight();return o<=a?r:r+Math.min(1,Math.max(0,(t-a)/(o-a)))}function zt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0||!Number.isFinite(t))return null;let r=Math.min(n+1,Math.max(1,t)),i=Math.floor(r);if(i>n)return e.getScrollHeight();let a=i+1,o=e.getTopForLineNumber(i),s=a<=n?e.getTopForLineNumber(a):e.getScrollHeight();return o+(r-i)*(s-o)}function Bt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??Pt,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t;let r=t.ratio>0&&t.ratio<1&&t.sourceLine!==null?zt(e,t.sourceLine):null;e.setScrollTop(r??It(t,e.getScrollHeight(),c()),n)};return t.receiver?(o=r.subscribe(t.channel,t.target,l),i.push(e.onDidChangeModel(()=>a&&l(a))),i.push(e.onDidLayoutChange(()=>a&&l(a))),i.push(e.onDidContentSizeChange(()=>a&&l(a)))):t.driver&&(s=Ft(()=>{let n=jt(e.getScrollTop(),e.getScrollHeight(),c());r.publish(t.channel,t.target,n,Rt(e,e.getScrollTop()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidChangeModelContent(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),i.push(e.onDidContentSizeChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function Vt(e){return!e}function Ht(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=De.CtrlCmd:e===`ctrl`?r|=De.WinCtrl:e===`alt`?r|=De.Alt:e===`shift`&&(r|=De.Shift);let i=ke[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function Ut(e,t){let n=Ht(ue(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Ht(ue(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>me({editorWordWrap:Vt(C().editorWordWrap)})})}function Wt(e){return`file-conflict:${e}`}function Gt(e,t,n,r,i){let a=i?.passive===!0,o=i?.focused??!0,s=Be(e,t,r),c=f(e,t,{root:r,live:i?.live}),l=te(e,r),[u,d]=(0,w.useState)(null),[p,m]=(0,w.useState)(!1),h=(0,w.useRef)(!1),g=(0,w.useRef)(null),_=(0,w.useRef)(null),v=(0,w.useRef)(n);v.current=n;let y=(0,w.useRef)(!1),b=(0,w.useCallback)((e,t)=>{_.current?.cancel(),y.current=!0;try{ze(s,e,t)}finally{y.current=!1}},[s]),S=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>Ve(s,e),[s]),()=>Pe(s)),ne=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>Xe(s,e),[s]),()=>qe(s)),ie=(0,w.useSyncExternalStore)((0,w.useCallback)(e=>mt(s,e),[s]),()=>pt(s));(0,w.useEffect)(()=>{let n=c.data;if(!n||n.binary||n.content===null||h.current)return;h.current=!0;let i=Fe(s)!==void 0,a=Re(e,t,n.content,n.mtime_ms,r),o=a.getValue();d(a),!i&&He(e,t,r).then(i=>{if(!i)return;let s=Ue(i,o,n.mtime_ms);s===`discard`?Ge(e,t,r):s===`restore`?Ke(a,i.content)&&m(!0):re(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Ke(a,i.content)&&m(!0)}}})})},[c.data,s,e,t,r]),(0,w.useEffect)(()=>{if(!u||a)return;let n=We(e,t,r);_.current=n;let i=u.onDidChangeContent(()=>{y.current||(n(u.getValue(),Fe(s)??0),Ye(e,t,r))});return()=>{n.flush(),i.dispose(),_.current=null}},[u,s,e,t,r,a]),(0,w.useEffect)(()=>{!u||!ne.savedElsewhere||Pe(s)||c.refetch().then(e=>{Pe(s)||(e.data&&e.data.content!==null&&b(e.data.content,e.data.mtime_ms),Je(s))})},[ne.savedElsewhere,u,s]),(0,w.useEffect)(()=>{let e=c.data;!u||!e||e.content===null||!Pe(s)&&e.mtime_ms!==Fe(s)&&b(e.content,e.mtime_ms)},[c.data,u,s]);let oe=(0,w.useCallback)((n,i)=>{Ae(s,n,i),_.current?.cancel(),Ge(e,t,r),Ze(e,t,i,r),m(!1),ft(s)},[s,e,t,r]),se=(0,w.useCallback)(()=>{let e=it(s);e!==null&&(re.dismiss(Wt(s)),c.refetch({throwOnError:!0}).then(t=>{let n=t.data;if(!n)throw Error(`The disk version did not load.`);if(n.content===null)throw Error(`The file on disk is binary and cannot be compared as text.`);at(s,e,n.content,n.mtime_ms)}).catch(t=>{st(s,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[c,s]),ce=(0,w.useRef)(se);ce.current=se,(0,w.useEffect)(()=>{if(!ct(ie,o))return;let e=Wt(s);return re(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>ce.current()}}),()=>{re.dismiss(e)}},[ie,o,s]);let le=(0,w.useCallback)(()=>{c.refetch().then(n=>{n.data&&n.data.content!==null&&b(n.data.content,n.data.mtime_ms),Ge(e,t,r),m(!1),ft(s)})},[s,e,t,b]),ue=(0,w.useCallback)((e,n)=>{l.mutate({path:t,content:e},{onSuccess:e=>oe(n,e.mtime_ms),onError:e=>re.error(e instanceof Error?e.message:`Overwrite failed`)})},[l,t,oe]),de=(0,w.useCallback)(async()=>{if(!u||!Pe(s))return!0;let e=u.getValue(),n=u.getAlternativeVersionId();if(ut(pt(s)))return!1;let r=lt(pt(s))??Fe(s);try{let i=await l.mutateAsync({path:t,content:e,expected_mtime_ms:r});return oe(n,i.mtime_ms),!0}catch(e){return e instanceof ae&&e.status===409&&e.code===`stale_file`?rt(s):re.error(e instanceof Error?e.message:`Save failed`),!1}},[u,s,l,t,oe]),fe=(0,w.useRef)(de);fe.current=de,(0,w.useEffect)(()=>x(ee(e,t,r),()=>fe.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let C=(0,w.useCallback)(()=>{let n=g.current,i=v.current;!n||!i||i.session!==e||i.path!==t||(i.root??void 0)!==(r??void 0)||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus())},[e,t,r]),pe=(0,w.useCallback)(e=>{g.current=e,Ut(e,{onSave:()=>fe.current()}),C()},[C]);(0,w.useEffect)(()=>{C()},[n,u,C]);let me=(0,w.useCallback)(()=>{le()},[le]),he=(0,w.useCallback)(()=>{!u||pt(s)?.phase!==`comparing`||ue(u.getValue(),u.getAlternativeVersionId())},[u,s,ue]),ge=(0,w.useCallback)(e=>{ot(s,e)},[s]),_e,ve=null;c.data?.binary?_e=`binary`:c.error?c.error instanceof ae&&c.error.status===413?_e=`too-large`:(_e=`error`,ve=c.error instanceof Error?c.error.message:`Failed to load file`):_e=u?`ready`:`loading`;let ye=S&&ne.savedElsewhere?`saved-elsewhere`:S&&ne.dirtyElsewhere?`dirty-elsewhere`:null;return{status:_e,errorMessage:ve,model:u,dirty:S,restoredNotice:p,discardRestore:me,peerBadge:ye,conflict:ie,takeDisk:le,keepMine:he,compare:se,comparisonReady:ge,save:de,onMount:pe}}function Kt(e,t,n,r){for(let i of e)if(Zt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function qt(e,t){return Yt(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function Jt(e){let t=Yt(e.originalStartLineNumber,e.originalEndLineNumber),n=Yt(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function Yt(e,t){return t===0?0:Math.max(0,t-e+1)}function Xt(e,t){if(e>t)return{startLineNumber:Math.max(1,t),endLineNumber:Math.max(1,t),kind:`deleted-after`};let n=Math.max(1,e);return{startLineNumber:n,endLineNumber:n,kind:`deleted-before`}}function Zt(e,t){let n=[];for(let r of e){let e=Yt(r.originalStartLineNumber,r.originalEndLineNumber),i=Yt(r.modifiedStartLineNumber,r.modifiedEndLineNumber);if(e===0&&i>0){n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedEndLineNumber,kind:`added`});continue}if(i===0&&e>0){n.push(Xt(r.modifiedStartLineNumber,t));continue}let a=Math.min(e,i);a>0&&n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedStartLineNumber+a-1,kind:`modified`}),i>a&&n.push({startLineNumber:r.modifiedStartLineNumber+a,endLineNumber:r.modifiedEndLineNumber,kind:`added`}),e>a&&n.push(Xt(r.modifiedStartLineNumber+i,t))}return n}var Qt=28,$t=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function en(e){if(e){for(let[t,n]of $t)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function tn({editor:e,original:t,modified:n,path:r}){let i=[],a=null,o=!1,s=t=>{try{e.changeViewZones(e=>e.removeZone(t))}catch{}},c=()=>{let e=a;e&&(a=null,e.frame!==null&&cancelAnimationFrame(e.frame),e.diffEditor&&(e.diffEditor.setModel(null),e.diffEditor.dispose()),s(e.zoneId))},l=e=>{let t=e.diffEditor;if(!t)return;let r=Math.max(1,Math.min(n.getLineCount(),e.change.modifiedStartLineNumber));t.getModifiedEditor().revealLineInCenter(r,Oe.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(Oe.EditorOption.lineHeight),d=document.createElement(`div`);d.className=`puddle-dirty-peek`;let f=document.createElement(`div`);f.className=`puddle-dirty-peek-header`;let p=document.createElement(`span`);p.className=`puddle-dirty-peek-title`,p.textContent=`${r.split(`/`).pop()??r} · Local changes against HEAD`;let m=document.createElement(`button`);m.type=`button`,m.className=`puddle-dirty-peek-close`,m.setAttribute(`aria-label`,`Close inline change`),m.title=`Close inline change`,m.textContent=`×`,m.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),c()}),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),c()});let h=document.createElement(`div`);h.className=`puddle-dirty-peek-editor`,f.append(p,m),d.append(f,h);let g=document.createElement(`div`);g.className=`puddle-dirty-peek-margin`;let _={afterLineNumber:qt(s,n.getLineCount()),heightInPx:Qt+Jt(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=Oe.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(Oe.EditorOption.fontFamily),fontSize:e.getOption(Oe.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==Oe.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=Kt(i,t,n.getLineCount(),en(e.target.element));r&&(e.event.preventDefault(),e.event.stopPropagation(),u(t,r))});return{update(t){if(i=t,!a)return;let r=a,o=Kt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=qt(o,n.getLineCount()),r.zone.heightInPx=Qt+Jt(o)*e.getOption(Oe.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var nn={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function rn(e,t,n,r){let i=xe(),a=o(e,t,{root:n,enabled:i.data!==void 0&&Ce(i.data.protocol)&&r!==null}),[s,c]=(0,w.useState)(null),l=(0,w.useCallback)(e=>{c(e)},[]);return(0,w.useEffect)(()=>{let e=a.data;if(!s||!r||!e||e.repository===null||e.ignored||e.binary)return;let n=document.createElement(`div`);n.className=`puddle-hidden-diff-controller`,document.body.appendChild(n);let i=Oe.createModel(e.exists?e.content??``:``,r.getLanguageId()),o=Oe.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();o.setModel({original:i,modified:r});let l=tn({editor:s,original:i,modified:r,path:t}),u=()=>{let e=o.getLineChanges();e&&(l.update(e),c.set(Zt(e,r.getLineCount()).map(e=>({range:new Ee(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:nn[e.kind]}}))))},d=o.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),o.setModel(null),o.dispose(),i.dispose(),n.remove()}},[s,r,a.data]),l}function an({message:e,session:t,path:n,root:r,download:i}){return(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,T.jsx)(`span`,{children:e}),i&&(0,T.jsxs)(`button`,{type:`button`,onClick:()=>void l(t,n,r).catch(e=>re.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,T.jsx)(s,{className:`size-4`}),`Download`]})]})}function on({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=Se(),l=Gt(e,t,n,r,{focused:i}),u=S(e,t,r),d=rn(e,t,r,l.model),f=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[p,m]=(0,w.useState)(null),h=(0,w.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),g=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,w.useEffect)(()=>{if(!(!p||!l.model||g))return Bt(p,{channel:s,target:h,driver:a,receiver:o},Oe.ScrollType.Immediate)},[p,l.model,g,s,h,a,o]),(0,w.useEffect)(()=>{let e=l.model;e&&Oe.setModelMarkers(e,`puddle-compilation`,u.map(t=>{let n=Math.min(t.line,e.getLineCount()),r=e.getLineMaxColumn(n),i=Math.min(t.column??1,r),a=t.end_line??n,o=Math.max(n,Math.min(a,e.getLineCount())),s=e.getLineMaxColumn(o),c=Math.min(t.end_column??(t.column?i+1:s),s);return{severity:t.severity===`error`?Te.Error:t.severity===`warning`?Te.Warning:Te.Info,message:t.message,source:`Puddle compilation`,startLineNumber:n,startColumn:i,endLineNumber:o,endColumn:Math.max(i,c)}}))},[l.model,u]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,T.jsx)(_t,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,T.jsx)(an,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,T.jsx)(an,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,T.jsx)(an,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let _=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,T.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,T.jsx)(`span`,{children:`Restored unsaved changes`}),(0,T.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),_&&(0,T.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:_}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,T.jsx)(Ne,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),d(e),m(e)},loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:f,fontSize:c.editorFontSize,...ht(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function sn({children:e}){return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function cn(e,t){let n=(0,w.useRef)(t);n.current=t,(0,w.useEffect)(()=>(je(e),()=>{n.current?.(),Ie(e)}),[e])}function ln(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function un({session:e,refName:t,path:n,content:r}){let i=Se(),a=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,T.jsx)(Ne,{path:ln(`puddle-view`,e,t,n),defaultValue:r,theme:Me,loading:(0,T.jsx)(sn,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,...ht(i.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function dn({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=u(e,t,n,{root:r,enabled:!i}),o=d(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,T.jsx)(sn,{children:`…`}):s.error?(0,T.jsx)(sn,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,T.jsx)(sn,{children:`Binary file — deleted`}):(0,T.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,T.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(un,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function fn({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=Se(),c=Gt(e,n,null,i,{focused:o}),l=u(e,t,r,{root:i,enabled:!a}),f=d(e,r,{root:i,enabled:a}),p=a?f:l,m=(0,w.useRef)(null);cn(Be(e,n,i),()=>{let e=m.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),m.current=null});let h=(0,w.useRef)(c.save);h.current=c.save;let g=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),_=p.error instanceof ae&&p.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,T.jsx)(_t,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||p.data?.binary?(0,T.jsx)(sn,{children:`Binary file`}):c.status===`too-large`?(0,T.jsx)(sn,{children:`File too large to show`}):c.status===`error`?(0,T.jsx)(sn,{children:c.errorMessage??`Failed to load file`}):_||a&&f.data&&!f.data.exists?(0,T.jsx)(on,{session:e,path:n,reveal:null,root:i,focused:o}):p.isPending||!c.model?(0,T.jsx)(sn,{children:`…`}):p.error?(0,T.jsx)(sn,{children:p.error instanceof Error?p.error.message:`Failed to load base`}):(0,T.jsx)(Le,{modifiedModelPath:c.model.uri.toString(),originalModelPath:ln(`puddle-base`,e,`${t}:${i??``}`,r),original:p.data.content??``,language:c.model.getLanguageId(),theme:Me,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(sn,{children:`…`}),onMount:e=>{m.current=e,e.onDidDispose(()=>{m.current=null}),e.getModifiedEditor().addCommand(De.CtrlCmd|ke.KeyS,()=>h.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:g,fontSize:s.editorFontSize,...ht(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function pn({session:e,against:t,entry:n,root:r}){let i=Se(),a=n.old_path??n.path,o=u(e,t,a,{root:r,enabled:n.status!==`added`}),s=d(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,T.jsx)(dn,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,T.jsx)(sn,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,T.jsx)(sn,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,T.jsx)(sn,{children:`Binary file`}):n.status===`added`?(0,T.jsx)(un,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,T.jsx)(Le,{originalModelPath:ln(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:ln(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:Me,loading:(0,T.jsx)(sn,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,...ht(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,T.jsx)(sn,{children:`Failed to load HEAD content`})}function mn({session:e,path:t,root:n,focused:r}){return cn(Be(e,t,n)),(0,T.jsx)(on,{session:e,path:t,reveal:null,root:n,focused:r})}function hn({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,T.jsx)(pn,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,T.jsx)(mn,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,T.jsx)(dn,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,T.jsx)(fn,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function gn({session:e,sha:t,path:n,root:r}){let i=u(e,t,n,{root:r});return i.isPending?(0,T.jsx)(sn,{children:`…`}):i.error?(0,T.jsx)(sn,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,T.jsx)(sn,{children:`Binary file`}):(0,T.jsx)(un,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function _n({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=Se(),l=(0,w.useRef)(null),u=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,w.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,T.jsx)(Le,{originalModelPath:ln(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:ln(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:Me,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,T.jsx)(sn,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,...ht(c.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function vn({session:e,sha:t,path:n,basePath:r,root:i}){let a=u(e,`${t}^`,r,{root:i}),o=u(e,t,n,{root:i});return a.error instanceof ae&&a.error.status===404?(0,T.jsx)(gn,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,T.jsx)(sn,{children:`…`}):a.error?(0,T.jsx)(sn,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,T.jsx)(sn,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,T.jsx)(sn,{children:`Binary file`}):(0,T.jsx)(_n,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function yn({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(m(n.status,r)){case`added`:return(0,T.jsx)(gn,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,T.jsx)(dn,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,T.jsx)(vn,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function bn({session:e,sha:t,path:n,root:r}){let i=c(e,t,r);if(i.isPending)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,T.jsx)(`div`,{className:`h-full`,children:(0,T.jsx)(yn,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,T.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,T.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function xn({session:e,path:t,root:n,area:r,focused:i=!0}){let o=a(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(o.isPending)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(o.error)return(0,T.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load diff`});let s=o.data.entries.find(e=>e.path===t);return s?(0,T.jsx)(`div`,{className:`h-full`,children:(0,T.jsx)(hn,{session:e,against:o.data.against,entry:s,root:n,area:r,focused:i})}):(0,T.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,T.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Sn=800;function Cn({name:e}){let t=Se(),n=fe(),r=h(n,e),i=be(),a=he(`editor.save`),o=(0,w.useRef)(null),s=(0,w.useRef)(null),c=(0,w.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,w.useEffect)(()=>{if(n===null)return;let t=ye(t=>{y(n,e,t).catch(e=>re.error(e instanceof Error?e.message:`Draft not saved`))},Sn);return s.current=t,()=>{t.flush(),s.current=null}},[n,e]),n===null)return null;if(r.error)return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load the draft`});if(r.data===void 0)return(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let l=()=>{let t=o.current;t&&(s.current?.flush(),p({name:e,content:t.getValue()}))};return(0,T.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,T.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,a,` saves it into one`]}),(0,T.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,T.jsx)(Ne,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:Me,keepCurrentModel:!1,loading:(0,T.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{o.current=t,b(e,t.getValue()),Ut(t,{onSave:l})},onChange:t=>{let r=t??``;b(e,r),_(i,n,e,r),s.current?.(r)},options:{automaticLayout:!0,fontFamily:c,fontSize:t.editorFontSize,...ht(t.editorTabSize),minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function wn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Tn(e){if(Array.isArray(e))return e}function En(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Dn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function On(e,t){return Tn(e)||En(e,t)||kn(e,t)||Dn()}function kn(e,t){if(e){if(typeof e==`string`)return wn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wn(e,t):void 0}}var An=Object.entries,jn=Object.setPrototypeOf,Mn=Object.isFrozen,Nn=Object.getPrototypeOf,Pn=Object.getOwnPropertyDescriptor,Fn=Object.freeze,In=Object.seal,Ln=Object.create,Rn=typeof Reflect<`u`&&Reflect,zn=Rn.apply,Bn=Rn.construct;Fn||=function(e){return e},In||=function(e){return e},zn||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Bn||=function(e){return new e(...[...arguments].slice(1))};var Vn=sr(Array.prototype.forEach),Hn=sr(Array.prototype.lastIndexOf),Un=sr(Array.prototype.pop),Wn=sr(Array.prototype.push),Gn=sr(Array.prototype.splice),Kn=Array.isArray,qn=sr(String.prototype.toLowerCase),Jn=sr(String.prototype.toString),Yn=sr(String.prototype.match),Xn=sr(String.prototype.replace),Zn=sr(String.prototype.indexOf),Qn=sr(String.prototype.trim),$n=sr(Number.prototype.toString),er=sr(Boolean.prototype.toString),tr=typeof BigInt>`u`?null:sr(BigInt.prototype.toString),nr=typeof Symbol>`u`?null:sr(Symbol.prototype.toString),rr=sr(Object.prototype.hasOwnProperty),ir=sr(Object.prototype.toString),ar=sr(RegExp.prototype.test),or=cr(TypeError);function sr(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return zn(e,t,n)}}function cr(e){return function(){return Bn(e,[...arguments])}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qn;if(jn&&jn(e,null),!Kn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Mn(t)||(t[r]=e),i=e)}e[i]=!0}return e}function lr(e){for(let t=0;t<e.length;t++)rr(e,t)||(e[t]=null);return e}function ur(e){let t=Ln(null);for(let r of An(e)){var n=On(r,2);let i=n[0],a=n[1];rr(e,i)&&(Kn(a)?t[i]=lr(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=ur(a):t[i]=a)}return t}function dr(e){switch(typeof e){case`string`:return e;case`number`:return $n(e);case`boolean`:return er(e);case`bigint`:return tr?tr(e):`0`;case`symbol`:return nr?nr(e):`Symbol()`;case`undefined`:return ir(e);case`function`:case`object`:{if(e===null)return ir(e);let t=e,n=fr(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:ir(e)}return ir(e)}default:return ir(e)}}function fr(e,t){for(;e!==null;){let n=Pn(e,t);if(n){if(n.get)return sr(n.get);if(typeof n.value==`function`)return sr(n.value)}e=Nn(e)}function n(){return null}return n}function pr(e){try{return ar(e,``),!0}catch{return!1}}var mr=Fn(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),hr=Fn(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),gr=Fn([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),_r=Fn([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),vr=Fn(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),yr=Fn([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),br=Fn([`#text`]),xr=Fn(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Sr=Fn(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Cr=Fn(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),wr=Fn([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Tr=In(/{{[\w\W]*|^[\w\W]*}}/g),Er=In(/<%[\w\W]*|^[\w\W]*%>/g),Dr=In(/\${[\w\W]*/g),Or=In(/^data-[\-\w.\u00B7-\uFFFF]+$/),kr=In(/^aria-[\-\w]+$/),Ar=In(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),jr=In(/^(?:\w+script|data):/i),Mr=In(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nr=In(/^html$/i),Pr=In(/^[a-z][.\w]*(-[.\w]+)+$/i),Fr=In(/<[/\w!]/g),Ir=In(/<[/\w]/g),Lr=In(/<\/no(script|embed|frames)/i),Rr=In(/\/>/i),zr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Br=function(){return typeof window>`u`?null:window},Vr=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Hr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ur=function(e,t,n,r){return rr(e,t)&&Kn(e[t])?E(r.base?ur(r.base):{},e[t],r.transform):n};function Wr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Br(),t=e=>Wr(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==zr.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=fr(d,`cloneNode`),p=fr(d,`remove`),m=fr(d,`nextSibling`),h=fr(d,`childNodes`),g=fr(d,`parentNode`),_=fr(d,`shadowRoot`),v=fr(d,`attributes`),y=o&&o.prototype?fr(o.prototype,`nodeType`):null,b=o&&o.prototype?fr(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,ee,te=!1,ne=0,re=function(){if(ne>0)throw or(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ie=function(e){re(),ne++;try{return x.createHTML(e)}finally{ne--}},ae=function(e){re(),ne++;try{return x.createScriptURL(e)}finally{ne--}},oe=function(){return te||=(ee=Vr(u,i),!0),ee},se=n,ce=se.implementation,le=se.createNodeIterator,ue=se.createDocumentFragment,de=se.getElementsByTagName,fe=r.importNode,C=Hr();t.isSupported=typeof An==`function`&&typeof g==`function`&&ce&&ce.createHTMLDocument!==void 0;let pe=Tr,me=Er,he=Dr,ge=Or,_e=kr,ve=jr,ye=Mr,be=Pr,xe=Ar,Se=null,Ce=E({},[...mr,...hr,...gr,...vr,...br]),we=null,Te=E({},[...xr,...Sr,...Cr,...wr]),Ee=Object.seal(Ln(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),De=null,Oe=null,ke=Object.seal(Ln(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ae=!0,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!0,Ie=!1,Le=!1,Re=null,ze=null,Be=!1,Ve=!1,He=!1,Ue=!1,We=!0,Ge=!1,Ke=`user-content-`,qe=!0,Je=!1,Ye={},Xe=null,Ze=E({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),w=null,Qe=E({},[`audio`,`video`,`img`,`source`,`image`,`track`]),$e=null,et=E({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),tt=`http://www.w3.org/1998/Math/MathML`,nt=`http://www.w3.org/2000/svg`,rt=`http://www.w3.org/1999/xhtml`,it=rt,at=!1,ot=null,st=E({},[tt,nt,rt],Jn),ct=Fn([`mi`,`mo`,`mn`,`ms`,`mtext`]),lt=E({},ct),ut=Fn([`annotation-xml`]),dt=E({},ut),ft=E({},[`title`,`style`,`font`,`a`,`script`]),pt=null,mt=[`application/xhtml+xml`,`text/html`],ht=null,T=null,gt=n.createElement(`form`),_t=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(T&&T===e)return;(!e||typeof e!=`object`)&&(e={}),e=ur(e),pt=mt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ht=pt===`application/xhtml+xml`?Jn:qn,Se=Ur(e,`ALLOWED_TAGS`,Ce,{transform:ht}),we=Ur(e,`ALLOWED_ATTR`,Te,{transform:ht}),ot=Ur(e,`ALLOWED_NAMESPACES`,st,{transform:Jn}),$e=Ur(e,`ADD_URI_SAFE_ATTR`,et,{transform:ht,base:et}),w=Ur(e,`ADD_DATA_URI_TAGS`,Qe,{transform:ht,base:Qe}),Xe=Ur(e,`FORBID_CONTENTS`,Ze,{transform:ht}),De=Ur(e,`FORBID_TAGS`,ur({}),{transform:ht}),Oe=Ur(e,`FORBID_ATTR`,ur({}),{transform:ht}),Ye=rr(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?ur(e.USE_PROFILES):e.USE_PROFILES:!1,Ae=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pe=e.SAFE_FOR_TEMPLATES||!1,Fe=e.SAFE_FOR_XML!==!1,Ie=e.WHOLE_DOCUMENT||!1,Ve=e.RETURN_DOM||!1,He=e.RETURN_DOM_FRAGMENT||!1,Ue=e.RETURN_TRUSTED_TYPE||!1,Be=e.FORCE_BODY||!1,We=e.SANITIZE_DOM!==!1,Ge=e.SANITIZE_NAMED_PROPS||!1,qe=e.KEEP_CONTENT!==!1,Je=e.IN_PLACE||!1,xe=pr(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Ar,it=typeof e.NAMESPACE==`string`?e.NAMESPACE:rt,lt=rr(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?ur(e.MATHML_TEXT_INTEGRATION_POINTS):E({},ct),dt=rr(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?ur(e.HTML_INTEGRATION_POINTS):E({},ut);let t=rr(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?ur(e.CUSTOM_ELEMENT_HANDLING):Ln(null);if(Ee=Ln(null),rr(t,`tagNameCheck`)&&_t(t.tagNameCheck)&&(Ee.tagNameCheck=t.tagNameCheck),rr(t,`attributeNameCheck`)&&_t(t.attributeNameCheck)&&(Ee.attributeNameCheck=t.attributeNameCheck),rr(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Ee.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),In(Ee),Pe&&(je=!1),He&&(Ve=!0),Ye&&(Se=E({},br),we=Ln(null),Ye.html===!0&&(E(Se,mr),E(we,xr)),Ye.svg===!0&&(E(Se,hr),E(we,Sr),E(we,wr)),Ye.svgFilters===!0&&(E(Se,gr),E(we,Sr),E(we,wr)),Ye.mathMl===!0&&(E(Se,vr),E(we,Cr),E(we,wr))),ke.tagCheck=null,ke.attributeCheck=null,rr(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?ke.tagCheck=e.ADD_TAGS:Kn(e.ADD_TAGS)&&(Se===Ce&&(Se=ur(Se)),E(Se,e.ADD_TAGS,ht))),rr(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?ke.attributeCheck=e.ADD_ATTR:Kn(e.ADD_ATTR)&&(we===Te&&(we=ur(we)),E(we,e.ADD_ATTR,ht))),rr(e,`ADD_URI_SAFE_ATTR`)&&Kn(e.ADD_URI_SAFE_ATTR)&&E($e,e.ADD_URI_SAFE_ATTR,ht),rr(e,`FORBID_CONTENTS`)&&Kn(e.FORBID_CONTENTS)&&(Xe===Ze&&(Xe=ur(Xe)),E(Xe,e.FORBID_CONTENTS,ht)),rr(e,`ADD_FORBID_CONTENTS`)&&Kn(e.ADD_FORBID_CONTENTS)&&(Xe===Ze&&(Xe=ur(Xe)),E(Xe,e.ADD_FORBID_CONTENTS,ht)),qe&&(Se[`#text`]=!0),Ie&&E(Se,[`html`,`head`,`body`]),Se.table&&(E(Se,[`tbody`]),delete De.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw or(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw or(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ie(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=oe()),x&&typeof S==`string`&&(S=ie(``)));Fn&&Fn(e),T=e},yt=E({},[...hr,...gr,..._r]),bt=E({},[...vr,...yr]),xt=function(e,t,n){return t.namespaceURI===rt?e===`svg`:t.namespaceURI===tt?e===`svg`&&(n===`annotation-xml`||lt[n]):!!yt[e]},St=function(e,t,n){return t.namespaceURI===rt?e===`math`:t.namespaceURI===nt?e===`math`&&dt[n]:!!bt[e]},Ct=function(e,t,n){return t.namespaceURI===nt&&!dt[n]||t.namespaceURI===tt&&!lt[n]?!1:!bt[e]&&(ft[e]||!yt[e])},wt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:it,tagName:`template`});let n=qn(e.tagName),r=qn(t.tagName);return ot[e.namespaceURI]?e.namespaceURI===nt?xt(n,t,r):e.namespaceURI===tt?St(n,t,r):e.namespaceURI===rt?Ct(n,t,r):!!(pt===`application/xhtml+xml`&&ot[e.namespaceURI]):!1},Tt=function(e){Wn(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw or(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Et=function(e){kt(e);let t=h(e);if(t){let e=[];Vn(t,t=>{Wn(e,t)}),Vn(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},Dt=function(e,n){try{Wn(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Wn(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ve||He)try{Tt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ot=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||we[ht(i)]))try{e.removeAttribute(i)}catch{}}},kt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===zr.element&&Ot(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},At=function(e){if(!Fe)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===zr.processingInstruction||n===zr.comment&&ar(Ir,e.data)){try{p(e)}catch{}continue}if(n===zr.element){let t=e,n=ht(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},jt=function(e){let t=null,r=null;if(Be)e=`<remove></remove>`+e;else{let t=Yn(e,/^[\r\n\t ]+/);r=t&&t[0]}pt===`application/xhtml+xml`&&it===rt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?ie(e):e;if(it===rt)try{t=new l().parseFromString(i,pt)}catch{}if(!t||!t.documentElement){t=ce.createDocument(it,`template`,null);try{t.documentElement.innerHTML=at?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),it===rt?de.call(t,Ie?`html`:`body`)[0]:Ie?t.documentElement:a},Mt=function(e){return le.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Nt=function(e){return e=Xn(e,pe,` `),e=Xn(e,me,` `),e=Xn(e,he,` `),e},Pt=function(e){e.normalize();let t=le.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=Nt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&Vn(r,e=>{It(e.content)&&Pt(e.content)})},Ft=function(e){let t=b?b(e):null;return typeof t!=`string`||ht(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},It=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===zr.documentFragment}catch{return!1}},Lt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Rt(e,n,r){e.length!==0&&Vn(e,e=>{e.call(t,n,r,T)})}let zt=function(e,t){return!!(Fe&&e.hasChildNodes()&&!Lt(e.firstElementChild)&&ar(Fr,e.textContent)&&ar(Fr,e.innerHTML)||Fe&&e.namespaceURI===rt&&t===`style`&&Lt(e.firstElementChild)||e.nodeType===zr.processingInstruction||Fe&&e.nodeType===zr.comment&&ar(Ir,e.data))},Bt=function(e,t){if(!De[t]&&Wt(t)&&(Ee.tagNameCheck instanceof RegExp&&ar(Ee.tagNameCheck,t)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(t)))return!1;if(qe&&!Xe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Je?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return Tt(e),!0},Vt=function(e,n){if(Rt(C.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Ft(e))return Tt(e),!0;let r=ht(b?b(e):e.nodeName);if(Rt(C.uponSanitizeElement,e,{tagName:r,allowedTags:Se}),e!==n&&g(e)===null)return!0;if(zt(e,r))return Tt(e),!0;if(De[r]||!(ke.tagCheck instanceof Function&&ke.tagCheck(r))&&!Se[r]){let t=Bt(e,r);return t===!1&&Rt(C.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===zr.element&&!wt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&ar(Lr,e.innerHTML))return Tt(e),!0;if(Pe&&e.nodeType===zr.text){let n=Nt(e.textContent);e.textContent!==n&&(Wn(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Rt(C.afterSanitizeElements,e,null),!1},Ht=function(e,t,r){if(Oe[t]||Fe&&t===`patchsrc`||Fe&&t===`for`&&e!==`label`&&e!==`output`||We&&(t===`id`||t===`name`)&&(r in n||r in gt))return!1;let i=we[t]||ke.attributeCheck instanceof Function&&ke.attributeCheck(t,e);if(!(je&&ar(ge,t))&&!(Ae&&ar(_e,t))){if(!i){if(!(Wt(e)&&(Ee.tagNameCheck instanceof RegExp&&ar(Ee.tagNameCheck,e)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(e))&&(Ee.attributeNameCheck instanceof RegExp&&ar(Ee.attributeNameCheck,t)||Ee.attributeNameCheck instanceof Function&&Ee.attributeNameCheck(t,e))||t===`is`&&Ee.allowCustomizedBuiltInElements&&(Ee.tagNameCheck instanceof RegExp&&ar(Ee.tagNameCheck,r)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(r))))return!1}else if(!$e[t]&&!ar(xe,Xn(r,ye,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Zn(r,`data:`)===0&&w[e])&&!(Me&&!ar(ve,Xn(r,ye,``)))&&r)return!1}return!0},Ut=E({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Wt=function(e){return!Ut[qn(e)]&&ar(be,e)},Gt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ie(r);case`TrustedScriptURL`:return ae(r)}return r},Kt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ft(e)?Tt(e):Un(t.removed)}catch{Dt(n,e)}},qt=function(e){Rt(C.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ft(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0},r=t.length,i=ht(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=ht(o),u=c,d=o===`value`?u:Qn(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Rt(C.uponSanitizeAttribute,e,n),d=n.attrValue,Ge&&(l===`id`||l===`name`)&&Zn(d,Ke)!==0&&(Dt(o,e),d=Ke+d),Fe&&ar(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Dt(o,e);continue}if(l===`attributename`&&Yn(d,`href`)){Dt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){Dt(o,e);continue}if(!Ne&&ar(Rr,d)){Dt(o,e);continue}if(Pe&&(d=Nt(d)),!Ht(i,l,d)){Dt(o,e);continue}d=Gt(i,l,s,d),d!==u&&Kt(e,o,s,d)}}Rt(C.afterSanitizeAttributes,e,null)},Jt=function(e){let t=null,n=Mt(e);for(Rt(C.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Rt(C.uponSanitizeShadowNode,t,null),Vt(t,e),qt(t),It(t.content)&&Jt(t.content),(y?y(t):t.nodeType)===zr.element){let e=_(t);It(e)&&(Yt(e),Jt(e))}Rt(C.afterSanitizeShadowDOM,e,null)},Yt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Jt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===zr.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&ht(e)===`template`){let e=n.content;It(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);It(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(at=!e,at&&(e=`<!-->`),typeof e!=`string`&&!Lt(e)&&(e=dr(e),typeof e!=`string`))throw or(`dirty is not a string, aborting`);if(!t.isSupported)return e;Le?(Se=Re,we=ze):vt(n),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(Se=ur(Se)),C.uponSanitizeAttribute.length>0&&(we=ur(we)),t.removed=[];let c=Je&&typeof e!=`string`&&Lt(e);if(c){At(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=ht(t);if(!Se[n]||De[n])throw Et(e),or(`root node is forbidden and cannot be sanitized in-place`)}if(Ft(e))throw Et(e),or(`root node is clobbered and cannot be sanitized in-place`);try{Yt(e)}catch(t){throw Et(e),t}}else if(Lt(e))i=jt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===zr.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Yt(a);else{if(!Ve&&!Pe&&!Ie&&e.indexOf(`<`)===-1)return x&&Ue?ie(e):e;if(i=jt(e),!i)return Ve?null:Ue?S:``}i&&Be&&Tt(i.firstChild);let l=c?e:i,u=Mt(l);try{for(;o=u.nextNode();)Vt(o,l),qt(o),It(o.content)&&Jt(o.content)}catch(n){throw c&&(Et(e),Vn(t.removed,e=>{e.element&&kt(e.element)})),n}if(c)return Vn(t.removed,e=>{e.element&&kt(e.element)}),Pe&&Pt(e),e;if(Ve){if(Pe&&Pt(i),He)for(s=ue.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(we.shadowroot||we.shadowrootmode)&&(s=fe.call(r,s,!0)),s}let d=Ie?i.outerHTML:i.innerHTML;return Ie&&Se[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&ar(Nr,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
4
4
|
`+d),Pe&&(d=Nt(d)),x&&Ue?ie(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),Le=!0,Re=Se,ze=we},t.clearConfig=function(){T=null,Le=!1,Re=null,ze=null,x=ee,S=``},t.isValidAttribute=function(e,t,n){T||vt({});let r=ht(e),i=ht(t);return Ht(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&rr(C,e)&&Wn(C[e],t)},t.removeHook=function(e,t){if(rr(C,e)){if(t!==void 0){let n=Hn(C[e],t);return n===-1?void 0:Gn(C[e],n,1)[0]}return Un(C[e])}},t.removeHooks=function(e){rr(C,e)&&(C[e]=[])},t.removeAllHooks=function(){C=Hr()},t}var Gr=Wr(),Kr=0;function qr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!e.textContent||t?.closest(`script, style, noscript, [hidden], [aria-hidden="true"]`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=[],r=``,i;for(;i=t.nextNode();){let e=i.textContent??``,t=r.length;r+=e,n.push({node:i,start:t,end:r.length})}return{text:r,nodes:n}}function Jr(e,t){let n=t.find(t=>t.end>e.start),r=t.findLast(t=>t.start<e.end);if(!n||!r)return null;let i=document.createRange();return i.setStart(n.node,e.start-n.start),i.setEnd(r.node,e.end-r.start),i}var Yr=class{root;matchName=`puddle-find-${++Kr}-match`;activeName=`puddle-find-${Kr}-active`;style;signature=``;ranges=[];index=-1;limited=!1;constructor(e){this.root=e,this.style=document.createElement(`style`),this.style.textContent=`
|
|
5
5
|
::highlight(${this.matchName}) { background: var(--selection); }
|