@gallop.software/studio 2.3.156 → 2.3.157
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.
|
@@ -121,5 +121,5 @@ CLOUDFLARE_R2_PUBLIC_URL=https://your-cdn.example.com`;function z1({onClose:i}){
|
|
|
121
121
|
to { transform: rotate(360deg); }
|
|
122
122
|
`,Wt={overlay:m("position:fixed;inset:0;background-color:rgba(26, 31, 54, 0.4);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:10000;animation:",k2," 0.15s ease-out;font-family:",kl,";",""),modal:m(ll," background-color:",s.surface,";border-radius:12px;box-shadow:0 30px 60px -12px rgba(50, 50, 93, 0.25),0 18px 36px -18px rgba(0, 0, 0, 0.3);max-width:480px;width:90%;max-height:80vh;overflow:hidden;animation:",z2," 0.2s ease-out;display:flex;flex-direction:column;",""),header:{name:"nsgk6m",styles:"padding:24px 24px 0"},title:m("font-size:",N.lg,";font-weight:600;color:",s.text,";margin:0;letter-spacing:-0.02em;",""),body:{name:"amghpa",styles:"padding:16px 24px 24px;overflow-y:auto;flex:1"},assignmentList:{name:"3w0yoi",styles:"display:flex;flex-direction:column;gap:8px"},assignmentRow:m("display:flex;align-items:center;justify-content:space-between;padding:12px 14px;background:",s.background,";border-radius:8px;border:1px solid ",s.border,";",""),assignmentInfo:{name:"nj7tus",styles:"display:flex;align-items:center;gap:8px;flex:1;min-width:0"},assignmentName:m("font-size:",N.base,";font-weight:500;color:",s.text,";",""),assignmentFolder:m("font-size:",N.sm,";color:",s.textMuted,";&::before{content:'→';margin-right:6px;color:",s.textMuted,";}",""),deleteBtn:m("padding:6px 12px;font-size:",N.sm,";font-weight:500;background:",s.surface,";border:1px solid ",s.border,";border-radius:4px;cursor:pointer;color:",s.textSecondary,";transition:all 0.15s ease;&:hover{background:",s.dangerLight,";border-color:",s.danger,";color:",s.danger,";}",""),confirmRow:{name:"1yydxi7",styles:"display:flex;align-items:center;gap:8px"},confirmBtn:m("padding:6px 12px;font-size:",N.sm,";font-weight:500;background:",s.danger,";border:1px solid ",s.danger,";border-radius:4px;cursor:pointer;color:white;transition:all 0.15s ease;&:hover{background:",s.dangerHover,";border-color:",s.dangerHover,";}",""),cancelBtn:m("padding:6px 12px;font-size:",N.sm,";font-weight:500;background:",s.surface,";border:1px solid ",s.border,";border-radius:4px;cursor:pointer;color:",s.textSecondary,";transition:all 0.15s ease;&:hover{background:",s.surfaceHover,";border-color:",s.borderHover,";}",""),emptyText:m("font-size:",N.base,";color:",s.textMuted,";text-align:center;padding:32px 0;",""),footer:m("display:flex;justify-content:flex-end;gap:12px;padding:16px 24px;border-top:1px solid ",s.border,";background-color:",s.background,";",""),btn:m("padding:10px 18px;font-size:",N.base,";font-weight:500;border-radius:6px;cursor:pointer;transition:all 0.15s ease;letter-spacing:-0.01em;",""),btnPrimary:m("background-color:",s.primary,";border:1px solid ",s.primary,";color:white;&:hover{background-color:",s.primaryHover,";border-color:",s.primaryHover,";}",""),loading:{name:"uphaut",styles:"display:flex;align-items:center;justify-content:center;padding:40px"},loadingSpinner:m("width:32px;height:32px;border-radius:50%;border:3px solid ",s.border,";border-top-color:",s.primary,";animation:",M2," 0.8s linear infinite;","")};function D2({onClose:i,onRefresh:c}){const[f,d]=v.useState(!0),[h,p]=v.useState([]),[C,D]=v.useState(null),x=v.useCallback(async()=>{try{const _=await fetch("/api/studio/fonts/assignments");if(_.ok){const q=await _.json();p(q.assignments||[])}}catch(_){console.error("Failed to load assignments:",_)}finally{d(!1)}},[]);v.useEffect(()=>{x()},[x]);const y=_=>{D(_)},A=()=>{D(null)},z=async _=>{try{(await fetch("/api/studio/fonts/delete-assignment",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:_})})).ok&&(p(H=>H.filter(G=>G.name!==_)),D(null),c?.())}catch(q){console.error("Failed to delete assignment:",q)}};return r("div",{css:Wt.overlay,onClick:i,children:b("div",{css:Wt.modal,onClick:_=>_.stopPropagation(),children:[r("div",{css:Wt.header,children:r("h3",{css:Wt.title,children:"Font Assignments"})}),r("div",{css:Wt.body,children:f?r("div",{css:Wt.loading,children:r("div",{css:Wt.loadingSpinner})}):h.length===0?b("p",{css:Wt.emptyText,children:["No font assignments yet.",r("br",{}),'Select a folder and click "Assign Web Font" to create one.']}):r("div",{css:Wt.assignmentList,children:h.map(_=>b("div",{css:Wt.assignmentRow,children:[b("div",{css:Wt.assignmentInfo,children:[r("span",{css:Wt.assignmentName,children:_.name}),r("span",{css:Wt.assignmentFolder,children:_.folder})]}),C===_.name?b("div",{css:Wt.confirmRow,children:[r("button",{css:Wt.confirmBtn,onClick:()=>z(_.name),children:"Delete?"}),r("button",{css:Wt.cancelBtn,onClick:A,children:"Cancel"})]}):r("button",{css:Wt.deleteBtn,onClick:()=>y(_.name),children:"Delete"})]},_.name))})}),r("div",{css:Wt.footer,children:r("button",{css:[Wt.btn,Wt.btnPrimary,"",""],onClick:i,children:"Done"})})]})})}const Tp="36px",Ep=Ft`
|
|
123
123
|
to { transform: rotate(360deg); }
|
|
124
|
-
`,F={container:{name:"xt6tct",styles:"flex:1;display:flex;flex-direction:column;overflow:hidden"},toolbar:m("display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;background-color:",s.surface,";border-bottom:1px solid ",s.border,";@media (min-width: 768px){padding:12px 24px;}",""),toolbarLeft:{name:"17nohj2",styles:"display:flex;flex-wrap:nowrap;flex-shrink:0;align-items:center;gap:8px"},toolbarRight:{name:"17nohj2",styles:"display:flex;flex-wrap:nowrap;flex-shrink:0;align-items:center;gap:8px"},selectionCount:m("font-size:",N.base,";color:",s.textSecondary,";display:flex;align-items:center;gap:8px;margin-right:8px;",""),clearBtn:m("color:",s.primary,";background:none;border:none;cursor:pointer;font-size:",N.base,";font-weight:500;padding:0;&:hover{text-decoration:underline;}",""),btn:m("display:inline-flex;align-items:center;justify-content:center;gap:6px;height:",Tp,";padding:0 14px;border-radius:6px;font-size:",N.base,";font-weight:500;background:",s.surface,";border:1px solid ",s.border,";cursor:pointer;transition:all 0.15s ease;color:",s.text,";&:hover:not(:disabled){background-color:",s.surfaceHover,";border-color:",s.borderHover,";}&:disabled{cursor:not-allowed;opacity:0.5;}",""),btnPrimary:m("background:",s.primary,";border-color:",s.primary,";color:white;&:hover:not(:disabled){background:",s.primaryHover,";border-color:",s.primaryHover,";}",""),btnDanger:m("color:",s.danger,";&:hover:not(:disabled){background-color:",s.dangerLight,";border-color:",s.danger,";}",""),btnIcon:{name:"157xhr7",styles:"width:16px;height:16px"},content:{name:"1tznmxd",styles:"flex:1;overflow:auto;padding:20px 24px"},loading:{name:"1d2ui9i",styles:"display:flex;align-items:center;justify-content:center;flex:1;min-height:300px"},spinner:m("width:32px;height:32px;border-radius:50%;border:3px solid ",s.border,";border-top-color:",s.primary,";animation:",Ep," 0.8s linear infinite;",""),empty:m("display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-height:300px;color:",s.textSecondary,";",""),emptyIcon:{name:"1o3cbsn",styles:"width:48px;height:48px;margin-bottom:16px;opacity:0.5"},emptyText:m("font-size:",N.base,";margin:0 0 4px 0;&:last-child{color:",s.textMuted,";font-size:",N.sm,";}",""),selectAllRow:m("display:flex;align-items:center;gap:24px;margin-bottom:16px;padding:12px 16px;background:",s.surface,";border-radius:8px;border:1px solid ",s.border,";",""),selectAllLabel:m("display:flex;align-items:center;gap:10px;font-size:",N.base,";font-weight:500;color:",s.textSecondary,";cursor:pointer;&:hover{color:",s.text,";}",""),selectAllCheckbox:m("width:16px;height:16px;accent-color:",s.primary,";",""),grid:{name:"el23hk",styles:"display:grid;grid-template-columns:1fr;gap:12px;@media (min-width: 480px){grid-template-columns:repeat(2, 1fr);}@media (min-width: 768px){grid-template-columns:repeat(3, 1fr);}@media (min-width: 1024px){grid-template-columns:repeat(4, 1fr);}@media (min-width: 1280px){grid-template-columns:repeat(5, 1fr);}"},item:m("position:relative;border-radius:8px;border:1px solid ",s.border,";overflow:hidden;cursor:pointer;transition:all 0.15s ease;background-color:",s.surface,";user-select:none;box-shadow:0 1px 2px rgba(0, 0, 0, 0.04);&:hover{border-color:#d0d5dd;box-shadow:0 2px 4px rgba(0, 0, 0, 0.06);}",""),itemSelected:m("border-color:",s.primary,";box-shadow:0 0 0 1px ",s.primary,";&:hover{border-color:",s.primary,";box-shadow:0 0 0 1px ",s.primary,";}",""),checkboxWrapper:{name:"v3lnpt",styles:"position:absolute;top:0;left:0;z-index:10;padding:8px;cursor:pointer"},checkbox:m("width:18px;height:18px;accent-color:",s.primary,";cursor:pointer;",""),itemContent:m("position:relative;aspect-ratio:1;display:flex;align-items:center;justify-content:center;padding:16px;background:",s.background,";",""),folderIcon:{name:"k1w47f",styles:"width:56px;height:56px;color:#f9935e"},parentIcon:m("width:56px;height:56px;color:",s.textMuted,";",""),fileIcon:m("width:40px;height:40px;color:",s.textMuted,";",""),openBtn:m("position:absolute;bottom:8px;right:8px;z-index:10;height:28px;font-size:",N.sm,";font-weight:500;color:",s.primary,";background:",s.surface,";border:1px solid ",s.border,";padding:0 8px;cursor:pointer;border-radius:4px;transition:all 0.15s ease;display:flex;align-items:center;box-shadow:0 1px 2px rgba(0, 0, 0, 0.08);&:hover{background-color:",s.primaryLight,";border-color:",s.primary,";}",""),label:m("padding:10px 12px;background-color:",s.surface,";border-top:1px solid ",s.borderLight,";",""),labelName:m("font-size:",N.sm,";font-weight:500;color:",s.text,";margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",""),labelMeta:m("font-size:",N.xs,";color:",s.textMuted,";margin:2px 0 0 0;",""),dropOverlay:m("position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(99, 91, 255, 0.1);border:3px dashed ",s.primary,";border-radius:8px;display:flex;align-items:center;justify-content:center;z-index:50;pointer-events:none;",""),dropMessage:m("display:flex;flex-direction:column;align-items:center;gap:12px;color:",s.primary,";font-size:",N.lg,";font-weight:600;",""),dropIcon:{name:"18jhpep",styles:"width:48px;height:48px"},createBtn:m("margin-top:16px;padding:10px 24px;font-size:",N.base,";font-weight:500;background:",s.primary,";color:white;border:none;border-radius:8px;cursor:pointer;transition:background 0.15s ease;&:hover{background:",s.primaryHover,";}",""),viewToggle:m("display:flex;align-items:center;height:",Tp,";background-color:",s.surface,";border:1px solid ",s.border,";border-radius:6px;overflow:hidden;",""),viewBtn:m("height:100%;padding:0 10px;background:transparent;border:none;cursor:pointer;color:",s.textSecondary,";transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;&:hover{color:",s.text,";background-color:",s.surfaceHover,";}",""),viewBtnActive:m("background-color:",s.primaryLight,";color:",s.primary,";&:hover{background-color:",s.primaryLight,";color:",s.primary,";}",""),iconSpin:m("animation:",Ep," 1s linear infinite;",""),tableWrapper:m("background:",s.surface,";border-radius:8px;border:1px solid ",s.border,";overflow-x:auto;",""),table:{name:"1ceqwkv",styles:"width:100%;min-width:400px;border-collapse:collapse;white-space:nowrap"},th:m("text-align:left;font-size:11px;color:",s.textMuted,";text-transform:uppercase;letter-spacing:0.05em;padding:12px 16px;font-weight:600;background:",s.background,";border-bottom:1px solid ",s.border,";",""),thCheckbox:{name:"5iz1wr",styles:"width:48px"},thSize:{name:"yct5co",styles:"width:96px"},row:m("cursor:pointer;transition:background-color 0.15s ease;user-select:none;&:hover{background-color:",s.surfaceHover,";}&:not(:last-child) td{border-bottom:1px solid ",s.borderLight,";}",""),rowSelected:m("background-color:",s.primaryLight,";&:hover{background-color:",s.primaryLight,";}",""),parentRow:m("cursor:pointer;border-bottom:1px solid ",s.border,";&:hover{background-color:",s.surfaceHover,";}",""),td:{name:"i563hg",styles:"padding:12px 16px"},checkboxCell:{name:"sahq4q",styles:"padding:12px 16px;cursor:pointer;vertical-align:middle"},nameCell:{name:"9s3nhy",styles:"display:flex;align-items:center;gap:12px;flex:1"},folderIconWrapper:{name:"xfecxx",styles:"width:48px;height:36px;display:flex;align-items:center;justify-content:center;flex-shrink:0"},folderIconSmall:{name:"a45yt2",styles:"width:24px;height:24px;color:#f9935e"},fileIconWrapper:{name:"xfecxx",styles:"width:48px;height:36px;display:flex;align-items:center;justify-content:center;flex-shrink:0"},fileIconSmall:m("width:20px;height:20px;color:",s.textMuted,";",""),parentIconSmall:m("width:20px;height:20px;color:",s.textMuted,";flex-shrink:0;",""),name:m("font-size:",N.base,";font-weight:500;color:",s.text,";letter-spacing:-0.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:300px;",""),meta:m("font-size:",N.sm,";color:",s.textSecondary,";",""),actionsCell:{name:"1w56d5c",styles:"display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-left:auto;flex-shrink:0"},listOpenBtn:m("height:32px;font-size:",N.sm,";font-weight:500;color:",s.primary,";background:",s.surface,";border:1px solid ",s.border,";padding:0 14px;cursor:pointer;border-radius:4px;transition:all 0.15s ease;display:inline-flex;align-items:center;&:hover{background-color:",s.primaryLight,";border-color:",s.primary,";}",""),badge:{name:"1ue8xbs",styles:"width:8px;height:8px;border-radius:50%;flex-shrink:0"},badgeGray:{name:"a0o945",styles:"background-color:#9ca3af"},badgeBlue:{name:"1pt39vn",styles:"background-color:#3b82f6"},badgeGreen:{name:"b752gh",styles:"background-color:#10b981"},badgeWrapper:{name:"1pi78hi",styles:"display:flex;align-items:center;gap:6px"}};function Rp(i){return i<1024?i+" B":i<1024*1024?(i/1024).toFixed(1)+" KB":(i/(1024*1024)).toFixed(1)+" MB"}function A2({currentPath:i,setCurrentPath:c,refreshKey:f,triggerRefresh:d}){const[h,p]=v.useState([]),[C,D]=v.useState(!0),[x,y]=v.useState(new Set),[A,z]=v.useState(!1),[_,q]=v.useState(!1),[H,G]=v.useState(!1),[oe,J]=v.useState(!1),[ce,Q]=v.useState(!1),[le,X]=v.useState(!1),[P,te]=v.useState("grid"),[ae,j]=v.useState(!1),[W,he]=v.useState(!1),[me,ge]=v.useState(!1),[ie,Oe]=v.useState(!1),[T,Z]=v.useState({status:"idle",current:0,total:0,percent:0}),[ee,Ee]=v.useState("Processing"),[qe,S]=v.useState(null),[O,ne]=v.useState({}),[re,we]=v.useState(null),ze=v.useCallback(async()=>{try{D(!0);const U=await fetch(`/api/studio/fonts/list?path=${encodeURIComponent(i)}`);if(U.ok){const De=await U.json();p(De.items||[]),z(De.canCreate===!0)}}catch(U){console.error("Failed to fetch fonts:",U),p([])}finally{D(!1)}},[i]);v.useEffect(()=>{ze(),y(new Set)},[ze,f]);const Ge=v.useCallback(async U=>{const De={};for(const Ke of U)if(Ke.type==="folder")try{const ft=await fetch("/api/studio/fonts/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:Ke.path})});if(ft.ok){const Rt=await ft.json();De[Ke.path]={needsGeneration:Rt.needsGeneration,hasWoff2:Rt.woff2Files?.length>0,assignments:Rt.assignments||[]}}}catch{}ne(De)},[]);v.useEffect(()=>{const U=h.filter(De=>De.type==="folder");U.length>0&&i.startsWith("_fonts")&&Ge(U)},[h,i,Ge]);const xt=i==="_fonts";i==="src"||i.startsWith("src/");const Re=v.useCallback((U,De)=>{if(De.stopPropagation(),De.shiftKey&&re){const Ke=h.findIndex(Rt=>Rt.path===re),ft=h.findIndex(Rt=>Rt.path===U.path);if(Ke!==-1&&ft!==-1){const Rt=Math.min(Ke,ft),zn=Math.max(Ke,ft);y(Ml=>{const ra=new Set(Ml);for(let Bn=Rt;Bn<=zn;Bn++)ra.add(h[Bn].path);return ra})}}else y(Ke=>{const ft=new Set(Ke);return ft.has(U.path)?ft.delete(U.path):ft.add(U.path),ft});we(U.path)},[h,re]),Pt=v.useCallback(U=>{U.type==="folder"&&(c(U.path),y(new Set))},[c]),Ze=v.useCallback(()=>{const U=i.split("/");U.pop();const De=U.join("/")||"_fonts";c(De),y(new Set)},[i,c]),Je=h.length>0&&x.size===h.length,it=x.size>0,Ht=v.useCallback(()=>{y(Je?new Set:new Set(h.map(U=>U.path)))},[Je,h]),Yt=v.useCallback(()=>{y(new Set),we(null)},[]),tn=v.useCallback(()=>{const U=h.filter(De=>De.type==="file"&&De.name.toLowerCase().endsWith(".woff2"));y(new Set(U.map(De=>De.path)))},[h]),Qt=v.useCallback(()=>{const U=h.filter(De=>De.type==="file"&&De.name.toLowerCase().endsWith(".ttf"));y(new Set(U.map(De=>De.path)))},[h]),fn=v.useCallback(async()=>{j(!0),await ze(),j(!1)},[ze]),Bt=Array.from(x),$e=Bt.length===1&&h.find(U=>U.path===Bt[0])?.type==="folder",gt=$e?Bt[0]:null,kt=gt&>.split("/").pop()||"",Te=Bt.length===1&&h.find(U=>U.path===Bt[0])?.type==="file",mt=Te?Bt[0]:null,hn=mt&&mt.split("/").pop()||"",Hn=v.useCallback(()=>{$e&&he(!0)},[$e]),kn=v.useCallback(async U=>{he(!1),Ee("Assigning Web Font"),Oe(!0),Z({status:"progress",current:0,total:1,percent:0,message:"Starting..."});try{const De=await fetch("/api/studio/fonts/assign-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:gt,assignments:U})});if(!De.ok||!De.body){Z({status:"error",current:0,total:0,percent:0,message:"Failed to start assignment"});return}const Ke=De.body.getReader(),ft=new TextDecoder;for(;;){const{done:Rt,value:zn}=await Ke.read();if(Rt)break;const ra=ft.decode(zn,{stream:!0}).split(`
|
|
125
|
-
`);for(const Bn of ra)if(Bn.startsWith("data: "))try{const Ut=JSON.parse(Bn.slice(6));Ut.status==="progress"?Z({status:"progress",current:Ut.current||0,total:Ut.total||1,percent:Ut.total?Math.round(Ut.current/Ut.total*100):0,message:Ut.message,currentFile:Ut.currentFile}):Ut.status==="complete"?(Z({status:"complete",current:Ut.created?.length||0,total:Ut.created?.length||0,percent:100,message:Ut.message,processed:Ut.created?.length||0}),d()):Ut.status==="error"&&Z({status:"error",current:0,total:0,percent:0,message:Ut.message})}catch{}}}catch(De){Z({status:"error",current:0,total:0,percent:0,message:String(De)})}},[gt,d]),mn=v.useCallback(()=>{Oe(!1),Z({status:"idle",current:0,total:0,percent:0})},[]),$=v.useCallback(async U=>{if(gt){G(!1);try{(await fetch("/api/studio/fonts/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:gt,newName:U})})).ok&&(y(new Set),d())}catch(De){console.error("Rename failed:",De)}}},[gt,d]),ue=v.useCallback(async U=>{if(mt){J(!1);try{(await fetch("/api/studio/fonts/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:mt,newName:U})})).ok&&(y(new Set),d())}catch(De){console.error("Rename file failed:",De)}}},[mt,d]),Xe=v.useCallback(()=>{x.size!==0&&X(!0)},[x.size]),at=v.useCallback(async()=>{X(!1),Ee("Deleting Files"),Oe(!0),Z({status:"progress",current:0,total:x.size,percent:0,message:"Deleting..."});try{(await fetch("/api/studio/fonts/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:Array.from(x)})})).ok?(Z({status:"complete",current:x.size,total:x.size,percent:100,message:`Deleted ${x.size} item${x.size!==1?"s":""}`}),y(new Set),d()):Z({status:"error",current:0,total:0,percent:0,message:"Delete failed"})}catch(U){console.error("Delete failed:",U),Z({status:"error",current:0,total:0,percent:0,message:"Delete failed"})}},[x,d]),Be=v.useCallback(()=>{Q(!0)},[]),Me=v.useCallback(async U=>{Q(!1);try{(await fetch("/api/studio/fonts/create-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i,name:U})})).ok&&d()}catch(De){console.error("Create folder failed:",De)}},[i,d]),zt=v.useCallback(U=>{U.preventDefault(),U.stopPropagation(),i.startsWith("_fonts")&&q(!0)},[i]),yt=v.useCallback(U=>{U.preventDefault(),U.stopPropagation(),q(!1)},[]),Aa=v.useCallback(async U=>{if(U.preventDefault(),U.stopPropagation(),q(!1),!i.startsWith("_fonts"))return;const De=Array.from(U.dataTransfer.files).filter(Ke=>Ke.name.toLowerCase().endsWith(".ttf"));if(De.length!==0){for(const Ke of De){const ft=new FormData;ft.append("file",Ke),ft.append("path",i);try{await fetch("/api/studio/fonts/upload",{method:"POST",body:ft})}catch(Rt){console.error("Upload failed:",Rt)}}d()}},[i,d]),ia=v.useCallback(U=>{U&&U.addEventListener("change",async De=>{const Ke=De.target.files;if(!(!Ke||Ke.length===0)){for(const ft of Array.from(Ke)){if(!ft.name.toLowerCase().endsWith(".ttf"))continue;const Rt=new FormData;Rt.append("file",ft),Rt.append("path",i);try{await fetch("/api/studio/fonts/upload",{method:"POST",body:Rt})}catch(zn){console.error("Upload failed:",zn)}}d(),U.value=""}})},[i,d]);if(C)return b("div",{css:F.container,children:[r("div",{css:F.toolbar}),r("div",{css:F.loading,children:r("div",{css:F.spinner})})]});const zl=i.startsWith("_fonts");return b("div",{css:F.container,children:[b("div",{css:F.toolbar,children:[b("div",{css:F.toolbarLeft,children:[zl&&b(tt,{children:[b("button",{css:[F.btn,F.btnPrimary,"",""],onClick:()=>document.getElementById("font-file-input")?.click(),children:[r(T2,{}),"Add New"]}),r("input",{id:"font-file-input",type:"file",accept:".ttf",multiple:!0,style:{display:"none"},ref:ia})]}),b("button",{css:F.btn,onClick:()=>{Te?J(!0):$e?G(!0):Be()},children:[Te||$e?r(L2,{}):r(E2,{}),Te?"Rename File":$e?"Rename Folder":"New Folder"]}),b("button",{css:[F.btn,F.btnDanger,"",""],onClick:Xe,disabled:x.size===0,children:[r(R2,{}),"Delete"]}),b("button",{css:F.btn,onClick:Hn,disabled:!$e,title:$e?"Assign web font":"Select a folder to assign",children:[r(j2,{}),"Assign Web Font"]})]}),b("div",{css:F.toolbarRight,children:[it&&b("span",{css:F.selectionCount,children:[x.size," selected",r("button",{css:F.clearBtn,onClick:Yt,children:"Clear"})]}),r("button",{css:F.btn,onClick:fn,title:"Refresh view",disabled:ae,children:r(B2,{spinning:ae})}),b("div",{css:F.viewToggle,children:[r("button",{css:[F.viewBtn,P==="grid"&&F.viewBtnActive,"",""],onClick:()=>te("grid"),"aria-label":"Grid view",children:r(U2,{})}),r("button",{css:[F.viewBtn,P==="list"&&F.viewBtnActive,"",""],onClick:()=>te("list"),"aria-label":"List view",children:r(N2,{})})]}),r("button",{css:F.btn,onClick:()=>ge(!0),title:"Font assignments settings",children:r(q2,{})})]})]}),b("div",{css:F.content,onDragOver:zt,onDragLeave:yt,onDrop:Aa,style:{position:"relative"},children:[_&&r("div",{css:F.dropOverlay,children:b("div",{css:F.dropMessage,children:[r(O2,{}),r("span",{children:"Drop TTF files to upload"})]})}),h.length===0&&!A?b("div",{css:F.empty,children:[r(ru,{css:F.emptyIcon}),r("p",{css:F.emptyText,children:"No files yet"}),r("p",{css:F.emptyText,children:zl?'Drop TTF files here or click "Add New"':"This folder is empty"})]}):h.length===0&&A?b("div",{css:F.empty,children:[r(ru,{css:F.emptyIcon}),r("p",{css:F.emptyText,children:"Folder doesn't exist"}),r("button",{css:F.createBtn,onClick:Be,children:"Create Folder"})]}):P==="grid"?b(tt,{children:[h.length>0&&b("div",{css:F.selectAllRow,children:[b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht}),"Select all (",h.length,")"]}),h.some(U=>U.name.toLowerCase().endsWith(".woff2"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".woff2")).every(U=>x.has(U.path)),onChange:tn}),"WOFF2"]}),h.some(U=>U.name.toLowerCase().endsWith(".ttf"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".ttf")).every(U=>x.has(U.path)),onChange:Qt}),"TTF"]})]}),b("div",{css:F.grid,children:[!xt&&b("div",{css:F.item,onClick:Ze,onDoubleClick:Ze,children:[r("div",{css:F.itemContent,children:r(_2,{})}),b("div",{css:F.label,children:[r("p",{css:F.labelName,children:".."}),r("p",{css:F.labelMeta,children:"Parent folder"})]})]}),h.map(U=>{const De=x.has(U.path);return b("div",{css:[F.item,De&&F.itemSelected,"",""],onClick:Ke=>Re(U,Ke),onDoubleClick:()=>Pt(U),children:[r("div",{css:F.checkboxWrapper,onClick:Ke=>{Ke.stopPropagation(),Re(U,Ke)},children:r("input",{type:"checkbox",css:F.checkbox,checked:De,onChange:()=>{}})}),b("div",{css:F.itemContent,children:[r("button",{css:F.openBtn,onClick:Ke=>{Ke.stopPropagation(),Pt(U)},children:"Open"}),U.type==="folder"?r(ru,{}):r(H2,{})]}),b("div",{css:F.label,children:[r("p",{css:F.labelName,children:b("span",{css:F.badgeWrapper,children:[U.type==="folder"&&O[U.path]&&r("span",{css:[F.badge,O[U.path].assignments.length>0?F.badgeGreen:O[U.path].hasWoff2?F.badgeBlue:F.badgeGray,"",""],title:O[U.path].assignments.length>0?`Assigned to: ${O[U.path].assignments.join(", ")}`:O[U.path].hasWoff2?"woff2 ready":"TTF only"}),U.name]})}),r("p",{css:F.labelMeta,children:U.type==="folder"?`${U.fileCount||0} files`:U.size?Rp(U.size):""})]})]},U.path)})]})]}):b(tt,{children:[h.length>0&&b("div",{css:F.selectAllRow,children:[b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht}),"Select all (",h.length,")"]}),h.some(U=>U.name.toLowerCase().endsWith(".woff2"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".woff2")).every(U=>x.has(U.path)),onChange:tn}),"WOFF2"]}),h.some(U=>U.name.toLowerCase().endsWith(".ttf"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".ttf")).every(U=>x.has(U.path)),onChange:Qt}),"TTF"]})]}),r("div",{css:F.tableWrapper,children:b("table",{css:F.table,children:[r("thead",{children:b("tr",{children:[r("th",{css:[F.th,F.thCheckbox,"",""],children:h.length>0&&r("input",{type:"checkbox",css:F.checkbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht})}),r("th",{css:F.th,children:"Name"}),r("th",{css:[F.th,F.thSize,"",""],children:"Size"})]})}),b("tbody",{children:[!xt&&b("tr",{css:F.parentRow,onClick:Ze,children:[r("td",{css:F.td}),r("td",{css:F.td,children:b("div",{css:F.nameCell,children:[r("svg",{css:F.parentIconSmall,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}),r("span",{css:F.name,children:".."})]})}),r("td",{css:[F.td,F.meta,"",""],children:"Parent folder"})]}),h.map(U=>{const De=x.has(U.path);return b("tr",{css:[F.row,De&&F.rowSelected,"",""],onClick:Ke=>Re(U,Ke),children:[r("td",{css:[F.td,F.checkboxCell,"",""],onClick:Ke=>Ke.stopPropagation(),children:r("input",{type:"checkbox",css:F.checkbox,checked:De,onChange:()=>Re(U,{})})}),r("td",{css:F.td,children:b("div",{css:F.nameCell,children:[U.type==="folder"?r("div",{css:F.folderIconWrapper,children:r("svg",{css:F.folderIconSmall,fill:"currentColor",viewBox:"0 0 24 24",children:r("path",{d:"M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-8l-2-2z"})})}):r("div",{css:F.fileIconWrapper,children:r("svg",{css:F.fileIconSmall,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),b("span",{css:F.badgeWrapper,children:[U.type==="folder"&&O[U.path]&&r("span",{css:[F.badge,O[U.path].assignments.length>0?F.badgeGreen:O[U.path].hasWoff2?F.badgeBlue:F.badgeGray,"",""],title:O[U.path].assignments.length>0?`Assigned to: ${O[U.path].assignments.join(", ")}`:O[U.path].hasWoff2?"woff2 ready":"TTF only"}),r("span",{css:F.name,title:U.name,children:U.name})]}),r("div",{css:F.actionsCell,children:r("button",{css:F.listOpenBtn,onClick:Ke=>{Ke.stopPropagation(),Pt(U)},children:"Open"})})]})}),r("td",{css:[F.td,F.meta,"",""],children:U.type==="folder"?`${U.fileCount||0} files`:U.size?Rp(U.size):"--"})]},U.path)})]})]})})]})]}),ce&&r(Cl,{title:"New Folder",message:"Enter a name for the new folder:",placeholder:"Folder name",confirmLabel:"Create",onConfirm:Me,onCancel:()=>Q(!1)}),H&>&&r(Cl,{title:"Rename Folder",message:"Enter a new name for the folder:",placeholder:kt,defaultValue:kt,confirmLabel:"Rename",onConfirm:$,onCancel:()=>G(!1)}),oe&&mt&&r(Cl,{title:"Rename File",message:"Enter a new name for the file:",placeholder:hn,defaultValue:hn,confirmLabel:"Rename",onConfirm:ue,onCancel:()=>J(!1)}),le&&r(fo,{title:"Delete Items",message:`Are you sure you want to delete ${x.size} item${x.size!==1?"s":""}? This action cannot be undone.`,confirmLabel:"Delete",variant:"danger",onConfirm:at,onCancel:()=>X(!1)}),W&>&&r(C2,{folderPath:gt,onConfirm:kn,onCancel:()=>he(!1)}),ie&&r(al,{title:ee,progress:T,onClose:mn}),me&&r(D2,{onClose:()=>ge(!1),onRefresh:d}),qe&&r(Gr,{title:qe.title,message:qe.message,onClose:()=>S(null)})]})}function T2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function E2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"})})}function R2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function L2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function O2(){return r("svg",{css:F.dropIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}function ru(){return r("svg",{css:F.folderIcon,fill:"currentColor",viewBox:"0 0 24 24",children:r("path",{d:"M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-8l-2-2z"})})}function _2(){return r("svg",{css:F.parentIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}function H2(){return r("svg",{css:F.fileIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}function B2({spinning:i}){return r("svg",{css:[F.btnIcon,i&&F.iconSpin,"",""],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function U2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}function N2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})}function j2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})})}function q2(){return b("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}const Y2="36px",At={container:m(ll," display:flex;flex-direction:column;height:100%;background:",s.background,";",""),header:m("display:flex;align-items:center;justify-content:space-between;padding:12px 24px;background:",s.surface,";border-bottom:1px solid ",s.border,";position:relative;",""),titleDropdown:{name:"bjn8wh",styles:"position:relative"},titleButton:m("display:flex;align-items:center;gap:6px;font-size:19px!important;font-weight:600;color:",s.text,";background:transparent;border:none;padding:4px 8px;margin:-4px -8px;border-radius:6px;cursor:pointer;letter-spacing:-0.02em;transition:background 0.15s ease;&:hover{background:",s.surfaceHover,";}",""),titleChevron:m("width:18px;height:18px;color:",s.textSecondary,";transition:transform 0.15s ease;margin-top:2px;stroke-width:2.5;",""),titleChevronOpen:{name:"21xn5r",styles:"transform:rotate(180deg)"},dropdownMenu:m("position:absolute;top:calc(100% + 8px);left:0;background:",s.surface,";border:1px solid ",s.border,";border-radius:8px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);padding:4px;z-index:100;",""),dropdownItem:m("display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;background:transparent;border:none;border-radius:6px;white-space:nowrap;position:relative;top:1px;font-size:19px!important;font-weight:600;letter-spacing:-0.02em;color:",s.text,";cursor:pointer;transition:all 0.15s ease;text-align:left;&:hover{background:",s.surfaceHover,";}",""),dropdownItemActive:m("&::after{content:'';display:inline-block;width:8px;height:8px;background:",s.primary,";border-radius:50%;position:relative;top:1px;}",""),headerLeft:{name:"16ur2v6",styles:"display:flex;align-items:center;gap:12px;flex:1;min-width:0"},headerCenter:{name:"1fsejhz",styles:"position:absolute;left:50%;transform:translateX(-50%);display:flex;align-items:center;max-width:50%"},breadcrumbs:m("display:flex;align-items:center;gap:6px;font-size:",N.base,";color:",s.textSecondary,";overflow:hidden;",""),breadcrumbSeparator:m("color:",s.border,";flex-shrink:0;",""),breadcrumbItem:m("color:",s.textSecondary,";text-decoration:none;cursor:pointer;transition:color 0.15s ease;white-space:nowrap;&:hover{color:",s.primary,";}",""),breadcrumbCurrent:m("color:",s.text,";font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",""),headerIconBtn:m("display:flex;align-items:center;justify-content:center;width:32px;height:32px;color:",s.textMuted,";background:transparent;border:none;border-radius:6px;cursor:pointer;transition:all 0.15s ease;&:hover{color:",s.text,";background:",s.surface,";}",""),headerActions:{name:"1yydxi7",styles:"display:flex;align-items:center;gap:8px"},headerBtn:m("height:",Y2,";padding:0 12px;background:",s.surface,";border:1px solid ",s.border,";border-radius:6px;cursor:pointer;transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;&:hover{background-color:",s.surfaceHover,";border-color:",s.borderHover,";}",""),headerIcon:m("width:16px;height:16px;color:",s.textSecondary,";",""),content:{name:"1rtaly3",styles:"flex:1;display:flex;overflow:hidden"},fileBrowser:{name:"upomw9",styles:"flex:1;min-width:0;overflow:auto;padding:20px 24px;display:flex;flex-direction:column"},dropOverlay:m("position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(99, 91, 255, 0.1);border:3px dashed ",s.primary,";border-radius:8px;display:flex;align-items:center;justify-content:center;z-index:50;pointer-events:none;",""),dropMessage:m("display:flex;flex-direction:column;align-items:center;gap:12px;color:",s.primary,";font-size:",N.lg,";font-weight:600;",""),dropIcon:{name:"18jhpep",styles:"width:48px;height:48px"}};function G2({onClose:i,isVisible:c=!0,standaloneMode:f=!1,workspacePath:d,siteUrl:h}){const p=i||(()=>{}),[C,D]=v.useState("public"),[x,y]=v.useState(new Set),[A,z]=v.useState(null),[_,q]=v.useState("grid"),[H,G]=v.useState(null),[oe,J]=v.useState(null),[ce,Q]=v.useState(!1),[le,X]=v.useState(0),[P,te]=v.useState(!1),[ae,j]=v.useState(""),[W,he]=v.useState(null),[me,ge]=v.useState([]),[ie,Oe]=v.useState(!1),[T,Z]=v.useState(()=>{if(typeof window<"u"){const $=window.location.hash.slice(1);if($==="fonts")return"fonts";if($==="media")return"media"}return"media"}),[ee,Ee]=v.useState(!1),qe=v.useRef(null);v.useEffect(()=>{const $=()=>{const ue=window.location.hash.slice(1);ue==="fonts"?Z("fonts"):ue==="media"&&Z("media")};return window.addEventListener("hashchange",$),()=>window.removeEventListener("hashchange",$)},[]);const[S,O]=v.useState("_fonts"),[ne,re]=v.useState(0),we=v.useCallback(()=>{X($=>$+1)},[]),[ze,Ge]=v.useState(null),xt=v.useCallback($=>{Ge({path:$,key:Date.now()})},[]);v.useEffect(()=>{if(H&&me.length>0){const $=me.find(ue=>ue.path===H.path);$&&JSON.stringify($)!==JSON.stringify(H)&&G($)}},[me,H]);const Re=v.useCallback(()=>{te(!0)},[]),Pt=v.useCallback(()=>{te(!1)},[]),Ze=v.useCallback(($,ue)=>{he({title:$,message:ue})},[]),Je=v.useCallback(()=>{he(null)},[]),it=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),Oe(!0)},[]),Ht=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),Oe(!1)},[]),Yt=v.useCallback(async $=>{$.preventDefault(),$.stopPropagation(),Oe(!1);const ue=Array.from($.dataTransfer.files);if(ue.length!==0&&!(C==="public/images"||C.startsWith("public/images/"))){for(const Xe of ue){const at=new FormData;at.append("file",Xe),at.append("path",C);try{await fetch("/api/studio/upload",{method:"POST",body:at})}catch(Be){console.error("Upload error:",Be)}}we()}},[C,we]),tn=v.useCallback(()=>{if(C==="public")return;const $=C.split("/");$.pop(),D($.join("/")||"public"),y(new Set)},[C]),Qt=v.useCallback($=>{D($),y(new Set),G(null)},[]),fn=v.useCallback($=>{y(ue=>{const Xe=new Set(ue);return Xe.has($)?Xe.delete($):Xe.add($),Xe}),z($)},[]),Bt=v.useCallback(($,ue,Xe)=>{const at=Xe.findIndex(yt=>yt.path===$),Be=Xe.findIndex(yt=>yt.path===ue);if(at===-1||Be===-1)return;const Me=Math.min(at,Be),zt=Math.max(at,Be);y(yt=>{const Aa=new Set(yt);for(let ia=Me;ia<=zt;ia++)Aa.add(Xe[ia].path);return Aa}),z(ue)},[]),$e=v.useCallback($=>{y(new Set($.map(ue=>ue.path)))},[]),gt=v.useCallback(()=>{y(new Set)},[]),kt=v.useCallback($=>{G($)},[]),Te=v2({triggerRefresh:we,clearSelection:gt,setFocusedItem:kt,showError:Ze}),mt=v.useCallback($=>{if($.key==="Escape"){const ue=$.target;if(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA")return;H?G(null):f||p()}},[p,H,f]);v.useEffect(()=>(c&&(document.addEventListener("keydown",mt),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",mt),document.body.style.overflow=""}),[mt,c]),v.useEffect(()=>{const $=ue=>{qe.current&&!qe.current.contains(ue.target)&&Ee(!1)};return ee&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ee]);const hn=v.useCallback(()=>{Ee($=>!$)},[]),Hn=v.useCallback($=>{Z($),Ee(!1),window.location.hash=$},[]),kn=v.useCallback(()=>{re($=>$+1)},[]),mn={isOpen:!0,openStudio:()=>{},closeStudio:p,toggleStudio:p,currentPath:C,setCurrentPath:Qt,navigateUp:tn,selectedItems:x,toggleSelection:fn,selectRange:Bt,selectAll:$e,clearSelection:gt,lastSelectedPath:A,viewMode:_,setViewMode:q,focusedItem:H,setFocusedItem:G,meta:oe,setMeta:J,isLoading:ce,setIsLoading:Q,refreshKey:le,triggerRefresh:we,editedImageKey:ze,setEditedImageKey:xt,scanRequested:P,triggerScan:Re,clearScanRequest:Pt,searchQuery:ae,setSearchQuery:j,error:W,showError:Ze,clearError:Je,fileItems:me,setFileItems:ge,actionState:Te.actionState,requestDelete:Te.requestDelete,requestMove:Te.requestMove,requestSync:Te.requestSync,requestDownload:Te.requestDownload,requestProcess:Te.requestProcess,setProcessMode:Te.setProcessMode,confirmDelete:Te.confirmDelete,confirmMove:Te.confirmMove,confirmSync:Te.confirmSync,confirmProcess:Te.confirmProcess,cancelAction:Te.cancelAction,closeProgress:Te.closeProgress,stopProcessing:Te.stopProcessing,deleteOrphans:Te.deleteOrphans};return r(Xp.Provider,{value:mn,children:b("div",{css:At.container,children:[b("div",{css:At.header,children:[r("div",{css:At.headerLeft,children:b("div",{css:At.titleDropdown,ref:qe,children:[b("button",{css:At.titleButton,onClick:hn,children:[r("span",{children:"gallop.studio"}),r(J2,{isOpen:ee})]}),ee&&b("div",{css:At.dropdownMenu,children:[r("button",{css:[At.dropdownItem,T==="media"&&At.dropdownItemActive,"",""],onClick:()=>Hn("media"),children:"media & files"}),r("button",{css:[At.dropdownItem,T==="fonts"&&At.dropdownItemActive,"",""],onClick:()=>Hn("fonts"),children:"fonts"})]})]})}),r("div",{css:At.headerCenter,children:r(Q2,{currentPath:C,onNavigate:Qt,projectName:d?d.split("/").pop():void 0})}),b("div",{css:At.headerActions,children:[h&&r("a",{href:h,target:"_blank",rel:"noopener noreferrer",css:At.headerIconBtn,title:`Open ${h}`,children:r(K2,{})}),!f&&r("button",{css:At.headerBtn,onClick:p,"aria-label":"Close Studio",children:r(Z2,{})})]})]}),T==="media"?b(tt,{children:[r(D1,{}),b("div",{css:At.content,onDragOver:it,onDragLeave:Ht,onDrop:Yt,children:[ie&&r("div",{css:At.dropOverlay,children:b("div",{css:At.dropMessage,children:[r("svg",{css:At.dropIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),r("span",{children:"Drop files to upload"})]})}),r("div",{css:At.fileBrowser,children:_==="grid"?r(Z1,{}):r(P1,{})})]}),H&&r(m2,{}),r(b2,{}),Te.actionState.showDeleteConfirm&&r(fo,{title:"Delete Files",message:`Are you sure you want to delete ${Te.actionState.actionPaths.length} item${Te.actionState.actionPaths.length!==1?"s":""}? This action cannot be undone.`,confirmLabel:"Delete",variant:"danger",onConfirm:Te.confirmDelete,onCancel:Te.cancelAction}),Te.actionState.showSyncConfirm&&r(fo,{title:"Push to CDN",message:`Push ${Te.actionState.syncImageCount} image${Te.actionState.syncImageCount!==1?"s":""} to Cloudflare R2?${Te.actionState.syncHasRemote?" Remote images will be downloaded first.":""}${Te.actionState.syncHasLocal?" After pushing, local files will be deleted.":""}`,confirmLabel:"Push",onConfirm:Te.confirmSync,onCancel:Te.cancelAction}),Te.actionState.showProcessConfirm&&r(F2,{imageCount:Te.actionState.actionPaths.length,mode:Te.actionState.processMode,onConfirm:Te.confirmProcess,onCancel:Te.cancelAction}),Te.actionState.showMoveModal&&r(Fp,{selectedItems:new Set(Te.actionState.actionPaths),currentPath:C,onMove:$=>Te.confirmMove($),onCancel:Te.cancelAction}),Te.actionState.showProgress&&r(al,{title:Te.actionState.progressTitle,progress:Te.actionState.progressState,onStop:Te.stopProcessing,onDeleteOrphans:Te.deleteOrphans,onClose:Te.closeProgress})]}):r(A2,{currentPath:S,setCurrentPath:O,refreshKey:ne,triggerRefresh:kn})]})})}var X2={name:"1cm5yut",styles:"display:flex;gap:12px;justify-content:flex-end"},V2={name:"1ca3l8d",styles:"position:fixed;inset:0;background:rgba(0, 0, 0, 0.5);display:flex;align-items:center;justify-content:center;z-index:10000"};function F2({imageCount:i,mode:c,onConfirm:f,onCancel:d}){const h={overlay:V2,container:m("background:",s.surface,";border-radius:12px;padding:24px;max-width:420px;width:90%;box-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.1),0 10px 10px -5px rgba(0, 0, 0, 0.04);",""),title:m("font-size:",N.lg,";font-weight:600;color:",s.text,";margin:0 0 16px;",""),message:m("font-size:",N.base,";color:",s.textSecondary,";margin:0 0 20px;line-height:1.5;",""),actions:X2,cancelBtn:m("padding:10px 20px;border:1px solid ",s.border,";border-radius:8px;background:",s.background,";color:",s.text,";font-size:",N.base,";font-weight:500;cursor:pointer;transition:all 0.15s ease;&:hover{background:",s.surfaceHover,";border-color:",s.borderHover,";}",""),confirmBtn:m("padding:10px 20px;border:none;border-radius:8px;background:",s.primary,";color:white;font-size:",N.base,";font-weight:500;cursor:pointer;transition:all 0.15s ease;&:hover{background:",s.primaryHover,";}",""),confirmBtnDanger:m("background:",s.danger,";&:hover{background:#dc2626;}","")},p=c==="remove",C=p?"Remove Thumbnails":"Generate Thumbnails",D=p?`Remove generated thumbnails for ${i} image${i!==1?"s":""}? Original images will be kept.`:`Generate thumbnails for ${i} image${i!==1?"s":""}?`,x=p?"Remove":"Generate";return r("div",{css:h.overlay,onClick:d,children:b("div",{css:h.container,onClick:y=>y.stopPropagation(),children:[r("h2",{css:h.title,children:C}),r("p",{css:h.message,children:D}),b("div",{css:h.actions,children:[r("button",{css:h.cancelBtn,onClick:d,children:"Cancel"}),r("button",{css:[h.confirmBtn,p&&h.confirmBtnDanger,"",""],onClick:f,children:x})]})]})})}function Q2({currentPath:i,onNavigate:c,projectName:f}){const d=i.split("/").filter(Boolean),h=d.map((p,C)=>({name:C===0&&p==="public"&&f?f:p,path:d.slice(0,C+1).join("/")}));return r("div",{css:At.breadcrumbs,children:h.map((p,C)=>b("span",{style:{display:"flex",alignItems:"center",gap:6},children:[C>0&&r("span",{css:At.breadcrumbSeparator,children:"/"}),C===h.length-1?r("span",{css:At.breadcrumbCurrent,children:p.name}):r("span",{css:At.breadcrumbItem,onClick:()=>c(p.path),children:p.name})]},p.path))})}function K2(){return b("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function Z2(){return b("svg",{css:At.headerIcon,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function J2({isOpen:i}){return r("svg",{css:[At.titleChevron,i&&At.titleChevronOpen,"",""],viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:r("polyline",{points:"6 9 12 15 18 9"})})}const Jp=document.getElementById("root");if(!Jp)throw new Error("Root element not found");const $2=window.__STUDIO_WORKSPACE__||"Unknown",W2=window.__STUDIO_SITE_URL__||"";c1.createRoot(Jp).render(r(v.StrictMode,{children:r("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"#0a0a0a"},children:r(G2,{isVisible:!0,standaloneMode:!0,workspacePath:$2,siteUrl:W2})})}));
|
|
124
|
+
`,F={container:{name:"xt6tct",styles:"flex:1;display:flex;flex-direction:column;overflow:hidden"},toolbar:m("display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;background-color:",s.surface,";border-bottom:1px solid ",s.border,";@media (min-width: 768px){padding:12px 24px;}",""),toolbarLeft:{name:"17nohj2",styles:"display:flex;flex-wrap:nowrap;flex-shrink:0;align-items:center;gap:8px"},toolbarRight:{name:"17nohj2",styles:"display:flex;flex-wrap:nowrap;flex-shrink:0;align-items:center;gap:8px"},selectionCount:m("font-size:",N.base,";color:",s.textSecondary,";display:flex;align-items:center;gap:8px;margin-right:8px;",""),clearBtn:m("color:",s.primary,";background:none;border:none;cursor:pointer;font-size:",N.base,";font-weight:500;padding:0;&:hover{text-decoration:underline;}",""),btn:m("display:inline-flex;align-items:center;justify-content:center;gap:6px;height:",Tp,";padding:0 14px;border-radius:6px;font-size:",N.base,";font-weight:500;background:",s.surface,";border:1px solid ",s.border,";cursor:pointer;transition:all 0.15s ease;color:",s.text,";&:hover:not(:disabled){background-color:",s.surfaceHover,";border-color:",s.borderHover,";}&:disabled{cursor:not-allowed;opacity:0.5;}",""),btnPrimary:m("background:",s.primary,";border-color:",s.primary,";color:white;&:hover:not(:disabled){background:",s.primaryHover,";border-color:",s.primaryHover,";}",""),btnDanger:m("color:",s.danger,";&:hover:not(:disabled){background-color:",s.dangerLight,";border-color:",s.danger,";}",""),btnIcon:{name:"157xhr7",styles:"width:16px;height:16px"},content:{name:"1tznmxd",styles:"flex:1;overflow:auto;padding:20px 24px"},loading:{name:"1d2ui9i",styles:"display:flex;align-items:center;justify-content:center;flex:1;min-height:300px"},spinner:m("width:32px;height:32px;border-radius:50%;border:3px solid ",s.border,";border-top-color:",s.primary,";animation:",Ep," 0.8s linear infinite;",""),empty:m("display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-height:300px;color:",s.textSecondary,";",""),emptyIcon:{name:"1o3cbsn",styles:"width:48px;height:48px;margin-bottom:16px;opacity:0.5"},emptyText:m("font-size:",N.base,";margin:0 0 4px 0;&:last-child{color:",s.textMuted,";font-size:",N.sm,";}",""),selectAllRow:m("display:flex;align-items:center;gap:24px;margin-bottom:16px;padding:12px 16px;background:",s.surface,";border-radius:8px;border:1px solid ",s.border,";",""),selectAllLabel:m("display:flex;align-items:center;gap:10px;font-size:",N.base,";font-weight:500;color:",s.textSecondary,";cursor:pointer;&:hover{color:",s.text,";}",""),selectAllCheckbox:m("width:16px;height:16px;accent-color:",s.primary,";",""),grid:{name:"el23hk",styles:"display:grid;grid-template-columns:1fr;gap:12px;@media (min-width: 480px){grid-template-columns:repeat(2, 1fr);}@media (min-width: 768px){grid-template-columns:repeat(3, 1fr);}@media (min-width: 1024px){grid-template-columns:repeat(4, 1fr);}@media (min-width: 1280px){grid-template-columns:repeat(5, 1fr);}"},item:m("position:relative;border-radius:8px;border:1px solid ",s.border,";overflow:hidden;cursor:pointer;transition:all 0.15s ease;background-color:",s.surface,";user-select:none;box-shadow:0 1px 2px rgba(0, 0, 0, 0.04);&:hover{border-color:#d0d5dd;box-shadow:0 2px 4px rgba(0, 0, 0, 0.06);}",""),itemSelected:m("border-color:",s.primary,";box-shadow:0 0 0 1px ",s.primary,";&:hover{border-color:",s.primary,";box-shadow:0 0 0 1px ",s.primary,";}",""),checkboxWrapper:{name:"v3lnpt",styles:"position:absolute;top:0;left:0;z-index:10;padding:8px;cursor:pointer"},checkbox:m("width:18px;height:18px;accent-color:",s.primary,";cursor:pointer;",""),itemContent:m("position:relative;aspect-ratio:1;display:flex;align-items:center;justify-content:center;padding:16px;background:",s.background,";",""),folderIcon:{name:"k1w47f",styles:"width:56px;height:56px;color:#f9935e"},parentIcon:m("width:56px;height:56px;color:",s.textMuted,";",""),fileIcon:m("width:40px;height:40px;color:",s.textMuted,";",""),openBtn:m("position:absolute;bottom:8px;right:8px;z-index:10;height:28px;font-size:",N.sm,";font-weight:500;color:",s.primary,";background:",s.surface,";border:1px solid ",s.border,";padding:0 8px;cursor:pointer;border-radius:4px;transition:all 0.15s ease;display:flex;align-items:center;box-shadow:0 1px 2px rgba(0, 0, 0, 0.08);&:hover{background-color:",s.primaryLight,";border-color:",s.primary,";}",""),label:m("padding:10px 12px;background-color:",s.surface,";border-top:1px solid ",s.borderLight,";",""),labelName:m("font-size:",N.sm,";font-weight:500;color:",s.text,";margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",""),labelMeta:m("font-size:",N.xs,";color:",s.textMuted,";margin:2px 0 0 0;",""),dropOverlay:m("position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(99, 91, 255, 0.1);border:3px dashed ",s.primary,";border-radius:8px;display:flex;align-items:center;justify-content:center;z-index:50;pointer-events:none;",""),dropMessage:m("display:flex;flex-direction:column;align-items:center;gap:12px;color:",s.primary,";font-size:",N.lg,";font-weight:600;",""),dropIcon:{name:"18jhpep",styles:"width:48px;height:48px"},createBtn:m("margin-top:16px;padding:10px 24px;font-size:",N.base,";font-weight:500;background:",s.primary,";color:white;border:none;border-radius:8px;cursor:pointer;transition:background 0.15s ease;&:hover{background:",s.primaryHover,";}",""),viewToggle:m("display:flex;align-items:center;height:",Tp,";background-color:",s.surface,";border:1px solid ",s.border,";border-radius:6px;overflow:hidden;",""),viewBtn:m("height:100%;padding:0 10px;background:transparent;border:none;cursor:pointer;color:",s.textSecondary,";transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;&:hover{color:",s.text,";background-color:",s.surfaceHover,";}",""),viewBtnActive:m("background-color:",s.primaryLight,";color:",s.primary,";&:hover{background-color:",s.primaryLight,";color:",s.primary,";}",""),iconSpin:m("animation:",Ep," 1s linear infinite;",""),tableWrapper:m("background:",s.surface,";border-radius:8px;border:1px solid ",s.border,";overflow-x:auto;",""),table:{name:"1ceqwkv",styles:"width:100%;min-width:400px;border-collapse:collapse;white-space:nowrap"},th:m("text-align:left;font-size:11px;color:",s.textMuted,";text-transform:uppercase;letter-spacing:0.05em;padding:12px 16px;font-weight:600;background:",s.background,";border-bottom:1px solid ",s.border,";",""),thCheckbox:{name:"5iz1wr",styles:"width:48px"},thSize:{name:"yct5co",styles:"width:96px"},row:m("cursor:pointer;transition:background-color 0.15s ease;user-select:none;&:hover{background-color:",s.surfaceHover,";}&:not(:last-child) td{border-bottom:1px solid ",s.borderLight,";}",""),rowSelected:m("background-color:",s.primaryLight,";&:hover{background-color:",s.primaryLight,";}",""),parentRow:m("cursor:pointer;border-bottom:1px solid ",s.border,";&:hover{background-color:",s.surfaceHover,";}",""),td:{name:"i563hg",styles:"padding:12px 16px"},checkboxCell:{name:"sahq4q",styles:"padding:12px 16px;cursor:pointer;vertical-align:middle"},nameCell:{name:"9s3nhy",styles:"display:flex;align-items:center;gap:12px;flex:1"},folderIconWrapper:{name:"xfecxx",styles:"width:48px;height:36px;display:flex;align-items:center;justify-content:center;flex-shrink:0"},folderIconSmall:{name:"a45yt2",styles:"width:24px;height:24px;color:#f9935e"},fileIconWrapper:{name:"xfecxx",styles:"width:48px;height:36px;display:flex;align-items:center;justify-content:center;flex-shrink:0"},fileIconSmall:m("width:20px;height:20px;color:",s.textMuted,";",""),parentIconSmall:m("width:20px;height:20px;color:",s.textMuted,";flex-shrink:0;",""),name:m("font-size:",N.base,";font-weight:500;color:",s.text,";letter-spacing:-0.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:300px;",""),meta:m("font-size:",N.sm,";color:",s.textSecondary,";",""),actionsCell:{name:"1w56d5c",styles:"display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-left:auto;flex-shrink:0"},listOpenBtn:m("height:32px;font-size:",N.sm,";font-weight:500;color:",s.primary,";background:",s.surface,";border:1px solid ",s.border,";padding:0 14px;cursor:pointer;border-radius:4px;transition:all 0.15s ease;display:inline-flex;align-items:center;&:hover{background-color:",s.primaryLight,";border-color:",s.primary,";}",""),badge:{name:"1ue8xbs",styles:"width:8px;height:8px;border-radius:50%;flex-shrink:0"},badgeGray:{name:"a0o945",styles:"background-color:#9ca3af"},badgeYellow:{name:"yqs32k",styles:"background-color:#eab308"},badgeGreen:{name:"b752gh",styles:"background-color:#10b981"},badgeWrapper:{name:"1pi78hi",styles:"display:flex;align-items:center;gap:6px"}};function Rp(i){return i<1024?i+" B":i<1024*1024?(i/1024).toFixed(1)+" KB":(i/(1024*1024)).toFixed(1)+" MB"}function A2({currentPath:i,setCurrentPath:c,refreshKey:f,triggerRefresh:d}){const[h,p]=v.useState([]),[C,D]=v.useState(!0),[x,y]=v.useState(new Set),[A,z]=v.useState(!1),[_,q]=v.useState(!1),[H,G]=v.useState(!1),[oe,J]=v.useState(!1),[ce,Q]=v.useState(!1),[le,X]=v.useState(!1),[P,te]=v.useState("grid"),[ae,j]=v.useState(!1),[W,he]=v.useState(!1),[me,ge]=v.useState(!1),[ie,Oe]=v.useState(!1),[T,Z]=v.useState({status:"idle",current:0,total:0,percent:0}),[ee,Ee]=v.useState("Processing"),[qe,S]=v.useState(null),[O,ne]=v.useState({}),[re,we]=v.useState(null),ze=v.useCallback(async()=>{try{D(!0);const U=await fetch(`/api/studio/fonts/list?path=${encodeURIComponent(i)}`);if(U.ok){const De=await U.json();p(De.items||[]),z(De.canCreate===!0)}}catch(U){console.error("Failed to fetch fonts:",U),p([])}finally{D(!1)}},[i]);v.useEffect(()=>{ze(),y(new Set)},[ze,f]);const Ge=v.useCallback(async U=>{const De={};for(const Ke of U)if(Ke.type==="folder")try{const ft=await fetch("/api/studio/fonts/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:Ke.path})});if(ft.ok){const Rt=await ft.json();De[Ke.path]={needsGeneration:Rt.needsGeneration,hasWoff2:Rt.woff2Files?.length>0,assignments:Rt.assignments||[]}}}catch{}ne(De)},[]);v.useEffect(()=>{const U=h.filter(De=>De.type==="folder");U.length>0&&i.startsWith("_fonts")&&Ge(U)},[h,i,Ge]);const xt=i==="_fonts";i==="src"||i.startsWith("src/");const Re=v.useCallback((U,De)=>{if(De.stopPropagation(),De.shiftKey&&re){const Ke=h.findIndex(Rt=>Rt.path===re),ft=h.findIndex(Rt=>Rt.path===U.path);if(Ke!==-1&&ft!==-1){const Rt=Math.min(Ke,ft),zn=Math.max(Ke,ft);y(Ml=>{const ra=new Set(Ml);for(let Bn=Rt;Bn<=zn;Bn++)ra.add(h[Bn].path);return ra})}}else y(Ke=>{const ft=new Set(Ke);return ft.has(U.path)?ft.delete(U.path):ft.add(U.path),ft});we(U.path)},[h,re]),Pt=v.useCallback(U=>{U.type==="folder"&&(c(U.path),y(new Set))},[c]),Ze=v.useCallback(()=>{const U=i.split("/");U.pop();const De=U.join("/")||"_fonts";c(De),y(new Set)},[i,c]),Je=h.length>0&&x.size===h.length,it=x.size>0,Ht=v.useCallback(()=>{y(Je?new Set:new Set(h.map(U=>U.path)))},[Je,h]),Yt=v.useCallback(()=>{y(new Set),we(null)},[]),tn=v.useCallback(()=>{const U=h.filter(De=>De.type==="file"&&De.name.toLowerCase().endsWith(".woff2"));y(new Set(U.map(De=>De.path)))},[h]),Qt=v.useCallback(()=>{const U=h.filter(De=>De.type==="file"&&De.name.toLowerCase().endsWith(".ttf"));y(new Set(U.map(De=>De.path)))},[h]),fn=v.useCallback(async()=>{j(!0),await ze(),j(!1)},[ze]),Bt=Array.from(x),$e=Bt.length===1&&h.find(U=>U.path===Bt[0])?.type==="folder",gt=$e?Bt[0]:null,kt=gt&>.split("/").pop()||"",Te=Bt.length===1&&h.find(U=>U.path===Bt[0])?.type==="file",mt=Te?Bt[0]:null,hn=mt&&mt.split("/").pop()||"",Hn=v.useCallback(()=>{$e&&he(!0)},[$e]),kn=v.useCallback(async U=>{he(!1),Ee("Assigning Web Font"),Oe(!0),Z({status:"progress",current:0,total:1,percent:0,message:"Starting..."});try{const De=await fetch("/api/studio/fonts/assign-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder:gt,assignments:U})});if(!De.ok||!De.body){Z({status:"error",current:0,total:0,percent:0,message:"Failed to start assignment"});return}const Ke=De.body.getReader(),ft=new TextDecoder;for(;;){const{done:Rt,value:zn}=await Ke.read();if(Rt)break;const ra=ft.decode(zn,{stream:!0}).split(`
|
|
125
|
+
`);for(const Bn of ra)if(Bn.startsWith("data: "))try{const Ut=JSON.parse(Bn.slice(6));Ut.status==="progress"?Z({status:"progress",current:Ut.current||0,total:Ut.total||1,percent:Ut.total?Math.round(Ut.current/Ut.total*100):0,message:Ut.message,currentFile:Ut.currentFile}):Ut.status==="complete"?(Z({status:"complete",current:Ut.created?.length||0,total:Ut.created?.length||0,percent:100,message:Ut.message,processed:Ut.created?.length||0}),d()):Ut.status==="error"&&Z({status:"error",current:0,total:0,percent:0,message:Ut.message})}catch{}}}catch(De){Z({status:"error",current:0,total:0,percent:0,message:String(De)})}},[gt,d]),mn=v.useCallback(()=>{Oe(!1),Z({status:"idle",current:0,total:0,percent:0})},[]),$=v.useCallback(async U=>{if(gt){G(!1);try{(await fetch("/api/studio/fonts/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:gt,newName:U})})).ok&&(y(new Set),d())}catch(De){console.error("Rename failed:",De)}}},[gt,d]),ue=v.useCallback(async U=>{if(mt){J(!1);try{(await fetch("/api/studio/fonts/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:mt,newName:U})})).ok&&(y(new Set),d())}catch(De){console.error("Rename file failed:",De)}}},[mt,d]),Xe=v.useCallback(()=>{x.size!==0&&X(!0)},[x.size]),at=v.useCallback(async()=>{X(!1),Ee("Deleting Files"),Oe(!0),Z({status:"progress",current:0,total:x.size,percent:0,message:"Deleting..."});try{(await fetch("/api/studio/fonts/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:Array.from(x)})})).ok?(Z({status:"complete",current:x.size,total:x.size,percent:100,message:`Deleted ${x.size} item${x.size!==1?"s":""}`}),y(new Set),d()):Z({status:"error",current:0,total:0,percent:0,message:"Delete failed"})}catch(U){console.error("Delete failed:",U),Z({status:"error",current:0,total:0,percent:0,message:"Delete failed"})}},[x,d]),Be=v.useCallback(()=>{Q(!0)},[]),Me=v.useCallback(async U=>{Q(!1);try{(await fetch("/api/studio/fonts/create-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:i,name:U})})).ok&&d()}catch(De){console.error("Create folder failed:",De)}},[i,d]),zt=v.useCallback(U=>{U.preventDefault(),U.stopPropagation(),i.startsWith("_fonts")&&q(!0)},[i]),yt=v.useCallback(U=>{U.preventDefault(),U.stopPropagation(),q(!1)},[]),Aa=v.useCallback(async U=>{if(U.preventDefault(),U.stopPropagation(),q(!1),!i.startsWith("_fonts"))return;const De=Array.from(U.dataTransfer.files).filter(Ke=>Ke.name.toLowerCase().endsWith(".ttf"));if(De.length!==0){for(const Ke of De){const ft=new FormData;ft.append("file",Ke),ft.append("path",i);try{await fetch("/api/studio/fonts/upload",{method:"POST",body:ft})}catch(Rt){console.error("Upload failed:",Rt)}}d()}},[i,d]),ia=v.useCallback(U=>{U&&U.addEventListener("change",async De=>{const Ke=De.target.files;if(!(!Ke||Ke.length===0)){for(const ft of Array.from(Ke)){if(!ft.name.toLowerCase().endsWith(".ttf"))continue;const Rt=new FormData;Rt.append("file",ft),Rt.append("path",i);try{await fetch("/api/studio/fonts/upload",{method:"POST",body:Rt})}catch(zn){console.error("Upload failed:",zn)}}d(),U.value=""}})},[i,d]);if(C)return b("div",{css:F.container,children:[r("div",{css:F.toolbar}),r("div",{css:F.loading,children:r("div",{css:F.spinner})})]});const zl=i.startsWith("_fonts");return b("div",{css:F.container,children:[b("div",{css:F.toolbar,children:[b("div",{css:F.toolbarLeft,children:[zl&&b(tt,{children:[b("button",{css:[F.btn,F.btnPrimary,"",""],onClick:()=>document.getElementById("font-file-input")?.click(),children:[r(T2,{}),"Add New"]}),r("input",{id:"font-file-input",type:"file",accept:".ttf",multiple:!0,style:{display:"none"},ref:ia})]}),b("button",{css:F.btn,onClick:()=>{Te?J(!0):$e?G(!0):Be()},children:[Te||$e?r(L2,{}):r(E2,{}),Te?"Rename File":$e?"Rename Folder":"New Folder"]}),b("button",{css:[F.btn,F.btnDanger,"",""],onClick:Xe,disabled:x.size===0,children:[r(R2,{}),"Delete"]}),b("button",{css:F.btn,onClick:Hn,disabled:!$e,title:$e?"Assign web font":"Select a folder to assign",children:[r(j2,{}),"Assign Web Font"]})]}),b("div",{css:F.toolbarRight,children:[it&&b("span",{css:F.selectionCount,children:[x.size," selected",r("button",{css:F.clearBtn,onClick:Yt,children:"Clear"})]}),r("button",{css:F.btn,onClick:fn,title:"Refresh view",disabled:ae,children:r(B2,{spinning:ae})}),b("div",{css:F.viewToggle,children:[r("button",{css:[F.viewBtn,P==="grid"&&F.viewBtnActive,"",""],onClick:()=>te("grid"),"aria-label":"Grid view",children:r(U2,{})}),r("button",{css:[F.viewBtn,P==="list"&&F.viewBtnActive,"",""],onClick:()=>te("list"),"aria-label":"List view",children:r(N2,{})})]}),r("button",{css:F.btn,onClick:()=>ge(!0),title:"Font assignments settings",children:r(q2,{})})]})]}),b("div",{css:F.content,onDragOver:zt,onDragLeave:yt,onDrop:Aa,style:{position:"relative"},children:[_&&r("div",{css:F.dropOverlay,children:b("div",{css:F.dropMessage,children:[r(O2,{}),r("span",{children:"Drop TTF files to upload"})]})}),h.length===0&&!A?b("div",{css:F.empty,children:[r(ru,{css:F.emptyIcon}),r("p",{css:F.emptyText,children:"No files yet"}),r("p",{css:F.emptyText,children:zl?'Drop TTF files here or click "Add New"':"This folder is empty"})]}):h.length===0&&A?b("div",{css:F.empty,children:[r(ru,{css:F.emptyIcon}),r("p",{css:F.emptyText,children:"Folder doesn't exist"}),r("button",{css:F.createBtn,onClick:Be,children:"Create Folder"})]}):P==="grid"?b(tt,{children:[h.length>0&&b("div",{css:F.selectAllRow,children:[b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht}),"Select all (",h.length,")"]}),h.some(U=>U.name.toLowerCase().endsWith(".woff2"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".woff2")).every(U=>x.has(U.path)),onChange:tn}),"WOFF2"]}),h.some(U=>U.name.toLowerCase().endsWith(".ttf"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".ttf")).every(U=>x.has(U.path)),onChange:Qt}),"TTF"]})]}),b("div",{css:F.grid,children:[!xt&&b("div",{css:F.item,onClick:Ze,onDoubleClick:Ze,children:[r("div",{css:F.itemContent,children:r(_2,{})}),b("div",{css:F.label,children:[r("p",{css:F.labelName,children:".."}),r("p",{css:F.labelMeta,children:"Parent folder"})]})]}),h.map(U=>{const De=x.has(U.path);return b("div",{css:[F.item,De&&F.itemSelected,"",""],onClick:Ke=>Re(U,Ke),onDoubleClick:()=>Pt(U),children:[r("div",{css:F.checkboxWrapper,onClick:Ke=>{Ke.stopPropagation(),Re(U,Ke)},children:r("input",{type:"checkbox",css:F.checkbox,checked:De,onChange:()=>{}})}),b("div",{css:F.itemContent,children:[r("button",{css:F.openBtn,onClick:Ke=>{Ke.stopPropagation(),Pt(U)},children:"Open"}),U.type==="folder"?r(ru,{}):r(H2,{})]}),b("div",{css:F.label,children:[r("p",{css:F.labelName,children:b("span",{css:F.badgeWrapper,children:[U.type==="folder"&&O[U.path]&&r("span",{css:[F.badge,O[U.path].assignments.length>0?F.badgeGreen:O[U.path].hasWoff2?F.badgeYellow:F.badgeGray,"",""],title:O[U.path].assignments.length>0?`Assigned to: ${O[U.path].assignments.join(", ")}`:O[U.path].hasWoff2?"woff2 ready":"TTF only"}),U.name]})}),r("p",{css:F.labelMeta,children:U.type==="folder"?`${U.fileCount||0} files`:U.size?Rp(U.size):""})]})]},U.path)})]})]}):b(tt,{children:[h.length>0&&b("div",{css:F.selectAllRow,children:[b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht}),"Select all (",h.length,")"]}),h.some(U=>U.name.toLowerCase().endsWith(".woff2"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".woff2")).every(U=>x.has(U.path)),onChange:tn}),"WOFF2"]}),h.some(U=>U.name.toLowerCase().endsWith(".ttf"))&&b("label",{css:F.selectAllLabel,children:[r("input",{type:"checkbox",css:F.selectAllCheckbox,checked:h.filter(U=>U.name.toLowerCase().endsWith(".ttf")).every(U=>x.has(U.path)),onChange:Qt}),"TTF"]})]}),r("div",{css:F.tableWrapper,children:b("table",{css:F.table,children:[r("thead",{children:b("tr",{children:[r("th",{css:[F.th,F.thCheckbox,"",""],children:h.length>0&&r("input",{type:"checkbox",css:F.checkbox,checked:Je,ref:U=>{U&&(U.indeterminate=it&&!Je)},onChange:Ht})}),r("th",{css:F.th,children:"Name"}),r("th",{css:[F.th,F.thSize,"",""],children:"Size"})]})}),b("tbody",{children:[!xt&&b("tr",{css:F.parentRow,onClick:Ze,children:[r("td",{css:F.td}),r("td",{css:F.td,children:b("div",{css:F.nameCell,children:[r("svg",{css:F.parentIconSmall,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})}),r("span",{css:F.name,children:".."})]})}),r("td",{css:[F.td,F.meta,"",""],children:"Parent folder"})]}),h.map(U=>{const De=x.has(U.path);return b("tr",{css:[F.row,De&&F.rowSelected,"",""],onClick:Ke=>Re(U,Ke),children:[r("td",{css:[F.td,F.checkboxCell,"",""],onClick:Ke=>Ke.stopPropagation(),children:r("input",{type:"checkbox",css:F.checkbox,checked:De,onChange:()=>Re(U,{})})}),r("td",{css:F.td,children:b("div",{css:F.nameCell,children:[U.type==="folder"?r("div",{css:F.folderIconWrapper,children:r("svg",{css:F.folderIconSmall,fill:"currentColor",viewBox:"0 0 24 24",children:r("path",{d:"M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-8l-2-2z"})})}):r("div",{css:F.fileIconWrapper,children:r("svg",{css:F.fileIconSmall,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),b("span",{css:F.badgeWrapper,children:[U.type==="folder"&&O[U.path]&&r("span",{css:[F.badge,O[U.path].assignments.length>0?F.badgeGreen:O[U.path].hasWoff2?F.badgeYellow:F.badgeGray,"",""],title:O[U.path].assignments.length>0?`Assigned to: ${O[U.path].assignments.join(", ")}`:O[U.path].hasWoff2?"woff2 ready":"TTF only"}),r("span",{css:F.name,title:U.name,children:U.name})]}),r("div",{css:F.actionsCell,children:r("button",{css:F.listOpenBtn,onClick:Ke=>{Ke.stopPropagation(),Pt(U)},children:"Open"})})]})}),r("td",{css:[F.td,F.meta,"",""],children:U.type==="folder"?`${U.fileCount||0} files`:U.size?Rp(U.size):"--"})]},U.path)})]})]})})]})]}),ce&&r(Cl,{title:"New Folder",message:"Enter a name for the new folder:",placeholder:"Folder name",confirmLabel:"Create",onConfirm:Me,onCancel:()=>Q(!1)}),H&>&&r(Cl,{title:"Rename Folder",message:"Enter a new name for the folder:",placeholder:kt,defaultValue:kt,confirmLabel:"Rename",onConfirm:$,onCancel:()=>G(!1)}),oe&&mt&&r(Cl,{title:"Rename File",message:"Enter a new name for the file:",placeholder:hn,defaultValue:hn,confirmLabel:"Rename",onConfirm:ue,onCancel:()=>J(!1)}),le&&r(fo,{title:"Delete Items",message:`Are you sure you want to delete ${x.size} item${x.size!==1?"s":""}? This action cannot be undone.`,confirmLabel:"Delete",variant:"danger",onConfirm:at,onCancel:()=>X(!1)}),W&>&&r(C2,{folderPath:gt,onConfirm:kn,onCancel:()=>he(!1)}),ie&&r(al,{title:ee,progress:T,onClose:mn}),me&&r(D2,{onClose:()=>ge(!1),onRefresh:d}),qe&&r(Gr,{title:qe.title,message:qe.message,onClose:()=>S(null)})]})}function T2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function E2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 13h6m-3-3v6m-9 1V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2z"})})}function R2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function L2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function O2(){return r("svg",{css:F.dropIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})})}function ru(){return r("svg",{css:F.folderIcon,fill:"currentColor",viewBox:"0 0 24 24",children:r("path",{d:"M10 4H4a2 2 0 00-2 2v12a2 2 0 002 2h16a2 2 0 002-2V8a2 2 0 00-2-2h-8l-2-2z"})})}function _2(){return r("svg",{css:F.parentIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}function H2(){return r("svg",{css:F.fileIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})}function B2({spinning:i}){return r("svg",{css:[F.btnIcon,i&&F.iconSpin,"",""],fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function U2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}function N2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 10h16M4 14h16M4 18h16"})})}function j2(){return r("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})})}function q2(){return b("svg",{css:F.btnIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}const Y2="36px",At={container:m(ll," display:flex;flex-direction:column;height:100%;background:",s.background,";",""),header:m("display:flex;align-items:center;justify-content:space-between;padding:12px 24px;background:",s.surface,";border-bottom:1px solid ",s.border,";position:relative;",""),titleDropdown:{name:"bjn8wh",styles:"position:relative"},titleButton:m("display:flex;align-items:center;gap:6px;font-size:19px!important;font-weight:600;color:",s.text,";background:transparent;border:none;padding:4px 8px;margin:-4px -8px;border-radius:6px;cursor:pointer;letter-spacing:-0.02em;transition:background 0.15s ease;&:hover{background:",s.surfaceHover,";}",""),titleChevron:m("width:18px;height:18px;color:",s.textSecondary,";transition:transform 0.15s ease;margin-top:2px;stroke-width:2.5;",""),titleChevronOpen:{name:"21xn5r",styles:"transform:rotate(180deg)"},dropdownMenu:m("position:absolute;top:calc(100% + 8px);left:0;background:",s.surface,";border:1px solid ",s.border,";border-radius:8px;box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);padding:4px;z-index:100;",""),dropdownItem:m("display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;background:transparent;border:none;border-radius:6px;white-space:nowrap;position:relative;top:1px;font-size:19px!important;font-weight:600;letter-spacing:-0.02em;color:",s.text,";cursor:pointer;transition:all 0.15s ease;text-align:left;&:hover{background:",s.surfaceHover,";}",""),dropdownItemActive:m("&::after{content:'';display:inline-block;width:8px;height:8px;background:",s.primary,";border-radius:50%;position:relative;top:1px;}",""),headerLeft:{name:"16ur2v6",styles:"display:flex;align-items:center;gap:12px;flex:1;min-width:0"},headerCenter:{name:"1fsejhz",styles:"position:absolute;left:50%;transform:translateX(-50%);display:flex;align-items:center;max-width:50%"},breadcrumbs:m("display:flex;align-items:center;gap:6px;font-size:",N.base,";color:",s.textSecondary,";overflow:hidden;",""),breadcrumbSeparator:m("color:",s.border,";flex-shrink:0;",""),breadcrumbItem:m("color:",s.textSecondary,";text-decoration:none;cursor:pointer;transition:color 0.15s ease;white-space:nowrap;&:hover{color:",s.primary,";}",""),breadcrumbCurrent:m("color:",s.text,";font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",""),headerIconBtn:m("display:flex;align-items:center;justify-content:center;width:32px;height:32px;color:",s.textMuted,";background:transparent;border:none;border-radius:6px;cursor:pointer;transition:all 0.15s ease;&:hover{color:",s.text,";background:",s.surface,";}",""),headerActions:{name:"1yydxi7",styles:"display:flex;align-items:center;gap:8px"},headerBtn:m("height:",Y2,";padding:0 12px;background:",s.surface,";border:1px solid ",s.border,";border-radius:6px;cursor:pointer;transition:all 0.15s ease;display:flex;align-items:center;justify-content:center;&:hover{background-color:",s.surfaceHover,";border-color:",s.borderHover,";}",""),headerIcon:m("width:16px;height:16px;color:",s.textSecondary,";",""),content:{name:"1rtaly3",styles:"flex:1;display:flex;overflow:hidden"},fileBrowser:{name:"upomw9",styles:"flex:1;min-width:0;overflow:auto;padding:20px 24px;display:flex;flex-direction:column"},dropOverlay:m("position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(99, 91, 255, 0.1);border:3px dashed ",s.primary,";border-radius:8px;display:flex;align-items:center;justify-content:center;z-index:50;pointer-events:none;",""),dropMessage:m("display:flex;flex-direction:column;align-items:center;gap:12px;color:",s.primary,";font-size:",N.lg,";font-weight:600;",""),dropIcon:{name:"18jhpep",styles:"width:48px;height:48px"}};function G2({onClose:i,isVisible:c=!0,standaloneMode:f=!1,workspacePath:d,siteUrl:h}){const p=i||(()=>{}),[C,D]=v.useState("public"),[x,y]=v.useState(new Set),[A,z]=v.useState(null),[_,q]=v.useState("grid"),[H,G]=v.useState(null),[oe,J]=v.useState(null),[ce,Q]=v.useState(!1),[le,X]=v.useState(0),[P,te]=v.useState(!1),[ae,j]=v.useState(""),[W,he]=v.useState(null),[me,ge]=v.useState([]),[ie,Oe]=v.useState(!1),[T,Z]=v.useState(()=>{if(typeof window<"u"){const $=window.location.hash.slice(1);if($==="fonts")return"fonts";if($==="media")return"media"}return"media"}),[ee,Ee]=v.useState(!1),qe=v.useRef(null);v.useEffect(()=>{const $=()=>{const ue=window.location.hash.slice(1);ue==="fonts"?Z("fonts"):ue==="media"&&Z("media")};return window.addEventListener("hashchange",$),()=>window.removeEventListener("hashchange",$)},[]);const[S,O]=v.useState("_fonts"),[ne,re]=v.useState(0),we=v.useCallback(()=>{X($=>$+1)},[]),[ze,Ge]=v.useState(null),xt=v.useCallback($=>{Ge({path:$,key:Date.now()})},[]);v.useEffect(()=>{if(H&&me.length>0){const $=me.find(ue=>ue.path===H.path);$&&JSON.stringify($)!==JSON.stringify(H)&&G($)}},[me,H]);const Re=v.useCallback(()=>{te(!0)},[]),Pt=v.useCallback(()=>{te(!1)},[]),Ze=v.useCallback(($,ue)=>{he({title:$,message:ue})},[]),Je=v.useCallback(()=>{he(null)},[]),it=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),Oe(!0)},[]),Ht=v.useCallback($=>{$.preventDefault(),$.stopPropagation(),Oe(!1)},[]),Yt=v.useCallback(async $=>{$.preventDefault(),$.stopPropagation(),Oe(!1);const ue=Array.from($.dataTransfer.files);if(ue.length!==0&&!(C==="public/images"||C.startsWith("public/images/"))){for(const Xe of ue){const at=new FormData;at.append("file",Xe),at.append("path",C);try{await fetch("/api/studio/upload",{method:"POST",body:at})}catch(Be){console.error("Upload error:",Be)}}we()}},[C,we]),tn=v.useCallback(()=>{if(C==="public")return;const $=C.split("/");$.pop(),D($.join("/")||"public"),y(new Set)},[C]),Qt=v.useCallback($=>{D($),y(new Set),G(null)},[]),fn=v.useCallback($=>{y(ue=>{const Xe=new Set(ue);return Xe.has($)?Xe.delete($):Xe.add($),Xe}),z($)},[]),Bt=v.useCallback(($,ue,Xe)=>{const at=Xe.findIndex(yt=>yt.path===$),Be=Xe.findIndex(yt=>yt.path===ue);if(at===-1||Be===-1)return;const Me=Math.min(at,Be),zt=Math.max(at,Be);y(yt=>{const Aa=new Set(yt);for(let ia=Me;ia<=zt;ia++)Aa.add(Xe[ia].path);return Aa}),z(ue)},[]),$e=v.useCallback($=>{y(new Set($.map(ue=>ue.path)))},[]),gt=v.useCallback(()=>{y(new Set)},[]),kt=v.useCallback($=>{G($)},[]),Te=v2({triggerRefresh:we,clearSelection:gt,setFocusedItem:kt,showError:Ze}),mt=v.useCallback($=>{if($.key==="Escape"){const ue=$.target;if(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA")return;H?G(null):f||p()}},[p,H,f]);v.useEffect(()=>(c&&(document.addEventListener("keydown",mt),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",mt),document.body.style.overflow=""}),[mt,c]),v.useEffect(()=>{const $=ue=>{qe.current&&!qe.current.contains(ue.target)&&Ee(!1)};return ee&&document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ee]);const hn=v.useCallback(()=>{Ee($=>!$)},[]),Hn=v.useCallback($=>{Z($),Ee(!1),window.location.hash=$},[]),kn=v.useCallback(()=>{re($=>$+1)},[]),mn={isOpen:!0,openStudio:()=>{},closeStudio:p,toggleStudio:p,currentPath:C,setCurrentPath:Qt,navigateUp:tn,selectedItems:x,toggleSelection:fn,selectRange:Bt,selectAll:$e,clearSelection:gt,lastSelectedPath:A,viewMode:_,setViewMode:q,focusedItem:H,setFocusedItem:G,meta:oe,setMeta:J,isLoading:ce,setIsLoading:Q,refreshKey:le,triggerRefresh:we,editedImageKey:ze,setEditedImageKey:xt,scanRequested:P,triggerScan:Re,clearScanRequest:Pt,searchQuery:ae,setSearchQuery:j,error:W,showError:Ze,clearError:Je,fileItems:me,setFileItems:ge,actionState:Te.actionState,requestDelete:Te.requestDelete,requestMove:Te.requestMove,requestSync:Te.requestSync,requestDownload:Te.requestDownload,requestProcess:Te.requestProcess,setProcessMode:Te.setProcessMode,confirmDelete:Te.confirmDelete,confirmMove:Te.confirmMove,confirmSync:Te.confirmSync,confirmProcess:Te.confirmProcess,cancelAction:Te.cancelAction,closeProgress:Te.closeProgress,stopProcessing:Te.stopProcessing,deleteOrphans:Te.deleteOrphans};return r(Xp.Provider,{value:mn,children:b("div",{css:At.container,children:[b("div",{css:At.header,children:[r("div",{css:At.headerLeft,children:b("div",{css:At.titleDropdown,ref:qe,children:[b("button",{css:At.titleButton,onClick:hn,children:[r("span",{children:"gallop.studio"}),r(J2,{isOpen:ee})]}),ee&&b("div",{css:At.dropdownMenu,children:[r("button",{css:[At.dropdownItem,T==="media"&&At.dropdownItemActive,"",""],onClick:()=>Hn("media"),children:"media & files"}),r("button",{css:[At.dropdownItem,T==="fonts"&&At.dropdownItemActive,"",""],onClick:()=>Hn("fonts"),children:"fonts"})]})]})}),r("div",{css:At.headerCenter,children:r(Q2,{currentPath:C,onNavigate:Qt,projectName:d?d.split("/").pop():void 0})}),b("div",{css:At.headerActions,children:[h&&r("a",{href:h,target:"_blank",rel:"noopener noreferrer",css:At.headerIconBtn,title:`Open ${h}`,children:r(K2,{})}),!f&&r("button",{css:At.headerBtn,onClick:p,"aria-label":"Close Studio",children:r(Z2,{})})]})]}),T==="media"?b(tt,{children:[r(D1,{}),b("div",{css:At.content,onDragOver:it,onDragLeave:Ht,onDrop:Yt,children:[ie&&r("div",{css:At.dropOverlay,children:b("div",{css:At.dropMessage,children:[r("svg",{css:At.dropIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),r("span",{children:"Drop files to upload"})]})}),r("div",{css:At.fileBrowser,children:_==="grid"?r(Z1,{}):r(P1,{})})]}),H&&r(m2,{}),r(b2,{}),Te.actionState.showDeleteConfirm&&r(fo,{title:"Delete Files",message:`Are you sure you want to delete ${Te.actionState.actionPaths.length} item${Te.actionState.actionPaths.length!==1?"s":""}? This action cannot be undone.`,confirmLabel:"Delete",variant:"danger",onConfirm:Te.confirmDelete,onCancel:Te.cancelAction}),Te.actionState.showSyncConfirm&&r(fo,{title:"Push to CDN",message:`Push ${Te.actionState.syncImageCount} image${Te.actionState.syncImageCount!==1?"s":""} to Cloudflare R2?${Te.actionState.syncHasRemote?" Remote images will be downloaded first.":""}${Te.actionState.syncHasLocal?" After pushing, local files will be deleted.":""}`,confirmLabel:"Push",onConfirm:Te.confirmSync,onCancel:Te.cancelAction}),Te.actionState.showProcessConfirm&&r(F2,{imageCount:Te.actionState.actionPaths.length,mode:Te.actionState.processMode,onConfirm:Te.confirmProcess,onCancel:Te.cancelAction}),Te.actionState.showMoveModal&&r(Fp,{selectedItems:new Set(Te.actionState.actionPaths),currentPath:C,onMove:$=>Te.confirmMove($),onCancel:Te.cancelAction}),Te.actionState.showProgress&&r(al,{title:Te.actionState.progressTitle,progress:Te.actionState.progressState,onStop:Te.stopProcessing,onDeleteOrphans:Te.deleteOrphans,onClose:Te.closeProgress})]}):r(A2,{currentPath:S,setCurrentPath:O,refreshKey:ne,triggerRefresh:kn})]})})}var X2={name:"1cm5yut",styles:"display:flex;gap:12px;justify-content:flex-end"},V2={name:"1ca3l8d",styles:"position:fixed;inset:0;background:rgba(0, 0, 0, 0.5);display:flex;align-items:center;justify-content:center;z-index:10000"};function F2({imageCount:i,mode:c,onConfirm:f,onCancel:d}){const h={overlay:V2,container:m("background:",s.surface,";border-radius:12px;padding:24px;max-width:420px;width:90%;box-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.1),0 10px 10px -5px rgba(0, 0, 0, 0.04);",""),title:m("font-size:",N.lg,";font-weight:600;color:",s.text,";margin:0 0 16px;",""),message:m("font-size:",N.base,";color:",s.textSecondary,";margin:0 0 20px;line-height:1.5;",""),actions:X2,cancelBtn:m("padding:10px 20px;border:1px solid ",s.border,";border-radius:8px;background:",s.background,";color:",s.text,";font-size:",N.base,";font-weight:500;cursor:pointer;transition:all 0.15s ease;&:hover{background:",s.surfaceHover,";border-color:",s.borderHover,";}",""),confirmBtn:m("padding:10px 20px;border:none;border-radius:8px;background:",s.primary,";color:white;font-size:",N.base,";font-weight:500;cursor:pointer;transition:all 0.15s ease;&:hover{background:",s.primaryHover,";}",""),confirmBtnDanger:m("background:",s.danger,";&:hover{background:#dc2626;}","")},p=c==="remove",C=p?"Remove Thumbnails":"Generate Thumbnails",D=p?`Remove generated thumbnails for ${i} image${i!==1?"s":""}? Original images will be kept.`:`Generate thumbnails for ${i} image${i!==1?"s":""}?`,x=p?"Remove":"Generate";return r("div",{css:h.overlay,onClick:d,children:b("div",{css:h.container,onClick:y=>y.stopPropagation(),children:[r("h2",{css:h.title,children:C}),r("p",{css:h.message,children:D}),b("div",{css:h.actions,children:[r("button",{css:h.cancelBtn,onClick:d,children:"Cancel"}),r("button",{css:[h.confirmBtn,p&&h.confirmBtnDanger,"",""],onClick:f,children:x})]})]})})}function Q2({currentPath:i,onNavigate:c,projectName:f}){const d=i.split("/").filter(Boolean),h=d.map((p,C)=>({name:C===0&&p==="public"&&f?f:p,path:d.slice(0,C+1).join("/")}));return r("div",{css:At.breadcrumbs,children:h.map((p,C)=>b("span",{style:{display:"flex",alignItems:"center",gap:6},children:[C>0&&r("span",{css:At.breadcrumbSeparator,children:"/"}),C===h.length-1?r("span",{css:At.breadcrumbCurrent,children:p.name}):r("span",{css:At.breadcrumbItem,onClick:()=>c(p.path),children:p.name})]},p.path))})}function K2(){return b("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"12",cy:"12",r:"10"}),r("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),r("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function Z2(){return b("svg",{css:At.headerIcon,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[r("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function J2({isOpen:i}){return r("svg",{css:[At.titleChevron,i&&At.titleChevronOpen,"",""],viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:r("polyline",{points:"6 9 12 15 18 9"})})}const Jp=document.getElementById("root");if(!Jp)throw new Error("Root element not found");const $2=window.__STUDIO_WORKSPACE__||"Unknown",W2=window.__STUDIO_SITE_URL__||"";c1.createRoot(Jp).render(r(v.StrictMode,{children:r("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"#0a0a0a"},children:r(G2,{isVisible:!0,standaloneMode:!0,workspacePath:$2,siteUrl:W2})})}));
|
package/dist/client/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
12
12
|
}
|
|
13
13
|
</style>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CDVj8xVj.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-DfPQBmNf.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|