@jxsuite/studio 5.7.0 → 6.0.0

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.
Files changed (74) hide show
  1. package/dist/chunks/{cf-account-picker-882a7ecm.js → cf-account-picker-bb2yq946.js} +2 -2
  2. package/dist/chunks/content-source-t0q184js.js +4 -0
  3. package/dist/chunks/{convert-to-repeater-grfep2w8.js → convert-to-repeater-vqkt7s3s.js} +2 -2
  4. package/dist/chunks/entry-commands-fxzgcc4k.js +4 -0
  5. package/dist/chunks/{extension-sections-dp8endhx.js → extension-sections-8beq9ac3.js} +2 -2
  6. package/dist/chunks/file-ops-2n77759h.js +4 -0
  7. package/dist/chunks/files-fjy7zpxt.js +4 -0
  8. package/dist/chunks/{format-host-e2pjvd25.js → format-host-wj3mf3n8.js} +2 -2
  9. package/dist/chunks/fs-events-7kcgn4e9.js +4 -0
  10. package/dist/chunks/git-panel-7z2mpt2d.js +4 -0
  11. package/dist/chunks/{grid-view-5amhg604.js → grid-view-ca10def6.js} +2 -2
  12. package/dist/chunks/{iframe-host-t819mcg5.js → iframe-host-a0zjd6xp.js} +2 -2
  13. package/dist/chunks/{layers-4bsr82wz.js → layers-p677nrh5.js} +2 -2
  14. package/dist/chunks/layers-panel-y4w1dq90.js +4 -0
  15. package/dist/chunks/media-picker-xg7yjpz9.js +4 -0
  16. package/dist/chunks/menu-fpekzj6w.js +4 -0
  17. package/dist/chunks/publish-panel-xtbfgg2r.js +4 -0
  18. package/dist/chunks/quick-search-d3a6m7j3.js +4 -0
  19. package/dist/chunks/right-panel-31vbk5xp.js +4 -0
  20. package/dist/chunks/studio-1q6amtph.js +5 -0
  21. package/dist/chunks/{studio-56z7evx4.js → studio-3ck2a5c4.js} +2 -2
  22. package/dist/chunks/{studio-gh97gngt.js → studio-4fde4a0x.js} +2 -2
  23. package/dist/chunks/{studio-gfn1kpxj.js → studio-4jj9gme2.js} +3 -3
  24. package/dist/chunks/{studio-zpnk016a.js → studio-4m50vh74.js} +3 -3
  25. package/dist/chunks/{studio-dkn3x3hz.js → studio-4r0sjtx8.js} +2 -2
  26. package/dist/chunks/{studio-a7xqhc3n.js → studio-5d7wfmnp.js} +2 -2
  27. package/dist/chunks/{studio-ceb34dxj.js → studio-5gs9th4b.js} +2 -2
  28. package/dist/chunks/{studio-j6gnhvaa.js → studio-5vy2wfm5.js} +2 -2
  29. package/dist/chunks/{studio-spf2skgc.js → studio-7qvs7v0m.js} +2 -2
  30. package/dist/chunks/{studio-e6re3rk1.js → studio-84rtc120.js} +2 -2
  31. package/dist/chunks/{studio-nt06yybj.js → studio-8xcwewjq.js} +2 -2
  32. package/dist/chunks/{studio-cxt150pj.js → studio-aekhcdzw.js} +2 -2
  33. package/dist/chunks/{studio-222rqyyc.js → studio-bftp4n4b.js} +2 -2
  34. package/dist/chunks/{studio-xta2vxp6.js → studio-capk0583.js} +2 -2
  35. package/dist/chunks/{studio-wma2c6g8.js → studio-cbr9czkn.js} +2 -2
  36. package/dist/chunks/{studio-c9d3pxf7.js → studio-chdmwwzw.js} +2 -2
  37. package/dist/chunks/{studio-0k9mvpgj.js → studio-cp1gbff9.js} +2 -2
  38. package/dist/chunks/{studio-1x8x26k3.js → studio-cqmtbg2p.js} +2 -2
  39. package/dist/chunks/{studio-c6w3tq7t.js → studio-e47215hh.js} +2 -2
  40. package/dist/chunks/{studio-frb0qbf7.js → studio-fbx6twps.js} +2 -2
  41. package/dist/chunks/{studio-xk0z6msk.js → studio-fthwn4kf.js} +2 -2
  42. package/dist/chunks/{studio-0scebvb9.js → studio-g8dsj3d2.js} +2 -2
  43. package/dist/chunks/{studio-54g077x3.js → studio-ge5fqjth.js} +2 -2
  44. package/dist/chunks/{studio-p7c1agz0.js → studio-gjknvzam.js} +3 -3
  45. package/dist/chunks/{studio-mwxgyn9h.js → studio-hnvnfbdv.js} +3 -3
  46. package/dist/chunks/{studio-9mqfamps.js → studio-mk00zd5d.js} +2 -2
  47. package/dist/chunks/{studio-skzanb0k.js → studio-qa73881a.js} +2 -2
  48. package/dist/chunks/{studio-xry7tk3z.js → studio-rmn2dz59.js} +2 -2
  49. package/dist/chunks/{studio-eh0rac07.js → studio-rr4xkv81.js} +2 -2
  50. package/dist/chunks/{studio-f195h2hq.js → studio-tmeq6mjb.js} +2 -2
  51. package/dist/chunks/{studio-cvbkkfqb.js → studio-x5g1xk77.js} +2 -2
  52. package/dist/chunks/{studio-65fhspdd.js → studio-xg1942as.js} +2 -2
  53. package/dist/chunks/{studio-888knnkc.js → studio-xkfs0dp2.js} +2 -2
  54. package/dist/chunks/{studio-xy3tv3az.js → studio-zev8ssp1.js} +3 -3
  55. package/dist/chunks/{studio-tw7rre6s.js → studio-ztvcxm3w.js} +2 -2
  56. package/dist/chunks/{workspace-b69mgm0e.js → workspace-5vmgsagj.js} +2 -2
  57. package/dist/iframe-entry.js +3 -3
  58. package/dist/manifest.json +36 -36
  59. package/dist/studio.js +10 -10
  60. package/package.json +11 -11
  61. package/src/ui/schema-form.ts +6 -2
  62. package/dist/chunks/content-source-37x3vsap.js +0 -4
  63. package/dist/chunks/entry-commands-c5h3nqck.js +0 -4
  64. package/dist/chunks/file-ops-937cvqk6.js +0 -4
  65. package/dist/chunks/files-tznwe1p1.js +0 -4
  66. package/dist/chunks/fs-events-fv64ak3s.js +0 -4
  67. package/dist/chunks/git-panel-gb713ttc.js +0 -4
  68. package/dist/chunks/layers-panel-b6shnaax.js +0 -4
  69. package/dist/chunks/media-picker-ej0kdh1j.js +0 -4
  70. package/dist/chunks/menu-rtxf9chb.js +0 -4
  71. package/dist/chunks/publish-panel-bq36xcmj.js +0 -4
  72. package/dist/chunks/quick-search-zm00h9dh.js +0 -4
  73. package/dist/chunks/right-panel-pq2f71q3.js +0 -4
  74. package/dist/chunks/studio-693nhyky.js +0 -5
