@aiquants/directory-tree 3.8.1 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entryRendering.d.ts +2 -2
- package/dist/entryRendering.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/entryRendering.tsx +2 -2
package/dist/entryRendering.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext } from './ty
|
|
|
4
4
|
export declare const DEFAULT_ITEM_HEIGHT = 18;
|
|
5
5
|
/** Indentation per depth level in px. / 1 階層あたりのインデント幅 (px)。 FHD環境に最適化されたコンパクト設計 (12px) */
|
|
6
6
|
export declare const INDENT_SIZE = 12;
|
|
7
|
-
/** Standard expand glyph size. / 展開アイコンの標準サイズ (
|
|
8
|
-
export declare const EXPAND_GLYPH_SIZE =
|
|
7
|
+
/** Standard expand glyph size. / 展開アイコンの標準サイズ (8px)。 */
|
|
8
|
+
export declare const EXPAND_GLYPH_SIZE = 8;
|
|
9
9
|
/**
|
|
10
10
|
* TailwindCSS v4 class names for DirectoryTree component.
|
|
11
11
|
* DirectoryTreeコンポーネント用の TailwindCSS v4 クラス名。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entryRendering.d.ts","sourceRoot":"","sources":["../src/entryRendering.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,0BAA0B,EAAE,8BAA8B,EAA6B,MAAM,YAAY,CAAA;AAEvH,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,2FAA2F;AAC3F,eAAO,MAAM,WAAW,KAAK,CAAA;AAC7B,
|
|
1
|
+
{"version":3,"file":"entryRendering.d.ts","sourceRoot":"","sources":["../src/entryRendering.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,0BAA0B,EAAE,8BAA8B,EAA6B,MAAM,YAAY,CAAA;AAEvH,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,2FAA2F;AAC3F,eAAO,MAAM,WAAW,KAAK,CAAA;AAC7B,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;CA8BhC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,MAMnD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC3B,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,OAAO,CAAA;IACxB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,oFAAoF,gBAAgB,KAAG,SAQxI,CAAA;AA8BD;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GAAI,WAAW,MAAM,EAAE,YAAY,MAAM,EAAE,WAAW,MAAM,KAAG,SA4GvG,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,8BAA8B,EAAE,YAAY,0BAA0B,KAAG,SAa9G,CAAA;AAmBD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAW5G,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,F,x,Y,x),P[x+F]=!0)}if(x=null,M!==void 0&&(s(M),x=""+M),u(h)&&(s(h.key),x=""+h.key),"key"in h){M={};for(var W in h)W!=="key"&&(M[W]=h[W])}else M=h;return x&&f(M,typeof a=="function"?a.displayName||a.name||"Unknown":a),v(a,x,M,r(),ne,oe)}function p(a){w(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===Q&&(a._payload.status==="fulfilled"?w(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function w(a){return typeof a=="object"&&a!==null&&a.$$typeof===I}var k=l,I=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),E=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),q=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,N=Array.isArray,G=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(a){return a()}};var z,V={},le=k.react_stack_bottom_frame.bind(k,i)(),ie=G(n(i)),P={};je.Fragment=b,je.jsx=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!1,F?Error("react-stack-top-frame"):le,F?G(n(a)):ie)},je.jsxs=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!0,F?Error("react-stack-top-frame"):le,F?G(n(a)):ie)}})()),je}var At;function lr(){return At||(At=1,process.env.NODE_ENV==="production"?We.exports=ar():We.exports=or()),We.exports}var c=lr();function ir({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const cr=ae.forwardRef(ir);function ur({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const dr=ae.forwardRef(ur);function fr({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const mr=ae.forwardRef(fr),Be=18,ze=12,Ft=10,O={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:A.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},we=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},$t=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:n,expandIconSize:r})=>{const i=r?{width:r,height:r}:void 0,u=r?"":"h-4 w-4";return!(s&&e)||n?c.jsx("span",{className:u,style:i,"aria-hidden":"true"}):t?c.jsx(cr,{className:u,style:i}):c.jsx(dr,{className:u,style:i})},tt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(r=>tt(r,t)).filter(Boolean);return n.length?n:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},hr=(e,t,s)=>{const n=(t||(s?we(s):"")).toLowerCase(),r=(e||"").toLowerCase();if(r&&r!=="application/octet-stream"){if(r==="text/markdown"||r==="text/x-markdown")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="application/pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(r.includes("excel")||r.includes("spreadsheet")||r.includes("google-apps.spreadsheet"))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r==="text/csv"||r==="text/tab-separated-values")return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r.includes("word")||r.includes("msword")||r.includes("wordprocessingml")||r.includes("google-apps.document")||r==="application/rtf")return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(r.includes("powerpoint")||r.includes("presentation")||r.includes("google-apps.presentation"))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(r.startsWith("image/"))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(r.startsWith("audio/"))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(r.startsWith("video/"))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(r.includes("zip")||r.includes("tar")||r.includes("compressed")||r.includes("archive"))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(r==="application/json"||r.includes("javascript")||r.includes("typescript")||r.includes("xml")||r.startsWith("text/html")||r.startsWith("text/css")||r.includes("x-python")||r.includes("x-sh")||r.includes("x-go")||r.includes("x-rust"))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(r.startsWith("text/"))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(n))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"].includes(n))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return c.jsx(D.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Ht=(e,t)=>{const{entry:s,isDirectory:n,isExpanded:r,extension:i,mimeType:u}=e;let f;const C=u||s.mimeType;return s.icon!==void 0?f=s.icon:n?f=r&&t?.directoryExpanded||t?.directory||c.jsx(mr,{className:"h-4 w-4"}):i&&t?.fileByExtension?.[i]?f=t.fileByExtension[i]:f=t?.file||hr(C,i,s.name),tt(typeof f=="function"?f(e):f,s.absolutePath)},pr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,n])=>[`data-${pr(s)}`,String(n)]))},yr=500,Bt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:n,selectionMode:r,onSelectionChange:i,onEntryClick:u,toggleDirectory:f,onToggleDirectoryRecursive:C})=>{const v=l.useRef(null);return l.useEffect(()=>()=>{v.current&&window.clearTimeout(v.current)},[]),l.useCallback(d=>{d.stopPropagation(),r!=="none"&&!t&&i&&i(e,!n);let p=!1;u({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{p=!0}}),!(!t||p)&&(v.current?(window.clearTimeout(v.current),v.current=null,C(e)):v.current=window.setTimeout(()=>{f(e.absolutePath),v.current=null},yr))},[t,e,s,C,f,u,r,i,n])},zt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Dt=(e,t)=>e.children!==void 0&&t(e.absolutePath),Yt=(e,t)=>({width:e,gridTemplateColumns:t}),Gt=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:n,rowIndex:r,isSelectedForAria:i,rowHeight:u,isDirOpen:f,columns:C,numericTemplate:v,numericTotal:d,nameWidth:p,rowClassName:w,selection:{onEntryClick:k,selectedPath:I,mode:m="none",selectedItems:b,onSelectionChange:S},expansion:{toggleDirectory:j,onToggleDirectoryRecursive:R},visual:{iconOverrides:E,showExpandIcons:y=!0,showDirectoryIcons:$=!0,showFileIcons:T=!0,useCanvasExpandIcons:L=!1,expandIconSize:Q,indentSize:ee=ze,highlightStyles:H}})=>{const[q,te]=l.useState(!1),N=e.children!==void 0,G=N&&f(e.absolutePath),z=e.absolutePath===I,V=!N&&!!b?.has(e.absolutePath),le=N?void 0:we(e.name)||we(e.relativePath)||we(e.absolutePath),ie=Bt({entry:e,isDirectory:N,isExpanded:G,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:k,toggleDirectory:j,onToggleDirectoryRecursive:R}),P=q?H?.hoverClassName!==void 0?H.hoverClassName:O.entryHover:"",a=(()=>{if(N){if(z)return H?.directorySelectedClassName!==void 0?H.directorySelectedClassName:O.entrySelected}else if(z||V)return H?.itemSelectedClassName!==void 0?H.itemSelectedClassName:A.twMerge(z&&O.entrySelected,V&&O.entryItemSelected);return""})(),h=typeof w=="function"?w(e):w,M=A.twMerge("dt-grid-row cursor-pointer select-none",P,a,h,e.className),F=A.twMerge(O.expandIcon,(z||V)&&O.expandIconSelected),ne=A.twMerge(O.typeIcon,(z||V)&&O.typeIconSelected),oe=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&O.nameDirectory,(z||V)&&O.nameSelected),x=$t({isDirectory:N,isExpanded:G,showExpandIcons:y,useCanvasExpandIcons:L,expandIconSize:Q}),Y=(N?$:T)?Ht({entry:e,isDirectory:N,isExpanded:G,isSelected:z,isItemSelected:V,extension:le,mimeType:e.mimeType},E):null,W={indentLevel:t,isDirectory:N,isExpanded:G},[U,...ke]=C,fe=U?.render?U.render(e,W):e.label??e.name,be={...q?H?.hoverStyle:{},...N&&z?H?.directorySelectedStyle:{},...!N&&(z||V)?H?.itemSelectedStyle:{}};return c.jsxs("div",{className:M,style:{height:u,...be,...e.style},role:"row","aria-expanded":N?G:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":n,"aria-rowindex":r,"aria-selected":m==="none"?void 0:i,...Wt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(G):void 0,"data-entry-selected":z?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:ie,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onKeyDown:se=>se.key==="Enter"&&ie(se),tabIndex:0,children:[c.jsxs("div",{className:A.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:p,paddingLeft:Math.max(0,t*ee)},children:[(y||L)&&c.jsx("span",{className:F,children:x}),(N?$:T)&&c.jsx("span",{className:ne,children:Y}),c.jsx("span",{className:oe,children:fe})]}),ke.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(d,v),children:ke.map(se=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(se.align),se.className),role:"gridcell",children:se.render?se.render(e,W):null},se.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Dt(e.entry,e.isDirOpen),n=Dt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Gt.displayName="DirectoryTreeGridRow";const Vt=({kind:e,columns:t,numericTemplate:s,numericTotal:n,nameWidth:r,scrollBarWidth:i,className:u,nameContent:f,renderCell:C})=>{const[,...v]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",p=e==="header"?"dt-grid-header":"dt-grid-footer",w=e==="header"?"columnheader":"gridcell";return c.jsxs("div",{className:A.twMerge(p,"text-gray-600 dark:text-gray-300",u),role:"row",children:[c.jsx("div",{className:A.twMerge(d,"px-1",t[0]?.className),role:w,style:{width:r},children:f}),v.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(n,s),children:v.map(k=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(k.align),k.className),role:w,children:C(k)},k.key))})}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},br=({columns:e,className:t,...s})=>c.jsx(Vt,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...s}),Ot=(e,t)=>typeof e=="function"?e(t):e??null,gr=({columns:e,allEntries:t,className:s,...n})=>c.jsx(Vt,{kind:"footer",columns:e,className:s,nameContent:Ot(e[0]?.footer,t),renderCell:r=>Ot(r.footer,t),...n}),xr=240,Ut=96,Xt=12,rt=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},vr=e=>e.slice(1).map(t=>`${rt(t,Ut)}px`).join(" "),wr=({measuredWidth:e,columns:t,scrollBarWidth:s=Xt})=>{const n=rt(t[0],xr),r=t.slice(1).reduce((C,v)=>C+rt(v,Ut),0),i=Number.isFinite(e)&&e>0?e:0,u=Math.max(0,i-n-Math.max(0,s)),f=Math.max(0,r-u);return{nameWidth:n,numericTotal:r,numericVisible:u,maxHScroll:f}},et=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,kr=e=>{const t=[],s=n=>{for(const r of n)t.push(r),r.children&&r.children.length>0&&s(r.children)};return s(e),t},Sr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Er=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const n=Sr(t,s),r=e[n];return r?{path:r.entry.absolutePath,offsetInViewport:s-t[n]}:null},Nr=(e,t,s)=>{if(t.length===0||s.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,s[n]+e.offsetInViewport);return null},Ir=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Rr=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Cr=(e,t,s,n)=>{const r=Math.max(1,Math.floor(t*n)),i=Math.max(1,Math.floor(s*n));(e.width!==r||e.height!==i)&&(e.width=r,e.height=i);const u=e.style;u.width!==`${t}px`&&(u.width=`${t}px`),u.height!==`${s}px`&&(u.height=`${s}px`)},jr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Mr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let n=s[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),u=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${u}, ${t})`},Tr=(e,t,s,n)=>{if(t.length===0)return;const r=Mr(s,.14),i=e.strokeStyle,u=e.fillStyle,f=e.lineWidth,C=e.lineCap,v=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const p=n??d.size,w=Math.max(0,p/2),k=Math.max(1,Math.round(p*.08)),I=Math.max(1,Math.round(p*.14)),m=Math.max(0,w-k*.8),b=Math.max(0,m*.55);r&&(e.fillStyle=r,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=k,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,w-k*.3),0,Math.PI*2),e.stroke(),e.lineWidth=I,e.beginPath(),e.moveTo(d.centerX-b,d.centerY),e.lineTo(d.centerX+b,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-b),e.lineTo(d.centerX,d.centerY+b),e.stroke())}e.strokeStyle=i,e.fillStyle=u,e.lineWidth=f,e.lineCap=C,e.lineJoin=v},Jt=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u="#a0aec0",strokeWidth:f=1,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k})=>{const I=l.useRef(null),m=l.useRef(null),b=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k}),S=l.useCallback(()=>{m.current=null;const R=I.current;if(!R)return;const E=R.getContext("2d");if(!E)return;const y=b.current;if(y.width<=0||y.viewportHeight<=0){E.clearRect(0,0,R.width,R.height);return}const $=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Cr(R,y.width,y.viewportHeight,$);const T=y.segmentsByItem.length,L=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),Q=Math.min(T,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ee=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const N=Math.floor(y.renderEndIndex);return Math.max(Math.min(T,N+1),L)}return Math.max(Q,L)})(),H=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const N=Math.floor(y.lookaheadEndIndex),G=Math.min(T,N+1);return Math.max(G,ee)}return Math.max(Q,ee)})(),q=Ir(y.segmentsByItem,L,H),te=Rr(y.glyphsByItem,L,H);E.save(),E.scale($,$),E.clearRect(0,0,y.width,y.viewportHeight),E.translate(0,-y.scrollPosition),E.strokeStyle=y.color,jr(E,q,y.strokeWidth),Tr(E,te,y.expandGlyphColor??y.color,y.expandGlyphSize),E.restore()},[]),j=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{b.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k},j()},[e,t,s,n,r,i,u,f,C,v,d,p,w,k,j]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),c.jsx("canvas",{ref:I,className:"pointer-events-none absolute top-0 left-0 z-0"})});Jt.displayName="TreeLineCanvas";const Pr={msOverflowStyle:"none",scrollbarWidth:"none"},_r=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},Ar=(e,t,s,n,r)=>{const i=[],u=[];let f=0;const C=(v,d,p)=>{const w=r?[...v].sort(r):v;for(let k=0;k<w.length;k++){const I=w[k],m=k===w.length-1,b=[...p,m],S=I.children!==void 0,j=S&&t(I.absolutePath,I.relativePath);let R=d,E=b,y=p;n&&(R=d-1,E=b.slice(1),y=p.slice(1)),i.push({entry:I,indentLevel:R,depth:d,positionInSet:k+1,setSize:w.length,parentIsLast:E}),s&&(R>f&&(f=R),u.push({id:I.absolutePath,name:I.name,absolutePath:I.absolutePath,indentLevel:R,isLastChild:m,isDirectory:S,isExpanded:j,ancestorIsLast:[...y],hideLines:n&&d===0})),S&&j&&I.children&&C(I.children,d+1,b)}};return C(e,0,[]),{flatItems:i,lineItems:u,maxIndent:f}},Lt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Fr=(e,t,s,n,r,i)=>{const u=n?.renderStart??Math.max(0,Lt(i,r)),f=t>0?Lt(i,r+t)+s:u+s,C=e>0?Math.min(e-1,Math.max(u,f)):u,v=n?.renderEnd??C,d=e>0?Math.min(e-1,v+s):v;return{renderStart:u,renderEnd:v,lookaheadEnd:d}},Dr=(e,t,s,n,r,i)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const u=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),C=d=>r?typeof i=="number"&&Number.isFinite(i)&&i>0?i:Math.max(8,Math.min(n*.9,d*.7)):0,v=3;for(let d=0;d<e.length;d++){const p=e[d];if(p.hideLines)continue;const w=[],k=t[d]??0,I=s[d]??0,m=I+k/2,b=C(k),S=b>0?b/2+2:n/1.5;for(let E=0;E<p.indentLevel;E++){if(p.ancestorIsLast[E]??!1)continue;let $=!1;for(let T=d;T<e.length;T++){const L=e[T];if(L.indentLevel>E&&L.ancestorIsLast.length>E&&!L.ancestorIsLast[E]){$=!0;break}if(T>d&&L.indentLevel===E)break}if($){const T=E*n+n/2+v;w.push({key:`${p.id}-ancestor-${E}`,x1:T,y1:I,x2:T,y2:I+k,itemIndex:d})}}const j=p.indentLevel*n,R=j+n/2+v;if(p.isDirectory?w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m-S,itemIndex:d}):w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m,itemIndex:d}),!p.isDirectory&&p.isLastChild&&w.push({key:`${p.id}-connector-horizontal`,x1:R,y1:m,x2:j+n+v,y2:m,itemIndex:d}),p.isLastChild||(p.isDirectory?w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m+S,x2:R,y2:I+k,itemIndex:d}):w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m,x2:R,y2:I+k,itemIndex:d})),u[d]=w,r&&p.isDirectory){const E=b,y=R,$=m;f[d]=[{key:`${p.id}-glyph`,itemIndex:d,centerX:y,centerY:$,size:E,isExpanded:p.isExpanded}]}}return{segmentsByItem:u,glyphsByItem:f}},nt=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:n,setSize:r,isSelectedForAria:i,flatIndex:u,isActive:f,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j="none",selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$=!0,showDirectoryIcons:T=!0,showFileIcons:L=!0,useCanvasExpandIcons:Q=!1,expandIconSize:ee,typeIconSize:H,fontSize:q,indentSize:te=ze,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:le,directoryNameClassName:ie,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}})=>{const[M,F]=l.useState(null),[ne,oe]=l.useState(!1),x=e.children!==void 0,Y=x&&p(e.absolutePath),W=e.absolutePath===S,U=!x&&R?.has(e.absolutePath),ke=x?void 0:we(e.name)||we(e.relativePath)||we(e.absolutePath);l.useEffect(()=>{F(Y&&e.children?e.children:null)},[Y,e.children]);const fe=Bt({entry:e,isDirectory:x,isExpanded:Y,isItemSelected:!!U,selectionMode:j,onSelectionChange:E,onEntryClick:b,toggleDirectory:I,onToggleDirectoryRecursive:m}),be=ne?N?.hoverClassName!==void 0?N.hoverClassName:O.entryHover:"",se=(()=>{if(x){if(W)return N?.directorySelectedClassName!==void 0?N.directorySelectedClassName:O.entrySelected}else if(W||U)return N?.itemSelectedClassName!==void 0?N.itemSelectedClassName:A.twMerge(W&&O.entrySelected,U&&O.entryItemSelected);return""})(),Ye=A.twMerge(O.entry,be,se,G,e.className),Se=A.twMerge(O.expandIcon,(W||U)&&O.expandIconSelected),Me=A.twMerge(O.typeIcon,(W||U)&&O.typeIconSelected),Te=A.twMerge(O.name,V,x&&O.nameDirectory,x&&ie,!x&&a,(W||U)&&O.nameSelected),Pe=$t({isDirectory:x,isExpanded:Y,showExpandIcons:$,useCanvasExpandIcons:Q,expandIconSize:ee}),_e=(x?T:L)?Ht({entry:e,isDirectory:x,isExpanded:Y,isSelected:W,isItemSelected:!!U,extension:ke,mimeType:e.mimeType},y):null,Ae={...ne?N?.hoverStyle:{},...x&&W?N?.directorySelectedStyle:{},...!x&&(W||U)?N?.itemSelectedStyle:{}},me=Wt(e.data),Fe=H?{width:H,height:H}:void 0,Ie=q?{fontSize:typeof q=="number"?`${q}px`:q}:void 0;return c.jsxs(l.Fragment,{children:[c.jsxs("div",{className:Ye,style:{paddingLeft:`${Math.max(0,t*te)}px`,transform:t<0?`translateX(${t*te}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*te)}px)`:void 0,height:`${d}px`,...Ie,...Ae,...z,...e.style},...me,"data-entry-type":x?"directory":"file","data-entry-expanded":x?String(Y):void 0,"data-entry-selected":W?"true":void 0,"data-entry-item-selected":U?"true":void 0,onClick:fe,onMouseEnter:()=>oe(!0),onMouseLeave:()=>oe(!1),ref:re=>C(u,re),onKeyDown:re=>{if(re.key==="Enter"||re.key===" "){re.preventDefault(),fe(re);return}v(re,u)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":x?Y:void 0,"aria-level":s+1,"aria-posinset":n,"aria-setsize":r,"aria-selected":j==="none"?void 0:i,"aria-label":`${e.name} (${x?"directory":"file"})`,children:[($||Q)&&c.jsx("span",{className:Se,children:Pe}),(x?T:L)&&c.jsx("span",{className:Me,style:Fe,children:_e}),c.jsx("span",{className:Te,style:{...Ie,...le,...x?P:h},"data-entry-type":x?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),Y&&M&&k&&c.jsx("fieldset",{children:M.map((re,Re)=>c.jsx(nt,{entry:re,indentLevel:t+1,depth:s+1,positionInSet:Re+1,setSize:M.length,isSelectedForAria:!!R?.has(re.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:[...w,Re===M.length-1],expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$,showDirectoryIcons:T,showFileIcons:L,useCanvasExpandIcons:Q,expandIconSize:ee,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:le,directoryNameClassName:ie,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}},re.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,n=t.entry.children!==void 0,r=s&&e.isDirOpen(e.entry.absolutePath),i=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&r===i&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((u,f)=>u===t.parentIsLast[f])});nt.displayName="DirectoryEntryItem";const qt=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...qt(s)));return t},Or=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:n,collapseMultiple:r,isPending:i,alwaysExpanded:u=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:C,selectedPath:v,mode:d="none",selectedItems:p,onSelectionChange:w},visual:{className:k,style:I,ariaLabel:m,ariaLabelledBy:b,lineColor:S="#A0AEC0",showTreeLines:j=!0,showExpandIcons:R=!0,showDirectoryIcons:E=!0,showFileIcons:y=!0,iconOverrides:$,expandIconSize:T,itemHeight:L=Be,removeRootIndent:Q=!1,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:le}={},virtualScroll:ie,grid:P,sort:a})=>{const h=P!==void 0,[M,F]=l.useState(!1),ne=l.useRef(null),oe=l.useRef(null),x=l.useRef(null),[Y,W]=l.useState(0),[U,ke]=l.useState(0),[fe,be]=l.useState(0),[se,Ye]=l.useState(null),{overscanCount:Se=15,className:Me,background:Te,onScroll:Pe,onRangeChange:_e,initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,callbackThrottleMs:Ie=5,contentInsets:re,onItemFocus:Re,viewportHeightOverride:ce,scrollBarOptions:Ge,behaviorOptions:st,preserveScrollAnchor:at=!1,getItemKey:Zt,testId:ot,contentProps:Ve}=ie??{},lt=l.useMemo(()=>h?{role:"rowgroup",...Ve}:Ve,[h,Ve]),[De,it]=l.useState(typeof me=="number"?me:0),Ue=l.useRef(typeof me=="number"?me:0),ct=l.useCallback((o,g)=>{Ue.current=o,it(o),Pe?.(o,g)},[Pe]),ut=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:_}=o;Ye(B=>B&&B.renderStart===g&&B.renderEnd===_?B:{renderStart:g,renderEnd:_}),_e?.(o)},[_e]);l.useEffect(()=>{F(!0),_r()},[]),l.useEffect(()=>{const o=ne.current,g=h?oe.current:o,_=()=>{if(o){const X=o.clientWidth;ke(Z=>Math.abs(Z-X)>1?X:Z)}if(typeof ce=="number")W(X=>Math.abs(X-ce)>1?ce:X);else if(g){const X=g.clientHeight;W(Z=>Math.abs(Z-X)>1?X:Z)}};if(!(o||g))return W(0);_();const B=new ResizeObserver(_);return o&&B.observe(o),g&&g!==o&&B.observe(g),()=>B.disconnect()},[ce,h]);const he=typeof ce=="number"?ce:Y,ue=l.useCallback(o=>u||(M?s(o):!1),[M,s,u]),dt=A.twMerge(O.container,i&&O.containerPending,k),ft=l.useMemo(()=>({...Pr,...I??{},...typeof ce=="number"?{height:ce,minHeight:ce}:{}}),[I,ce]),Xe=l.useCallback((o,g)=>{const _=[o.absolutePath,...qt(o)],B=g||f;if(_.every(de=>ue(de)))return r(_);if(_.every(de=>!ue(de))||B==="recursive")return n(_);if(B==="toggle")return r(_);console.warn(`[DirectoryTree] Unknown double click action: ${B}. No action taken.`)},[ue,n,r,f]),mt=h?!1:Q,{flatItems:ge,lineItems:Je,maxIndent:ht}=l.useMemo(()=>Ar(e,ue,j,mt,a),[e,ue,j,mt,a]),J=l.useMemo(()=>ge.map((o,g)=>{const _=typeof L=="function"?L(o.entry,g):L;return{...o,rowHeight:Number.isFinite(_)&&_>0?_:Be}}),[ge,L]),pe=l.useMemo(()=>J.map(o=>o.rowHeight),[J]),xe=l.useMemo(()=>{const o=new Array(pe.length+1);o[0]=0;for(let g=0;g<pe.length;g++)o[g+1]=o[g]+pe[g];return o},[pe]),pt=l.useCallback(o=>J[o]?.rowHeight??Be,[J]),Kt=l.useCallback(o=>J[o]?.entry.absolutePath??o,[J]),yt=Zt??Kt,bt=l.useRef(ge);bt.current=ge;const gt=l.useRef(ue);gt.current=ue;const qe=l.useRef(t);qe.current=t;const[xt,vt]=l.useState(0),Ze=l.useRef(new Map),Ke=l.useRef(null),wt=l.useCallback((o,g)=>{g?(Ze.current.set(o,g),Ke.current===o&&(Ke.current=null,g.focus())):Ze.current.delete(o)},[]),ve=l.useCallback(o=>{vt(o);const g=Ze.current.get(o);if(g){g.focus();return}Ke.current=o,x.current?.scrollToIndex(o)},[]);l.useEffect(()=>{vt(o=>ge.length===0?0:Math.min(o,ge.length-1))},[ge.length]);const kt=l.useCallback((o,g)=>{const _=bt.current,B=_.length-1;if(B<0)return;const X=_[g],Z=X?.entry.children!==void 0,de=Z&>.current(X.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),ve(Math.min(g+1,B));break;case"ArrowUp":o.preventDefault(),ve(Math.max(g-1,0));break;case"Home":o.preventDefault(),ve(0);break;case"End":o.preventDefault(),ve(B);break;case"ArrowRight":o.preventDefault(),Z&&!de?qe.current(X.entry.absolutePath):Z&&g<B&&ve(g+1);break;case"ArrowLeft":{if(o.preventDefault(),Z&&de){qe.current(X.entry.absolutePath);break}const nr=X?.depth??0;for(let He=g-1;He>=0;He--)if(_[He].depth<nr){ve(He);break}break}}},[ve]),Oe=l.useMemo(()=>!j||Je.length===0?{segmentsByItem:[],glyphsByItem:[]}:Dr(Je,pe,xe,ze,j,T??Ft),[Je,pe,xe,j,T]),Le=l.useMemo(()=>!j||e.length===0?0:(ht+2)*ze,[e.length,ht,j]),{renderStart:St,renderEnd:Et,lookaheadEnd:Nt}=l.useMemo(()=>Fr(J.length,he,Se,se,De,xe),[J.length,he,Se,se,De,xe]),Qe=l.useMemo(()=>!j||Le<=0||he<=0||Oe.segmentsByItem.length===0?null:c.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:c.jsx("div",{className:"absolute top-0 left-0",style:{width:Le,height:he},children:c.jsx(Jt,{segmentsByItem:Oe.segmentsByItem,glyphsByItem:Oe.glyphsByItem,itemHeight:pe[0]??Be,width:Le,viewportHeight:he,scrollPosition:De,color:S,expandGlyphColor:S,expandGlyphSize:T??Ft,renderStartIndex:St,renderEndIndex:Et,lookaheadEndIndex:Nt})})}),[Le,he,St,Et,Nt,De,Oe,S,j,T,pe]),It=l.useCallback(o=>J[o],[J]),Rt=l.useRef(null);l.useLayoutEffect(()=>{const o=Rt.current;if(Rt.current={items:J,offsets:xe},!at||!o||o.items===J)return;const g=x.current,_=g?.getScrollPosition(),B=typeof _=="number"&&_>=0?_:Ue.current,X=Er(o.items,o.offsets,B);if(!X)return;const Z=Nr(X,J,xe);if(Z===null||Math.abs(Z-B)<1)return;const de=g?g.scrollTo(Z):Z;Ue.current=de,it(de)},[J,xe,at]);const ye=P?.columns,Ee=P?.scrollBarWidth??Ge?.width??Xt,K=l.useMemo(()=>ye?wr({measuredWidth:U,columns:ye,scrollBarWidth:Ee}):null,[ye,U,Ee]),$e=l.useMemo(()=>ye?vr(ye):"",[ye]),Qt=l.useMemo(()=>P?.showFooter&&ye?kr(e):[],[P?.showFooter,ye,e]),Ne=K?.maxHScroll??0;l.useEffect(()=>{be(o=>et(o,Ne))},[Ne]);const Ct=l.useCallback(o=>be(g=>et(g+o,Ne)),[Ne]),jt=l.useMemo(()=>({iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee}),[$,R,E,y,j,T,ee]),Mt=l.useMemo(()=>c.jsx(Tt.VirtualScroll,{ref:x,itemCount:J.length,getItem:It,getItemHeight:pt,getItemKey:yt,testId:ot,contentProps:lt,viewportSize:he,overscanCount:Se,onScroll:ct,onRangeChange:ut,className:Me,onWheelHorizontal:h?Ct:void 0,background:c.jsxs(c.Fragment,{children:[h&&K?c.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:K.nameWidth},"aria-hidden":"true",children:Qe}):Qe,Te]}),initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,onItemFocus:Re,callbackThrottleMs:Ie,contentInsets:re,scrollBarOptions:Ge,behaviorOptions:st,children:(o,g)=>o?h&&P&&K?c.jsx(Gt,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!p?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:ue,columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},visual:jt},o.entry.absolutePath):c.jsx(nt,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!p?.has(o.entry.absolutePath),flatIndex:g,isActive:g===xt,registerRowRef:wt,onNavigationKeyDown:kt,rowHeight:o.rowHeight,isDirOpen:ue,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},visual:{iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:le}},o.entry.absolutePath):null}),[J.length,It,pt,yt,ot,lt,xt,wt,kt,he,Se,ct,ut,Me,h,Ct,K,Qe,Te,Ae,me,Fe,Re,Ie,re,Ge,st,P,$e,ue,C,v,d,p,w,t,Xe,jt,$,R,E,y,j,T,ee,H,q,te,N,G,z,V,le]);if(!(P&&K))return c.jsx("div",{ref:ne,className:dt,style:ft,role:"tree","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,children:Mt});const er=P.showHeader??!0,tr=P.showFooter??!1,rr={...ft,"--dt-hscroll":`${fe}px`};return c.jsxs("div",{ref:ne,className:A.twMerge(dt,"dt-grid"),style:rr,role:"treegrid","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":J.length+(P.showHeader??!0?1:0),children:[er&&c.jsx("div",{role:"rowgroup",children:c.jsx(br,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,className:P.headerClassName})}),c.jsx("div",{ref:oe,className:"dt-grid-body",children:Mt}),Ne>0&&c.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:K.nameWidth},"aria-hidden":"true"}),c.jsx(Tt.ScrollBar,{horizontal:!0,contentSize:K.numericTotal,viewportSize:K.numericVisible,scrollPosition:fe,scrollBarWidth:Ee,onScroll:o=>{const g=typeof o=="function"?o(fe):o,_=et(g,Ne);return be(_),_}}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Ee},"aria-hidden":"true"})]}),tr&&c.jsx("div",{role:"rowgroup",children:c.jsx(gr,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,allEntries:Qt,className:P.footerClassName})})]})},Lr=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,n]=l.useTransition(),[r,i]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const b=JSON.parse(m);return new Set(b)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),u=l.useCallback(m=>{n(()=>{i(b=>{const S=new Set(b);return m(S),S})})},[]),f=l.useCallback((m,b)=>{u(S=>{for(const j of m)b(S,j)})},[u]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(r)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[r,t]);const C=l.useCallback(m=>{f([m],(b,S)=>{b.has(S)?b.delete(S):b.add(S)})},[f]),v=l.useCallback(m=>{f([m],(b,S)=>{b.add(S)})},[f]),d=l.useCallback(m=>{f([m],(b,S)=>{b.delete(S)})},[f]),p=l.useCallback(m=>{f(m,(b,S)=>{b.delete(S)})},[f]),w=l.useCallback(m=>{f(m,(b,S)=>{b.add(S)})},[f]),k=l.useCallback(()=>{u(m=>{m.clear()})},[u]),I=l.useCallback(m=>r.has(m),[r]);return{expanded:r,toggle:C,expand:v,collapse:d,collapseMultiple:p,expandMultiple:w,collapseAll:k,isExpanded:I,isPending:s}};exports.DirectoryTree=Or;exports.directoryTreeClasses=O;exports.useDirectoryTreeState=Lr;
|
|
6
|
+
<%s key={someKey} {...props} />`,F,x,Y,x),P[x+F]=!0)}if(x=null,M!==void 0&&(s(M),x=""+M),u(h)&&(s(h.key),x=""+h.key),"key"in h){M={};for(var W in h)W!=="key"&&(M[W]=h[W])}else M=h;return x&&f(M,typeof a=="function"?a.displayName||a.name||"Unknown":a),v(a,x,M,r(),ne,oe)}function p(a){w(a)?a._store&&(a._store.validated=1):typeof a=="object"&&a!==null&&a.$$typeof===Q&&(a._payload.status==="fulfilled"?w(a._payload.value)&&a._payload.value._store&&(a._payload.value._store.validated=1):a._store&&(a._store.validated=1))}function w(a){return typeof a=="object"&&a!==null&&a.$$typeof===I}var k=l,I=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),S=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),E=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),Q=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),q=k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,N=Array.isArray,G=console.createTask?console.createTask:function(){return null};k={react_stack_bottom_frame:function(a){return a()}};var z,V={},le=k.react_stack_bottom_frame.bind(k,i)(),ie=G(n(i)),P={};je.Fragment=b,je.jsx=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!1,F?Error("react-stack-top-frame"):le,F?G(n(a)):ie)},je.jsxs=function(a,h,M){var F=1e4>q.recentlyCreatedOwnerStacks++;return d(a,h,M,!0,F?Error("react-stack-top-frame"):le,F?G(n(a)):ie)}})()),je}var At;function lr(){return At||(At=1,process.env.NODE_ENV==="production"?We.exports=ar():We.exports=or()),We.exports}var c=lr();function ir({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M12.53 16.28a.75.75 0 0 1-1.06 0l-7.5-7.5a.75.75 0 0 1 1.06-1.06L12 14.69l6.97-6.97a.75.75 0 1 1 1.06 1.06l-7.5 7.5Z",clipRule:"evenodd"}))}const cr=ae.forwardRef(ir);function ur({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{fillRule:"evenodd",d:"M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z",clipRule:"evenodd"}))}const dr=ae.forwardRef(ur);function fr({title:e,titleId:t,...s},n){return ae.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":t},s),e?ae.createElement("title",{id:t},e):null,ae.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const mr=ae.forwardRef(fr),Be=18,ze=12,Ft=8,O={container:"directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",containerPending:"opacity-70",entry:"directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",entryHover:A.twMerge("directory-tree-entry--hover hover:bg-gray-400/15","dark:hover:bg-gray-200/10"),entrySelected:A.twMerge("directory-tree-entry--selected bg-blue-400/10","dark:bg-blue-400/15"),entryItemSelected:A.twMerge("directory-tree-entry--item-selected bg-blue-400/20 shadow-[0_0_0_1px_rgba(59,130,246,0.3)]","dark:bg-blue-400/25 dark:shadow-[0_0_0_1px_rgba(96,165,250,0.4)]"),expandIcon:A.twMerge("directory-tree-expand-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),expandIconSelected:A.twMerge("directory-tree-expand-icon--selected text-blue-700","dark:text-blue-400"),typeIcon:A.twMerge("directory-tree-type-icon w-3.5 h-3.5 flex-shrink-0 flex items-center justify-center","text-gray-500","dark:text-gray-400"),typeIconSelected:A.twMerge("directory-tree-type-icon--selected text-blue-700","dark:text-blue-400"),name:A.twMerge("directory-tree-name overflow-hidden text-ellipsis whitespace-nowrap ml-1 text-xs font-normal","text-gray-700","dark:text-gray-200"),nameDirectory:"directory-tree-name--directory font-medium",nameSelected:A.twMerge("directory-tree-name--selected text-blue-800 font-semibold","dark:text-blue-300")},we=e=>{if(!e)return"";const t=e.split("?")[0].split("#")[0].split("/").pop()||e,s=t.lastIndexOf(".");return s<=0?"":t.slice(s+1).toLowerCase()},$t=({isDirectory:e,isExpanded:t,showExpandIcons:s,useCanvasExpandIcons:n,expandIconSize:r})=>{const i=r?{width:r,height:r}:void 0,u=r?"":"h-4 w-4";return!(s&&e)||n?c.jsx("span",{className:u,style:i,"aria-hidden":"true"}):t?c.jsx(cr,{className:u,style:i}):c.jsx(dr,{className:u,style:i})},tt=(e,t)=>{if(e==null||typeof e=="boolean")return null;if(typeof e=="function")return console.warn(`[DirectoryTree] Function returned by renderer for "${t}". Return a node.`),null;if(typeof e=="object"){if("then"in e)return console.warn(`[DirectoryTree] Promise returned for "${t}". Not supported.`),null;if(Array.isArray(e)){const n=e.map(r=>tt(r,t)).filter(Boolean);return n.length?n:null}const s=e.type;if(s&&s.$$typeof===Symbol.for("react.lazy"))return console.warn(`[DirectoryTree] Lazy component for "${t}". Not supported.`),null}return e},hr=(e,t,s)=>{const n=(t||(s?we(s):"")).toLowerCase(),r=(e||"").toLowerCase();if(r&&r!=="application/octet-stream"){if(r==="text/markdown"||r==="text/x-markdown")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(r==="application/pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(r.includes("excel")||r.includes("spreadsheet")||r.includes("google-apps.spreadsheet"))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r==="text/csv"||r==="text/tab-separated-values")return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(r.includes("word")||r.includes("msword")||r.includes("wordprocessingml")||r.includes("google-apps.document")||r==="application/rtf")return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(r.includes("powerpoint")||r.includes("presentation")||r.includes("google-apps.presentation"))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(r.startsWith("image/"))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(r.startsWith("audio/"))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(r.startsWith("video/"))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(r.includes("zip")||r.includes("tar")||r.includes("compressed")||r.includes("archive"))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(r==="application/json"||r.includes("javascript")||r.includes("typescript")||r.includes("xml")||r.startsWith("text/html")||r.startsWith("text/css")||r.includes("x-python")||r.includes("x-sh")||r.includes("x-go")||r.includes("x-rust"))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(r.startsWith("text/"))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}if(n){if(n==="md"||n==="markdown"||n==="mdx")return c.jsx(D.FileMd,{className:"h-4 w-4 text-sky-500 dark:text-sky-400"});if(n==="pdf")return c.jsx(D.FilePdf,{className:"h-4 w-4 text-red-500 dark:text-red-400"});if(["xls","xlsx","xlsm","xlsb","ods"].includes(n))return c.jsx(D.FileXls,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["csv","tsv"].includes(n))return c.jsx(D.FileCsv,{className:"h-4 w-4 text-emerald-600 dark:text-emerald-400"});if(["doc","docx","rtf","odt"].includes(n))return c.jsx(D.FileDoc,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"});if(["ppt","pptx","odp"].includes(n))return c.jsx(D.FilePpt,{className:"h-4 w-4 text-orange-500 dark:text-orange-400"});if(["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff","avif"].includes(n))return c.jsx(D.FileImage,{className:"h-4 w-4 text-teal-500 dark:text-teal-400"});if(["js","mjs","cjs","ts","tsx","jsx","json","html","htm","css","scss","py","go","rs","c","cpp","h","hpp","sh","bash","yaml","yml","sql","xml","toml"].includes(n))return c.jsx(D.FileCode,{className:"h-4 w-4 text-purple-500 dark:text-purple-400"});if(["mp3","wav","ogg","m4a","flac","aac","wma"].includes(n))return c.jsx(D.FileAudio,{className:"h-4 w-4 text-pink-500 dark:text-pink-400"});if(["mp4","webm","mov","avi","mkv","wmv","flv"].includes(n))return c.jsx(D.FileVideo,{className:"h-4 w-4 text-violet-500 dark:text-violet-400"});if(["zip","tar","gz","7z","rar","tgz","bz2"].includes(n))return c.jsx(D.FileZip,{className:"h-4 w-4 text-amber-500 dark:text-amber-400"});if(["txt","log"].includes(n))return c.jsx(D.FileText,{className:"h-4 w-4 text-gray-500 dark:text-gray-400"})}return c.jsx(D.FileIcon,{className:"h-4 w-4 text-gray-400 dark:text-gray-400"})},Ht=(e,t)=>{const{entry:s,isDirectory:n,isExpanded:r,extension:i,mimeType:u}=e;let f;const C=u||s.mimeType;return s.icon!==void 0?f=s.icon:n?f=r&&t?.directoryExpanded||t?.directory||c.jsx(mr,{className:"h-4 w-4"}):i&&t?.fileByExtension?.[i]?f=t.fileByExtension[i]:f=t?.file||hr(C,i,s.name),tt(typeof f=="function"?f(e):f,s.absolutePath)},pr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Wt=e=>{if(!e)return;const t=Object.entries(e).filter(([,s])=>s!=null);if(t.length!==0)return Object.fromEntries(t.map(([s,n])=>[`data-${pr(s)}`,String(n)]))},yr=500,Bt=({entry:e,isDirectory:t,isExpanded:s,isItemSelected:n,selectionMode:r,onSelectionChange:i,onEntryClick:u,toggleDirectory:f,onToggleDirectoryRecursive:C})=>{const v=l.useRef(null);return l.useEffect(()=>()=>{v.current&&window.clearTimeout(v.current)},[]),l.useCallback(d=>{d.stopPropagation(),r!=="none"&&!t&&i&&i(e,!n);let p=!1;u({entry:e,isDirectory:t,isExpanded:s,preventDefault:()=>{p=!0}}),!(!t||p)&&(v.current?(window.clearTimeout(v.current),v.current=null,C(e)):v.current=window.setTimeout(()=>{f(e.absolutePath),v.current=null},yr))},[t,e,s,C,f,u,r,i,n])},zt=e=>e==="right"?"dt-grid-cell--right":e==="center"?"dt-grid-cell--center":"",Dt=(e,t)=>e.children!==void 0&&t(e.absolutePath),Yt=(e,t)=>({width:e,gridTemplateColumns:t}),Gt=l.memo(({entry:e,indentLevel:t,positionInSet:s,setSize:n,rowIndex:r,isSelectedForAria:i,rowHeight:u,isDirOpen:f,columns:C,numericTemplate:v,numericTotal:d,nameWidth:p,rowClassName:w,selection:{onEntryClick:k,selectedPath:I,mode:m="none",selectedItems:b,onSelectionChange:S},expansion:{toggleDirectory:j,onToggleDirectoryRecursive:R},visual:{iconOverrides:E,showExpandIcons:y=!0,showDirectoryIcons:$=!0,showFileIcons:T=!0,useCanvasExpandIcons:L=!1,expandIconSize:Q,indentSize:ee=ze,highlightStyles:H}})=>{const[q,te]=l.useState(!1),N=e.children!==void 0,G=N&&f(e.absolutePath),z=e.absolutePath===I,V=!N&&!!b?.has(e.absolutePath),le=N?void 0:we(e.name)||we(e.relativePath)||we(e.absolutePath),ie=Bt({entry:e,isDirectory:N,isExpanded:G,isItemSelected:V,selectionMode:m,onSelectionChange:S,onEntryClick:k,toggleDirectory:j,onToggleDirectoryRecursive:R}),P=q?H?.hoverClassName!==void 0?H.hoverClassName:O.entryHover:"",a=(()=>{if(N){if(z)return H?.directorySelectedClassName!==void 0?H.directorySelectedClassName:O.entrySelected}else if(z||V)return H?.itemSelectedClassName!==void 0?H.itemSelectedClassName:A.twMerge(z&&O.entrySelected,V&&O.entryItemSelected);return""})(),h=typeof w=="function"?w(e):w,M=A.twMerge("dt-grid-row cursor-pointer select-none",P,a,h,e.className),F=A.twMerge(O.expandIcon,(z||V)&&O.expandIconSelected),ne=A.twMerge(O.typeIcon,(z||V)&&O.typeIconSelected),oe=A.twMerge("dt-grid-name-label ml-1","text-gray-700 dark:text-gray-200",N&&O.nameDirectory,(z||V)&&O.nameSelected),x=$t({isDirectory:N,isExpanded:G,showExpandIcons:y,useCanvasExpandIcons:L,expandIconSize:Q}),Y=(N?$:T)?Ht({entry:e,isDirectory:N,isExpanded:G,isSelected:z,isItemSelected:V,extension:le,mimeType:e.mimeType},E):null,W={indentLevel:t,isDirectory:N,isExpanded:G},[U,...ke]=C,fe=U?.render?U.render(e,W):e.label??e.name,be={...q?H?.hoverStyle:{},...N&&z?H?.directorySelectedStyle:{},...!N&&(z||V)?H?.itemSelectedStyle:{}};return c.jsxs("div",{className:M,style:{height:u,...be,...e.style},role:"row","aria-expanded":N?G:void 0,"aria-level":t+1,"aria-posinset":s,"aria-setsize":n,"aria-rowindex":r,"aria-selected":m==="none"?void 0:i,...Wt(e.data),"data-entry-type":N?"directory":"file","data-entry-expanded":N?String(G):void 0,"data-entry-selected":z?"true":void 0,"data-entry-item-selected":V?"true":void 0,onClick:ie,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onKeyDown:se=>se.key==="Enter"&&ie(se),tabIndex:0,children:[c.jsxs("div",{className:A.twMerge("dt-grid-name-cell",U?.className),role:"gridcell",style:{width:p,paddingLeft:Math.max(0,t*ee)},children:[(y||L)&&c.jsx("span",{className:F,children:x}),(N?$:T)&&c.jsx("span",{className:ne,children:Y}),c.jsx("span",{className:oe,children:fe})]}),ke.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(d,v),children:ke.map(se=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(se.align),se.className),role:"gridcell",children:se.render?se.render(e,W):null},se.key))})})]})},(e,t)=>{if(e.entry!==t.entry)return!1;const s=Dt(e.entry,e.isDirOpen),n=Dt(t.entry,t.isDirOpen);return e.indentLevel===t.indentLevel&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.rowIndex===t.rowIndex&&e.isSelectedForAria===t.isSelectedForAria&&e.rowHeight===t.rowHeight&&s===n&&e.columns===t.columns&&e.numericTemplate===t.numericTemplate&&e.numericTotal===t.numericTotal&&e.nameWidth===t.nameWidth&&e.rowClassName===t.rowClassName&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual===t.visual});Gt.displayName="DirectoryTreeGridRow";const Vt=({kind:e,columns:t,numericTemplate:s,numericTotal:n,nameWidth:r,scrollBarWidth:i,className:u,nameContent:f,renderCell:C})=>{const[,...v]=t,d=e==="header"?"dt-grid-name-header":"dt-grid-name-footer",p=e==="header"?"dt-grid-header":"dt-grid-footer",w=e==="header"?"columnheader":"gridcell";return c.jsxs("div",{className:A.twMerge(p,"text-gray-600 dark:text-gray-300",u),role:"row",children:[c.jsx("div",{className:A.twMerge(d,"px-1",t[0]?.className),role:w,style:{width:r},children:f}),v.length>0&&c.jsx("div",{className:"dt-grid-numeric-viewport",children:c.jsx("div",{className:"dt-grid-numeric-track",style:Yt(n,s),children:v.map(k=>c.jsx("div",{className:A.twMerge("dt-grid-cell",zt(k.align),k.className),role:w,children:C(k)},k.key))})}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:i},"aria-hidden":"true"})]})},br=({columns:e,className:t,...s})=>c.jsx(Vt,{kind:"header",columns:e,className:t,nameContent:e[0]?.header??null,renderCell:n=>n.header??null,...s}),Ot=(e,t)=>typeof e=="function"?e(t):e??null,gr=({columns:e,allEntries:t,className:s,...n})=>c.jsx(Vt,{kind:"footer",columns:e,className:s,nameContent:Ot(e[0]?.footer,t),renderCell:r=>Ot(r.footer,t),...n}),xr=240,Ut=96,Xt=12,rt=(e,t)=>{const s=e?.width;return typeof s=="number"&&Number.isFinite(s)&&s>0?s:t},vr=e=>e.slice(1).map(t=>`${rt(t,Ut)}px`).join(" "),wr=({measuredWidth:e,columns:t,scrollBarWidth:s=Xt})=>{const n=rt(t[0],xr),r=t.slice(1).reduce((C,v)=>C+rt(v,Ut),0),i=Number.isFinite(e)&&e>0?e:0,u=Math.max(0,i-n-Math.max(0,s)),f=Math.max(0,r-u);return{nameWidth:n,numericTotal:r,numericVisible:u,maxHScroll:f}},et=(e,t)=>!Number.isFinite(e)||e<0?0:e>t?t:e,kr=e=>{const t=[],s=n=>{for(const r of n)t.push(r),r.children&&r.children.length>0&&s(r.children)};return s(e),t},Sr=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Er=(e,t,s)=>{if(s<=0||e.length===0||t.length!==e.length+1)return null;const n=Sr(t,s),r=e[n];return r?{path:r.entry.absolutePath,offsetInViewport:s-t[n]}:null},Nr=(e,t,s)=>{if(t.length===0||s.length!==t.length+1)return null;for(let n=0;n<t.length;n++)if(t[n].entry.absolutePath===e.path)return Math.max(0,s[n]+e.offsetInViewport);return null},Ir=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Rr=(e,t,s)=>{const n=[];for(let r=t;r<s;r++){const i=e[r];if(!(!i||i.length===0))for(const u of i)n.push(u)}return n},Cr=(e,t,s,n)=>{const r=Math.max(1,Math.floor(t*n)),i=Math.max(1,Math.floor(s*n));(e.width!==r||e.height!==i)&&(e.width=r,e.height=i);const u=e.style;u.width!==`${t}px`&&(u.width=`${t}px`),u.height!==`${s}px`&&(u.height=`${s}px`)},jr=(e,t,s)=>{e.lineWidth=s,e.beginPath();for(const n of t)e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke()},Mr=(e,t)=>{const s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!s)return null;let n=s[1];n.length===3&&(n=n.split("").map(f=>f+f).join(""));const r=Number.parseInt(n.slice(0,2),16),i=Number.parseInt(n.slice(2,4),16),u=Number.parseInt(n.slice(4,6),16);return`rgba(${r}, ${i}, ${u}, ${t})`},Tr=(e,t,s,n)=>{if(t.length===0)return;const r=Mr(s,.14),i=e.strokeStyle,u=e.fillStyle,f=e.lineWidth,C=e.lineCap,v=e.lineJoin;e.strokeStyle=s,e.lineCap="round",e.lineJoin="round";for(const d of t){const p=n??d.size,w=Math.max(0,p/2),k=Math.max(1,Math.round(p*.08)),I=Math.max(1,Math.round(p*.14)),m=Math.max(0,w-k*.8),b=Math.max(0,m*.55);r&&(e.fillStyle=r,e.beginPath(),e.arc(d.centerX,d.centerY,m,0,Math.PI*2),e.fill()),e.lineWidth=k,e.beginPath(),e.arc(d.centerX,d.centerY,Math.max(0,w-k*.3),0,Math.PI*2),e.stroke(),e.lineWidth=I,e.beginPath(),e.moveTo(d.centerX-b,d.centerY),e.lineTo(d.centerX+b,d.centerY),e.stroke(),d.isExpanded||(e.beginPath(),e.moveTo(d.centerX,d.centerY-b),e.lineTo(d.centerX,d.centerY+b),e.stroke())}e.strokeStyle=i,e.fillStyle=u,e.lineWidth=f,e.lineCap=C,e.lineJoin=v},Jt=l.memo(({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u="#a0aec0",strokeWidth:f=1,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k})=>{const I=l.useRef(null),m=l.useRef(null),b=l.useRef({segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k}),S=l.useCallback(()=>{m.current=null;const R=I.current;if(!R)return;const E=R.getContext("2d");if(!E)return;const y=b.current;if(y.width<=0||y.viewportHeight<=0){E.clearRect(0,0,R.width,R.height);return}const $=Number.isFinite(y.devicePixelRatio??NaN)?y.devicePixelRatio:typeof window<"u"&&window.devicePixelRatio||1;Cr(R,y.width,y.viewportHeight,$);const T=y.segmentsByItem.length,L=typeof y.renderStartIndex=="number"&&Number.isFinite(y.renderStartIndex)?Math.max(0,Math.floor(y.renderStartIndex)):Math.max(0,Math.floor(y.scrollPosition/y.itemHeight)),Q=Math.min(T,Math.ceil((y.scrollPosition+y.viewportHeight)/y.itemHeight)),ee=(()=>{if(typeof y.renderEndIndex=="number"&&Number.isFinite(y.renderEndIndex)){const N=Math.floor(y.renderEndIndex);return Math.max(Math.min(T,N+1),L)}return Math.max(Q,L)})(),H=(()=>{if(typeof y.lookaheadEndIndex=="number"&&Number.isFinite(y.lookaheadEndIndex)){const N=Math.floor(y.lookaheadEndIndex),G=Math.min(T,N+1);return Math.max(G,ee)}return Math.max(Q,ee)})(),q=Ir(y.segmentsByItem,L,H),te=Rr(y.glyphsByItem,L,H);E.save(),E.scale($,$),E.clearRect(0,0,y.width,y.viewportHeight),E.translate(0,-y.scrollPosition),E.strokeStyle=y.color,jr(E,q,y.strokeWidth),Tr(E,te,y.expandGlyphColor??y.color,y.expandGlyphSize),E.restore()},[]),j=l.useCallback(()=>{m.current===null&&(m.current=window.requestAnimationFrame(S))},[S]);return l.useEffect(()=>{b.current={segmentsByItem:e,glyphsByItem:t,itemHeight:s,width:n,viewportHeight:r,scrollPosition:i,color:u,strokeWidth:f,renderStartIndex:C,renderEndIndex:v,lookaheadEndIndex:d,devicePixelRatio:p,expandGlyphColor:w,expandGlyphSize:k},j()},[e,t,s,n,r,i,u,f,C,v,d,p,w,k,j]),l.useEffect(()=>()=>{m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null)},[]),c.jsx("canvas",{ref:I,className:"pointer-events-none absolute top-0 left-0 z-0"})});Jt.displayName="TreeLineCanvas";const Pr={msOverflowStyle:"none",scrollbarWidth:"none"},_r=()=>{let e=document.getElementById("directory-tree-webkit-scrollbar-hide");e||(e=document.createElement("style"),e.id="directory-tree-webkit-scrollbar-hide",e.textContent=".directory-tree-container::-webkit-scrollbar { display: none; }",document.head.appendChild(e))},Ar=(e,t,s,n,r)=>{const i=[],u=[];let f=0;const C=(v,d,p)=>{const w=r?[...v].sort(r):v;for(let k=0;k<w.length;k++){const I=w[k],m=k===w.length-1,b=[...p,m],S=I.children!==void 0,j=S&&t(I.absolutePath,I.relativePath);let R=d,E=b,y=p;n&&(R=d-1,E=b.slice(1),y=p.slice(1)),i.push({entry:I,indentLevel:R,depth:d,positionInSet:k+1,setSize:w.length,parentIsLast:E}),s&&(R>f&&(f=R),u.push({id:I.absolutePath,name:I.name,absolutePath:I.absolutePath,indentLevel:R,isLastChild:m,isDirectory:S,isExpanded:j,ancestorIsLast:[...y],hideLines:n&&d===0})),S&&j&&I.children&&C(I.children,d+1,b)}};return C(e,0,[]),{flatItems:i,lineItems:u,maxIndent:f}},Lt=(e,t)=>{const s=e.length-1;if(s<=0)return 0;let n=0,r=s-1,i=0;for(;n<=r;){const u=n+r>>>1;e[u]<=t?(i=u,n=u+1):r=u-1}return i},Fr=(e,t,s,n,r,i)=>{const u=n?.renderStart??Math.max(0,Lt(i,r)),f=t>0?Lt(i,r+t)+s:u+s,C=e>0?Math.min(e-1,Math.max(u,f)):u,v=n?.renderEnd??C,d=e>0?Math.min(e-1,v+s):v;return{renderStart:u,renderEnd:v,lookaheadEnd:d}},Dr=(e,t,s,n,r,i)=>{if(e.length===0)return{segmentsByItem:[],glyphsByItem:[]};const u=Array.from({length:e.length},()=>[]),f=Array.from({length:e.length},()=>[]),C=d=>r?typeof i=="number"&&Number.isFinite(i)&&i>0?i:Math.max(8,Math.min(n*.9,d*.7)):0,v=3;for(let d=0;d<e.length;d++){const p=e[d];if(p.hideLines)continue;const w=[],k=t[d]??0,I=s[d]??0,m=I+k/2,b=C(k),S=b>0?b/2+2:n/1.5;for(let E=0;E<p.indentLevel;E++){if(p.ancestorIsLast[E]??!1)continue;let $=!1;for(let T=d;T<e.length;T++){const L=e[T];if(L.indentLevel>E&&L.ancestorIsLast.length>E&&!L.ancestorIsLast[E]){$=!0;break}if(T>d&&L.indentLevel===E)break}if($){const T=E*n+n/2+v;w.push({key:`${p.id}-ancestor-${E}`,x1:T,y1:I,x2:T,y2:I+k,itemIndex:d})}}const j=p.indentLevel*n,R=j+n/2+v;if(p.isDirectory?w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m-S,itemIndex:d}):w.push({key:`${p.id}-connector-top`,x1:R,y1:I,x2:R,y2:m,itemIndex:d}),!p.isDirectory&&p.isLastChild&&w.push({key:`${p.id}-connector-horizontal`,x1:R,y1:m,x2:j+n+v,y2:m,itemIndex:d}),p.isLastChild||(p.isDirectory?w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m+S,x2:R,y2:I+k,itemIndex:d}):w.push({key:`${p.id}-connector-bottom`,x1:R,y1:m,x2:R,y2:I+k,itemIndex:d})),u[d]=w,r&&p.isDirectory){const E=b,y=R,$=m;f[d]=[{key:`${p.id}-glyph`,itemIndex:d,centerX:y,centerY:$,size:E,isExpanded:p.isExpanded}]}}return{segmentsByItem:u,glyphsByItem:f}},nt=l.memo(({entry:e,indentLevel:t,depth:s,positionInSet:n,setSize:r,isSelectedForAria:i,flatIndex:u,isActive:f,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:w,renderChildren:k=!0,expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j="none",selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$=!0,showDirectoryIcons:T=!0,showFileIcons:L=!0,useCanvasExpandIcons:Q=!1,expandIconSize:ee,typeIconSize:H,fontSize:q,indentSize:te=ze,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:le,directoryNameClassName:ie,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}})=>{const[M,F]=l.useState(null),[ne,oe]=l.useState(!1),x=e.children!==void 0,Y=x&&p(e.absolutePath),W=e.absolutePath===S,U=!x&&R?.has(e.absolutePath),ke=x?void 0:we(e.name)||we(e.relativePath)||we(e.absolutePath);l.useEffect(()=>{F(Y&&e.children?e.children:null)},[Y,e.children]);const fe=Bt({entry:e,isDirectory:x,isExpanded:Y,isItemSelected:!!U,selectionMode:j,onSelectionChange:E,onEntryClick:b,toggleDirectory:I,onToggleDirectoryRecursive:m}),be=ne?N?.hoverClassName!==void 0?N.hoverClassName:O.entryHover:"",se=(()=>{if(x){if(W)return N?.directorySelectedClassName!==void 0?N.directorySelectedClassName:O.entrySelected}else if(W||U)return N?.itemSelectedClassName!==void 0?N.itemSelectedClassName:A.twMerge(W&&O.entrySelected,U&&O.entryItemSelected);return""})(),Ye=A.twMerge(O.entry,be,se,G,e.className),Se=A.twMerge(O.expandIcon,(W||U)&&O.expandIconSelected),Me=A.twMerge(O.typeIcon,(W||U)&&O.typeIconSelected),Te=A.twMerge(O.name,V,x&&O.nameDirectory,x&&ie,!x&&a,(W||U)&&O.nameSelected),Pe=$t({isDirectory:x,isExpanded:Y,showExpandIcons:$,useCanvasExpandIcons:Q,expandIconSize:ee}),_e=(x?T:L)?Ht({entry:e,isDirectory:x,isExpanded:Y,isSelected:W,isItemSelected:!!U,extension:ke,mimeType:e.mimeType},y):null,Ae={...ne?N?.hoverStyle:{},...x&&W?N?.directorySelectedStyle:{},...!x&&(W||U)?N?.itemSelectedStyle:{}},me=Wt(e.data),Fe=H?{width:H,height:H}:void 0,Ie=q?{fontSize:typeof q=="number"?`${q}px`:q}:void 0;return c.jsxs(l.Fragment,{children:[c.jsxs("div",{className:Ye,style:{paddingLeft:`${Math.max(0,t*te)}px`,transform:t<0?`translateX(${t*te}px)`:void 0,width:t<0?`calc(100% + ${Math.abs(t*te)}px)`:void 0,height:`${d}px`,...Ie,...Ae,...z,...e.style},...me,"data-entry-type":x?"directory":"file","data-entry-expanded":x?String(Y):void 0,"data-entry-selected":W?"true":void 0,"data-entry-item-selected":U?"true":void 0,onClick:fe,onMouseEnter:()=>oe(!0),onMouseLeave:()=>oe(!1),ref:re=>C(u,re),onKeyDown:re=>{if(re.key==="Enter"||re.key===" "){re.preventDefault(),fe(re);return}v(re,u)},tabIndex:f?0:-1,role:"treeitem","aria-expanded":x?Y:void 0,"aria-level":s+1,"aria-posinset":n,"aria-setsize":r,"aria-selected":j==="none"?void 0:i,"aria-label":`${e.name} (${x?"directory":"file"})`,children:[($||Q)&&c.jsx("span",{className:Se,children:Pe}),(x?T:L)&&c.jsx("span",{className:Me,style:Fe,children:_e}),c.jsx("span",{className:Te,style:{...Ie,...le,...x?P:h},"data-entry-type":x?"directory":"file","data-entry-role":"name",children:e.label??e.name})]}),Y&&M&&k&&c.jsx("fieldset",{children:M.map((re,Re)=>c.jsx(nt,{entry:re,indentLevel:t+1,depth:s+1,positionInSet:Re+1,setSize:M.length,isSelectedForAria:!!R?.has(re.absolutePath),flatIndex:-1,isActive:!1,registerRowRef:C,onNavigationKeyDown:v,rowHeight:d,isDirOpen:p,parentIsLast:[...w,Re===M.length-1],expansion:{toggleDirectory:I,onToggleDirectoryRecursive:m},selection:{onEntryClick:b,selectedPath:S,mode:j,selectedItems:R,onSelectionChange:E},visual:{iconOverrides:y,showExpandIcons:$,showDirectoryIcons:T,showFileIcons:L,useCanvasExpandIcons:Q,expandIconSize:ee,highlightStyles:N,entryClassName:G,entryStyle:z,nameClassName:V,nameStyle:le,directoryNameClassName:ie,directoryNameStyle:P,fileNameClassName:a,fileNameStyle:h}},re.absolutePath))})]},e.absolutePath)},(e,t)=>{if(e.entry!==t.entry)return!1;const s=e.entry.children!==void 0,n=t.entry.children!==void 0,r=s&&e.isDirOpen(e.entry.absolutePath),i=n&&t.isDirOpen(t.entry.absolutePath);return e.indentLevel===t.indentLevel&&e.depth===t.depth&&e.positionInSet===t.positionInSet&&e.setSize===t.setSize&&e.isSelectedForAria===t.isSelectedForAria&&e.flatIndex===t.flatIndex&&e.isActive===t.isActive&&e.rowHeight===t.rowHeight&&r===i&&e.selection.selectedPath===t.selection.selectedPath&&e.selection.mode===t.selection.mode&&e.selection.selectedItems===t.selection.selectedItems&&e.visual.iconOverrides===t.visual.iconOverrides&&e.visual.showExpandIcons===t.visual.showExpandIcons&&e.visual.showDirectoryIcons===t.visual.showDirectoryIcons&&e.visual.showFileIcons===t.visual.showFileIcons&&e.visual.useCanvasExpandIcons===t.visual.useCanvasExpandIcons&&e.visual.expandIconSize===t.visual.expandIconSize&&e.visual.highlightStyles===t.visual.highlightStyles&&e.visual.entryClassName===t.visual.entryClassName&&e.visual.entryStyle===t.visual.entryStyle&&e.visual.nameClassName===t.visual.nameClassName&&e.visual.nameStyle===t.visual.nameStyle&&e.visual.directoryNameClassName===t.visual.directoryNameClassName&&e.visual.directoryNameStyle===t.visual.directoryNameStyle&&e.visual.fileNameClassName===t.visual.fileNameClassName&&e.visual.fileNameStyle===t.visual.fileNameStyle&&e.parentIsLast.length===t.parentIsLast.length&&e.parentIsLast.every((u,f)=>u===t.parentIsLast[f])});nt.displayName="DirectoryEntryItem";const qt=e=>{const t=[];if(e.children)for(const s of e.children)s.type==="directory"&&(t.push(s.absolutePath),t.push(...qt(s)));return t},Or=({entries:e,expansion:{toggle:t,isExpanded:s,expandMultiple:n,collapseMultiple:r,isPending:i,alwaysExpanded:u=!1,doubleClickAction:f="recursive"},selection:{onEntryClick:C,selectedPath:v,mode:d="none",selectedItems:p,onSelectionChange:w},visual:{className:k,style:I,ariaLabel:m,ariaLabelledBy:b,lineColor:S="#A0AEC0",showTreeLines:j=!0,showExpandIcons:R=!0,showDirectoryIcons:E=!0,showFileIcons:y=!0,iconOverrides:$,expandIconSize:T,itemHeight:L=Be,removeRootIndent:Q=!1,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:le}={},virtualScroll:ie,grid:P,sort:a})=>{const h=P!==void 0,[M,F]=l.useState(!1),ne=l.useRef(null),oe=l.useRef(null),x=l.useRef(null),[Y,W]=l.useState(0),[U,ke]=l.useState(0),[fe,be]=l.useState(0),[se,Ye]=l.useState(null),{overscanCount:Se=15,className:Me,background:Te,onScroll:Pe,onRangeChange:_e,initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,callbackThrottleMs:Ie=5,contentInsets:re,onItemFocus:Re,viewportHeightOverride:ce,scrollBarOptions:Ge,behaviorOptions:st,preserveScrollAnchor:at=!1,getItemKey:Zt,testId:ot,contentProps:Ve}=ie??{},lt=l.useMemo(()=>h?{role:"rowgroup",...Ve}:Ve,[h,Ve]),[De,it]=l.useState(typeof me=="number"?me:0),Ue=l.useRef(typeof me=="number"?me:0),ct=l.useCallback((o,g)=>{Ue.current=o,it(o),Pe?.(o,g)},[Pe]),ut=l.useCallback(o=>{const{renderingStartIndex:g,renderingEndIndex:_}=o;Ye(B=>B&&B.renderStart===g&&B.renderEnd===_?B:{renderStart:g,renderEnd:_}),_e?.(o)},[_e]);l.useEffect(()=>{F(!0),_r()},[]),l.useEffect(()=>{const o=ne.current,g=h?oe.current:o,_=()=>{if(o){const X=o.clientWidth;ke(Z=>Math.abs(Z-X)>1?X:Z)}if(typeof ce=="number")W(X=>Math.abs(X-ce)>1?ce:X);else if(g){const X=g.clientHeight;W(Z=>Math.abs(Z-X)>1?X:Z)}};if(!(o||g))return W(0);_();const B=new ResizeObserver(_);return o&&B.observe(o),g&&g!==o&&B.observe(g),()=>B.disconnect()},[ce,h]);const he=typeof ce=="number"?ce:Y,ue=l.useCallback(o=>u||(M?s(o):!1),[M,s,u]),dt=A.twMerge(O.container,i&&O.containerPending,k),ft=l.useMemo(()=>({...Pr,...I??{},...typeof ce=="number"?{height:ce,minHeight:ce}:{}}),[I,ce]),Xe=l.useCallback((o,g)=>{const _=[o.absolutePath,...qt(o)],B=g||f;if(_.every(de=>ue(de)))return r(_);if(_.every(de=>!ue(de))||B==="recursive")return n(_);if(B==="toggle")return r(_);console.warn(`[DirectoryTree] Unknown double click action: ${B}. No action taken.`)},[ue,n,r,f]),mt=h?!1:Q,{flatItems:ge,lineItems:Je,maxIndent:ht}=l.useMemo(()=>Ar(e,ue,j,mt,a),[e,ue,j,mt,a]),J=l.useMemo(()=>ge.map((o,g)=>{const _=typeof L=="function"?L(o.entry,g):L;return{...o,rowHeight:Number.isFinite(_)&&_>0?_:Be}}),[ge,L]),pe=l.useMemo(()=>J.map(o=>o.rowHeight),[J]),xe=l.useMemo(()=>{const o=new Array(pe.length+1);o[0]=0;for(let g=0;g<pe.length;g++)o[g+1]=o[g]+pe[g];return o},[pe]),pt=l.useCallback(o=>J[o]?.rowHeight??Be,[J]),Kt=l.useCallback(o=>J[o]?.entry.absolutePath??o,[J]),yt=Zt??Kt,bt=l.useRef(ge);bt.current=ge;const gt=l.useRef(ue);gt.current=ue;const qe=l.useRef(t);qe.current=t;const[xt,vt]=l.useState(0),Ze=l.useRef(new Map),Ke=l.useRef(null),wt=l.useCallback((o,g)=>{g?(Ze.current.set(o,g),Ke.current===o&&(Ke.current=null,g.focus())):Ze.current.delete(o)},[]),ve=l.useCallback(o=>{vt(o);const g=Ze.current.get(o);if(g){g.focus();return}Ke.current=o,x.current?.scrollToIndex(o)},[]);l.useEffect(()=>{vt(o=>ge.length===0?0:Math.min(o,ge.length-1))},[ge.length]);const kt=l.useCallback((o,g)=>{const _=bt.current,B=_.length-1;if(B<0)return;const X=_[g],Z=X?.entry.children!==void 0,de=Z&>.current(X.entry.absolutePath);switch(o.key){case"ArrowDown":o.preventDefault(),ve(Math.min(g+1,B));break;case"ArrowUp":o.preventDefault(),ve(Math.max(g-1,0));break;case"Home":o.preventDefault(),ve(0);break;case"End":o.preventDefault(),ve(B);break;case"ArrowRight":o.preventDefault(),Z&&!de?qe.current(X.entry.absolutePath):Z&&g<B&&ve(g+1);break;case"ArrowLeft":{if(o.preventDefault(),Z&&de){qe.current(X.entry.absolutePath);break}const nr=X?.depth??0;for(let He=g-1;He>=0;He--)if(_[He].depth<nr){ve(He);break}break}}},[ve]),Oe=l.useMemo(()=>!j||Je.length===0?{segmentsByItem:[],glyphsByItem:[]}:Dr(Je,pe,xe,ze,j,T??Ft),[Je,pe,xe,j,T]),Le=l.useMemo(()=>!j||e.length===0?0:(ht+2)*ze,[e.length,ht,j]),{renderStart:St,renderEnd:Et,lookaheadEnd:Nt}=l.useMemo(()=>Fr(J.length,he,Se,se,De,xe),[J.length,he,Se,se,De,xe]),Qe=l.useMemo(()=>!j||Le<=0||he<=0||Oe.segmentsByItem.length===0?null:c.jsx("div",{className:"pointer-events-none absolute inset-0 z-0","aria-hidden":"true",children:c.jsx("div",{className:"absolute top-0 left-0",style:{width:Le,height:he},children:c.jsx(Jt,{segmentsByItem:Oe.segmentsByItem,glyphsByItem:Oe.glyphsByItem,itemHeight:pe[0]??Be,width:Le,viewportHeight:he,scrollPosition:De,color:S,expandGlyphColor:S,expandGlyphSize:T??Ft,renderStartIndex:St,renderEndIndex:Et,lookaheadEndIndex:Nt})})}),[Le,he,St,Et,Nt,De,Oe,S,j,T,pe]),It=l.useCallback(o=>J[o],[J]),Rt=l.useRef(null);l.useLayoutEffect(()=>{const o=Rt.current;if(Rt.current={items:J,offsets:xe},!at||!o||o.items===J)return;const g=x.current,_=g?.getScrollPosition(),B=typeof _=="number"&&_>=0?_:Ue.current,X=Er(o.items,o.offsets,B);if(!X)return;const Z=Nr(X,J,xe);if(Z===null||Math.abs(Z-B)<1)return;const de=g?g.scrollTo(Z):Z;Ue.current=de,it(de)},[J,xe,at]);const ye=P?.columns,Ee=P?.scrollBarWidth??Ge?.width??Xt,K=l.useMemo(()=>ye?wr({measuredWidth:U,columns:ye,scrollBarWidth:Ee}):null,[ye,U,Ee]),$e=l.useMemo(()=>ye?vr(ye):"",[ye]),Qt=l.useMemo(()=>P?.showFooter&&ye?kr(e):[],[P?.showFooter,ye,e]),Ne=K?.maxHScroll??0;l.useEffect(()=>{be(o=>et(o,Ne))},[Ne]);const Ct=l.useCallback(o=>be(g=>et(g+o,Ne)),[Ne]),jt=l.useMemo(()=>({iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee}),[$,R,E,y,j,T,ee]),Mt=l.useMemo(()=>c.jsx(Tt.VirtualScroll,{ref:x,itemCount:J.length,getItem:It,getItemHeight:pt,getItemKey:yt,testId:ot,contentProps:lt,viewportSize:he,overscanCount:Se,onScroll:ct,onRangeChange:ut,className:Me,onWheelHorizontal:h?Ct:void 0,background:c.jsxs(c.Fragment,{children:[h&&K?c.jsx("div",{className:"pointer-events-none absolute top-0 left-0 z-0 h-full overflow-hidden",style:{width:K.nameWidth},"aria-hidden":"true",children:Qe}):Qe,Te]}),initialScrollIndex:Ae,initialScrollOffset:me,initialScrollAnchor:Fe,onItemFocus:Re,callbackThrottleMs:Ie,contentInsets:re,scrollBarOptions:Ge,behaviorOptions:st,children:(o,g)=>o?h&&P&&K?c.jsx(Gt,{entry:o.entry,indentLevel:o.indentLevel,positionInSet:o.positionInSet,setSize:o.setSize,rowIndex:g+(P.showHeader??!0?2:1),isSelectedForAria:!!p?.has(o.entry.absolutePath),rowHeight:o.rowHeight,isDirOpen:ue,columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,rowClassName:P.rowClassName,selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},visual:jt},o.entry.absolutePath):c.jsx(nt,{entry:o.entry,indentLevel:o.indentLevel,depth:o.depth,positionInSet:o.positionInSet,setSize:o.setSize,isSelectedForAria:!!p?.has(o.entry.absolutePath),flatIndex:g,isActive:g===xt,registerRowRef:wt,onNavigationKeyDown:kt,rowHeight:o.rowHeight,isDirOpen:ue,parentIsLast:o.parentIsLast,renderChildren:!1,expansion:{toggleDirectory:t,onToggleDirectoryRecursive:Xe},selection:{onEntryClick:C,selectedPath:v??null,mode:d,selectedItems:p,onSelectionChange:w},visual:{iconOverrides:$,showExpandIcons:R,showDirectoryIcons:E,showFileIcons:y,useCanvasExpandIcons:j,expandIconSize:T,highlightStyles:ee,entryClassName:H,entryStyle:q,nameClassName:te,nameStyle:N,directoryNameClassName:G,directoryNameStyle:z,fileNameClassName:V,fileNameStyle:le}},o.entry.absolutePath):null}),[J.length,It,pt,yt,ot,lt,xt,wt,kt,he,Se,ct,ut,Me,h,Ct,K,Qe,Te,Ae,me,Fe,Re,Ie,re,Ge,st,P,$e,ue,C,v,d,p,w,t,Xe,jt,$,R,E,y,j,T,ee,H,q,te,N,G,z,V,le]);if(!(P&&K))return c.jsx("div",{ref:ne,className:dt,style:ft,role:"tree","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,children:Mt});const er=P.showHeader??!0,tr=P.showFooter??!1,rr={...ft,"--dt-hscroll":`${fe}px`};return c.jsxs("div",{ref:ne,className:A.twMerge(dt,"dt-grid"),style:rr,role:"treegrid","aria-label":b?void 0:m,"aria-labelledby":b,"aria-multiselectable":d==="multiple"?!0:void 0,"aria-rowcount":J.length+(P.showHeader??!0?1:0),children:[er&&c.jsx("div",{role:"rowgroup",children:c.jsx(br,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,className:P.headerClassName})}),c.jsx("div",{ref:oe,className:"dt-grid-body",children:Mt}),Ne>0&&c.jsxs("div",{className:"dt-grid-hscrollbar-row",children:[c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:K.nameWidth},"aria-hidden":"true"}),c.jsx(Tt.ScrollBar,{horizontal:!0,contentSize:K.numericTotal,viewportSize:K.numericVisible,scrollPosition:fe,scrollBarWidth:Ee,onScroll:o=>{const g=typeof o=="function"?o(fe):o,_=et(g,Ne);return be(_),_}}),c.jsx("div",{className:"dt-grid-scrollbar-spacer",style:{width:Ee},"aria-hidden":"true"})]}),tr&&c.jsx("div",{role:"rowgroup",children:c.jsx(gr,{columns:P.columns,numericTemplate:$e,numericTotal:K.numericTotal,nameWidth:K.nameWidth,scrollBarWidth:Ee,allEntries:Qt,className:P.footerClassName})})]})},Lr=({initialExpanded:e=new Set,storageKey:t}={})=>{const[s,n]=l.useTransition(),[r,i]=l.useState(()=>{if(typeof window<"u"&&t)try{const m=window.localStorage.getItem(t);if(m){const b=JSON.parse(m);return new Set(b)}}catch(m){console.error("[useDirectoryTreeState] Error reading from localStorage",m)}return e}),u=l.useCallback(m=>{n(()=>{i(b=>{const S=new Set(b);return m(S),S})})},[]),f=l.useCallback((m,b)=>{u(S=>{for(const j of m)b(S,j)})},[u]);l.useEffect(()=>{if(t&&typeof window<"u")try{window.localStorage.setItem(t,JSON.stringify(Array.from(r)))}catch(m){console.warn(`Error setting localStorage key "${t}":`,m)}},[r,t]);const C=l.useCallback(m=>{f([m],(b,S)=>{b.has(S)?b.delete(S):b.add(S)})},[f]),v=l.useCallback(m=>{f([m],(b,S)=>{b.add(S)})},[f]),d=l.useCallback(m=>{f([m],(b,S)=>{b.delete(S)})},[f]),p=l.useCallback(m=>{f(m,(b,S)=>{b.delete(S)})},[f]),w=l.useCallback(m=>{f(m,(b,S)=>{b.add(S)})},[f]),k=l.useCallback(()=>{u(m=>{m.clear()})},[u]),I=l.useCallback(m=>r.has(m),[r]);return{expanded:r,toggle:C,expand:v,collapse:d,collapseMultiple:p,expandMultiple:w,collapseAll:k,isExpanded:I,isPending:s}};exports.DirectoryTree=Or;exports.directoryTreeClasses=O;exports.useDirectoryTreeState=Lr;
|
package/dist/index.js
CHANGED
|
@@ -326,7 +326,7 @@ function Ar({
|
|
|
326
326
|
d: "M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"
|
|
327
327
|
}));
|
|
328
328
|
}
|
|
329
|
-
const Mr = /* @__PURE__ */ oe.forwardRef(Ar), Ge = 18, Ve = 12, Zt =
|
|
329
|
+
const Mr = /* @__PURE__ */ oe.forwardRef(Ar), Ge = 18, Ve = 12, Zt = 8, D = {
|
|
330
330
|
container: "directory-tree-container relative h-full transition-opacity duration-300 overflow-y-hidden pb-[3px] pr-[2px]",
|
|
331
331
|
containerPending: "opacity-70",
|
|
332
332
|
entry: "directory-tree-entry flex items-center cursor-pointer relative select-none text-xs leading-tight py-0.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/directory-tree",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.2",
|
|
4
4
|
"description": "High-performance directory tree component for React with virtual scrolling and file selection",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
|
-
"build": "vite build && vite build --config vite.config.cli.ts && pnpm build:css",
|
|
78
|
+
"build": "rimraf dist && vite build && vite build --config vite.config.cli.ts && pnpm build:css",
|
|
79
79
|
"build:css": "tailwindcss -i src/styles/components.entry.css -o dist/styles/directory-tree.css --minify && tailwindcss -i src/styles/standalone.entry.css -o dist/styles/directory-tree.standalone.css --minify",
|
|
80
80
|
"dev": "vite build --watch",
|
|
81
81
|
"watch": "vite build --watch",
|
package/src/entryRendering.tsx
CHANGED
|
@@ -18,8 +18,8 @@ import type { DirectoryTreeIconOverrides, DirectoryTreeIconRenderContext, Direct
|
|
|
18
18
|
export const DEFAULT_ITEM_HEIGHT = 18
|
|
19
19
|
/** Indentation per depth level in px. / 1 階層あたりのインデント幅 (px)。 FHD環境に最適化されたコンパクト設計 (12px) */
|
|
20
20
|
export const INDENT_SIZE = 12
|
|
21
|
-
/** Standard expand glyph size. / 展開アイコンの標準サイズ (
|
|
22
|
-
export const EXPAND_GLYPH_SIZE =
|
|
21
|
+
/** Standard expand glyph size. / 展開アイコンの標準サイズ (8px)。 */
|
|
22
|
+
export const EXPAND_GLYPH_SIZE = 8
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* TailwindCSS v4 class names for DirectoryTree component.
|