@wp-playground/components 3.1.56 → 3.1.58
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/iframe-messages.d.ts +1 -0
- package/index.cjs +6 -6
- package/index.cjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +527 -512
- package/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isMessageFromIframeTree(event: MessageEvent, iframe: HTMLIFrameElement | null): boolean;
|
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var er=Object.create;var Ft=Object.defineProperty;var tr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty;var or=(a,i,f,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let w of rr(i))!ar.call(a,w)&&w!==f&&Ft(a,w,{get:()=>i[w],enumerable:!(u=tr(i,w))||u.enumerable});return a};var ot=(a,i,f)=>(f=a!=null?er(nr(a)):{},or(i||!a||!a.__esModule?Ft(f,"default",{value:a,enumerable:!0}):f,a));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),U=require("@php-wasm/util"),z=require("@wordpress/components"),Ae=require("classnames"),Ht=require("react-dom"),Ue=require("@php-wasm/logger"),Et=require("@wordpress/element"),ir=require("clsx"),Ve=require("@codemirror/state"),Pe=require("@codemirror/view"),wt=require("@codemirror/commands"),It=require("@codemirror/search"),vt=require("@codemirror/autocomplete"),Ke=require("@codemirror/language"),lt=require("@codemirror/lang-php"),Mt=require("@wp-playground/components"),Lt=require("@php-wasm/universal/mime-types"),sr=a=>t.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},t.createElement("rect",{width:"10.4176",height:"10.4176",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 7.45703 24.1775)",stroke:"white",strokeWidth:"0.965644"}),t.createElement("rect",{width:"13.2346",height:"13.2346",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 5.0918 18.9934)",stroke:"white",strokeWidth:"1.44847"}),t.createElement("rect",{width:"17.451",height:"17.451",rx:"3.86258",transform:"matrix(0.829038 -0.559193 0.838671 0.544639 1.55371 11.6099)",stroke:"white",strokeWidth:"1.93129"})),lr=a=>t.createElement("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8 15C4.41015 15 1.5 12.0899 1.5 8.5C1.5 4.91015 4.41015 2 8 2C11.5899 2 14.5 4.91015 14.5 8.5C14.5 12.0899 11.5899 15 8 15ZM0 8.5C0 4.08172 3.58172 0.5 8 0.5C12.4183 0.5 16 4.08172 16 8.5C16 12.9183 12.4183 16.5 8 16.5C3.58172 16.5 0 12.9183 0 8.5ZM9 9.5V4.5H7.5V8H5.5V9.5H9Z",fill:"#949494"})),cr=a=>t.createElement("svg",{width:"20",height:"21",viewBox:"0 0 20 21",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},t.createElement("path",{d:"M20 10.5C20 4.99 15.51 0.5 10 0.5C4.48 0.5 0 4.99 0 10.5C0 16.02 4.48 20.5 10 20.5C15.51 20.5 20 16.02 20 10.5ZM7.78 15.87L4.37 6.72C4.92 6.7 5.54 6.64 5.54 6.64C6.04 6.58 5.98 5.51 5.48 5.53C5.48 5.53 4.03 5.64 3.11 5.64C2.93 5.64 2.74 5.64 2.53 5.63C4.12 3.19 6.87 1.61 10 1.61C12.33 1.61 14.45 2.48 16.05 3.95C15.37 3.84 14.4 4.34 14.4 5.53C14.4 6.27 14.85 6.89 15.3 7.63C15.65 8.24 15.85 8.99 15.85 10.09C15.85 11.58 14.45 15.09 14.45 15.09L11.42 6.72C11.96 6.7 12.24 6.55 12.24 6.55C12.74 6.5 12.68 5.3 12.18 5.33C12.18 5.33 10.74 5.45 9.8 5.45C8.93 5.45 7.47 5.33 7.47 5.33C6.97 5.3 6.91 6.53 7.41 6.55L8.33 6.63L9.59 10.04L7.78 15.87ZM17.41 10.5C17.65 9.86 18.15 8.63 17.84 6.25C18.54 7.54 18.89 8.96 18.89 10.5C18.89 13.79 17.16 16.74 14.49 18.28C15.46 15.69 16.43 13.08 17.41 10.5ZM6.1 18.59C3.12 17.15 1.11 14.03 1.11 10.5C1.11 9.2 1.34 8.02 1.83 6.91C3.25 10.8 4.67 14.7 6.1 18.59ZM10.13 11.96L12.71 18.94C11.85 19.23 10.95 19.39 10 19.39C9.21 19.39 8.43 19.28 7.71 19.06C8.52 16.68 9.33 14.32 10.13 11.96Z",fill:"#ffffff"})),Wt=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"15",height:"14",viewBox:"0 0 15 14",fill:"none"},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.59196 3.59524L6.77745 1.96623C6.70755 1.82641 6.56464 1.7381 6.40832 1.7381H1.65079C1.42287 1.7381 1.2381 1.92287 1.2381 2.15079V11.8492C1.2381 12.0771 1.42287 12.2619 1.65079 12.2619H13.2063C13.4343 12.2619 13.619 12.0771 13.619 11.8492V4.00794C13.619 3.78001 13.4343 3.59524 13.2063 3.59524H7.59196ZM8.35714 2.35714L7.88484 1.41254C7.60521 0.853274 7.0336 0.5 6.40832 0.5H1.65079C0.739085 0.5 0 1.23909 0 2.15079V11.8492C0 12.7609 0.739085 13.5 1.65079 13.5H13.2063C14.1181 13.5 14.8571 12.7609 14.8571 11.8492V4.00794C14.8571 3.09623 14.1181 2.35714 13.2063 2.35714H8.35714Z"})),Ut=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"bi bi-file-earmark",viewBox:"0 0 16 16"},t.createElement("path",{d:"M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"})),ur=a=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",...a},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 12.6875C3.85888 12.6875 1.3125 10.1411 1.3125 7C1.3125 3.85888 3.85888 1.3125 7 1.3125C10.1411 1.3125 12.6875 3.85888 12.6875 7C12.6875 10.1411 10.1411 12.6875 7 12.6875ZM0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7ZM7.875 7.875V3.5H6.5625V6.5625H4.8125V7.875H7.875Z",fill:"#949494"})),fr=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none"},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.25 1.3125H1.75C1.50838 1.3125 1.3125 1.50838 1.3125 1.75V4.37495H12.6875V1.75C12.6875 1.50837 12.4916 1.3125 12.25 1.3125ZM12.6875 5.68745H5.25003V12.6875H12.25C12.4916 12.6875 12.6875 12.4916 12.6875 12.25V5.68745ZM3.93753 5.68745H1.3125V12.25C1.3125 12.4916 1.50837 12.6875 1.75 12.6875H3.93753L3.93753 5.68745ZM1.75 0H12.25C13.2165 0 14 0.783502 14 1.75V12.25C14 13.2165 13.2165 14 12.25 14H1.75C0.783502 14 0 13.2165 0 12.25V1.75C0 0.783502 0.783502 0 1.75 0Z",fill:"#949494"}));function dr(a){return`data:${a.mime};base64,${a.data}`}function mr({size:a=24,sidebarActive:i=!1}){return t.createElement("svg",{width:a,height:a,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},t.createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i?t.createElement("rect",{x:"3",y:"3",width:"7",height:"18",rx:"2",ry:"2",fill:"currentColor"}):t.createElement("rect",{x:"3",y:"3",width:"8",height:"18",rx:"2",ry:"2",fill:"none",stroke:"currentColor",strokeWidth:"2"}))}function pr(a,i){return!(i!=null&&i.contentWindow)||!a.source?!1:a.source===i.contentWindow?!0:zt(i.contentWindow,a.source)}function zt(a,i){try{for(let f=0;f<a.frames.length;f++){const u=a.frames[f];if(u===i||zt(u,i))return!0}}catch{}return!1}const jt=Et.forwardRef(({icon:a,size:i=24,...f},u)=>Et.cloneElement(a,{width:i,height:i,...f,ref:u}));var Tt={exports:{}},it={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Ot;function
|
|
9
|
+
*/var Ot;function hr(){if(Ot)return it;Ot=1;var a=t,i=Symbol.for("react.element"),f=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,w=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function C(g,R,b){var D,P={},F=null,X=null;b!==void 0&&(F=""+b),R.key!==void 0&&(F=""+R.key),R.ref!==void 0&&(X=R.ref);for(D in R)u.call(R,D)&&!h.hasOwnProperty(D)&&(P[D]=R[D]);if(g&&g.defaultProps)for(D in R=g.defaultProps,R)P[D]===void 0&&(P[D]=R[D]);return{$$typeof:i,type:g,key:F,ref:X,props:P,_owner:w.current}}return it.Fragment=f,it.jsx=C,it.jsxs=C,it}var st={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Bt;function
|
|
17
|
+
*/var Bt;function wr(){return Bt||(Bt=1,process.env.NODE_ENV!=="production"&&function(){var a=t,i=Symbol.for("react.element"),f=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),C=Symbol.for("react.provider"),g=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),X=Symbol.for("react.offscreen"),K=Symbol.iterator,v="@@iterator";function Y(e){if(e===null||typeof e!="object")return null;var n=K&&e[K]||e[v];return typeof n=="function"?n:null}var k=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(e){{for(var n=arguments.length,l=new Array(n>1?n-1:0),p=1;p<n;p++)l[p-1]=arguments[p];A("error",e,l)}}function A(e,n,l){{var p=k.ReactDebugCurrentFrame,T=p.getStackAddendum();T!==""&&(n+="%s",l=l.concat([T]));var M=l.map(function(N){return String(N)});M.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,M)}}var j=!1,I=!1,H=!1,te=!1,re=!1,J;J=Symbol.for("react.module.reference");function ne(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===h||re||e===w||e===b||e===D||te||e===X||j||I||H||typeof e=="object"&&e!==null&&(e.$$typeof===F||e.$$typeof===P||e.$$typeof===C||e.$$typeof===g||e.$$typeof===R||e.$$typeof===J||e.getModuleId!==void 0))}function y(e,n,l){var p=e.displayName;if(p)return p;var T=n.displayName||n.name||"";return T!==""?l+"("+T+")":l}function d(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&m("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case u:return"Fragment";case f:return"Portal";case h:return"Profiler";case w:return"StrictMode";case b:return"Suspense";case D:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case g:var n=e;return d(n)+".Consumer";case C:var l=e;return d(l._context)+".Provider";case R:return y(e,e.render,"ForwardRef");case P:var p=e.displayName||null;return p!==null?p:S(e.type)||"Memo";case F:{var T=e,M=T._payload,N=T._init;try{return S(N(M))}catch{return null}}}return null}var B=Object.assign,W=0,V,q,le,de,G,Q,ce;function Re(){}Re.__reactDisabledLog=!0;function ae(){{if(W===0){V=console.log,q=console.info,le=console.warn,de=console.error,G=console.group,Q=console.groupCollapsed,ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}W++}}function ke(){{if(W--,W===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},e,{value:V}),info:B({},e,{value:q}),warn:B({},e,{value:le}),error:B({},e,{value:de}),group:B({},e,{value:G}),groupCollapsed:B({},e,{value:Q}),groupEnd:B({},e,{value:ce})})}W<0&&m("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var we=k.ReactCurrentDispatcher,Ce;function oe(e,n,l){{if(Ce===void 0)try{throw Error()}catch(T){var p=T.stack.trim().match(/\n( *(at )?)/);Ce=p&&p[1]||""}return`
|
|
18
18
|
`+Ce+e}}var je=!1,ve;{var Te=typeof WeakMap=="function"?WeakMap:Map;ve=new Te}function E(e,n){if(!e||je)return"";{var l=ve.get(e);if(l!==void 0)return l}var p;je=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var M;M=we.current,we.current=null,ae();try{if(n){var N=function(){throw Error()};if(Object.defineProperty(N.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(N,[])}catch(xe){p=xe}Reflect.construct(e,[],N)}else{try{N.call()}catch(xe){p=xe}e.call(N.prototype)}}else{try{throw Error()}catch(xe){p=xe}e()}}catch(xe){if(xe&&p&&typeof xe.stack=="string"){for(var L=xe.stack.split(`
|
|
19
19
|
`),_e=p.stack.split(`
|
|
20
20
|
`),ee=L.length-1,se=_e.length-1;ee>=1&&se>=0&&L[ee]!==_e[se];)se--;for(;ee>=1&&se>=0;ee--,se--)if(L[ee]!==_e[se]){if(ee!==1||se!==1)do if(ee--,se--,se<0||L[ee]!==_e[se]){var Ne=`
|
|
21
|
-
`+L[ee].replace(" at new "," at ");return e.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",e.displayName)),typeof e=="function"&&ve.set(e,Ne),Ne}while(ee>=1&&se>=0);break}}}finally{je=!1,we.current=M,ke(),Error.prepareStackTrace=T}var Ze=e?e.displayName||e.name:"",He=Ze?oe(Ze):"";return typeof e=="function"&&ve.set(e,He),He}function Ee(e,n,l){return E(e,!1)}function pe(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function $(e,n,l){if(e==null)return"";if(typeof e=="function")return E(e,pe(e));if(typeof e=="string")return oe(e);switch(e){case b:return oe("Suspense");case D:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case R:return Ee(e.render);case P:return $(e.type,n,l);case F:{var p=e,T=p._payload,M=p._init;try{return $(M(T),n,l)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,$e={},he=k.ReactDebugCurrentFrame;function ge(e){if(e){var n=e._owner,l=$(e.type,e._source,n?n.type:null);he.setExtraStackFrame(l)}else he.setExtraStackFrame(null)}function Oe(e,n,l,p,T){{var M=Function.call.bind(ue);for(var N in e)if(M(e,N)){var L=void 0;try{if(typeof e[N]!="function"){var _e=Error((p||"React class")+": "+l+" type `"+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[N]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _e.name="Invariant Violation",_e}L=e[N](n,N,p,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){L=ee}L&&!(L instanceof Error)&&(ge(T),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",p||"React class",l,N,typeof L),ge(null)),L instanceof Error&&!(L.message in $e)&&($e[L.message]=!0,ge(T),m("Failed %s type: %s",l,L.message),ge(null))}}}var x=Array.isArray;function _(e){return x(e)}function me(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,l=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l}}function fe(e){try{return ie(e),!1}catch{return!0}}function ie(e){return""+e}function Se(e){if(fe(e))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",me(e)),ie(e)}var Me=k.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0},De,ze;function et(e){if(ue.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function gt(e){if(ue.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function yt(e,n){typeof e.ref=="string"&&Me.current}function _t(e,n){{var l=function(){De||(De=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}}function qe(e,n){{var l=function(){ze||(ze=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};l.isReactWarning=!0,Object.defineProperty(e,"ref",{get:l,configurable:!0})}}var Ge=function(e,n,l,p,T,M,N){var L={$$typeof:
|
|
21
|
+
`+L[ee].replace(" at new "," at ");return e.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",e.displayName)),typeof e=="function"&&ve.set(e,Ne),Ne}while(ee>=1&&se>=0);break}}}finally{je=!1,we.current=M,ke(),Error.prepareStackTrace=T}var Ze=e?e.displayName||e.name:"",He=Ze?oe(Ze):"";return typeof e=="function"&&ve.set(e,He),He}function Ee(e,n,l){return E(e,!1)}function pe(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function $(e,n,l){if(e==null)return"";if(typeof e=="function")return E(e,pe(e));if(typeof e=="string")return oe(e);switch(e){case b:return oe("Suspense");case D:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case R:return Ee(e.render);case P:return $(e.type,n,l);case F:{var p=e,T=p._payload,M=p._init;try{return $(M(T),n,l)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,$e={},he=k.ReactDebugCurrentFrame;function ge(e){if(e){var n=e._owner,l=$(e.type,e._source,n?n.type:null);he.setExtraStackFrame(l)}else he.setExtraStackFrame(null)}function Oe(e,n,l,p,T){{var M=Function.call.bind(ue);for(var N in e)if(M(e,N)){var L=void 0;try{if(typeof e[N]!="function"){var _e=Error((p||"React class")+": "+l+" type `"+N+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[N]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw _e.name="Invariant Violation",_e}L=e[N](n,N,p,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ee){L=ee}L&&!(L instanceof Error)&&(ge(T),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",p||"React class",l,N,typeof L),ge(null)),L instanceof Error&&!(L.message in $e)&&($e[L.message]=!0,ge(T),m("Failed %s type: %s",l,L.message),ge(null))}}}var x=Array.isArray;function _(e){return x(e)}function me(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,l=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l}}function fe(e){try{return ie(e),!1}catch{return!0}}function ie(e){return""+e}function Se(e){if(fe(e))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",me(e)),ie(e)}var Me=k.ReactCurrentOwner,Ie={key:!0,ref:!0,__self:!0,__source:!0},De,ze;function et(e){if(ue.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function gt(e){if(ue.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function yt(e,n){typeof e.ref=="string"&&Me.current}function _t(e,n){{var l=function(){De||(De=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}}function qe(e,n){{var l=function(){ze||(ze=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};l.isReactWarning=!0,Object.defineProperty(e,"ref",{get:l,configurable:!0})}}var Ge=function(e,n,l,p,T,M,N){var L={$$typeof:i,type:e,key:n,ref:l,props:N,_owner:M};return L._store={},Object.defineProperty(L._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(L,"_self",{configurable:!1,enumerable:!1,writable:!1,value:p}),Object.defineProperty(L,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(L.props),Object.freeze(L)),L};function bt(e,n,l,p,T){{var M,N={},L=null,_e=null;l!==void 0&&(Se(l),L=""+l),gt(n)&&(Se(n.key),L=""+n.key),et(n)&&(_e=n.ref,yt(n,T));for(M in n)ue.call(n,M)&&!Ie.hasOwnProperty(M)&&(N[M]=n[M]);if(e&&e.defaultProps){var ee=e.defaultProps;for(M in ee)N[M]===void 0&&(N[M]=ee[M])}if(L||_e){var se=typeof e=="function"?e.displayName||e.name||"Unknown":e;L&&_t(N,se),_e&&qe(N,se)}return Ge(e,L,_e,T,p,Me.current,N)}}var tt=k.ReactCurrentOwner,ct=k.ReactDebugCurrentFrame;function Be(e){if(e){var n=e._owner,l=$(e.type,e._source,n?n.type:null);ct.setExtraStackFrame(l)}else ct.setExtraStackFrame(null)}var rt;rt=!1;function Ye(e){return typeof e=="object"&&e!==null&&e.$$typeof===i}function nt(){{if(tt.current){var e=S(tt.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function ut(e){return""}var ft={};function dt(e){{var n=nt();if(!n){var l=typeof e=="string"?e:e.displayName||e.name;l&&(n=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+l+">.")}return n}}function at(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var l=dt(n);if(ft[l])return;ft[l]=!0;var p="";e&&e._owner&&e._owner!==tt.current&&(p=" It was passed a child from "+S(e._owner.type)+"."),Be(e),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,p),Be(null)}}function mt(e,n){{if(typeof e!="object")return;if(_(e))for(var l=0;l<e.length;l++){var p=e[l];Ye(p)&&at(p,n)}else if(Ye(e))e._store&&(e._store.validated=!0);else if(e){var T=Y(e);if(typeof T=="function"&&T!==e.entries)for(var M=T.call(e),N;!(N=M.next()).done;)Ye(N.value)&&at(N.value,n)}}}function Ct(e){{var n=e.type;if(n==null||typeof n=="string")return;var l;if(typeof n=="function")l=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===R||n.$$typeof===P))l=n.propTypes;else return;if(l){var p=S(n);Oe(l,e.props,"prop",p,e)}else if(n.PropTypes!==void 0&&!rt){rt=!0;var T=S(n);m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var n=Object.keys(e.props),l=0;l<n.length;l++){var p=n[l];if(p!=="children"&&p!=="key"){Be(e),m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",p),Be(null);break}}e.ref!==null&&(Be(e),m("Invalid attribute `ref` supplied to `React.Fragment`."),Be(null))}}var pt={};function ht(e,n,l,p,T,M){{var N=ne(e);if(!N){var L="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var _e=ut();_e?L+=_e:L+=nt();var ee;e===null?ee="null":_(e)?ee="array":e!==void 0&&e.$$typeof===
|
|
25
|
+
Check the top-level render call using <`+l+">.")}return n}}function at(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var l=dt(n);if(ft[l])return;ft[l]=!0;var p="";e&&e._owner&&e._owner!==tt.current&&(p=" It was passed a child from "+S(e._owner.type)+"."),Be(e),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,p),Be(null)}}function mt(e,n){{if(typeof e!="object")return;if(_(e))for(var l=0;l<e.length;l++){var p=e[l];Ye(p)&&at(p,n)}else if(Ye(e))e._store&&(e._store.validated=!0);else if(e){var T=Y(e);if(typeof T=="function"&&T!==e.entries)for(var M=T.call(e),N;!(N=M.next()).done;)Ye(N.value)&&at(N.value,n)}}}function Ct(e){{var n=e.type;if(n==null||typeof n=="string")return;var l;if(typeof n=="function")l=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===R||n.$$typeof===P))l=n.propTypes;else return;if(l){var p=S(n);Oe(l,e.props,"prop",p,e)}else if(n.PropTypes!==void 0&&!rt){rt=!0;var T=S(n);m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xt(e){{for(var n=Object.keys(e.props),l=0;l<n.length;l++){var p=n[l];if(p!=="children"&&p!=="key"){Be(e),m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",p),Be(null);break}}e.ref!==null&&(Be(e),m("Invalid attribute `ref` supplied to `React.Fragment`."),Be(null))}}var pt={};function ht(e,n,l,p,T,M){{var N=ne(e);if(!N){var L="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(L+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var _e=ut();_e?L+=_e:L+=nt();var ee;e===null?ee="null":_(e)?ee="array":e!==void 0&&e.$$typeof===i?(ee="<"+(S(e.type)||"Unknown")+" />",L=" Did you accidentally export a JSX literal instead of a component?"):ee=typeof e,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ee,L)}var se=bt(e,n,l,T,M);if(se==null)return se;if(N){var Ne=n.children;if(Ne!==void 0)if(p)if(_(Ne)){for(var Ze=0;Ze<Ne.length;Ze++)mt(Ne[Ze],e);Object.freeze&&Object.freeze(Ne)}else m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else mt(Ne,e)}if(ue.call(n,"key")){var He=S(e),xe=Object.keys(n).filter(function(Qt){return Qt!=="key"}),Rt=xe.length>0?"{key: someKey, "+xe.join(": ..., ")+": ...}":"{key: someKey}";if(!pt[He+Rt]){var Xt=xe.length>0?"{"+xe.join(": ..., ")+": ...}":"{}";m(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Rt,He,Jt,He),pt[He+Rt]=!0}}return e===u?xt(se):Ct(se),se}}function r(e,n,l){return ht(e,n,l,!0)}function a(e,n,l){return ht(e,n,l,!1)}var o=a,c=r;st.Fragment=u,st.jsx=o,st.jsxs=c}()),st}process.env.NODE_ENV==="production"?Tt.exports=mr():Tt.exports=pr();var Fe=Tt.exports,Xe=i=>Et.createElement("path",i),Qe=Et.forwardRef(({className:i,isPressed:s,...f},u)=>{const w={...f,className:or(i,{"is-pressed":s})||void 0,"aria-hidden":!0,focusable:!1};return Fe.jsx("svg",{...w,ref:u})});Qe.displayName="SVG";const hr=Fe.jsx(Qe,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Fe.jsx(Xe,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),wr=Fe.jsx(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:Fe.jsx(Xe,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),vr=Fe.jsx(Qe,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Fe.jsx(Xe,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z"})}),Er=Fe.jsxs(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[Fe.jsx(Xe,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),Fe.jsx(Xe,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),gr=Fe.jsx(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:Fe.jsx(Xe,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})}),yr="_file-picker-tree_12ffp_1",_r="_file-node-button_12ffp_17",br="_selected_12ffp_56",Cr="_focused_12ffp_75",xr="_dropTarget_12ffp_83",Rr="_dropTargetInvalid_12ffp_95",Sr="_renaming_12ffp_104",Pr="_renameInput_12ffp_109",kr="_file-name_12ffp_124",Tr="_path-badge_12ffp_128",Dr="_path-badge-tooltip_12ffp_140",ye={filePickerTree:yr,fileNodeButton:_r,selected:br,focused:Cr,dropTarget:xr,dropTargetInvalid:Rr,renaming:Sr,renameInput:Pr,fileName:kr,pathBadge:Tr,pathBadgeTooltip:Dr};function St(i){if(!i)return[];const s=U.normalizePath(i),f=s.startsWith("/"),u=s.split("/").filter(Boolean),w=[];let h=f?"/":"";f&&w.push("/");for(const C of u)!h||h==="/"?h=h==="/"?`/${C}`:C:h=`${h}/${C}`,w.push(h);return w}function We(i,s,f){return i&&(i===s?f:i.startsWith(s==="/"?"/":`${s}/`)?f+i.slice(s.length):i)}const zt=t.forwardRef(function({withContextMenu:s=!0,readOnly:f=!1,filesystem:u,root:w="/wordpress",initialSelectedPath:h,onSelect:C=()=>{},onDoubleClickFile:g,pathBadges:R,onMountFromGit:b,onPathRenamed:D},P){const F=t.useMemo(()=>U.joinPaths("/",w||"/"),[w]),X=t.useMemo(()=>U.joinPaths(F,"wp-content","plugins"),[F]),K=t.useMemo(()=>U.joinPaths(F,"wp-content","themes"),[F]),[v,Y]=t.useState(()=>{if(!h)return{};const r={};for(const a of St(h))r[a]=!0;return r}),[k,m]=t.useState(()=>h??null),[A,j]=t.useState(()=>h??null),[I,H]=t.useState({}),[te,re]=t.useState({}),[J,ne]=t.useState(null),[y,d]=t.useState(null),S=t.useRef({}),B=t.useRef(!1),W=t.useRef(null),V=t.useRef(null),q=t.useRef(te),le=t.useRef(I),de=()=>{for(const r of Object.keys(S.current))clearTimeout(S.current[r]),delete S.current[r]},G=r=>{const a=S.current[r];a&&(clearTimeout(a),delete S.current[r])};t.useEffect(()=>{q.current=te},[te]),t.useEffect(()=>{le.current=I},[I]);const Q=r=>{var o;const a=(o=W.current)==null?void 0:o.querySelector(`[data-path="${CSS.escape(r)}"]`);a&&typeof a.focus=="function"&&(a.focus(),a.scrollIntoView({behavior:"smooth",block:"nearest"}))},ce=(r,a="")=>a?U.joinPaths(a,r.name):U.joinPaths("/",r.name),Re=(r,a)=>r.children?r.children:I[a],ae=async(r,a)=>{const o=await r.listFiles(a),c=[];for(const e of o){const n=a==="/"?`/${e}`:`${a}/${e}`,l=await r.isDir(n);c.push({name:e,type:l?"folder":"file"})}return c.sort((e,n)=>{var M;if(e.type!==n.type)return e.type==="folder"?-1:1;const l=a==="/"?`/${e.name}`:`${a}/${e.name}`,p=a==="/"?`/${n.name}`:`${a}/${n.name}`,T=(M=ge.current)==null?void 0:M.tempPath;if(T){if(l===T)return-1;if(p===T)return 1}return e.name.localeCompare(n.name)}),c},ke=async r=>await ae(u,r),we=(r,a)=>{if(a.type!=="folder")return a.children;const o=a.children??le.current[r];return o||q.current[r]?o:(re(c=>({...c,[r]:!0})),new Promise(c=>{ke(r).then(e=>{H(n=>({...n,[r]:e??[]})),c(e??[])}).catch(()=>{c([])}).finally(()=>{re(e=>{const n={...e};return delete n[r],n})})}))},Ce=(r,a)=>{a.type==="folder"&&(typeof window>"u"||S.current[r]||(S.current[r]=window.setTimeout(()=>{Y(o=>o[r]?o:{...o,[r]:!0}),we(r,a),delete S.current[r]},600)))},oe=r=>(re(a=>({...a,[r]:!0})),new Promise(a=>{ke(r).then(o=>{H(c=>({...c,[r]:o??[]})),a(o??[])}).catch(()=>{a([])}).finally(()=>{re(o=>{const c={...o};return delete c[r],c})})})),je=(r,a,o)=>{Y(c=>({...c,[r]:o})),o?we(r,a):H(c=>{if(c[r]===void 0)return c;const e={...c};return delete e[r],e})},ve=async r=>{if(!r)return;const a=St(r);if(a.length===0)return;Y(e=>{const n={...e};for(const l of a)n[l]=!0;return n});let o=[{name:F,type:"folder"}],c="";for(const e of a){const n=o==null?void 0:o.find(p=>ce(p,c)===e);if(!n||n.type!=="folder"){c=e,o=[];continue}o=await we(e,n)??le.current[e],c=e}},Te=(r,a)=>{!r||!a||r===a||(Y(o=>{let c=!1;const e={...o};for(const n of Object.keys(o)){const l=We(n,r,a);l&&l!==n&&(e[l]=o[n],delete e[n],c=!0)}return c?e:o}),H(o=>{let c=!1;const e={...o};for(const n of Object.keys(o)){const l=We(n,r,a);l&&l!==n&&(e[l]=o[n],delete e[n],c=!0)}return c?e:o}),m(o=>We(o,r,a)),j(o=>We(o,r,a)))},E=()=>{ne(null),d(null),de()},Ee=(r,a=!0)=>{m(r),a&&C(r)},pe=t.useMemo(()=>[{name:F,type:"folder"}],[F]),[$,ue]=t.useState(null),[$e,he]=t.useState(null),ge=t.useRef(null),Oe=f?null:$e;t.useImperativeHandle(P,()=>({focusPath:(r,a={})=>{if(!r)return;const{select:o=!0,domFocus:c=!0,notify:e=!1}=a;o&&Ee(r,e),j(r),c&&Q(r)},selectPath:r=>{r&&(Ee(r),j(r),Q(r))},getSelectedPath:()=>k,expandToPath:async r=>await ve(r),refresh:async r=>await oe(r),revealPath:async r=>{const a=U.dirname(r);await oe(a),await ve(a),await oe(r),Y(o=>({...o,[r]:!0})),Ee(r,!1),j(r),setTimeout(()=>Q(r),0)},remapPath:Te,createFile:async r=>{f||await Ge(r,"file","untitled.php")},createFolder:async r=>{f||await Ge(r,"folder","New Folder")},importFiles:async(r,a)=>{f||await ft(r,a)},importDataTransfer:async(r,a)=>{f||await dt(r,a)}}),[k,oe,Te,ve,f]);const x=t.useRef(!1),_=t.useRef(h??null),me=t.useRef(h);t.useEffect(()=>{B.current=!1},[F]),t.useEffect(()=>{h&&h!==me.current?_.current=h:h||(_.current=null),me.current=h},[h]),t.useEffect(()=>{if(!h||x.current)return;x.current=!0;const r=St(h);Y(o=>{const c={...o};for(const e of r)c[e]=!0;return c});const a=r[r.length-1]||h;j(a),m(a),ve(h)},[h,ve]),t.useEffect(()=>{const r=_.current;!r||pe.length===0||(_.current=null,ve(r))},[pe,ve]),t.useEffect(()=>{if(!A){if(pe.length>0){const r=ce(pe[0]);j(r)}return}Oe&&Oe===A||Q(A)},[pe,A,Oe]),t.useEffect(()=>{if(pe.length===0)return;const r=pe[0];if((r==null?void 0:r.type)!=="folder"||B.current)return;const a=r.name;B.current=!0,Y(o=>o[a]?o:{...o,[a]:!0}),!le.current[a]&&!q.current[a]&&we(a,r)},[pe,we,F]),t.useEffect(()=>()=>{V.current&&clearTimeout(V.current),de()},[]),t.useEffect(()=>{$&&setTimeout(()=>{const r=document.querySelector('[role="menu"] [role="menuitem"]');r&&typeof r.focus=="function"&&r.focus()},0)},[$]);const[fe,ie]=t.useState(""),Se=(r,a)=>{if(r.type==="folder")return a;const o=U.dirname(a);return o&&o||"/"},Me=(r,a,o)=>{const c=Se(r,a);return c?o&&U.isParentOf(o,c)?{allowed:!1,state:"invalid",destination:null}:{allowed:!0,state:"valid",destination:c}:{allowed:!1,state:"invalid",destination:null}},Ie=(r,a,o)=>{a.type!=="folder"&&a.type!=="file"||(ne(o),d(null),r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("application/x-wp-playground-path",o),r.dataTransfer.setData("text/plain",o)))},De=()=>{E()},ze=(r,a,o)=>{const c=Me(a,o,J);c.allowed&&a.type==="folder"&&Ce(o,a),d(e=>(e==null?void 0:e.path)===o&&e.state===c.state?e:{path:o,state:c.state})},et=(r,a,o)=>{const c=Me(a,o,J);c.allowed&&c.destination?(r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect=J?"move":"copy"),a.type==="folder"&&Ce(o,a),d(e=>(e==null?void 0:e.path)===o&&e.state===c.state?e:{path:o,state:c.state})):(r.dataTransfer&&(r.dataTransfer.dropEffect="none"),G(o),d(e=>(e==null?void 0:e.path)===o&&e.state==="invalid"?e:{path:o,state:"invalid"}))},gt=(r,a,o)=>{G(o);const c=r.relatedTarget;c&&r.currentTarget.contains(c)||d(e=>(e==null?void 0:e.path)===o?null:e)},yt=async(r,a,o)=>{const c=J,e=Me(a,o,c);if(!e.allowed||!e.destination){E();return}r.preventDefault(),r.stopPropagation(),G(o),d(null);try{c?await ct(c,e.destination):await dt(r.dataTransfer,e.destination)}finally{E()}},_t=(r,a,o)=>{s&&(r.preventDefault(),r.stopPropagation(),he(null),ue({absPath:o,type:a.type,x:r.clientX,y:r.clientY}))},qe=async(r,a)=>{let o=a,c=0;const e=l=>{const p=l.lastIndexOf(".");return p>0?{stem:l.slice(0,p),ext:l.slice(p)}:{stem:l,ext:""}},n=r==="/"?"":r;for(;await(u==null?void 0:u.fileExists(`${n}/${o}`))||await(u==null?void 0:u.isDir(`${n}/${o}`));){c+=1;const{stem:l,ext:p}=e(a);o=`${l} (${c})${p}`}return o},Ge=async(r,a,o)=>{if(!u)return;let c=r||k||F;try{await u.isDir(c)||(c=U.dirname(c))}catch{c=U.dirname(c)}const e=c,n=await qe(e,o),l=U.joinPaths(e,n);a==="folder"?await u.mkdir(l):await u.writeFile(l,""),ge.current={type:a,tempPath:l},he(l),await oe(e),setTimeout(()=>{j(l),Q(l)},0)},bt=async r=>{if(!u)return!1;try{if(await u.fileExists(r))return!0}catch{}try{if(await u.isDir(r))return!0}catch{}return!1},tt=async r=>{if(u)try{await u.mkdir(r)}catch(a){if(!await u.isDir(r).catch(()=>!1))throw a}},ct=async(r,a)=>{if(!u)return;const o=U.basename(r),c=U.joinPaths(a,o);if(c===r||await bt(c))return;const e=U.dirname(r);try{await u.mv(r,c),Te(r,c);const n=We(k,r,c);k&&(k===r||k.startsWith(`${r}/`))&&C(n),j(l=>We(l,r,c)),Y(l=>({...l,[a]:!0})),await Promise.all([oe(e),oe(a)]),m(l=>We(l,r,c)),Q(c)}catch{}},Be=r=>{const a=r;return a.webkitGetAsEntry?a.webkitGetAsEntry():null},rt=r=>new Promise((a,o)=>{r.file(a,o)}),Ye=async(r,a)=>{if(!u)return;const o=r.name||"untitled",c=await qe(a,o),e=U.joinPaths(a,c),n=new Uint8Array(await r.arrayBuffer());await u.writeFile(e,n)},nt=async(r,a)=>{const o=await rt(r);await Ye(o,a)},ut=async(r,a)=>{const o=await qe(a,r.name||"New Folder"),c=U.joinPaths(a,o);await tt(c);const e=r.createReader(),n=()=>new Promise((l,p)=>{e.readEntries(T=>l(Array.from(T)),p)});for(;;){const l=await n();if(!l.length)break;for(const p of l)p.isFile?await nt(p,c):p.isDirectory&&await ut(p,c)}},ft=(r,a)=>at([],r,a),dt=(r,a)=>{const c=Array.from(r.items).filter(n=>n.kind==="file").map(n=>Be(n)).filter(n=>!!n),e=Array.from(r.files);return at(c,e,a)},at=async(r,a,o)=>{if(u){if(r.length>0)for(const c of r)c.isFile?await nt(c,o):c.isDirectory&&await ut(c,o);else for(const c of a)await Ye(c,o);await oe(o),Y(c=>({...c,[o]:!0}))}},mt=async(r,a)=>{if(!u)return;const o=r;ue(null);try{a==="folder"?await u.rmdir(o,{recursive:!0}):await u.unlink(o)}catch{}finally{he(null);const c=U.dirname(o);await oe(c),k&&(k===o||k.startsWith(`${o}/`))&&C(null)}},Ct=async r=>{if(u)try{const o=await(await u.read(r)).arrayBuffer(),c=new Blob([o]),e=URL.createObjectURL(c),n=document.createElement("a");n.href=e,n.download=U.basename(r)||"download",document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(e),6e4)}catch(a){console.error("Failed to download file",a)}},xt=r=>{var a;if(!$e)if(r.key.length===1&&r.key.match(/\S/)){const o=fe+r.key.toLowerCase();if(ie(o),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{ie("")},1e3),!W.current)return;const c=Array.from(W.current.querySelectorAll(".file-node-button")),e=document.activeElement;let n=0;e&&c.includes(e)&&(n=c.indexOf(e));for(let l=0;l<c.length;l++){const p=(n+l)%c.length,T=c[p];if((a=T.textContent)!=null&&a.toLowerCase().trim().startsWith(o)){T.focus();const M=T.getAttribute("data-path");M&&j(M);break}}}else ie(""),V.current&&clearTimeout(V.current)},pt=async(r,a)=>{if(f)return;const o=ge.current,c=(o==null?void 0:o.tempPath)===r,e=U.dirname(r);if(!a||a==="."||a===".."||U.basename(a)!==a){if(c){try{o.type==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}ge.current=null}he(c?null:r);return}let n=U.joinPaths(e,a),l=n;if(l===r){he(null);const N=c&&(o==null?void 0:o.type)==="file";c&&(ge.current=null),setTimeout(()=>{j(l),Q(l),N&&g&&g(l)},0);return}const p=await u.fileExists(l),T=await u.isDir(l);if((p||T)&&l!==r)if(c)try{const N=await qe(e==="/"?"/":e,a);n=U.joinPaths(e,N),l=n}catch{}else{he(r);return}let M=(o==null?void 0:o.type)==="folder";try{if(await u.mv(r,n),o||(M=await u.isDir(n)),M&&(Te(r,l),!c))try{await(D==null?void 0:D(r,l))}catch(N){Ue.logger.error("Failed to update metadata after renaming a path",N)}k===r&&C(l),await oe(e),j(l),Q(l),c&&!M&&g&&g(l)}catch{if(c)try{(o==null?void 0:o.type)==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}}finally{ge.current=null,he(null)}},ht=async r=>{const a=ge.current;if(!u||(a==null?void 0:a.tempPath)!==r){he(c=>c===r?null:c);return}try{a.type==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}ge.current=null,he(null);const o=U.dirname(r);await oe(o),j(o),Q(o)};return t.createElement("div",{onKeyDown:xt,ref:W},t.createElement(z.__experimentalTreeGrid,{className:ye.filePickerTree},pe.map((r,a)=>t.createElement(qt,{key:r.name,node:r,level:0,position:a+1,setSize:pe.length,expandedNodePaths:v,onToggle:je,selectedNode:k,focusPath:o=>j(o),focusedNode:A,selectPath:Ee,generatePath:ce,getChildren:Re,onContextMenu:f?void 0:_t,renamingPath:Oe,onRename:pt,onRenameCancel:ht,dropIndicator:y,onDragStart:f?void 0:Ie,onDragEnd:f?void 0:De,onDragEnter:f?void 0:ze,onDragOver:f?void 0:et,onDragLeave:f?void 0:gt,onDrop:f?void 0:yt,rootPath:F,onDoubleClickFile:g,pathBadges:R}))),!f&&$&&t.createElement(z.Popover,{placement:"bottom-start",onClose:()=>ue(null),anchor:{getBoundingClientRect:()=>({x:$.x,y:$.y,width:0,height:0,top:$.y,left:$.x,right:$.x,bottom:$.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},t.createElement(z.NavigableMenu,{role:"menu"},$.type==="folder"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ge($.absPath,"file","untitled.php")}},"Create file"),$.type==="folder"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ge($.absPath,"folder","New Folder")}},"Create directory"),b&&$.type==="folder"&&($.absPath===X||$.absPath===K)&&t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>{ue(null),b($.absPath===X?"plugin":"theme",$.absPath)}},"Mount via git…"),t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>{ue(null),he($.absPath)}},"Rename"),$.type==="file"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ct($.absPath)}},"Download"),t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>mt($.absPath,$.type)},"Delete"))))}),qt=({node:i,level:s,position:f,setSize:u,expandedNodePaths:w,onToggle:h,selectedNode:C,focusPath:g,focusedNode:R,selectPath:b,generatePath:D,getChildren:P,onContextMenu:F,renamingPath:X,onRename:K,onRenameCancel:v,parentPath:Y="",dropIndicator:k,onDragStart:m,onDragEnd:A,onDragEnter:j,onDragOver:I,onDragLeave:H,onDrop:te,rootPath:re,onDoubleClickFile:J,pathBadges:ne})=>{const y=D(i,Y),d=w[y],S=X===y,B=t.useRef(null),[W,V]=t.useState(i.name),q=t.useRef(!1),le=(k==null?void 0:k.path)===y,de=le&&(k==null?void 0:k.state)==="valid",G=le&&(k==null?void 0:k.state)==="invalid",Q=!!m&&!S&&y!==re,ce=t.useRef(null),Re={onDragEnter:E=>j==null?void 0:j(E,i,y),onDragOver:E=>I==null?void 0:I(E,i,y),onDragLeave:E=>H==null?void 0:H(E,i,y),onDrop:E=>te==null?void 0:te(E,i,y)},ae=P(i,y)??[];t.useEffect(()=>{var E;S?(V(i.name),q.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var Ee;(Ee=B.current)==null||Ee.select()}):(E=B.current)==null||E.select()):q.current=!1},[S,i.name]);const ke=()=>{i.type==="folder"&&h(y,i,!d)},we=E=>{var Ee,pe;if(E.key==="ArrowLeft")d?ke():(Ee=document.querySelector(`[data-path="${CSS.escape(Y)}"]`))==null||Ee.focus(),E.preventDefault(),E.stopPropagation();else if(E.key==="ArrowRight"){if(d){if(ae!=null&&ae.length){const $=D(ae[0],y);(pe=document.querySelector(`[data-path="${CSS.escape($)}"]`))==null||pe.focus()}}else ke();E.preventDefault(),E.stopPropagation()}else E.key===" "||E.key==="Space"||E.key==="Spacebar"?(i.type==="folder"&&h(y,i,!d),E.preventDefault()):E.key==="Enter"&&(i.type==="folder"?h(y,i,!d):(b(y,!1),g(y),J?J(y):b(y,!0)),E.preventDefault())},Ce=E=>{F==null||F(E,i,y)},oe=E=>{E.preventDefault(),q.current=!0,K==null||K(y,W)},je=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),q.current=!0,v==null||v(y);return}(E.key==="ArrowLeft"||E.key==="ArrowRight"||E.key==="ArrowUp"||E.key==="ArrowDown")&&E.stopPropagation()},ve=()=>{q.current||v==null||v(y),q.current=!1},Te=()=>{if(i.type==="folder"){ke(),b(y),g(y);return}const E=ce.current!==null;if(E&&ce.current&&clearTimeout(ce.current),ce.current=null,E){J?J(y):b(y,!0);return}b(y,!1),g(y),b(y,!0),ce.current=window.setTimeout(()=>{ce.current=null},300)};return t.useEffect(()=>()=>{ce.current!==null&&typeof window<"u"&&clearTimeout(ce.current)},[]),t.createElement(t.Fragment,null,t.createElement(z.__experimentalTreeGridRow,{level:s,positionInSet:f,setSize:u},t.createElement(z.__experimentalTreeGridCell,null,()=>t.createElement(t.Fragment,null,S?t.createElement("form",{onSubmit:oe,className:Ae(ye.fileNodeButton,ye.renaming,"file-node-button",{[ye.selected]:C===y,[ye.focused]:R===y,[ye.dropTarget]:de,[ye.dropTargetInvalid]:G}),"data-path":y,onContextMenu:Ce,...Re},t.createElement(Vt,{node:i,isOpen:i.type==="folder"&&d,level:s,hideName:!0,badge:ne==null?void 0:ne[y]}),t.createElement("input",{ref:B,className:ye.renameInput,value:W,onChange:E=>V(E.target.value),onBlur:ve,onFocus:()=>g(y),onKeyDown:je})):t.createElement(z.Button,{...Re,draggable:Q,onDragStart:E=>m==null?void 0:m(E,i,y),onDragEnd:E=>A==null?void 0:A(E,i,y),onClick:Te,onKeyDown:we,onFocus:()=>{g(y)},onContextMenu:Ce,className:Ae(ye.fileNodeButton,"file-node-button",{[ye.selected]:C===y,[ye.focused]:R===y,[ye.dropTarget]:de,[ye.dropTargetInvalid]:G}),"data-path":y,"data-expanded":d?"true":"false"},t.createElement(Vt,{node:i,isOpen:i.type==="folder"&&d,level:s,badge:ne==null?void 0:ne[y]}))))),d&&ae&&ae.map((E,Ee)=>t.createElement(qt,{key:E.name,node:E,level:s+1,position:Ee+1,setSize:ae.length,expandedNodePaths:w,onToggle:h,selectedNode:C,focusPath:g,focusedNode:R,selectPath:b,generatePath:D,getChildren:P,onContextMenu:F,renamingPath:X,onRename:K,onRenameCancel:v,parentPath:y,dropIndicator:k,onDragStart:m,onDragEnd:A,onDragEnter:j,onDragOver:I,onDragLeave:H,onDrop:te,rootPath:re,onDoubleClickFile:J,pathBadges:ne})))},Vt=({node:i,level:s,isOpen:f,hideName:u=!1,badge:w})=>{const h=[];for(let b=0;b<s;b++)h.push(" ");const C=t.useRef(null),[g,R]=t.useState(null);return t.useEffect(()=>{if(!g)return;const b=()=>R(null);return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[g]),t.createElement(t.Fragment,null,t.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:h.join("")}}),i.type==="folder"?t.createElement(jt,{width:16,icon:f?hr:wr}):t.createElement("div",{style:{width:16}}," "),t.createElement(jt,{width:16,icon:i.type==="folder"?Wt:Ut}),!u&&t.createElement("span",{className:ye.fileName},i.name),w?t.createElement("span",{ref:C,className:ye.pathBadge,"aria-label":w.tooltip,onMouseEnter:()=>{var D;const b=(D=C.current)==null?void 0:D.getBoundingClientRect();b&&R({top:b.top,left:b.left})},onMouseLeave:()=>R(null)},w.icon,g?Ht.createPortal(t.createElement("span",{className:ye.pathBadgeTooltip,role:"tooltip",style:{top:g.top,left:g.left}},w.tooltip),document.body):null):null)},Nr="_control_kp9d9_1",Ar="_browse-label_kp9d9_11",Fr="_path-preview_kp9d9_37",Ir="_modal_kp9d9_43",Mr="_modal-footer_kp9d9_48",Je={control:Nr,browseLabel:Ar,pathPreview:Fr,modal:Ir,modalFooter:Mr};function Lr({path:i}){if(!i)return t.createElement("div",{className:Je.pathPreview},t.createElement("i",null,"Select a path"));const s=i.split("/");let f=(s.length>2?"/":"")+s.pop();f.length>10&&(f=f.substring(f.length-10));const u=i.substring(0,i.length-f.length);return t.createElement("div",{className:Je.pathPreview,"data-content-start":u,"data-content-end":f})}function jr({value:i="",onChange:s,filesystem:f}){const[u,w]=t.useState(!1),h=()=>w(!0),C=()=>w(!1),[g,R]=t.useState(i||null);function b(D){D==null||D.preventDefault(),s(g||""),C()}return t.createElement(t.Fragment,null,t.createElement(z.Button,{variant:"tertiary",className:Je.control,onClick:h},t.createElement("span",{className:Je.browseLabel},"Browse"),t.createElement(Lr,{path:i||""})),u&&t.createElement(z.Modal,{title:"Select a path ",onRequestClose:C,className:Je.modal},t.createElement("form",{onSubmit:b},t.createElement(zt,{filesystem:f,initialSelectedPath:i,onSelect:R}),t.createElement("div",{className:Je.modalFooter},t.createElement(z.Button,{type:"submit",variant:"primary"},"Select Path")))))}const Or="_container_1h0az_1",Br="_header_1h0az_9",Vr="_filename_1h0az_18",$r="_downloadLink_1h0az_26",Hr="_previewArea_1h0az_38",Wr="_imagePreview_1h0az_51",Ur="_videoPreview_1h0az_57",zr="_audioPreview_1h0az_64",qr="_unsupportedMessage_1h0az_68",Gr="_actions_1h0az_74",Le={container:Or,header:Br,filename:Vr,downloadLink:$r,previewArea:Hr,imagePreview:Wr,videoPreview:Ur,audioPreview:zr,unsupportedMessage:qr,actions:Gr},Yr=i=>{if(!i)return{isImage:!1,isVideo:!1,isAudio:!1};const s=i.toLowerCase();return{isImage:s.startsWith("image/"),isVideo:s.startsWith("video/"),isAudio:s.startsWith("audio/")}};function Zr({filename:i,mimeType:s,dataUrl:f,downloadUrl:u,showHeader:w=!0}){const{isImage:h,isVideo:C,isAudio:g}=Yr(s),R=w!==!1,b=!!(u&&i),D=()=>b?t.createElement("a",{className:Le.downloadLink,href:u,download:i},"Download"):null,P=()=>h?t.createElement("img",{className:Le.imagePreview,src:f,alt:i||"Preview"}):C?t.createElement("video",{className:Le.videoPreview,controls:!0,preload:"metadata"},t.createElement("source",{src:f,type:s}),"Your browser does not support the video tag."):g?t.createElement("audio",{className:Le.audioPreview,controls:!0},t.createElement("source",{src:f,type:s}),"Your browser does not support the audio tag."):t.createElement("div",{className:Le.unsupportedMessage},t.createElement("p",null,"Preview unavailable for this file type."),b?t.createElement("p",null,D()):t.createElement("p",null,"Download the file to inspect its contents."));return t.createElement("div",{className:Le.container},R&&t.createElement("div",{className:Le.header},t.createElement("span",{className:Le.filename,title:i},i),D()),t.createElement("div",{className:Le.previewArea},P()),!R&&b&&t.createElement("div",{className:Le.actions},D()))}const Pt=new Map,Kr=async i=>{var w;if(!i)return lt.php();const s=(w=i.split(".").pop())==null?void 0:w.toLowerCase();if(!s||s==="php")return lt.php();const f=i;if(Pt.has(f))return Pt.get(f);let u;switch(s){case"css":u=await import("@codemirror/lang-css").then(h=>h.css());break;case"js":case"jsx":case"ts":case"tsx":u=await import("@codemirror/lang-javascript").then(h=>h.javascript({jsx:s==="jsx"||s==="tsx",typescript:s==="ts"||s==="tsx"}));break;case"json":u=await import("@codemirror/lang-json").then(h=>h.json());break;case"html":case"htm":u=await import("@codemirror/lang-html").then(h=>h.html());break;case"md":case"markdown":u=await import("@codemirror/lang-markdown").then(h=>h.markdown());break;default:u=lt.php()}return Pt.set(f,u),u};class Jr{constructor(s){this.view=s,this.handleClick=this.handleClick.bind(this),this.view.dom.addEventListener("mousedown",this.handleClick)}handleClick(s){const f=s.target;if((f.classList.contains("cm-scroller")||f.classList.contains("cm-content"))&&this.view.posAtCoords({x:s.clientX,y:s.clientY})===null){const w=this.view.state.doc.length,h=Ve.EditorSelection.create([Ve.EditorSelection.range(w,w)]);this.view.dispatch({selection:h,effects:Pe.EditorView.scrollIntoView(w,{y:"center"})}),this.view.focus(),s.preventDefault()}}destroy(){this.view.dom.removeEventListener("mousedown",this.handleClick)}}const Xr=Pe.ViewPlugin.define(i=>new Jr(i)),Nt=t.forwardRef(function({code:s,onChange:f,currentPath:u,language:w,className:h,onSaveShortcut:C,readOnly:g=!1,additionalExtensions:R},b){const D=t.useRef(null),P=t.useRef(null),F=t.useRef(new Ve.Compartment),X=t.useRef(new Ve.Compartment),K=t.useRef(new Ve.Compartment),v=t.useRef(s),Y=t.useRef(f),k=t.useRef(!1);return t.useImperativeHandle(b,()=>({focus:()=>{var m;(m=P.current)==null||m.focus()},blur:()=>{const m=P.current;m&&m.contentDOM.blur()},getCursorPosition:()=>P.current?P.current.state.selection.main.anchor:null,setCursorPosition:m=>{if(!P.current)return;const A=Math.min(m,P.current.state.doc.length),j=Ve.EditorSelection.create([Ve.EditorSelection.range(A,A)]);P.current.dispatch({selection:j,scrollIntoView:!0})}})),t.useEffect(()=>{v.current=s},[s]),t.useEffect(()=>{Y.current=f},[f]),t.useEffect(()=>{if(P.current)return;const m=D.current;if(!m)return;const A=Ve.EditorState.create({doc:s,extensions:[K.current.of(R??[]),Pe.lineNumbers(),Pe.highlightActiveLineGutter(),Pe.highlightActiveLine(),Ke.foldGutter(),Pe.dropCursor(),Pe.rectangularSelection(),Pe.crosshairCursor(),Xr,F.current.of(w??lt.php()),X.current.of(Pe.EditorView.editable.of(!g)),Ke.syntaxHighlighting(Ke.defaultHighlightStyle),Ke.indentOnInput(),Ke.bracketMatching(),vt.closeBrackets(),wt.history(),It.highlightSelectionMatches(),vt.autocompletion(),Pe.EditorView.updateListener.of(I=>{if(!I.docChanged)return;const H=I.state.doc.toString();H!==v.current&&(v.current=H,Y.current(H))}),Pe.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(C==null||C(),!0)},...vt.closeBracketsKeymap,...vt.completionKeymap,...Ke.foldKeymap,...It.searchKeymap,...wt.historyKeymap,...wt.defaultKeymap,wt.indentWithTab])]}),j=new Pe.EditorView({state:A,parent:m});return P.current=j,()=>{j.destroy(),P.current=null}},[]),t.useEffect(()=>{const m=P.current;m&&m.dispatch({effects:K.current.reconfigure(R??[])})},[R]),t.useEffect(()=>{const m=P.current;if(!m)return;const A=m.state.doc.toString();s!==A&&m.dispatch({changes:{from:0,to:m.state.doc.length,insert:s}})},[s]),t.useEffect(()=>{var H;const m=P.current;if(!m)return;if(w){m.dispatch({effects:F.current.reconfigure(w)});return}const A=(H=u==null?void 0:u.split(".").pop())==null?void 0:H.toLowerCase();(!A||A==="php")&&m.dispatch({effects:F.current.reconfigure(lt.php())});let I=!1;return Kr(u).then(te=>{I||!P.current||P.current.dispatch({effects:F.current.reconfigure(te)})}),()=>{I=!0}},[u,w]),t.useEffect(()=>{const m=P.current;m&&(m.hasFocus&&(k.current=!0),m.dispatch({effects:X.current.reconfigure(Pe.EditorView.editable.of(!g))}))},[g]),t.useLayoutEffect(()=>{const m=P.current;m&&k.current&&!m.hasFocus&&(m.focus(),k.current=!1)},[u,g]),t.createElement("div",{ref:D,className:h})});Nt.displayName="CodeEditor";const Qr="_fileExplorerContainer_rb5rx_1",en="_dropActive_rb5rx_9",tn="_fileExplorerHeader_rb5rx_14",rn="_fileExplorerTitle_rb5rx_23",nn="_fileExplorerSubsectionTitle_rb5rx_31",an="_fileExplorerActions_rb5rx_35",on="_fileExplorerButton_rb5rx_41",sn="_fileExplorerIconButton_rb5rx_71",ln="_fileExplorerTree_rb5rx_83",cn="_dockPresentation_rb5rx_92",un="_fileExplorerUploadButton_rb5rx_152",be={fileExplorerContainer:Qr,dropActive:en,fileExplorerHeader:tn,fileExplorerTitle:rn,fileExplorerSubsectionTitle:nn,fileExplorerActions:an,fileExplorerButton:on,fileExplorerIconButton:sn,fileExplorerTree:ln,dockPresentation:cn,fileExplorerUploadButton:un},At=1024*1024,Gt=i=>{const s=i.byteLength;for(let f=0;f<Math.min(s,4096);f++)if(i[f]===0)return!0;try{return new TextDecoder("utf-8",{fatal:!0}).decode(i),!1}catch{return!0}},Dt=(i,s)=>{const f=new Blob([i]),u=URL.createObjectURL(f);return setTimeout(()=>URL.revokeObjectURL(u),6e4),{url:u,filename:s}};async function fn(i,s=At){const f=dn(i);if(f!==void 0&&f>s)return{type:"too-large"};if(typeof i.stream=="function")return mn(i,s);const u=new Uint8Array(await i.arrayBuffer());return u.byteLength>s?{type:"too-large"}:{type:"inline",data:u}}function dn(i){if(typeof i.filesize=="number")return i.filesize;if(typeof i.size=="number")return i.size}async function mn(i,s){const f=i.stream().getReader(),u=[];let w=0;try{for(;;){const{done:h,value:C}=await f.read();if(h)return{type:"inline",data:U.concatUint8Arrays(u)};if(C){if(w+=C.byteLength,w>s)return await f.cancel().catch(()=>{}),{type:"too-large"};u.push(C)}}}finally{f.releaseLock()}}const Yt=i=>{const s=i.split(".").pop();return Lt[s]||Lt._default},Zt=i=>i.startsWith("image/")||i.startsWith("video/")||i.startsWith("audio/"),Kt=t.forwardRef(function({filesystem:s,currentPath:f,selectedDirPath:u,setSelectedDirPath:w,onFileOpened:h,onSelectionCleared:C,onShowMessage:g,documentRoot:R,readOnly:b=!1,title:D="Files",mobileSubsectionTitle:P,showBinaryPreviewHeader:F=!0,dockPresentation:X=!1,useWordPressTooltips:K=!1,pathBadges:v,onMountFromGit:Y,onPathRenamed:k},m){const A=t.useRef(null),j=t.useRef(null);t.useImperativeHandle(m,()=>({refreshPath:async d=>{var S;await((S=A.current)==null?void 0:S.refresh(d))},revealPath:async d=>{var S;await((S=A.current)==null?void 0:S.revealPath(d))}}),[]);const I=t.useMemo(()=>f?U.dirname(f):u??R,[f,R]),[H,te]=t.useState(!1);t.useEffect(()=>{!f||!A.current||(w(U.dirname(f)),A.current.focusPath(f,{select:!0,domFocus:!1,notify:!1}),A.current.expandToPath(f))},[f,w]);const re=async(d,S)=>{try{const B=await s.read(d),W=await fn(B);if(W.type==="too-large"){const de=At/1024/1024;if(!X){await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,`File too large to open (>${de}MB).`),t.createElement("p",null,"Open or download it outside the in-browser editor.")));return}const G=U.basename(d)||"download";await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,`File too large to open (>${de}MB).`),t.createElement("p",null,t.createElement(z.Button,{type:"button",variant:"link",onClick:()=>{J(d,G)}},"Download ",G))));return}const V=W.data,q=U.basename(d)||"download";if(Gt(V)){const de=Yt(q),{url:G,filename:Q}=Dt(V,q);if(Zt(de)){const ce=new Blob([V],{type:de}),Re=URL.createObjectURL(ce);await g(d,t.createElement(Mt.BinaryFilePreview,{filename:Q,mimeType:de,dataUrl:Re,downloadUrl:G,showHeader:F}));return}await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,"Binary file. Cannot be edited."),t.createElement("p",null,t.createElement("a",{href:G,download:Q},"Download ",Q))));return}const le=new TextDecoder("utf-8").decode(V);await h(d,le,S)}catch(B){Ue.logger.error("Could not open file",B),await g(null,"Could not open file.")}},J=async(d,S)=>{try{const B=await s.read(d),W=new Uint8Array(await B.arrayBuffer()),{url:V}=Dt(W,S),q=document.createElement("a");q.href=V,q.download=S,document.body.appendChild(q),q.click(),document.body.removeChild(q)}catch(B){Ue.logger.error("Could not download file",B),await g(d,"Could not download file.")}},ne=d=>{var B;const S=Array.from(d.target.files??[]);d.target.value="",S.length!==0&&((B=A.current)==null||B.importFiles(S,u??R).catch(W=>Ue.logger.error("Failed to import files",W)))},y=d=>{var S;d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),!b&&((S=A.current)==null||S.importDataTransfer(d.dataTransfer,u??R).catch(B=>Ue.logger.error("Failed to import dropped files",B))))};return t.createElement("div",{className:Ae(be.fileExplorerContainer,{[be.dropActive]:H,[be.dockPresentation]:X}),onDragEnter:d=>{d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),b||te(!0))},onDragOver:d=>{d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),d.dataTransfer.dropEffect=b?"none":"copy")},onDragLeave:d=>{const S=d.relatedTarget;(!S||!d.currentTarget.contains(S))&&te(!1)},onDropCapture:()=>te(!1),onDrop:y},t.createElement("div",{className:be.fileExplorerHeader},t.createElement("span",{className:be.fileExplorerTitle},D),P?t.createElement("span",{className:be.fileExplorerSubsectionTitle},P):null,b?null:t.createElement("div",{className:be.fileExplorerActions},t.createElement(kt,{label:"Create new file",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton),type:"button",onClick:()=>{A.current&&A.current.createFile()},"aria-label":"Create new file",title:K?void 0:"Create new file"},X?t.createElement(pn,null):t.createElement(z.Icon,{icon:Er,size:20}))),t.createElement(kt,{label:"Create new folder",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton),type:"button",onClick:()=>{A.current&&A.current.createFolder()},"aria-label":"Create new folder",title:K?void 0:"Create new folder"},X?t.createElement(hn,null):t.createElement(z.Icon,{icon:vr,size:20}))),t.createElement(kt,{label:"Upload files",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton,be.fileExplorerUploadButton),type:"button",onClick:()=>{var d;return(d=j.current)==null?void 0:d.click()},"aria-label":"Upload files",title:K?void 0:"Upload files"},t.createElement(z.Icon,{icon:gr,size:X?16:20}))),t.createElement("input",{ref:j,type:"file",multiple:!0,style:{display:"none"},onChange:ne}))),t.createElement("div",{className:be.fileExplorerTree},t.createElement(Mt.FilePickerTree,{ref:A,readOnly:b,filesystem:s,root:R,initialSelectedPath:I,pathBadges:v,onMountFromGit:Y,onPathRenamed:k,onSelect:async d=>{if(!d){w(R),await C();return}try{if(await s.isDir(d)){w(d);return}}catch{}w(U.dirname(d)),await re(d,!1)},onDoubleClickFile:async d=>{await re(d,!0)}})))});function kt({label:i,useWordPressTooltip:s,children:f}){return s?t.createElement(z.Tooltip,{text:i,delay:0,placement:"top"},f):f}const pn=()=>t.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},t.createElement("path",{d:"M11 6h7l5 5v12a2 2 0 0 1-2 2H11a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("path",{d:"M18 6v5h5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("g",{transform:"translate(19 19)"},t.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),t.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),hn=()=>t.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},t.createElement("path",{d:"M6 9h7l3 3h10v11a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V9z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("path",{d:"M6 9V8a2 2 0 0 1 2-2h5l3 3",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("g",{transform:"translate(19 19)"},t.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),t.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),wn="_container_a36e6_1",vn="_content_a36e6_9",En="_sidebarWrapper_a36e6_17",gn="_editorWrapper_a36e6_28",yn="_editorHeader_a36e6_37",_n="_editorPath_a36e6_49",bn="_editorPathDirectory_a36e6_61",Cn="_editorPathFilename_a36e6_68",xn="_editorPathPlaceholder_a36e6_73",Rn="_editorPathPortaled_a36e6_77",Sn="_editorHeaderActions_a36e6_83",Pn="_saveStatus_a36e6_90",kn="_saveStatusSaving_a36e6_97",Tn="_saveStatusPending_a36e6_98",Dn="_saveStatusError_a36e6_102",Nn="_editor_a36e6_28",An="_placeholder_a36e6_124",Fn="_messageArea_a36e6_135",In="_mobileToggle_a36e6_171",Mn="_mobileOverlay_a36e6_175",Ln="_dockPresentation_a36e6_181",jn="_dockDirtyIndicator_a36e6_205",On="_dockSaveButton_a36e6_214",Bn="_sidebarOpen_a36e6_269",Vn="_editorHeaderPathPortaled_a36e6_367",Z={container:wn,content:vn,sidebarWrapper:En,editorWrapper:gn,editorHeader:yn,editorPath:_n,editorPathDirectory:bn,editorPathFilename:Cn,editorPathPlaceholder:xn,editorPathPortaled:Rn,editorHeaderActions:Sn,saveStatus:Pn,saveStatusSaving:kn,saveStatusPending:Tn,saveStatusError:Dn,editor:Nn,placeholder:An,messageArea:Fn,mobileToggle:In,mobileOverlay:Mn,dockPresentation:Ln,dockDirtyIndicator:jn,dockSaveButton:On,sidebarOpen:Bn,editorHeaderPathPortaled:Vn},$n=1500,Hn=700,Wn=1e3,O={IDLE:"idle",PENDING:"pending",SAVING:"saving",SAVED:"saved",ERROR:"error"},Un=t.forwardRef(function({filesystem:s,isVisible:f=!0,documentRoot:u,initialPath:w=null,placeholderText:h="Select a file to view or edit its contents.",dockPresentation:C=!1,mobileHeaderTarget:g=null,pathBadges:R,onMountFromGit:b,onPathRenamed:D},P){const F=t.useRef(null);t.useImperativeHandle(P,()=>({refreshPath:async x=>{var _;await((_=F.current)==null?void 0:_.refreshPath(x))},revealPath:async x=>{var _;await((_=F.current)==null?void 0:_.revealPath(x))}}),[]);const[X,K]=t.useState(u),[v,Y]=t.useState(null),[k,m]=t.useState(""),[A,j]=t.useState(!0),[I,H]=t.useState(O.IDLE),[te,re]=t.useState(null),[J,ne]=t.useState("idle"),[y,d]=t.useState(!1),[S,B]=t.useState(null),W=t.useRef(null),V=t.useRef(null),q=t.useRef(!1),le=t.useRef(v),de=t.useRef(s),G=t.useRef(null),Q=t.useRef(null),ce=t.useRef(new WeakMap),Re=t.useRef(!0),ae=t.useRef(new Map),ke=t.useRef(!1);de.current=s,t.useEffect(()=>{le.current=v},[v]);const we=t.useCallback(async x=>{const{filesystem:_,path:me,content:fe}=x,ie=Q.current===x,Se=ce.current,Ie=(Se.get(_)??Promise.resolve()).catch(()=>{}).then(()=>_.writeFile(me,fe));Se.set(_,Ie);let De=!1;try{await Ie}catch(et){De=!0,Ue.logger.error("Failed to save file",et)}const ze=Re.current&&Se.get(_)===Ie&&de.current===_&&le.current===me&&G.current===null;Se.get(_)===Ie&&Se.delete(_),Q.current===x&&(Q.current=null),ze&&(H(De?O.ERROR:O.SAVED),re(De?"Could not save changes. Try again.":null),ie&&ne(De?"idle":"saved"))},[]),Ce=t.useCallback(()=>{const x=G.current;x&&(V.current!==null&&(window.clearTimeout(V.current),V.current=null),G.current=null,we(x))},[we]);t.useEffect(()=>(Re.current=!0,()=>{Re.current=!1}),[]),t.useEffect(()=>()=>{var x;((x=G.current)==null?void 0:x.filesystem)===s&&Ce()},[u,s,Ce]),t.useEffect(()=>{q.current=!0,K(u),m(""),Y(null),j(!0),H(O.IDLE),re(null),d(!1),B(null),ae.current.clear(),ke.current=!1},[u,s]),t.useEffect(()=>{if(!s||!w||ke.current)return;let x=!1;return(async()=>{try{if(await s.fileExists(w)&&!x){const fe=await s.readFileAsText(w);if(x)return;q.current=!0,Y(w),m(fe),j(!1),H(O.IDLE),re(null),setTimeout(()=>{var ie;(ie=W.current)==null||ie.focus()},100)}}catch(me){Ue.logger.debug("Could not auto-open initial path:",me)}finally{x||(ke.current=!0)}})(),()=>{x=!0}},[s,w]),t.useEffect(()=>{if(!s||!v){V.current!==null&&(window.clearTimeout(V.current),V.current=null),G.current=null,v||H(O.IDLE);return}if(q.current){q.current=!1,G.current=null;return}V.current!==null&&(window.clearTimeout(V.current),V.current=null),H(O.PENDING);const x={filesystem:s,path:v,content:k};G.current=x;const _=window.setTimeout(()=>{G.current===x&&(V.current=null,G.current=null,H(O.SAVING),we(x))},$n);return V.current=_,()=>{V.current===_&&(window.clearTimeout(_),V.current=null)}},[k,v,s,we]),t.useEffect(()=>{if(I!==O.SAVED)return;const x=window.setTimeout(()=>{H(_=>_===O.SAVED?O.IDLE:_)},2e3);return()=>window.clearTimeout(x)},[I]),t.useEffect(()=>{J==="idle"||I===O.SAVING||I===O.SAVED||ne("idle")},[J,I]),t.useEffect(()=>{if(J!=="saved")return;const x=window.setTimeout(()=>ne("idle"),Wn);return()=>window.clearTimeout(x)},[J]),t.useEffect(()=>{if(J!=="waiting")return;const x=window.setTimeout(()=>ne(_=>_==="waiting"?"saving":_),Hn);return()=>window.clearTimeout(x)},[J]);const oe=t.useCallback(async(x,_,me=!0)=>{var ie;const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&le.current&&ae.current.set(le.current,fe),q.current=!0,Y(x),m(_),B(null),j(!1),H(O.IDLE),re(null),d(!1),setTimeout(()=>{var Me,Ie,De;const Se=ae.current.get(x);Se!==void 0&&((Me=W.current)==null||Me.setCursorPosition(Se)),me?(Ie=W.current)==null||Ie.focus():(De=W.current)==null||De.blur()},50)},[]);t.useEffect(()=>{var me;if(!v)return;const x=setInterval(()=>{var ie;const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&ae.current.set(v,fe)},1e3),_=(me=W.current)==null?void 0:me.getCursorPosition();return _!=null&&ae.current.set(v,_),()=>{var ie;clearInterval(x);const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&ae.current.set(v,fe)}},[v]),t.useEffect(()=>{if(!f||!v)return;const x=setTimeout(()=>{var me;const _=ae.current.get(v);_!==void 0&&((me=W.current)==null||me.setCursorPosition(_))},100);return()=>clearTimeout(x)},[f,v]);const je=t.useCallback(async()=>{var _;const x=(_=W.current)==null?void 0:_.getCursorPosition();x!=null&&le.current&&ae.current.set(le.current,x),q.current=!0,Y(null),m(""),B(null),j(!0),H(O.IDLE),re(null)},[]),ve=t.useCallback(async(x,_)=>{q.current=!0,Y(null),typeof _=="string"?(m(_),B(null)):(m(""),B(_)),j(!0),H(O.IDLE),re(null),d(!1)},[]),Te=t.useCallback(()=>{G.current&&(Q.current=G.current,ne("waiting"),H(O.SAVING),Ce())},[Ce]),E=t.useCallback(()=>{!G.current&&I===O.ERROR&&s&&v&&(G.current={filesystem:s,path:v,content:k}),G.current&&(re(null),Te())},[k,v,s,Te,I]),Ee=zn(I,te),pe=qn(I,Z),$=Gn(I);let ue="Save";I===O.ERROR?ue="Retry":I===O.SAVED&&J==="saved"?ue="Saved":I===O.SAVING&&J==="saving"&&(ue="Saving…");const $e=I===O.PENDING||I===O.SAVING||I===O.ERROR;if(!s)return t.createElement("div",{className:Ae(Z.container,{[Z.dockPresentation]:C})},t.createElement("div",{className:Z.placeholder},h));const he=v?U.dirname(v):null,ge=v?U.basename(v):null,Oe=t.createElement("div",{className:Ae(Z.editorPath,{[Z.editorPathPlaceholder]:!(v!=null&&v.length),[Z.editorPathPortaled]:g}),title:v??void 0},he&&ge?t.createElement(t.Fragment,null,t.createElement("span",{className:Z.editorPathDirectory},he==="/"?"":he),t.createElement("span",{className:Z.editorPathFilename},"/",ge)):`Browse files under ${u}`);return t.createElement("div",{className:Ae(Z.container,{[Z.dockPresentation]:C})},t.createElement("div",{className:Ae(Z.content,{[Z.sidebarOpen]:y})},t.createElement("div",{className:Z.mobileOverlay,onClick:()=>d(!1)}),t.createElement("aside",{className:Z.sidebarWrapper},t.createElement(Kt,{ref:F,filesystem:s,currentPath:v,selectedDirPath:X,setSelectedDirPath:K,onFileOpened:oe,onSelectionCleared:je,onShowMessage:ve,documentRoot:u,dockPresentation:C,useWordPressTooltips:C,pathBadges:R,onMountFromGit:b,onPathRenamed:D})),t.createElement("section",{className:Z.editorWrapper},t.createElement("div",{className:Ae(Z.editorHeader,{[Z.editorHeaderPathPortaled]:g})},t.createElement(z.Button,{className:Z.mobileToggle,variant:"secondary",onClick:()=>d(x=>!x)},y?"Hide files":"Browse files"),g?Ht.createPortal(Oe,g):Oe,C&&!A&&v?t.createElement("div",{className:Z.editorHeaderActions},$e?t.createElement("span",{className:Z.dockDirtyIndicator,"aria-hidden":"true"}):null,t.createElement(z.Tooltip,{text:$,placement:"top"},t.createElement(z.Button,{variant:"secondary",className:Z.dockSaveButton,isDestructive:I===O.ERROR,onClick:E},ue))):C?null:t.createElement("div",{className:Ae(Z.saveStatus,pe)},Ee),C&&!A&&v?t.createElement(z.VisuallyHidden,{role:"status","aria-live":"polite"},$):null),te?t.createElement("div",{style:{padding:"8px 16px"}},t.createElement(z.Notice,{status:"error",isDismissible:!1},te)):null,v||k||S?S?t.createElement("div",{className:Z.messageArea},S):t.createElement(Nt,{ref:W,code:k,onChange:m,currentPath:v,className:Z.editor,onSaveShortcut:Te,readOnly:A}):t.createElement("div",{className:Z.placeholder},h))))});function zn(i,s){switch(i){case O.PENDING:case O.SAVING:return"Saving…";case O.SAVED:return"Saved";case O.ERROR:return s??"Save failed";default:return""}}function qn(i,s){switch(i){case O.PENDING:return s.saveStatusPending;case O.SAVING:return s.saveStatusSaving;case O.ERROR:return s.saveStatusError;default:return}}function Gn(i){switch(i){case O.PENDING:return"Unsaved changes. Click to save now.";case O.SAVING:return"Saving changes…";case O.ERROR:return"Saving failed. Click to retry.";default:return"All changes saved."}}const Yn="_modal_1i30f_1",Zn="_actions_1i30f_5",$t={modal:Yn,actions:Zn};function Kn({kind:i,isBusy:s,error:f,onSubmit:u,onCancel:w}){const[h,C]=t.useState(""),[g,R]=t.useState(""),[b,D]=t.useState(""),P=h.trim(),F=v=>{const Y=Jn(v);if(Y){C(Y.url),R(Y.ref);return}C(v)},X=()=>{!P||s||u({url:P,ref:g.trim()||"HEAD",path:b.trim()||void 0})},K=()=>{s||w()};return t.createElement(z.Modal,{title:`Mount ${i} via git`,onRequestClose:K,isDismissible:!s,className:$t.modal},t.createElement("form",{onSubmit:v=>{v.preventDefault(),X()},style:{display:"flex",flexDirection:"column",gap:12}},t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Repository URL",value:h,onChange:F,placeholder:"github.com/owner/repo",autoFocus:!0,disabled:s}),t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Branch, tag, or commit",value:g,onChange:v=>R(v),placeholder:"HEAD",disabled:s}),t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Path within the repository (optional)",value:b,onChange:v=>D(v),placeholder:"Leave empty to use the repository root",disabled:s}),f?t.createElement("p",{role:"alert"},f):null,t.createElement(z.Flex,{justify:"end",className:$t.actions},t.createElement(z.Button,{type:"button",variant:"link",disabled:s,onClick:w},"Cancel"),t.createElement(z.Button,{type:"submit",variant:"primary",isBusy:s,disabled:!P||s},"Mount ",i))))}function Jn(i){const s=i.trim().match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/tree\/(.+)$/i);if(!s)return null;const[,f,u,w]=s;return{url:`https://github.com/${f}/${u.replace(/\.git$/i,"")}`,ref:w}}exports.BinaryFilePreview=Zr;exports.ClockIcon=cr;exports.CodeEditor=Nt;exports.FileExplorerSidebar=Kt;exports.FilePickerControl=jr;exports.FilePickerTree=zt;exports.MAX_INLINE_FILE_BYTES=At;exports.MountGitDirectoryModal=Kn;exports.PlaygroundFileEditor=Un;exports.SiteManagerIcon=dr;exports.WordPressIcon=lr;exports.createDownloadUrl=Dt;exports.file=Ut;exports.folder=Wt;exports.getLogoDataURL=fr;exports.getMimeType=Yt;exports.isPreviewableBinary=Zt;exports.layout=ur;exports.playgroundLogo=ir;exports.seemsLikeBinary=Gt;exports.temporaryStorage=sr;
|
|
30
|
+
<%s key={someKey} {...props} />`,Rt,He,Xt,He),pt[He+Rt]=!0}}return e===u?xt(se):Ct(se),se}}function r(e,n,l){return ht(e,n,l,!0)}function o(e,n,l){return ht(e,n,l,!1)}var s=o,c=r;st.Fragment=u,st.jsx=s,st.jsxs=c}()),st}process.env.NODE_ENV==="production"?Tt.exports=hr():Tt.exports=wr();var Fe=Tt.exports,Xe=a=>Et.createElement("path",a),Qe=Et.forwardRef(({className:a,isPressed:i,...f},u)=>{const w={...f,className:ir(a,{"is-pressed":i})||void 0,"aria-hidden":!0,focusable:!1};return Fe.jsx("svg",{...w,ref:u})});Qe.displayName="SVG";const vr=Fe.jsx(Qe,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Fe.jsx(Xe,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"})}),Er=Fe.jsx(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:Fe.jsx(Xe,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"})}),gr=Fe.jsx(Qe,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Fe.jsx(Xe,{fillRule:"evenodd",clipRule:"evenodd",d:"M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z"})}),yr=Fe.jsxs(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[Fe.jsx(Xe,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),Fe.jsx(Xe,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),_r=Fe.jsx(Qe,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:Fe.jsx(Xe,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})}),br="_file-picker-tree_12ffp_1",Cr="_file-node-button_12ffp_17",xr="_selected_12ffp_56",Rr="_focused_12ffp_75",Sr="_dropTarget_12ffp_83",Pr="_dropTargetInvalid_12ffp_95",kr="_renaming_12ffp_104",Tr="_renameInput_12ffp_109",Dr="_file-name_12ffp_124",Nr="_path-badge_12ffp_128",Ar="_path-badge-tooltip_12ffp_140",ye={filePickerTree:br,fileNodeButton:Cr,selected:xr,focused:Rr,dropTarget:Sr,dropTargetInvalid:Pr,renaming:kr,renameInput:Tr,fileName:Dr,pathBadge:Nr,pathBadgeTooltip:Ar};function St(a){if(!a)return[];const i=U.normalizePath(a),f=i.startsWith("/"),u=i.split("/").filter(Boolean),w=[];let h=f?"/":"";f&&w.push("/");for(const C of u)!h||h==="/"?h=h==="/"?`/${C}`:C:h=`${h}/${C}`,w.push(h);return w}function We(a,i,f){return a&&(a===i?f:a.startsWith(i==="/"?"/":`${i}/`)?f+a.slice(i.length):a)}const qt=t.forwardRef(function({withContextMenu:i=!0,readOnly:f=!1,filesystem:u,root:w="/wordpress",initialSelectedPath:h,onSelect:C=()=>{},onDoubleClickFile:g,pathBadges:R,onMountFromGit:b,onPathRenamed:D},P){const F=t.useMemo(()=>U.joinPaths("/",w||"/"),[w]),X=t.useMemo(()=>U.joinPaths(F,"wp-content","plugins"),[F]),K=t.useMemo(()=>U.joinPaths(F,"wp-content","themes"),[F]),[v,Y]=t.useState(()=>{if(!h)return{};const r={};for(const o of St(h))r[o]=!0;return r}),[k,m]=t.useState(()=>h??null),[A,j]=t.useState(()=>h??null),[I,H]=t.useState({}),[te,re]=t.useState({}),[J,ne]=t.useState(null),[y,d]=t.useState(null),S=t.useRef({}),B=t.useRef(!1),W=t.useRef(null),V=t.useRef(null),q=t.useRef(te),le=t.useRef(I),de=()=>{for(const r of Object.keys(S.current))clearTimeout(S.current[r]),delete S.current[r]},G=r=>{const o=S.current[r];o&&(clearTimeout(o),delete S.current[r])};t.useEffect(()=>{q.current=te},[te]),t.useEffect(()=>{le.current=I},[I]);const Q=r=>{var s;const o=(s=W.current)==null?void 0:s.querySelector(`[data-path="${CSS.escape(r)}"]`);o&&typeof o.focus=="function"&&(o.focus(),o.scrollIntoView({behavior:"smooth",block:"nearest"}))},ce=(r,o="")=>o?U.joinPaths(o,r.name):U.joinPaths("/",r.name),Re=(r,o)=>r.children?r.children:I[o],ae=async(r,o)=>{const s=await r.listFiles(o),c=[];for(const e of s){const n=o==="/"?`/${e}`:`${o}/${e}`,l=await r.isDir(n);c.push({name:e,type:l?"folder":"file"})}return c.sort((e,n)=>{var M;if(e.type!==n.type)return e.type==="folder"?-1:1;const l=o==="/"?`/${e.name}`:`${o}/${e.name}`,p=o==="/"?`/${n.name}`:`${o}/${n.name}`,T=(M=ge.current)==null?void 0:M.tempPath;if(T){if(l===T)return-1;if(p===T)return 1}return e.name.localeCompare(n.name)}),c},ke=async r=>await ae(u,r),we=(r,o)=>{if(o.type!=="folder")return o.children;const s=o.children??le.current[r];return s||q.current[r]?s:(re(c=>({...c,[r]:!0})),new Promise(c=>{ke(r).then(e=>{H(n=>({...n,[r]:e??[]})),c(e??[])}).catch(()=>{c([])}).finally(()=>{re(e=>{const n={...e};return delete n[r],n})})}))},Ce=(r,o)=>{o.type==="folder"&&(typeof window>"u"||S.current[r]||(S.current[r]=window.setTimeout(()=>{Y(s=>s[r]?s:{...s,[r]:!0}),we(r,o),delete S.current[r]},600)))},oe=r=>(re(o=>({...o,[r]:!0})),new Promise(o=>{ke(r).then(s=>{H(c=>({...c,[r]:s??[]})),o(s??[])}).catch(()=>{o([])}).finally(()=>{re(s=>{const c={...s};return delete c[r],c})})})),je=(r,o,s)=>{Y(c=>({...c,[r]:s})),s?we(r,o):H(c=>{if(c[r]===void 0)return c;const e={...c};return delete e[r],e})},ve=async r=>{if(!r)return;const o=St(r);if(o.length===0)return;Y(e=>{const n={...e};for(const l of o)n[l]=!0;return n});let s=[{name:F,type:"folder"}],c="";for(const e of o){const n=s==null?void 0:s.find(p=>ce(p,c)===e);if(!n||n.type!=="folder"){c=e,s=[];continue}s=await we(e,n)??le.current[e],c=e}},Te=(r,o)=>{!r||!o||r===o||(Y(s=>{let c=!1;const e={...s};for(const n of Object.keys(s)){const l=We(n,r,o);l&&l!==n&&(e[l]=s[n],delete e[n],c=!0)}return c?e:s}),H(s=>{let c=!1;const e={...s};for(const n of Object.keys(s)){const l=We(n,r,o);l&&l!==n&&(e[l]=s[n],delete e[n],c=!0)}return c?e:s}),m(s=>We(s,r,o)),j(s=>We(s,r,o)))},E=()=>{ne(null),d(null),de()},Ee=(r,o=!0)=>{m(r),o&&C(r)},pe=t.useMemo(()=>[{name:F,type:"folder"}],[F]),[$,ue]=t.useState(null),[$e,he]=t.useState(null),ge=t.useRef(null),Oe=f?null:$e;t.useImperativeHandle(P,()=>({focusPath:(r,o={})=>{if(!r)return;const{select:s=!0,domFocus:c=!0,notify:e=!1}=o;s&&Ee(r,e),j(r),c&&Q(r)},selectPath:r=>{r&&(Ee(r),j(r),Q(r))},getSelectedPath:()=>k,expandToPath:async r=>await ve(r),refresh:async r=>await oe(r),revealPath:async r=>{const o=U.dirname(r);await oe(o),await ve(o),await oe(r),Y(s=>({...s,[r]:!0})),Ee(r,!1),j(r),setTimeout(()=>Q(r),0)},remapPath:Te,createFile:async r=>{f||await Ge(r,"file","untitled.php")},createFolder:async r=>{f||await Ge(r,"folder","New Folder")},importFiles:async(r,o)=>{f||await ft(r,o)},importDataTransfer:async(r,o)=>{f||await dt(r,o)}}),[k,oe,Te,ve,f]);const x=t.useRef(!1),_=t.useRef(h??null),me=t.useRef(h);t.useEffect(()=>{B.current=!1},[F]),t.useEffect(()=>{h&&h!==me.current?_.current=h:h||(_.current=null),me.current=h},[h]),t.useEffect(()=>{if(!h||x.current)return;x.current=!0;const r=St(h);Y(s=>{const c={...s};for(const e of r)c[e]=!0;return c});const o=r[r.length-1]||h;j(o),m(o),ve(h)},[h,ve]),t.useEffect(()=>{const r=_.current;!r||pe.length===0||(_.current=null,ve(r))},[pe,ve]),t.useEffect(()=>{if(!A){if(pe.length>0){const r=ce(pe[0]);j(r)}return}Oe&&Oe===A||Q(A)},[pe,A,Oe]),t.useEffect(()=>{if(pe.length===0)return;const r=pe[0];if((r==null?void 0:r.type)!=="folder"||B.current)return;const o=r.name;B.current=!0,Y(s=>s[o]?s:{...s,[o]:!0}),!le.current[o]&&!q.current[o]&&we(o,r)},[pe,we,F]),t.useEffect(()=>()=>{V.current&&clearTimeout(V.current),de()},[]),t.useEffect(()=>{$&&setTimeout(()=>{const r=document.querySelector('[role="menu"] [role="menuitem"]');r&&typeof r.focus=="function"&&r.focus()},0)},[$]);const[fe,ie]=t.useState(""),Se=(r,o)=>{if(r.type==="folder")return o;const s=U.dirname(o);return s&&s||"/"},Me=(r,o,s)=>{const c=Se(r,o);return c?s&&U.isParentOf(s,c)?{allowed:!1,state:"invalid",destination:null}:{allowed:!0,state:"valid",destination:c}:{allowed:!1,state:"invalid",destination:null}},Ie=(r,o,s)=>{o.type!=="folder"&&o.type!=="file"||(ne(s),d(null),r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("application/x-wp-playground-path",s),r.dataTransfer.setData("text/plain",s)))},De=()=>{E()},ze=(r,o,s)=>{const c=Me(o,s,J);c.allowed&&o.type==="folder"&&Ce(s,o),d(e=>(e==null?void 0:e.path)===s&&e.state===c.state?e:{path:s,state:c.state})},et=(r,o,s)=>{const c=Me(o,s,J);c.allowed&&c.destination?(r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect=J?"move":"copy"),o.type==="folder"&&Ce(s,o),d(e=>(e==null?void 0:e.path)===s&&e.state===c.state?e:{path:s,state:c.state})):(r.dataTransfer&&(r.dataTransfer.dropEffect="none"),G(s),d(e=>(e==null?void 0:e.path)===s&&e.state==="invalid"?e:{path:s,state:"invalid"}))},gt=(r,o,s)=>{G(s);const c=r.relatedTarget;c&&r.currentTarget.contains(c)||d(e=>(e==null?void 0:e.path)===s?null:e)},yt=async(r,o,s)=>{const c=J,e=Me(o,s,c);if(!e.allowed||!e.destination){E();return}r.preventDefault(),r.stopPropagation(),G(s),d(null);try{c?await ct(c,e.destination):await dt(r.dataTransfer,e.destination)}finally{E()}},_t=(r,o,s)=>{i&&(r.preventDefault(),r.stopPropagation(),he(null),ue({absPath:s,type:o.type,x:r.clientX,y:r.clientY}))},qe=async(r,o)=>{let s=o,c=0;const e=l=>{const p=l.lastIndexOf(".");return p>0?{stem:l.slice(0,p),ext:l.slice(p)}:{stem:l,ext:""}},n=r==="/"?"":r;for(;await(u==null?void 0:u.fileExists(`${n}/${s}`))||await(u==null?void 0:u.isDir(`${n}/${s}`));){c+=1;const{stem:l,ext:p}=e(o);s=`${l} (${c})${p}`}return s},Ge=async(r,o,s)=>{if(!u)return;let c=r||k||F;try{await u.isDir(c)||(c=U.dirname(c))}catch{c=U.dirname(c)}const e=c,n=await qe(e,s),l=U.joinPaths(e,n);o==="folder"?await u.mkdir(l):await u.writeFile(l,""),ge.current={type:o,tempPath:l},he(l),await oe(e),setTimeout(()=>{j(l),Q(l)},0)},bt=async r=>{if(!u)return!1;try{if(await u.fileExists(r))return!0}catch{}try{if(await u.isDir(r))return!0}catch{}return!1},tt=async r=>{if(u)try{await u.mkdir(r)}catch(o){if(!await u.isDir(r).catch(()=>!1))throw o}},ct=async(r,o)=>{if(!u)return;const s=U.basename(r),c=U.joinPaths(o,s);if(c===r||await bt(c))return;const e=U.dirname(r);try{await u.mv(r,c),Te(r,c);const n=We(k,r,c);k&&(k===r||k.startsWith(`${r}/`))&&C(n),j(l=>We(l,r,c)),Y(l=>({...l,[o]:!0})),await Promise.all([oe(e),oe(o)]),m(l=>We(l,r,c)),Q(c)}catch{}},Be=r=>{const o=r;return o.webkitGetAsEntry?o.webkitGetAsEntry():null},rt=r=>new Promise((o,s)=>{r.file(o,s)}),Ye=async(r,o)=>{if(!u)return;const s=r.name||"untitled",c=await qe(o,s),e=U.joinPaths(o,c),n=new Uint8Array(await r.arrayBuffer());await u.writeFile(e,n)},nt=async(r,o)=>{const s=await rt(r);await Ye(s,o)},ut=async(r,o)=>{const s=await qe(o,r.name||"New Folder"),c=U.joinPaths(o,s);await tt(c);const e=r.createReader(),n=()=>new Promise((l,p)=>{e.readEntries(T=>l(Array.from(T)),p)});for(;;){const l=await n();if(!l.length)break;for(const p of l)p.isFile?await nt(p,c):p.isDirectory&&await ut(p,c)}},ft=(r,o)=>at([],r,o),dt=(r,o)=>{const c=Array.from(r.items).filter(n=>n.kind==="file").map(n=>Be(n)).filter(n=>!!n),e=Array.from(r.files);return at(c,e,o)},at=async(r,o,s)=>{if(u){if(r.length>0)for(const c of r)c.isFile?await nt(c,s):c.isDirectory&&await ut(c,s);else for(const c of o)await Ye(c,s);await oe(s),Y(c=>({...c,[s]:!0}))}},mt=async(r,o)=>{if(!u)return;const s=r;ue(null);try{o==="folder"?await u.rmdir(s,{recursive:!0}):await u.unlink(s)}catch{}finally{he(null);const c=U.dirname(s);await oe(c),k&&(k===s||k.startsWith(`${s}/`))&&C(null)}},Ct=async r=>{if(u)try{const s=await(await u.read(r)).arrayBuffer(),c=new Blob([s]),e=URL.createObjectURL(c),n=document.createElement("a");n.href=e,n.download=U.basename(r)||"download",document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(()=>URL.revokeObjectURL(e),6e4)}catch(o){console.error("Failed to download file",o)}},xt=r=>{var o;if(!$e)if(r.key.length===1&&r.key.match(/\S/)){const s=fe+r.key.toLowerCase();if(ie(s),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{ie("")},1e3),!W.current)return;const c=Array.from(W.current.querySelectorAll(".file-node-button")),e=document.activeElement;let n=0;e&&c.includes(e)&&(n=c.indexOf(e));for(let l=0;l<c.length;l++){const p=(n+l)%c.length,T=c[p];if((o=T.textContent)!=null&&o.toLowerCase().trim().startsWith(s)){T.focus();const M=T.getAttribute("data-path");M&&j(M);break}}}else ie(""),V.current&&clearTimeout(V.current)},pt=async(r,o)=>{if(f)return;const s=ge.current,c=(s==null?void 0:s.tempPath)===r,e=U.dirname(r);if(!o||o==="."||o===".."||U.basename(o)!==o){if(c){try{s.type==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}ge.current=null}he(c?null:r);return}let n=U.joinPaths(e,o),l=n;if(l===r){he(null);const N=c&&(s==null?void 0:s.type)==="file";c&&(ge.current=null),setTimeout(()=>{j(l),Q(l),N&&g&&g(l)},0);return}const p=await u.fileExists(l),T=await u.isDir(l);if((p||T)&&l!==r)if(c)try{const N=await qe(e==="/"?"/":e,o);n=U.joinPaths(e,N),l=n}catch{}else{he(r);return}let M=(s==null?void 0:s.type)==="folder";try{if(await u.mv(r,n),s||(M=await u.isDir(n)),M&&(Te(r,l),!c))try{await(D==null?void 0:D(r,l))}catch(N){Ue.logger.error("Failed to update metadata after renaming a path",N)}k===r&&C(l),await oe(e),j(l),Q(l),c&&!M&&g&&g(l)}catch{if(c)try{(s==null?void 0:s.type)==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}}finally{ge.current=null,he(null)}},ht=async r=>{const o=ge.current;if(!u||(o==null?void 0:o.tempPath)!==r){he(c=>c===r?null:c);return}try{o.type==="folder"?await u.rmdir(r,{recursive:!0}):await u.unlink(r)}catch{}ge.current=null,he(null);const s=U.dirname(r);await oe(s),j(s),Q(s)};return t.createElement("div",{onKeyDown:xt,ref:W},t.createElement(z.__experimentalTreeGrid,{className:ye.filePickerTree},pe.map((r,o)=>t.createElement(Gt,{key:r.name,node:r,level:0,position:o+1,setSize:pe.length,expandedNodePaths:v,onToggle:je,selectedNode:k,focusPath:s=>j(s),focusedNode:A,selectPath:Ee,generatePath:ce,getChildren:Re,onContextMenu:f?void 0:_t,renamingPath:Oe,onRename:pt,onRenameCancel:ht,dropIndicator:y,onDragStart:f?void 0:Ie,onDragEnd:f?void 0:De,onDragEnter:f?void 0:ze,onDragOver:f?void 0:et,onDragLeave:f?void 0:gt,onDrop:f?void 0:yt,rootPath:F,onDoubleClickFile:g,pathBadges:R}))),!f&&$&&t.createElement(z.Popover,{placement:"bottom-start",onClose:()=>ue(null),anchor:{getBoundingClientRect:()=>({x:$.x,y:$.y,width:0,height:0,top:$.y,left:$.x,right:$.x,bottom:$.y,toJSON:()=>({})}),ownerDocument:document},noArrow:!0,resize:!1,focusOnMount:"firstElement"},t.createElement(z.NavigableMenu,{role:"menu"},$.type==="folder"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ge($.absPath,"file","untitled.php")}},"Create file"),$.type==="folder"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ge($.absPath,"folder","New Folder")}},"Create directory"),b&&$.type==="folder"&&($.absPath===X||$.absPath===K)&&t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>{ue(null),b($.absPath===X?"plugin":"theme",$.absPath)}},"Mount via git…"),t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>{ue(null),he($.absPath)}},"Rename"),$.type==="file"&&t.createElement(z.MenuItem,{role:"menuitem",onClick:async()=>{ue(null),await Ct($.absPath)}},"Download"),t.createElement(z.MenuItem,{role:"menuitem",onClick:()=>mt($.absPath,$.type)},"Delete"))))}),Gt=({node:a,level:i,position:f,setSize:u,expandedNodePaths:w,onToggle:h,selectedNode:C,focusPath:g,focusedNode:R,selectPath:b,generatePath:D,getChildren:P,onContextMenu:F,renamingPath:X,onRename:K,onRenameCancel:v,parentPath:Y="",dropIndicator:k,onDragStart:m,onDragEnd:A,onDragEnter:j,onDragOver:I,onDragLeave:H,onDrop:te,rootPath:re,onDoubleClickFile:J,pathBadges:ne})=>{const y=D(a,Y),d=w[y],S=X===y,B=t.useRef(null),[W,V]=t.useState(a.name),q=t.useRef(!1),le=(k==null?void 0:k.path)===y,de=le&&(k==null?void 0:k.state)==="valid",G=le&&(k==null?void 0:k.state)==="invalid",Q=!!m&&!S&&y!==re,ce=t.useRef(null),Re={onDragEnter:E=>j==null?void 0:j(E,a,y),onDragOver:E=>I==null?void 0:I(E,a,y),onDragLeave:E=>H==null?void 0:H(E,a,y),onDrop:E=>te==null?void 0:te(E,a,y)},ae=P(a,y)??[];t.useEffect(()=>{var E;S?(V(a.name),q.current=!1,typeof window<"u"&&requestAnimationFrame?requestAnimationFrame(()=>{var Ee;(Ee=B.current)==null||Ee.select()}):(E=B.current)==null||E.select()):q.current=!1},[S,a.name]);const ke=()=>{a.type==="folder"&&h(y,a,!d)},we=E=>{var Ee,pe;if(E.key==="ArrowLeft")d?ke():(Ee=document.querySelector(`[data-path="${CSS.escape(Y)}"]`))==null||Ee.focus(),E.preventDefault(),E.stopPropagation();else if(E.key==="ArrowRight"){if(d){if(ae!=null&&ae.length){const $=D(ae[0],y);(pe=document.querySelector(`[data-path="${CSS.escape($)}"]`))==null||pe.focus()}}else ke();E.preventDefault(),E.stopPropagation()}else E.key===" "||E.key==="Space"||E.key==="Spacebar"?(a.type==="folder"&&h(y,a,!d),E.preventDefault()):E.key==="Enter"&&(a.type==="folder"?h(y,a,!d):(b(y,!1),g(y),J?J(y):b(y,!0)),E.preventDefault())},Ce=E=>{F==null||F(E,a,y)},oe=E=>{E.preventDefault(),q.current=!0,K==null||K(y,W)},je=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),q.current=!0,v==null||v(y);return}(E.key==="ArrowLeft"||E.key==="ArrowRight"||E.key==="ArrowUp"||E.key==="ArrowDown")&&E.stopPropagation()},ve=()=>{q.current||v==null||v(y),q.current=!1},Te=()=>{if(a.type==="folder"){ke(),b(y),g(y);return}const E=ce.current!==null;if(E&&ce.current&&clearTimeout(ce.current),ce.current=null,E){J?J(y):b(y,!0);return}b(y,!1),g(y),b(y,!0),ce.current=window.setTimeout(()=>{ce.current=null},300)};return t.useEffect(()=>()=>{ce.current!==null&&typeof window<"u"&&clearTimeout(ce.current)},[]),t.createElement(t.Fragment,null,t.createElement(z.__experimentalTreeGridRow,{level:i,positionInSet:f,setSize:u},t.createElement(z.__experimentalTreeGridCell,null,()=>t.createElement(t.Fragment,null,S?t.createElement("form",{onSubmit:oe,className:Ae(ye.fileNodeButton,ye.renaming,"file-node-button",{[ye.selected]:C===y,[ye.focused]:R===y,[ye.dropTarget]:de,[ye.dropTargetInvalid]:G}),"data-path":y,onContextMenu:Ce,...Re},t.createElement(Vt,{node:a,isOpen:a.type==="folder"&&d,level:i,hideName:!0,badge:ne==null?void 0:ne[y]}),t.createElement("input",{ref:B,className:ye.renameInput,value:W,onChange:E=>V(E.target.value),onBlur:ve,onFocus:()=>g(y),onKeyDown:je})):t.createElement(z.Button,{...Re,draggable:Q,onDragStart:E=>m==null?void 0:m(E,a,y),onDragEnd:E=>A==null?void 0:A(E,a,y),onClick:Te,onKeyDown:we,onFocus:()=>{g(y)},onContextMenu:Ce,className:Ae(ye.fileNodeButton,"file-node-button",{[ye.selected]:C===y,[ye.focused]:R===y,[ye.dropTarget]:de,[ye.dropTargetInvalid]:G}),"data-path":y,"data-expanded":d?"true":"false"},t.createElement(Vt,{node:a,isOpen:a.type==="folder"&&d,level:i,badge:ne==null?void 0:ne[y]}))))),d&&ae&&ae.map((E,Ee)=>t.createElement(Gt,{key:E.name,node:E,level:i+1,position:Ee+1,setSize:ae.length,expandedNodePaths:w,onToggle:h,selectedNode:C,focusPath:g,focusedNode:R,selectPath:b,generatePath:D,getChildren:P,onContextMenu:F,renamingPath:X,onRename:K,onRenameCancel:v,parentPath:y,dropIndicator:k,onDragStart:m,onDragEnd:A,onDragEnter:j,onDragOver:I,onDragLeave:H,onDrop:te,rootPath:re,onDoubleClickFile:J,pathBadges:ne})))},Vt=({node:a,level:i,isOpen:f,hideName:u=!1,badge:w})=>{const h=[];for(let b=0;b<i;b++)h.push(" ");const C=t.useRef(null),[g,R]=t.useState(null);return t.useEffect(()=>{if(!g)return;const b=()=>R(null);return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[g]),t.createElement(t.Fragment,null,t.createElement("span",{"aria-hidden":"true",dangerouslySetInnerHTML:{__html:h.join("")}}),a.type==="folder"?t.createElement(jt,{width:16,icon:f?vr:Er}):t.createElement("div",{style:{width:16}}," "),t.createElement(jt,{width:16,icon:a.type==="folder"?Wt:Ut}),!u&&t.createElement("span",{className:ye.fileName},a.name),w?t.createElement("span",{ref:C,className:ye.pathBadge,"aria-label":w.tooltip,onMouseEnter:()=>{var D;const b=(D=C.current)==null?void 0:D.getBoundingClientRect();b&&R({top:b.top,left:b.left})},onMouseLeave:()=>R(null)},w.icon,g?Ht.createPortal(t.createElement("span",{className:ye.pathBadgeTooltip,role:"tooltip",style:{top:g.top,left:g.left}},w.tooltip),document.body):null):null)},Fr="_control_kp9d9_1",Ir="_browse-label_kp9d9_11",Mr="_path-preview_kp9d9_37",Lr="_modal_kp9d9_43",jr="_modal-footer_kp9d9_48",Je={control:Fr,browseLabel:Ir,pathPreview:Mr,modal:Lr,modalFooter:jr};function Or({path:a}){if(!a)return t.createElement("div",{className:Je.pathPreview},t.createElement("i",null,"Select a path"));const i=a.split("/");let f=(i.length>2?"/":"")+i.pop();f.length>10&&(f=f.substring(f.length-10));const u=a.substring(0,a.length-f.length);return t.createElement("div",{className:Je.pathPreview,"data-content-start":u,"data-content-end":f})}function Br({value:a="",onChange:i,filesystem:f}){const[u,w]=t.useState(!1),h=()=>w(!0),C=()=>w(!1),[g,R]=t.useState(a||null);function b(D){D==null||D.preventDefault(),i(g||""),C()}return t.createElement(t.Fragment,null,t.createElement(z.Button,{variant:"tertiary",className:Je.control,onClick:h},t.createElement("span",{className:Je.browseLabel},"Browse"),t.createElement(Or,{path:a||""})),u&&t.createElement(z.Modal,{title:"Select a path ",onRequestClose:C,className:Je.modal},t.createElement("form",{onSubmit:b},t.createElement(qt,{filesystem:f,initialSelectedPath:a,onSelect:R}),t.createElement("div",{className:Je.modalFooter},t.createElement(z.Button,{type:"submit",variant:"primary"},"Select Path")))))}const Vr="_container_1h0az_1",$r="_header_1h0az_9",Hr="_filename_1h0az_18",Wr="_downloadLink_1h0az_26",Ur="_previewArea_1h0az_38",zr="_imagePreview_1h0az_51",qr="_videoPreview_1h0az_57",Gr="_audioPreview_1h0az_64",Yr="_unsupportedMessage_1h0az_68",Zr="_actions_1h0az_74",Le={container:Vr,header:$r,filename:Hr,downloadLink:Wr,previewArea:Ur,imagePreview:zr,videoPreview:qr,audioPreview:Gr,unsupportedMessage:Yr,actions:Zr},Kr=a=>{if(!a)return{isImage:!1,isVideo:!1,isAudio:!1};const i=a.toLowerCase();return{isImage:i.startsWith("image/"),isVideo:i.startsWith("video/"),isAudio:i.startsWith("audio/")}};function Jr({filename:a,mimeType:i,dataUrl:f,downloadUrl:u,showHeader:w=!0}){const{isImage:h,isVideo:C,isAudio:g}=Kr(i),R=w!==!1,b=!!(u&&a),D=()=>b?t.createElement("a",{className:Le.downloadLink,href:u,download:a},"Download"):null,P=()=>h?t.createElement("img",{className:Le.imagePreview,src:f,alt:a||"Preview"}):C?t.createElement("video",{className:Le.videoPreview,controls:!0,preload:"metadata"},t.createElement("source",{src:f,type:i}),"Your browser does not support the video tag."):g?t.createElement("audio",{className:Le.audioPreview,controls:!0},t.createElement("source",{src:f,type:i}),"Your browser does not support the audio tag."):t.createElement("div",{className:Le.unsupportedMessage},t.createElement("p",null,"Preview unavailable for this file type."),b?t.createElement("p",null,D()):t.createElement("p",null,"Download the file to inspect its contents."));return t.createElement("div",{className:Le.container},R&&t.createElement("div",{className:Le.header},t.createElement("span",{className:Le.filename,title:a},a),D()),t.createElement("div",{className:Le.previewArea},P()),!R&&b&&t.createElement("div",{className:Le.actions},D()))}const Pt=new Map,Xr=async a=>{var w;if(!a)return lt.php();const i=(w=a.split(".").pop())==null?void 0:w.toLowerCase();if(!i||i==="php")return lt.php();const f=a;if(Pt.has(f))return Pt.get(f);let u;switch(i){case"css":u=await import("@codemirror/lang-css").then(h=>h.css());break;case"js":case"jsx":case"ts":case"tsx":u=await import("@codemirror/lang-javascript").then(h=>h.javascript({jsx:i==="jsx"||i==="tsx",typescript:i==="ts"||i==="tsx"}));break;case"json":u=await import("@codemirror/lang-json").then(h=>h.json());break;case"html":case"htm":u=await import("@codemirror/lang-html").then(h=>h.html());break;case"md":case"markdown":u=await import("@codemirror/lang-markdown").then(h=>h.markdown());break;default:u=lt.php()}return Pt.set(f,u),u};class Qr{constructor(i){this.view=i,this.handleClick=this.handleClick.bind(this),this.view.dom.addEventListener("mousedown",this.handleClick)}handleClick(i){const f=i.target;if((f.classList.contains("cm-scroller")||f.classList.contains("cm-content"))&&this.view.posAtCoords({x:i.clientX,y:i.clientY})===null){const w=this.view.state.doc.length,h=Ve.EditorSelection.create([Ve.EditorSelection.range(w,w)]);this.view.dispatch({selection:h,effects:Pe.EditorView.scrollIntoView(w,{y:"center"})}),this.view.focus(),i.preventDefault()}}destroy(){this.view.dom.removeEventListener("mousedown",this.handleClick)}}const en=Pe.ViewPlugin.define(a=>new Qr(a)),Nt=t.forwardRef(function({code:i,onChange:f,currentPath:u,language:w,className:h,onSaveShortcut:C,readOnly:g=!1,additionalExtensions:R},b){const D=t.useRef(null),P=t.useRef(null),F=t.useRef(new Ve.Compartment),X=t.useRef(new Ve.Compartment),K=t.useRef(new Ve.Compartment),v=t.useRef(i),Y=t.useRef(f),k=t.useRef(!1);return t.useImperativeHandle(b,()=>({focus:()=>{var m;(m=P.current)==null||m.focus()},blur:()=>{const m=P.current;m&&m.contentDOM.blur()},getCursorPosition:()=>P.current?P.current.state.selection.main.anchor:null,setCursorPosition:m=>{if(!P.current)return;const A=Math.min(m,P.current.state.doc.length),j=Ve.EditorSelection.create([Ve.EditorSelection.range(A,A)]);P.current.dispatch({selection:j,scrollIntoView:!0})}})),t.useEffect(()=>{v.current=i},[i]),t.useEffect(()=>{Y.current=f},[f]),t.useEffect(()=>{if(P.current)return;const m=D.current;if(!m)return;const A=Ve.EditorState.create({doc:i,extensions:[K.current.of(R??[]),Pe.lineNumbers(),Pe.highlightActiveLineGutter(),Pe.highlightActiveLine(),Ke.foldGutter(),Pe.dropCursor(),Pe.rectangularSelection(),Pe.crosshairCursor(),en,F.current.of(w??lt.php()),X.current.of(Pe.EditorView.editable.of(!g)),Ke.syntaxHighlighting(Ke.defaultHighlightStyle),Ke.indentOnInput(),Ke.bracketMatching(),vt.closeBrackets(),wt.history(),It.highlightSelectionMatches(),vt.autocompletion(),Pe.EditorView.updateListener.of(I=>{if(!I.docChanged)return;const H=I.state.doc.toString();H!==v.current&&(v.current=H,Y.current(H))}),Pe.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(C==null||C(),!0)},...vt.closeBracketsKeymap,...vt.completionKeymap,...Ke.foldKeymap,...It.searchKeymap,...wt.historyKeymap,...wt.defaultKeymap,wt.indentWithTab])]}),j=new Pe.EditorView({state:A,parent:m});return P.current=j,()=>{j.destroy(),P.current=null}},[]),t.useEffect(()=>{const m=P.current;m&&m.dispatch({effects:K.current.reconfigure(R??[])})},[R]),t.useEffect(()=>{const m=P.current;if(!m)return;const A=m.state.doc.toString();i!==A&&m.dispatch({changes:{from:0,to:m.state.doc.length,insert:i}})},[i]),t.useEffect(()=>{var H;const m=P.current;if(!m)return;if(w){m.dispatch({effects:F.current.reconfigure(w)});return}const A=(H=u==null?void 0:u.split(".").pop())==null?void 0:H.toLowerCase();(!A||A==="php")&&m.dispatch({effects:F.current.reconfigure(lt.php())});let I=!1;return Xr(u).then(te=>{I||!P.current||P.current.dispatch({effects:F.current.reconfigure(te)})}),()=>{I=!0}},[u,w]),t.useEffect(()=>{const m=P.current;m&&(m.hasFocus&&(k.current=!0),m.dispatch({effects:X.current.reconfigure(Pe.EditorView.editable.of(!g))}))},[g]),t.useLayoutEffect(()=>{const m=P.current;m&&k.current&&!m.hasFocus&&(m.focus(),k.current=!1)},[u,g]),t.createElement("div",{ref:D,className:h})});Nt.displayName="CodeEditor";const tn="_fileExplorerContainer_rb5rx_1",rn="_dropActive_rb5rx_9",nn="_fileExplorerHeader_rb5rx_14",an="_fileExplorerTitle_rb5rx_23",on="_fileExplorerSubsectionTitle_rb5rx_31",sn="_fileExplorerActions_rb5rx_35",ln="_fileExplorerButton_rb5rx_41",cn="_fileExplorerIconButton_rb5rx_71",un="_fileExplorerTree_rb5rx_83",fn="_dockPresentation_rb5rx_92",dn="_fileExplorerUploadButton_rb5rx_152",be={fileExplorerContainer:tn,dropActive:rn,fileExplorerHeader:nn,fileExplorerTitle:an,fileExplorerSubsectionTitle:on,fileExplorerActions:sn,fileExplorerButton:ln,fileExplorerIconButton:cn,fileExplorerTree:un,dockPresentation:fn,fileExplorerUploadButton:dn},At=1024*1024,Yt=a=>{const i=a.byteLength;for(let f=0;f<Math.min(i,4096);f++)if(a[f]===0)return!0;try{return new TextDecoder("utf-8",{fatal:!0}).decode(a),!1}catch{return!0}},Dt=(a,i)=>{const f=new Blob([a]),u=URL.createObjectURL(f);return setTimeout(()=>URL.revokeObjectURL(u),6e4),{url:u,filename:i}};async function mn(a,i=At){const f=pn(a);if(f!==void 0&&f>i)return{type:"too-large"};if(typeof a.stream=="function")return hn(a,i);const u=new Uint8Array(await a.arrayBuffer());return u.byteLength>i?{type:"too-large"}:{type:"inline",data:u}}function pn(a){if(typeof a.filesize=="number")return a.filesize;if(typeof a.size=="number")return a.size}async function hn(a,i){const f=a.stream().getReader(),u=[];let w=0;try{for(;;){const{done:h,value:C}=await f.read();if(h)return{type:"inline",data:U.concatUint8Arrays(u)};if(C){if(w+=C.byteLength,w>i)return await f.cancel().catch(()=>{}),{type:"too-large"};u.push(C)}}}finally{f.releaseLock()}}const Zt=a=>{const i=a.split(".").pop();return Lt[i]||Lt._default},Kt=a=>a.startsWith("image/")||a.startsWith("video/")||a.startsWith("audio/"),Jt=t.forwardRef(function({filesystem:i,currentPath:f,selectedDirPath:u,setSelectedDirPath:w,onFileOpened:h,onSelectionCleared:C,onShowMessage:g,documentRoot:R,readOnly:b=!1,title:D="Files",mobileSubsectionTitle:P,showBinaryPreviewHeader:F=!0,dockPresentation:X=!1,useWordPressTooltips:K=!1,pathBadges:v,onMountFromGit:Y,onPathRenamed:k},m){const A=t.useRef(null),j=t.useRef(null);t.useImperativeHandle(m,()=>({refreshPath:async d=>{var S;await((S=A.current)==null?void 0:S.refresh(d))},revealPath:async d=>{var S;await((S=A.current)==null?void 0:S.revealPath(d))}}),[]);const I=t.useMemo(()=>f?U.dirname(f):u??R,[f,R]),[H,te]=t.useState(!1);t.useEffect(()=>{!f||!A.current||(w(U.dirname(f)),A.current.focusPath(f,{select:!0,domFocus:!1,notify:!1}),A.current.expandToPath(f))},[f,w]);const re=async(d,S)=>{try{const B=await i.read(d),W=await mn(B);if(W.type==="too-large"){const de=At/1024/1024;if(!X){await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,`File too large to open (>${de}MB).`),t.createElement("p",null,"Open or download it outside the in-browser editor.")));return}const G=U.basename(d)||"download";await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,`File too large to open (>${de}MB).`),t.createElement("p",null,t.createElement(z.Button,{type:"button",variant:"link",onClick:()=>{J(d,G)}},"Download ",G))));return}const V=W.data,q=U.basename(d)||"download";if(Yt(V)){const de=Zt(q),{url:G,filename:Q}=Dt(V,q);if(Kt(de)){const ce=new Blob([V],{type:de}),Re=URL.createObjectURL(ce);await g(d,t.createElement(Mt.BinaryFilePreview,{filename:Q,mimeType:de,dataUrl:Re,downloadUrl:G,showHeader:F}));return}await g(d,t.createElement(t.Fragment,null,t.createElement("p",null,"Binary file. Cannot be edited."),t.createElement("p",null,t.createElement("a",{href:G,download:Q},"Download ",Q))));return}const le=new TextDecoder("utf-8").decode(V);await h(d,le,S)}catch(B){Ue.logger.error("Could not open file",B),await g(null,"Could not open file.")}},J=async(d,S)=>{try{const B=await i.read(d),W=new Uint8Array(await B.arrayBuffer()),{url:V}=Dt(W,S),q=document.createElement("a");q.href=V,q.download=S,document.body.appendChild(q),q.click(),document.body.removeChild(q)}catch(B){Ue.logger.error("Could not download file",B),await g(d,"Could not download file.")}},ne=d=>{var B;const S=Array.from(d.target.files??[]);d.target.value="",S.length!==0&&((B=A.current)==null||B.importFiles(S,u??R).catch(W=>Ue.logger.error("Failed to import files",W)))},y=d=>{var S;d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),!b&&((S=A.current)==null||S.importDataTransfer(d.dataTransfer,u??R).catch(B=>Ue.logger.error("Failed to import dropped files",B))))};return t.createElement("div",{className:Ae(be.fileExplorerContainer,{[be.dropActive]:H,[be.dockPresentation]:X}),onDragEnter:d=>{d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),b||te(!0))},onDragOver:d=>{d.dataTransfer.types.includes("application/x-wp-playground-path")||(d.preventDefault(),d.dataTransfer.dropEffect=b?"none":"copy")},onDragLeave:d=>{const S=d.relatedTarget;(!S||!d.currentTarget.contains(S))&&te(!1)},onDropCapture:()=>te(!1),onDrop:y},t.createElement("div",{className:be.fileExplorerHeader},t.createElement("span",{className:be.fileExplorerTitle},D),P?t.createElement("span",{className:be.fileExplorerSubsectionTitle},P):null,b?null:t.createElement("div",{className:be.fileExplorerActions},t.createElement(kt,{label:"Create new file",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton),type:"button",onClick:()=>{A.current&&A.current.createFile()},"aria-label":"Create new file",title:K?void 0:"Create new file"},X?t.createElement(wn,null):t.createElement(z.Icon,{icon:yr,size:20}))),t.createElement(kt,{label:"Create new folder",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton),type:"button",onClick:()=>{A.current&&A.current.createFolder()},"aria-label":"Create new folder",title:K?void 0:"Create new folder"},X?t.createElement(vn,null):t.createElement(z.Icon,{icon:gr,size:20}))),t.createElement(kt,{label:"Upload files",useWordPressTooltip:K},t.createElement("button",{className:Ae(be.fileExplorerButton,be.fileExplorerIconButton,be.fileExplorerUploadButton),type:"button",onClick:()=>{var d;return(d=j.current)==null?void 0:d.click()},"aria-label":"Upload files",title:K?void 0:"Upload files"},t.createElement(z.Icon,{icon:_r,size:X?16:20}))),t.createElement("input",{ref:j,type:"file",multiple:!0,style:{display:"none"},onChange:ne}))),t.createElement("div",{className:be.fileExplorerTree},t.createElement(Mt.FilePickerTree,{ref:A,readOnly:b,filesystem:i,root:R,initialSelectedPath:I,pathBadges:v,onMountFromGit:Y,onPathRenamed:k,onSelect:async d=>{if(!d){w(R),await C();return}try{if(await i.isDir(d)){w(d);return}}catch{}w(U.dirname(d)),await re(d,!1)},onDoubleClickFile:async d=>{await re(d,!0)}})))});function kt({label:a,useWordPressTooltip:i,children:f}){return i?t.createElement(z.Tooltip,{text:a,delay:0,placement:"top"},f):f}const wn=()=>t.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},t.createElement("path",{d:"M11 6h7l5 5v12a2 2 0 0 1-2 2H11a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("path",{d:"M18 6v5h5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("g",{transform:"translate(19 19)"},t.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),t.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),vn=()=>t.createElement("svg",{viewBox:"0 0 32 32",width:"24",height:"24","aria-hidden":"true"},t.createElement("path",{d:"M6 9h7l3 3h10v11a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V9z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("path",{d:"M6 9V8a2 2 0 0 1 2-2h5l3 3",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),t.createElement("g",{transform:"translate(19 19)"},t.createElement("circle",{cx:"5",cy:"5",r:"8",fill:"var(--paper-2, #fff)"}),t.createElement("path",{d:"M5 1.5v7M1.5 5h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))),En="_container_a36e6_1",gn="_content_a36e6_9",yn="_sidebarWrapper_a36e6_17",_n="_editorWrapper_a36e6_28",bn="_editorHeader_a36e6_37",Cn="_editorPath_a36e6_49",xn="_editorPathDirectory_a36e6_61",Rn="_editorPathFilename_a36e6_68",Sn="_editorPathPlaceholder_a36e6_73",Pn="_editorPathPortaled_a36e6_77",kn="_editorHeaderActions_a36e6_83",Tn="_saveStatus_a36e6_90",Dn="_saveStatusSaving_a36e6_97",Nn="_saveStatusPending_a36e6_98",An="_saveStatusError_a36e6_102",Fn="_editor_a36e6_28",In="_placeholder_a36e6_124",Mn="_messageArea_a36e6_135",Ln="_mobileToggle_a36e6_171",jn="_mobileOverlay_a36e6_175",On="_dockPresentation_a36e6_181",Bn="_dockDirtyIndicator_a36e6_205",Vn="_dockSaveButton_a36e6_214",$n="_sidebarOpen_a36e6_269",Hn="_editorHeaderPathPortaled_a36e6_367",Z={container:En,content:gn,sidebarWrapper:yn,editorWrapper:_n,editorHeader:bn,editorPath:Cn,editorPathDirectory:xn,editorPathFilename:Rn,editorPathPlaceholder:Sn,editorPathPortaled:Pn,editorHeaderActions:kn,saveStatus:Tn,saveStatusSaving:Dn,saveStatusPending:Nn,saveStatusError:An,editor:Fn,placeholder:In,messageArea:Mn,mobileToggle:Ln,mobileOverlay:jn,dockPresentation:On,dockDirtyIndicator:Bn,dockSaveButton:Vn,sidebarOpen:$n,editorHeaderPathPortaled:Hn},Wn=1500,Un=700,zn=1e3,O={IDLE:"idle",PENDING:"pending",SAVING:"saving",SAVED:"saved",ERROR:"error"},qn=t.forwardRef(function({filesystem:i,isVisible:f=!0,documentRoot:u,initialPath:w=null,placeholderText:h="Select a file to view or edit its contents.",dockPresentation:C=!1,mobileHeaderTarget:g=null,pathBadges:R,onMountFromGit:b,onPathRenamed:D},P){const F=t.useRef(null);t.useImperativeHandle(P,()=>({refreshPath:async x=>{var _;await((_=F.current)==null?void 0:_.refreshPath(x))},revealPath:async x=>{var _;await((_=F.current)==null?void 0:_.revealPath(x))}}),[]);const[X,K]=t.useState(u),[v,Y]=t.useState(null),[k,m]=t.useState(""),[A,j]=t.useState(!0),[I,H]=t.useState(O.IDLE),[te,re]=t.useState(null),[J,ne]=t.useState("idle"),[y,d]=t.useState(!1),[S,B]=t.useState(null),W=t.useRef(null),V=t.useRef(null),q=t.useRef(!1),le=t.useRef(v),de=t.useRef(i),G=t.useRef(null),Q=t.useRef(null),ce=t.useRef(new WeakMap),Re=t.useRef(!0),ae=t.useRef(new Map),ke=t.useRef(!1);de.current=i,t.useEffect(()=>{le.current=v},[v]);const we=t.useCallback(async x=>{const{filesystem:_,path:me,content:fe}=x,ie=Q.current===x,Se=ce.current,Ie=(Se.get(_)??Promise.resolve()).catch(()=>{}).then(()=>_.writeFile(me,fe));Se.set(_,Ie);let De=!1;try{await Ie}catch(et){De=!0,Ue.logger.error("Failed to save file",et)}const ze=Re.current&&Se.get(_)===Ie&&de.current===_&&le.current===me&&G.current===null;Se.get(_)===Ie&&Se.delete(_),Q.current===x&&(Q.current=null),ze&&(H(De?O.ERROR:O.SAVED),re(De?"Could not save changes. Try again.":null),ie&&ne(De?"idle":"saved"))},[]),Ce=t.useCallback(()=>{const x=G.current;x&&(V.current!==null&&(window.clearTimeout(V.current),V.current=null),G.current=null,we(x))},[we]);t.useEffect(()=>(Re.current=!0,()=>{Re.current=!1}),[]),t.useEffect(()=>()=>{var x;((x=G.current)==null?void 0:x.filesystem)===i&&Ce()},[u,i,Ce]),t.useEffect(()=>{q.current=!0,K(u),m(""),Y(null),j(!0),H(O.IDLE),re(null),d(!1),B(null),ae.current.clear(),ke.current=!1},[u,i]),t.useEffect(()=>{if(!i||!w||ke.current)return;let x=!1;return(async()=>{try{if(await i.fileExists(w)&&!x){const fe=await i.readFileAsText(w);if(x)return;q.current=!0,Y(w),m(fe),j(!1),H(O.IDLE),re(null),setTimeout(()=>{var ie;(ie=W.current)==null||ie.focus()},100)}}catch(me){Ue.logger.debug("Could not auto-open initial path:",me)}finally{x||(ke.current=!0)}})(),()=>{x=!0}},[i,w]),t.useEffect(()=>{if(!i||!v){V.current!==null&&(window.clearTimeout(V.current),V.current=null),G.current=null,v||H(O.IDLE);return}if(q.current){q.current=!1,G.current=null;return}V.current!==null&&(window.clearTimeout(V.current),V.current=null),H(O.PENDING);const x={filesystem:i,path:v,content:k};G.current=x;const _=window.setTimeout(()=>{G.current===x&&(V.current=null,G.current=null,H(O.SAVING),we(x))},Wn);return V.current=_,()=>{V.current===_&&(window.clearTimeout(_),V.current=null)}},[k,v,i,we]),t.useEffect(()=>{if(I!==O.SAVED)return;const x=window.setTimeout(()=>{H(_=>_===O.SAVED?O.IDLE:_)},2e3);return()=>window.clearTimeout(x)},[I]),t.useEffect(()=>{J==="idle"||I===O.SAVING||I===O.SAVED||ne("idle")},[J,I]),t.useEffect(()=>{if(J!=="saved")return;const x=window.setTimeout(()=>ne("idle"),zn);return()=>window.clearTimeout(x)},[J]),t.useEffect(()=>{if(J!=="waiting")return;const x=window.setTimeout(()=>ne(_=>_==="waiting"?"saving":_),Un);return()=>window.clearTimeout(x)},[J]);const oe=t.useCallback(async(x,_,me=!0)=>{var ie;const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&le.current&&ae.current.set(le.current,fe),q.current=!0,Y(x),m(_),B(null),j(!1),H(O.IDLE),re(null),d(!1),setTimeout(()=>{var Me,Ie,De;const Se=ae.current.get(x);Se!==void 0&&((Me=W.current)==null||Me.setCursorPosition(Se)),me?(Ie=W.current)==null||Ie.focus():(De=W.current)==null||De.blur()},50)},[]);t.useEffect(()=>{var me;if(!v)return;const x=setInterval(()=>{var ie;const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&ae.current.set(v,fe)},1e3),_=(me=W.current)==null?void 0:me.getCursorPosition();return _!=null&&ae.current.set(v,_),()=>{var ie;clearInterval(x);const fe=(ie=W.current)==null?void 0:ie.getCursorPosition();fe!=null&&ae.current.set(v,fe)}},[v]),t.useEffect(()=>{if(!f||!v)return;const x=setTimeout(()=>{var me;const _=ae.current.get(v);_!==void 0&&((me=W.current)==null||me.setCursorPosition(_))},100);return()=>clearTimeout(x)},[f,v]);const je=t.useCallback(async()=>{var _;const x=(_=W.current)==null?void 0:_.getCursorPosition();x!=null&&le.current&&ae.current.set(le.current,x),q.current=!0,Y(null),m(""),B(null),j(!0),H(O.IDLE),re(null)},[]),ve=t.useCallback(async(x,_)=>{q.current=!0,Y(null),typeof _=="string"?(m(_),B(null)):(m(""),B(_)),j(!0),H(O.IDLE),re(null),d(!1)},[]),Te=t.useCallback(()=>{G.current&&(Q.current=G.current,ne("waiting"),H(O.SAVING),Ce())},[Ce]),E=t.useCallback(()=>{!G.current&&I===O.ERROR&&i&&v&&(G.current={filesystem:i,path:v,content:k}),G.current&&(re(null),Te())},[k,v,i,Te,I]),Ee=Gn(I,te),pe=Yn(I,Z),$=Zn(I);let ue="Save";I===O.ERROR?ue="Retry":I===O.SAVED&&J==="saved"?ue="Saved":I===O.SAVING&&J==="saving"&&(ue="Saving…");const $e=I===O.PENDING||I===O.SAVING||I===O.ERROR;if(!i)return t.createElement("div",{className:Ae(Z.container,{[Z.dockPresentation]:C})},t.createElement("div",{className:Z.placeholder},h));const he=v?U.dirname(v):null,ge=v?U.basename(v):null,Oe=t.createElement("div",{className:Ae(Z.editorPath,{[Z.editorPathPlaceholder]:!(v!=null&&v.length),[Z.editorPathPortaled]:g}),title:v??void 0},he&&ge?t.createElement(t.Fragment,null,t.createElement("span",{className:Z.editorPathDirectory},he==="/"?"":he),t.createElement("span",{className:Z.editorPathFilename},"/",ge)):`Browse files under ${u}`);return t.createElement("div",{className:Ae(Z.container,{[Z.dockPresentation]:C})},t.createElement("div",{className:Ae(Z.content,{[Z.sidebarOpen]:y})},t.createElement("div",{className:Z.mobileOverlay,onClick:()=>d(!1)}),t.createElement("aside",{className:Z.sidebarWrapper},t.createElement(Jt,{ref:F,filesystem:i,currentPath:v,selectedDirPath:X,setSelectedDirPath:K,onFileOpened:oe,onSelectionCleared:je,onShowMessage:ve,documentRoot:u,dockPresentation:C,useWordPressTooltips:C,pathBadges:R,onMountFromGit:b,onPathRenamed:D})),t.createElement("section",{className:Z.editorWrapper},t.createElement("div",{className:Ae(Z.editorHeader,{[Z.editorHeaderPathPortaled]:g})},t.createElement(z.Button,{className:Z.mobileToggle,variant:"secondary",onClick:()=>d(x=>!x)},y?"Hide files":"Browse files"),g?Ht.createPortal(Oe,g):Oe,C&&!A&&v?t.createElement("div",{className:Z.editorHeaderActions},$e?t.createElement("span",{className:Z.dockDirtyIndicator,"aria-hidden":"true"}):null,t.createElement(z.Tooltip,{text:$,placement:"top"},t.createElement(z.Button,{variant:"secondary",className:Z.dockSaveButton,isDestructive:I===O.ERROR,onClick:E},ue))):C?null:t.createElement("div",{className:Ae(Z.saveStatus,pe)},Ee),C&&!A&&v?t.createElement(z.VisuallyHidden,{role:"status","aria-live":"polite"},$):null),te?t.createElement("div",{style:{padding:"8px 16px"}},t.createElement(z.Notice,{status:"error",isDismissible:!1},te)):null,v||k||S?S?t.createElement("div",{className:Z.messageArea},S):t.createElement(Nt,{ref:W,code:k,onChange:m,currentPath:v,className:Z.editor,onSaveShortcut:Te,readOnly:A}):t.createElement("div",{className:Z.placeholder},h))))});function Gn(a,i){switch(a){case O.PENDING:case O.SAVING:return"Saving…";case O.SAVED:return"Saved";case O.ERROR:return i??"Save failed";default:return""}}function Yn(a,i){switch(a){case O.PENDING:return i.saveStatusPending;case O.SAVING:return i.saveStatusSaving;case O.ERROR:return i.saveStatusError;default:return}}function Zn(a){switch(a){case O.PENDING:return"Unsaved changes. Click to save now.";case O.SAVING:return"Saving changes…";case O.ERROR:return"Saving failed. Click to retry.";default:return"All changes saved."}}const Kn="_modal_1i30f_1",Jn="_actions_1i30f_5",$t={modal:Kn,actions:Jn};function Xn({kind:a,isBusy:i,error:f,onSubmit:u,onCancel:w}){const[h,C]=t.useState(""),[g,R]=t.useState(""),[b,D]=t.useState(""),P=h.trim(),F=v=>{const Y=Qn(v);if(Y){C(Y.url),R(Y.ref);return}C(v)},X=()=>{!P||i||u({url:P,ref:g.trim()||"HEAD",path:b.trim()||void 0})},K=()=>{i||w()};return t.createElement(z.Modal,{title:`Mount ${a} via git`,onRequestClose:K,isDismissible:!i,className:$t.modal},t.createElement("form",{onSubmit:v=>{v.preventDefault(),X()},style:{display:"flex",flexDirection:"column",gap:12}},t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Repository URL",value:h,onChange:F,placeholder:"github.com/owner/repo",autoFocus:!0,disabled:i}),t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Branch, tag, or commit",value:g,onChange:v=>R(v),placeholder:"HEAD",disabled:i}),t.createElement(z.TextControl,{__nextHasNoMarginBottom:!0,label:"Path within the repository (optional)",value:b,onChange:v=>D(v),placeholder:"Leave empty to use the repository root",disabled:i}),f?t.createElement("p",{role:"alert"},f):null,t.createElement(z.Flex,{justify:"end",className:$t.actions},t.createElement(z.Button,{type:"button",variant:"link",disabled:i,onClick:w},"Cancel"),t.createElement(z.Button,{type:"submit",variant:"primary",isBusy:i,disabled:!P||i},"Mount ",a))))}function Qn(a){const i=a.trim().match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/]+)\/([^/]+)\/tree\/(.+)$/i);if(!i)return null;const[,f,u,w]=i;return{url:`https://github.com/${f}/${u.replace(/\.git$/i,"")}`,ref:w}}exports.BinaryFilePreview=Jr;exports.ClockIcon=ur;exports.CodeEditor=Nt;exports.FileExplorerSidebar=Jt;exports.FilePickerControl=Br;exports.FilePickerTree=qt;exports.MAX_INLINE_FILE_BYTES=At;exports.MountGitDirectoryModal=Xn;exports.PlaygroundFileEditor=qn;exports.SiteManagerIcon=mr;exports.WordPressIcon=cr;exports.createDownloadUrl=Dt;exports.file=Ut;exports.folder=Wt;exports.getLogoDataURL=dr;exports.getMimeType=Zt;exports.isMessageFromIframeTree=pr;exports.isPreviewableBinary=Kt;exports.layout=fr;exports.playgroundLogo=sr;exports.seemsLikeBinary=Yt;exports.temporaryStorage=lr;
|
|
31
31
|
//# sourceMappingURL=index.cjs.map
|