diff --git a/jhub_apps/static/js/index.js b/jhub_apps/static/js/index.js index bfc66d90..bde09027 100644 --- a/jhub_apps/static/js/index.js +++ b/jhub_apps/static/js/index.js @@ -82,4 +82,4 @@ Error generating stack: `+s.message+` `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||t[n]&&tA[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},ep=Symbol("internals");function Do(e){return e&&String(e).trim().toLowerCase()}function Ai(e){return e===!1||e==null?e:b.isArray(e)?e.map(Ai):String(e)}function rA(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const oA=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ja(e,t,n,r,o){if(b.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!b.isString(t)){if(b.isString(r))return t.indexOf(r)!==-1;if(b.isRegExp(r))return r.test(t)}}function sA(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function iA(e,t){const n=b.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,s,i){return this[r].call(this,t,o,s,i)},configurable:!0})})}class fa{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function s(l,a,u){const c=Do(a);if(!c)throw new Error("header name must be a non-empty string");const f=b.findKey(o,c);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||a]=Ai(l))}const i=(l,a)=>b.forEach(l,(u,c)=>s(u,c,a));return b.isPlainObject(t)||t instanceof this.constructor?i(t,n):b.isString(t)&&(t=t.trim())&&!oA(t)?i(nA(t),n):t!=null&&s(n,t,r),this}get(t,n){if(t=Do(t),t){const r=b.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return rA(o);if(b.isFunction(n))return n.call(this,o,r);if(b.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Do(t),t){const r=b.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ja(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function s(i){if(i=Do(i),i){const l=b.findKey(r,i);l&&(!n||Ja(r,r[l],l,n))&&(delete r[l],o=!0)}}return b.isArray(t)?t.forEach(s):s(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!t||Ja(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){const n=this,r={};return b.forEach(this,(o,s)=>{const i=b.findKey(r,s);if(i){n[i]=Ai(o),delete n[s];return}const l=t?sA(s):String(s).trim();l!==s&&delete n[s],n[l]=Ai(o),r[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return b.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&b.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(` `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ep]=this[ep]={accessors:{}}).accessors,o=this.prototype;function s(i){const l=Do(i);r[l]||(iA(o,i),r[l]=!0)}return b.isArray(t)?t.forEach(s):s(t),this}}fa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);b.reduceDescriptors(fa.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});b.freezeMethods(fa);const gn=fa;function Xa(e,t){const n=this||zf,r=t||n,o=gn.from(r.headers);let s=r.data;return b.forEach(e,function(l){s=l.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function bg(e){return!!(e&&e.__CANCEL__)}function Is(e,t,n){Se.call(this,e??"canceled",Se.ERR_CANCELED,t,n),this.name="CanceledError"}b.inherits(Is,Se,{__CANCEL__:!0});function lA(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Se("Request failed with status code "+n.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const aA=tn.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];b.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),b.isString(r)&&i.push("path="+r),b.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function uA(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function cA(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Fg(e,t){return e&&!uA(t)?cA(e,t):t}const fA=tn.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function o(s){let i=s;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=o(window.location.href),function(i){const l=b.isString(i)?o(i):i;return l.protocol===r.protocol&&l.host===r.host}}():function(){return function(){return!0}}();function dA(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function hA(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(a){const u=Date.now(),c=r[s];i||(i=u),n[o]=a,r[o]=u;let f=s,h=0;for(;f!==o;)h+=n[f++],f=f%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),u-i{const s=o.loaded,i=o.lengthComputable?o.total:void 0,l=s-n,a=r(l),u=s<=i;n=s;const c={loaded:s,total:i,progress:i?s/i:void 0,bytes:l,rate:a||void 0,estimated:a&&i&&u?(i-s)/a:void 0,event:o};c[t?"download":"upload"]=!0,e(c)}}const pA=typeof XMLHttpRequest<"u",mA=pA&&function(e){return new Promise(function(n,r){let o=e.data;const s=gn.from(e.headers).normalize();let{responseType:i,withXSRFToken:l}=e,a;function u(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}let c;if(b.isFormData(o)){if(tn.hasStandardBrowserEnv||tn.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if((c=s.getContentType())!==!1){const[v,...T]=c?c.split(";").map(p=>p.trim()).filter(Boolean):[];s.setContentType([v||"multipart/form-data",...T].join("; "))}}let f=new XMLHttpRequest;if(e.auth){const v=e.auth.username||"",T=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.set("Authorization","Basic "+btoa(v+":"+T))}const h=Fg(e.baseURL,e.url);f.open(e.method.toUpperCase(),Ag(h,e.params,e.paramsSerializer),!0),f.timeout=e.timeout;function g(){if(!f)return;const v=gn.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders()),p={data:!i||i==="text"||i==="json"?f.responseText:f.response,status:f.status,statusText:f.statusText,headers:v,config:e,request:f};lA(function(m){n(m),u()},function(m){r(m),u()},p),f=null}if("onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){!f||f.readyState!==4||f.status===0&&!(f.responseURL&&f.responseURL.indexOf("file:")===0)||setTimeout(g)},f.onabort=function(){f&&(r(new Se("Request aborted",Se.ECONNABORTED,e,f)),f=null)},f.onerror=function(){r(new Se("Network Error",Se.ERR_NETWORK,e,f)),f=null},f.ontimeout=function(){let T=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const p=e.transitional||Lg;e.timeoutErrorMessage&&(T=e.timeoutErrorMessage),r(new Se(T,p.clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,e,f)),f=null},tn.hasStandardBrowserEnv&&(l&&b.isFunction(l)&&(l=l(e)),l||l!==!1&&fA(h))){const v=e.xsrfHeaderName&&e.xsrfCookieName&&aA.read(e.xsrfCookieName);v&&s.set(e.xsrfHeaderName,v)}o===void 0&&s.setContentType(null),"setRequestHeader"in f&&b.forEach(s.toJSON(),function(T,p){f.setRequestHeader(p,T)}),b.isUndefined(e.withCredentials)||(f.withCredentials=!!e.withCredentials),i&&i!=="json"&&(f.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&f.addEventListener("progress",tp(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&f.upload&&f.upload.addEventListener("progress",tp(e.onUploadProgress)),(e.cancelToken||e.signal)&&(a=v=>{f&&(r(!v||v.type?new Is(null,e,f):v),f.abort(),f=null)},e.cancelToken&&e.cancelToken.subscribe(a),e.signal&&(e.signal.aborted?a():e.signal.addEventListener("abort",a)));const y=dA(h);if(y&&tn.protocols.indexOf(y)===-1){r(new Se("Unsupported protocol "+y+":",Se.ERR_BAD_REQUEST,e));return}f.send(o||null)})},yc={http:VN,xhr:mA};b.forEach(yc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const np=e=>`- ${e}`,yA=e=>b.isFunction(e)||e===null||e===!1,Dg={getAdapter:e=>{e=b.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let s=0;s`adapter ${l} `+(a===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since : `+s.map(np).join(` -`):" "+np(s[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:yc};function Za(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Is(null,e)}function rp(e){return Za(e),e.headers=gn.from(e.headers),e.data=Xa.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Dg.getAdapter(e.adapter||zf.adapter)(e).then(function(r){return Za(e),r.data=Xa.call(e,e.transformResponse,r),r.headers=gn.from(r.headers),r},function(r){return bg(r)||(Za(e),r&&r.response&&(r.response.data=Xa.call(e,e.transformResponse,r.response),r.response.headers=gn.from(r.response.headers))),Promise.reject(r)})}const op=e=>e instanceof gn?e.toJSON():e;function ao(e,t){t=t||{};const n={};function r(u,c,f){return b.isPlainObject(u)&&b.isPlainObject(c)?b.merge.call({caseless:f},u,c):b.isPlainObject(c)?b.merge({},c):b.isArray(c)?c.slice():c}function o(u,c,f){if(b.isUndefined(c)){if(!b.isUndefined(u))return r(void 0,u,f)}else return r(u,c,f)}function s(u,c){if(!b.isUndefined(c))return r(void 0,c)}function i(u,c){if(b.isUndefined(c)){if(!b.isUndefined(u))return r(void 0,u)}else return r(void 0,c)}function l(u,c,f){if(f in t)return r(u,c);if(f in e)return r(void 0,u)}const a={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(u,c)=>o(op(u),op(c),!0)};return b.forEach(Object.keys(Object.assign({},e,t)),function(c){const f=a[c]||o,h=f(e[c],t[c],c);b.isUndefined(h)&&f!==l||(n[c]=h)}),n}const Mg="1.6.2",Hf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Hf[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const sp={};Hf.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Mg+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,l)=>{if(t===!1)throw new Se(o(i," has been removed"+(n?" in "+n:"")),Se.ERR_DEPRECATED);return n&&!sp[i]&&(sp[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,l):!0}};function vA(e,t,n){if(typeof e!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const l=e[s],a=l===void 0||i(l,s,e);if(a!==!0)throw new Se("option "+s+" must be "+a,Se.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Se("Unknown option "+s,Se.ERR_BAD_OPTION)}}const vc={assertOptions:vA,validators:Hf},Nn=vc.validators;class pl{constructor(t){this.defaults=t,this.interceptors={request:new Zh,response:new Zh}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ao(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&vc.assertOptions(r,{silentJSONParsing:Nn.transitional(Nn.boolean),forcedJSONParsing:Nn.transitional(Nn.boolean),clarifyTimeoutError:Nn.transitional(Nn.boolean)},!1),o!=null&&(b.isFunction(o)?n.paramsSerializer={serialize:o}:vc.assertOptions(o,{encode:Nn.function,serialize:Nn.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&b.merge(s.common,s[n.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=gn.concat(i,s);const l=[];let a=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(a=a&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let c,f=0,h;if(!a){const y=[rp.bind(this),void 0];for(y.unshift.apply(y,l),y.push.apply(y,u),h=y.length,c=Promise.resolve(n);f{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{r.subscribe(l),s=l}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,l){r.reason||(r.reason=new Is(s,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Qf(function(o){t=o}),cancel:t}}}const gA=Qf;function SA(e){return function(n){return e.apply(null,n)}}function wA(e){return b.isObject(e)&&e.isAxiosError===!0}const gc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(gc).forEach(([e,t])=>{gc[t]=e});const _A=gc;function Ig(e){const t=new Li(e),n=vg(Li.prototype.request,t);return b.extend(n,Li.prototype,t,{allOwnKeys:!0}),b.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ig(ao(e,o))},n}const Qe=Ig(zf);Qe.Axios=Li;Qe.CanceledError=Is;Qe.CancelToken=gA;Qe.isCancel=bg;Qe.VERSION=Mg;Qe.toFormData=ca;Qe.AxiosError=Se;Qe.Cancel=Qe.CanceledError;Qe.all=function(t){return Promise.all(t)};Qe.spread=SA;Qe.isAxiosError=wA;Qe.mergeConfig=ao;Qe.AxiosHeaders=gn;Qe.formToJSON=e=>Og(b.isHTMLForm(e)?new FormData(e):e);Qe.getAdapter=Dg.getAdapter;Qe.HttpStatusCode=_A;Qe.default=Qe;const RA=Qe,Qt=RA.create({baseURL:"/services/japps",headers:{"Content-Type":"application/json"}});Qt.interceptors.response.use(e=>e,e=>{const t=e.response.status;(e.response.status===401||t===403)&&(window.location.href="/services/japps/jhub-login")});const EA="This field is required.",Mo={required:EA},Ug=()=>window.jhdata,CA=(e,t)=>{var r;const n=[];for(const o in e)if(Object.hasOwnProperty.call(e,o)){const s=e[o];s.display===!0&&s.info.name&&n.push({name:s.info.name,url:(r=s.info.url)==null?void 0:r.replace("[USER]",t),external:s.info.external})}return n},xA=(e,t)=>{const n=[];t.toLowerCase()==="shared"?n.push(...e.shared_apps):n.push(...e.user_apps);const r=[];return n.forEach(o=>{var s;if((s=o.user_options)!=null&&s.jhub_app){const i=o.user_options;r.push({id:i.name,name:i.display_name,description:i.description,framework:TA(i.framework),url:o.url,thumbnail:i.thumbnail,username:o.username,ready:o.ready,public:i.public})}}),r},TA=e=>e.charAt(0).toUpperCase()+e.slice(1);var Us=e=>e.type==="checkbox",jr=e=>e instanceof Date,ut=e=>e==null;const Vg=e=>typeof e=="object";var Ke=e=>!ut(e)&&!Array.isArray(e)&&Vg(e)&&!jr(e),jg=e=>Ke(e)&&e.target?Us(e.target)?e.target.checked:e.target.value:e,kA=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,$g=(e,t)=>e.has(kA(t)),NA=e=>{const t=e.constructor&&e.constructor.prototype;return Ke(t)&&t.hasOwnProperty("isPrototypeOf")},Wf=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Bt(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Wf&&(e instanceof Blob||e instanceof FileList))&&(n||Ke(e)))if(t=n?[]:{},!n&&!NA(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=Bt(e[r]));else return e;return t}var Vs=e=>Array.isArray(e)?e.filter(Boolean):[],Be=e=>e===void 0,W=(e,t,n)=>{if(!t||!Ke(e))return n;const r=Vs(t.split(/[,[\].]+?/)).reduce((o,s)=>ut(o)?o:o[s],e);return Be(r)||r===e?Be(e[t])?n:e[t]:r},Un=e=>typeof e=="boolean";const ml={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Wt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},fn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},AA=oe.createContext(null),qf=()=>oe.useContext(AA);var Bg=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Wt.all&&(t._proxyFormState[i]=!r||Wt.all),n&&(n[i]=!0),e[i]}});return o},Lt=e=>Ke(e)&&!Object.keys(e).length,zg=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Lt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!r||Wt.all))},Pi=e=>Array.isArray(e)?e:[e],Hg=(e,t,n)=>!e||!t||e===t||Pi(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Kf(e){const t=oe.useRef(e);t.current=e,oe.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function LA(e){const t=qf(),{control:n=t.control,disabled:r,name:o,exact:s}=e||{},[i,l]=oe.useState(n._formState),a=oe.useRef(!0),u=oe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),c=oe.useRef(o);return c.current=o,Kf({disabled:r,next:f=>a.current&&Hg(c.current,f.name,s)&&zg(f,u.current,n._updateFormState)&&l({...n._formState,...f}),subject:n._subjects.state}),oe.useEffect(()=>(a.current=!0,u.current.isValid&&n._updateValid(!0),()=>{a.current=!1}),[n]),Bg(i,n,u.current,!1)}var nn=e=>typeof e=="string",Qg=(e,t,n,r,o)=>nn(e)?(r&&t.watch.add(e),W(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),W(n,s))):(r&&(t.watchAll=!0),n);function PA(e){const t=qf(),{control:n=t.control,name:r,defaultValue:o,disabled:s,exact:i}=e||{},l=oe.useRef(r);l.current=r,Kf({disabled:s,subject:n._subjects.values,next:c=>{Hg(l.current,c.name,i)&&u(Bt(Qg(l.current,n._names,c.values||n._formValues,!1,o)))}});const[a,u]=oe.useState(n._getWatch(r,o));return oe.useEffect(()=>n._removeUnmounted()),a}var Gf=e=>/^\w*$/.test(e),Wg=e=>Vs(e.replace(/["|']|\]/g,"").split(/\.|\[/));function ke(e,t,n){let r=-1;const o=Gf(t)?[t]:Wg(t),s=o.length,i=s-1;for(;++r{const c=o._options.shouldUnregister||s,f=(h,g)=>{const y=W(o._fields,h);y&&(y._f.mount=g)};if(f(n,!0),c){const h=Bt(W(o._options.defaultValues,n));ke(o._defaultValues,n,h),Be(W(o._formValues,n))&&ke(o._formValues,n,h)}return()=>{(i?c&&!o._state.action:c)?o.unregister(n):f(n,!1)}},[n,o,i,s]),oe.useEffect(()=>{W(o._fields,n)&&o._updateDisabledField({disabled:r,fields:o._fields,name:n})},[r,n,o]),{field:{name:n,value:l,...Un(r)?{disabled:r}:{},onChange:oe.useCallback(c=>u.current.onChange({target:{value:jg(c),name:n},type:ml.CHANGE}),[n]),onBlur:oe.useCallback(()=>u.current.onBlur({target:{value:W(o._formValues,n),name:n},type:ml.BLUR}),[n,o]),ref:c=>{const f=W(o._fields,n);f&&c&&(f._f.ref={focus:()=>c.focus(),select:()=>c.select(),setCustomValidity:h=>c.setCustomValidity(h),reportValidity:()=>c.reportValidity()})}},formState:a,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!W(a.errors,n)},isDirty:{enumerable:!0,get:()=>!!W(a.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!W(a.touchedFields,n)},error:{enumerable:!0,get:()=>W(a.errors,n)}})}}const dn=e=>e.render(OA(e));var bA=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{};const Sc=(e,t,n)=>{for(const r of n||Object.keys(e)){const o=W(e,r);if(o){const{_f:s,...i}=o;if(s&&t(s.name)){if(s.ref.focus){s.ref.focus();break}else if(s.refs&&s.refs[0].focus){s.refs[0].focus();break}}else Ke(i)&&Sc(i,t)}}};var ip=e=>({isOnSubmit:!e||e===Wt.onSubmit,isOnBlur:e===Wt.onBlur,isOnChange:e===Wt.onChange,isOnAll:e===Wt.all,isOnTouch:e===Wt.onTouched}),lp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length)))),FA=(e,t,n)=>{const r=Vs(W(e,n));return ke(r,"root",t[n]),ke(e,n,r),e},Yf=e=>e.type==="file",Vn=e=>typeof e=="function",yl=e=>{if(!Wf)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Oi=e=>nn(e),Jf=e=>e.type==="radio",vl=e=>e instanceof RegExp;const ap={value:!1,isValid:!1},up={value:!0,isValid:!0};var qg=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Be(e[0].attributes.value)?Be(e[0].value)||e[0].value===""?up:{value:e[0].value,isValid:!0}:up:ap}return ap};const cp={isValid:!1,value:null};var Kg=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,cp):cp;function fp(e,t,n="validate"){if(Oi(e)||Array.isArray(e)&&e.every(Oi)||Un(e)&&!e)return{type:n,message:Oi(e)?e:"",ref:t}}var Tr=e=>Ke(e)&&!vl(e)?e:{value:e,message:""},dp=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:l,maxLength:a,minLength:u,min:c,max:f,pattern:h,validate:g,name:y,valueAsNumber:v,mount:T,disabled:p}=e._f,d=W(t,y);if(!T||p)return{};const m=i?i[0]:s,R=ae=>{r&&m.reportValidity&&(m.setCustomValidity(Un(ae)?"":ae||""),m.reportValidity())},k={},x=Jf(s),P=Us(s),F=x||P,J=(v||Yf(s))&&Be(s.value)&&Be(d)||yl(s)&&s.value===""||d===""||Array.isArray(d)&&!d.length,K=bA.bind(null,y,n,k),ye=(ae,B,re,_e=fn.maxLength,ve=fn.minLength)=>{const fe=ae?B:re;k[y]={type:ae?_e:ve,message:fe,ref:s,...K(ae?_e:ve,fe)}};if(o?!Array.isArray(d)||!d.length:l&&(!F&&(J||ut(d))||Un(d)&&!d||P&&!qg(i).isValid||x&&!Kg(i).isValid)){const{value:ae,message:B}=Oi(l)?{value:!!l,message:l}:Tr(l);if(ae&&(k[y]={type:fn.required,message:B,ref:m,...K(fn.required,B)},!n))return R(B),k}if(!J&&(!ut(c)||!ut(f))){let ae,B;const re=Tr(f),_e=Tr(c);if(!ut(d)&&!isNaN(d)){const ve=s.valueAsNumber||d&&+d;ut(re.value)||(ae=ve>re.value),ut(_e.value)||(B=ve<_e.value)}else{const ve=s.valueAsDate||new Date(d),fe=ee=>new Date(new Date().toDateString()+" "+ee),j=s.type=="time",Z=s.type=="week";nn(re.value)&&d&&(ae=j?fe(d)>fe(re.value):Z?d>re.value:ve>new Date(re.value)),nn(_e.value)&&d&&(B=j?fe(d)+ae.value,_e=!ut(B.value)&&d.length<+B.value;if((re||_e)&&(ye(re,ae.message,B.message),!n))return R(k[y].message),k}if(h&&!J&&nn(d)){const{value:ae,message:B}=Tr(h);if(vl(ae)&&!d.match(ae)&&(k[y]={type:fn.pattern,message:B,ref:s,...K(fn.pattern,B)},!n))return R(B),k}if(g){if(Vn(g)){const ae=await g(d,t),B=fp(ae,m);if(B&&(k[y]={...B,...K(fn.validate,B.message)},!n))return R(B.message),k}else if(Ke(g)){let ae={};for(const B in g){if(!Lt(ae)&&!n)break;const re=fp(await g[B](d,t),m,B);re&&(ae={...re,...K(B,re.message)},R(re.message),n&&(k[y]=ae))}if(!Lt(ae)&&(k[y]={ref:m,...ae},!n))return k}}return R(!0),k};function DA(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}}var gl=e=>ut(e)||!Vg(e);function ur(e,t){if(gl(e)||gl(t))return e===t;if(jr(e)&&jr(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(jr(s)&&jr(i)||Ke(s)&&Ke(i)||Array.isArray(s)&&Array.isArray(i)?!ur(s,i):s!==i)return!1}}return!0}var Gg=e=>e.type==="select-multiple",IA=e=>Jf(e)||Us(e),tu=e=>yl(e)&&e.isConnected,Yg=e=>{for(const t in e)if(Vn(e[t]))return!0;return!1};function Sl(e,t={}){const n=Array.isArray(e);if(Ke(e)||n)for(const r in e)Array.isArray(e[r])||Ke(e[r])&&!Yg(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Sl(e[r],t[r])):ut(e[r])||(t[r]=!0);return t}function Jg(e,t,n){const r=Array.isArray(e);if(Ke(e)||r)for(const o in e)Array.isArray(e[o])||Ke(e[o])&&!Yg(e[o])?Be(t)||gl(n[o])?n[o]=Array.isArray(e[o])?Sl(e[o],[]):{...Sl(e[o])}:Jg(e[o],ut(t)?{}:t[o],n[o]):n[o]=!ur(e[o],t[o]);return n}var nu=(e,t)=>Jg(e,t,Sl(t)),Xg=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Be(e)?e:t?e===""?NaN:e&&+e:n&&nn(e)?new Date(e):r?r(e):e;function ru(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Yf(t)?t.files:Jf(t)?Kg(e.refs).value:Gg(t)?[...t.selectedOptions].map(({value:n})=>n):Us(t)?qg(e.refs).value:Xg(Be(t.value)?e.ref.value:t.value,e)}var UA=(e,t,n,r)=>{const o={};for(const s of e){const i=W(t,s);i&&ke(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Io=e=>Be(e)?e:vl(e)?e.source:Ke(e)?vl(e.value)?e.value.source:e.value:e,VA=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function hp(e,t,n){const r=W(e,n);if(r||Gf(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=W(t,s),l=W(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(l&&l.type)return{name:s,error:l};o.pop()}return{name:n}}var jA=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,$A=(e,t)=>!Vs(W(e,t)).length&&Xe(e,t);const BA={mode:Wt.onSubmit,reValidateMode:Wt.onChange,shouldFocusError:!0};function zA(e={},t){let n={...BA,...e},r={submitCount:0,isDirty:!1,isLoading:Vn(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},o={},s=Ke(n.defaultValues)||Ke(n.values)?Bt(n.defaultValues||n.values)||{}:{},i=n.shouldUnregister?{}:Bt(s),l={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const f={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:eu(),array:eu(),state:eu()},g=e.resetOptions&&e.resetOptions.keepDirtyValues,y=ip(n.mode),v=ip(n.reValidateMode),T=n.criteriaMode===Wt.all,p=S=>N=>{clearTimeout(c),c=setTimeout(S,N)},d=async S=>{if(f.isValid||S){const N=n.resolver?Lt((await J()).errors):await ye(o,!0);N!==r.isValid&&h.state.next({isValid:N})}},m=S=>f.isValidating&&h.state.next({isValidating:S}),R=(S,N=[],O,Y,z=!0,V=!0)=>{if(Y&&O){if(l.action=!0,V&&Array.isArray(W(o,S))){const te=O(W(o,S),Y.argA,Y.argB);z&&ke(o,S,te)}if(V&&Array.isArray(W(r.errors,S))){const te=O(W(r.errors,S),Y.argA,Y.argB);z&&ke(r.errors,S,te),$A(r.errors,S)}if(f.touchedFields&&V&&Array.isArray(W(r.touchedFields,S))){const te=O(W(r.touchedFields,S),Y.argA,Y.argB);z&&ke(r.touchedFields,S,te)}f.dirtyFields&&(r.dirtyFields=nu(s,i)),h.state.next({name:S,isDirty:B(S,N),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ke(i,S,N)},k=(S,N)=>{ke(r.errors,S,N),h.state.next({errors:r.errors})},x=(S,N,O,Y)=>{const z=W(o,S);if(z){const V=W(i,S,Be(O)?W(s,S):O);Be(V)||Y&&Y.defaultChecked||N?ke(i,S,N?V:ru(z._f)):ve(S,V),l.mount&&d()}},P=(S,N,O,Y,z)=>{let V=!1,te=!1;const Te={name:S};if(!O||Y){f.isDirty&&(te=r.isDirty,r.isDirty=Te.isDirty=B(),V=te!==Te.isDirty);const Ae=ur(W(s,S),N);te=W(r.dirtyFields,S),Ae?Xe(r.dirtyFields,S):ke(r.dirtyFields,S,!0),Te.dirtyFields=r.dirtyFields,V=V||f.dirtyFields&&te!==!Ae}if(O){const Ae=W(r.touchedFields,S);Ae||(ke(r.touchedFields,S,O),Te.touchedFields=r.touchedFields,V=V||f.touchedFields&&Ae!==O)}return V&&z&&h.state.next(Te),V?Te:{}},F=(S,N,O,Y)=>{const z=W(r.errors,S),V=f.isValid&&Un(N)&&r.isValid!==N;if(e.delayError&&O?(u=p(()=>k(S,O)),u(e.delayError)):(clearTimeout(c),u=null,O?ke(r.errors,S,O):Xe(r.errors,S)),(O?!ur(z,O):z)||!Lt(Y)||V){const te={...Y,...V&&Un(N)?{isValid:N}:{},errors:r.errors,name:S};r={...r,...te},h.state.next(te)}m(!1)},J=async S=>n.resolver(i,n.context,UA(S||a.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),K=async S=>{const{errors:N}=await J(S);if(S)for(const O of S){const Y=W(N,O);Y?ke(r.errors,O,Y):Xe(r.errors,O)}else r.errors=N;return N},ye=async(S,N,O={valid:!0})=>{for(const Y in S){const z=S[Y];if(z){const{_f:V,...te}=z;if(V){const Te=a.array.has(V.name),Ae=await dp(z,i,T,n.shouldUseNativeValidation&&!N,Te);if(Ae[V.name]&&(O.valid=!1,N))break;!N&&(W(Ae,V.name)?Te?FA(r.errors,Ae,V.name):ke(r.errors,V.name,Ae[V.name]):Xe(r.errors,V.name))}te&&await ye(te,N,O)}}return O.valid},ae=()=>{for(const S of a.unMount){const N=W(o,S);N&&(N._f.refs?N._f.refs.every(O=>!tu(O)):!tu(N._f.ref))&&U(S)}a.unMount=new Set},B=(S,N)=>(S&&N&&ke(i,S,N),!ur(ge(),s)),re=(S,N,O)=>Qg(S,a,{...l.mount?i:Be(N)?s:nn(S)?{[S]:N}:N},O,N),_e=S=>Vs(W(l.mount?i:s,S,e.shouldUnregister?W(s,S,[]):[])),ve=(S,N,O={})=>{const Y=W(o,S);let z=N;if(Y){const V=Y._f;V&&(!V.disabled&&ke(i,S,Xg(N,V)),z=yl(V.ref)&&ut(N)?"":N,Gg(V.ref)?[...V.ref.options].forEach(te=>te.selected=z.includes(te.value)):V.refs?Us(V.ref)?V.refs.length>1?V.refs.forEach(te=>(!te.defaultChecked||!te.disabled)&&(te.checked=Array.isArray(z)?!!z.find(Te=>Te===te.value):z===te.value)):V.refs[0]&&(V.refs[0].checked=!!z):V.refs.forEach(te=>te.checked=te.value===z):Yf(V.ref)?V.ref.value="":(V.ref.value=z,V.ref.type||h.values.next({name:S,values:{...i}})))}(O.shouldDirty||O.shouldTouch)&&P(S,z,O.shouldTouch,O.shouldDirty,!0),O.shouldValidate&&ee(S)},fe=(S,N,O)=>{for(const Y in N){const z=N[Y],V=`${S}.${Y}`,te=W(o,V);(a.array.has(S)||!gl(z)||te&&!te._f)&&!jr(z)?fe(V,z,O):ve(V,z,O)}},j=(S,N,O={})=>{const Y=W(o,S),z=a.array.has(S),V=Bt(N);ke(i,S,V),z?(h.array.next({name:S,values:{...i}}),(f.isDirty||f.dirtyFields)&&O.shouldDirty&&h.state.next({name:S,dirtyFields:nu(s,i),isDirty:B(S,V)})):Y&&!Y._f&&!ut(V)?fe(S,V,O):ve(S,V,O),lp(S,a)&&h.state.next({...r}),h.values.next({name:S,values:{...i}}),!l.mount&&t()},Z=async S=>{const N=S.target;let O=N.name,Y=!0;const z=W(o,O),V=()=>N.type?ru(z._f):jg(S);if(z){let te,Te;const Ae=V(),Tn=S.type===ml.BLUR||S.type===ml.FOCUS_OUT,da=!VA(z._f)&&!n.resolver&&!W(r.errors,O)&&!z._f.deps||jA(Tn,W(r.touchedFields,O),r.isSubmitted,v,y),vo=lp(O,a,Tn);ke(i,O,Ae),Tn?(z._f.onBlur&&z._f.onBlur(S),u&&u(0)):z._f.onChange&&z._f.onChange(S);const go=P(O,Ae,Tn,!1),ha=!Lt(go)||vo;if(!Tn&&h.values.next({name:O,type:S.type,values:{...i}}),da)return f.isValid&&d(),ha&&h.state.next({name:O,...vo?{}:go});if(!Tn&&vo&&h.state.next({...r}),m(!0),n.resolver){const{errors:js}=await J([O]),$s=hp(r.errors,o,O),Bs=hp(js,o,$s.name||O);te=Bs.error,O=Bs.name,Te=Lt(js)}else te=(await dp(z,i,T,n.shouldUseNativeValidation))[O],Y=Number.isNaN(Ae)||Ae===W(i,O,Ae),Y&&(te?Te=!1:f.isValid&&(Te=await ye(o,!0)));Y&&(z._f.deps&&ee(z._f.deps),F(O,Te,te,go))}},ee=async(S,N={})=>{let O,Y;const z=Pi(S);if(m(!0),n.resolver){const V=await K(Be(S)?S:z);O=Lt(V),Y=S?!z.some(te=>W(V,te)):O}else S?(Y=(await Promise.all(z.map(async V=>{const te=W(o,V);return await ye(te&&te._f?{[V]:te}:te)}))).every(Boolean),!(!Y&&!r.isValid)&&d()):Y=O=await ye(o);return h.state.next({...!nn(S)||f.isValid&&O!==r.isValid?{}:{name:S},...n.resolver||!S?{isValid:O}:{},errors:r.errors,isValidating:!1}),N.shouldFocus&&!Y&&Sc(o,V=>V&&W(r.errors,V),S?z:a.mount),Y},ge=S=>{const N={...s,...l.mount?i:{}};return Be(S)?N:nn(S)?W(N,S):S.map(O=>W(N,O))},E=(S,N)=>({invalid:!!W((N||r).errors,S),isDirty:!!W((N||r).dirtyFields,S),isTouched:!!W((N||r).touchedFields,S),error:W((N||r).errors,S)}),A=S=>{S&&Pi(S).forEach(N=>Xe(r.errors,N)),h.state.next({errors:S?r.errors:{}})},L=(S,N,O)=>{const Y=(W(o,S,{_f:{}})._f||{}).ref;ke(r.errors,S,{...N,ref:Y}),h.state.next({name:S,errors:r.errors,isValid:!1}),O&&O.shouldFocus&&Y&&Y.focus&&Y.focus()},$=(S,N)=>Vn(S)?h.values.subscribe({next:O=>S(re(void 0,N),O)}):re(S,N,!0),U=(S,N={})=>{for(const O of S?Pi(S):a.mount)a.mount.delete(O),a.array.delete(O),N.keepValue||(Xe(o,O),Xe(i,O)),!N.keepError&&Xe(r.errors,O),!N.keepDirty&&Xe(r.dirtyFields,O),!N.keepTouched&&Xe(r.touchedFields,O),!n.shouldUnregister&&!N.keepDefaultValue&&Xe(s,O);h.values.next({values:{...i}}),h.state.next({...r,...N.keepDirty?{isDirty:B()}:{}}),!N.keepIsValid&&d()},ne=({disabled:S,name:N,field:O,fields:Y})=>{if(Un(S)){const z=S?void 0:W(i,N,ru(O?O._f:W(Y,N)._f));ke(i,N,z),P(N,z,!1,!1,!0)}},ue=(S,N={})=>{let O=W(o,S);const Y=Un(N.disabled);return ke(o,S,{...O||{},_f:{...O&&O._f?O._f:{ref:{name:S}},name:S,mount:!0,...N}}),a.mount.add(S),O?ne({field:O,disabled:N.disabled,name:S}):x(S,!0,N.value),{...Y?{disabled:N.disabled}:{},...n.progressive?{required:!!N.required,min:Io(N.min),max:Io(N.max),minLength:Io(N.minLength),maxLength:Io(N.maxLength),pattern:Io(N.pattern)}:{},name:S,onChange:Z,onBlur:Z,ref:z=>{if(z){ue(S,N),O=W(o,S);const V=Be(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,te=IA(V),Te=O._f.refs||[];if(te?Te.find(Ae=>Ae===V):V===O._f.ref)return;ke(o,S,{_f:{...O._f,...te?{refs:[...Te.filter(tu),V,...Array.isArray(W(s,S))?[{}]:[]],ref:{type:V.type,name:S}}:{ref:V}}}),x(S,!1,void 0,V)}else O=W(o,S,{}),O._f&&(O._f.mount=!1),(n.shouldUnregister||N.shouldUnregister)&&!($g(a.array,S)&&l.action)&&a.unMount.add(S)}}},X=()=>n.shouldFocusError&&Sc(o,S=>S&&W(r.errors,S),a.mount),Ee=(S,N)=>async O=>{O&&(O.preventDefault&&O.preventDefault(),O.persist&&O.persist());let Y=Bt(i);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:z,values:V}=await J();r.errors=z,Y=V}else await ye(o);Xe(r.errors,"root"),Lt(r.errors)?(h.state.next({errors:{}}),await S(Y,O)):(N&&await N({...r.errors},O),X(),setTimeout(X)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Lt(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Me=(S,N={})=>{W(o,S)&&(Be(N.defaultValue)?j(S,W(s,S)):(j(S,N.defaultValue),ke(s,S,N.defaultValue)),N.keepTouched||Xe(r.touchedFields,S),N.keepDirty||(Xe(r.dirtyFields,S),r.isDirty=N.defaultValue?B(S,W(s,S)):B()),N.keepError||(Xe(r.errors,S),f.isValid&&d()),h.state.next({...r}))},de=(S,N={})=>{const O=S?Bt(S):s,Y=Bt(O),z=S&&!Lt(S)?Y:s;if(N.keepDefaultValues||(s=O),!N.keepValues){if(N.keepDirtyValues||g)for(const V of a.mount)W(r.dirtyFields,V)?ke(z,V,W(i,V)):j(V,W(z,V));else{if(Wf&&Be(S))for(const V of a.mount){const te=W(o,V);if(te&&te._f){const Te=Array.isArray(te._f.refs)?te._f.refs[0]:te._f.ref;if(yl(Te)){const Ae=Te.closest("form");if(Ae){Ae.reset();break}}}}o={}}i=e.shouldUnregister?N.keepDefaultValues?Bt(s):{}:Bt(z),h.array.next({values:{...z}}),h.values.next({values:{...z}})}a={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!l.mount&&t(),l.mount=!f.isValid||!!N.keepIsValid,l.watch=!!e.shouldUnregister,h.state.next({submitCount:N.keepSubmitCount?r.submitCount:0,isDirty:N.keepDirty?r.isDirty:!!(N.keepDefaultValues&&!ur(S,s)),isSubmitted:N.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:N.keepDirtyValues?r.dirtyFields:N.keepDefaultValues&&S?nu(s,S):{},touchedFields:N.keepTouched?r.touchedFields:{},errors:N.keepErrors?r.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Re=(S,N)=>de(Vn(S)?S(i):S,N);return{control:{register:ue,unregister:U,getFieldState:E,handleSubmit:Ee,setError:L,_executeSchema:J,_getWatch:re,_getDirty:B,_updateValid:d,_removeUnmounted:ae,_updateFieldArray:R,_updateDisabledField:ne,_getFieldArray:_e,_reset:de,_resetDefaultValues:()=>Vn(n.defaultValues)&&n.defaultValues().then(S=>{Re(S,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:S=>{r={...r,...S}},_subjects:h,_proxyFormState:f,get _fields(){return o},get _formValues(){return i},get _state(){return l},set _state(S){l=S},get _defaultValues(){return s},get _names(){return a},set _names(S){a=S},get _formState(){return r},set _formState(S){r=S},get _options(){return n},set _options(S){n={...n,...S}}},trigger:ee,register:ue,handleSubmit:Ee,watch:$,setValue:j,getValues:ge,reset:Re,resetField:Me,clearErrors:A,unregister:U,setError:L,setFocus:(S,N={})=>{const O=W(o,S),Y=O&&O._f;if(Y){const z=Y.refs?Y.refs[0]:Y.ref;z.focus&&(z.focus(),N.shouldSelect&&z.select())}},getFieldState:E}}function HA(e={}){const t=oe.useRef(),n=oe.useRef(),[r,o]=oe.useState({isDirty:!1,isValidating:!1,isLoading:Vn(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:Vn(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...zA(e,()=>o(i=>({...i}))),formState:r});const s=t.current.control;return s._options=e,Kf({subject:s._subjects.state,next:i=>{zg(i,s._proxyFormState,s._updateFormState,!0)&&o({...s._formState})}}),oe.useEffect(()=>{e.values&&!ur(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values):s._resetDefaultValues()},[e.values,s]),oe.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),t.current.formState=Bg(r,s),t.current}const Zg=({id:e,onCancel:t,onSubmit:n})=>{var B,re,_e,ve,fe,j,Z,ee,ge,E;const r=ia(),[o,s]=D.useState(!1),[,i]=Yn(Ds),[l,a]=D.useState(""),[u,c]=D.useState(),[f,h]=D.useState(!1),{data:g,error:y}=Vr({queryKey:["app-form",e],queryFn:()=>Qt.get(`/server/${e}/`).then(A=>A.data),enabled:!!e}),{data:v}=Vr({queryKey:["app-frameworks"],queryFn:()=>Qt.get("/frameworks/").then(A=>A.data)}),{data:T}=Vr({queryKey:["app-environments"],queryFn:()=>Qt.get("/conda-environments/").then(A=>A.data)}),{data:p}=Vr({queryKey:["app-profiles"],queryFn:()=>Qt.get("/spawner-profiles/").then(A=>A.data)}),{control:d,handleSubmit:m,reset:R,watch:k,formState:{errors:x}}=HA({defaultValues:{display_name:"",description:"",framework:"",thumbnail:"",filepath:"",conda_env:"",custom_command:"",profile:"",is_public:!1}}),P=k("framework"),F=({display_name:A,description:L,framework:$,thumbnail:U,filepath:ne,conda_env:ue,custom_command:X,profile:Ee})=>{const Me={servername:l||A,user_options:{jhub_app:!0,name:l||A,display_name:A,description:L||"",framework:$,thumbnail:U||"",filepath:ne||"",conda_env:ue||"",custom_command:X||"",profile:Ee||"",public:f}};s(!0),e?ae(Me,{onSuccess:async()=>{s(!1),r.invalidateQueries(["app-state"]),n&&n()},onError:async de=>{s(!1),i(de.message)}}):ye(Me,{onSuccess:async de=>{s(!1);const Re=Ug().user;if(Re&&(de==null?void 0:de.length)>1){const lt=de[1];window.location.assign(`/user/${Re}/${lt}`)}},onError:async de=>{s(!1),i(de.message)}})},J=async({servername:A,user_options:L})=>{const $={accept:"application/json","Content-Type":"multipart/form-data"},U=new FormData;return U.append("data",JSON.stringify({servername:A,user_options:L})),u&&U.append("thumbnail",u),(await Qt.post("/server/",U,{headers:$})).data},K=async({servername:A,user_options:L})=>{const $={accept:"application/json","Content-Type":"multipart/form-data"},U=new FormData;return U.append("data",JSON.stringify({servername:A,user_options:L})),u&&U.append("thumbnail",u),(await Qt.put(`/server/${A}/`,U,{headers:$})).data},{mutate:ye}=hl({mutationFn:J,retry:1}),{mutate:ae}=hl({mutationFn:K,retry:1});return D.useEffect(()=>{g!=null&&g.name&&(g!=null&&g.user_options)&&(a(g.name),R({...g.user_options}),h(g.user_options.public))},[g==null?void 0:g.name,g==null?void 0:g.user_options,R]),D.useEffect(()=>{y&&i(y.message)},[y,i]),w.jsxs("form",{id:"app-form",onSubmit:m(F),className:"form",children:[w.jsxs(un,{errors:(B=x.display_name)!=null&&B.message?[x.display_name.message]:void 0,children:[w.jsx(cn,{htmlFor:"display_name",required:!0,children:"Display Name"}),w.jsx(dn,{name:"display_name",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"display_name",autoFocus:!0})}),((re=x.display_name)==null?void 0:re.message)&&w.jsx(Fo,{errors:[x.display_name.message]})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"description",children:"Description"}),w.jsx(dn,{name:"description",control:d,render:({field:{ref:A,...L}})=>w.jsx(rN,{...L,id:"description"})})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"thumbnail",children:"Thumbnail"}),w.jsx(dn,{name:"thumbnail",control:d,render:({field:{ref:A,value:L,onChange:$,...U}})=>w.jsx(nN,{...U,id:"thumbnail",value:void 0,onChange:ne=>{const{files:ue}=ne.target,X=ue;c(X==null?void 0:X[0])}})})]}),w.jsxs(un,{errors:(_e=x.framework)!=null&&_e.message?[x.framework.message]:void 0,children:[w.jsx(cn,{htmlFor:"framework",required:!0,children:"Framework"}),w.jsx(dn,{name:"framework",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"framework",options:v?[{value:"",label:"Select..."},...v.map($=>({value:$.name,label:$.display_name}))]:[]})}),((ve=x.framework)==null?void 0:ve.message)&&w.jsx(Fo,{errors:[x.framework.message]})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"filepath",children:"Filepath"}),w.jsx(dn,{name:"filepath",control:d,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"filepath"})})]}),T&&T.length>0?w.jsxs(un,{errors:(fe=x.conda_env)!=null&&fe.message?[x.conda_env.message]:void 0,children:[w.jsx(cn,{htmlFor:"conda_env",required:!0,children:"Conda Environment"}),w.jsx(dn,{name:"conda_env",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"conda_env",options:[{value:"",label:"Select..."},...T.map($=>({value:$,label:$}))]})}),((j=x.conda_env)==null?void 0:j.message)&&w.jsx(Fo,{errors:[x.conda_env.message]})]}):w.jsx(w.Fragment,{}),p&&p.length>0?w.jsxs(un,{errors:(Z=x.profile)!=null&&Z.message?[x.profile.message]:void 0,children:[w.jsx(cn,{htmlFor:"profile",required:!0,children:"Spawner Profile"}),w.jsx(dn,{name:"profile",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"profile",options:[{value:"",label:"Select..."},...p.map($=>({value:$.slug,label:$.display_name}))]})}),((ee=x.profile)==null?void 0:ee.message)&&w.jsx(Fo,{errors:[x.profile.message]})]}):w.jsx(w.Fragment,{}),P==="custom"?w.jsxs(un,{errors:(ge=x.custom_command)!=null&&ge.message?[x.custom_command.message]:void 0,children:[w.jsx(cn,{htmlFor:"custom_command",required:!0,children:"Custom Command"}),w.jsx(dn,{name:"custom_command",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"custom_command"})}),((E=x.custom_command)==null?void 0:E.message)&&w.jsx(Fo,{errors:[x.custom_command.message]})]}):w.jsx(w.Fragment,{}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"is_public",children:"Allow Public Access"}),w.jsx(dn,{name:"is_public",control:d,render:({field:{ref:A,value:L,onChange:$,...U}})=>w.jsx(oN,{...U,id:"is_public",checked:f,onChange:()=>{h(!f)}})})]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",type:"button",variant:"secondary",onClick:t,children:"Cancel"}),w.jsx(Zt,{id:"submit-btn",type:"submit",disabled:o,children:"Submit"})]})]})},QA=({id:e,title:t,description:n,thumbnail:r,framework:o,url:s,username:i,ready:l=!1,isPublic:a=!1,isShared:u=!1})=>{const c=ia(),[f,h]=D.useState(!1),[,g]=Yn(Ds),[y,v]=D.useState(!1),[T,p]=D.useState(!1),[d,m]=D.useState(!1),[R,k]=D.useState(!1),x=async({id:fe})=>await Qt.post(`/server/${fe}/`),P=async({id:fe,remove:j})=>await Qt.delete(`/server/${fe}`,{params:{remove:j}}),{mutate:F}=hl({mutationFn:x,retry:1}),{mutate:J}=hl({mutationFn:P,retry:1}),K=()=>{h(!0),J({id:e,remove:!0},{onSuccess:async()=>{h(!1),m(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},ye=()=>{h(!0),F({id:e},{onSuccess:async()=>{h(!1),v(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},ae=()=>{h(!0),J({id:e,remove:!1},{onSuccess:async()=>{h(!1),p(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},B=[{id:"start",title:"Start",onClick:()=>v(!0),visible:!0,disabled:l},{id:"stop",title:"Stop",onClick:()=>p(!0),visible:!0,disabled:!l||u},{id:"edit",title:"Edit",onClick:()=>k(!0),visible:!0,disabled:u},{id:"delete",title:"Delete",onClick:()=>m(!0),visible:!0,disabled:u}],re=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to start ",w.jsx("b",{children:t}),"?"]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>v(!1),children:"Cancel"}),w.jsx(Zt,{id:"start-btn",variant:"primary",onClick:()=>ye(),disabled:f,children:"Start"})]})]}),_e=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to stop ",w.jsx("b",{children:t}),"?"]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>p(!1),children:"Cancel"}),w.jsx(Zt,{id:"stop-btn",variant:"primary",onClick:()=>ae(),disabled:f,children:"Stop"})]})]}),ve=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to delete ",w.jsx("b",{children:t}),"? This action is permanent and cannot be reversed."]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),w.jsx(Zt,{id:"delete-btn",variant:"primary",onClick:()=>K(),disabled:f,children:"Delete"})]})]});return w.jsxs("div",{className:"card",id:`card-${e}`,tabIndex:0,children:[w.jsxs("div",{className:"card-header-media",children:[w.jsxs("div",{className:"card-header-menu",children:[w.jsx(tN,{id:`card-menu-${e}`,items:B}),y&&w.jsx(Ho,{title:`Start ${t}`,setIsOpen:v,body:re}),T&&w.jsx(Ho,{title:`Stop ${t}`,setIsOpen:p,body:_e}),d&&w.jsx(Ho,{title:`Delete ${t}`,setIsOpen:m,body:ve}),R&&w.jsx(Ho,{title:`Edit ${t}`,setIsOpen:k,body:w.jsx(Zg,{id:e,onCancel:()=>k(!1),onSubmit:()=>k(!1)})})]}),w.jsx("div",{className:"card-header-img flex flex-row",children:r?w.jsx("img",{src:r,alt:"App thumb"}):w.jsx(w.Fragment,{})})]}),w.jsx("div",{className:"card-header",children:w.jsx("h3",{className:"font-bold",children:w.jsx("a",{href:s,children:t})})}),w.jsxs("div",{className:"card-body",children:[w.jsx("p",{className:"text-sm pb-2",children:n}),i?w.jsxs("div",{className:"text-sm",children:[w.jsx("span",{className:"font-bold",children:"Author: "}),i]}):w.jsx(w.Fragment,{})]}),w.jsxs("div",{className:"card-footer",children:[w.jsx(Kh,{id:`tag-${e}`,children:o}),a?w.jsx(Kh,{id:`tag-${e}`,className:"ml-2 bg-warning-light",children:"Public"}):w.jsx(w.Fragment,{})]})]})},pp=({appType:e="My",filter:t})=>{const[n]=Yn(Vf),[,r]=Yn(Ds),[o,s]=D.useState([]),{isLoading:i,error:l,data:a}=Vr({queryKey:["app-state"],queryFn:()=>Qt.get("/server/").then(u=>u.data).then(u=>u),enabled:!!n.user});return D.useEffect(()=>{if(!i&&a){const u=t.toLowerCase();s(()=>xA(a,e).filter(c=>{var f,h;return c.name.toLowerCase().includes(u)||((f=c.description)==null?void 0:f.toLowerCase().includes(u))||((h=c.framework)==null?void 0:h.toLowerCase().includes(u))}))}},[i,a,e,t]),D.useEffect(()=>{r(l?l.message:void 0)},[l,r]),w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 flex flex-align-center pb-12",children:[w.jsx("div",{className:"col-span-1",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[e," Apps"]})}),w.jsx("div",{className:"col-span-10",children:w.jsx("hr",{className:"spacer"})}),w.jsx("div",{className:"col-span-1 flex justify-end",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[o.length," apps"]})})]}),w.jsx("div",{className:"container grid pb-12",children:o.length>0?w.jsx("div",{className:"flex flex flex-row flex-wrap gap-4",children:o.map(u=>w.jsx(QA,{id:u.id,title:u.name,description:u.description,thumbnail:u.thumbnail,framework:u.framework,url:u.url,ready:u.ready,username:u.username,isPublic:u.public,isShared:e==="Shared"},`app-${u.id}`))}):w.jsx("div",{children:"No apps available"})})]})},WA=()=>{const[e]=Yn(Vf),[,t]=Yn(Ds),[n,r]=D.useState([]),{isLoading:o,error:s,data:i}=Vr({queryKey:["service-data"],queryFn:()=>Qt.get("/services/").then(a=>a.data).then(a=>a),enabled:!!e.user}),l=(a,u)=>{u?window.open(a,"_blank"):window.location.assign(a)};return D.useEffect(()=>{!o&&i&&r(()=>CA(i,e.user))},[o,i,e.user]),D.useEffect(()=>{t(s?s.message:void 0)},[s,t]),w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 flex flex-align-center pb-12",children:[w.jsx("div",{className:"col-span-1",children:w.jsx("h2",{className:"whitespace-nowrap font-bold",children:"Services"})}),w.jsx("div",{className:"col-span-10",children:w.jsx("hr",{className:"spacer"})}),w.jsx("div",{className:"col-span-1 flex justify-end",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[n.length," services"]})})]}),w.jsx("div",{className:"container grid pb-12",children:n.length>0?w.jsx("div",{className:"flex flex flex-row flex-wrap gap-4",children:n.map((a,u)=>w.jsx(Zt,{id:`service-${u}`,variant:"secondary",style:{minWidth:"180px"},onClick:()=>{l(a.url,a.external)},children:a.name},`service-${u}`))}):w.jsx("div",{children:"No services available"})})]})},mp=()=>{const[e,t]=D.useState(!1),[n]=Yn(Ds),[r,o]=D.useState(""),s=i=>{const l=i.target;o(l.value)};return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 pb-12",children:[w.jsx("div",{className:"md:col-span-2 xs:col-span-12",children:w.jsx("h1",{className:"text-3xl font-bold",children:"Home"})}),w.jsx("div",{className:"md:col-span-8 xs:col-span-8",children:w.jsx(ki,{id:"search",placeholder:"Search...","aria-label":"Search for an app",className:"w-full mt-0",onChange:s})}),w.jsxs("div",{className:"md:col-span-2 xs:col-span-4 flex justify-end",children:[w.jsx(Zt,{id:"create-app",onClick:()=>{t(!0)},children:"Create App"}),e&&w.jsx(Ho,{title:"Create New App",setIsOpen:t,body:w.jsx(Zg,{onCancel:()=>t(!1)})})]})]}),n&&w.jsx("div",{className:"container grid grid-cols-12 pb-2",children:w.jsx("div",{className:"col-span-12",children:w.jsx(Kk,{id:"alert-notification",type:"error",children:n})})}),w.jsx(WA,{}),w.jsx(pp,{appType:"My",filter:r}),w.jsx(pp,{appType:"Shared",filter:r})]})},qA=new gk,KA=()=>{const[,e]=Yn(Vf);return D.useEffect(()=>{e(Ug())},[e]),w.jsx(bk,{client:qA,children:w.jsx("div",{children:w.jsx("main",{className:"my-6",children:w.jsxs(c_,{children:[w.jsx(Zu,{path:"/home",element:w.jsx(mp,{})}),w.jsx(Zu,{path:"/",element:w.jsx(mp,{})})]})})})})};ou.createRoot(document.getElementById("root")).render(w.jsx(oe.StrictMode,{children:w.jsx(d_,{basename:"/hub",children:w.jsx(rk,{children:w.jsx(KA,{})})})})); +`):" "+np(s[0]):"as no adapter specified";throw new Se("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:yc};function Za(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Is(null,e)}function rp(e){return Za(e),e.headers=gn.from(e.headers),e.data=Xa.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Dg.getAdapter(e.adapter||zf.adapter)(e).then(function(r){return Za(e),r.data=Xa.call(e,e.transformResponse,r),r.headers=gn.from(r.headers),r},function(r){return bg(r)||(Za(e),r&&r.response&&(r.response.data=Xa.call(e,e.transformResponse,r.response),r.response.headers=gn.from(r.response.headers))),Promise.reject(r)})}const op=e=>e instanceof gn?e.toJSON():e;function ao(e,t){t=t||{};const n={};function r(u,c,f){return b.isPlainObject(u)&&b.isPlainObject(c)?b.merge.call({caseless:f},u,c):b.isPlainObject(c)?b.merge({},c):b.isArray(c)?c.slice():c}function o(u,c,f){if(b.isUndefined(c)){if(!b.isUndefined(u))return r(void 0,u,f)}else return r(u,c,f)}function s(u,c){if(!b.isUndefined(c))return r(void 0,c)}function i(u,c){if(b.isUndefined(c)){if(!b.isUndefined(u))return r(void 0,u)}else return r(void 0,c)}function l(u,c,f){if(f in t)return r(u,c);if(f in e)return r(void 0,u)}const a={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(u,c)=>o(op(u),op(c),!0)};return b.forEach(Object.keys(Object.assign({},e,t)),function(c){const f=a[c]||o,h=f(e[c],t[c],c);b.isUndefined(h)&&f!==l||(n[c]=h)}),n}const Mg="1.6.2",Hf={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Hf[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const sp={};Hf.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Mg+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,l)=>{if(t===!1)throw new Se(o(i," has been removed"+(n?" in "+n:"")),Se.ERR_DEPRECATED);return n&&!sp[i]&&(sp[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,l):!0}};function vA(e,t,n){if(typeof e!="object")throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const l=e[s],a=l===void 0||i(l,s,e);if(a!==!0)throw new Se("option "+s+" must be "+a,Se.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Se("Unknown option "+s,Se.ERR_BAD_OPTION)}}const vc={assertOptions:vA,validators:Hf},Nn=vc.validators;class pl{constructor(t){this.defaults=t,this.interceptors={request:new Zh,response:new Zh}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ao(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&vc.assertOptions(r,{silentJSONParsing:Nn.transitional(Nn.boolean),forcedJSONParsing:Nn.transitional(Nn.boolean),clarifyTimeoutError:Nn.transitional(Nn.boolean)},!1),o!=null&&(b.isFunction(o)?n.paramsSerializer={serialize:o}:vc.assertOptions(o,{encode:Nn.function,serialize:Nn.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&b.merge(s.common,s[n.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],y=>{delete s[y]}),n.headers=gn.concat(i,s);const l=[];let a=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(a=a&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const u=[];this.interceptors.response.forEach(function(v){u.push(v.fulfilled,v.rejected)});let c,f=0,h;if(!a){const y=[rp.bind(this),void 0];for(y.unshift.apply(y,l),y.push.apply(y,u),h=y.length,c=Promise.resolve(n);f{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{r.subscribe(l),s=l}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,l){r.reason||(r.reason=new Is(s,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Qf(function(o){t=o}),cancel:t}}}const gA=Qf;function SA(e){return function(n){return e.apply(null,n)}}function wA(e){return b.isObject(e)&&e.isAxiosError===!0}const gc={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(gc).forEach(([e,t])=>{gc[t]=e});const _A=gc;function Ig(e){const t=new Li(e),n=vg(Li.prototype.request,t);return b.extend(n,Li.prototype,t,{allOwnKeys:!0}),b.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Ig(ao(e,o))},n}const Qe=Ig(zf);Qe.Axios=Li;Qe.CanceledError=Is;Qe.CancelToken=gA;Qe.isCancel=bg;Qe.VERSION=Mg;Qe.toFormData=ca;Qe.AxiosError=Se;Qe.Cancel=Qe.CanceledError;Qe.all=function(t){return Promise.all(t)};Qe.spread=SA;Qe.isAxiosError=wA;Qe.mergeConfig=ao;Qe.AxiosHeaders=gn;Qe.formToJSON=e=>Og(b.isHTMLForm(e)?new FormData(e):e);Qe.getAdapter=Dg.getAdapter;Qe.HttpStatusCode=_A;Qe.default=Qe;const RA=Qe,Qt=RA.create({baseURL:"/services/japps",headers:{"Content-Type":"application/json"}});Qt.interceptors.response.use(e=>e,e=>{const t=e.response.status;(e.response.status===401||t===403)&&(window.location.href="/services/japps/jhub-login")});const EA="This field is required.",Mo={required:EA},Ug=()=>window.jhdata,CA=(e,t)=>{var r;const n=[];for(const o in e)if(Object.hasOwnProperty.call(e,o)){const s=e[o];s.display===!0&&s.info.name&&n.push({name:s.info.name,url:(r=s.info.url)==null?void 0:r.replace("[USER]",t),external:s.info.external})}return n},xA=(e,t)=>{const n=[];t.toLowerCase()==="shared"?n.push(...e.shared_apps):n.push(...e.user_apps);const r=[];return n.forEach(o=>{var s;if((s=o.user_options)!=null&&s.jhub_app){const i=o.user_options;r.push({id:i.name,name:i.display_name,description:i.description,framework:TA(i.framework),url:o.url,thumbnail:i.thumbnail,username:o.username,ready:o.ready,public:i.public})}}),r},TA=e=>e.charAt(0).toUpperCase()+e.slice(1);var Us=e=>e.type==="checkbox",jr=e=>e instanceof Date,ut=e=>e==null;const Vg=e=>typeof e=="object";var Ke=e=>!ut(e)&&!Array.isArray(e)&&Vg(e)&&!jr(e),jg=e=>Ke(e)&&e.target?Us(e.target)?e.target.checked:e.target.value:e,kA=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,$g=(e,t)=>e.has(kA(t)),NA=e=>{const t=e.constructor&&e.constructor.prototype;return Ke(t)&&t.hasOwnProperty("isPrototypeOf")},Wf=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Bt(e){let t;const n=Array.isArray(e);if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Wf&&(e instanceof Blob||e instanceof FileList))&&(n||Ke(e)))if(t=n?[]:{},!n&&!NA(e))t=e;else for(const r in e)e.hasOwnProperty(r)&&(t[r]=Bt(e[r]));else return e;return t}var Vs=e=>Array.isArray(e)?e.filter(Boolean):[],Be=e=>e===void 0,W=(e,t,n)=>{if(!t||!Ke(e))return n;const r=Vs(t.split(/[,[\].]+?/)).reduce((o,s)=>ut(o)?o:o[s],e);return Be(r)||r===e?Be(e[t])?n:e[t]:r},Un=e=>typeof e=="boolean";const ml={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Wt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},fn={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},AA=oe.createContext(null),qf=()=>oe.useContext(AA);var Bg=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Wt.all&&(t._proxyFormState[i]=!r||Wt.all),n&&(n[i]=!0),e[i]}});return o},Lt=e=>Ke(e)&&!Object.keys(e).length,zg=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Lt(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===(!r||Wt.all))},Pi=e=>Array.isArray(e)?e:[e],Hg=(e,t,n)=>!e||!t||e===t||Pi(e).some(r=>r&&(n?r===t:r.startsWith(t)||t.startsWith(r)));function Kf(e){const t=oe.useRef(e);t.current=e,oe.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}function LA(e){const t=qf(),{control:n=t.control,disabled:r,name:o,exact:s}=e||{},[i,l]=oe.useState(n._formState),a=oe.useRef(!0),u=oe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),c=oe.useRef(o);return c.current=o,Kf({disabled:r,next:f=>a.current&&Hg(c.current,f.name,s)&&zg(f,u.current,n._updateFormState)&&l({...n._formState,...f}),subject:n._subjects.state}),oe.useEffect(()=>(a.current=!0,u.current.isValid&&n._updateValid(!0),()=>{a.current=!1}),[n]),Bg(i,n,u.current,!1)}var nn=e=>typeof e=="string",Qg=(e,t,n,r,o)=>nn(e)?(r&&t.watch.add(e),W(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),W(n,s))):(r&&(t.watchAll=!0),n);function PA(e){const t=qf(),{control:n=t.control,name:r,defaultValue:o,disabled:s,exact:i}=e||{},l=oe.useRef(r);l.current=r,Kf({disabled:s,subject:n._subjects.values,next:c=>{Hg(l.current,c.name,i)&&u(Bt(Qg(l.current,n._names,c.values||n._formValues,!1,o)))}});const[a,u]=oe.useState(n._getWatch(r,o));return oe.useEffect(()=>n._removeUnmounted()),a}var Gf=e=>/^\w*$/.test(e),Wg=e=>Vs(e.replace(/["|']|\]/g,"").split(/\.|\[/));function ke(e,t,n){let r=-1;const o=Gf(t)?[t]:Wg(t),s=o.length,i=s-1;for(;++r{const c=o._options.shouldUnregister||s,f=(h,g)=>{const y=W(o._fields,h);y&&(y._f.mount=g)};if(f(n,!0),c){const h=Bt(W(o._options.defaultValues,n));ke(o._defaultValues,n,h),Be(W(o._formValues,n))&&ke(o._formValues,n,h)}return()=>{(i?c&&!o._state.action:c)?o.unregister(n):f(n,!1)}},[n,o,i,s]),oe.useEffect(()=>{W(o._fields,n)&&o._updateDisabledField({disabled:r,fields:o._fields,name:n})},[r,n,o]),{field:{name:n,value:l,...Un(r)?{disabled:r}:{},onChange:oe.useCallback(c=>u.current.onChange({target:{value:jg(c),name:n},type:ml.CHANGE}),[n]),onBlur:oe.useCallback(()=>u.current.onBlur({target:{value:W(o._formValues,n),name:n},type:ml.BLUR}),[n,o]),ref:c=>{const f=W(o._fields,n);f&&c&&(f._f.ref={focus:()=>c.focus(),select:()=>c.select(),setCustomValidity:h=>c.setCustomValidity(h),reportValidity:()=>c.reportValidity()})}},formState:a,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!W(a.errors,n)},isDirty:{enumerable:!0,get:()=>!!W(a.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!W(a.touchedFields,n)},error:{enumerable:!0,get:()=>W(a.errors,n)}})}}const dn=e=>e.render(OA(e));var bA=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{};const Sc=(e,t,n)=>{for(const r of n||Object.keys(e)){const o=W(e,r);if(o){const{_f:s,...i}=o;if(s&&t(s.name)){if(s.ref.focus){s.ref.focus();break}else if(s.refs&&s.refs[0].focus){s.refs[0].focus();break}}else Ke(i)&&Sc(i,t)}}};var ip=e=>({isOnSubmit:!e||e===Wt.onSubmit,isOnBlur:e===Wt.onBlur,isOnChange:e===Wt.onChange,isOnAll:e===Wt.all,isOnTouch:e===Wt.onTouched}),lp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length)))),FA=(e,t,n)=>{const r=Vs(W(e,n));return ke(r,"root",t[n]),ke(e,n,r),e},Yf=e=>e.type==="file",Vn=e=>typeof e=="function",yl=e=>{if(!Wf)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Oi=e=>nn(e),Jf=e=>e.type==="radio",vl=e=>e instanceof RegExp;const ap={value:!1,isValid:!1},up={value:!0,isValid:!0};var qg=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Be(e[0].attributes.value)?Be(e[0].value)||e[0].value===""?up:{value:e[0].value,isValid:!0}:up:ap}return ap};const cp={isValid:!1,value:null};var Kg=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,cp):cp;function fp(e,t,n="validate"){if(Oi(e)||Array.isArray(e)&&e.every(Oi)||Un(e)&&!e)return{type:n,message:Oi(e)?e:"",ref:t}}var Tr=e=>Ke(e)&&!vl(e)?e:{value:e,message:""},dp=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:l,maxLength:a,minLength:u,min:c,max:f,pattern:h,validate:g,name:y,valueAsNumber:v,mount:T,disabled:p}=e._f,d=W(t,y);if(!T||p)return{};const m=i?i[0]:s,R=ae=>{r&&m.reportValidity&&(m.setCustomValidity(Un(ae)?"":ae||""),m.reportValidity())},k={},x=Jf(s),P=Us(s),F=x||P,J=(v||Yf(s))&&Be(s.value)&&Be(d)||yl(s)&&s.value===""||d===""||Array.isArray(d)&&!d.length,K=bA.bind(null,y,n,k),ye=(ae,B,re,_e=fn.maxLength,ve=fn.minLength)=>{const fe=ae?B:re;k[y]={type:ae?_e:ve,message:fe,ref:s,...K(ae?_e:ve,fe)}};if(o?!Array.isArray(d)||!d.length:l&&(!F&&(J||ut(d))||Un(d)&&!d||P&&!qg(i).isValid||x&&!Kg(i).isValid)){const{value:ae,message:B}=Oi(l)?{value:!!l,message:l}:Tr(l);if(ae&&(k[y]={type:fn.required,message:B,ref:m,...K(fn.required,B)},!n))return R(B),k}if(!J&&(!ut(c)||!ut(f))){let ae,B;const re=Tr(f),_e=Tr(c);if(!ut(d)&&!isNaN(d)){const ve=s.valueAsNumber||d&&+d;ut(re.value)||(ae=ve>re.value),ut(_e.value)||(B=ve<_e.value)}else{const ve=s.valueAsDate||new Date(d),fe=ee=>new Date(new Date().toDateString()+" "+ee),j=s.type=="time",Z=s.type=="week";nn(re.value)&&d&&(ae=j?fe(d)>fe(re.value):Z?d>re.value:ve>new Date(re.value)),nn(_e.value)&&d&&(B=j?fe(d)+ae.value,_e=!ut(B.value)&&d.length<+B.value;if((re||_e)&&(ye(re,ae.message,B.message),!n))return R(k[y].message),k}if(h&&!J&&nn(d)){const{value:ae,message:B}=Tr(h);if(vl(ae)&&!d.match(ae)&&(k[y]={type:fn.pattern,message:B,ref:s,...K(fn.pattern,B)},!n))return R(B),k}if(g){if(Vn(g)){const ae=await g(d,t),B=fp(ae,m);if(B&&(k[y]={...B,...K(fn.validate,B.message)},!n))return R(B.message),k}else if(Ke(g)){let ae={};for(const B in g){if(!Lt(ae)&&!n)break;const re=fp(await g[B](d,t),m,B);re&&(ae={...re,...K(B,re.message)},R(re.message),n&&(k[y]=ae))}if(!Lt(ae)&&(k[y]={ref:m,...ae},!n))return k}}return R(!0),k};function DA(e,t){const n=t.slice(0,-1).length;let r=0;for(;r{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}}var gl=e=>ut(e)||!Vg(e);function ur(e,t){if(gl(e)||gl(t))return e===t;if(jr(e)&&jr(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(jr(s)&&jr(i)||Ke(s)&&Ke(i)||Array.isArray(s)&&Array.isArray(i)?!ur(s,i):s!==i)return!1}}return!0}var Gg=e=>e.type==="select-multiple",IA=e=>Jf(e)||Us(e),tu=e=>yl(e)&&e.isConnected,Yg=e=>{for(const t in e)if(Vn(e[t]))return!0;return!1};function Sl(e,t={}){const n=Array.isArray(e);if(Ke(e)||n)for(const r in e)Array.isArray(e[r])||Ke(e[r])&&!Yg(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Sl(e[r],t[r])):ut(e[r])||(t[r]=!0);return t}function Jg(e,t,n){const r=Array.isArray(e);if(Ke(e)||r)for(const o in e)Array.isArray(e[o])||Ke(e[o])&&!Yg(e[o])?Be(t)||gl(n[o])?n[o]=Array.isArray(e[o])?Sl(e[o],[]):{...Sl(e[o])}:Jg(e[o],ut(t)?{}:t[o],n[o]):n[o]=!ur(e[o],t[o]);return n}var nu=(e,t)=>Jg(e,t,Sl(t)),Xg=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Be(e)?e:t?e===""?NaN:e&&+e:n&&nn(e)?new Date(e):r?r(e):e;function ru(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Yf(t)?t.files:Jf(t)?Kg(e.refs).value:Gg(t)?[...t.selectedOptions].map(({value:n})=>n):Us(t)?qg(e.refs).value:Xg(Be(t.value)?e.ref.value:t.value,e)}var UA=(e,t,n,r)=>{const o={};for(const s of e){const i=W(t,s);i&&ke(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Io=e=>Be(e)?e:vl(e)?e.source:Ke(e)?vl(e.value)?e.value.source:e.value:e,VA=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function hp(e,t,n){const r=W(e,n);if(r||Gf(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=W(t,s),l=W(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(l&&l.type)return{name:s,error:l};o.pop()}return{name:n}}var jA=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,$A=(e,t)=>!Vs(W(e,t)).length&&Xe(e,t);const BA={mode:Wt.onSubmit,reValidateMode:Wt.onChange,shouldFocusError:!0};function zA(e={},t){let n={...BA,...e},r={submitCount:0,isDirty:!1,isLoading:Vn(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},o={},s=Ke(n.defaultValues)||Ke(n.values)?Bt(n.defaultValues||n.values)||{}:{},i=n.shouldUnregister?{}:Bt(s),l={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,c=0;const f={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={values:eu(),array:eu(),state:eu()},g=e.resetOptions&&e.resetOptions.keepDirtyValues,y=ip(n.mode),v=ip(n.reValidateMode),T=n.criteriaMode===Wt.all,p=S=>N=>{clearTimeout(c),c=setTimeout(S,N)},d=async S=>{if(f.isValid||S){const N=n.resolver?Lt((await J()).errors):await ye(o,!0);N!==r.isValid&&h.state.next({isValid:N})}},m=S=>f.isValidating&&h.state.next({isValidating:S}),R=(S,N=[],O,Y,z=!0,V=!0)=>{if(Y&&O){if(l.action=!0,V&&Array.isArray(W(o,S))){const te=O(W(o,S),Y.argA,Y.argB);z&&ke(o,S,te)}if(V&&Array.isArray(W(r.errors,S))){const te=O(W(r.errors,S),Y.argA,Y.argB);z&&ke(r.errors,S,te),$A(r.errors,S)}if(f.touchedFields&&V&&Array.isArray(W(r.touchedFields,S))){const te=O(W(r.touchedFields,S),Y.argA,Y.argB);z&&ke(r.touchedFields,S,te)}f.dirtyFields&&(r.dirtyFields=nu(s,i)),h.state.next({name:S,isDirty:B(S,N),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ke(i,S,N)},k=(S,N)=>{ke(r.errors,S,N),h.state.next({errors:r.errors})},x=(S,N,O,Y)=>{const z=W(o,S);if(z){const V=W(i,S,Be(O)?W(s,S):O);Be(V)||Y&&Y.defaultChecked||N?ke(i,S,N?V:ru(z._f)):ve(S,V),l.mount&&d()}},P=(S,N,O,Y,z)=>{let V=!1,te=!1;const Te={name:S};if(!O||Y){f.isDirty&&(te=r.isDirty,r.isDirty=Te.isDirty=B(),V=te!==Te.isDirty);const Ae=ur(W(s,S),N);te=W(r.dirtyFields,S),Ae?Xe(r.dirtyFields,S):ke(r.dirtyFields,S,!0),Te.dirtyFields=r.dirtyFields,V=V||f.dirtyFields&&te!==!Ae}if(O){const Ae=W(r.touchedFields,S);Ae||(ke(r.touchedFields,S,O),Te.touchedFields=r.touchedFields,V=V||f.touchedFields&&Ae!==O)}return V&&z&&h.state.next(Te),V?Te:{}},F=(S,N,O,Y)=>{const z=W(r.errors,S),V=f.isValid&&Un(N)&&r.isValid!==N;if(e.delayError&&O?(u=p(()=>k(S,O)),u(e.delayError)):(clearTimeout(c),u=null,O?ke(r.errors,S,O):Xe(r.errors,S)),(O?!ur(z,O):z)||!Lt(Y)||V){const te={...Y,...V&&Un(N)?{isValid:N}:{},errors:r.errors,name:S};r={...r,...te},h.state.next(te)}m(!1)},J=async S=>n.resolver(i,n.context,UA(S||a.mount,o,n.criteriaMode,n.shouldUseNativeValidation)),K=async S=>{const{errors:N}=await J(S);if(S)for(const O of S){const Y=W(N,O);Y?ke(r.errors,O,Y):Xe(r.errors,O)}else r.errors=N;return N},ye=async(S,N,O={valid:!0})=>{for(const Y in S){const z=S[Y];if(z){const{_f:V,...te}=z;if(V){const Te=a.array.has(V.name),Ae=await dp(z,i,T,n.shouldUseNativeValidation&&!N,Te);if(Ae[V.name]&&(O.valid=!1,N))break;!N&&(W(Ae,V.name)?Te?FA(r.errors,Ae,V.name):ke(r.errors,V.name,Ae[V.name]):Xe(r.errors,V.name))}te&&await ye(te,N,O)}}return O.valid},ae=()=>{for(const S of a.unMount){const N=W(o,S);N&&(N._f.refs?N._f.refs.every(O=>!tu(O)):!tu(N._f.ref))&&U(S)}a.unMount=new Set},B=(S,N)=>(S&&N&&ke(i,S,N),!ur(ge(),s)),re=(S,N,O)=>Qg(S,a,{...l.mount?i:Be(N)?s:nn(S)?{[S]:N}:N},O,N),_e=S=>Vs(W(l.mount?i:s,S,e.shouldUnregister?W(s,S,[]):[])),ve=(S,N,O={})=>{const Y=W(o,S);let z=N;if(Y){const V=Y._f;V&&(!V.disabled&&ke(i,S,Xg(N,V)),z=yl(V.ref)&&ut(N)?"":N,Gg(V.ref)?[...V.ref.options].forEach(te=>te.selected=z.includes(te.value)):V.refs?Us(V.ref)?V.refs.length>1?V.refs.forEach(te=>(!te.defaultChecked||!te.disabled)&&(te.checked=Array.isArray(z)?!!z.find(Te=>Te===te.value):z===te.value)):V.refs[0]&&(V.refs[0].checked=!!z):V.refs.forEach(te=>te.checked=te.value===z):Yf(V.ref)?V.ref.value="":(V.ref.value=z,V.ref.type||h.values.next({name:S,values:{...i}})))}(O.shouldDirty||O.shouldTouch)&&P(S,z,O.shouldTouch,O.shouldDirty,!0),O.shouldValidate&&ee(S)},fe=(S,N,O)=>{for(const Y in N){const z=N[Y],V=`${S}.${Y}`,te=W(o,V);(a.array.has(S)||!gl(z)||te&&!te._f)&&!jr(z)?fe(V,z,O):ve(V,z,O)}},j=(S,N,O={})=>{const Y=W(o,S),z=a.array.has(S),V=Bt(N);ke(i,S,V),z?(h.array.next({name:S,values:{...i}}),(f.isDirty||f.dirtyFields)&&O.shouldDirty&&h.state.next({name:S,dirtyFields:nu(s,i),isDirty:B(S,V)})):Y&&!Y._f&&!ut(V)?fe(S,V,O):ve(S,V,O),lp(S,a)&&h.state.next({...r}),h.values.next({name:S,values:{...i}}),!l.mount&&t()},Z=async S=>{const N=S.target;let O=N.name,Y=!0;const z=W(o,O),V=()=>N.type?ru(z._f):jg(S);if(z){let te,Te;const Ae=V(),Tn=S.type===ml.BLUR||S.type===ml.FOCUS_OUT,da=!VA(z._f)&&!n.resolver&&!W(r.errors,O)&&!z._f.deps||jA(Tn,W(r.touchedFields,O),r.isSubmitted,v,y),vo=lp(O,a,Tn);ke(i,O,Ae),Tn?(z._f.onBlur&&z._f.onBlur(S),u&&u(0)):z._f.onChange&&z._f.onChange(S);const go=P(O,Ae,Tn,!1),ha=!Lt(go)||vo;if(!Tn&&h.values.next({name:O,type:S.type,values:{...i}}),da)return f.isValid&&d(),ha&&h.state.next({name:O,...vo?{}:go});if(!Tn&&vo&&h.state.next({...r}),m(!0),n.resolver){const{errors:js}=await J([O]),$s=hp(r.errors,o,O),Bs=hp(js,o,$s.name||O);te=Bs.error,O=Bs.name,Te=Lt(js)}else te=(await dp(z,i,T,n.shouldUseNativeValidation))[O],Y=Number.isNaN(Ae)||Ae===W(i,O,Ae),Y&&(te?Te=!1:f.isValid&&(Te=await ye(o,!0)));Y&&(z._f.deps&&ee(z._f.deps),F(O,Te,te,go))}},ee=async(S,N={})=>{let O,Y;const z=Pi(S);if(m(!0),n.resolver){const V=await K(Be(S)?S:z);O=Lt(V),Y=S?!z.some(te=>W(V,te)):O}else S?(Y=(await Promise.all(z.map(async V=>{const te=W(o,V);return await ye(te&&te._f?{[V]:te}:te)}))).every(Boolean),!(!Y&&!r.isValid)&&d()):Y=O=await ye(o);return h.state.next({...!nn(S)||f.isValid&&O!==r.isValid?{}:{name:S},...n.resolver||!S?{isValid:O}:{},errors:r.errors,isValidating:!1}),N.shouldFocus&&!Y&&Sc(o,V=>V&&W(r.errors,V),S?z:a.mount),Y},ge=S=>{const N={...s,...l.mount?i:{}};return Be(S)?N:nn(S)?W(N,S):S.map(O=>W(N,O))},E=(S,N)=>({invalid:!!W((N||r).errors,S),isDirty:!!W((N||r).dirtyFields,S),isTouched:!!W((N||r).touchedFields,S),error:W((N||r).errors,S)}),A=S=>{S&&Pi(S).forEach(N=>Xe(r.errors,N)),h.state.next({errors:S?r.errors:{}})},L=(S,N,O)=>{const Y=(W(o,S,{_f:{}})._f||{}).ref;ke(r.errors,S,{...N,ref:Y}),h.state.next({name:S,errors:r.errors,isValid:!1}),O&&O.shouldFocus&&Y&&Y.focus&&Y.focus()},$=(S,N)=>Vn(S)?h.values.subscribe({next:O=>S(re(void 0,N),O)}):re(S,N,!0),U=(S,N={})=>{for(const O of S?Pi(S):a.mount)a.mount.delete(O),a.array.delete(O),N.keepValue||(Xe(o,O),Xe(i,O)),!N.keepError&&Xe(r.errors,O),!N.keepDirty&&Xe(r.dirtyFields,O),!N.keepTouched&&Xe(r.touchedFields,O),!n.shouldUnregister&&!N.keepDefaultValue&&Xe(s,O);h.values.next({values:{...i}}),h.state.next({...r,...N.keepDirty?{isDirty:B()}:{}}),!N.keepIsValid&&d()},ne=({disabled:S,name:N,field:O,fields:Y})=>{if(Un(S)){const z=S?void 0:W(i,N,ru(O?O._f:W(Y,N)._f));ke(i,N,z),P(N,z,!1,!1,!0)}},ue=(S,N={})=>{let O=W(o,S);const Y=Un(N.disabled);return ke(o,S,{...O||{},_f:{...O&&O._f?O._f:{ref:{name:S}},name:S,mount:!0,...N}}),a.mount.add(S),O?ne({field:O,disabled:N.disabled,name:S}):x(S,!0,N.value),{...Y?{disabled:N.disabled}:{},...n.progressive?{required:!!N.required,min:Io(N.min),max:Io(N.max),minLength:Io(N.minLength),maxLength:Io(N.maxLength),pattern:Io(N.pattern)}:{},name:S,onChange:Z,onBlur:Z,ref:z=>{if(z){ue(S,N),O=W(o,S);const V=Be(z.value)&&z.querySelectorAll&&z.querySelectorAll("input,select,textarea")[0]||z,te=IA(V),Te=O._f.refs||[];if(te?Te.find(Ae=>Ae===V):V===O._f.ref)return;ke(o,S,{_f:{...O._f,...te?{refs:[...Te.filter(tu),V,...Array.isArray(W(s,S))?[{}]:[]],ref:{type:V.type,name:S}}:{ref:V}}}),x(S,!1,void 0,V)}else O=W(o,S,{}),O._f&&(O._f.mount=!1),(n.shouldUnregister||N.shouldUnregister)&&!($g(a.array,S)&&l.action)&&a.unMount.add(S)}}},X=()=>n.shouldFocusError&&Sc(o,S=>S&&W(r.errors,S),a.mount),Ee=(S,N)=>async O=>{O&&(O.preventDefault&&O.preventDefault(),O.persist&&O.persist());let Y=Bt(i);if(h.state.next({isSubmitting:!0}),n.resolver){const{errors:z,values:V}=await J();r.errors=z,Y=V}else await ye(o);Xe(r.errors,"root"),Lt(r.errors)?(h.state.next({errors:{}}),await S(Y,O)):(N&&await N({...r.errors},O),X(),setTimeout(X)),h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Lt(r.errors),submitCount:r.submitCount+1,errors:r.errors})},Me=(S,N={})=>{W(o,S)&&(Be(N.defaultValue)?j(S,W(s,S)):(j(S,N.defaultValue),ke(s,S,N.defaultValue)),N.keepTouched||Xe(r.touchedFields,S),N.keepDirty||(Xe(r.dirtyFields,S),r.isDirty=N.defaultValue?B(S,W(s,S)):B()),N.keepError||(Xe(r.errors,S),f.isValid&&d()),h.state.next({...r}))},de=(S,N={})=>{const O=S?Bt(S):s,Y=Bt(O),z=S&&!Lt(S)?Y:s;if(N.keepDefaultValues||(s=O),!N.keepValues){if(N.keepDirtyValues||g)for(const V of a.mount)W(r.dirtyFields,V)?ke(z,V,W(i,V)):j(V,W(z,V));else{if(Wf&&Be(S))for(const V of a.mount){const te=W(o,V);if(te&&te._f){const Te=Array.isArray(te._f.refs)?te._f.refs[0]:te._f.ref;if(yl(Te)){const Ae=Te.closest("form");if(Ae){Ae.reset();break}}}}o={}}i=e.shouldUnregister?N.keepDefaultValues?Bt(s):{}:Bt(z),h.array.next({values:{...z}}),h.values.next({values:{...z}})}a={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!l.mount&&t(),l.mount=!f.isValid||!!N.keepIsValid,l.watch=!!e.shouldUnregister,h.state.next({submitCount:N.keepSubmitCount?r.submitCount:0,isDirty:N.keepDirty?r.isDirty:!!(N.keepDefaultValues&&!ur(S,s)),isSubmitted:N.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:N.keepDirtyValues?r.dirtyFields:N.keepDefaultValues&&S?nu(s,S):{},touchedFields:N.keepTouched?r.touchedFields:{},errors:N.keepErrors?r.errors:{},isSubmitSuccessful:N.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Re=(S,N)=>de(Vn(S)?S(i):S,N);return{control:{register:ue,unregister:U,getFieldState:E,handleSubmit:Ee,setError:L,_executeSchema:J,_getWatch:re,_getDirty:B,_updateValid:d,_removeUnmounted:ae,_updateFieldArray:R,_updateDisabledField:ne,_getFieldArray:_e,_reset:de,_resetDefaultValues:()=>Vn(n.defaultValues)&&n.defaultValues().then(S=>{Re(S,n.resetOptions),h.state.next({isLoading:!1})}),_updateFormState:S=>{r={...r,...S}},_subjects:h,_proxyFormState:f,get _fields(){return o},get _formValues(){return i},get _state(){return l},set _state(S){l=S},get _defaultValues(){return s},get _names(){return a},set _names(S){a=S},get _formState(){return r},set _formState(S){r=S},get _options(){return n},set _options(S){n={...n,...S}}},trigger:ee,register:ue,handleSubmit:Ee,watch:$,setValue:j,getValues:ge,reset:Re,resetField:Me,clearErrors:A,unregister:U,setError:L,setFocus:(S,N={})=>{const O=W(o,S),Y=O&&O._f;if(Y){const z=Y.refs?Y.refs[0]:Y.ref;z.focus&&(z.focus(),N.shouldSelect&&z.select())}},getFieldState:E}}function HA(e={}){const t=oe.useRef(),n=oe.useRef(),[r,o]=oe.useState({isDirty:!1,isValidating:!1,isLoading:Vn(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:Vn(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...zA(e,()=>o(i=>({...i}))),formState:r});const s=t.current.control;return s._options=e,Kf({subject:s._subjects.state,next:i=>{zg(i,s._proxyFormState,s._updateFormState,!0)&&o({...s._formState})}}),oe.useEffect(()=>{e.values&&!ur(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values):s._resetDefaultValues()},[e.values,s]),oe.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),t.current.formState=Bg(r,s),t.current}const Zg=({id:e,onCancel:t,onSubmit:n})=>{var B,re,_e,ve,fe,j,Z,ee,ge,E;const r=ia(),[o,s]=D.useState(!1),[,i]=Yn(Ds),[l,a]=D.useState(""),[u,c]=D.useState(),[f,h]=D.useState(!1),{data:g,error:y}=Vr({queryKey:["app-form",e],queryFn:()=>Qt.get(`/server/${e}/`).then(A=>A.data),enabled:!!e}),{data:v}=Vr({queryKey:["app-frameworks"],queryFn:()=>Qt.get("/frameworks/").then(A=>A.data)}),{data:T}=Vr({queryKey:["app-environments"],queryFn:()=>Qt.get("/conda-environments/").then(A=>A.data)}),{data:p}=Vr({queryKey:["app-profiles"],queryFn:()=>Qt.get("/spawner-profiles/").then(A=>A.data)}),{control:d,handleSubmit:m,reset:R,watch:k,formState:{errors:x}}=HA({defaultValues:{display_name:"",description:"",framework:"",thumbnail:"",filepath:"",conda_env:"",custom_command:"",profile:"",is_public:!1}}),P=k("framework"),F=({display_name:A,description:L,framework:$,thumbnail:U,filepath:ne,conda_env:ue,custom_command:X,profile:Ee})=>{const Me={servername:l||A,user_options:{jhub_app:!0,name:l||A,display_name:A,description:L||"",framework:$,thumbnail:U||"",filepath:ne||"",conda_env:ue||"",custom_command:X||"",profile:Ee||"",public:f}};s(!0),e?ae(Me,{onSuccess:async()=>{s(!1),r.invalidateQueries(["app-state"]),n&&n()},onError:async de=>{s(!1),i(de.message)}}):ye(Me,{onSuccess:async de=>{s(!1);const Re=Ug().user;if(Re&&(de==null?void 0:de.length)>1){const lt=de[1];window.location.assign(`/user/${Re}/${lt}`)}},onError:async de=>{s(!1),i(de.message)}})},J=async({servername:A,user_options:L})=>{const $={accept:"application/json","Content-Type":"multipart/form-data"},U=new FormData;return U.append("data",JSON.stringify({servername:A,user_options:L})),u&&U.append("thumbnail",u),(await Qt.post("/server/",U,{headers:$})).data},K=async({servername:A,user_options:L})=>{const $={accept:"application/json","Content-Type":"multipart/form-data"},U=new FormData;return U.append("data",JSON.stringify({servername:A,user_options:L})),u&&U.append("thumbnail",u),(await Qt.put(`/server/${A}/`,U,{headers:$})).data},{mutate:ye}=hl({mutationFn:J,retry:1}),{mutate:ae}=hl({mutationFn:K,retry:1});return D.useEffect(()=>{g!=null&&g.name&&(g!=null&&g.user_options)&&(a(g.name),R({...g.user_options}),h(g.user_options.public))},[g==null?void 0:g.name,g==null?void 0:g.user_options,R]),D.useEffect(()=>{y&&i(y.message)},[y,i]),w.jsxs("form",{id:"app-form",onSubmit:m(F),className:"form",children:[w.jsxs(un,{errors:(B=x.display_name)!=null&&B.message?[x.display_name.message]:void 0,children:[w.jsx(cn,{htmlFor:"display_name",required:!0,children:"Display Name"}),w.jsx(dn,{name:"display_name",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"display_name",autoFocus:!0})}),((re=x.display_name)==null?void 0:re.message)&&w.jsx(Fo,{errors:[x.display_name.message]})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"description",children:"Description"}),w.jsx(dn,{name:"description",control:d,render:({field:{ref:A,...L}})=>w.jsx(rN,{...L,id:"description"})})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"thumbnail",children:"Thumbnail"}),w.jsx(dn,{name:"thumbnail",control:d,render:({field:{ref:A,value:L,onChange:$,...U}})=>w.jsx(nN,{...U,id:"thumbnail",value:void 0,onChange:ne=>{const{files:ue}=ne.target,X=ue;c(X==null?void 0:X[0])}})})]}),w.jsxs(un,{errors:(_e=x.framework)!=null&&_e.message?[x.framework.message]:void 0,children:[w.jsx(cn,{htmlFor:"framework",required:!0,children:"Framework"}),w.jsx(dn,{name:"framework",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"framework",options:v?[{value:"",label:"Select..."},...v.map($=>({value:$.name,label:$.display_name}))]:[]})}),((ve=x.framework)==null?void 0:ve.message)&&w.jsx(Fo,{errors:[x.framework.message]})]}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"filepath",children:"Filepath"}),w.jsx(dn,{name:"filepath",control:d,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"filepath"})})]}),T&&T.length>0?w.jsxs(un,{errors:(fe=x.conda_env)!=null&&fe.message?[x.conda_env.message]:void 0,children:[w.jsx(cn,{htmlFor:"conda_env",required:!0,children:"Conda Environment"}),w.jsx(dn,{name:"conda_env",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"conda_env",options:[{value:"",label:"Select..."},...T.map($=>({value:$,label:$}))]})}),((j=x.conda_env)==null?void 0:j.message)&&w.jsx(Fo,{errors:[x.conda_env.message]})]}):w.jsx(w.Fragment,{}),p&&p.length>0?w.jsxs(un,{errors:(Z=x.profile)!=null&&Z.message?[x.profile.message]:void 0,children:[w.jsx(cn,{htmlFor:"profile",required:!0,children:"Spawner Profile"}),w.jsx(dn,{name:"profile",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(Ga,{...L,id:"profile",options:[{value:"",label:"Select..."},...p.map($=>({value:$.slug,label:$.display_name}))]})}),((ee=x.profile)==null?void 0:ee.message)&&w.jsx(Fo,{errors:[x.profile.message]})]}):w.jsx(w.Fragment,{}),P==="custom"?w.jsxs(un,{errors:(ge=x.custom_command)!=null&&ge.message?[x.custom_command.message]:void 0,children:[w.jsx(cn,{htmlFor:"custom_command",required:!0,children:"Custom Command"}),w.jsx(dn,{name:"custom_command",control:d,rules:Mo,render:({field:{ref:A,...L}})=>w.jsx(ki,{...L,id:"custom_command"})}),((E=x.custom_command)==null?void 0:E.message)&&w.jsx(Fo,{errors:[x.custom_command.message]})]}):w.jsx(w.Fragment,{}),w.jsxs(un,{children:[w.jsx(cn,{htmlFor:"is_public",children:"Allow Public Access"}),w.jsx(dn,{name:"is_public",control:d,render:({field:{ref:A,value:L,onChange:$,...U}})=>w.jsx(oN,{...U,id:"is_public",checked:f,onChange:()=>{h(!f)}})})]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",type:"button",variant:"secondary",onClick:t,children:"Cancel"}),w.jsx(Zt,{id:"submit-btn",type:"submit",disabled:o,children:"Submit"})]})]})},QA=({id:e,title:t,description:n,thumbnail:r,framework:o,url:s,username:i,ready:l=!1,isPublic:a=!1,isShared:u=!1})=>{const c=ia(),[f,h]=D.useState(!1),[,g]=Yn(Ds),[y,v]=D.useState(!1),[T,p]=D.useState(!1),[d,m]=D.useState(!1),[R,k]=D.useState(!1),x=async({id:fe})=>await Qt.post(`/server/${fe}`),P=async({id:fe,remove:j})=>await Qt.delete(`/server/${fe}`,{params:{remove:j}}),{mutate:F}=hl({mutationFn:x,retry:1}),{mutate:J}=hl({mutationFn:P,retry:1}),K=()=>{h(!0),J({id:e,remove:!0},{onSuccess:async()=>{h(!1),m(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},ye=()=>{h(!0),F({id:e},{onSuccess:async()=>{h(!1),v(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},ae=()=>{h(!0),J({id:e,remove:!1},{onSuccess:async()=>{h(!1),p(!1),c.invalidateQueries(["app-state"])},onError:async fe=>{h(!1),g(fe.message)}})},B=[{id:"start",title:"Start",onClick:()=>v(!0),visible:!0,disabled:l},{id:"stop",title:"Stop",onClick:()=>p(!0),visible:!0,disabled:!l||u},{id:"edit",title:"Edit",onClick:()=>k(!0),visible:!0,disabled:u},{id:"delete",title:"Delete",onClick:()=>m(!0),visible:!0,disabled:u}],re=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to start ",w.jsx("b",{children:t}),"?"]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>v(!1),children:"Cancel"}),w.jsx(Zt,{id:"start-btn",variant:"primary",onClick:()=>ye(),disabled:f,children:"Start"})]})]}),_e=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to stop ",w.jsx("b",{children:t}),"?"]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>p(!1),children:"Cancel"}),w.jsx(Zt,{id:"stop-btn",variant:"primary",onClick:()=>ae(),disabled:f,children:"Stop"})]})]}),ve=w.jsxs(w.Fragment,{children:[w.jsxs("p",{className:"w-[400px] mb-6",children:["Are you sure you want to delete ",w.jsx("b",{children:t}),"? This action is permanent and cannot be reversed."]}),w.jsxs(Ti,{children:[w.jsx(Zt,{id:"cancel-btn",variant:"secondary",onClick:()=>m(!1),children:"Cancel"}),w.jsx(Zt,{id:"delete-btn",variant:"primary",onClick:()=>K(),disabled:f,children:"Delete"})]})]});return w.jsxs("div",{className:"card",id:`card-${e}`,tabIndex:0,children:[w.jsxs("div",{className:"card-header-media",children:[w.jsxs("div",{className:"card-header-menu",children:[w.jsx(tN,{id:`card-menu-${e}`,items:B}),y&&w.jsx(Ho,{title:`Start ${t}`,setIsOpen:v,body:re}),T&&w.jsx(Ho,{title:`Stop ${t}`,setIsOpen:p,body:_e}),d&&w.jsx(Ho,{title:`Delete ${t}`,setIsOpen:m,body:ve}),R&&w.jsx(Ho,{title:`Edit ${t}`,setIsOpen:k,body:w.jsx(Zg,{id:e,onCancel:()=>k(!1),onSubmit:()=>k(!1)})})]}),w.jsx("div",{className:"card-header-img flex flex-row",children:r?w.jsx("img",{src:r,alt:"App thumb"}):w.jsx(w.Fragment,{})})]}),w.jsx("div",{className:"card-header",children:w.jsx("h3",{className:"font-bold",children:w.jsx("a",{href:s,children:t})})}),w.jsxs("div",{className:"card-body",children:[w.jsx("p",{className:"text-sm pb-2",children:n}),i?w.jsxs("div",{className:"text-sm",children:[w.jsx("span",{className:"font-bold",children:"Author: "}),i]}):w.jsx(w.Fragment,{})]}),w.jsxs("div",{className:"card-footer",children:[w.jsx(Kh,{id:`tag-${e}`,children:o}),a?w.jsx(Kh,{id:`tag-${e}`,className:"ml-2 bg-warning-light",children:"Public"}):w.jsx(w.Fragment,{})]})]})},pp=({appType:e="My",filter:t})=>{const[n]=Yn(Vf),[,r]=Yn(Ds),[o,s]=D.useState([]),{isLoading:i,error:l,data:a}=Vr({queryKey:["app-state"],queryFn:()=>Qt.get("/server/").then(u=>u.data).then(u=>u),enabled:!!n.user});return D.useEffect(()=>{if(!i&&a){const u=t.toLowerCase();s(()=>xA(a,e).filter(c=>{var f,h;return c.name.toLowerCase().includes(u)||((f=c.description)==null?void 0:f.toLowerCase().includes(u))||((h=c.framework)==null?void 0:h.toLowerCase().includes(u))}))}},[i,a,e,t]),D.useEffect(()=>{r(l?l.message:void 0)},[l,r]),w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 flex flex-align-center pb-12",children:[w.jsx("div",{className:"col-span-1",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[e," Apps"]})}),w.jsx("div",{className:"col-span-10",children:w.jsx("hr",{className:"spacer"})}),w.jsx("div",{className:"col-span-1 flex justify-end",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[o.length," apps"]})})]}),w.jsx("div",{className:"container grid pb-12",children:o.length>0?w.jsx("div",{className:"flex flex flex-row flex-wrap gap-4",children:o.map(u=>w.jsx(QA,{id:u.id,title:u.name,description:u.description,thumbnail:u.thumbnail,framework:u.framework,url:u.url,ready:u.ready,username:u.username,isPublic:u.public,isShared:e==="Shared"},`app-${u.id}`))}):w.jsx("div",{children:"No apps available"})})]})},WA=()=>{const[e]=Yn(Vf),[,t]=Yn(Ds),[n,r]=D.useState([]),{isLoading:o,error:s,data:i}=Vr({queryKey:["service-data"],queryFn:()=>Qt.get("/services/").then(a=>a.data).then(a=>a),enabled:!!e.user}),l=(a,u)=>{u?window.open(a,"_blank"):window.location.assign(a)};return D.useEffect(()=>{!o&&i&&r(()=>CA(i,e.user))},[o,i,e.user]),D.useEffect(()=>{t(s?s.message:void 0)},[s,t]),w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 flex flex-align-center pb-12",children:[w.jsx("div",{className:"col-span-1",children:w.jsx("h2",{className:"whitespace-nowrap font-bold",children:"Services"})}),w.jsx("div",{className:"col-span-10",children:w.jsx("hr",{className:"spacer"})}),w.jsx("div",{className:"col-span-1 flex justify-end",children:w.jsxs("h2",{className:"whitespace-nowrap font-bold",children:[n.length," services"]})})]}),w.jsx("div",{className:"container grid pb-12",children:n.length>0?w.jsx("div",{className:"flex flex flex-row flex-wrap gap-4",children:n.map((a,u)=>w.jsx(Zt,{id:`service-${u}`,variant:"secondary",style:{minWidth:"180px"},onClick:()=>{l(a.url,a.external)},children:a.name},`service-${u}`))}):w.jsx("div",{children:"No services available"})})]})},mp=()=>{const[e,t]=D.useState(!1),[n]=Yn(Ds),[r,o]=D.useState(""),s=i=>{const l=i.target;o(l.value)};return w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"container grid grid-cols-12 pb-12",children:[w.jsx("div",{className:"md:col-span-2 xs:col-span-12",children:w.jsx("h1",{className:"text-3xl font-bold",children:"Home"})}),w.jsx("div",{className:"md:col-span-8 xs:col-span-8",children:w.jsx(ki,{id:"search",placeholder:"Search...","aria-label":"Search for an app",className:"w-full mt-0",onChange:s})}),w.jsxs("div",{className:"md:col-span-2 xs:col-span-4 flex justify-end",children:[w.jsx(Zt,{id:"create-app",onClick:()=>{t(!0)},children:"Create App"}),e&&w.jsx(Ho,{title:"Create New App",setIsOpen:t,body:w.jsx(Zg,{onCancel:()=>t(!1)})})]})]}),n&&w.jsx("div",{className:"container grid grid-cols-12 pb-2",children:w.jsx("div",{className:"col-span-12",children:w.jsx(Kk,{id:"alert-notification",type:"error",children:n})})}),w.jsx(WA,{}),w.jsx(pp,{appType:"My",filter:r}),w.jsx(pp,{appType:"Shared",filter:r})]})},qA=new gk,KA=()=>{const[,e]=Yn(Vf);return D.useEffect(()=>{e(Ug())},[e]),w.jsx(bk,{client:qA,children:w.jsx("div",{children:w.jsx("main",{className:"my-6",children:w.jsxs(c_,{children:[w.jsx(Zu,{path:"/home",element:w.jsx(mp,{})}),w.jsx(Zu,{path:"/",element:w.jsx(mp,{})})]})})})})};ou.createRoot(document.getElementById("root")).render(w.jsx(oe.StrictMode,{children:w.jsx(d_,{basename:"/hub",children:w.jsx(rk,{children:w.jsx(KA,{})})})}));