@@ -1,7 +1,7 @@
1
- import{te}from"./studio-ery42sqr.js";import{v,k}from"./studio-fqq890ap.js";import{un,rn}from"./studio-0k9mvpgj.js";import{rt,zt,T,R,An,Ct}from"./studio-spf2skgc.js";var S={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGithubAuth",$description:"The RFC 8628 device flow's waiting room: the code GitHub minted, the page to type it into, and a Cancel. A `jx-dialog`, so the platform owns modality, Escape, focus restoration and the backdrop — and it is the reason the dialog has no confirm button at all: the answer arrives from GitHub over a poll rather than from anything the reader can press here, so a primary button would be a control with nothing to do. Nothing in this document talks to GitHub: `github/github-auth.ts` keeps the client id, the poll loop, its failure budget and every report the three outcomes raise.",tagName:"jx-dialog",$props:{headline:"Sign in to GitHub",confirmLabel:"",cancelLabel:"Cancel",size:"sm"},attributes:{part:"github-auth"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"Four `.github-auth-*` rules in `styles/overlays.css` become the parts below, and two things in them do not travel. `.github-auth-dialog`'s `padding: 16px 0` was the card's own body padding drawn by hand, and `jx-dialog` already pads its body; `.github-auth-dialog p { font-size: 13px }` was a body size this surface picked for itself, and what the paragraphs now inherit is the dialog's own `--jx-text-md`. The `8px 0` margins go with them — the column is a flex column with a gap, so a margin between two rows would be a second opinion about the same space. The code keeps its 24px, which is above the token scale on purpose: it is a string the reader has to copy onto another screen, and reading it out loud is the whole job of this dialog.",'& [part="device"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",textAlign:"center"},'& [part="lede"], & [part="waiting"]':{margin:"0"},'& [part="code"]':{$description:"`<code>`, not a styled `<div>`: this is a literal string to be transcribed, and the element that says so is also the one a reader's own stylesheet and a screen reader's character-by-character mode already know about. It is this dialog's message, and the one string in it the reader must carry to another screen, so it opts back in to selection against the root's `user-select: none`. `all` rather than `text`: one click selects the whole code, so a copy never leaves a character behind.",userSelect:"all",fontFamily:"var(--font-mono)",fontSize:"24px",fontWeight:"700",letterSpacing:"2px",padding:"var(--jx-space-3) var(--jx-space-4)",background:"var(--hover-bg)",borderRadius:"var(--radius)"},'& [part="link"]':{$description:"The blue this carried as a `var(--accent, …)` fallback is gone: `--accent` is declared on `:root` in `styles/tokens.css`, so the fallback could only ever have painted when the token was missing — which is a theme fault to fix rather than a colour to hard-code.",color:"var(--accent)",textDecoration:"underline"},'& [part="waiting"]':{color:"var(--fg-dim)",fontStyle:"italic"}},children:[{tagName:"div",attributes:{part:"device"},children:[{tagName:"p",attributes:{part:"lede"},textContent:"Enter this code on GitHub to authorize Jx Studio:"},{tagName:"code",attributes:{part:"code"},textContent:"${state.userCode}"},{tagName:"a",attributes:{part:"link",href:"${state.verificationUri}",target:"_blank",rel:"noreferrer"},textContent:"Open ${state.verificationUri}"},{tagName:"p",attributes:{part:"waiting"},textContent:"Waiting for authorization…"}]}]};T("github-auth",S);function A(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(rt,zt("dialog","github-auth")),e.layer.append(t);let r=!1,u=()=>{if(r)return;r=!0,e.onClosed()},f=v({cancel:()=>{e.onCancel()},closed:u,userCode:e.userCode,verificationUri:e.verificationUri}),s=null,c=R("github-auth",f,t).then(async(o)=>{s=o;let n=o.root;if(r)return o.dispose(),n;if(await An(n),r)return n;return un(n),n});return{close(){let o=s?.root;if(o instanceof HTMLElement)rn(o);s?.dispose(),s=null,t.remove(),u()},host:t,ready:c}}var _="jx_github_token";function p(){return globalThis.__jxPlatform?.githubAuth??null}var g=null,C=!1;function E(e){g=e}function h1(){return g!==null||C||localStorage.getItem("jx_github_token")!==null}function p1(){return p()?"desktop":"browser"}function b(){return g??localStorage.getItem("jx_github_token")}function f1(){g=null,C=!1,localStorage.removeItem("jx_github_token"),p()?.signOut().catch(()=>{})}var H="Ov23liYVlMFpgjOEPXJH",O="github.auth",j="Source Control",N="git.signInToGithub",U=3,M="The request never reached GitHub. GitHub's device-flow endpoints send no CORS headers, so a "+"browser cannot call them directly — the desktop app can. A machine that is offline fails "+"identically, and the browser does not say which happened.";function D(e){k.error("Could not reach GitHub to sign in.",{action:N,detail:`${M}
1
+ import{te}from"./studio-ery42sqr.js";import{v,k}from"./studio-fqq890ap.js";import{un,rn}from"./studio-cp1gbff9.js";import{rt,zt,T,R,An,Ct}from"./studio-7qvs7v0m.js";var S={$schema:"https://jxsuite.com/schema/v1",$id:"StudioGithubAuth",$description:"The RFC 8628 device flow's waiting room: the code GitHub minted, the page to type it into, and a Cancel. A `jx-dialog`, so the platform owns modality, Escape, focus restoration and the backdrop — and it is the reason the dialog has no confirm button at all: the answer arrives from GitHub over a poll rather than from anything the reader can press here, so a primary button would be a control with nothing to do. Nothing in this document talks to GitHub: `github/github-auth.ts` keeps the client id, the poll loop, its failure budget and every report the three outcomes raise.",tagName:"jx-dialog",$props:{headline:"Sign in to GitHub",confirmLabel:"",cancelLabel:"Cancel",size:"sm"},attributes:{part:"github-auth"},oncancel:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/cancel"},value:[]}]},onclose:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/closed"},value:[]}]},style:{$description:"Four `.github-auth-*` rules in `styles/overlays.css` become the parts below, and two things in them do not travel. `.github-auth-dialog`'s `padding: 16px 0` was the card's own body padding drawn by hand, and `jx-dialog` already pads its body; `.github-auth-dialog p { font-size: 13px }` was a body size this surface picked for itself, and what the paragraphs now inherit is the dialog's own `--jx-text-md`. The `8px 0` margins go with them — the column is a flex column with a gap, so a margin between two rows would be a second opinion about the same space. The code keeps its 24px, which is above the token scale on purpose: it is a string the reader has to copy onto another screen, and reading it out loud is the whole job of this dialog.",'& [part="device"]':{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-3)",textAlign:"center"},'& [part="lede"], & [part="waiting"]':{margin:"0"},'& [part="code"]':{$description:"`<code>`, not a styled `<div>`: this is a literal string to be transcribed, and the element that says so is also the one a reader's own stylesheet and a screen reader's character-by-character mode already know about. It is this dialog's message, and the one string in it the reader must carry to another screen, so it opts back in to selection against the root's `user-select: none`. `all` rather than `text`: one click selects the whole code, so a copy never leaves a character behind.",userSelect:"all",fontFamily:"var(--font-mono)",fontSize:"24px",fontWeight:"700",letterSpacing:"2px",padding:"var(--jx-space-3) var(--jx-space-4)",background:"var(--hover-bg)",borderRadius:"var(--radius)"},'& [part="link"]':{$description:"The blue this carried as a `var(--accent, …)` fallback is gone: `--accent` is declared on `:root` in `styles/tokens.css`, so the fallback could only ever have painted when the token was missing — which is a theme fault to fix rather than a colour to hard-code.",color:"var(--accent)",textDecoration:"underline"},'& [part="waiting"]':{color:"var(--fg-dim)",fontStyle:"italic"}},children:[{tagName:"div",attributes:{part:"device"},children:[{tagName:"p",attributes:{part:"lede"},textContent:"Enter this code on GitHub to authorize Jx Studio:"},{tagName:"code",attributes:{part:"code"},textContent:"${state.userCode}"},{tagName:"a",attributes:{part:"link",href:"${state.verificationUri}",target:"_blank",rel:"noreferrer"},textContent:"Open ${state.verificationUri}"},{tagName:"p",attributes:{part:"waiting"},textContent:"Waiting for authorization…"}]}]};T("github-auth",S);function A(e){let t=document.createElement("div");t.style.pointerEvents="auto",t.setAttribute(rt,zt("dialog","github-auth")),e.layer.append(t);let r=!1,u=()=>{if(r)return;r=!0,e.onClosed()},f=v({cancel:()=>{e.onCancel()},closed:u,userCode:e.userCode,verificationUri:e.verificationUri}),s=null,c=R("github-auth",f,t).then(async(o)=>{s=o;let n=o.root;if(r)return o.dispose(),n;if(await An(n),r)return n;return un(n),n});return{close(){let o=s?.root;if(o instanceof HTMLElement)rn(o);s?.dispose(),s=null,t.remove(),u()},host:t,ready:c}}var _="jx_github_token";function p(){return globalThis.__jxPlatform?.githubAuth??null}var g=null,C=!1;function E(e){g=e}function h1(){return g!==null||C||localStorage.getItem("jx_github_token")!==null}function p1(){return p()?"desktop":"browser"}function b(){return g??localStorage.getItem("jx_github_token")}function f1(){g=null,C=!1,localStorage.removeItem("jx_github_token"),p()?.signOut().catch(()=>{})}var H="Ov23liYVlMFpgjOEPXJH",O="github.auth",j="Source Control",N="git.signInToGithub",U=3,M="The request never reached GitHub. GitHub's device-flow endpoints send no CORS headers, so a "+"browser cannot call them directly — the desktop app can. A machine that is offline fails "+"identically, and the browser does not say which happened.";function D(e){k.error("Could not reach GitHub to sign in.",{action:N,detail:`${M}
2
2
 
3
3
  ${te(e)}`,key:O,source:j})}function y(e,t){k.warn(e,{action:N,detail:t,key:O,source:j})}async function Y(){let e;try{e=await fetch("https://github.com/login/device/code",{body:JSON.stringify({client_id:H,scope:"repo"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})}catch(t){return D(t),null}if(!e.ok)return y("GitHub refused to start the sign-in.",`GitHub answered ${e.status}${e.statusText?` ${e.statusText}`:""}.`),null;return await e.json()}async function Cw(){let e=b();if(e)return e;let t=p();if(t)try{let{token:o}=await t.signIn();return E(o),o}catch(o){return y("GitHub sign-in was not completed.",te(o)),null}let r=await Y();if(!r)return null;let{device_code:u,user_code:f,verification_uri:s,interval:c=5}=r;return new Promise((o)=>{let n=!1,a=null,m=0,w=!1,I=(l)=>{if(w)return;if(w=!0,n=!0,a)clearTimeout(a),a=null;o(l)},x=!1,G=()=>{if(x)return;x=!0,L.close()},d=(l)=>{I(l),G()},h=async()=>{if(n)return;try{let i=await(await fetch("https://github.com/login/oauth/access_token",{body:JSON.stringify({client_id:H,device_code:u,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"})).json();if(m=0,i.access_token){localStorage.setItem(_,i.access_token),d(i.access_token);return}if(i.error==="authorization_pending"){a=setTimeout(h,c*1000);return}if(i.error==="slow_down"){a=setTimeout(h,(c+5)*1000);return}y("GitHub sign-in was not completed.",i.error==="access_denied"?"The authorization was declined on GitHub.":i.error==="expired_token"?"The device code expired before it was entered.":`GitHub answered "${i.error??"an unrecognised response"}".`),d(null)}catch(l){if(m+=1,m>=U){D(l),d(null);return}a=setTimeout(h,c*1000)}},L=A({layer:Ct("dialog"),onCancel:()=>{G()},onClosed:()=>{d(null)},userCode:f,verificationUri:s});a=setTimeout(h,c*1000)})}
4
4
  export{h1,p1,f1,Cw};
5
5
 
6
6
  //# debugId=1B7FC845BC721E9264756E2164756E21
7
- //# sourceMappingURL=studio-54g077x3.js.map
7
+ //# sourceMappingURL=studio-ge5fqjth.js.map
@@ -1,9 +1,9 @@
1
- import{$v}from"./studio-0k9mvpgj.js";import{v}from"./studio-fqq890ap.js";import{Nl,Cv,u}from"./studio-cvbkkfqb.js";import{Di,qo,y}from"./studio-zpnk016a.js";import{st}from"./studio-pwqfmt4p.js";import{lt,bi,Il,Ou,hr,kC,IC}from"./studio-ceb34dxj.js";import{D,Lc}from"./studio-tp642n5g.js";import{T,R}from"./studio-spf2skgc.js";import{me}from"./studio-0bbxhhce.js";var qg={$sections:[{label:"Headings",elements:[{tag:"h1",text:"Code Is Poetry"},{tag:"h2",text:"Code Is Poetry"},{tag:"h3",text:"Code Is Poetry"},{tag:"h4",text:"Code Is Poetry"},{tag:"h5",text:"Code Is Poetry"},{tag:"h6",text:"Code Is Poetry"}]},{label:"Paragraph",elements:[{tag:"p",text:"In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing."}]},{label:"List",elements:[{tag:"ul",children:[{tag:"li",text:"Alice."},{tag:"li",text:"The White Rabbit."},{tag:"li",text:"The Cheshire Cat."},{tag:"li",text:"The Mad Hatter."},{tag:"li",text:"The Queen of Hearts."}]},{tag:"ol",children:[{tag:"li",text:"First item"},{tag:"li",text:"Second item"},{tag:"li",text:"Third item"}]}]},{label:"Quote",elements:[{tag:"blockquote",children:[{tag:"p",text:"In quoting others, we cite ourselves.",style:"font-size:1.25em;font-style:italic"},{tag:"p",text:"— Julio Cortázar"}]}]},{label:"Code",elements:[{tag:"pre",children:[{tag:"code",text:`// A "block" is the abstract term used
1
+ import{$v}from"./studio-cp1gbff9.js";import{v}from"./studio-fqq890ap.js";import{Nl,Cv,u}from"./studio-x5g1xk77.js";import{Di,qo,y}from"./studio-4m50vh74.js";import{st}from"./studio-pwqfmt4p.js";import{lt,bi,Il,Ou,hr,kC,IC}from"./studio-5gs9th4b.js";import{D,Lc}from"./studio-tp642n5g.js";import{T,R}from"./studio-7qvs7v0m.js";import{me}from"./studio-0bbxhhce.js";var qg={$sections:[{label:"Headings",elements:[{tag:"h1",text:"Code Is Poetry"},{tag:"h2",text:"Code Is Poetry"},{tag:"h3",text:"Code Is Poetry"},{tag:"h4",text:"Code Is Poetry"},{tag:"h5",text:"Code Is Poetry"},{tag:"h6",text:"Code Is Poetry"}]},{label:"Paragraph",elements:[{tag:"p",text:"In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing."}]},{label:"List",elements:[{tag:"ul",children:[{tag:"li",text:"Alice."},{tag:"li",text:"The White Rabbit."},{tag:"li",text:"The Cheshire Cat."},{tag:"li",text:"The Mad Hatter."},{tag:"li",text:"The Queen of Hearts."}]},{tag:"ol",children:[{tag:"li",text:"First item"},{tag:"li",text:"Second item"},{tag:"li",text:"Third item"}]}]},{label:"Quote",elements:[{tag:"blockquote",children:[{tag:"p",text:"In quoting others, we cite ourselves.",style:"font-size:1.25em;font-style:italic"},{tag:"p",text:"— Julio Cortázar"}]}]},{label:"Code",elements:[{tag:"pre",children:[{tag:"code",text:`// A "block" is the abstract term used
2
2
  // to describe units of markup that
3
3
  // when composed together, form the
4
4
  // content or layout of a page.
5
- registerBlockType( name, settings );`}]}]},{label:"Inline",elements:[{tag:"a",text:"Visit the documentation",attributes:{href:"#"}},{tag:"strong",text:"Bold text emphasis"},{tag:"em",text:"Italic text emphasis"},{tag:"small",text:"Fine print and legal text"},{tag:"mark",text:"Highlighted text"},{tag:"code",text:"const x = 42;"},{tag:"abbr",text:"HTML",attributes:{title:"HyperText Markup Language"}},{tag:"sub",text:"subscript"},{tag:"sup",text:"superscript"}]},{label:"Form",elements:[{tag:"input",attributes:{type:"text",placeholder:"Enter text…"}},{tag:"button",text:"Click Me"},{tag:"select",children:[{tag:"option",text:"Option 1"},{tag:"option",text:"Option 2"},{tag:"option",text:"Option 3"}]},{tag:"textarea",attributes:{placeholder:"Enter longer text…",rows:"3"}}]},{label:"Table",elements:[{tag:"table",children:[{tag:"thead",children:[{tag:"tr",children:[{tag:"th",text:"Name"},{tag:"th",text:"Role"},{tag:"th",text:"Status"}]}]},{tag:"tbody",children:[{tag:"tr",children:[{tag:"td",text:"Alice"},{tag:"td",text:"Developer"},{tag:"td",text:"Active"}]},{tag:"tr",children:[{tag:"td",text:"Bob"},{tag:"td",text:"Designer"},{tag:"td",text:"Away"}]},{tag:"tr",children:[{tag:"td",text:"Carol"},{tag:"td",text:"Manager"},{tag:"td",text:"Active"}]}]}]}]},{label:"Interactive",elements:[{tag:"details",attributes:{open:""},children:[{tag:"summary",text:"Click to expand details"},{tag:"p",text:"Additional detail content revealed when the disclosure widget is toggled open."}]}]},{label:"Media",elements:[{tag:"img",attributes:{alt:"Placeholder image"},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"video",attributes:{controls:""},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"audio",attributes:{controls:""},style:"width:100%"}]}],$variables:{color:{label:"Color",prefix:"--color-",placeholder:"#007acc"},font:{label:"Font",prefix:"--font-",placeholder:"system-ui, sans-serif"},size:{label:"Size",prefix:"--size-",placeholder:"16px"},other:{label:"Other",prefix:"--",placeholder:"value"}}};var O={$schema:"https://jxsuite.com/schema/v1",$id:"StudioStylebookChrome",$description:"The bar across the top of the Project Styles canvas: the filter that narrows the specimen catalogue, and the toggle that reduces it to the elements this file has already styled. Both are shell state rather than document state — the adapter owns which — and the two names come in as values, because the surface is called Project Styles and the canvas view it draws is the wire word `stylebook`; nothing a reader sees here may be spelled from that. **The bar IS the kit's toolbar now.** It used to write `role=\"toolbar\"` and its own `aria-label` on a `<div>`, which is a role with none of the behaviour under it: two controls, two tab stops, and no arrow key between them. `jx-action-group` is not the element for it — that one roves `jx-action-button` and this bar's first control is a `jx-textfield` — so `jx-toolbar` is, and the field keeps its own arrows while its caret still has text to walk (ui.md §5.5).",tagName:"jx-toolbar",attributes:{part:"chrome"},$props:{label:{$ref:"#/state/title"}},style:{$description:'What `.sb-chrome` said in `styles/overlays.css`, plus the six inline declarations the template carried beside it, plus `.tb-toggle` — all three go dead with this conversion, and none of them is shared with another surface. Three repairs on the way. The bar is one element rather than a positioned box wrapping a `role="toolbar"` row that declared the same flex layout again. The flex layout is not declared here EITHER any more: `display: flex`, `align-items: center`, the `--jx-space-2` gap, the sans face and the foreground colour are all `jx-toolbar`\'s own, so what is left below is only what a positioned BAND is. And `.tb-toggle` read `var(--spectrum-font-size-50, 11px)`, which the kit spells `--jx-text-sm` at the same value; the rest of its drawing is a `jx-action-button` reaching in through `part="control"`, because what it has to look like is a small bordered chip and every fill and control height the kit draws would otherwise have to be taken back off.',position:"absolute",top:"0",left:"0",right:"0",zIndex:"15",flexShrink:"0",padding:"var(--jx-space-2) var(--jx-space-3)",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",'& [part="filter"]':{flex:"1",maxWidth:"200px"},'& [part="customized"] > [part="control"]':{$description:"Bordered, unfilled and dimmed until it is on, which is what says it is a filter rather than an action: the catalogue it narrows is the thing the reader is looking at, so the control has to be quieter than its subject.",padding:"3px var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"transparent",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)",":hover":{background:"var(--hover-bg)"}},'& [part="customized"][data-selected] > [part="control"]':{$description:"`data-selected` and not `selected`: the kit reflects the pressed state as a data attribute (`jx-action-button.json`), and the property this document binds never reaches the attribute of the same name.",borderColor:"var(--accent)",background:"var(--accent-15)",color:"var(--accent)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{size:"sm",type:"search",clearable:!0,label:{$ref:"#/state/filterLabel"},placeholder:"Filter…",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-action-button",$description:"`onchange` and not `onclick`: a `toggles` button owns its own pressed state and says so with `change` (`jx-action-button.json`), and an `onclick` written here would replace the element's own click handler on the same property — the toggle would stop flipping and stop announcing `aria-pressed`.",attributes:{part:"customized"},$props:{size:"sm",toggles:!0,selected:{$ref:"#/state/customizedOnly"},label:{$ref:"#/state/customizedLabel"},hint:{$ref:"#/state/customizedHint"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleCustomized"},value:[]}]},children:[{tagName:"span",textContent:"${state.customizedLabel}"}]}]};T("stylebook-chrome",O);function z(e,o){let t=document.createElement("div");t.style.display="contents";let n=v({...e,...o}),r=null,s=!1;function i(){s=!0,R("stylebook-chrome",n,t).then((d)=>{s=!1,r=d})}return i(),{host:t,update(d){if(Object.assign(n,d),s||r!==null&&t.contains(r.root))return;r?.dispose(),r=null,t.textContent="",i()}}}function E(e){return!e.startsWith(":")&&!e.startsWith(".")&&!e.startsWith("&")&&!e.startsWith("[")&&!e.startsWith("@")&&!e.startsWith("--")}function w(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}var M="& .element-card-preview";function Wg(e){let o=e,t={},n=(r)=>{let s={};for(let[i,d]of Object.entries(r))if(i!=="@--")s[i]=d;return s};for(let[r,s]of Object.entries(o)){if(!w(s)){t[r]=s;continue}if(r==="@--")continue;if($v(r)){t[r]=s;continue}if(r.startsWith("@")){let i={};for(let[d,g]of Object.entries(s))if(w(g)&&E(d))i[`${M} ${d}`]=n(g);else i[d]=g;t[r]=i;continue}if(E(r)){t[`${M} ${r}`]=n(s);continue}t[r]=s}return t}function I(e,o){let t=o.split(" "),n=e;for(let r of t){if(!w(n))return null;n=n[r]}return w(n)?n:null}function J(e,o){let t=e,n=I(t,o);if(n&&Object.keys(n).length>0)return!0;for(let[r,s]of Object.entries(t)){if(!r.startsWith("@")||!w(s))continue;let i=I(s,o);if(i&&Object.keys(i).length>0)return!0}return!1}function _(e){let o=new Map,t=new Map,n=e.filter.toLowerCase(),r=(a,c,h)=>{let p=a.tag===h?h:`${h} ${a.tag}`;o.set(Il(c),p);let m=a.children??[];for(let[l,C]of m.entries())r(C,[...c,"children",l],h)},s=(a)=>{let c={...a.attributes};if(a.style)c.style=a.style;return{tagName:a.tag,...a.text?{textContent:a.text}:{},...Object.keys(c).length>0?{attributes:c}:{},...a.children?{children:a.children.map(s)}:{}}},i=(a,c,h,p,m)=>{o.set(Il(p),a),o.set(Il([...p,"children",0]),a);let l=[...p,"children",0,"children",0];if(m)r(m,l,a);else o.set(Il(l),a);if(!t.has(a))t.set(a,p);return{attributes:{class:"element-card"},children:[{attributes:{class:"element-card-preview"},children:[h],tagName:"div"},{attributes:{class:"element-card-label"},tagName:"div",textContent:c}],tagName:"div"}},d=[],g=(a,c)=>({attributes:{class:"sb-section"},children:[{attributes:{class:"sb-label"},tagName:"div",textContent:a},{attributes:{class:"sb-body"},children:c,tagName:"div"}],tagName:"div"}),f=()=>["children",d.length,"children",1];for(let a of e.meta.$sections){let c=a.elements;if(n)c=c.filter((m)=>m.tag.includes(n)||a.label.toLowerCase().includes(n));if(e.customizedOnly)c=c.filter((m)=>J(e.effectiveStyle,m.tag));if(c.length===0)continue;let h=f(),p=c.map((m,l)=>i(m.tag,`<${m.tag}>`,s(m),[...h,"children",l],m));d.push(g(a.label,p))}let b=[];{let a=e.components;if(n)a=a.filter((c)=>c.tagName.toLowerCase().includes(n));if(e.customizedOnly)a=a.filter((c)=>J(e.effectiveStyle,c.tagName));if(a.length>0){let c=f(),h=a.map((p,m)=>{let l=[...c,"children",m];if(p.source!=="npm"&&p.path?.endsWith(".json")){b.push({$ref:`/${e.projectRoot?`${e.projectRoot}/`:""}${p.path}`.replace(/^\/+/,"/")});let j={};for(let k of p.props??[])if(k.default!==void 0&&k.default!=="false"&&k.default!=="''")j[k.name]=String(k.default).replaceAll(/^'|'$/g,"");let q={tagName:p.tagName,...Object.keys(j).length>0?{attributes:j}:{}};return i(p.tagName,`<${p.tagName}>`,q,l,null)}let V={attributes:{class:"sb-fallback"},tagName:"div",textContent:`<${p.tagName}>`};return i(p.tagName,`<${p.tagName}>`,V,l,null)});d.push(g("Components",h))}}if(d.length===0)d.push({attributes:{class:"sb-empty"},tagName:"div",textContent:e.customizedOnly?"No customized elements":"No matching elements"});return{doc:{...b.length>0?{$elements:b}:{},$media:e.effectiveMedia,attributes:{class:"sb-root"},children:d,style:Wg(e.effectiveStyle),tagName:"div"},pathToTag:o,tagToCardPath:t}}var Vg="Project Styles",WS="stylebook",Qy=[{id:"color",prefix:"--color-",title:"Colors"},{id:"font",prefix:"--font-",title:"Fonts"},{id:"size",prefix:"--size-",title:"Sizes & Spacing"},{id:"other",prefix:"--",title:"Other"}];function L(e){if(e.startsWith("--color"))return"color";if(e.startsWith("--font"))return"font";if(e.startsWith("--size")||e.startsWith("--spacing")||e.startsWith("--radius"))return"size";return"other"}function j_(e){let o=L(e);if(o==="other")return e;let{prefix:t}=Qy.find((n)=>n.id===o);return Cv(e,t)}function U(e){if(!e)return[];let o=[];for(let[t,n]of Object.entries(e)){if(!t.startsWith("--"))continue;if(typeof n!=="string"&&typeof n!=="number")continue;o.push({group:L(t),label:j_(t),name:t,value:n})}return o}function VS(e){let o=U(e);return Qy.map((t)=>({group:t,tokens:o.filter((n)=>n.group===t.id)}))}function US(e){if(!e)return[];let{featureQueries:o,sizeBreakpoints:t}=hr(e),n=[],r=[];for(let{name:i,query:d}of o){let g=Ou(d);if(g)n.push({key:`@${i}`,kind:"scheme",label:g==="dark"?"Dark":"Light",name:i,scheme:g});else r.push({key:`@${i}`,kind:"feature",label:`@${i}`,name:i})}let s=t.map(({name:i})=>({key:`@${i}`,kind:"size",label:`@${i}`,name:i}));return[...n,...s,...r]}function A(e,o){let t=e[o.key];return t&&typeof t==="object"?t:void 0}function Ug(e,o,t){let n=A(e,o)?.[t];return typeof n==="string"||typeof n==="number"?n:void 0}function H_(e,o,t,n){if(n){let s=e[o.key]??={};s[t]=n;return}let r=A(e,o);if(!r)return;if(delete r[t],Object.keys(r).length===0)delete e[o.key]}function qS(e,o,t,n=[]){let r=new Set(n.map((s)=>s.name));return o.filter((s)=>!r.has(s.name)&&Ug(e,s,t)===void 0)}var W=new WeakMap;function K(e){let o={customizedHint:"Show only the elements this file has already styled",customizedLabel:"Customized",customizedOnly:y.stylebook.customizedOnly,filter:y.stylebook.filter,filterLabel:`Filter the ${Vg} catalogue`,title:Vg},t=W.get(e);if(t)return t.update(o),t.host;let n=z(o,{setFilter:(r)=>{y.stylebook.filter=r},toggleCustomized:()=>{y.stylebook.customizedOnly=!y.stylebook.customizedOnly}});return W.set(e,n),n.host}async function GS(e,o){let t=e.wrap,n=lt(e.paneId),r=y.stylebook.filter.toLowerCase(),{customizedOnly:s}=y.stylebook,i=Di(n?.doc.document?.$media),{sizeBreakpoints:d,baseWidth:g}=hr(i),f=d.length>0,b=K(e);t.style.overflow="hidden";let S=[];if(f){S.push({displayName:bi("--"),name:"base",width:g});for(let l of d)S.push({displayName:bi(l.name),name:l.name,width:l.width})}let a;if(!f){let l=i&&i["--"],C=l?`${bi("--")} (${g}px)`:null;a=[o.canvasPanelEntry(l?"base":null,C,!l,l?g:void 0)]}else a=S.map((l)=>o.canvasPanelEntry(l.name,`${l.displayName} (${l.width}px)`,!1,l.width));if(!await o.drawStage(e,{frame:"boards",framePart:"panzoom",frameVars:"--boards-inset:40px",handles:"hidden",hug:!1,innerPart:"boards",lead:"chrome",panels:a.map((l)=>l.item)},a))return;let h=o.stageHost(e,"chrome-host");if(h&&h.firstChild!==b)h.replaceChildren(b);let p=_({components:st,customizedOnly:Boolean(s),effectiveMedia:i??{},effectiveStyle:qo(n?.doc.document?.style),filter:r,meta:qg,projectRoot:D?.projectRoot??null}),{panels:m}=e;for(let{panel:l}of a)m.push(l),kC(e.renderGeneration,p,l.canvas,l._width);if(f)o.updateActivePanelHeaders(e);o.applyTransform(e),o.observeCenterUntilStable(e)}function wu(e,o,{panCanvas:t=!1}={}){if(y.stylebook.selection=e,Lc(u.value,{selection:[[]],ui:{activeSelector:e,rightTab:"style",...o!==void 0?{activeMedia:o}:{}}}),e&&t)IC(e)}var Q=8,ew=[{id:"properties",title:"Content"},{id:"style",title:"Style"},{id:"events",title:"Logic"},{id:"assistant",title:"Assistant"}];function tw(){return{saveDocument:()=>{},undo:()=>{},redo:()=>{},openInBrowser:()=>{},buildSite:()=>{},closeDocument:()=>{},duplicateSelection:()=>{},deleteSelection:()=>{},selectParent:()=>{},toggleDock:()=>{},toggleZen:()=>{},openPalette:()=>{},openProject:()=>{},newWindow:()=>{},panelRoster:[],focusPanel:()=>{},focusInspectorTab:()=>{},cycleRegion:()=>{}}}var x=(e)=>e.document.open,P=(e)=>e.selection.count>0&&e.editor.kind==="canvas",N=(e)=>!e.selection.isRoot&&e.selection.paths.every((o)=>Nl(o)),B="an element selected on the canvas that has a sibling position: not the document root, a repeater's template or a switch case",H=(e)=>e.map((o)=>`[${o.join(", ")}]`).join(" and ");function Jh(e){return[{id:"file.save",title:"Save",category:"File",level:"document",icon:"floppy-disk",keybinding:"mod+s",menus:["commandbar/primary","statusbar/document","palette"],group:"1_file",undo:"none",when:x,requires:"an open document",run:()=>e.saveDocument()},{id:"document.close",title:"Close Document",category:"Document",level:"document",keybinding:"mod+w",menus:["context/tab","palette"],group:"1_file",when:x,requires:"an open document",run:()=>e.closeDocument()},{id:"view.openInBrowser",title:"Open in Browser",category:"View",level:"document",icon:"arrow-square-out",keybinding:"mod+shift+o",menus:["commandbar/primary","statusbar/document","palette"],group:"2_output",when:(t)=>t.project.isSite,enablement:x,requires:"a page to preview",run:()=>e.openInBrowser()},{id:"project.buildSite",title:"Build Site",category:"Project",level:"project",menus:["commandbar/overflow","palette"],group:"2_output",when:(t)=>t.project.isSite,requires:"a site project",run:()=>e.buildSite()},{id:"edit.undo",title:"Undo",category:"Edit",level:"document",icon:"arrow-u-up-left",keybinding:"mod+z",menus:["commandbar/primary","palette"],group:"1_history",when:x,enablement:(t)=>t.document.canUndo,requires:"a change to undo",run:()=>e.undo()},{id:"edit.redo",title:"Redo",category:"Edit",level:"document",icon:"arrow-u-up-right",keybinding:["mod+shift+z","mod+y"],menus:["commandbar/primary","palette"],group:"1_history",when:x,enablement:(t)=>t.document.canRedo,requires:"a change to redo",run:()=>e.redo()},{id:"selection.duplicate",title:"Duplicate",category:"Selection",level:"selection",keyScope:"canvas",keybinding:"mod+d",menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"3_structure",undo:"document",when:P,enablement:N,requires:B,aiTool:{name:"duplicate_node",description:"Duplicate elements in the document, inserting each copy after its original, as one undoable step. The copies become the selection.",report:({after:t})=>{let n=t.selection.paths.length;return`Duplicated ${n} element${n===1?"":"s"}; the ${n===1?"copy is":"copies are"} selected at ${H(t.selection.paths)}.`}},run:()=>e.duplicateSelection()},{id:"selection.repeat",title:"Repeat...",category:"Selection",level:"selection",keyScope:"canvas",menus:["context/element","palette"],group:"3_structure",undo:"document",when:P,enablement:(t)=>N(t)&&!t.selection.isRepeater,requires:"an element with a sibling position that is not already a repeater",run:()=>{(me("grfep2w8"),import("./convert-to-repeater-grfep2w8.js")).then(({convertToRepeater:t})=>t())}},{id:"selection.delete",title:"Delete",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["delete","backspace"],menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"9_danger",destructive:!0,undo:"document",when:P,enablement:N,requires:B,aiTool:{name:"delete_node",description:"Delete elements from the document as one undoable step.",report:({before:t,after:n})=>{let r=t.selection.paths.length;return`Deleted ${r} element${r===1?"":"s"} at ${H(t.selection.paths)} in one undo step; the selection is now ${n.selection.count===0?"empty":"elsewhere"}.`}},run:()=>e.deleteSelection()},{id:"selection.selectParent",title:"Select Parent",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["escape","arrowleft"],menus:["palette"],group:"2_navigate",when:P,requires:"an element selection",run:()=>e.selectParent()},{id:"view.toggleNavigator",title:"Toggle Navigator Dock",category:"View",level:"application",keybinding:"mod+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("navigator")},{id:"view.toggleInspector",title:"Toggle Inspector Dock",category:"View",level:"application",keybinding:"mod+alt+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("inspector")},{id:"view.zen",title:"Zen Mode",category:"View",level:"application",keybinding:"mod+.",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleZen()},{id:"palette.open",title:"Open Command Center",category:"View",level:"application",keybinding:"mod+k",menus:["palette"],group:"5_palette",run:()=>e.openPalette("picker")},{id:"palette.openFiles",title:"Go to File…",category:"File",level:"application",keybinding:"mod+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("files")},{id:"palette.openCommands",title:"Run Command…",category:"View",level:"application",keybinding:"mod+shift+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("commands")},{id:"palette.openNodes",title:"Go to Symbol in Document…",category:"Selection",level:"document",menus:["palette"],group:"5_palette",when:x,requires:"an open document",run:()=>e.openPalette("nodes")},{id:"project.open",title:"Open Project…",category:"Project",level:"project",keybinding:"mod+o",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openProject()},{id:"view.newWindow",title:"New Window",category:"View",level:"application",keybinding:"mod+shift+n",menus:["commandbar/overflow","palette"],group:"1_file",when:(t)=>t.capability.windowControls,requires:"a host that can hold more than one window",run:()=>e.newWindow()},{id:"project.openRecent",title:"Open Recent…",category:"Project",level:"project",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openPalette("projects")},...Z(e),...Y(e),{id:"view.cycleRegion",title:"Focus Next Region",category:"View",level:"application",keybinding:"f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(1)},{id:"view.cycleRegionBack",title:"Focus Previous Region",category:"View",level:"application",keybinding:"shift+f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(-1)}]}function Z(e){let o=0;return e.panelRoster.map((t)=>{let n={id:`panel.focus.${t.id}`,title:`Show ${t.title}`,category:"View",level:"application",menus:["palette"],group:"4_docks",requires:"an open project",when:(r)=>r.project.open&&(t.when?.(r)??!0),run:()=>e.focusPanel(t.id)};if(t.rail!==!1&&o<Q)o+=1,n.keybinding=`mod+${o}`;return n})}function Y(e){return ew.map((o,t)=>({id:`inspector.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"document",keybinding:`mod+shift+${t+1}`,menus:["palette"],group:"4_docks",requires:"an open document",when:(r)=>r.document.open,run:()=>e.focusInspectorTab(o.id)}))}
5
+ registerBlockType( name, settings );`}]}]},{label:"Inline",elements:[{tag:"a",text:"Visit the documentation",attributes:{href:"#"}},{tag:"strong",text:"Bold text emphasis"},{tag:"em",text:"Italic text emphasis"},{tag:"small",text:"Fine print and legal text"},{tag:"mark",text:"Highlighted text"},{tag:"code",text:"const x = 42;"},{tag:"abbr",text:"HTML",attributes:{title:"HyperText Markup Language"}},{tag:"sub",text:"subscript"},{tag:"sup",text:"superscript"}]},{label:"Form",elements:[{tag:"input",attributes:{type:"text",placeholder:"Enter text…"}},{tag:"button",text:"Click Me"},{tag:"select",children:[{tag:"option",text:"Option 1"},{tag:"option",text:"Option 2"},{tag:"option",text:"Option 3"}]},{tag:"textarea",attributes:{placeholder:"Enter longer text…",rows:"3"}}]},{label:"Table",elements:[{tag:"table",children:[{tag:"thead",children:[{tag:"tr",children:[{tag:"th",text:"Name"},{tag:"th",text:"Role"},{tag:"th",text:"Status"}]}]},{tag:"tbody",children:[{tag:"tr",children:[{tag:"td",text:"Alice"},{tag:"td",text:"Developer"},{tag:"td",text:"Active"}]},{tag:"tr",children:[{tag:"td",text:"Bob"},{tag:"td",text:"Designer"},{tag:"td",text:"Away"}]},{tag:"tr",children:[{tag:"td",text:"Carol"},{tag:"td",text:"Manager"},{tag:"td",text:"Active"}]}]}]}]},{label:"Interactive",elements:[{tag:"details",attributes:{open:""},children:[{tag:"summary",text:"Click to expand details"},{tag:"p",text:"Additional detail content revealed when the disclosure widget is toggled open."}]}]},{label:"Media",elements:[{tag:"img",attributes:{alt:"Placeholder image"},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"video",attributes:{controls:""},style:"width:100%;max-width:400px;height:200px;background:#e0e0e0;display:block;border-radius:4px"},{tag:"audio",attributes:{controls:""},style:"width:100%"}]}],$variables:{color:{label:"Color",prefix:"--color-",placeholder:"#007acc"},font:{label:"Font",prefix:"--font-",placeholder:"system-ui, sans-serif"},size:{label:"Size",prefix:"--size-",placeholder:"16px"},other:{label:"Other",prefix:"--",placeholder:"value"}}};var O={$schema:"https://jxsuite.com/schema/v1",$id:"StudioStylebookChrome",$description:"The bar across the top of the Project Styles canvas: the filter that narrows the specimen catalogue, and the toggle that reduces it to the elements this file has already styled. Both are shell state rather than document state — the adapter owns which — and the two names come in as values, because the surface is called Project Styles and the canvas view it draws is the wire word `stylebook`; nothing a reader sees here may be spelled from that. **The bar IS the kit's toolbar now.** It used to write `role=\"toolbar\"` and its own `aria-label` on a `<div>`, which is a role with none of the behaviour under it: two controls, two tab stops, and no arrow key between them. `jx-action-group` is not the element for it — that one roves `jx-action-button` and this bar's first control is a `jx-textfield` — so `jx-toolbar` is, and the field keeps its own arrows while its caret still has text to walk (ui.md §5.5).",tagName:"jx-toolbar",attributes:{part:"chrome"},$props:{label:{$ref:"#/state/title"}},style:{$description:'What `.sb-chrome` said in `styles/overlays.css`, plus the six inline declarations the template carried beside it, plus `.tb-toggle` — all three go dead with this conversion, and none of them is shared with another surface. Three repairs on the way. The bar is one element rather than a positioned box wrapping a `role="toolbar"` row that declared the same flex layout again. The flex layout is not declared here EITHER any more: `display: flex`, `align-items: center`, the `--jx-space-2` gap, the sans face and the foreground colour are all `jx-toolbar`\'s own, so what is left below is only what a positioned BAND is. And `.tb-toggle` read `var(--spectrum-font-size-50, 11px)`, which the kit spells `--jx-text-sm` at the same value; the rest of its drawing is a `jx-action-button` reaching in through `part="control"`, because what it has to look like is a small bordered chip and every fill and control height the kit draws would otherwise have to be taken back off.',position:"absolute",top:"0",left:"0",right:"0",zIndex:"15",flexShrink:"0",padding:"var(--jx-space-2) var(--jx-space-3)",background:"var(--bg-panel)",borderBottom:"1px solid var(--border)",'& [part="filter"]':{flex:"1",maxWidth:"200px"},'& [part="customized"] > [part="control"]':{$description:"Bordered, unfilled and dimmed until it is on, which is what says it is a filter rather than an action: the catalogue it narrows is the thing the reader is looking at, so the control has to be quieter than its subject.",padding:"3px var(--jx-space-3)",border:"1px solid var(--border)",borderRadius:"var(--radius)",background:"transparent",color:"var(--fg-dim)",fontSize:"var(--jx-text-sm)",":hover":{background:"var(--hover-bg)"}},'& [part="customized"][data-selected] > [part="control"]':{$description:"`data-selected` and not `selected`: the kit reflects the pressed state as a data attribute (`jx-action-button.json`), and the property this document binds never reaches the attribute of the same name.",borderColor:"var(--accent)",background:"var(--accent-15)",color:"var(--accent)"}},children:[{tagName:"jx-textfield",attributes:{part:"filter"},$props:{size:"sm",type:"search",clearable:!0,label:{$ref:"#/state/filterLabel"},placeholder:"Filter…",value:{$ref:"#/state/filter"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/setFilter"},value:[{$ref:"event#/target/value"}]}]}},{tagName:"jx-action-button",$description:"`onchange` and not `onclick`: a `toggles` button owns its own pressed state and says so with `change` (`jx-action-button.json`), and an `onclick` written here would replace the element's own click handler on the same property — the toggle would stop flipping and stop announcing `aria-pressed`.",attributes:{part:"customized"},$props:{size:"sm",toggles:!0,selected:{$ref:"#/state/customizedOnly"},label:{$ref:"#/state/customizedLabel"},hint:{$ref:"#/state/customizedHint"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleCustomized"},value:[]}]},children:[{tagName:"span",textContent:"${state.customizedLabel}"}]}]};T("stylebook-chrome",O);function z(e,o){let t=document.createElement("div");t.style.display="contents";let n=v({...e,...o}),r=null,s=!1;function i(){s=!0,R("stylebook-chrome",n,t).then((d)=>{s=!1,r=d})}return i(),{host:t,update(d){if(Object.assign(n,d),s||r!==null&&t.contains(r.root))return;r?.dispose(),r=null,t.textContent="",i()}}}function E(e){return!e.startsWith(":")&&!e.startsWith(".")&&!e.startsWith("&")&&!e.startsWith("[")&&!e.startsWith("@")&&!e.startsWith("--")}function w(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}var M="& .element-card-preview";function Wg(e){let o=e,t={},n=(r)=>{let s={};for(let[i,d]of Object.entries(r))if(i!=="@--")s[i]=d;return s};for(let[r,s]of Object.entries(o)){if(!w(s)){t[r]=s;continue}if(r==="@--")continue;if($v(r)){t[r]=s;continue}if(r.startsWith("@")){let i={};for(let[d,g]of Object.entries(s))if(w(g)&&E(d))i[`${M} ${d}`]=n(g);else i[d]=g;t[r]=i;continue}if(E(r)){t[`${M} ${r}`]=n(s);continue}t[r]=s}return t}function I(e,o){let t=o.split(" "),n=e;for(let r of t){if(!w(n))return null;n=n[r]}return w(n)?n:null}function J(e,o){let t=e,n=I(t,o);if(n&&Object.keys(n).length>0)return!0;for(let[r,s]of Object.entries(t)){if(!r.startsWith("@")||!w(s))continue;let i=I(s,o);if(i&&Object.keys(i).length>0)return!0}return!1}function _(e){let o=new Map,t=new Map,n=e.filter.toLowerCase(),r=(a,c,h)=>{let p=a.tag===h?h:`${h} ${a.tag}`;o.set(Il(c),p);let m=a.children??[];for(let[l,C]of m.entries())r(C,[...c,"children",l],h)},s=(a)=>{let c={...a.attributes};if(a.style)c.style=a.style;return{tagName:a.tag,...a.text?{textContent:a.text}:{},...Object.keys(c).length>0?{attributes:c}:{},...a.children?{children:a.children.map(s)}:{}}},i=(a,c,h,p,m)=>{o.set(Il(p),a),o.set(Il([...p,"children",0]),a);let l=[...p,"children",0,"children",0];if(m)r(m,l,a);else o.set(Il(l),a);if(!t.has(a))t.set(a,p);return{attributes:{class:"element-card"},children:[{attributes:{class:"element-card-preview"},children:[h],tagName:"div"},{attributes:{class:"element-card-label"},tagName:"div",textContent:c}],tagName:"div"}},d=[],g=(a,c)=>({attributes:{class:"sb-section"},children:[{attributes:{class:"sb-label"},tagName:"div",textContent:a},{attributes:{class:"sb-body"},children:c,tagName:"div"}],tagName:"div"}),f=()=>["children",d.length,"children",1];for(let a of e.meta.$sections){let c=a.elements;if(n)c=c.filter((m)=>m.tag.includes(n)||a.label.toLowerCase().includes(n));if(e.customizedOnly)c=c.filter((m)=>J(e.effectiveStyle,m.tag));if(c.length===0)continue;let h=f(),p=c.map((m,l)=>i(m.tag,`<${m.tag}>`,s(m),[...h,"children",l],m));d.push(g(a.label,p))}let b=[];{let a=e.components;if(n)a=a.filter((c)=>c.tagName.toLowerCase().includes(n));if(e.customizedOnly)a=a.filter((c)=>J(e.effectiveStyle,c.tagName));if(a.length>0){let c=f(),h=a.map((p,m)=>{let l=[...c,"children",m];if(p.source!=="npm"&&p.path?.endsWith(".json")){b.push({$ref:`/${e.projectRoot?`${e.projectRoot}/`:""}${p.path}`.replace(/^\/+/,"/")});let j={};for(let k of p.props??[])if(k.default!==void 0&&k.default!=="false"&&k.default!=="''")j[k.name]=String(k.default).replaceAll(/^'|'$/g,"");let q={tagName:p.tagName,...Object.keys(j).length>0?{attributes:j}:{}};return i(p.tagName,`<${p.tagName}>`,q,l,null)}let V={attributes:{class:"sb-fallback"},tagName:"div",textContent:`<${p.tagName}>`};return i(p.tagName,`<${p.tagName}>`,V,l,null)});d.push(g("Components",h))}}if(d.length===0)d.push({attributes:{class:"sb-empty"},tagName:"div",textContent:e.customizedOnly?"No customized elements":"No matching elements"});return{doc:{...b.length>0?{$elements:b}:{},$media:e.effectiveMedia,attributes:{class:"sb-root"},children:d,style:Wg(e.effectiveStyle),tagName:"div"},pathToTag:o,tagToCardPath:t}}var Vg="Project Styles",WS="stylebook",Qy=[{id:"color",prefix:"--color-",title:"Colors"},{id:"font",prefix:"--font-",title:"Fonts"},{id:"size",prefix:"--size-",title:"Sizes & Spacing"},{id:"other",prefix:"--",title:"Other"}];function L(e){if(e.startsWith("--color"))return"color";if(e.startsWith("--font"))return"font";if(e.startsWith("--size")||e.startsWith("--spacing")||e.startsWith("--radius"))return"size";return"other"}function j_(e){let o=L(e);if(o==="other")return e;let{prefix:t}=Qy.find((n)=>n.id===o);return Cv(e,t)}function U(e){if(!e)return[];let o=[];for(let[t,n]of Object.entries(e)){if(!t.startsWith("--"))continue;if(typeof n!=="string"&&typeof n!=="number")continue;o.push({group:L(t),label:j_(t),name:t,value:n})}return o}function VS(e){let o=U(e);return Qy.map((t)=>({group:t,tokens:o.filter((n)=>n.group===t.id)}))}function US(e){if(!e)return[];let{featureQueries:o,sizeBreakpoints:t}=hr(e),n=[],r=[];for(let{name:i,query:d}of o){let g=Ou(d);if(g)n.push({key:`@${i}`,kind:"scheme",label:g==="dark"?"Dark":"Light",name:i,scheme:g});else r.push({key:`@${i}`,kind:"feature",label:`@${i}`,name:i})}let s=t.map(({name:i})=>({key:`@${i}`,kind:"size",label:`@${i}`,name:i}));return[...n,...s,...r]}function A(e,o){let t=e[o.key];return t&&typeof t==="object"?t:void 0}function Ug(e,o,t){let n=A(e,o)?.[t];return typeof n==="string"||typeof n==="number"?n:void 0}function H_(e,o,t,n){if(n){let s=e[o.key]??={};s[t]=n;return}let r=A(e,o);if(!r)return;if(delete r[t],Object.keys(r).length===0)delete e[o.key]}function qS(e,o,t,n=[]){let r=new Set(n.map((s)=>s.name));return o.filter((s)=>!r.has(s.name)&&Ug(e,s,t)===void 0)}var W=new WeakMap;function K(e){let o={customizedHint:"Show only the elements this file has already styled",customizedLabel:"Customized",customizedOnly:y.stylebook.customizedOnly,filter:y.stylebook.filter,filterLabel:`Filter the ${Vg} catalogue`,title:Vg},t=W.get(e);if(t)return t.update(o),t.host;let n=z(o,{setFilter:(r)=>{y.stylebook.filter=r},toggleCustomized:()=>{y.stylebook.customizedOnly=!y.stylebook.customizedOnly}});return W.set(e,n),n.host}async function GS(e,o){let t=e.wrap,n=lt(e.paneId),r=y.stylebook.filter.toLowerCase(),{customizedOnly:s}=y.stylebook,i=Di(n?.doc.document?.$media),{sizeBreakpoints:d,baseWidth:g}=hr(i),f=d.length>0,b=K(e);t.style.overflow="hidden";let S=[];if(f){S.push({displayName:bi("--"),name:"base",width:g});for(let l of d)S.push({displayName:bi(l.name),name:l.name,width:l.width})}let a;if(!f){let l=i&&i["--"],C=l?`${bi("--")} (${g}px)`:null;a=[o.canvasPanelEntry(l?"base":null,C,!l,l?g:void 0)]}else a=S.map((l)=>o.canvasPanelEntry(l.name,`${l.displayName} (${l.width}px)`,!1,l.width));if(!await o.drawStage(e,{frame:"boards",framePart:"panzoom",frameVars:"--boards-inset:40px",handles:"hidden",hug:!1,innerPart:"boards",lead:"chrome",panels:a.map((l)=>l.item)},a))return;let h=o.stageHost(e,"chrome-host");if(h&&h.firstChild!==b)h.replaceChildren(b);let p=_({components:st,customizedOnly:Boolean(s),effectiveMedia:i??{},effectiveStyle:qo(n?.doc.document?.style),filter:r,meta:qg,projectRoot:D?.projectRoot??null}),{panels:m}=e;for(let{panel:l}of a)m.push(l),kC(e.renderGeneration,p,l.canvas,l._width);if(f)o.updateActivePanelHeaders(e);o.applyTransform(e),o.observeCenterUntilStable(e)}function wu(e,o,{panCanvas:t=!1}={}){if(y.stylebook.selection=e,Lc(u.value,{selection:[[]],ui:{activeSelector:e,rightTab:"style",...o!==void 0?{activeMedia:o}:{}}}),e&&t)IC(e)}var Q=8,ew=[{id:"properties",title:"Content"},{id:"style",title:"Style"},{id:"events",title:"Logic"},{id:"assistant",title:"Assistant"}];function tw(){return{saveDocument:()=>{},undo:()=>{},redo:()=>{},openInBrowser:()=>{},buildSite:()=>{},closeDocument:()=>{},duplicateSelection:()=>{},deleteSelection:()=>{},selectParent:()=>{},toggleDock:()=>{},toggleZen:()=>{},openPalette:()=>{},openProject:()=>{},newWindow:()=>{},panelRoster:[],focusPanel:()=>{},focusInspectorTab:()=>{},cycleRegion:()=>{}}}var x=(e)=>e.document.open,P=(e)=>e.selection.count>0&&e.editor.kind==="canvas",N=(e)=>!e.selection.isRoot&&e.selection.paths.every((o)=>Nl(o)),B="an element selected on the canvas that has a sibling position: not the document root, a repeater's template or a switch case",H=(e)=>e.map((o)=>`[${o.join(", ")}]`).join(" and ");function Jh(e){return[{id:"file.save",title:"Save",category:"File",level:"document",icon:"floppy-disk",keybinding:"mod+s",menus:["commandbar/primary","statusbar/document","palette"],group:"1_file",undo:"none",when:x,requires:"an open document",run:()=>e.saveDocument()},{id:"document.close",title:"Close Document",category:"Document",level:"document",keybinding:"mod+w",menus:["context/tab","palette"],group:"1_file",when:x,requires:"an open document",run:()=>e.closeDocument()},{id:"view.openInBrowser",title:"Open in Browser",category:"View",level:"document",icon:"arrow-square-out",keybinding:"mod+shift+o",menus:["commandbar/primary","statusbar/document","palette"],group:"2_output",when:(t)=>t.project.isSite,enablement:x,requires:"a page to preview",run:()=>e.openInBrowser()},{id:"project.buildSite",title:"Build Site",category:"Project",level:"project",menus:["commandbar/overflow","palette"],group:"2_output",when:(t)=>t.project.isSite,requires:"a site project",run:()=>e.buildSite()},{id:"edit.undo",title:"Undo",category:"Edit",level:"document",icon:"arrow-u-up-left",keybinding:"mod+z",menus:["commandbar/primary","palette"],group:"1_history",when:x,enablement:(t)=>t.document.canUndo,requires:"a change to undo",run:()=>e.undo()},{id:"edit.redo",title:"Redo",category:"Edit",level:"document",icon:"arrow-u-up-right",keybinding:["mod+shift+z","mod+y"],menus:["commandbar/primary","palette"],group:"1_history",when:x,enablement:(t)=>t.document.canRedo,requires:"a change to redo",run:()=>e.redo()},{id:"selection.duplicate",title:"Duplicate",category:"Selection",level:"selection",keyScope:"canvas",keybinding:"mod+d",menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"3_structure",undo:"document",when:P,enablement:N,requires:B,aiTool:{name:"duplicate_node",description:"Duplicate elements in the document, inserting each copy after its original, as one undoable step. The copies become the selection.",report:({after:t})=>{let n=t.selection.paths.length;return`Duplicated ${n} element${n===1?"":"s"}; the ${n===1?"copy is":"copies are"} selected at ${H(t.selection.paths)}.`}},run:()=>e.duplicateSelection()},{id:"selection.repeat",title:"Repeat...",category:"Selection",level:"selection",keyScope:"canvas",menus:["context/element","palette"],group:"3_structure",undo:"document",when:P,enablement:(t)=>N(t)&&!t.selection.isRepeater,requires:"an element with a sibling position that is not already a repeater",run:()=>{(me("vqkt7s3s"),import("./convert-to-repeater-vqkt7s3s.js")).then(({convertToRepeater:t})=>t())}},{id:"selection.delete",title:"Delete",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["delete","backspace"],menus:["blockbar","context/element","context/layer","outline/row","palette"],group:"9_danger",destructive:!0,undo:"document",when:P,enablement:N,requires:B,aiTool:{name:"delete_node",description:"Delete elements from the document as one undoable step.",report:({before:t,after:n})=>{let r=t.selection.paths.length;return`Deleted ${r} element${r===1?"":"s"} at ${H(t.selection.paths)} in one undo step; the selection is now ${n.selection.count===0?"empty":"elsewhere"}.`}},run:()=>e.deleteSelection()},{id:"selection.selectParent",title:"Select Parent",category:"Selection",level:"selection",keyScope:"canvas",keybinding:["escape","arrowleft"],menus:["palette"],group:"2_navigate",when:P,requires:"an element selection",run:()=>e.selectParent()},{id:"view.toggleNavigator",title:"Toggle Navigator Dock",category:"View",level:"application",keybinding:"mod+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("navigator")},{id:"view.toggleInspector",title:"Toggle Inspector Dock",category:"View",level:"application",keybinding:"mod+alt+b",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleDock("inspector")},{id:"view.zen",title:"Zen Mode",category:"View",level:"application",keybinding:"mod+.",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>e.toggleZen()},{id:"palette.open",title:"Open Command Center",category:"View",level:"application",keybinding:"mod+k",menus:["palette"],group:"5_palette",run:()=>e.openPalette("picker")},{id:"palette.openFiles",title:"Go to File…",category:"File",level:"application",keybinding:"mod+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("files")},{id:"palette.openCommands",title:"Run Command…",category:"View",level:"application",keybinding:"mod+shift+p",menus:["palette"],group:"5_palette",run:()=>e.openPalette("commands")},{id:"palette.openNodes",title:"Go to Symbol in Document…",category:"Selection",level:"document",menus:["palette"],group:"5_palette",when:x,requires:"an open document",run:()=>e.openPalette("nodes")},{id:"project.open",title:"Open Project…",category:"Project",level:"project",keybinding:"mod+o",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openProject()},{id:"view.newWindow",title:"New Window",category:"View",level:"application",keybinding:"mod+shift+n",menus:["commandbar/overflow","palette"],group:"1_file",when:(t)=>t.capability.windowControls,requires:"a host that can hold more than one window",run:()=>e.newWindow()},{id:"project.openRecent",title:"Open Recent…",category:"Project",level:"project",menus:["commandbar/overflow","statusbar/project","palette"],group:"1_file",run:()=>e.openPalette("projects")},...Z(e),...Y(e),{id:"view.cycleRegion",title:"Focus Next Region",category:"View",level:"application",keybinding:"f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(1)},{id:"view.cycleRegionBack",title:"Focus Previous Region",category:"View",level:"application",keybinding:"shift+f6",menus:["palette"],group:"4_docks",run:()=>e.cycleRegion(-1)}]}function Z(e){let o=0;return e.panelRoster.map((t)=>{let n={id:`panel.focus.${t.id}`,title:`Show ${t.title}`,category:"View",level:"application",menus:["palette"],group:"4_docks",requires:"an open project",when:(r)=>r.project.open&&(t.when?.(r)??!0),run:()=>e.focusPanel(t.id)};if(t.rail!==!1&&o<Q)o+=1,n.keybinding=`mod+${o}`;return n})}function Y(e){return ew.map((o,t)=>({id:`inspector.focus.${o.id}`,title:`Show ${o.title}`,category:"View",level:"document",keybinding:`mod+shift+${t+1}`,menus:["palette"],group:"4_docks",requires:"an open document",when:(r)=>r.document.open,run:()=>e.focusInspectorTab(o.id)}))}
6
6
  export{Wg,Vg,WS,Qy,j_,VS,US,Ug,H_,qS,qg,GS,wu,ew,tw,Jh};
7
7
 
8
8
  //# debugId=672B287246E1308B64756E2164756E21
9
- //# sourceMappingURL=studio-p7c1agz0.js.map
9
+ //# sourceMappingURL=studio-gjknvzam.js.map
@@ -1,7 +1,7 @@
1
- import{tt}from"./studio-sxc0zvpt.js";import{te}from"./studio-ery42sqr.js";import{ne}from"./studio-0k9mvpgj.js";import{T,R,on,Rc,Nn}from"./studio-spf2skgc.js";import{v,Mo,k}from"./studio-fqq890ap.js";import{p,We}from"./studio-y7jehjrp.js";import{qt,Md,Ga,Tp,Vs,Lp,Zt,Ka}from"./studio-1x8x26k3.js";import{ua}from"./studio-yr04mv2j.js";import{Ir,pp}from"./studio-888knnkc.js";import{dn,$o,zu,wm,bp,Ax,Qn,m,Gu,Pl,Ua,No,ek,ci,Cm,Sv}from"./studio-cvbkkfqb.js";import{$u,WE,VE,Ps}from"./studio-9mqfamps.js";import{_t,Lr,qr}from"./studio-semd1s8s.js";import{hs,XT,tL,Yb,fs,Zb}from"./studio-zpnk016a.js";import{la}from"./studio-xta2vxp6.js";import{qn}from"./studio-xry7tk3z.js";import{Dl}from"./studio-pwqfmt4p.js";import{gr,zs,Ws,gs}from"./studio-st75kn99.js";import{ib,tp,np,ww,fE,Bf}from"./studio-j6gnhvaa.js";import{_c,ev,Va}from"./studio-c6w3tq7t.js";import{AE,E1}from"./studio-56z7evx4.js";import{zE,Er,Jf,Yf}from"./studio-skzanb0k.js";import{Nt}from"./studio-nt06yybj.js";import{eb,tb,nb}from"./studio-zd4kayn2.js";import{ls}from"./studio-tzegmy4w.js";import{sa}from"./studio-e6re3rk1.js";import{D,Hl,vt}from"./studio-tp642n5g.js";import{me}from"./studio-0bbxhhce.js";async function Pf(){if(ib(location.search))return!1;let e=p();if(!e.dependenciesNeedInstall||!e.installDependencies)return!1;let t=!1;try{t=await e.dependenciesNeedInstall()}catch{return!1}if(!t)return!1;let n=la({status:"Running bun install…",title:"Installing dependencies"});try{let o=await e.installDependencies();if(o.ok)return n.done(),!0;n.fail(o.log??"bun install failed")}catch(o){n.fail(o instanceof Error?o.message:String(o))}return!1}var Be=["page","component"],Ge={components:"component",pages:"page"};function _(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Ke(e){let t=_(e).toLowerCase();for(let[n,o]of Object.entries(Ge))if(t.startsWith(`${n}/`))return o;return null}function ee(e){return Be.some((t)=>e.includes(t))}function Ye(e){let t=D?.projectConfig?.layout;if(typeof t!=="string")return!1;return _(t).toLowerCase()===_(e).toLowerCase()}function ge(e){let t=[{ext:".json",label:"JSON (.json)"}];for(let n of Ka(e)){let o=Vs(n,"parse");if(o&&Vs(n,"serialize"))t.push({ext:n,label:`${o.name} (${n})`})}return t}function we(){return new Set([".json",...Tp().flatMap((e)=>e.extensions)])}function hw(e){if(e===null||e===void 0||e==="")return[];let t=Ke(e);if(t===null||Ye(e)||Ax(e))return[];let n=Zt(e);if(!(n?Boolean(n.capabilities.parse)&&ee(n.documentKinds):_(e).toLowerCase().endsWith(".json")))return[];let r=[];if(n)r.push({ext:".json",label:"JSON (.json)"});for(let a of Ka()){let i=Vs(a,"serialize");if(!i||i.name===n?.name||!ee(i.documentKinds)||!i.documentKinds.includes(t))continue;r.push({ext:a,label:`${i.name} (${a})`})}return r}function rE(){let e=new Set([".json"]);for(let t of Tp()){if(!t.capabilities.serialize||!ee(t.documentKinds))continue;for(let n of t.extensions)e.add(n)}return[...e].toSorted()}var oe="jx-studio-recent-projects",ye="jx-studio-recent-files",ve=8,Qe=10,M=[];function V(){if(!We())return null;let e=p();return e.getRecentProjects&&e.saveRecentProjects?e:null}function Xe(){try{let e=localStorage.getItem(oe);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function re(){return V()?M:Xe()}function be(e){M=e;let t=V();if(t)t.saveRecentProjects(e);else try{localStorage.setItem(oe,JSON.stringify(e))}catch{}}async function sE(){let e=V();if(!e)return;try{M=await e.getRecentProjects()}catch{M=[]}}function Xg(){return re().toSorted((e,t)=>t.timestamp-e.timestamp)}function Qg(e,t){let n=re().filter((o)=>o.root!==t);if(n.unshift({name:e,root:t,timestamp:Mo()}),n.length>ve)n.length=ve;be(n)}function pw(e){be(re().filter((t)=>t.root!==e))}function aE(){M=[];let e=V();if(e)e.saveRecentProjects([]);else localStorage.removeItem(oe)}function xe(){try{let e=localStorage.getItem(ye);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function lE(e){let t=xe().toSorted((n,o)=>o.timestamp-n.timestamp);return e==null?t:t.filter((n)=>n.root===e)}function Ff(e){let t=xe().filter((r)=>!(r.root===e.root&&r.path===e.path));t.unshift({name:e.name,path:e.path,root:e.root,timestamp:Mo()});let n=new Map,o=[];for(let r of t.toSorted((a,i)=>i.timestamp-a.timestamp)){let a=(n.get(r.root)??0)+1;if(n.set(r.root,a),a<=Qe)o.push(r)}localStorage.setItem(ye,JSON.stringify(o))}var Pe={$schema:"https://jxsuite.com/schema/v1",$id:"StudioFilesPanel",$description:'The Navigator\'s Files tree, as a Jx document over the kit. `files/files.ts` keeps every decision — which directories are listed, which entries `.gitignore` masks, which rows the window draws, what a click on a row means, what the context menu offers and what each verb does to the filesystem — and hands this document one projection: a word saying which of three things to draw, a toolbar whose state is already resolved, and rows whose every field is already a string. Nothing here asks what a file is, how tall the Navigator is, or whether a directory has been read. THE TREE IS `jx-tree`, and that is what this document no longer says: `role="tree"`, `role="treeitem"`, `aria-level`, `aria-posinset`, `aria-setsize`, the roving `tabindex` and the five arrow-key cases were each written out here and written out again in `panel-outline.json`, two copies of one keyboard contract with nothing holding them in agreement. The element owns all of it; what is left here is what this tree IS — a flat projection of rows, each already carrying its own level and set counts, because the DOM holds a WINDOW onto the model and an expanded `node_modules` is eleven rows rather than ten thousand. The window reaches the element as `padtop`/`padbottom`, and a caret move past either comes back as `move` for the flow to scroll and repaint. Four facts a row carries are bound against ONE scope field each — the current path, the selected path, the dragged path and the drop target — so moving the caret or dragging a file re-evaluates an attribute per drawn row instead of rebuilding the list under the reader\'s pointer. The pragmatic-drag-and-drop handles are an ISLAND: the document draws the rows and the tree, and the adapter attaches sources and targets to them through `onNodeCreated` (specs/studio-ui-guidelines.md §9.4).',tagName:"div",attributes:{part:"files"},style:{$description:"What the twenty `.file-tree*`, `.files-toolbar`, `.project-header` and `.project-name` rules in `styles/panels.css` said, keyed on `part` and re-pointed at the studio token layer. Three names could not come with the declarations. The five `var(--spectrum-font-size-50 | -75, …)` reads are the kit's `--jx-text-sm` and `--jx-text-md`, which are the same 11px and 12px — a `--spectrum-*` name is declared by `<sp-theme>` and by nothing else in this package, so a document that reads one is a document whose type size changes when a component it does not use is removed. The `.selected`, `.dragging`, `.drag-over` and `.drag-over-root` classes are `data-` attributes on a part, because a part is the handle now and because a state a handler adds and forgets to take off is exactly the defect a cancelled drag used to leave on screen. MOST OF THE ROW'S OWN RULES ARE GONE, and that is the point of the element rather than an omission: `jx-tree-item` declares the flex line, the one-control-height box the window reserves scroll by, the indent (`--jx-tree-indent` times one less than `level` — exactly the `8 + depth * 16` this file composed per row), the hover and focus states, the selected wash and the faded dragged row. What is left here is what is TRUE OF THIS TREE and not of trees in general: it owns its own scrollbar, a click on a row opens it, and the row a drag is over wears the drop mark this file draws.",display:"flex",flexDirection:"column",height:"100%",minHeight:"0",overflow:"hidden",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="empty"]':{$description:"The two states that are not a tree. They are two states and not one sentence: a window with no project at all and a monorepo root that has not been pointed at a site are different situations, and only the second has anything to offer (studio-ui-guidelines.md §11).",padding:"var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)",fontSize:"var(--jx-text-md)",display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-4)"},'& [part="empty"] p':{margin:"0"},'& [part="frame"]':{display:"flex",flexDirection:"column",height:"100%",minHeight:"0"},'& [part="project-header"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)",flexShrink:"0"},'& [part="project-name"]':{fontSize:"var(--jx-text-md)",fontWeight:"600",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="toolbar"]':{display:"flex",gap:"var(--jx-space-2)",padding:"var(--jx-space-2) var(--jx-space-3)",borderBottom:"1px solid var(--border)",alignItems:"center",flexShrink:"0"},'& [part="search"]':{flex:"1",minWidth:"0"},'& [part="tree"]':{$description:"The scroller as well as the list. `ui/virtual-window.ts` walks up from the element it is given looking for the nearest thing that scrolls, and finding itself is the shortest answer — which is why the element declares no `overflow` of its own and leaves the question to the two trees that answer it differently. The colour is re-declared because `jx-tree` sets `--jx-fg` on itself, and this panel's text colour is the studio alias of it.",flex:"1",minHeight:"0",overflowY:"auto",color:"var(--fg)"},'& [part="tree"][data-drop="true"]':{background:"var(--hover-bg)"},'& [part="row"]':{$description:"What the element does not decide. A click on a row OPENS it here — a directory unfolds, a file takes a tab — so the pointer is a pointer rather than the element's default arrow; and the gap is the wider one this tree has always drawn between a 16px file glyph and its name.",gap:"var(--jx-space-3)",cursor:"pointer"},'& [part="loading-row"]':{$description:"A directory whose listing has not arrived yet. It holds the place and it is NOT a row: it is not a `jx-tree-item`, so the caret cannot land on it, the set counts do not include it and typeahead cannot match it — and it is replaced by the real rows on the repaint the listing provokes. It draws the same box by hand because it is the only line in this tree the element does not draw, and a placeholder of a different height would desynchronise the window's scroll reservation from the rows it reserves for.",display:"flex",alignItems:"center",boxSizing:"border-box",blockSize:"var(--jx-control-h)",paddingInline:"calc(var(--jx-space-3) + var(--depth, 0) * 16px) var(--jx-space-3)",color:"var(--fg-dim)",fontStyle:"italic",cursor:"default",userSelect:"none",whiteSpace:"nowrap"},'& [part="row-icon"]':{flexShrink:"0",display:"flex",alignItems:"center","--jx-icon-size":"16px"},'& [part="locale"]':{$description:"The language chip. Deliberately declares no block size, no padding and no line height: the row above is one control-height by contract, and a chip that grew the box would desynchronise the window's scroll reservation from the height it reserves by. It only ever shrinks the text. A chip, not a filter term: the search matches the file's name alone, because a query that silently also matched a language would make “why is this file here” unanswerable from what is on screen.",marginInlineStart:"auto",flexShrink:"0",fontSize:"var(--jx-text-sm)",color:"var(--fg-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxInlineSize:"6em"},'& [part="view-slot"], & [part="header-slot"], & [part="locale-slot"]':{$description:"A `$switch` renders its own container, and none of these three is a box: each stands exactly where its case does, so the case's own rule is the only one that lays anything out.",display:"contents"}},children:[{tagName:"div",attributes:{part:"view-slot",role:"none"},$switch:{$ref:"#/state/view"},cases:{none:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"No project loaded"}]},welcome:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Open a project folder to get started."},{tagName:"jx-button",attributes:{part:"open-project"},$props:{variant:"accent",size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openProject"},value:[]}],description:"The declared `project.open` command, run through the registry — not a second opener of this surface's own. It is the one the chord, the palette and the status bar's PROJECT field already run, so a window that opens a project from here reports the outcome the same way they do (studio-ui-guidelines.md §12.5)."},children:[{tagName:"span",textContent:"Open Project"}]}]},tree:{tagName:"div",attributes:{part:"frame"},children:[{tagName:"div",attributes:{part:"header-slot",role:"none"},$switch:{$ref:"#/state/headerState"},cases:{shown:{tagName:"div",attributes:{part:"project-header"},children:[{tagName:"span",attributes:{part:"project-name",title:"${state.projectName}"},textContent:"${state.projectName}"}]}}},{tagName:"div",attributes:{part:"toolbar"},children:[{$description:"A row of quiet tools, so NOT compact. A compact group draws every member's frame and fill whatever its quiet says, which is the segmented look a choice wants and not the borderless one a toolbar wants; Spectrum's group here was `compact quiet`, a combination the kit spells as compact=false with its members' default quiet.",tagName:"jx-action-group",attributes:{part:"toolbar-actions"},$props:{compact:!1,label:"File tree actions"},children:[{tagName:"jx-action-button",attributes:{part:"new-file"},$props:{size:"sm",icon:"plus",label:"New File",hint:"New File"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/newFile"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"refresh"},$props:{size:"sm",icon:"arrows-clockwise",label:"Refresh",hint:"Refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}],description:"The rules go with the listings. Refresh is what an author reaches for after editing a `.gitignore` by hand, and a tree that came back still hiding by the old rules would read as the button not having worked."}},{tagName:"jx-action-button",attributes:{part:"show-ignored"},$props:{size:"sm",icon:{$ref:"#/state/ignoredIcon"},label:{$ref:"#/state/ignoredLabel"},hint:{$ref:"#/state/ignoredLabel"},selected:{$ref:"#/state/ignoredSelected"}},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleIgnored"},value:[]}],description:"A repaint and nothing else: the ignored entries were never dropped from the cached listings, only from the rows built out of them."}}]},{tagName:"jx-textfield",attributes:{part:"search"},$props:{label:"Filter files",placeholder:"Filter files…",size:"sm",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/search"},value:[{$ref:"event#/target/value"}]}],description:"The query matches a file's NAME and nothing else. A directory is kept whatever it says, because hiding the folder a match sits in would leave the match with nowhere to be drawn."}}]},{$description:'The `role="tree"`, and everything that used to be spelled out under it. The element writes the role, the name, the roving tab stop and every row\'s `aria-level` / `aria-posinset` / `aria-setsize`, and it owns the whole ARIA keyboard: the arrows walk the drawn rows without wrapping, `Home` and `End` reach the ends of the MODEL by way of the pads, `ArrowRight` opens a directory and steps into an open one, `ArrowLeft` closes one and otherwise steps out to its parent, `Enter` activates and a printable character is typeahead. Every chord it does not own — cut, copy, paste, delete, rename — passes straight through to the flow, which is the WCAG 2.5.7 obligation this tree carries because dragging a file is the other way to move it. What reaches this document is five events, and each of them is a decision `files.ts` already owned.',tagName:"jx-tree",attributes:{part:"tree",label:"Project files",current:"${state.currentPath}",padtop:"${state.padTop}",padbottom:"${state.padBottom}","data-drop":"${state.rootDrop || null}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"event#/detail/value"}]}],description:"The reader meant that row. This tree is single-select, so the element resolves every modifier to `replace` before it gets here and the detail's `mode` and `anchor` are answers to a question this tree does not ask. There is no `change` handler beside it on purpose: the element OWNS the caret and keeps it across every repaint that does not change `current`, so a second copy of it in the flow would be a variable that only ever went stale."},onactivate:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"event#/detail"}]}],description:"`Enter` or a double click. The same verb a single click reaches, by the same name."},onexpand:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/expand"},value:[{$ref:"event#/detail/value"},{$ref:"event#/detail/expanded"}]}],description:"`ArrowRight`, `ArrowLeft` or the twisty, with ONE dispatcher between them: the detail says the state the row should be PUT INTO, so the flow never has to work out which way a toggle was going."},onmove:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/move"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/key"}]}],description:"The caret has to reach a row the window did not draw. The element knows only that the pad on that side is not zero; where the row is in the model, and how far to scroll to bring it into view, is the flow's — which is why this is an event and not a `scrollIntoView`."},ontypeahead:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/typeahead"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/char"}]}],description:"A printable character, on a windowed tree. The same hand-off as `onmove` and for a sharper reason: a move off the end of the slice announces itself, and a letter never does — the element's own search over the drawn rows always answers, and over a `node_modules` of ten thousand entries the answer is whichever of the eleven painted rows happened to start with that letter. So the element dispatches EVERY such character and the flow answers it over the model."},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"row-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/kind"},cases:{item:{tagName:"jx-tree-item",attributes:{part:"row",value:"${$map.item.path}",label:"${$map.item.name}",level:"${$map.item.level}",posinset:"${$map.item.posInSet}",setsize:"${$map.item.setSize}",expanded:"${$map.item.ariaExpanded}",selected:"${state.selectedPath === $map.item.path ? 'true' : 'false'}","data-type":"${$map.item.type}","data-dragging":"${state.dragPath === $map.item.path ? '' : null}","data-drop":"${state.dropPath === $map.item.path ? '' : null}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/path"}]}],description:"A single click OPENS the row, which is this tree's own answer and not the element's. `jx-tree` answers a click with `change` and `select`, exactly as it answers an arrow key, and a tree that opened on `select` would open every file the reader arrowed past. So the opening verb is bound here, where a click is a click; what a click MEANS — unfold this directory, take a tab for that file — stays the flow's, and Enter reaches the same verb through `activate`. It does NOT stop the event, which is the correction: the tree's delegated click is what moves the caret and the selection onto the row, so a `stopPropagation` here would leave a reader who clicked a folder with the tab stop still on whatever they had open last. The twisty stops its own click, so opening a directory from the chevron does not also activate the row."},oncontextmenu:{$prototype:"Function",body:[{preventDefault:!0},{stopPropagation:!0},{operator:"call",target:{$ref:"#/state/contextMenu"},value:[{$ref:"$map/item/path"},{$ref:"event#/clientX"},{$ref:"event#/clientY"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon",part:"row-icon","aria-hidden":"true"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"div",attributes:{slot:"status",part:"locale-slot",role:"none"},$switch:{$ref:"$map/item/localeState"},cases:{shown:{tagName:"span",attributes:{part:"locale"},textContent:"${$map.item.locale}"}}}]},loading:{$description:"A directory whose listing has not arrived yet. Deliberately not a `jx-tree-item`: there is no file there to select, open, rename or drag, and a row the caret could land on that answers to none of the verbs the caret offers is a stop in the walk with nothing behind it.",tagName:"div",attributes:{part:"loading-row",role:"none","data-loading":"true",style:"--depth:${$map.item.depth}"},textContent:"Loading…"}}}}]}]}}}]};T("files-panel",Pe);function Fe(e,t){e.view=t.view,e.headerState=t.headerState,e.projectName=t.projectName,e.query=t.query,e.ignoredLabel=t.ignoredLabel,e.ignoredIcon=t.ignoredIcon,e.ignoredSelected=t.ignoredSelected,e.padTop=t.padTop,e.padBottom=t.padBottom,e.rows=t.rows,e.selectedPath=t.selectedPath,e.dragPath=t.dragPath,e.dropPath=t.dropPath,e.rootDrop=t.rootDrop,e.currentPath=t.currentPath}function J(){return{currentPath:"",dragPath:"",dropPath:"",headerState:"hidden",ignoredIcon:"eye-slash",ignoredLabel:"Show ignored files",ignoredSelected:!1,padBottom:0,padTop:0,projectName:"",query:"",rootDrop:"",rows:[],selectedPath:"",view:"none"}}function et(e){let t=typeof e==="string"?void 0:e.attributes?.part;return typeof t==="string"?t:""}function nt(e){let n=e?.$map?.item;return typeof n?.path==="string"?n:null}function je(e,t,n){let o=v({...J(),...n});Fe(o,t);let r=null,a=!1,i=R("files-panel",o,e,{onNodeCreated:(s,l,c,d)=>{if(a||!(s instanceof HTMLElement))return;let F=et(c);if(F==="tree"){n.treeHost(s);return}if(F!=="row")return;let y=nt(d);if(y)n.rowHost(s,y.path,y.type)}}).then((s)=>{if(a){s.dispose();return}r=s});return{connected:()=>!a&&(r===null||r.root.parentNode===e),dispose(){a=!0,r?.dispose(),r=null},ready:i,update:(s)=>{Fe(o,s)}}}async function To(e){if(!D)return;try{let t=p(),[n]=await Promise.all([Ir(()=>t.listDirectory(e)),WE(e)]);D.dirs.set(e,n)}catch{D.dirs.set(e,[])}}function pe(){return Lr(_t.showIgnoredFiles)==="true"}function ot(e){qr(_t.showIgnoredFiles,e?"true":"")}async function Z_(){try{let e=p(),t=await e.probeRootProject();if(!t)return;let{meta:n,info:o}=t;if(Md(),qt(),Ga(e),$u(),pp(),Hl({dirs:new Map,expanded:new Set,isSiteProject:o.isSiteProject,name:o.isSiteProject?o.projectConfig?.name||n.name:n.name,projectConfig:(o.isSiteProject?o.projectConfig:null)||null,projectDirs:o.directories||[],projectRoot:".",root:n.root,searchQuery:"",selectedPath:null}),o.isSiteProject)Ua(n.root||".",o.projectConfig||null);if(o.isSiteProject){if(Qg(vt().name,n.root),await np(),await Pf())Md(),await qt(),Ga(e);await To("."),await Dl(),await jf(),tp(n.root)}}catch{}}async function X_({renderLeftPanel:e}){try{let t=p(),n=await t.openProject();if(!n)return!1;let{config:o,handle:r}=n;if(ek({document:{children:[],tagName:"div"},id:"initial"}),zE(),Md(),qt(),Ga(t),$u(),pp(),Hl({...D,dirs:new Map,expanded:new Set,isSiteProject:!0,name:o.name||r.name,projectConfig:o,projectRoot:r.root,searchQuery:"",selectedPath:null}),Ua(r.root,o),await np(),await Pf())Md(),await qt(),Ga(t);await To("."),await Dl();let a=new Set(["pages","layouts","components","content","data","public","styles"]),i=vt().dirs.get(".")||[],s=[];for(let l of i)if(l.type==="directory"&&a.has(l.name))s.push(l.name),vt().expanded.add(l.path||l.name),await To(l.path||l.name);return vt().projectDirs=s,Bf(),Zb(),fs("files"),Qg(vt().name,vt().projectRoot),e(),await jf(),tp(vt().projectRoot),!0}catch(t){return k.error("Could not open the project.",{detail:te(t),source:"Open Project"}),!1}}async function Q_(e){let t=p();if(t.createDestination!=="path")return!1;try{if(await t.activate(e),(await t.gitStatus()).isRepo)return!1;return await t.gitInit(),k.success("Initialized a git repository for this project."),!0}catch(n){return k.warn("Could not initialize a git repository — the project itself was written.",{detail:te(n),source:"Source Control"}),!1}}async function fw(){await qt();let e=[...Ka("page"),".json"],t;try{t=await p().listDirectory("pages")}catch{return null}let n=new Set(t.filter((o)=>o.type==="file").map((o)=>o.name));for(let o of e)if(n.has(`index${o}`))return`pages/index${o}`;return null}async function rt(){let e=await fw();if(e)await Lo(e)}async function jf(){let e=tL(m.projectRoot);if(Yb(m.projectRoot),e){if(await XT(e,{ensureSecondPane:()=>{Pl(Qn)},openFile:(n,o)=>Lo(n,{focus:!1,paneId:o})})>0)return!0}return await rt(),!1}function at(e,t,n){if(t==="directory")return n?"folder-open":"folder";let o=e.split(".").pop()?.toLowerCase();switch(o){case"css":case"js":case"json":case"ts":return"file-code";case"md":return"file-text";default:return o!==void 0&&ev(o)?"image":"file"}}function e1(){return tt}function t1(e){}var it=24,u=[],A=null,L=new Map,B=null,Se=null;function ue(){for(let e of L.values())if(e.isConnected&&e.offsetHeight>0)return e.offsetHeight;return it}function st(){for(let[e,t]of L)if(!t.isConnected)L.delete(e),Oe(t)}function Re(e){let t=L.get(e);return t?.isConnected===!0?t:null}function X(e){return u.find((t)=>!t.loading&&t.path===e)}function ke(e,t,n,o){let r=vt().dirs.get(e);if(!r){To(e).then(()=>f()),n.push({depth:t,expanded:!1,key:`loading:${e}`,loading:!0,name:"Loading…",path:e,posInSet:1,setSize:1,type:"file"});return}let a=[...r].toSorted((c,d)=>{if(c.type==="directory"&&d.type!=="directory")return-1;if(c.type!=="directory"&&d.type==="directory")return 1;return c.name.localeCompare(d.name)}),i=pe()?a:a.filter((c)=>!VE(e,c.path,c.type==="directory")),s=vt().searchQuery.toLowerCase(),l=s?i.filter((c)=>c.type==="directory"||c.name.toLowerCase().includes(s)):i;for(let[c,d]of l.entries()){let y=d.type==="directory"&&vt().expanded.has(d.path);if(n.push({depth:t,expanded:y,key:d.path,loading:!1,name:d.name,path:d.path,locale:zu(d.path,o)??void 0,posInSet:c+1,setSize:l.length,type:d.type}),y)ke(d.path,t+1,n,o)}}function Ee(e){return e===void 0?-1:u.findIndex((t)=>!t.loading&&t.path===e)}function q(e,t){for(let n=e+t;n>=0&&n<u.length;n+=t)if(!u[n].loading)return n;return-1}function lt(e){let t=u[e];if(!t)return-1;for(let n=e-1;n>=0;n--){let o=u[n];if(!o.loading&&o.depth<t.depth)return n}return-1}function ct(){if(A?.isConnected!==!0||O!=="")return;queueMicrotask(f)}function ie(){let e=A;if(e===null)return;B=nb(B,e,{count:()=>u.length,onChange:ct,rowHeight:ue})}function dt(e){let t=String(e.depth+1);if(e.loading)return{ariaExpanded:"",depth:String(e.depth),icon:"",key:e.key,kind:"loading",level:t,locale:"",localeState:"hidden",name:e.name,path:e.path,posInSet:"",setSize:"",type:e.type};return{ariaExpanded:e.type==="directory"?String(e.expanded):"",depth:String(e.depth),icon:at(e.path,e.type,e.expanded),key:e.key,kind:"item",level:t,locale:e.locale===void 0?"":dn(e.locale),localeState:e.locale===void 0?"hidden":"shown",name:e.name,path:e.path,posInSet:String(e.posInSet),setSize:String(e.setSize),type:e.type}}function pt(){if(st(),!D){u=[];let s={...J(),view:"none"};return P=s,s}if(!D.isSiteProject&&D.projectRoot==="."){u=[];let s={...J(),view:"welcome"};return P=s,s}let e=vt();u=[];let{i18n:t}=$o(e.projectConfig??{});ke(".",0,u,t);let n=eb(A,{count:u.length,rowHeight:ue()}),o=u.slice(n.start,n.end),r=(e.selectedPath!==null&&X(e.selectedPath)?e.selectedPath:"")||o.find((s)=>!s.loading)?.path||"",a=pe(),i={currentPath:r,dragPath:O,dropPath:W,headerState:e.isSiteProject?"shown":"hidden",ignoredIcon:a?"eye":"eye-slash",ignoredLabel:a?"Hide ignored files":"Show ignored files",ignoredSelected:a,padBottom:n.padBottom,padTop:n.padTop,projectName:e.projectConfig?.name||e.name,query:e.searchQuery,rootDrop:Z,rows:o.map((s)=>dt(s)),selectedPath:e.selectedPath??"",view:"tree"};return P=i,i}function se(){if(!w||!P)return;P={...P,dragPath:O,dropPath:W,rootDrop:Z},w.handle.update(P)}function f(){Se?.()}async function ut(){let e=vt();e.dirs.clear(),$u(),await To(".");for(let t of e.expanded)await To(t);f()}function ft(e){let t=X(e);if(!t)return;if(t.type==="directory"){Ce(e).then(()=>f());return}Lo(e)}function ht(e,t){let n=vt();if(X(e)?.type!=="directory"||n.expanded.has(e)===t)return;if(!t){n.expanded.delete(e),f();return}Ce(e).then(()=>f())}function Te(e){if(!D||vt().selectedPath===e)return;vt().selectedPath=e,f()}function mt(e,t){let n=Ee(e),o;switch(t){case"Home":{o=q(-1,1);break}case"End":{o=q(u.length,-1);break}case"ArrowUp":{o=q(n,-1);break}case"ArrowLeft":{o=lt(n);break}case"ArrowDown":case"ArrowRight":{o=q(n,1);break}default:return}De(o)}function gt(e,t){let n=Ee(e),o=u.length;for(let r=1;r<=o;r++){let a=(n+r+o)%o,i=u[a];if(i&&!i.loading&&i.name.trim().toLowerCase().startsWith(t)){De(a);return}}}function De(e){let t=u[e];if(!t)return;if(Te(t.path),Re(t.path))return;tb(A,e,ue()),f()}async function Ce(e){let t=vt();if(t.expanded.has(e)){t.expanded.delete(e);return}if(t.expanded.add(e),!t.dirs.has(e))await To(e)}var z=new Map,G=null,O="",K="",W="",Y=!1,Z="";function wt(e){return[...e.dataTransfer?.types??[]].includes("Files")}function Ne(e,t,n){let o=(i)=>{if(!wt(i))return;if(i.preventDefault(),i.stopPropagation(),i.dataTransfer)i.dataTransfer.dropEffect="copy";n(!0)},r=()=>n(!1),a=(i)=>{n(!1);let s=i.dataTransfer?.files;if(!s?.length)return;i.preventDefault(),i.stopPropagation(),Le(s,t,f)};return e.addEventListener("dragover",o),e.addEventListener("dragleave",r),e.addEventListener("drop",a),()=>{e.removeEventListener("dragover",o),e.removeEventListener("dragleave",r),e.removeEventListener("drop",a)}}function le(e,t){let n=e.replaceAll("\\","/"),o=t.replaceAll("\\","/");if(!n||n===o)return!1;if(n.startsWith(`${o}/`)||o.startsWith(`${n}/`))return!1;return Q(n)!==o}function ae(e,t,n){return n==="directory"&&typeof e==="string"&&le(e,t)}function I(e,t){let n=t?e:"";if(K===e&&W===n)return;K=e,W=n,Ie()}function U(e){if(Y===e)return;Y=e,Ie()}function Ie(){Z=Y&&K===""?"true":"",se()}async function Le(e,t,n){if((await Va([...e],{dir:t})).length===0)return;if(t!==".")vt().expanded.add(t);n()}function yt(e,t){let n=document.createElement("input");n.type="file",n.multiple=!0,n.accept=_c(),n.addEventListener("change",()=>{if(n.files?.length)Le(n.files,e,t)}),n.click()}function bt(e,t,n){Oe(e),L.set(t,e);let o=[gs({element:e,getInitialData(){return{entryType:n,path:t,type:"file-tree"}},onDragStart(){O=t,se()},onDrop(){O="",I("",!1),se()}}),Ne(e,n==="directory"?t:Q(t),(r)=>{I(r?t:"",r)}),zs({canDrop({source:r}){return r.data.type==="file-tree"},element:e,getData({source:r}){return ae(r.data.path,t,n)?{targetDir:t,type:"file-tree-target"}:{type:"file-tree-refused"}},onDrag({source:r}){I(t,ae(r.data.path,t,n))},onDragEnter({source:r}){I(t,ae(r.data.path,t,n))},onDragLeave(){I("",!1)},onDrop(){I("",!1)}})];z.set(e,gr(...o))}function Oe(e){let t=z.get(e);if(t)t(),z.delete(e)}function xt(e){if(G?.element===e)return;Ae(),A=e;let t=zs({canDrop({source:o}){return o.data.type==="file-tree"&&le(o.data.path,".")},element:e,getData(){return{targetDir:".",type:"file-tree-target"}},onDragEnter(){U(!0)},onDragLeave(){U(!1)},onDrop(){U(!1)}}),n=Ws({onDrop({source:o,location:r}){let[a]=r.current.dropTargets;if(!a)return;if(o.data.type!=="file-tree")return;if(a.data.type!=="file-tree-target")return;let i=o.data.path,s=a.data.targetDir;if(!le(i,s))return;let l=i.split("/").pop(),c=s==="."?l:`${s}/${l}`;Pt(i,c,f)}});G={cleanup:gr(t,n,Ne(e,".",U)),element:e},ie()}function Ae(){G?.cleanup(),G=null;for(let e of z.values())e();z.clear(),B?.window.destroy(),B=null,A=null,O="",K="",W="",Y=!1,Z=""}async function Pt(e,t,n){let o=p();Ps(e,t);try{let r=await o.renameFile(e,t);ua();for(let[s]of m.tabs.entries())if(s===e)Sv(e,t,t);else if(s.startsWith(`${e}/`)){let l=t+s.slice(e.length);Sv(s,l,l)}let a=Q(e),i=Q(t);if(await To(a),i!==a)await To(i);if(i!==".")vt().expanded.add(i);ze(r,t),n(),cE(`Moved to ${t}`,r,t)}catch(r){k.error(`Could not move ${e}.`,{detail:te(r),path:e,source:"Files"})}}function Q(e){let t=e.replaceAll("\\","/"),n=t.lastIndexOf("/");return n===-1?".":t.slice(0,n)}var H=null;function Me(){H?.close(),H=null}function Ft(e){let t={};if(e.type==="directory"){let n=bp(e.path);if(n?.isSourceRoot===!0&&!n.fileBacked)t.name=n.name;return t}if(t.file=e.path,sa(e.path))t.path=e.path;if(hw(e.path).length>0)t.source=e.path;return t}function S(e,t,n,o={}){return{destructive:!1,disabled:!1,dividerAbove:!1,id:e,run:n,title:t,...o}}function jt(e){let t=ne();if(!t)return[];let n=Ft(e),o=[];for(let r of t.forPlacement("context/file")){let a=r.args;if(!(a?.required??[]).every((l)=>(l in n)))continue;let i={};for(let l of Object.keys(a?.properties??{}))if(l in n)i[l]=n[l];let s=t.disabledReason(r.id);o.push(s===void 0?S(r.id,r.title,()=>{on(t,r.id,i,"Files")}):{destructive:!1,disabled:!0,dividerAbove:!1,id:r.id,requires:s,title:r.title})}return o}function $t(e){let t=e.type==="directory",n=[];if(t){if(n.push(S("files.newFile","New File…",()=>{He(e.path,f)}),S("files.upload","Upload Files…",()=>{yt(e.path,f)})),e.path==="pages"||e.path.endsWith("/pages"))n.push(S("files.pagesGrid","Edit Pages in Grid",()=>{E1()}))}else n.push(S("files.open","Open",()=>{Lo(e.path)}));return n.push(...jt(e),S("files.rename","Rename…",()=>{Ct(e,f)},{dividerAbove:!0}),S("files.delete","Delete",()=>{It(e,f)},{destructive:!0})),n}function St(e,t,n){let o=X(e);if(!o)return;Me();let r=Re(e);H=Nt({label:"File actions",onClosed:(a)=>{if(H===a)H=null},opener:r,origin:{x:t,y:n},region:"files",rows:$t({name:o.name,path:o.path,type:o.type})})}var Rt=JSON.stringify({children:[{children:[],tagName:"p"}],tagName:"div"},null,2),E="__other__";function $e(e){return e.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function ce(e){let t=e.lastIndexOf(".");return t>0?e.slice(t):""}function kt(e){return[...(e.kind==="locked"?[{ext:e.ext,label:`${Vs(e.ext)?.name??e.ext} (${e.ext})`}]:ge(e.docKind)).map((n)=>({label:n.label,value:n.ext})),{dividerBefore:!0,label:"Other…",value:E}]}function Et(e,t,n){let o=e.kind==="choose"?e.defaultExt:e.ext;if(o!==void 0&&t.some((a)=>a.value===o))return o;let r=ce(n);if(r!==""&&t.some((a)=>a.value===r))return r;return t[0]?.value??E}async function mw(e){let{dir:t,format:n,source:o="Files"}=e;await qt();let r=new Set;try{let g=await p().listDirectory(t);r=new Set(g.map((h)=>h.name.toLowerCase()))}catch{}let a=n!==void 0&&n.kind!=="fixed"?n:null,i=a===null?null:kt(a),s=a===null||i===null?"":Et(a,i,e.suggestedName??""),l=(g,h)=>{let b=g.trim();if(n===void 0||h===E)return b;if(n.kind==="fixed"){let x=$e(b);return x===""?"":`${x}${n.ext}`}return b.toLowerCase().endsWith(h.toLowerCase())?b:`${b}${h}`},c=we(),d=(g,h)=>{let b=g.trim();if(!b)return n?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(n?.kind==="fixed"&&$e(b)==="")return"Enter at least one letter or number.";let x=b.replaceAll("\\","/");if(x.startsWith("/")||x.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(x.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(x.includes("/")&&n!==void 0&&h!==E)return`Pick Other… to create a file in a subfolder of ${t==="."?"the project root":t}.`;let j=ce(x);if(h!==""&&h!==E&&j!==""&&j.toLowerCase()!==h.toLowerCase()&&c.has(j.toLowerCase()))return`You picked ${i?.find((Ue)=>Ue.value===h)?.label??h}; this name ends in ${j}.`;if(n?.kind==="locked"&&h===E){if(j!==""&&j.toLowerCase()!==n.ext.toLowerCase()&&c.has(j.toLowerCase()))return n.because}let he=l(g,h);return r.has(he.toLowerCase())?`${he} already exists in ${t}/.`:""},F=s,y=await Nn(e.title??"New File",{...i===null?{}:{choice:{initial:s,label:"Format",onChange:(g)=>{F=g},options:()=>i}},confirmLabel:"Create",message:t==="."?"Creating in the project root.":`Creating in ${t}/`,...e.suggestedName===void 0?{}:{placeholder:e.suggestedName},select:i===null?"stem":"all",validate:d,value:e.suggestedName??"untitled.json"});if(!y)return null;let C=l(y,F),N=t==="."?C:`${t}/${C}`;Ps(N);let fe=Zt(C),_e=typeof e.content==="function"?await e.content(ce(C),C):e.content,Ve=n!==void 0&&F!==E,Je=_e??fe?.studio?.newFileTemplate??(fe?"":C.toLowerCase().endsWith(".json")?Ve?Rt:`{}
2
- `:"");try{return await p().writeFile(N,Je),await To(t),k.success(`Created ${N}`),N}catch(g){return k.error(`Could not create ${N}.`,{detail:te(g),path:N,source:o}),null}}async function He(e,t){await qt();let n=bp(e);if(n?.unresolvedFormat!=null)k.error(`New files in ${e}/ cannot be constrained to the collection's format.`,{detail:`The "${n.name}" content type declares format "${n.unresolvedFormat}", which no installed extension provides. Install the extension that supplies it, or correct `+"the name in Project Settings › Content Types.",path:e,source:"Files"});let o=n?.ext!=null&&n.unresolvedFormat===null,r=o&&n.isSourceRoot&&n.def.schema!==void 0,a;if(r){let{createEntry:i}=await (me("c5h3nqck"),import("./entry-commands-c5h3nqck.js"));a=await i(n.name,{dir:e})}else a=await mw({dir:e,format:o&&n.ext!==null?{because:`${n.name} entries are ${n.ext} files, so a document of another format here would not be one.`,ext:n.ext,kind:"locked"}:{defaultExt:".json",kind:"choose"},suggestedName:"untitled"});if(a!==null)t()}async function Tt(e,t){let n=await Yf(t);return Nn("Rename",{confirmLabel:"Rename",...n===void 0?{}:{message:n},select:"stem",validate:(o)=>o.trim()?"":"Enter a file name.",value:e})}function Dt(e,t){let n=t.references,o=t.tag?`; tag → <${t.tag.to}> (${t.tag.refsUpdated})`:"";if(n&&n.refsUpdated>0)return`Renamed to ${e}; updated ${n.refsUpdated} reference(s) in ${n.filesChanged} file(s)${o}`;if(o)return`Renamed to ${e}${o}`;return`Renamed to ${e}`}function cE(e,t,n){let o=t.errors??[];if(o.length===0){k.success(e);return}let r=o.length===1?"1 file":`${o.length} files`;k.warn(`${e} — references in ${r} could not be updated`,{detail:o.map((a)=>`${a.path}: ${a.error}`).join(`
1
+ import{tt}from"./studio-sxc0zvpt.js";import{te}from"./studio-ery42sqr.js";import{ne}from"./studio-cp1gbff9.js";import{T,R,on,Rc,Nn}from"./studio-7qvs7v0m.js";import{v,Mo,k}from"./studio-fqq890ap.js";import{p,We}from"./studio-y7jehjrp.js";import{qt,Md,Ga,Tp,Vs,Lp,Zt,Ka}from"./studio-cqmtbg2p.js";import{ua}from"./studio-yr04mv2j.js";import{Ir,pp}from"./studio-xkfs0dp2.js";import{dn,$o,zu,wm,bp,Ax,Qn,m,Gu,Pl,Ua,No,ek,ci,Cm,Sv}from"./studio-x5g1xk77.js";import{$u,WE,VE,Ps}from"./studio-mk00zd5d.js";import{_t,Lr,qr}from"./studio-semd1s8s.js";import{hs,XT,tL,Yb,fs,Zb}from"./studio-4m50vh74.js";import{la}from"./studio-capk0583.js";import{qn}from"./studio-rmn2dz59.js";import{Dl}from"./studio-pwqfmt4p.js";import{gr,zs,Ws,gs}from"./studio-st75kn99.js";import{ib,tp,np,ww,fE,Bf}from"./studio-5vy2wfm5.js";import{_c,ev,Va}from"./studio-e47215hh.js";import{AE,E1}from"./studio-3ck2a5c4.js";import{zE,Er,Jf,Yf}from"./studio-qa73881a.js";import{Nt}from"./studio-8xcwewjq.js";import{eb,tb,nb}from"./studio-zd4kayn2.js";import{ls}from"./studio-tzegmy4w.js";import{sa}from"./studio-84rtc120.js";import{D,Hl,vt}from"./studio-tp642n5g.js";import{me}from"./studio-0bbxhhce.js";async function Pf(){if(ib(location.search))return!1;let e=p();if(!e.dependenciesNeedInstall||!e.installDependencies)return!1;let t=!1;try{t=await e.dependenciesNeedInstall()}catch{return!1}if(!t)return!1;let n=la({status:"Running bun install…",title:"Installing dependencies"});try{let o=await e.installDependencies();if(o.ok)return n.done(),!0;n.fail(o.log??"bun install failed")}catch(o){n.fail(o instanceof Error?o.message:String(o))}return!1}var Be=["page","component"],Ge={components:"component",pages:"page"};function _(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Ke(e){let t=_(e).toLowerCase();for(let[n,o]of Object.entries(Ge))if(t.startsWith(`${n}/`))return o;return null}function ee(e){return Be.some((t)=>e.includes(t))}function Ye(e){let t=D?.projectConfig?.layout;if(typeof t!=="string")return!1;return _(t).toLowerCase()===_(e).toLowerCase()}function ge(e){let t=[{ext:".json",label:"JSON (.json)"}];for(let n of Ka(e)){let o=Vs(n,"parse");if(o&&Vs(n,"serialize"))t.push({ext:n,label:`${o.name} (${n})`})}return t}function we(){return new Set([".json",...Tp().flatMap((e)=>e.extensions)])}function hw(e){if(e===null||e===void 0||e==="")return[];let t=Ke(e);if(t===null||Ye(e)||Ax(e))return[];let n=Zt(e);if(!(n?Boolean(n.capabilities.parse)&&ee(n.documentKinds):_(e).toLowerCase().endsWith(".json")))return[];let r=[];if(n)r.push({ext:".json",label:"JSON (.json)"});for(let a of Ka()){let i=Vs(a,"serialize");if(!i||i.name===n?.name||!ee(i.documentKinds)||!i.documentKinds.includes(t))continue;r.push({ext:a,label:`${i.name} (${a})`})}return r}function rE(){let e=new Set([".json"]);for(let t of Tp()){if(!t.capabilities.serialize||!ee(t.documentKinds))continue;for(let n of t.extensions)e.add(n)}return[...e].toSorted()}var oe="jx-studio-recent-projects",ye="jx-studio-recent-files",ve=8,Qe=10,M=[];function V(){if(!We())return null;let e=p();return e.getRecentProjects&&e.saveRecentProjects?e:null}function Xe(){try{let e=localStorage.getItem(oe);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function re(){return V()?M:Xe()}function be(e){M=e;let t=V();if(t)t.saveRecentProjects(e);else try{localStorage.setItem(oe,JSON.stringify(e))}catch{}}async function sE(){let e=V();if(!e)return;try{M=await e.getRecentProjects()}catch{M=[]}}function Xg(){return re().toSorted((e,t)=>t.timestamp-e.timestamp)}function Qg(e,t){let n=re().filter((o)=>o.root!==t);if(n.unshift({name:e,root:t,timestamp:Mo()}),n.length>ve)n.length=ve;be(n)}function pw(e){be(re().filter((t)=>t.root!==e))}function aE(){M=[];let e=V();if(e)e.saveRecentProjects([]);else localStorage.removeItem(oe)}function xe(){try{let e=localStorage.getItem(ye);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function lE(e){let t=xe().toSorted((n,o)=>o.timestamp-n.timestamp);return e==null?t:t.filter((n)=>n.root===e)}function Ff(e){let t=xe().filter((r)=>!(r.root===e.root&&r.path===e.path));t.unshift({name:e.name,path:e.path,root:e.root,timestamp:Mo()});let n=new Map,o=[];for(let r of t.toSorted((a,i)=>i.timestamp-a.timestamp)){let a=(n.get(r.root)??0)+1;if(n.set(r.root,a),a<=Qe)o.push(r)}localStorage.setItem(ye,JSON.stringify(o))}var Pe={$schema:"https://jxsuite.com/schema/v1",$id:"StudioFilesPanel",$description:'The Navigator\'s Files tree, as a Jx document over the kit. `files/files.ts` keeps every decision — which directories are listed, which entries `.gitignore` masks, which rows the window draws, what a click on a row means, what the context menu offers and what each verb does to the filesystem — and hands this document one projection: a word saying which of three things to draw, a toolbar whose state is already resolved, and rows whose every field is already a string. Nothing here asks what a file is, how tall the Navigator is, or whether a directory has been read. THE TREE IS `jx-tree`, and that is what this document no longer says: `role="tree"`, `role="treeitem"`, `aria-level`, `aria-posinset`, `aria-setsize`, the roving `tabindex` and the five arrow-key cases were each written out here and written out again in `panel-outline.json`, two copies of one keyboard contract with nothing holding them in agreement. The element owns all of it; what is left here is what this tree IS — a flat projection of rows, each already carrying its own level and set counts, because the DOM holds a WINDOW onto the model and an expanded `node_modules` is eleven rows rather than ten thousand. The window reaches the element as `padtop`/`padbottom`, and a caret move past either comes back as `move` for the flow to scroll and repaint. Four facts a row carries are bound against ONE scope field each — the current path, the selected path, the dragged path and the drop target — so moving the caret or dragging a file re-evaluates an attribute per drawn row instead of rebuilding the list under the reader\'s pointer. The pragmatic-drag-and-drop handles are an ISLAND: the document draws the rows and the tree, and the adapter attaches sources and targets to them through `onNodeCreated` (specs/studio-ui-guidelines.md §9.4).',tagName:"div",attributes:{part:"files"},style:{$description:"What the twenty `.file-tree*`, `.files-toolbar`, `.project-header` and `.project-name` rules in `styles/panels.css` said, keyed on `part` and re-pointed at the studio token layer. Three names could not come with the declarations. The five `var(--spectrum-font-size-50 | -75, …)` reads are the kit's `--jx-text-sm` and `--jx-text-md`, which are the same 11px and 12px — a `--spectrum-*` name is declared by `<sp-theme>` and by nothing else in this package, so a document that reads one is a document whose type size changes when a component it does not use is removed. The `.selected`, `.dragging`, `.drag-over` and `.drag-over-root` classes are `data-` attributes on a part, because a part is the handle now and because a state a handler adds and forgets to take off is exactly the defect a cancelled drag used to leave on screen. MOST OF THE ROW'S OWN RULES ARE GONE, and that is the point of the element rather than an omission: `jx-tree-item` declares the flex line, the one-control-height box the window reserves scroll by, the indent (`--jx-tree-indent` times one less than `level` — exactly the `8 + depth * 16` this file composed per row), the hover and focus states, the selected wash and the faded dragged row. What is left here is what is TRUE OF THIS TREE and not of trees in general: it owns its own scrollbar, a click on a row opens it, and the row a drag is over wears the drop mark this file draws.",display:"flex",flexDirection:"column",height:"100%",minHeight:"0",overflow:"hidden",fontFamily:"var(--jx-font-sans)",fontSize:"var(--jx-text-md)",color:"var(--fg)",'& [part="empty"]':{$description:"The two states that are not a tree. They are two states and not one sentence: a window with no project at all and a monorepo root that has not been pointed at a site are different situations, and only the second has anything to offer (studio-ui-guidelines.md §11).",padding:"var(--jx-space-6)",textAlign:"center",color:"var(--fg-dim)",fontSize:"var(--jx-text-md)",display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--jx-space-4)"},'& [part="empty"] p':{margin:"0"},'& [part="frame"]':{display:"flex",flexDirection:"column",height:"100%",minHeight:"0"},'& [part="project-header"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",padding:"var(--jx-space-3) var(--jx-space-4)",borderBottom:"1px solid var(--border)",flexShrink:"0"},'& [part="project-name"]':{fontSize:"var(--jx-text-md)",fontWeight:"600",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},'& [part="toolbar"]':{display:"flex",gap:"var(--jx-space-2)",padding:"var(--jx-space-2) var(--jx-space-3)",borderBottom:"1px solid var(--border)",alignItems:"center",flexShrink:"0"},'& [part="search"]':{flex:"1",minWidth:"0"},'& [part="tree"]':{$description:"The scroller as well as the list. `ui/virtual-window.ts` walks up from the element it is given looking for the nearest thing that scrolls, and finding itself is the shortest answer — which is why the element declares no `overflow` of its own and leaves the question to the two trees that answer it differently. The colour is re-declared because `jx-tree` sets `--jx-fg` on itself, and this panel's text colour is the studio alias of it.",flex:"1",minHeight:"0",overflowY:"auto",color:"var(--fg)"},'& [part="tree"][data-drop="true"]':{background:"var(--hover-bg)"},'& [part="row"]':{$description:"What the element does not decide. A click on a row OPENS it here — a directory unfolds, a file takes a tab — so the pointer is a pointer rather than the element's default arrow; and the gap is the wider one this tree has always drawn between a 16px file glyph and its name.",gap:"var(--jx-space-3)",cursor:"pointer"},'& [part="loading-row"]':{$description:"A directory whose listing has not arrived yet. It holds the place and it is NOT a row: it is not a `jx-tree-item`, so the caret cannot land on it, the set counts do not include it and typeahead cannot match it — and it is replaced by the real rows on the repaint the listing provokes. It draws the same box by hand because it is the only line in this tree the element does not draw, and a placeholder of a different height would desynchronise the window's scroll reservation from the rows it reserves for.",display:"flex",alignItems:"center",boxSizing:"border-box",blockSize:"var(--jx-control-h)",paddingInline:"calc(var(--jx-space-3) + var(--depth, 0) * 16px) var(--jx-space-3)",color:"var(--fg-dim)",fontStyle:"italic",cursor:"default",userSelect:"none",whiteSpace:"nowrap"},'& [part="row-icon"]':{flexShrink:"0",display:"flex",alignItems:"center","--jx-icon-size":"16px"},'& [part="locale"]':{$description:"The language chip. Deliberately declares no block size, no padding and no line height: the row above is one control-height by contract, and a chip that grew the box would desynchronise the window's scroll reservation from the height it reserves by. It only ever shrinks the text. A chip, not a filter term: the search matches the file's name alone, because a query that silently also matched a language would make “why is this file here” unanswerable from what is on screen.",marginInlineStart:"auto",flexShrink:"0",fontSize:"var(--jx-text-sm)",color:"var(--fg-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxInlineSize:"6em"},'& [part="view-slot"], & [part="header-slot"], & [part="locale-slot"]':{$description:"A `$switch` renders its own container, and none of these three is a box: each stands exactly where its case does, so the case's own rule is the only one that lays anything out.",display:"contents"}},children:[{tagName:"div",attributes:{part:"view-slot",role:"none"},$switch:{$ref:"#/state/view"},cases:{none:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"No project loaded"}]},welcome:{tagName:"div",attributes:{part:"empty"},children:[{tagName:"p",textContent:"Open a project folder to get started."},{tagName:"jx-button",attributes:{part:"open-project"},$props:{variant:"accent",size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openProject"},value:[]}],description:"The declared `project.open` command, run through the registry — not a second opener of this surface's own. It is the one the chord, the palette and the status bar's PROJECT field already run, so a window that opens a project from here reports the outcome the same way they do (studio-ui-guidelines.md §12.5)."},children:[{tagName:"span",textContent:"Open Project"}]}]},tree:{tagName:"div",attributes:{part:"frame"},children:[{tagName:"div",attributes:{part:"header-slot",role:"none"},$switch:{$ref:"#/state/headerState"},cases:{shown:{tagName:"div",attributes:{part:"project-header"},children:[{tagName:"span",attributes:{part:"project-name",title:"${state.projectName}"},textContent:"${state.projectName}"}]}}},{tagName:"div",attributes:{part:"toolbar"},children:[{$description:"A row of quiet tools, so NOT compact. A compact group draws every member's frame and fill whatever its quiet says, which is the segmented look a choice wants and not the borderless one a toolbar wants; Spectrum's group here was `compact quiet`, a combination the kit spells as compact=false with its members' default quiet.",tagName:"jx-action-group",attributes:{part:"toolbar-actions"},$props:{compact:!1,label:"File tree actions"},children:[{tagName:"jx-action-button",attributes:{part:"new-file"},$props:{size:"sm",icon:"plus",label:"New File",hint:"New File"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/newFile"},value:[]}]}},{tagName:"jx-action-button",attributes:{part:"refresh"},$props:{size:"sm",icon:"arrows-clockwise",label:"Refresh",hint:"Refresh"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/refresh"},value:[]}],description:"The rules go with the listings. Refresh is what an author reaches for after editing a `.gitignore` by hand, and a tree that came back still hiding by the old rules would read as the button not having worked."}},{tagName:"jx-action-button",attributes:{part:"show-ignored"},$props:{size:"sm",icon:{$ref:"#/state/ignoredIcon"},label:{$ref:"#/state/ignoredLabel"},hint:{$ref:"#/state/ignoredLabel"},selected:{$ref:"#/state/ignoredSelected"}},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/toggleIgnored"},value:[]}],description:"A repaint and nothing else: the ignored entries were never dropped from the cached listings, only from the rows built out of them."}}]},{tagName:"jx-textfield",attributes:{part:"search"},$props:{label:"Filter files",placeholder:"Filter files…",size:"sm",value:{$ref:"#/state/query"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/search"},value:[{$ref:"event#/target/value"}]}],description:"The query matches a file's NAME and nothing else. A directory is kept whatever it says, because hiding the folder a match sits in would leave the match with nowhere to be drawn."}}]},{$description:'The `role="tree"`, and everything that used to be spelled out under it. The element writes the role, the name, the roving tab stop and every row\'s `aria-level` / `aria-posinset` / `aria-setsize`, and it owns the whole ARIA keyboard: the arrows walk the drawn rows without wrapping, `Home` and `End` reach the ends of the MODEL by way of the pads, `ArrowRight` opens a directory and steps into an open one, `ArrowLeft` closes one and otherwise steps out to its parent, `Enter` activates and a printable character is typeahead. Every chord it does not own — cut, copy, paste, delete, rename — passes straight through to the flow, which is the WCAG 2.5.7 obligation this tree carries because dragging a file is the other way to move it. What reaches this document is five events, and each of them is a decision `files.ts` already owned.',tagName:"jx-tree",attributes:{part:"tree",label:"Project files",current:"${state.currentPath}",padtop:"${state.padTop}",padbottom:"${state.padBottom}","data-drop":"${state.rootDrop || null}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"event#/detail/value"}]}],description:"The reader meant that row. This tree is single-select, so the element resolves every modifier to `replace` before it gets here and the detail's `mode` and `anchor` are answers to a question this tree does not ask. There is no `change` handler beside it on purpose: the element OWNS the caret and keeps it across every repaint that does not change `current`, so a second copy of it in the flow would be a variable that only ever went stale."},onactivate:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"event#/detail"}]}],description:"`Enter` or a double click. The same verb a single click reaches, by the same name."},onexpand:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/expand"},value:[{$ref:"event#/detail/value"},{$ref:"event#/detail/expanded"}]}],description:"`ArrowRight`, `ArrowLeft` or the twisty, with ONE dispatcher between them: the detail says the state the row should be PUT INTO, so the flow never has to work out which way a toggle was going."},onmove:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/move"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/key"}]}],description:"The caret has to reach a row the window did not draw. The element knows only that the pad on that side is not zero; where the row is in the model, and how far to scroll to bring it into view, is the flow's — which is why this is an event and not a `scrollIntoView`."},ontypeahead:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/typeahead"},value:[{$ref:"event#/detail/from"},{$ref:"event#/detail/char"}]}],description:"A printable character, on a windowed tree. The same hand-off as `onmove` and for a sharper reason: a move off the end of the slice announces itself, and a letter never does — the element's own search over the drawn rows always answers, and over a `node_modules` of ten thousand entries the answer is whichever of the eleven painted rows happened to start with that letter. So the element dispatches EVERY such character and the flow answers it over the model."},children:[{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"div",attributes:{part:"row-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"$map/item/kind"},cases:{item:{tagName:"jx-tree-item",attributes:{part:"row",value:"${$map.item.path}",label:"${$map.item.name}",level:"${$map.item.level}",posinset:"${$map.item.posInSet}",setsize:"${$map.item.setSize}",expanded:"${$map.item.ariaExpanded}",selected:"${state.selectedPath === $map.item.path ? 'true' : 'false'}","data-type":"${$map.item.type}","data-dragging":"${state.dragPath === $map.item.path ? '' : null}","data-drop":"${state.dropPath === $map.item.path ? '' : null}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activate"},value:[{$ref:"$map/item/path"}]}],description:"A single click OPENS the row, which is this tree's own answer and not the element's. `jx-tree` answers a click with `change` and `select`, exactly as it answers an arrow key, and a tree that opened on `select` would open every file the reader arrowed past. So the opening verb is bound here, where a click is a click; what a click MEANS — unfold this directory, take a tab for that file — stays the flow's, and Enter reaches the same verb through `activate`. It does NOT stop the event, which is the correction: the tree's delegated click is what moves the caret and the selection onto the row, so a `stopPropagation` here would leave a reader who clicked a folder with the tab stop still on whatever they had open last. The twisty stops its own click, so opening a directory from the chevron does not also activate the row."},oncontextmenu:{$prototype:"Function",body:[{preventDefault:!0},{stopPropagation:!0},{operator:"call",target:{$ref:"#/state/contextMenu"},value:[{$ref:"$map/item/path"},{$ref:"event#/clientX"},{$ref:"event#/clientY"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon",part:"row-icon","aria-hidden":"true"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"div",attributes:{slot:"status",part:"locale-slot",role:"none"},$switch:{$ref:"$map/item/localeState"},cases:{shown:{tagName:"span",attributes:{part:"locale"},textContent:"${$map.item.locale}"}}}]},loading:{$description:"A directory whose listing has not arrived yet. Deliberately not a `jx-tree-item`: there is no file there to select, open, rename or drag, and a row the caret could land on that answers to none of the verbs the caret offers is a stop in the walk with nothing behind it.",tagName:"div",attributes:{part:"loading-row",role:"none","data-loading":"true",style:"--depth:${$map.item.depth}"},textContent:"Loading…"}}}}]}]}}}]};T("files-panel",Pe);function Fe(e,t){e.view=t.view,e.headerState=t.headerState,e.projectName=t.projectName,e.query=t.query,e.ignoredLabel=t.ignoredLabel,e.ignoredIcon=t.ignoredIcon,e.ignoredSelected=t.ignoredSelected,e.padTop=t.padTop,e.padBottom=t.padBottom,e.rows=t.rows,e.selectedPath=t.selectedPath,e.dragPath=t.dragPath,e.dropPath=t.dropPath,e.rootDrop=t.rootDrop,e.currentPath=t.currentPath}function J(){return{currentPath:"",dragPath:"",dropPath:"",headerState:"hidden",ignoredIcon:"eye-slash",ignoredLabel:"Show ignored files",ignoredSelected:!1,padBottom:0,padTop:0,projectName:"",query:"",rootDrop:"",rows:[],selectedPath:"",view:"none"}}function et(e){let t=typeof e==="string"?void 0:e.attributes?.part;return typeof t==="string"?t:""}function nt(e){let n=e?.$map?.item;return typeof n?.path==="string"?n:null}function je(e,t,n){let o=v({...J(),...n});Fe(o,t);let r=null,a=!1,i=R("files-panel",o,e,{onNodeCreated:(s,l,c,d)=>{if(a||!(s instanceof HTMLElement))return;let F=et(c);if(F==="tree"){n.treeHost(s);return}if(F!=="row")return;let y=nt(d);if(y)n.rowHost(s,y.path,y.type)}}).then((s)=>{if(a){s.dispose();return}r=s});return{connected:()=>!a&&(r===null||r.root.parentNode===e),dispose(){a=!0,r?.dispose(),r=null},ready:i,update:(s)=>{Fe(o,s)}}}async function To(e){if(!D)return;try{let t=p(),[n]=await Promise.all([Ir(()=>t.listDirectory(e)),WE(e)]);D.dirs.set(e,n)}catch{D.dirs.set(e,[])}}function pe(){return Lr(_t.showIgnoredFiles)==="true"}function ot(e){qr(_t.showIgnoredFiles,e?"true":"")}async function Z_(){try{let e=p(),t=await e.probeRootProject();if(!t)return;let{meta:n,info:o}=t;if(Md(),qt(),Ga(e),$u(),pp(),Hl({dirs:new Map,expanded:new Set,isSiteProject:o.isSiteProject,name:o.isSiteProject?o.projectConfig?.name||n.name:n.name,projectConfig:(o.isSiteProject?o.projectConfig:null)||null,projectDirs:o.directories||[],projectRoot:".",root:n.root,searchQuery:"",selectedPath:null}),o.isSiteProject)Ua(n.root||".",o.projectConfig||null);if(o.isSiteProject){if(Qg(vt().name,n.root),await np(),await Pf())Md(),await qt(),Ga(e);await To("."),await Dl(),await jf(),tp(n.root)}}catch{}}async function X_({renderLeftPanel:e}){try{let t=p(),n=await t.openProject();if(!n)return!1;let{config:o,handle:r}=n;if(ek({document:{children:[],tagName:"div"},id:"initial"}),zE(),Md(),qt(),Ga(t),$u(),pp(),Hl({...D,dirs:new Map,expanded:new Set,isSiteProject:!0,name:o.name||r.name,projectConfig:o,projectRoot:r.root,searchQuery:"",selectedPath:null}),Ua(r.root,o),await np(),await Pf())Md(),await qt(),Ga(t);await To("."),await Dl();let a=new Set(["pages","layouts","components","content","data","public","styles"]),i=vt().dirs.get(".")||[],s=[];for(let l of i)if(l.type==="directory"&&a.has(l.name))s.push(l.name),vt().expanded.add(l.path||l.name),await To(l.path||l.name);return vt().projectDirs=s,Bf(),Zb(),fs("files"),Qg(vt().name,vt().projectRoot),e(),await jf(),tp(vt().projectRoot),!0}catch(t){return k.error("Could not open the project.",{detail:te(t),source:"Open Project"}),!1}}async function Q_(e){let t=p();if(t.createDestination!=="path")return!1;try{if(await t.activate(e),(await t.gitStatus()).isRepo)return!1;return await t.gitInit(),k.success("Initialized a git repository for this project."),!0}catch(n){return k.warn("Could not initialize a git repository — the project itself was written.",{detail:te(n),source:"Source Control"}),!1}}async function fw(){await qt();let e=[...Ka("page"),".json"],t;try{t=await p().listDirectory("pages")}catch{return null}let n=new Set(t.filter((o)=>o.type==="file").map((o)=>o.name));for(let o of e)if(n.has(`index${o}`))return`pages/index${o}`;return null}async function rt(){let e=await fw();if(e)await Lo(e)}async function jf(){let e=tL(m.projectRoot);if(Yb(m.projectRoot),e){if(await XT(e,{ensureSecondPane:()=>{Pl(Qn)},openFile:(n,o)=>Lo(n,{focus:!1,paneId:o})})>0)return!0}return await rt(),!1}function at(e,t,n){if(t==="directory")return n?"folder-open":"folder";let o=e.split(".").pop()?.toLowerCase();switch(o){case"css":case"js":case"json":case"ts":return"file-code";case"md":return"file-text";default:return o!==void 0&&ev(o)?"image":"file"}}function e1(){return tt}function t1(e){}var it=24,u=[],A=null,L=new Map,B=null,Se=null;function ue(){for(let e of L.values())if(e.isConnected&&e.offsetHeight>0)return e.offsetHeight;return it}function st(){for(let[e,t]of L)if(!t.isConnected)L.delete(e),Oe(t)}function Re(e){let t=L.get(e);return t?.isConnected===!0?t:null}function X(e){return u.find((t)=>!t.loading&&t.path===e)}function ke(e,t,n,o){let r=vt().dirs.get(e);if(!r){To(e).then(()=>f()),n.push({depth:t,expanded:!1,key:`loading:${e}`,loading:!0,name:"Loading…",path:e,posInSet:1,setSize:1,type:"file"});return}let a=[...r].toSorted((c,d)=>{if(c.type==="directory"&&d.type!=="directory")return-1;if(c.type!=="directory"&&d.type==="directory")return 1;return c.name.localeCompare(d.name)}),i=pe()?a:a.filter((c)=>!VE(e,c.path,c.type==="directory")),s=vt().searchQuery.toLowerCase(),l=s?i.filter((c)=>c.type==="directory"||c.name.toLowerCase().includes(s)):i;for(let[c,d]of l.entries()){let y=d.type==="directory"&&vt().expanded.has(d.path);if(n.push({depth:t,expanded:y,key:d.path,loading:!1,name:d.name,path:d.path,locale:zu(d.path,o)??void 0,posInSet:c+1,setSize:l.length,type:d.type}),y)ke(d.path,t+1,n,o)}}function Ee(e){return e===void 0?-1:u.findIndex((t)=>!t.loading&&t.path===e)}function q(e,t){for(let n=e+t;n>=0&&n<u.length;n+=t)if(!u[n].loading)return n;return-1}function lt(e){let t=u[e];if(!t)return-1;for(let n=e-1;n>=0;n--){let o=u[n];if(!o.loading&&o.depth<t.depth)return n}return-1}function ct(){if(A?.isConnected!==!0||O!=="")return;queueMicrotask(f)}function ie(){let e=A;if(e===null)return;B=nb(B,e,{count:()=>u.length,onChange:ct,rowHeight:ue})}function dt(e){let t=String(e.depth+1);if(e.loading)return{ariaExpanded:"",depth:String(e.depth),icon:"",key:e.key,kind:"loading",level:t,locale:"",localeState:"hidden",name:e.name,path:e.path,posInSet:"",setSize:"",type:e.type};return{ariaExpanded:e.type==="directory"?String(e.expanded):"",depth:String(e.depth),icon:at(e.path,e.type,e.expanded),key:e.key,kind:"item",level:t,locale:e.locale===void 0?"":dn(e.locale),localeState:e.locale===void 0?"hidden":"shown",name:e.name,path:e.path,posInSet:String(e.posInSet),setSize:String(e.setSize),type:e.type}}function pt(){if(st(),!D){u=[];let s={...J(),view:"none"};return P=s,s}if(!D.isSiteProject&&D.projectRoot==="."){u=[];let s={...J(),view:"welcome"};return P=s,s}let e=vt();u=[];let{i18n:t}=$o(e.projectConfig??{});ke(".",0,u,t);let n=eb(A,{count:u.length,rowHeight:ue()}),o=u.slice(n.start,n.end),r=(e.selectedPath!==null&&X(e.selectedPath)?e.selectedPath:"")||o.find((s)=>!s.loading)?.path||"",a=pe(),i={currentPath:r,dragPath:O,dropPath:W,headerState:e.isSiteProject?"shown":"hidden",ignoredIcon:a?"eye":"eye-slash",ignoredLabel:a?"Hide ignored files":"Show ignored files",ignoredSelected:a,padBottom:n.padBottom,padTop:n.padTop,projectName:e.projectConfig?.name||e.name,query:e.searchQuery,rootDrop:Z,rows:o.map((s)=>dt(s)),selectedPath:e.selectedPath??"",view:"tree"};return P=i,i}function se(){if(!w||!P)return;P={...P,dragPath:O,dropPath:W,rootDrop:Z},w.handle.update(P)}function f(){Se?.()}async function ut(){let e=vt();e.dirs.clear(),$u(),await To(".");for(let t of e.expanded)await To(t);f()}function ft(e){let t=X(e);if(!t)return;if(t.type==="directory"){Ce(e).then(()=>f());return}Lo(e)}function ht(e,t){let n=vt();if(X(e)?.type!=="directory"||n.expanded.has(e)===t)return;if(!t){n.expanded.delete(e),f();return}Ce(e).then(()=>f())}function Te(e){if(!D||vt().selectedPath===e)return;vt().selectedPath=e,f()}function mt(e,t){let n=Ee(e),o;switch(t){case"Home":{o=q(-1,1);break}case"End":{o=q(u.length,-1);break}case"ArrowUp":{o=q(n,-1);break}case"ArrowLeft":{o=lt(n);break}case"ArrowDown":case"ArrowRight":{o=q(n,1);break}default:return}De(o)}function gt(e,t){let n=Ee(e),o=u.length;for(let r=1;r<=o;r++){let a=(n+r+o)%o,i=u[a];if(i&&!i.loading&&i.name.trim().toLowerCase().startsWith(t)){De(a);return}}}function De(e){let t=u[e];if(!t)return;if(Te(t.path),Re(t.path))return;tb(A,e,ue()),f()}async function Ce(e){let t=vt();if(t.expanded.has(e)){t.expanded.delete(e);return}if(t.expanded.add(e),!t.dirs.has(e))await To(e)}var z=new Map,G=null,O="",K="",W="",Y=!1,Z="";function wt(e){return[...e.dataTransfer?.types??[]].includes("Files")}function Ne(e,t,n){let o=(i)=>{if(!wt(i))return;if(i.preventDefault(),i.stopPropagation(),i.dataTransfer)i.dataTransfer.dropEffect="copy";n(!0)},r=()=>n(!1),a=(i)=>{n(!1);let s=i.dataTransfer?.files;if(!s?.length)return;i.preventDefault(),i.stopPropagation(),Le(s,t,f)};return e.addEventListener("dragover",o),e.addEventListener("dragleave",r),e.addEventListener("drop",a),()=>{e.removeEventListener("dragover",o),e.removeEventListener("dragleave",r),e.removeEventListener("drop",a)}}function le(e,t){let n=e.replaceAll("\\","/"),o=t.replaceAll("\\","/");if(!n||n===o)return!1;if(n.startsWith(`${o}/`)||o.startsWith(`${n}/`))return!1;return Q(n)!==o}function ae(e,t,n){return n==="directory"&&typeof e==="string"&&le(e,t)}function I(e,t){let n=t?e:"";if(K===e&&W===n)return;K=e,W=n,Ie()}function U(e){if(Y===e)return;Y=e,Ie()}function Ie(){Z=Y&&K===""?"true":"",se()}async function Le(e,t,n){if((await Va([...e],{dir:t})).length===0)return;if(t!==".")vt().expanded.add(t);n()}function yt(e,t){let n=document.createElement("input");n.type="file",n.multiple=!0,n.accept=_c(),n.addEventListener("change",()=>{if(n.files?.length)Le(n.files,e,t)}),n.click()}function bt(e,t,n){Oe(e),L.set(t,e);let o=[gs({element:e,getInitialData(){return{entryType:n,path:t,type:"file-tree"}},onDragStart(){O=t,se()},onDrop(){O="",I("",!1),se()}}),Ne(e,n==="directory"?t:Q(t),(r)=>{I(r?t:"",r)}),zs({canDrop({source:r}){return r.data.type==="file-tree"},element:e,getData({source:r}){return ae(r.data.path,t,n)?{targetDir:t,type:"file-tree-target"}:{type:"file-tree-refused"}},onDrag({source:r}){I(t,ae(r.data.path,t,n))},onDragEnter({source:r}){I(t,ae(r.data.path,t,n))},onDragLeave(){I("",!1)},onDrop(){I("",!1)}})];z.set(e,gr(...o))}function Oe(e){let t=z.get(e);if(t)t(),z.delete(e)}function xt(e){if(G?.element===e)return;Ae(),A=e;let t=zs({canDrop({source:o}){return o.data.type==="file-tree"&&le(o.data.path,".")},element:e,getData(){return{targetDir:".",type:"file-tree-target"}},onDragEnter(){U(!0)},onDragLeave(){U(!1)},onDrop(){U(!1)}}),n=Ws({onDrop({source:o,location:r}){let[a]=r.current.dropTargets;if(!a)return;if(o.data.type!=="file-tree")return;if(a.data.type!=="file-tree-target")return;let i=o.data.path,s=a.data.targetDir;if(!le(i,s))return;let l=i.split("/").pop(),c=s==="."?l:`${s}/${l}`;Pt(i,c,f)}});G={cleanup:gr(t,n,Ne(e,".",U)),element:e},ie()}function Ae(){G?.cleanup(),G=null;for(let e of z.values())e();z.clear(),B?.window.destroy(),B=null,A=null,O="",K="",W="",Y=!1,Z=""}async function Pt(e,t,n){let o=p();Ps(e,t);try{let r=await o.renameFile(e,t);ua();for(let[s]of m.tabs.entries())if(s===e)Sv(e,t,t);else if(s.startsWith(`${e}/`)){let l=t+s.slice(e.length);Sv(s,l,l)}let a=Q(e),i=Q(t);if(await To(a),i!==a)await To(i);if(i!==".")vt().expanded.add(i);ze(r,t),n(),cE(`Moved to ${t}`,r,t)}catch(r){k.error(`Could not move ${e}.`,{detail:te(r),path:e,source:"Files"})}}function Q(e){let t=e.replaceAll("\\","/"),n=t.lastIndexOf("/");return n===-1?".":t.slice(0,n)}var H=null;function Me(){H?.close(),H=null}function Ft(e){let t={};if(e.type==="directory"){let n=bp(e.path);if(n?.isSourceRoot===!0&&!n.fileBacked)t.name=n.name;return t}if(t.file=e.path,sa(e.path))t.path=e.path;if(hw(e.path).length>0)t.source=e.path;return t}function S(e,t,n,o={}){return{destructive:!1,disabled:!1,dividerAbove:!1,id:e,run:n,title:t,...o}}function jt(e){let t=ne();if(!t)return[];let n=Ft(e),o=[];for(let r of t.forPlacement("context/file")){let a=r.args;if(!(a?.required??[]).every((l)=>(l in n)))continue;let i={};for(let l of Object.keys(a?.properties??{}))if(l in n)i[l]=n[l];let s=t.disabledReason(r.id);o.push(s===void 0?S(r.id,r.title,()=>{on(t,r.id,i,"Files")}):{destructive:!1,disabled:!0,dividerAbove:!1,id:r.id,requires:s,title:r.title})}return o}function $t(e){let t=e.type==="directory",n=[];if(t){if(n.push(S("files.newFile","New File…",()=>{He(e.path,f)}),S("files.upload","Upload Files…",()=>{yt(e.path,f)})),e.path==="pages"||e.path.endsWith("/pages"))n.push(S("files.pagesGrid","Edit Pages in Grid",()=>{E1()}))}else n.push(S("files.open","Open",()=>{Lo(e.path)}));return n.push(...jt(e),S("files.rename","Rename…",()=>{Ct(e,f)},{dividerAbove:!0}),S("files.delete","Delete",()=>{It(e,f)},{destructive:!0})),n}function St(e,t,n){let o=X(e);if(!o)return;Me();let r=Re(e);H=Nt({label:"File actions",onClosed:(a)=>{if(H===a)H=null},opener:r,origin:{x:t,y:n},region:"files",rows:$t({name:o.name,path:o.path,type:o.type})})}var Rt=JSON.stringify({children:[{children:[],tagName:"p"}],tagName:"div"},null,2),E="__other__";function $e(e){return e.trim().toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z\d-]/g,"")}function ce(e){let t=e.lastIndexOf(".");return t>0?e.slice(t):""}function kt(e){return[...(e.kind==="locked"?[{ext:e.ext,label:`${Vs(e.ext)?.name??e.ext} (${e.ext})`}]:ge(e.docKind)).map((n)=>({label:n.label,value:n.ext})),{dividerBefore:!0,label:"Other…",value:E}]}function Et(e,t,n){let o=e.kind==="choose"?e.defaultExt:e.ext;if(o!==void 0&&t.some((a)=>a.value===o))return o;let r=ce(n);if(r!==""&&t.some((a)=>a.value===r))return r;return t[0]?.value??E}async function mw(e){let{dir:t,format:n,source:o="Files"}=e;await qt();let r=new Set;try{let g=await p().listDirectory(t);r=new Set(g.map((h)=>h.name.toLowerCase()))}catch{}let a=n!==void 0&&n.kind!=="fixed"?n:null,i=a===null?null:kt(a),s=a===null||i===null?"":Et(a,i,e.suggestedName??""),l=(g,h)=>{let b=g.trim();if(n===void 0||h===E)return b;if(n.kind==="fixed"){let x=$e(b);return x===""?"":`${x}${n.ext}`}return b.toLowerCase().endsWith(h.toLowerCase())?b:`${b}${h}`},c=we(),d=(g,h)=>{let b=g.trim();if(!b)return n?.kind==="fixed"?"Enter a name.":"Enter a file name.";if(n?.kind==="fixed"&&$e(b)==="")return"Enter at least one letter or number.";let x=b.replaceAll("\\","/");if(x.startsWith("/")||x.endsWith("/"))return"Enter a name, not a path that starts or ends with a slash.";if(x.split("/").includes(".."))return"A name cannot step outside the destination folder.";if(x.includes("/")&&n!==void 0&&h!==E)return`Pick Other… to create a file in a subfolder of ${t==="."?"the project root":t}.`;let j=ce(x);if(h!==""&&h!==E&&j!==""&&j.toLowerCase()!==h.toLowerCase()&&c.has(j.toLowerCase()))return`You picked ${i?.find((Ue)=>Ue.value===h)?.label??h}; this name ends in ${j}.`;if(n?.kind==="locked"&&h===E){if(j!==""&&j.toLowerCase()!==n.ext.toLowerCase()&&c.has(j.toLowerCase()))return n.because}let he=l(g,h);return r.has(he.toLowerCase())?`${he} already exists in ${t}/.`:""},F=s,y=await Nn(e.title??"New File",{...i===null?{}:{choice:{initial:s,label:"Format",onChange:(g)=>{F=g},options:()=>i}},confirmLabel:"Create",message:t==="."?"Creating in the project root.":`Creating in ${t}/`,...e.suggestedName===void 0?{}:{placeholder:e.suggestedName},select:i===null?"stem":"all",validate:d,value:e.suggestedName??"untitled.json"});if(!y)return null;let C=l(y,F),N=t==="."?C:`${t}/${C}`;Ps(N);let fe=Zt(C),_e=typeof e.content==="function"?await e.content(ce(C),C):e.content,Ve=n!==void 0&&F!==E,Je=_e??fe?.studio?.newFileTemplate??(fe?"":C.toLowerCase().endsWith(".json")?Ve?Rt:`{}
2
+ `:"");try{return await p().writeFile(N,Je),await To(t),k.success(`Created ${N}`),N}catch(g){return k.error(`Could not create ${N}.`,{detail:te(g),path:N,source:o}),null}}async function He(e,t){await qt();let n=bp(e);if(n?.unresolvedFormat!=null)k.error(`New files in ${e}/ cannot be constrained to the collection's format.`,{detail:`The "${n.name}" content type declares format "${n.unresolvedFormat}", which no installed extension provides. Install the extension that supplies it, or correct `+"the name in Project Settings › Content Types.",path:e,source:"Files"});let o=n?.ext!=null&&n.unresolvedFormat===null,r=o&&n.isSourceRoot&&n.def.schema!==void 0,a;if(r){let{createEntry:i}=await (me("fxzgcc4k"),import("./entry-commands-fxzgcc4k.js"));a=await i(n.name,{dir:e})}else a=await mw({dir:e,format:o&&n.ext!==null?{because:`${n.name} entries are ${n.ext} files, so a document of another format here would not be one.`,ext:n.ext,kind:"locked"}:{defaultExt:".json",kind:"choose"},suggestedName:"untitled"});if(a!==null)t()}async function Tt(e,t){let n=await Yf(t);return Nn("Rename",{confirmLabel:"Rename",...n===void 0?{}:{message:n},select:"stem",validate:(o)=>o.trim()?"":"Enter a file name.",value:e})}function Dt(e,t){let n=t.references,o=t.tag?`; tag → <${t.tag.to}> (${t.tag.refsUpdated})`:"";if(n&&n.refsUpdated>0)return`Renamed to ${e}; updated ${n.refsUpdated} reference(s) in ${n.filesChanged} file(s)${o}`;if(o)return`Renamed to ${e}${o}`;return`Renamed to ${e}`}function cE(e,t,n){let o=t.errors??[];if(o.length===0){k.success(e);return}let r=o.length===1?"1 file":`${o.length} files`;k.warn(`${e} — references in ${r} could not be updated`,{detail:o.map((a)=>`${a.path}: ${a.error}`).join(`
3
3
  `),path:n,source:"Files"})}function ze(e,t){for(let n of e.references?.files??[])if(n.path!==t&&m.tabs.has(n.path))ep(n.path)}function de(e){let t=e.replaceAll("\\","/");return t.includes("/")?t.slice(0,t.lastIndexOf("/")):"."}async function t$(e,t,n){ua();let o=de(e),r=de(t);if(await To(o),r!==o)await To(r);if(vt().selectedPath===e)vt().selectedPath=t;ze(n,t)}async function Ct(e,t){let n=await Tt(e.name,e.path);if(!n||n===e.name)return;let o=de(e.path),r=o==="."?n:`${o}/${n}`;Ps(e.path,r);try{let i=await p().renameFile(e.path,r);if(m.tabs.has(e.path))Sv(e.path,r,r);await t$(e.path,r,i),t(),cE(Dt(n,i),i,r)}catch(a){k.error(`Could not rename ${e.name}.`,{detail:te(a),path:e.path,source:"Files"})}}async function It(e,t){if(!await Jf(e))return;try{let o=p();Ps(e.path),await o.deleteFile(e.path),ua();let r=e.path.replaceAll("\\","/"),a=r.includes("/")?r.slice(0,r.lastIndexOf("/")):".";if(await To(a),vt().selectedPath===e.path)vt().selectedPath=null;t(),k.success(`Deleted ${e.name}`)}catch(o){k.error(`Could not delete ${e.name}.`,{detail:te(o),path:e.path,source:"Files"})}}function Lt(e,t){let n=t.paneId,o=Gu(e);if(n!==void 0&&o){if(o.activeTabId===e&&t.focus===!1)return;Cm(e,n)}ci(e,{focus:t.focus!==!1})}async function Lo(e,t={}){let n=t.focus!==!1;for(let[r,a]of m.tabs.entries())if(a.documentPath===e){if(Lt(r,t),n)vt().selectedPath=e;return}if(ww(e)){if(fE(e,t),n)vt().selectedPath=e;Ff({name:e.split("/").pop()||e,path:e,root:vt().projectRoot});return}if(e.toLowerCase().endsWith(".csv")){try{if(await AE(e,t),n)vt().selectedPath=e;Ff({name:e.split("/").pop()||e,path:e,root:vt().projectRoot})}catch(r){k.error(`Could not open ${e}.`,{detail:te(r),path:e,source:"Open File"})}return}let o=p();try{let r=await o.readFile(e);if(!r){if(await qt(),!Zt(e)&&!e.toLowerCase().endsWith(".json"))throw Lp(e);return}await qt();let a,i,s=null,l=Zt(e);if(l){let d=await Er(e,r);({document:a}=d),{frontmatter:i}=d}else if(e.endsWith(".json"))({document:a,layout:s}=hs(r));else throw Lp(e);if(No({id:e,documentPath:e,document:a,...i!=null&&{frontmatter:i},layout:s,sourceFormat:l?.name??null,...t.paneId!==void 0&&{paneId:t.paneId},...t.preview===!0&&{preview:!0},...t.focus===!1&&{focus:!1}}),n)vt().selectedPath=e;Ff({name:e.split("/").pop()||e,path:e,root:vt().projectRoot})}catch(r){k.error(`Could not open ${e}.`,{detail:te(r),path:e,source:"Open File"})}}async function gw(e,t){await Lo(t,{focus:!1,paneId:e,preview:!0})}function n1(e){if(wm(e))return;for(let[,t]of m.tabs.entries())if(t.documentPath===e&&!t.doc.dirty){ep(e);return}}function i1(e){for(let t of e)ep(t,{onlyIfChanged:!0})}async function ep(e,t={}){for(let[,n]of m.tabs.entries())if(n.documentPath===e){let o=p(),r=n.doc.dirty,a=()=>!r&&n.doc.dirty||wm(e);try{let i=await o.readFile(e);if(!i)return;if(await qt(),a())return;if(Zt(e)){let{document:s,frontmatter:l}=await Er(e,i);if(a())return;if(t.onlyIfChanged&&ls(s,n.doc.document)&&ls(l,n.doc.content.frontmatter))return;n.doc.document=s,n.doc.content.frontmatter=l}else if(e.endsWith(".json")){let s=hs(i);if(n.doc.layout=s.layout,t.onlyIfChanged&&ls(s.document,n.doc.document))return;n.doc.document=s.document}n.doc.dirty=!1}catch(i){k.error(`Could not reload ${e} after it changed on disk.`,{detail:te(i),key:`reload:${e}`,path:e,source:"Files"})}return}}function o1(){qn({id:"files",title:"Files",level:"project",dock:"navigator",icon:"folder",render:()=>tt,afterRender:(e,t)=>{At(t,e.rerender)}})}var Ot={activate:ft,contextMenu:St,expand:ht,move:mt,newFile:()=>{He(".",f)},openProject:()=>{Rc("project.open",void 0,"Files")},refresh:()=>{ut()},rowHost:bt,search:(e)=>{vt().searchQuery=e,f()},select:Te,toggleIgnored:()=>{ot(!pe()),f()},treeHost:xt,typeahead:gt},w=null,P=null;function At(e,t){let n=e.querySelector(".panel-content")??e;if(Se=t,w&&(w.host!==n||!w.handle.connected()))Mt();let o=pt();if(w)w.handle.update(o);else{let r=je(n,o,Ot);w={handle:r,host:n},r.ready.then(ie)}queueMicrotask(ie)}function Mt(){Me(),w?.handle.dispose(),w=null,P=null,Ae(),L.clear(),u=[]}
4
4
  export{Pf,hw,rE,sE,Xg,Qg,pw,aE,lE,Ff,To,Z_,X_,Q_,fw,jf,e1,t1,mw,cE,t$,Lo,gw,n1,i1,ep,o1};
5
5
 
6
6
  //# debugId=8017D335DAC27AE964756E2164756E21
7
- //# sourceMappingURL=studio-mwxgyn9h.js.map
7
+ //# sourceMappingURL=studio-hnvnfbdv.js.map
@@ -1,5 +1,5 @@
1
- import{p}from"./studio-y7jehjrp.js";import{ua}from"./studio-yr04mv2j.js";import{Ir,gm,HC}from"./studio-888knnkc.js";import{wm,m}from"./studio-cvbkkfqb.js";import{D}from"./studio-tp642n5g.js";var P=/[.*+?^${}()|[\]\\]/;function R(e){return P.test(e)?`\\${e}`:e}function L(e){let t=e.length;while(t>0&&e[t-1]===" "){let n=0,r=t-2;while(r>=0&&e[r]==="\\")n+=1,r-=1;if(n%2===1)break;t-=1}return e.slice(0,t)}function T(e,t){let n=t+1;if(e[n]==="!")n+=1;if(e[n]==="]")n+=1;while(n<e.length){if(e[n]==="\\"){n+=2;continue}if(e[n]==="]")return n;n+=1}return-1}function k(e){let t="",n=0;while(n<e.length){let r=e[n];if(r==="\\"){let o=e[n+1];if(o===void 0)t+=String.raw`\\`,n+=1;else t+=R(o),n+=2;continue}if(r==="*"){let o=0;while(e[n]==="*")o+=1,n+=1;let i=t===""||t.endsWith("/");if(o>=2&&i&&e[n]==="/")t+="(?:[^/]+/)*",n+=1;else if(o>=2&&i&&n>=e.length)t+=".*";else t+="[^/]*";continue}if(r==="?"){t+="[^/]",n+=1;continue}if(r==="["){let o=T(e,n);if(o===-1){t+=String.raw`\[`,n+=1;continue}let i=e.slice(n+1,o),s=i.startsWith("!"),a=s?i.slice(1):i;t+=`[${s?"^":""}${a.startsWith("]")?String.raw`\]${a.slice(1)}`:a}]`,n=o+1;continue}t+=R(r),n+=1}return t}function F(e){let t=L(e);if(t===""||t.startsWith("#"))return null;let n=!1;if(t.startsWith("!"))n=!0,t=t.slice(1);let r=!1;if(t.endsWith("/"))r=!0,t=t.slice(0,-1);let o=t.includes("/");if(t.startsWith("/"))t=t.slice(1),o=!0;if(t==="")return null;let i=k(t);return{dirOnly:r,negated:n,re:new RegExp(`^${o?"":"(?:.*/)?"}${i}$`),source:e}}function M(e){let t=[];for(let n of e.split(/\r?\n/)){let r=F(n);if(r)t.push(r)}return t}function b(e){let t=e.replaceAll("\\","/").replace(/^\.\/+/,"").replace(/\/+$/,"");return t==="."?"":t}function O(e,t){if(e==="")return t;return t.startsWith(`${e}/`)?t.slice(e.length+1):null}function x(e){let t=b(e),n=[""];if(t==="")return n;let r="";for(let o of t.split("/"))r=r===""?o:`${r}/${o}`,n.push(r);return n}function W(e,t,n){let r=!1;for(let o of e){let i=O(o.base,t);if(i===null||i==="")continue;for(let s of o.rules){if(s.dirOnly&&!n)continue;if(s.re.test(i))r=!s.negated}}return r}function N(e,t,n){let r=b(t);if(r==="")return!1;let o=r.split("/"),i="";for(let[s,a]of o.entries()){i=i===""?a:`${i}/${a}`;let f=s===o.length-1;if(W(e,i,f?n:!0))return!0}return!1}var g=new Map,h=new Map;function $u(){g.clear(),h.clear()}async function w(e){try{let t=await p().readFile(e===""?".gitignore":`${e}/.gitignore`);return{base:e,rules:M(t)}}catch{return null}}function _(e){let t=g.get(e);if(t!==void 0)return Promise.resolve(t);let n=h.get(e);if(n)return n;let r=w(e).then((o)=>(g.set(e,o),h.delete(e),o));return h.set(e,r),r}async function v(){let e=[...g.keys()];h.clear();let t=await Promise.all(e.map((n)=>w(n)));g.clear();for(let[n,r]of e.entries())g.set(r,t[n]??null)}async function WE(e){await Promise.all(x(e).map((t)=>_(t)))}function A(e){let t=[];for(let n of x(e)){let r=g.get(n);if(r)t.push(r)}return t}function VE(e,t,n){return N(A(e),t,n)}function C(e){return e.some((t)=>b(t).split("/").pop()===".gitignore")}var U=1500,S={commit:0,open:1,reconnect:2},G=250,V=8,E=new Map,I=(e)=>e.replaceAll("\\","/");function Ps(...e){gm(e,e);let t=Date.now()+U;for(let n of e)if(n)E.set(I(n),t)}function mc(e){let t=I(e),n=E.get(t);if(n===void 0)return!1;if(Date.now()>n)return E.delete(t),!1;return!0}function Y(e){let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)}function z(e){let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}function B(e,t,n){let r=new Set;for(let o of n){let i=Y(o.path);if(o.type==="add"||o.type==="addDir"){let s=e.get(i);if(s&&!s.some((a)=>a.path===o.path))s.push({name:z(o.path),path:o.path,type:o.isDir?"directory":"file"}),r.add(i);if(o.type==="addDir"&&!e.has(o.path))e.set(o.path,[])}else if(o.type==="unlink"||o.type==="unlinkDir"){let s=e.get(i);if(s){let a=s.findIndex((f)=>f.path===o.path);if(a!==-1)s.splice(a,1),r.add(i)}if(o.type==="unlinkDir"){e.delete(o.path);let a=[];for(let c of e.keys())if(c.startsWith(`${o.path}/`))a.push(c);for(let c of a)e.delete(c);let f=[];for(let c of t)if(c===o.path||c.startsWith(`${o.path}/`))f.push(c);for(let c of f)t.delete(c)}}}return r}function j(e){let t=[],n=[];for(let r of e)if(r.type==="unlinkDir")n.push(r.path);else if(r.type!=="addDir")t.push(r.path);if(t.length>0||n.length>0)gm(t,n)}function q(e,t){return e!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r])}var K=2;async function H(e,t){let n=[...e.keys()],r=0,o=async(s)=>{for(let a=0;a<K;a+=1){let f=e.get(s);if(!f)return;let c=[...f],l;try{l=await t(s)}catch{l=null}if(!e.has(s))return;if(!q(e.get(s),c))continue;if(l)e.set(s,l);else e.delete(s);return}},i=async()=>{while(r<n.length){let s=n[r];r+=1,await o(s)}};await Promise.all(Array.from({length:Math.min(V,n.length)},i))}var J=new Set(["media","grid","manage"]);function Q(e){return e.some((t)=>J.has(t))||e.length>0&&e.every((t)=>t==="git-diff")}function X(){let e=new Set;for(let t of m.tabs.values()){let n=t.documentPath;if(n&&!t.doc.dirty&&!wm(n)&&!Q(t.capabilities.modes))e.add(n)}return[...e]}function O1(e){let t=p();if(!t.subscribeFileEvents)return()=>{};let n=[],r=null,o=null,i=null,s=()=>{r=null;let l=D,u=n.filter((d)=>!mc(d.path));if(n=[],!l||u.length===0)return;let y=B(l.dirs,l.expanded,u);if(e.onContentChange){for(let d of u)if(d.type==="change")e.onContentChange(d.path)}if(y.size>0)e.renderLeftPanel()},a=async()=>{i=null;let l=o;o=null;let u=D;if(!u||!l)return;let y=H(u.dirs,(d)=>Ir(()=>t.listDirectory(d)));if(l==="reconnect")ua(),e.invalidateDerivedCaches?.(),await Promise.all([y,v()]);else await y;if(D!==u)return;if(l==="reconnect")e.onResyncContent?.(X());e.renderLeftPanel()},f=(l)=>{if(l!=="commit")HC();if(!o||S[l]>S[o])o=l;if(i)clearTimeout(i);i=setTimeout(()=>{a()},G)},c=t.subscribeFileEvents((l)=>{if(ua(),e.invalidateDerivedCaches?.(),j(l),C(l.map((u)=>u.path)))v().then(()=>e.renderLeftPanel());if(n.push(...l),r)clearTimeout(r);r=setTimeout(s,50)},{onResync:f});return()=>{if(i)clearTimeout(i),i=null;c()}}
1
+ import{p}from"./studio-y7jehjrp.js";import{ua}from"./studio-yr04mv2j.js";import{Ir,gm,HC}from"./studio-xkfs0dp2.js";import{wm,m}from"./studio-x5g1xk77.js";import{D}from"./studio-tp642n5g.js";var P=/[.*+?^${}()|[\]\\]/;function R(e){return P.test(e)?`\\${e}`:e}function L(e){let t=e.length;while(t>0&&e[t-1]===" "){let n=0,r=t-2;while(r>=0&&e[r]==="\\")n+=1,r-=1;if(n%2===1)break;t-=1}return e.slice(0,t)}function T(e,t){let n=t+1;if(e[n]==="!")n+=1;if(e[n]==="]")n+=1;while(n<e.length){if(e[n]==="\\"){n+=2;continue}if(e[n]==="]")return n;n+=1}return-1}function k(e){let t="",n=0;while(n<e.length){let r=e[n];if(r==="\\"){let o=e[n+1];if(o===void 0)t+=String.raw`\\`,n+=1;else t+=R(o),n+=2;continue}if(r==="*"){let o=0;while(e[n]==="*")o+=1,n+=1;let i=t===""||t.endsWith("/");if(o>=2&&i&&e[n]==="/")t+="(?:[^/]+/)*",n+=1;else if(o>=2&&i&&n>=e.length)t+=".*";else t+="[^/]*";continue}if(r==="?"){t+="[^/]",n+=1;continue}if(r==="["){let o=T(e,n);if(o===-1){t+=String.raw`\[`,n+=1;continue}let i=e.slice(n+1,o),s=i.startsWith("!"),a=s?i.slice(1):i;t+=`[${s?"^":""}${a.startsWith("]")?String.raw`\]${a.slice(1)}`:a}]`,n=o+1;continue}t+=R(r),n+=1}return t}function F(e){let t=L(e);if(t===""||t.startsWith("#"))return null;let n=!1;if(t.startsWith("!"))n=!0,t=t.slice(1);let r=!1;if(t.endsWith("/"))r=!0,t=t.slice(0,-1);let o=t.includes("/");if(t.startsWith("/"))t=t.slice(1),o=!0;if(t==="")return null;let i=k(t);return{dirOnly:r,negated:n,re:new RegExp(`^${o?"":"(?:.*/)?"}${i}$`),source:e}}function M(e){let t=[];for(let n of e.split(/\r?\n/)){let r=F(n);if(r)t.push(r)}return t}function b(e){let t=e.replaceAll("\\","/").replace(/^\.\/+/,"").replace(/\/+$/,"");return t==="."?"":t}function O(e,t){if(e==="")return t;return t.startsWith(`${e}/`)?t.slice(e.length+1):null}function x(e){let t=b(e),n=[""];if(t==="")return n;let r="";for(let o of t.split("/"))r=r===""?o:`${r}/${o}`,n.push(r);return n}function W(e,t,n){let r=!1;for(let o of e){let i=O(o.base,t);if(i===null||i==="")continue;for(let s of o.rules){if(s.dirOnly&&!n)continue;if(s.re.test(i))r=!s.negated}}return r}function N(e,t,n){let r=b(t);if(r==="")return!1;let o=r.split("/"),i="";for(let[s,a]of o.entries()){i=i===""?a:`${i}/${a}`;let f=s===o.length-1;if(W(e,i,f?n:!0))return!0}return!1}var g=new Map,h=new Map;function $u(){g.clear(),h.clear()}async function w(e){try{let t=await p().readFile(e===""?".gitignore":`${e}/.gitignore`);return{base:e,rules:M(t)}}catch{return null}}function _(e){let t=g.get(e);if(t!==void 0)return Promise.resolve(t);let n=h.get(e);if(n)return n;let r=w(e).then((o)=>(g.set(e,o),h.delete(e),o));return h.set(e,r),r}async function v(){let e=[...g.keys()];h.clear();let t=await Promise.all(e.map((n)=>w(n)));g.clear();for(let[n,r]of e.entries())g.set(r,t[n]??null)}async function WE(e){await Promise.all(x(e).map((t)=>_(t)))}function A(e){let t=[];for(let n of x(e)){let r=g.get(n);if(r)t.push(r)}return t}function VE(e,t,n){return N(A(e),t,n)}function C(e){return e.some((t)=>b(t).split("/").pop()===".gitignore")}var U=1500,S={commit:0,open:1,reconnect:2},G=250,V=8,E=new Map,I=(e)=>e.replaceAll("\\","/");function Ps(...e){gm(e,e);let t=Date.now()+U;for(let n of e)if(n)E.set(I(n),t)}function mc(e){let t=I(e),n=E.get(t);if(n===void 0)return!1;if(Date.now()>n)return E.delete(t),!1;return!0}function Y(e){let t=e.lastIndexOf("/");return t===-1?".":e.slice(0,t)}function z(e){let t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}function B(e,t,n){let r=new Set;for(let o of n){let i=Y(o.path);if(o.type==="add"||o.type==="addDir"){let s=e.get(i);if(s&&!s.some((a)=>a.path===o.path))s.push({name:z(o.path),path:o.path,type:o.isDir?"directory":"file"}),r.add(i);if(o.type==="addDir"&&!e.has(o.path))e.set(o.path,[])}else if(o.type==="unlink"||o.type==="unlinkDir"){let s=e.get(i);if(s){let a=s.findIndex((f)=>f.path===o.path);if(a!==-1)s.splice(a,1),r.add(i)}if(o.type==="unlinkDir"){e.delete(o.path);let a=[];for(let c of e.keys())if(c.startsWith(`${o.path}/`))a.push(c);for(let c of a)e.delete(c);let f=[];for(let c of t)if(c===o.path||c.startsWith(`${o.path}/`))f.push(c);for(let c of f)t.delete(c)}}}return r}function j(e){let t=[],n=[];for(let r of e)if(r.type==="unlinkDir")n.push(r.path);else if(r.type!=="addDir")t.push(r.path);if(t.length>0||n.length>0)gm(t,n)}function q(e,t){return e!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r])}var K=2;async function H(e,t){let n=[...e.keys()],r=0,o=async(s)=>{for(let a=0;a<K;a+=1){let f=e.get(s);if(!f)return;let c=[...f],l;try{l=await t(s)}catch{l=null}if(!e.has(s))return;if(!q(e.get(s),c))continue;if(l)e.set(s,l);else e.delete(s);return}},i=async()=>{while(r<n.length){let s=n[r];r+=1,await o(s)}};await Promise.all(Array.from({length:Math.min(V,n.length)},i))}var J=new Set(["media","grid","manage"]);function Q(e){return e.some((t)=>J.has(t))||e.length>0&&e.every((t)=>t==="git-diff")}function X(){let e=new Set;for(let t of m.tabs.values()){let n=t.documentPath;if(n&&!t.doc.dirty&&!wm(n)&&!Q(t.capabilities.modes))e.add(n)}return[...e]}function O1(e){let t=p();if(!t.subscribeFileEvents)return()=>{};let n=[],r=null,o=null,i=null,s=()=>{r=null;let l=D,u=n.filter((d)=>!mc(d.path));if(n=[],!l||u.length===0)return;let y=B(l.dirs,l.expanded,u);if(e.onContentChange){for(let d of u)if(d.type==="change")e.onContentChange(d.path)}if(y.size>0)e.renderLeftPanel()},a=async()=>{i=null;let l=o;o=null;let u=D;if(!u||!l)return;let y=H(u.dirs,(d)=>Ir(()=>t.listDirectory(d)));if(l==="reconnect")ua(),e.invalidateDerivedCaches?.(),await Promise.all([y,v()]);else await y;if(D!==u)return;if(l==="reconnect")e.onResyncContent?.(X());e.renderLeftPanel()},f=(l)=>{if(l!=="commit")HC();if(!o||S[l]>S[o])o=l;if(i)clearTimeout(i);i=setTimeout(()=>{a()},G)},c=t.subscribeFileEvents((l)=>{if(ua(),e.invalidateDerivedCaches?.(),j(l),C(l.map((u)=>u.path)))v().then(()=>e.renderLeftPanel());if(n.push(...l),r)clearTimeout(r);r=setTimeout(s,50)},{onResync:f});return()=>{if(i)clearTimeout(i),i=null;c()}}
2
2
  export{$u,WE,VE,Ps,mc,O1};
3
3
 
4
4
  //# debugId=18E416EAF76F387B64756E2164756E21
5
- //# sourceMappingURL=studio-9mqfamps.js.map
5
+ //# sourceMappingURL=studio-mk00zd5d.js.map