@ws-ui/store 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +37 -27
- package/dist/index.es.js.map +1 -1
- package/dist/modules/explorer/thunks.d.ts +8 -0
- package/package.json +55 -55
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Qodly store
|
|
2
|
-
|
|
3
|
-
coming soon...
|
|
1
|
+
# Qodly store
|
|
2
|
+
|
|
3
|
+
coming soon...
|
package/dist/index.cjs.js
CHANGED
|
@@ -266,7 +266,7 @@ globstar while`,n,b,r,E,O),this.matchOne(n.slice(b),r.slice(E),a))return this.de
|
|
|
266
266
|
>>> no match, partial?`,n,b,r,E),b===f))}var R;if(typeof h=="string"?(R=m===h,this.debug("string match",h,m,R)):(R=m.match(h),this.debug("pattern match",h,m,R)),!R)return!1}if(u===f&&c===p)return!0;if(u===f)return a;if(c===p)return u===f-1&&n[u]==="";throw new Error("wtf?")}braceExpand(){return ux(this.pattern,this.options)}parse(n,r){md(n);const a=this.options;if(n==="**")if(a.noglobstar)n="*";else return go;if(n==="")return"";let i="",u=!1,c=!1;const f=[],p=[];let h,m=!1,b=-1,E=-1,O,R,C,k=n.charAt(0)===".",j=a.dot||k;const F=()=>k?"":j?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",D=U=>U.charAt(0)==="."?"":a.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",M=()=>{if(h){switch(h){case"*":i+=a1,u=!0;break;case"?":i+=Z1,u=!0;break;default:i+="\\"+h;break}this.debug("clearStateChar %j %j",h,i),h=!1}};for(let U=0,V;U<n.length&&(V=n.charAt(U));U++){if(this.debug("%s %s %s %j",n,U,i,V),c){if(V==="/")return!1;TS[V]&&(i+="\\"),i+=V,c=!1;continue}switch(V){case"/":return!1;case"\\":if(m&&n.charAt(U+1)==="-"){i+=V;continue}M(),c=!0;continue;case"?":case"*":case"+":case"@":case"!":if(this.debug("%s %s %s %j <-- stateChar",n,U,i,V),m){this.debug(" in class"),V==="!"&&U===E+1&&(V="^"),i+=V;continue}this.debug("call clearStateChar %j",h),M(),h=V,a.noext&&M();continue;case"(":{if(m){i+="(";continue}if(!h){i+="\\(";continue}const Ee={type:h,start:U-1,reStart:i.length,open:OS[h].open,close:OS[h].close};this.debug(this.pattern," ",Ee),f.push(Ee),i+=Ee.open,Ee.start===0&&Ee.type!=="!"&&(k=!0,i+=D(n.slice(U+1))),this.debug("plType %j %j",h,i),h=!1;continue}case")":{const Ee=f[f.length-1];if(m||!Ee){i+="\\)";continue}f.pop(),M(),u=!0,R=Ee,i+=R.close,R.type==="!"&&p.push(Object.assign(R,{reEnd:i.length}));continue}case"|":{const Ee=f[f.length-1];if(m||!Ee){i+="\\|";continue}M(),i+="|",Ee.start===0&&Ee.type!=="!"&&(k=!0,i+=D(n.slice(U+1)));continue}case"[":if(M(),m){i+="\\"+V;continue}m=!0,E=U,b=i.length,i+=V;continue;case"]":if(U===E+1||!m){i+="\\"+V;continue}O=n.substring(E+1,U);try{RegExp("["+RL(xL(O))+"]"),i+=V}catch{i=i.substring(0,b)+"(?:$.)"}u=!0,m=!1;continue;default:M(),TS[V]&&!(V==="^"&&m)&&(i+="\\"),i+=V;break}}for(m&&(O=n.slice(E+1),C=this.parse(O,i1),i=i.substring(0,b)+"\\["+C[0],u=u||C[1]),R=f.pop();R;R=f.pop()){let U;U=i.slice(R.reStart+R.open.length),this.debug("setting tail",i,R),U=U.replace(/((?:\\{2}){0,64})(\\?)\|/g,(Ee,He,Be)=>(Be||(Be="\\"),He+He+Be+"|")),this.debug(`tail=%j
|
|
267
267
|
%s`,U,U,R,i);const V=R.type==="*"?a1:R.type==="?"?Z1:"\\"+R.type;u=!0,i=i.slice(0,R.reStart)+V+"\\("+U}M(),c&&(i+="\\\\");const S=SL[i.charAt(0)];for(let U=p.length-1;U>-1;U--){const V=p[U],Ee=i.slice(0,V.reStart),He=i.slice(V.reStart,V.reEnd-8);let Be=i.slice(V.reEnd);const St=i.slice(V.reEnd-8,V.reEnd)+Be,me=Ee.split(")").length,Me=Ee.split("(").length-me;let at=Be;for(let Le=0;Le<Me;Le++)at=at.replace(/\)[+*?]?/,"");Be=at;const Xe=Be===""&&r!==i1?"(?:$|\\/)":"";i=Ee+He+Be+Xe+St}if(i!==""&&u&&(i="(?=.)"+i),S&&(i=F()+i),r===i1)return[i,u];if(a.nocase&&!u&&(u=n.toUpperCase()!==n.toLowerCase()),!u)return TL(n);const q=a.nocase?"i":"";try{return Object.assign(new RegExp("^"+i+"$",q),{_glob:n,_src:i})}catch{return new RegExp("$.")}}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const n=this.set;if(!n.length)return this.regexp=!1,this.regexp;const r=this.options,a=r.noglobstar?a1:r.dot?wL:EL,i=r.nocase?"i":"";let u=n.map(c=>(c=c.map(f=>typeof f=="string"?CL(f):f===go?go:f._src).reduce((f,p)=>(f[f.length-1]===go&&p===go||f.push(p),f),[]),c.forEach((f,p)=>{f!==go||c[p-1]===go||(p===0?c.length>1?c[p+1]="(?:\\/|"+a+"\\/)?"+c[p+1]:c[p]=a:p===c.length-1?c[p-1]+="(?:\\/|"+a+")?":(c[p-1]+="(?:\\/|\\/"+a+"\\/)"+c[p+1],c[p+1]=go))}),c.filter(f=>f!==go).join("/"))).join("|");u="^(?:"+u+")$",this.negate&&(u="^(?!"+u+").*$");try{this.regexp=new RegExp(u,i)}catch{this.regexp=!1}return this.regexp}match(n,r=this.partial){if(this.debug("match",n,this.pattern),this.comment)return!1;if(this.empty)return n==="";if(n==="/"&&r)return!0;const a=this.options;J1.sep!=="/"&&(n=n.split(J1.sep).join("/")),n=n.split(xS),this.debug(this.pattern,"split",n);const i=this.set;this.debug(this.pattern,"set",i);let u;for(let c=n.length-1;c>=0&&(u=n[c],!u);c--);for(let c=0;c<i.length;c++){const f=i[c];let p=n;if(a.matchBase&&f.length===1&&(p=[u]),this.matchOne(p,f,r))return a.flipNegate?!0:!this.negate}return a.flipNegate?!1:this.negate}static defaults(n){return Un.defaults(n).Minimatch}}Un.Minimatch=Jd;const cx=Rd(ix),lx=[{pattern:Ur,editor:{key:"editors:roles"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]},{pattern:B_,editor:{key:"editors:model"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]},{pattern:"**/*.webform",editor:{key:"editors:webforms"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]},{pattern:"Methods/*.4dm",editor:{key:"editors:code:method",config:{theme:"fd-dark",language:"4d"}}},{pattern:"Methods/*.4qs",editor:{key:"editors:code:method",config:{theme:"fd-dark",language:"4d"}}},{pattern:"Classes/*.4dm",editor:{key:"editors:code",config:{theme:"fd-dark",language:"4d"}}},{pattern:"Classes/*.4qs",editor:{key:"editors:code",config:{theme:"fd-dark",language:"4d"}}},{pattern:"**/*.+(json)",editor:{key:"editors:code",config:{language:"json"}}},{pattern:"**/*.+(js)",editor:{key:"editors:code",config:{language:"js"}}},{pattern:"**/*.+(css)",editor:{key:"editors:code",config:{language:"css"}}},{pattern:"**/*.+(txt)",editor:{key:"editors:code",config:{language:""}}},{pattern:"Debugger/*",editor:{key:"editors:code",config:{theme:"fd-dark",language:"4d"}}},{pattern:"**/*.+(png|jpeg|jpg|gif|svg)",editor:{key:"editors:img"}}],fx=[{pattern:"**/*.+(json|4DModel|WebForm)",type:"json"},{pattern:"**/*.+(4dm|txt|json|4qs)",type:"text"}];function dx(e){const n=e.split("/");return n.pop(),n.join("/")}function bo(e){const n=lx.find(({pattern:r})=>cx(e,r,{nocase:!0}));return n||{pattern:"",editor:{key:"editors:unknown",config:{language:"text"}}}}function px(e){const n=fx.find(({pattern:r})=>cx(e,r,{nocase:!0}));return n?n.type:"text"}var Q1=function(e,n){return Q1=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,a){r.__proto__=a}||function(r,a){for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&(r[i]=a[i])},Q1(e,n)};function Zd(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");Q1(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}function e_(e){var n=typeof Symbol=="function"&&Symbol.iterator,r=n&&e[n],a=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function yd(e,n){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var a=r.call(e),i,u=[],c;try{for(;(n===void 0||n-- >0)&&!(i=a.next()).done;)u.push(i.value)}catch(f){c={error:f}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(c)throw c.error}}return u}function bd(e,n,r){if(r||arguments.length===2)for(var a=0,i=n.length,u;a<i;a++)(u||!(a in n))&&(u||(u=Array.prototype.slice.call(n,0,a)),u[a]=n[a]);return e.concat(u||Array.prototype.slice.call(n))}function ja(e){return typeof e=="function"}function hx(e){var n=function(a){Error.call(a),a.stack=new Error().stack},r=e(n);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var s1=hx(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
268
268
|
`+r.map(function(a,i){return i+1+") "+a.toString()}).join(`
|
|
269
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function t_(e,n){if(e){var r=e.indexOf(n);0<=r&&e.splice(r,1)}}var Qd=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,r,a,i,u;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var f=e_(c),p=f.next();!p.done;p=f.next()){var h=p.value;h.remove(this)}}catch(C){n={error:C}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}else c.remove(this);var m=this.initialTeardown;if(ja(m))try{m()}catch(C){u=C instanceof s1?C.errors:[C]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var E=e_(b),O=E.next();!O.done;O=E.next()){var R=O.value;try{CS(R)}catch(C){u=u??[],C instanceof s1?u=bd(bd([],yd(u)),yd(C.errors)):u.push(C)}}}catch(C){a={error:C}}finally{try{O&&!O.done&&(i=E.return)&&i.call(E)}finally{if(a)throw a.error}}}if(u)throw new s1(u)}},e.prototype.add=function(n){var r;if(n&&n!==this)if(this.closed)CS(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(n)}},e.prototype._hasParent=function(n){var r=this._parentage;return r===n||Array.isArray(r)&&r.includes(n)},e.prototype._addParent=function(n){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(n),r):r?[r,n]:n},e.prototype._removeParent=function(n){var r=this._parentage;r===n?this._parentage=null:Array.isArray(r)&&t_(r,n)},e.prototype.remove=function(n){var r=this._finalizers;r&&t_(r,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}(),vx=Qd.EMPTY;function gx(e){return e instanceof Qd||e&&"closed"in e&&ja(e.remove)&&ja(e.add)&&ja(e.unsubscribe)}function CS(e){ja(e)?e():e.unsubscribe()}var mx={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},r_={setTimeout:function(e,n){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];var i=r_.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,bd([e,n],yd(r))):setTimeout.apply(void 0,bd([e,n],yd(r)))},clearTimeout:function(e){var n=r_.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(e)},delegate:void 0};function AL(e){r_.setTimeout(function(){throw e})}function RS(){}function Gf(e){e()}var yx=function(e){Zd(n,e);function n(r){var a=e.call(this)||this;return a.isStopped=!1,r?(a.destination=r,gx(r)&&r.add(a)):a.destination=ML,a}return n.create=function(r,a,i){return new n_(r,a,i)},n.prototype.next=function(r){this.isStopped||this._next(r)},n.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(r){this.destination.next(r)},n.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(Qd),PL=Function.prototype.bind;function u1(e,n){return PL.call(e,n)}var DL=function(){function e(n){this.partialObserver=n}return e.prototype.next=function(n){var r=this.partialObserver;if(r.next)try{r.next(n)}catch(a){Df(a)}},e.prototype.error=function(n){var r=this.partialObserver;if(r.error)try{r.error(n)}catch(a){Df(a)}else Df(n)},e.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(r){Df(r)}},e}(),n_=function(e){Zd(n,e);function n(r,a,i){var u=e.call(this)||this,c;if(ja(r)||!r)c={next:r??void 0,error:a??void 0,complete:i??void 0};else{var f;u&&mx.useDeprecatedNextContext?(f=Object.create(r),f.unsubscribe=function(){return u.unsubscribe()},c={next:r.next&&u1(r.next,f),error:r.error&&u1(r.error,f),complete:r.complete&&u1(r.complete,f)}):c=r}return u.destination=new DL(c),u}return n}(yx);function Df(e){AL(e)}function IL(e){throw e}var ML={closed:!0,next:RS,error:IL,complete:RS},kL=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function $L(e){return e}function NL(e){return e.length===0?$L:e.length===1?e[0]:function(r){return e.reduce(function(a,i){return i(a)},r)}}var AS=function(){function e(n){n&&(this._subscribe=n)}return e.prototype.lift=function(n){var r=new e;return r.source=this,r.operator=n,r},e.prototype.subscribe=function(n,r,a){var i=this,u=LL(n)?n:new n_(n,r,a);return Gf(function(){var c=i,f=c.operator,p=c.source;u.add(f?f.call(u,p):p?i._subscribe(u):i._trySubscribe(u))}),u},e.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(r){n.error(r)}},e.prototype.forEach=function(n,r){var a=this;return r=PS(r),new r(function(i,u){var c=new n_({next:function(f){try{n(f)}catch(p){u(p),c.unsubscribe()}},error:u,complete:i});a.subscribe(c)})},e.prototype._subscribe=function(n){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(n)},e.prototype[kL]=function(){return this},e.prototype.pipe=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return NL(n)(this)},e.prototype.toPromise=function(n){var r=this;return n=PS(n),new n(function(a,i){var u;r.subscribe(function(c){return u=c},function(c){return i(c)},function(){return a(u)})})},e.create=function(n){return new e(n)},e}();function PS(e){var n;return(n=e??mx.Promise)!==null&&n!==void 0?n:Promise}function jL(e){return e&&ja(e.next)&&ja(e.error)&&ja(e.complete)}function LL(e){return e&&e instanceof yx||jL(e)&&gx(e)}var FL=hx(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),bx=function(e){Zd(n,e);function n(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return n.prototype.lift=function(r){var a=new DS(this,this);return a.operator=r,a},n.prototype._throwIfClosed=function(){if(this.closed)throw new FL},n.prototype.next=function(r){var a=this;Gf(function(){var i,u;if(a._throwIfClosed(),!a.isStopped){a.currentObservers||(a.currentObservers=Array.from(a.observers));try{for(var c=e_(a.currentObservers),f=c.next();!f.done;f=c.next()){var p=f.value;p.next(r)}}catch(h){i={error:h}}finally{try{f&&!f.done&&(u=c.return)&&u.call(c)}finally{if(i)throw i.error}}}})},n.prototype.error=function(r){var a=this;Gf(function(){if(a._throwIfClosed(),!a.isStopped){a.hasError=a.isStopped=!0,a.thrownError=r;for(var i=a.observers;i.length;)i.shift().error(r)}})},n.prototype.complete=function(){var r=this;Gf(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var a=r.observers;a.length;)a.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},n.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},n.prototype._innerSubscribe=function(r){var a=this,i=this,u=i.hasError,c=i.isStopped,f=i.observers;return u||c?vx:(this.currentObservers=null,f.push(r),new Qd(function(){a.currentObservers=null,t_(f,r)}))},n.prototype._checkFinalizedStatuses=function(r){var a=this,i=a.hasError,u=a.thrownError,c=a.isStopped;i?r.error(u):c&&r.complete()},n.prototype.asObservable=function(){var r=new AS;return r.source=this,r},n.create=function(r,a){return new DS(r,a)},n}(AS),DS=function(e){Zd(n,e);function n(r,a){var i=e.call(this)||this;return i.destination=r,i.source=a,i}return n.prototype.next=function(r){var a,i;(i=(a=this.destination)===null||a===void 0?void 0:a.next)===null||i===void 0||i.call(a,r)},n.prototype.error=function(r){var a,i;(i=(a=this.destination)===null||a===void 0?void 0:a.error)===null||i===void 0||i.call(a,r)},n.prototype.complete=function(){var r,a;(a=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||a===void 0||a.call(r)},n.prototype._subscribe=function(r){var a,i;return(i=(a=this.source)===null||a===void 0?void 0:a.subscribe(r))!==null&&i!==void 0?i:vx},n}(bx);const _x=new bx,WL=()=>JT(),Ua=sL,J_=pe(e=>e,e=>e.catalog.state==="loaded"?e.catalog.model:null),BL=pe(J_,e=>e?e.dataClasses:[]),UL=pe(J_,e=>e?e.methods:[]),wx=e=>pe(n=>n,n=>{switch(n.catalog.state){case"loaded":const r=e?n.catalog.model.dataClasses[e]:n.catalog.model;return(r==null?void 0:r.methods)||[];default:return[]}}),zL=e=>Ua(wx(e),YT),HL=(e,n)=>pe(wx(e),r=>r.find(a=>`${a.applyTo}.${a.name}`===n)),GL=(e,n,r)=>Ua(HL(e,`${r}.${n}`),YT),Ex=pe(e=>e,e=>e),qL=e=>pe(za,n=>{var i;const r=n.tabs.find(({path:u})=>u===e),a=r==null?void 0:r.content.components;return!r||!a?[]:(i=Object.keys(a))==null?void 0:i.map(u=>({id:u,...a[u]}))}),Sx=e=>pe(za,n=>{var a,i;const r=n.tabs.find(({path:u})=>u===e);return((i=(a=r==null?void 0:r.content)==null?void 0:a.metadata)==null?void 0:i.datasources)||[]}),VL=(e,n,r)=>pe(Ex,a=>{var i,u;if(n){const c=a.sharedDatasources.sources[n];return c?c.find(f=>f.id===e):void 0}else{const c=a.root.tabs.find(p=>p.path===r);return c?(u=(i=c.content.metadata)==null?void 0:i.datasources)==null?void 0:u.find(p=>p.id===e):void 0}}),Ox=pe(e=>e,e=>e.sharedDatasources.sources),YL=(e,n,r,a)=>pe(Sx(e),Ox,(i,u)=>{const c=Bt.flatten(Bt.values(u)),f=[...n!=="private"?i:[],...n!=="shared"?c:[]];return r?f.filter(p=>(!a||a.every(({id:h,namespace:m=""})=>p.id!==h||(p.namespace||"")!==m))&&(r.includes(p.type)||p.dataType&&(r.includes(p.dataType)||r.includes("objectFromArray")&&p.dataType==="object"&&p.from))):f}),KL=pe(e=>e.debugger,e=>e.meta),Is=pe(e=>e.debugger,e=>e.list),En=pe(e=>e.debugger,e=>e.sessions),XL=pe(En,e=>e.length),Ps=(e,n,r,a)=>e.find(i=>i.filePath===n&&i.methodName===r&&(!a||i.className===a)),dr=(e,n)=>e.find(r=>r.threadId===n),Tx=(e,n)=>e.find(r=>r.tabPath===n),JL=(e,n)=>pe(Is,r=>{var a;return((a=Ps(r,e,n))==null?void 0:a.breakpoints.saved.locations)||[]}),ZL=(e,n)=>pe(Is,r=>{var a;return((a=Ps(r,e,n))==null?void 0:a.breakpoints.draft.locations)||[]}),QL=e=>pe(Is,n=>n.filter(r=>r.filePath===e).reduce((r,a)=>[...r,...a.breakpoints.saved.locations.map(i=>({...i,line:i.line+(a.breakpoints.saved.offset||0)}))],[]).sort((r,a)=>r.line-a.line)),e3=e=>pe(Is,n=>n.filter(r=>r.filePath===e).reduce((r,a)=>[...r,...a.breakpoints.draft.locations.map(i=>({...i,line:i.line+(a.breakpoints.draft.offset||0)}))],[]).sort((r,a)=>r.line-a.line)),t3=e=>pe(En,n=>{const r=dr(n,e);return r!=null&&r.stopped?r.highlightedLines:null}),r3=e=>pe(En,n=>{const r=dr(n,e);return r!=null&&r.stopped?r.activeLine:null}),n3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.expressions)||[]}),o3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.stopped)||!1}),a3=(e,n)=>pe(Is,r=>{var a;return(a=Ps(r,e,n))==null?void 0:a.source}),i3=e=>pe(En,n=>{var r;return((r=Tx(n,e))==null?void 0:r.threadId)||-1}),s3=e=>pe(En,n=>{var r,a;return(a=(r=dr(n,e))==null?void 0:r.currentStackFrame)==null?void 0:a.source}),u3=e=>pe(En,n=>{var r;return(r=dr(n,e))==null?void 0:r.currentStackFrame}),c3=pe(En,e=>e.map(({channelId:n,threadId:r})=>({id:n,threadId:r}))),l3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.stackFrames)||[]}),f3=e=>pe(En,n=>{var r,a;return((a=(r=dr(n,e))==null?void 0:r.variables)==null?void 0:a.callchain)||[]}),d3=e=>pe(En,n=>{var r,a;return((a=(r=dr(n,e))==null?void 0:r.variables)==null?void 0:a.expressions)||[]}),p3=(e,n="saved")=>pe(Is,r=>{const a=r.find(i=>i.filePath===e);return(a==null?void 0:a.breakpoints[n].offset)||0}),h3=(e,n,r,a)=>pe(En,i=>{var h;const u=((h=dr(i,e))==null?void 0:h.exceptions)||[],c=n===le.CLASS,f=c&&a?`${a}.${r}`:r;return(f?u.filter(m=>m.location===f):u).map(m=>({...m,locationLine:c?m.locationLine:m.locationLine+1}))}),za=pe(e=>e.root,e=>e),cu=pe(za,e=>e.tabs),v3=pe(za,e=>e.activeTab),g3=pe(za,e=>e.recent.filter(({type:n})=>n!==le.DEBUGGER)),m3=pe(za,({tabs:e,activeTab:n})=>e.find(({path:r})=>r===n)),y3=pe(za,({tabs:e})=>e.reduce((r,a)=>(a==null?void 0:a.weight)>((r==null?void 0:r.weight)||0)?a:r,null)),b3=pe(cu,e=>e.filter(({type:n,flags:r})=>n===le.WEBFORM&&r.enabled===!1).map(({path:n})=>n)),_3=pe(cu,e=>e.length>0),gf=e=>pe(za,n=>n.tabs.find(({path:r})=>r===e)),xx=(e,n="")=>pe(gf(e),r=>!r||!r.content||typeof r.content=="string"?r==null?void 0:r.content:Bt.get(r.content,n)),w3=e=>pe(gf(e),n=>n==null?void 0:n.extra),E3=(e,n=r=>r)=>pe(xx(e,"components"),r=>n(r||{})),Z_=pe(cu,e=>e.filter(n=>n.flags.touched)),S3=pe(Z_,e=>e.length),O3=pe(En,e=>e.map(({threadId:n,currentStackFrame:{source:r},tabPath:a})=>({name:WT(n,r),path:a,type:le.DEBUGGER,content:r==null?void 0:r.content,flags:{},extra:{source:r}}))),T3=pe(e=>e,e=>e.explorer||[]),Cx=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.WEBFORMS)),Rx=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.METHODS)),Ax=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.CLASSES)),x3=pe(Rx,e=>(e==null?void 0:e.children)||[]),C3=pe(Cx,e=>(e==null?void 0:e.children)||[]),R3=pe(Ax,e=>(e==null?void 0:e.children)||[]),A3=pe(e=>e.modals,e=>e.list),P3=pe(e=>e.roles,({roles:e})=>e),D3=pe(e=>e.roles,({privileges:e})=>e),I3=pe(e=>e.roles,({privileges:e})=>Object.values(e).find(({privilege:n})=>n==="guest")),M3=pe(e=>e.roles,({flags:e})=>e),k3=pe(e=>e.roles,({selectedTab:e})=>e),$3=pe(e=>e.roles,({date:e})=>e),Px=pe(e=>e.settings,e=>e.session),N3=pe(e=>e.settings,e=>e.project),j3=pe(e=>e.settings,e=>e),Q_=pe(e=>e.settings,e=>e.server),L3=pe(Q_,e=>e.remoteDebuggerMode),F3=pe(Q_,e=>e.qodly),W3=pe(Px,e=>e["monaco.zoom"]),Dx=["rounded-full","rounded-lg","border-gray-400","border-2","bg-red-500","bg-blue-500","bg-indigo-500","bg-transparent","bg-primary-dark","bg-green-500","bg-yellow-400","text-gray-500","text-4xl","text-white","px-4","py-2","primary","info","secondary","success","warning","danger","w-10","w-20","w-40","w-60","w-80","mb-2","mb-3","shadow","shadow-lg","shadow-xl","shadow-2xl"],Ix=Dx.map(e=>({id:y_(),content:"",name:e,parentId:null,scope:As.THEME})),ew=e=>pe(gf(e),n=>{var r,a;return((a=(r=n==null?void 0:n.content)==null?void 0:r.metadata)==null?void 0:a.styles)||[]}),B3=(e,n)=>pe(ew(e),r=>n.map(a=>{switch(!0){case a===As.LOCAL:return r.map(i=>({...i,scope:As.LOCAL}));case a===As.THEME:return Ix;default:return[]}}).flat()),U3=e=>pe(ew(e),n=>[...n.map(r=>({...r,scope:As.LOCAL})),...Ix]),z3=pe(e=>e,e=>{var n;return[...(((n=e.sharedCSS)==null?void 0:n.styles)||[]).map(r=>({...r,scope:As.SHARED}))]}),H3=e=>pe(gf(e),n=>n==null?void 0:n.flags),mf=pe(e=>e.webforms,e=>e),Mx=pe(mf,e=>(e==null?void 0:e.components)||[]),ep=pe(mf,e=>e.inspector),G3=pe(ep,e=>e.css),q3=pe(ep,e=>e.datasource),kx=pe(mf,e=>e.templates||{data:[]}),V3=pe(kx,e=>e.data||[]),Y3=e=>pe(Mx,n=>n.find(r=>r.id===e)),K3=e=>pe(ep,n=>n[e]),X3=pe(mf,e=>e.datasources.theme),J3=pe(e=>e.catalog,e=>e.sharedDatasources,e=>e.sharedCSS,(e,n,r)=>[e.state,n.state,r.state].every(a=>["loaded","error"].includes(a)));var tw=(e=>(e.SHOW_AFTER_TIMEOUT="show_after_timeout",e.HIDE_AFTER_TIMEOUT="hide_after_timeout",e))(tw||{}),$x=(e=>(e.AIRY="airy",e.COMPACT="neutral",e))($x||{});const Nx={metadata:{v:"1.0",datasources:[],styles:[]},components:{ROOT:{parent:"",type:{resolvedName:"Container"},isCanvas:!0,props:{className:"bg-white h-full w-full px-6",classNames:[],events:[],airyMode:!1},displayName:"App",custom:{},hidden:!1,nodes:[],linkedNodes:{}}}};var If,Z3=new Uint8Array(16);function jx(){if(!If&&(If=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!If))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return If(Z3)}const Q3=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function tp(e){return typeof e=="string"&&Q3.test(e)}var Fr=[];for(var c1=0;c1<256;++c1)Fr.push((c1+256).toString(16).substr(1));function rp(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(Fr[e[n+0]]+Fr[e[n+1]]+Fr[e[n+2]]+Fr[e[n+3]]+"-"+Fr[e[n+4]]+Fr[e[n+5]]+"-"+Fr[e[n+6]]+Fr[e[n+7]]+"-"+Fr[e[n+8]]+Fr[e[n+9]]+"-"+Fr[e[n+10]]+Fr[e[n+11]]+Fr[e[n+12]]+Fr[e[n+13]]+Fr[e[n+14]]+Fr[e[n+15]]).toLowerCase();if(!tp(r))throw TypeError("Stringified UUID is invalid");return r}var IS,l1,f1=0,d1=0;function e4(e,n,r){var a=n&&r||0,i=n||new Array(16);e=e||{};var u=e.node||IS,c=e.clockseq!==void 0?e.clockseq:l1;if(u==null||c==null){var f=e.random||(e.rng||jx)();u==null&&(u=IS=[f[0]|1,f[1],f[2],f[3],f[4],f[5]]),c==null&&(c=l1=(f[6]<<8|f[7])&16383)}var p=e.msecs!==void 0?e.msecs:Date.now(),h=e.nsecs!==void 0?e.nsecs:d1+1,m=p-f1+(h-d1)/1e4;if(m<0&&e.clockseq===void 0&&(c=c+1&16383),(m<0||p>f1)&&e.nsecs===void 0&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f1=p,d1=h,l1=c,p+=122192928e5;var b=((p&268435455)*1e4+h)%4294967296;i[a++]=b>>>24&255,i[a++]=b>>>16&255,i[a++]=b>>>8&255,i[a++]=b&255;var E=p/4294967296*1e4&268435455;i[a++]=E>>>8&255,i[a++]=E&255,i[a++]=E>>>24&15|16,i[a++]=E>>>16&255,i[a++]=c>>>8|128,i[a++]=c&255;for(var O=0;O<6;++O)i[a+O]=u[O];return n||rp(i)}function Lx(e){if(!tp(e))throw TypeError("Invalid UUID");var n,r=new Uint8Array(16);return r[0]=(n=parseInt(e.slice(0,8),16))>>>24,r[1]=n>>>16&255,r[2]=n>>>8&255,r[3]=n&255,r[4]=(n=parseInt(e.slice(9,13),16))>>>8,r[5]=n&255,r[6]=(n=parseInt(e.slice(14,18),16))>>>8,r[7]=n&255,r[8]=(n=parseInt(e.slice(19,23),16))>>>8,r[9]=n&255,r[10]=(n=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=n/4294967296&255,r[12]=n>>>24&255,r[13]=n>>>16&255,r[14]=n>>>8&255,r[15]=n&255,r}function t4(e){e=unescape(encodeURIComponent(e));for(var n=[],r=0;r<e.length;++r)n.push(e.charCodeAt(r));return n}var r4="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n4="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Fx(e,n,r){function a(i,u,c,f){if(typeof i=="string"&&(i=t4(i)),typeof u=="string"&&(u=Lx(u)),u.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var p=new Uint8Array(16+i.length);if(p.set(u),p.set(i,u.length),p=r(p),p[6]=p[6]&15|n,p[8]=p[8]&63|128,c){f=f||0;for(var h=0;h<16;++h)c[f+h]=p[h];return c}return rp(p)}try{a.name=e}catch{}return a.DNS=r4,a.URL=n4,a}function o4(e){if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=new Uint8Array(n.length);for(var r=0;r<n.length;++r)e[r]=n.charCodeAt(r)}return a4(i4(s4(e),e.length*8))}function a4(e){for(var n=[],r=e.length*32,a="0123456789abcdef",i=0;i<r;i+=8){var u=e[i>>5]>>>i%32&255,c=parseInt(a.charAt(u>>>4&15)+a.charAt(u&15),16);n.push(c)}return n}function Wx(e){return(e+64>>>9<<4)+14+1}function i4(e,n){e[n>>5]|=128<<n%32,e[Wx(n)-1]=n;for(var r=1732584193,a=-271733879,i=-1732584194,u=271733878,c=0;c<e.length;c+=16){var f=r,p=a,h=i,m=u;r=Vr(r,a,i,u,e[c],7,-680876936),u=Vr(u,r,a,i,e[c+1],12,-389564586),i=Vr(i,u,r,a,e[c+2],17,606105819),a=Vr(a,i,u,r,e[c+3],22,-1044525330),r=Vr(r,a,i,u,e[c+4],7,-176418897),u=Vr(u,r,a,i,e[c+5],12,1200080426),i=Vr(i,u,r,a,e[c+6],17,-1473231341),a=Vr(a,i,u,r,e[c+7],22,-45705983),r=Vr(r,a,i,u,e[c+8],7,1770035416),u=Vr(u,r,a,i,e[c+9],12,-1958414417),i=Vr(i,u,r,a,e[c+10],17,-42063),a=Vr(a,i,u,r,e[c+11],22,-1990404162),r=Vr(r,a,i,u,e[c+12],7,1804603682),u=Vr(u,r,a,i,e[c+13],12,-40341101),i=Vr(i,u,r,a,e[c+14],17,-1502002290),a=Vr(a,i,u,r,e[c+15],22,1236535329),r=Yr(r,a,i,u,e[c+1],5,-165796510),u=Yr(u,r,a,i,e[c+6],9,-1069501632),i=Yr(i,u,r,a,e[c+11],14,643717713),a=Yr(a,i,u,r,e[c],20,-373897302),r=Yr(r,a,i,u,e[c+5],5,-701558691),u=Yr(u,r,a,i,e[c+10],9,38016083),i=Yr(i,u,r,a,e[c+15],14,-660478335),a=Yr(a,i,u,r,e[c+4],20,-405537848),r=Yr(r,a,i,u,e[c+9],5,568446438),u=Yr(u,r,a,i,e[c+14],9,-1019803690),i=Yr(i,u,r,a,e[c+3],14,-187363961),a=Yr(a,i,u,r,e[c+8],20,1163531501),r=Yr(r,a,i,u,e[c+13],5,-1444681467),u=Yr(u,r,a,i,e[c+2],9,-51403784),i=Yr(i,u,r,a,e[c+7],14,1735328473),a=Yr(a,i,u,r,e[c+12],20,-1926607734),r=Kr(r,a,i,u,e[c+5],4,-378558),u=Kr(u,r,a,i,e[c+8],11,-2022574463),i=Kr(i,u,r,a,e[c+11],16,1839030562),a=Kr(a,i,u,r,e[c+14],23,-35309556),r=Kr(r,a,i,u,e[c+1],4,-1530992060),u=Kr(u,r,a,i,e[c+4],11,1272893353),i=Kr(i,u,r,a,e[c+7],16,-155497632),a=Kr(a,i,u,r,e[c+10],23,-1094730640),r=Kr(r,a,i,u,e[c+13],4,681279174),u=Kr(u,r,a,i,e[c],11,-358537222),i=Kr(i,u,r,a,e[c+3],16,-722521979),a=Kr(a,i,u,r,e[c+6],23,76029189),r=Kr(r,a,i,u,e[c+9],4,-640364487),u=Kr(u,r,a,i,e[c+12],11,-421815835),i=Kr(i,u,r,a,e[c+15],16,530742520),a=Kr(a,i,u,r,e[c+2],23,-995338651),r=Xr(r,a,i,u,e[c],6,-198630844),u=Xr(u,r,a,i,e[c+7],10,1126891415),i=Xr(i,u,r,a,e[c+14],15,-1416354905),a=Xr(a,i,u,r,e[c+5],21,-57434055),r=Xr(r,a,i,u,e[c+12],6,1700485571),u=Xr(u,r,a,i,e[c+3],10,-1894986606),i=Xr(i,u,r,a,e[c+10],15,-1051523),a=Xr(a,i,u,r,e[c+1],21,-2054922799),r=Xr(r,a,i,u,e[c+8],6,1873313359),u=Xr(u,r,a,i,e[c+15],10,-30611744),i=Xr(i,u,r,a,e[c+6],15,-1560198380),a=Xr(a,i,u,r,e[c+13],21,1309151649),r=Xr(r,a,i,u,e[c+4],6,-145523070),u=Xr(u,r,a,i,e[c+11],10,-1120210379),i=Xr(i,u,r,a,e[c+2],15,718787259),a=Xr(a,i,u,r,e[c+9],21,-343485551),r=Ja(r,f),a=Ja(a,p),i=Ja(i,h),u=Ja(u,m)}return[r,a,i,u]}function s4(e){if(e.length===0)return[];for(var n=e.length*8,r=new Uint32Array(Wx(n)),a=0;a<n;a+=8)r[a>>5]|=(e[a/8]&255)<<a%32;return r}function Ja(e,n){var r=(e&65535)+(n&65535),a=(e>>16)+(n>>16)+(r>>16);return a<<16|r&65535}function u4(e,n){return e<<n|e>>>32-n}function np(e,n,r,a,i,u){return Ja(u4(Ja(Ja(n,e),Ja(a,u)),i),r)}function Vr(e,n,r,a,i,u,c){return np(n&r|~n&a,e,n,i,u,c)}function Yr(e,n,r,a,i,u,c){return np(n&a|r&~a,e,n,i,u,c)}function Kr(e,n,r,a,i,u,c){return np(n^r^a,e,n,i,u,c)}function Xr(e,n,r,a,i,u,c){return np(r^(n|~a),e,n,i,u,c)}var c4=Fx("v3",48,o4);const l4=c4;function f4(e,n,r){e=e||{};var a=e.random||(e.rng||jx)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){r=r||0;for(var i=0;i<16;++i)n[r+i]=a[i];return n}return rp(a)}function d4(e,n,r,a){switch(e){case 0:return n&r^~n&a;case 1:return n^r^a;case 2:return n&r^n&a^r&a;case 3:return n^r^a}}function p1(e,n){return e<<n|e>>>32-n}function p4(e){var n=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var a=unescape(encodeURIComponent(e));e=[];for(var i=0;i<a.length;++i)e.push(a.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var u=e.length/4+2,c=Math.ceil(u/16),f=new Array(c),p=0;p<c;++p){for(var h=new Uint32Array(16),m=0;m<16;++m)h[m]=e[p*64+m*4]<<24|e[p*64+m*4+1]<<16|e[p*64+m*4+2]<<8|e[p*64+m*4+3];f[p]=h}f[c-1][14]=(e.length-1)*8/Math.pow(2,32),f[c-1][14]=Math.floor(f[c-1][14]),f[c-1][15]=(e.length-1)*8&4294967295;for(var b=0;b<c;++b){for(var E=new Uint32Array(80),O=0;O<16;++O)E[O]=f[b][O];for(var R=16;R<80;++R)E[R]=p1(E[R-3]^E[R-8]^E[R-14]^E[R-16],1);for(var C=r[0],k=r[1],j=r[2],F=r[3],D=r[4],M=0;M<80;++M){var S=Math.floor(M/20),q=p1(C,5)+d4(S,k,j,F)+D+n[S]+E[M]>>>0;D=F,F=j,j=p1(k,30)>>>0,k=C,C=q}r[0]=r[0]+C>>>0,r[1]=r[1]+k>>>0,r[2]=r[2]+j>>>0,r[3]=r[3]+F>>>0,r[4]=r[4]+D>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var h4=Fx("v5",80,p4);const v4=h4,g4="00000000-0000-0000-0000-000000000000";function m4(e){if(!tp(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}const y4=Object.freeze(Object.defineProperty({__proto__:null,NIL:g4,parse:Lx,stringify:rp,v1:e4,v3:l4,v4:f4,v5:v4,validate:tp,version:m4},Symbol.toStringTag,{value:"Module"})),b4=cA(y4);function rw(e,n){if(!e||!n||!e.length||!n.length)throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=n}rw.prototype.convert=function(e){var n,r,a,i={},u=this.srcAlphabet.length,c=this.dstAlphabet.length,f=e.length,p=typeof e=="string"?"":[];if(!this.isValid(e))throw new Error('Number "'+e+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return e;for(n=0;n<f;n++)i[n]=this.srcAlphabet.indexOf(e[n]);do{for(r=0,a=0,n=0;n<f;n++)r=r*u+i[n],r>=c?(i[a++]=parseInt(r/c,10),r=r%c):a>0&&(i[a++]=0);f=a,p=this.dstAlphabet.slice(r,r+1).concat(p)}while(a!==0);return p};rw.prototype.isValid=function(e){for(var n=0;n<e.length;++n)if(this.srcAlphabet.indexOf(e[n])===-1)return!1;return!0};var _4=rw,w4=_4;function yf(e,n){var r=new w4(e,n);return function(a){return r.convert(a)}}yf.BIN="01";yf.OCT="01234567";yf.DEC="0123456789";yf.HEX="0123456789abcdef";var E4=yf;const{v4:h1}=b4,Mf=E4,v1="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",S4="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",O4={consistentLength:!0};let g1;const MS=(e,n,r)=>{const a=n(e.toLowerCase().replace(/-/g,""));return!r||!r.consistentLength?a:a.padStart(r.shortIdLength,r.paddingChar)},T4=(e,n)=>{const a=n(e).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/);return[a[1],a[2],a[3],a[4],a[5]].join("-")},x4=e=>Math.ceil(Math.log(2**128)/Math.log(e));var _d=(()=>{const e=(n,r)=>{const a=n||v1,i={...O4,...r};if([...new Set(Array.from(a))].length!==a.length)throw new Error("The provided Alphabet has duplicate characters resulting in unreliable results");const u=x4(a.length),c={shortIdLength:u,consistentLength:i.consistentLength,paddingChar:a[0]},f=Mf(Mf.HEX,a),p=Mf(a,Mf.HEX),h=()=>MS(h1(),f,c),m={new:h,generate:h,uuid:h1,fromUUID:b=>MS(b,f,c),toUUID:b=>T4(b,p),alphabet:a,maxLength:u};return Object.freeze(m),m};return e.constants={flickrBase58:v1,cookieBase90:S4},e.uuid=h1,e.generate=()=>(g1||(g1=e(v1).generate),g1()),e})(),gt=(e=>(e.DATACLASS="dataclass",e.METHOD="method",e.ATTRIBUTE="attribute",e.DATASTORE="datastore",e))(gt||{});const C4=[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE,gt.METHOD],wd="guest",nw=[{key:"read",label:"Read",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"create",label:"Create",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"update",label:"Update",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"drop",label:"Delete",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"describe",label:"Describe",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE,gt.METHOD]},{key:"execute",label:"Execute",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.METHOD]},{key:"promote",label:"Promote",canApplyTo:[gt.METHOD]}];function Gn(e,...n){return Array.from(new Set([...e,...n]))}function Bx(e){const n={},r=new Map;e.forEach(p=>{const h=p.id||_d.generate();n[h]={...p,id:h,parents:[],includes:Gn(p.includes||[]),resources:[]},r.set(p.privilege,h)}),Object.entries(n).forEach(([p,h])=>{const m=h.includes.map(b=>{const E=r.get(b);return E?(n[E].parents=Gn(n[E].parents,E),E):""}).filter(Boolean);n[p]={...h,includes:m}});const a=Ux(n),i=new Set;function u(p){i.add(p.id),p.includes=p.includes.filter(h=>!i.has(h))}if(a.forEach(u),a.forEach(p=>p.parents=[]),a.forEach(p=>{p.includes.forEach(h=>n[h].parents.push(p.id))}),Object.values(n).find(({privilege:p})=>p===wd))return n;const f=_d.generate();return{[f]:{id:f,privilege:wd,includes:[],parents:[],resources:[]},...n}}function Ux(e){return Object.values(e).sort((n,r)=>n.parents.length-r.parents.length)}function op(e,n){const r=n[e];let a=[];return r&&r.parents.forEach(i=>{a=Gn(a,...op(i,n),i)}),a}function Ed(e,n){const r=n[e];let a=[];return r&&r.includes.forEach(i=>{a=Gn(a,...Ed(i,n),i)}),a}function R4(e,n){const r=n[e];if(!r)return[];const a=[e,...op(e,n),...r.includes];return Object.keys(n).filter(i=>!a.includes(i))}function A4(e,n){return n[e]?Object.keys(n).reduce((a,i)=>i===e?a:{...a,[i]:{...n[i],parents:n[i].parents.filter(u=>u!==e),includes:n[i].includes.filter(u=>u!==e)}},{}):n}function P4(e,n,r){const a=r[e],i=r[n];return!a||!i?r:{...r,[e]:{...r[e],includes:Gn(a.includes,n)},[n]:{...r[n],parents:Gn(i.parents,e)}}}function D4(e,n,r){const a=r[e],i=r[n];return!a||!i?r:{...r,[e]:{...r[e],includes:r[e].includes.filter(u=>u!==n)},[n]:{...r[n],parents:r[n].parents.filter(u=>u!==e)}}}function zx(e,n){vT(e),Object.entries(n).forEach(([,{privilege:a}])=>{if(e.toLowerCase()===a.toLowerCase())throw new Error(`There's already a Privilege with the name ${e}`)});const r=_d.generate();return{[r]:{id:r,privilege:e,includes:[],parents:[],resources:[]},...n}}function I4(e,n,r,a,i){let u=zx(e,i);const c=Object.entries(u).find(([,f])=>f.privilege===e);return c?(u=Vx(c[1].id,n,r,a,u),u):i}function M4(e,n,r){if(!e)throw new Error("Please enter a name");if(!r[n])throw new Error("Invalid privilege");return Object.entries(r).forEach(([,{privilege:a,id:i}])=>{if(e.toLowerCase()===a.toLowerCase()&&n!==i)throw new Error(`There's already a Privilege with the name ${e}`)}),{...r,[n]:{...r[n],privilege:e}}}function k4(e,n){return e.map(r=>Ha(r,n))}function Ha(e,n){return n[e]?n[e]:null}function Hx({applyTo:e,type:n,...r}){return Object.entries(r).reduce((a,[i,u])=>{const c=Bt.find(nw,["key",i]);return!c||!c.canApplyTo.includes(n)||(typeof u=="string"?u.split(","):u).forEach(p=>{a[p]=Gn(a[p]||[],i)}),a},{})}const o_=(e,n=!1)=>["read","create","update","delete"].includes(e.toLowerCase())?`All ${n?"dataclasses and ":""}attributes have the '${e.toLowerCase()}' permission`:e.toLowerCase()==="execute"?`All functions defined ${n?"through the model (DataStore, Dataclasses, Entity selections, Entities) have the execute permission":"on this Dataclass, Entity selection class, Entity class have the execute permission"}`:`All ${n?"dataclasses, ":""}attributes and functions have the '${e.toLowerCase()}' permission`;function ow(e){return{permissions:nw.filter(({canApplyTo:n})=>n.includes(e.type)).map(({key:n,label:r})=>{const a={name:n,from:[]};switch(e.type){case gt.DATASTORE:return{...a,info:o_(r,!0)};case gt.DATACLASS:return{...a,info:o_(r)};default:return a}}),resource:e.applyTo,type:e.type}}function Gx(e,n){const r=qx(n),a={};return e.filter(({type:i})=>C4.includes(i)).forEach(i=>{const u=Hx(i);Object.entries(u).forEach(([c,f])=>{var m;const p=(m=r[c])==null?void 0:m.id;if(!p)return;a[p]=a[p]||{...n[p]};let h=Bt.find(a[p].resources,{resource:i.applyTo,type:i.type});h||(h=ow(i),a[p].resources.push(h)),h.permissions=h.permissions.map(b=>({...b,checked:b.checked||f.includes(b.name)}))})}),{...n,...a}}function qx(e){return Object.values(e).reduce((n,r)=>({...n,[r.privilege]:r}),{})}function ap(e){var r;const n=Bx(e.privileges||[]);return{privileges:Gx(((r=e.permissions)==null?void 0:r.allowed)||[],n),roles:(e.roles||[]).map(({id:a=_d.generate(),role:i,privileges:u=[]})=>({id:a,role:i,privileges:Gn(u).map(c=>{var f;return(f=Object.values(n).find(({privilege:p})=>p===c))==null?void 0:f.id}).filter(Boolean)})).reduce((a,i)=>({...a,[i.id]:{...i}}),{})}}function aw(e){const n=Object.values(e.privileges).filter(({includes:a})=>a.length===0).map(({id:a})=>a),r=[...n,...n.map(a=>op(a,e.privileges).reverse())].flat().filter((a,i,u)=>u.indexOf(a)===i).map(a=>e.privileges[a]);return{permissions:{allowed:Object.values(e.privileges).reduce((a,i)=>(i.resources.forEach(({permissions:u,resource:c,type:f})=>{let p=Bt.find(a,{applyTo:c,type:f});p||(p={applyTo:c,type:f},a.push(p)),u.forEach(({name:h,checked:m})=>{m&&p&&(p[h]=p[h]||[],p[h].push(i.privilege))})}),a),[])},privileges:r.filter(({privilege:a})=>a!==wd).map(({id:a,includes:i,privilege:u})=>({id:a,privilege:u,includes:i.map(c=>e.privileges[c].privilege)})),roles:Object.values(e.roles).map(a=>({...a,privileges:a.privileges.map(i=>{var u;return(u=e.privileges[i])==null?void 0:u.privilege}).filter(Boolean)}))}}function $4(e,n){const r=n[e],a={children:[],links:[],parents:[],selected:e};if(!r)return a;function i(f,p,h=[]){const m=f.reduce((b,E)=>[...b,...n[E][p]],[]);return m.length===0?h:(h.push(m),i(m,p,h))}function u(f){const p=[],h=[];for(let m=f.length-1;m>=0;m-=1){const b=f[m].filter(E=>p.includes(E)?!1:(p.push(E),!0));b.length>0&&h.unshift(Gn(b))}return h}function c(f,p){const h=[];return f.reduce((m,b)=>(b.forEach(E=>{n[E][p==="parents"?"includes":"parents"].forEach(R=>{h.includes(R)&&m.push(p==="parents"?{source:E,target:R}:{source:R,target:E})}),h.push(E)}),m),[])}return a.children=i([e],"includes"),a.children=u(a.children),a.parents=i([e],"parents"),a.parents=u(a.parents),a.links=[...c([[e],...a.parents],"parents"),...c([[e],...a.children],"includes")],a}function N4(e,n,r){const a=Ha(e,r);if(!a||Bt.find(a.resources,{resource:n.applyTo,type:n.type}))return r;const i={...a,resources:[...a.resources,ow(n)]};return{...r,[e]:i}}function j4(e,n,r){const a=Ha(e,r);if(!a)return r;const i={...a,resources:a.resources.filter(({resource:u,type:c})=>u!==n.applyTo||c!==n.type)};return{...r,[e]:i}}function L4(e,n){const r=Ha(e,n);if(!r)return n;const a={...r,resources:r.resources.filter(i=>i.permissions.some(u=>u.from.length)).map(i=>({...i,permissions:i.permissions.map(u=>({...u,checked:!1}))}))};return{...n,[e]:a}}function Vx(e,n,r,a,i){const u=Ha(e,i);if(!u)return i;const f=Bt.find(u.resources,{type:r,resource:n})?{...u,resources:u.resources.map(p=>p.type===r&&p.resource===n?{...p,permissions:p.permissions.map(h=>h.name===a?{...h,checked:!h.checked,from:[]}:h)}:p)}:{...u,resources:[...u.resources,{type:r,resource:n,permissions:nw.filter(p=>p.canApplyTo.includes(r)).map(p=>({from:[],name:p.key,checked:p.key===a,info:o_(p.key,r===gt.DATASTORE)}))}]};return{...i,[e]:f}}function F4(e,n,r,a){const i=Ha(e,a);if(!i)return a;const c=Bt.find(i.resources,{type:n.type,resource:n.resource})?{...i,resources:i.resources.map(f=>f.type===n.type&&f.resource===n.resource?{...f,permissions:n.permissions.map(p=>p.name===r.name?{...p,checked:!p.checked,from:[]}:p)}:f)}:{...i,resources:[...i.resources,{...n,permissions:n.permissions.map(f=>({...f,checked:r.name===f.name,from:[]}))}]};return{...a,[e]:c}}function W4(e,n){var p;const r=Yx(e,n)||[],a=((p=Ha(e,n))==null?void 0:p.resources)||[],c=([...r,...a].filter(({type:h})=>h===gt.METHOD)||[]).map(({resource:h})=>h);return Object.entries(n).reduce((h,[m,{resources:b}])=>(b.filter(({resource:E,type:O})=>O===gt.METHOD&&c.includes(E)).forEach(({permissions:E,resource:O})=>{var C;((C=E.find(({name:k})=>k==="promote"))==null?void 0:C.checked)&&(h[O]=Gn(h[O]||[],m))}),h),{})}function Yx(e,n){var c;const r=Ha(e,n);if(!r)return[];const a=(c=Object.values(n).find(f=>f.privilege===wd))==null?void 0:c.id;return(a&&a!==e?Gn(Ed(e,n),a):Ed(e,n)).reduce((f,p)=>(n[p].resources.forEach(m=>{if(m.permissions.filter(({checked:O})=>O).length===0)return;const E=Bt.find(f,{type:m.type,resource:m.resource});if(!E){f.push({...m,permissions:m.permissions.map(O=>({...O,from:O.checked?[p]:[],checked:!1}))});return}E.permissions=E.permissions.map((O,R)=>{let{from:C=[]}=O;return m.permissions[R].checked&&!C.includes(p)&&(C=[...C,p]),{...O,from:C,checked:O.checked}})}),f),Bt.clone(r.resources.map(f=>({...f,permissions:f.permissions.map(({checked:p,...h})=>({...h,checked:!!p}))}))))}const B4=e=>e.reduce((n,r)=>({...n,[r.id]:{...r}}),{}),U4=(e,n)=>n[e]?Object.values(n).reduce((r,a)=>e===a.id||a.role===""?r:{...r,[a.id]:a},{}):n,z4=(e,n,r)=>r[e]?Object.values(r).reduce((a,i)=>e===i.id?{...a,[i.id]:{...i,name:n}}:{...a,[i.id]:i},{}):r,H4=(e,n)=>{const r={id:e,role:"",privileges:[]};return{...n,[r.id]:r}},G4=(e,n)=>{if(vT(e.role),Object.values(n).find(a=>a.role===e.role))throw new Error(`a role with the name ${e.role} already exists`);return Object.values(n).reduce((a,i)=>e.id===i.id?{...a,[e.id]:e}:{...a,[i.id]:i},{})},q4={list:[]},kS=(e,n)=>e.list.filter(r=>r.id!==n),Kx=qn({name:"modals",initialState:q4,reducers:{createModal:(e,n)=>{e.list.push(n.payload)},editModal:(e,n)=>{const{id:r,...a}=n.payload,i=e.list.find(QM(r));i&&Object.assign(i,{...a})},removeModal:(e,n)=>{const r=n.payload;e.list=kS(e,r)},closeModal:(e,n)=>{const{id:r,reason:a}=n.payload;if(a){const i=e.list.find(u=>u.id===r);i&&(i.closeReason=a,i.isOpen=!1)}else e.list=kS(e,r)}}}),{createModal:Xx,removeModal:Jx,closeModal:V4,editModal:Y4}=Kx.actions;var Zx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$S=ie.createContext&&ie.createContext(Zx),ei=globalThis&&globalThis.__assign||function(){return ei=Object.assign||function(e){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ei.apply(this,arguments)},K4=globalThis&&globalThis.__rest||function(e,n){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(r[a[i]]=e[a[i]]);return r};function Qx(e){return e&&e.map(function(n,r){return ie.createElement(n.tag,ei({key:r},n.attr),Qx(n.child))})}function ip(e){return function(n){return ie.createElement(X4,ei({attr:ei({},e.attr)},n),Qx(e.child))}}function X4(e){var n=function(r){var a=e.attr,i=e.size,u=e.title,c=K4(e,["attr","size","title"]),f=i||r.size||"1em",p;return r.className&&(p=r.className),e.className&&(p=(p?p+" ":"")+e.className),ie.createElement("svg",ei({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,a,c,{className:p,style:ei(ei({color:e.color||r.color},r.style),e.style),height:f,width:f,xmlns:"http://www.w3.org/2000/svg"}),u&&ie.createElement("title",null,u),e.children)};return $S!==void 0?ie.createElement($S.Consumer,null,function(r){return n(r)}):n(Zx)}function J4(e){return ip({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"}}]})(e)}function Z4(e){return ip({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}}]})(e)}function Q4(e){return ip({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11.953 2C6.465 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.493 2 11.953 2zM12 20c-4.411 0-8-3.589-8-8s3.567-8 7.953-8C16.391 4 20 7.589 20 12s-3.589 8-8 8z"}},{tag:"path",attr:{d:"M11 7h2v7h-2zm0 8h2v2h-2z"}}]})(e)}function e6(e){return ip({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"}}]})(e)}const t6={FaSave:J4,AiFillWarning:e6,BiErrorCircle:Q4,BsFillInfoCircleFill:Z4};var Hn=(e=>(e.ALERT="alert",e.CONFIRM="confirm",e))(Hn||{}),Ga=(e=>(e.PRIMARY="primary",e.WARNING="warning",e.DANGER="danger",e))(Ga||{}),iw=(e=>(e.CONFIRMED="confirmed",e.CANCELED="canceled",e))(iw||{});const Eo=xe("modals/open",async(e,{dispatch:n})=>{const{type:r=Hn.ALERT}=e,a=y_();switch(n(Xx({id:a,type:r,isOpen:!0,...e})),r){case Hn.CONFIRM:return new Promise(i=>{const u=Ds.subscribe(()=>{var p;const{modals:c}=Ds.getState(),f=c.list.find(h=>h.id===a);if(f&&!f.isOpen){const h=f.closeReason===iw.CONFIRMED,m=Bt.entries((p=f.views)==null?void 0:p.toggles).reduce((b,E)=>({...b,[E[0]]:E[1].value}),{});n(Jx(a)),u(),i({confirmed:h,options:m})}})});default:return{}}}),eC=()=>hk({name:Ur}),tC="Roles & Privileges",Sd=xe("roles/fetchRoles",async(e,{dispatch:n,rejectWithValue:r})=>{var u;let a;try{a=await eC()}catch(c){if(!Array.isArray((u=c==null?void 0:c.data)==null?void 0:u.__ERROR))return r("Error while loading the roles");a={name:Ur,date:new Date().toISOString(),content:{permissions:{allowed:[]},privileges:[],roles:[]}}}const i={name:tC,type:le.ROLES,date:a.date,view:{panel:{isOpen:!1,type:"",current:""}},path:Ur,flags:{},content:{}};return n(wn(i)),{...a,content:ap(a.content)}}),rC=xe("roles/fetchRolesChanges",async(e,{getState:n})=>{const{tabs:r}=n().root;if(r.find(i=>i.path===Ur)){const{date:i}=n().roles;if(i&&await sw(i))return{old:!0}}return{}}),sw=async e=>{if(!e)return!1;try{const n=await eC();if(n.date){const r=new Date(e),a=new Date(n.date);if(r>a)return!0}}catch(n){if(!Array.isArray(n==null?void 0:n.data.__ERROR))throw n}return!1},a_=xe("roles/saveRoles",async(e,{getState:n,rejectWithValue:r,dispatch:a})=>{try{const{flags:i,date:u}=n().roles;if(i.old||await sw(u)){const{confirmed:p}=await a(Eo({title:tC,message:"New content has been found on the server. Are you sure you want to continue?",type:Hn.CONFIRM,icon:"FaSave"})).unwrap();if(!p)return r({old:!0})}return await Gd({name:Ur,content:aw(e)})}catch{return r("Error while loading the roles")}}),r6=nu().roles,{roles:n6={},privileges:o6={},flags:a6={touched:!1},date:i6,selectedTab:s6="roles"}=r6||{},u6={flags:a6,roles:n6,privileges:o6,date:i6,selectedTab:s6},nC=qn({name:"roles",initialState:u6,reducers:{updatePrivileges:(e,n)=>{e.privileges=n.payload,e.flags.touched=!0},updateRoles:(e,n)=>{e.roles=n.payload,e.flags.touched=!0},updateRolesAndPrivileges:(e,n)=>{e.roles=n.payload.roles,e.privileges=n.payload.privileges},toggleTab:(e,n)=>{e.selectedTab=n.payload},setRolesContent(e,n){const{content:r,date:a}=n.payload,i=ap(r);return{...e,...i,date:a}}},extraReducers(e){e.addCase(Sd.fulfilled,(n,r)=>{const{content:a,date:i}=r.payload;n={...n,...a,date:i}}).addCase(Sd.rejected,n=>({...n,roles:{},privileges:{},flags:{touched:!1},date:void 0})).addCase(a_.fulfilled,(n,r)=>({...n,flags:{...n.flags,touched:!1,old:!1},date:r.payload.date})).addCase(a_.rejected,(n,r)=>FT.isString(r.payload)?n:{...n,flags:{...n.flags,...r.payload}}).addCase(rC.fulfilled,(n,r)=>({...n,flags:{...n.flags,...r.payload}})).addCase(Ys.fulfilled,(n,r)=>{!r.payload||r.payload.path!==Ur||(n.flags.touched=!1,n.flags.old=!1)}).addCase(hw.fulfilled,(n,r)=>{r.meta.arg!==Ur||!r.payload||(n.flags.touched=!1,n.flags.old=!1)})}}),{updatePrivileges:oC,updateRoles:aC,setRolesContent:uw,toggleTab:c6,updateRolesAndPrivileges:cw}=nC.actions,l6=nC.reducer,oi="qodlyApp.json",lw=xe("settings/fetch",async()=>await ni({verb:Zt.GET_INFO,path:oi,content:!0,as:"json"})),iC=xe("settings/app",uk),f6=IT(),NS={session:{"studio.tips":!0,"studio.notifications":!0,"webforms.tooltip.behavior":tw.SHOW_AFTER_TIMEOUT,"webforms.tooltip.timeout":3e3,"webforms.renderer.showPopOver":!0,"welcometour.active":!0,"webforms.properties.advanced-mode":!1,"monaco.zoom":0},project:{"webforms.renderer.indexPage":"","webforms.display-mode":"neutral"},server:{projectOpened:!1,remoteDebuggerMode:W_.DISABLED,baseUrl:"",qodly:!0,urls:{renderer:"/$lib/renderer/",debugger:"",lsp:""},isRestActive:!0}},d6={...NS,session:{...NS.session,...f6},welcometour:{}},sC=qn({name:"settings",initialState:d6,reducers:{setSetting(e,n){const{path:r,settingsKey:a,value:i}=n.payload;e[r][a]=i},setSettings(e,n){const{path:r,value:a}=n.payload;e[r]={...e[r],...a}},setSettingsAsText(e,n){const{path:r,settings:a}=n.payload;e[r]=a}},extraReducers(e){e.addCase(lw.fulfilled,(n,r)=>{n.project={...n.project,...r.payload.content}}),e.addCase(iC.fulfilled,(n,r)=>{n.server=r.payload,n.server.qodly&&(n.project["webforms.display-mode"]="airy")})}}),{setSetting:uC,setSettings:sp,setSettingsAsText:p6}=sC.actions,h6=sC.reducer,i_=e=>{const n=["folder","file"];return e.sort((r,a)=>r.type===a.type?r.name.localeCompare(a.name):n.indexOf(r.type)-n.indexOf(a.type))},ct=(e,n)=>e.reduce((r,a)=>a.path===n.path&&a.type===n.type?[...r,n]:a.children?[...r,{...a,children:i_(ct(a.children,n))}]:[...r,a],[]),Tr=(e,n)=>e.reduce((r,a)=>r||(a.path===n?a:a.children?Tr(a.children,n):null),null),v6=[{name:Wt.WEBFORMS,type:le.FOLDER,children:[],path:Wt.WEBFORMS,error:null,flags:{expanded:!1,loading:!1,cached:!1},tipKey:"editors:webform:explorer:webforms",config:{},isRoot:!0},{name:Wt.METHODS,type:le.FOLDER,children:[],path:Wt.METHODS,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:Wt.CLASSES,type:le.FOLDER,children:[],path:Wt.CLASSES,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:Wt.SHARED,type:le.FOLDER,children:[],path:Wt.SHARED,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:"Debugger",type:le.FOLDER,children:[],path:"Debugger",error:null,flags:{expanded:!1,cached:!0},config:{},isRoot:!0},{name:"Roles And Privileges",type:le.FILE,ext:"json",path:"roles",error:null,flags:{},config:{editor:{key:"editors:roles"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]},isRoot:!0},{name:"Model",type:le.MODEL,ext:"4DModel",path:"model",error:null,flags:{},config:{editor:{key:"editors:model"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]}},{name:"Settings",type:le.FILE,ext:"json",path:"qodlyApp",error:null,flags:{},config:{editor:{key:"editors:settings"}},isRoot:!0}],cC=qn({name:"explorer",initialState:v6,reducers:{toggleExpandFolder:(e,n)=>(e=ct(e,{...n.payload,flags:{...n.payload.flags,expanded:!n.payload.flags.expanded}}),e),expandFolder:(e,n)=>(e=ct(e,{...n.payload,flags:{...n.payload.flags,expanded:!0}}),e),openAddFileInput:(e,n)=>ct(e,{...n.payload,flags:{...n.payload.flags,adding:!0}}),addNewFile:(e,n)=>{const{parent:r,child:a}=n.payload;return ct(e,{...r,children:[a,...r.children||[]]})},removeFile:(e,n)=>{const{parent:r,child:a}=n.payload;return ct(e,{...r,children:r.children.filter(i=>i.path!==a.path)})},refreshFile:(e,n)=>{const{parent:r,child:a}=n.payload,i=(r.children||[]).filter(u=>u.path!==a.path&&!a.error);return ct(e,{...r,children:[a,...i]})},setFolderChildren:(e,n)=>{const r=Tr(e,n.payload.parentPath);return r?ct(e,{...r,children:n.payload.children}):e}},extraReducers:e=>{e.addCase(Vs.pending,(n,r)=>{const{file:a,newname:i}=r.meta.arg,u=Tr(n,a.path);if(!u)return n;const c=a.path.split("/");c.pop();const f=`${c.join("/")}/${a.name}.${a.ext}`,p=`${c.join("/")}/${i}.${a.ext}`;switch(a.ext){case"4dm":case"4qs":Xa.next({action:ka.WILL_RENAME,payload:{oldPath:f,newPath:p}});break}return ct(n,{...u,flags:{...u.flags,loading:!0}})}),e.addCase(Vs.fulfilled,(n,r)=>{const{meta:{arg:{file:a}},payload:i}=r,u=Tr(n,a.path);if(!u)return n;switch(i.old.ext){case"4dm":case"4qs":Xa.next({action:ka.DID_RENAME,payload:{oldPath:i.old.path,newPath:i.new.path}});break}return ct(n,{...u,flags:{...u.flags,loading:!1}})}),e.addCase(Vs.rejected,(n,r)=>{const{file:a}=r.meta.arg,i=Tr(n,a.path);return i?ct(n,{...i,flags:{...i.flags,loading:!1}}):n}),e.addCase(Po.pending,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,flags:{...i.flags,loading:!0}}):n}),e.addCase(Po.fulfilled,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,children:i_(r.payload),flags:{...i.flags,loading:!1,cached:!0,expanded:!0},error:null}):n}),e.addCase(Po.rejected,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,error:{message:r.payload},flags:{...i.flags,loading:!1,cached:!0,expanded:!0}}):n}),e.addCase(zl.pending,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,flags:{...i.flags,loading:!0}}):n}),e.addCase(zl.fulfilled,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,children:i_(r.payload),flags:{...i.flags,loading:!1,cached:!0,expanded:!1},error:null}):n}),e.addCase(zl.rejected,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,error:{message:r.payload},flags:{...i.flags,loading:!1,cached:!0,expanded:!1}}):n}),e.addCase(qf.pending,(n,r)=>{const{fileName:a,parentNode:i,path:u,type:c}=r.meta.arg;return ct(n,{...i,children:[{name:a,path:`${u}/${a}`,type:c,error:null,flags:{loading:!0},config:{}},...i.children]})}),e.addCase(qf.fulfilled,(n,r)=>{const{path:a,fileName:i,type:u}=r.meta.arg,c=Ws(u),{editor:f,supportedEditors:p}=bo(`${a}${c?`.${c.toLowerCase()}`:""}`);return ct(n,{name:i,path:`${a}/${i}`,type:u,error:null,flags:{loading:!1},config:{editor:f,supportedEditors:p}})}),e.addCase(qf.rejected,(n,r)=>{const{path:a,fileName:i,type:u}=r.meta.arg;return ct(n,{name:i,path:`${a}/${i}`,type:u,error:{message:r.payload},flags:{loading:!1},config:{}})}),e.addCase(Vf.pending,(n,r)=>{const{node:a,parentNode:i}=r.meta.arg;return ct(n,{...i,children:[{name:`${a.name}_copy`,path:`${a.path}/${a.name}_copy`,type:a.type,error:null,flags:{loading:!0},permissions:{canRename:!0,canDelete:!0}},...i.children]})}),e.addCase(Vf.fulfilled,(n,r)=>{const{node:a}=r.payload,{node:{path:i,ext:u}}=r.meta.arg,{editor:c,supportedEditors:f}=bo(`${i}${u?`.${u.toLowerCase()}`:""}`);return ct(n,{name:`${a.name}`,path:`${i}/${a.name}`,type:a.type,error:null,flags:{loading:!1},config:{editor:c,supportedEditors:f}})}),e.addCase(Vf.rejected,(n,r)=>{const a=r.payload,{node:i}=r.meta.arg;return ct(n,{name:`${i.name}_copy`,path:`${i.path}/${i.name}_copy`,type:i.type,error:{message:a},flags:{loading:!1},config:{}})}),e.addCase(Gl.pending,(n,r)=>{}),e.addCase(Gl.fulfilled,(n,r)=>{var b;const{draggedNode:a,newLocation:i}=r.meta.arg,u=dx(a.path),c=Tr(n,u),f=Tr(n,i.path),p=(b=c==null?void 0:c.children)==null?void 0:b.filter(E=>E.path!==a.path),h=i.path.split("/").length,m=a.path.split("/").length;return h>=m?(n=ct(n,{...c,children:p}),n=ct(n,{...f,children:[{...a,path:`${f.path}/${a.name}`},...f!=null&&f.children?f==null?void 0:f.children:[]],flags:{...f.flags,expanded:!0}})):(n=ct(n,{...f,children:[{...a,path:`${f.path}/${a.name}`},...f!=null&&f.children?f==null?void 0:f.children:[]],flags:{...f.flags,expanded:!0}}),n=ct(n,{...c,children:p})),n}),e.addCase(Gl.rejected,(n,r)=>{Ao.next({message:"Error moving file",kind:"danger"})}),e.addCase(qs.pending,(n,r)=>{var C;const{fileName:a,parentNode:i,path:u,type:c,qodly:f}=r.meta.arg,p=Ws(c,f),h=`${u}/${a}${p?`.${p.toLowerCase()}`:""}`,{editor:m,supportedEditors:b}=bo(h);switch(c){case le.CLASS:case le.METHOD:Xa.next({action:ka.WILL_CREATE,payload:{filePath:h}});break}const E=(C=i.children)==null?void 0:C.filter(k=>k.path!==`${u}/${a}`),O=[{name:a,path:`${u}/${a}`,type:le.FILE,error:null,flags:{loading:!0},config:{editor:m,supportedEditors:b},ext:p,date:new Date().toISOString()},...E],R=ct(n,{...i,children:O});return FT.merge(n,R)}),e.addCase(qs.fulfilled,(n,r)=>{const{fileName:a,path:i,type:u,qodly:c}=r.meta.arg,f=Ws(u,c),p=`${i}/${a}${f?`.${f.toLowerCase()}`:""}`,{editor:h,supportedEditors:m}=bo(p),b=ct(n,{name:a,path:`${i}/${a}`,type:le.FILE,error:null,flags:{},config:{editor:h,supportedEditors:m},ext:f,date:new Date().toISOString()});switch(u){case le.CLASS:case le.METHOD:Xa.next({action:ka.DID_CREATE,payload:{filePath:p}});break}return n=b,n}),e.addCase(qs.rejected,(n,r)=>{const{fileName:a,path:i,type:u}=r.meta.arg,c=Ws(u),{editor:f,supportedEditors:p}=bo(`${i}${c?`.${c.toLowerCase()}`:""}`);return n=ct(n,{name:a,path:`${i}/${a}`,type:le.FILE,error:{message:"Failed creating file"},flags:{},config:{editor:f,supportedEditors:p},ext:c,date:new Date().toISOString()}),n}),e.addMatcher(iO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!0}})),n}),e.addMatcher(uO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!1}})),n}),e.addMatcher(sO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!1}})),Ao.next({message:"Failed to open file, try again",kind:"danger"}),n})}}),{toggleExpandFolder:g6,expandFolder:m6,openAddFileInput:y6,addNewFile:lC,refreshFile:b6,removeFile:s_,setFolderChildren:_6}=cC.actions;function fC(e){switch(e){case le.WEBFORMS:return Nx;case le.METHODS:return`//%attributes = {}
|
|
269
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function t_(e,n){if(e){var r=e.indexOf(n);0<=r&&e.splice(r,1)}}var Qd=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,r,a,i,u;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var f=e_(c),p=f.next();!p.done;p=f.next()){var h=p.value;h.remove(this)}}catch(C){n={error:C}}finally{try{p&&!p.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}else c.remove(this);var m=this.initialTeardown;if(ja(m))try{m()}catch(C){u=C instanceof s1?C.errors:[C]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var E=e_(b),O=E.next();!O.done;O=E.next()){var R=O.value;try{CS(R)}catch(C){u=u??[],C instanceof s1?u=bd(bd([],yd(u)),yd(C.errors)):u.push(C)}}}catch(C){a={error:C}}finally{try{O&&!O.done&&(i=E.return)&&i.call(E)}finally{if(a)throw a.error}}}if(u)throw new s1(u)}},e.prototype.add=function(n){var r;if(n&&n!==this)if(this.closed)CS(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(n)}},e.prototype._hasParent=function(n){var r=this._parentage;return r===n||Array.isArray(r)&&r.includes(n)},e.prototype._addParent=function(n){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(n),r):r?[r,n]:n},e.prototype._removeParent=function(n){var r=this._parentage;r===n?this._parentage=null:Array.isArray(r)&&t_(r,n)},e.prototype.remove=function(n){var r=this._finalizers;r&&t_(r,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}(),vx=Qd.EMPTY;function gx(e){return e instanceof Qd||e&&"closed"in e&&ja(e.remove)&&ja(e.add)&&ja(e.unsubscribe)}function CS(e){ja(e)?e():e.unsubscribe()}var mx={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},r_={setTimeout:function(e,n){for(var r=[],a=2;a<arguments.length;a++)r[a-2]=arguments[a];var i=r_.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,bd([e,n],yd(r))):setTimeout.apply(void 0,bd([e,n],yd(r)))},clearTimeout:function(e){var n=r_.delegate;return((n==null?void 0:n.clearTimeout)||clearTimeout)(e)},delegate:void 0};function AL(e){r_.setTimeout(function(){throw e})}function RS(){}function Gf(e){e()}var yx=function(e){Zd(n,e);function n(r){var a=e.call(this)||this;return a.isStopped=!1,r?(a.destination=r,gx(r)&&r.add(a)):a.destination=ML,a}return n.create=function(r,a,i){return new n_(r,a,i)},n.prototype.next=function(r){this.isStopped||this._next(r)},n.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(r){this.destination.next(r)},n.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(Qd),PL=Function.prototype.bind;function u1(e,n){return PL.call(e,n)}var DL=function(){function e(n){this.partialObserver=n}return e.prototype.next=function(n){var r=this.partialObserver;if(r.next)try{r.next(n)}catch(a){Df(a)}},e.prototype.error=function(n){var r=this.partialObserver;if(r.error)try{r.error(n)}catch(a){Df(a)}else Df(n)},e.prototype.complete=function(){var n=this.partialObserver;if(n.complete)try{n.complete()}catch(r){Df(r)}},e}(),n_=function(e){Zd(n,e);function n(r,a,i){var u=e.call(this)||this,c;if(ja(r)||!r)c={next:r??void 0,error:a??void 0,complete:i??void 0};else{var f;u&&mx.useDeprecatedNextContext?(f=Object.create(r),f.unsubscribe=function(){return u.unsubscribe()},c={next:r.next&&u1(r.next,f),error:r.error&&u1(r.error,f),complete:r.complete&&u1(r.complete,f)}):c=r}return u.destination=new DL(c),u}return n}(yx);function Df(e){AL(e)}function IL(e){throw e}var ML={closed:!0,next:RS,error:IL,complete:RS},kL=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function $L(e){return e}function NL(e){return e.length===0?$L:e.length===1?e[0]:function(r){return e.reduce(function(a,i){return i(a)},r)}}var AS=function(){function e(n){n&&(this._subscribe=n)}return e.prototype.lift=function(n){var r=new e;return r.source=this,r.operator=n,r},e.prototype.subscribe=function(n,r,a){var i=this,u=LL(n)?n:new n_(n,r,a);return Gf(function(){var c=i,f=c.operator,p=c.source;u.add(f?f.call(u,p):p?i._subscribe(u):i._trySubscribe(u))}),u},e.prototype._trySubscribe=function(n){try{return this._subscribe(n)}catch(r){n.error(r)}},e.prototype.forEach=function(n,r){var a=this;return r=PS(r),new r(function(i,u){var c=new n_({next:function(f){try{n(f)}catch(p){u(p),c.unsubscribe()}},error:u,complete:i});a.subscribe(c)})},e.prototype._subscribe=function(n){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(n)},e.prototype[kL]=function(){return this},e.prototype.pipe=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return NL(n)(this)},e.prototype.toPromise=function(n){var r=this;return n=PS(n),new n(function(a,i){var u;r.subscribe(function(c){return u=c},function(c){return i(c)},function(){return a(u)})})},e.create=function(n){return new e(n)},e}();function PS(e){var n;return(n=e??mx.Promise)!==null&&n!==void 0?n:Promise}function jL(e){return e&&ja(e.next)&&ja(e.error)&&ja(e.complete)}function LL(e){return e&&e instanceof yx||jL(e)&&gx(e)}var FL=hx(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),bx=function(e){Zd(n,e);function n(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return n.prototype.lift=function(r){var a=new DS(this,this);return a.operator=r,a},n.prototype._throwIfClosed=function(){if(this.closed)throw new FL},n.prototype.next=function(r){var a=this;Gf(function(){var i,u;if(a._throwIfClosed(),!a.isStopped){a.currentObservers||(a.currentObservers=Array.from(a.observers));try{for(var c=e_(a.currentObservers),f=c.next();!f.done;f=c.next()){var p=f.value;p.next(r)}}catch(h){i={error:h}}finally{try{f&&!f.done&&(u=c.return)&&u.call(c)}finally{if(i)throw i.error}}}})},n.prototype.error=function(r){var a=this;Gf(function(){if(a._throwIfClosed(),!a.isStopped){a.hasError=a.isStopped=!0,a.thrownError=r;for(var i=a.observers;i.length;)i.shift().error(r)}})},n.prototype.complete=function(){var r=this;Gf(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var a=r.observers;a.length;)a.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},n.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},n.prototype._innerSubscribe=function(r){var a=this,i=this,u=i.hasError,c=i.isStopped,f=i.observers;return u||c?vx:(this.currentObservers=null,f.push(r),new Qd(function(){a.currentObservers=null,t_(f,r)}))},n.prototype._checkFinalizedStatuses=function(r){var a=this,i=a.hasError,u=a.thrownError,c=a.isStopped;i?r.error(u):c&&r.complete()},n.prototype.asObservable=function(){var r=new AS;return r.source=this,r},n.create=function(r,a){return new DS(r,a)},n}(AS),DS=function(e){Zd(n,e);function n(r,a){var i=e.call(this)||this;return i.destination=r,i.source=a,i}return n.prototype.next=function(r){var a,i;(i=(a=this.destination)===null||a===void 0?void 0:a.next)===null||i===void 0||i.call(a,r)},n.prototype.error=function(r){var a,i;(i=(a=this.destination)===null||a===void 0?void 0:a.error)===null||i===void 0||i.call(a,r)},n.prototype.complete=function(){var r,a;(a=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||a===void 0||a.call(r)},n.prototype._subscribe=function(r){var a,i;return(i=(a=this.source)===null||a===void 0?void 0:a.subscribe(r))!==null&&i!==void 0?i:vx},n}(bx);const _x=new bx,WL=()=>JT(),Ua=sL,J_=pe(e=>e,e=>e.catalog.state==="loaded"?e.catalog.model:null),BL=pe(J_,e=>e?e.dataClasses:[]),UL=pe(J_,e=>e?e.methods:[]),wx=e=>pe(n=>n,n=>{switch(n.catalog.state){case"loaded":const r=e?n.catalog.model.dataClasses[e]:n.catalog.model;return(r==null?void 0:r.methods)||[];default:return[]}}),zL=e=>Ua(wx(e),YT),HL=(e,n)=>pe(wx(e),r=>r.find(a=>`${a.applyTo}.${a.name}`===n)),GL=(e,n,r)=>Ua(HL(e,`${r}.${n}`),YT),Ex=pe(e=>e,e=>e),qL=e=>pe(za,n=>{var i;const r=n.tabs.find(({path:u})=>u===e),a=r==null?void 0:r.content.components;return!r||!a?[]:(i=Object.keys(a))==null?void 0:i.map(u=>({id:u,...a[u]}))}),Sx=e=>pe(za,n=>{var a,i;const r=n.tabs.find(({path:u})=>u===e);return((i=(a=r==null?void 0:r.content)==null?void 0:a.metadata)==null?void 0:i.datasources)||[]}),VL=(e,n,r)=>pe(Ex,a=>{var i,u;if(n){const c=a.sharedDatasources.sources[n];return c?c.find(f=>f.id===e):void 0}else{const c=a.root.tabs.find(p=>p.path===r);return c?(u=(i=c.content.metadata)==null?void 0:i.datasources)==null?void 0:u.find(p=>p.id===e):void 0}}),Ox=pe(e=>e,e=>{var n;return((n=e.sharedDatasources)==null?void 0:n.sources)||[]}),YL=(e,n,r,a)=>pe(Sx(e),Ox,(i,u)=>{const c=Bt.flatten(Bt.values(u)),f=[...n!=="private"?i:[],...n!=="shared"?c:[]];return r?f.filter(p=>(!a||a.every(({id:h,namespace:m=""})=>p.id!==h||(p.namespace||"")!==m))&&(r.includes(p.type)||p.dataType&&(r.includes(p.dataType)||r.includes("objectFromArray")&&p.dataType==="object"&&p.from))):f}),KL=pe(e=>e.debugger,e=>e.meta),Is=pe(e=>e.debugger,e=>e.list),En=pe(e=>e.debugger,e=>e.sessions),XL=pe(En,e=>e.length),Ps=(e,n,r,a)=>e.find(i=>i.filePath===n&&i.methodName===r&&(!a||i.className===a)),dr=(e,n)=>e.find(r=>r.threadId===n),Tx=(e,n)=>e.find(r=>r.tabPath===n),JL=(e,n)=>pe(Is,r=>{var a;return((a=Ps(r,e,n))==null?void 0:a.breakpoints.saved.locations)||[]}),ZL=(e,n)=>pe(Is,r=>{var a;return((a=Ps(r,e,n))==null?void 0:a.breakpoints.draft.locations)||[]}),QL=e=>pe(Is,n=>n.filter(r=>r.filePath===e).reduce((r,a)=>[...r,...a.breakpoints.saved.locations.map(i=>({...i,line:i.line+(a.breakpoints.saved.offset||0)}))],[]).sort((r,a)=>r.line-a.line)),e3=e=>pe(Is,n=>n.filter(r=>r.filePath===e).reduce((r,a)=>[...r,...a.breakpoints.draft.locations.map(i=>({...i,line:i.line+(a.breakpoints.draft.offset||0)}))],[]).sort((r,a)=>r.line-a.line)),t3=e=>pe(En,n=>{const r=dr(n,e);return r!=null&&r.stopped?r.highlightedLines:null}),r3=e=>pe(En,n=>{const r=dr(n,e);return r!=null&&r.stopped?r.activeLine:null}),n3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.expressions)||[]}),o3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.stopped)||!1}),a3=(e,n)=>pe(Is,r=>{var a;return(a=Ps(r,e,n))==null?void 0:a.source}),i3=e=>pe(En,n=>{var r;return((r=Tx(n,e))==null?void 0:r.threadId)||-1}),s3=e=>pe(En,n=>{var r,a;return(a=(r=dr(n,e))==null?void 0:r.currentStackFrame)==null?void 0:a.source}),u3=e=>pe(En,n=>{var r;return(r=dr(n,e))==null?void 0:r.currentStackFrame}),c3=pe(En,e=>e.map(({channelId:n,threadId:r})=>({id:n,threadId:r}))),l3=e=>pe(En,n=>{var r;return((r=dr(n,e))==null?void 0:r.stackFrames)||[]}),f3=e=>pe(En,n=>{var r,a;return((a=(r=dr(n,e))==null?void 0:r.variables)==null?void 0:a.callchain)||[]}),d3=e=>pe(En,n=>{var r,a;return((a=(r=dr(n,e))==null?void 0:r.variables)==null?void 0:a.expressions)||[]}),p3=(e,n="saved")=>pe(Is,r=>{const a=r.find(i=>i.filePath===e);return(a==null?void 0:a.breakpoints[n].offset)||0}),h3=(e,n,r,a)=>pe(En,i=>{var h;const u=((h=dr(i,e))==null?void 0:h.exceptions)||[],c=n===le.CLASS,f=c&&a?`${a}.${r}`:r;return(f?u.filter(m=>m.location===f):u).map(m=>({...m,locationLine:c?m.locationLine:m.locationLine+1}))}),za=pe(e=>e.root,e=>e),cu=pe(za,e=>e.tabs),v3=pe(za,e=>e.activeTab),g3=pe(za,e=>e.recent.filter(({type:n})=>n!==le.DEBUGGER)),m3=pe(za,({tabs:e,activeTab:n})=>e.find(({path:r})=>r===n)),y3=pe(za,({tabs:e})=>e.reduce((r,a)=>(a==null?void 0:a.weight)>((r==null?void 0:r.weight)||0)?a:r,null)),b3=pe(cu,e=>e.filter(({type:n,flags:r})=>n===le.WEBFORM&&r.enabled===!1).map(({path:n})=>n)),_3=pe(cu,e=>e.length>0),gf=e=>pe(za,n=>n.tabs.find(({path:r})=>r===e)),xx=(e,n="")=>pe(gf(e),r=>!r||!r.content||typeof r.content=="string"?r==null?void 0:r.content:Bt.get(r.content,n)),w3=e=>pe(gf(e),n=>n==null?void 0:n.extra),E3=(e,n=r=>r)=>pe(xx(e,"components"),r=>n(r||{})),Z_=pe(cu,e=>e.filter(n=>n.flags.touched)),S3=pe(Z_,e=>e.length),O3=pe(En,e=>e.map(({threadId:n,currentStackFrame:{source:r},tabPath:a})=>({name:WT(n,r),path:a,type:le.DEBUGGER,content:r==null?void 0:r.content,flags:{},extra:{source:r}}))),T3=pe(e=>e,e=>e.explorer||[]),Cx=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.WEBFORMS)),Rx=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.METHODS)),Ax=pe(e=>e,e=>e.explorer.find(n=>n.path===Wt.CLASSES)),x3=pe(Rx,e=>(e==null?void 0:e.children)||[]),C3=pe(Cx,e=>(e==null?void 0:e.children)||[]),R3=pe(Ax,e=>(e==null?void 0:e.children)||[]),A3=pe(e=>e.modals,e=>e.list),P3=pe(e=>e.roles,({roles:e})=>e),D3=pe(e=>e.roles,({privileges:e})=>e),I3=pe(e=>e.roles,({privileges:e})=>Object.values(e).find(({privilege:n})=>n==="guest")),M3=pe(e=>e.roles,({flags:e})=>e),k3=pe(e=>e.roles,({selectedTab:e})=>e),$3=pe(e=>e.roles,({date:e})=>e),Px=pe(e=>e.settings,e=>e.session),N3=pe(e=>e.settings,e=>e.project),j3=pe(e=>e.settings,e=>e),Q_=pe(e=>e.settings,e=>e.server),L3=pe(Q_,e=>e.remoteDebuggerMode),F3=pe(Q_,e=>e.qodly),W3=pe(Px,e=>e["monaco.zoom"]),Dx=["rounded-full","rounded-lg","border-gray-400","border-2","bg-red-500","bg-blue-500","bg-indigo-500","bg-transparent","bg-primary-dark","bg-green-500","bg-yellow-400","text-gray-500","text-4xl","text-white","px-4","py-2","primary","info","secondary","success","warning","danger","w-10","w-20","w-40","w-60","w-80","mb-2","mb-3","shadow","shadow-lg","shadow-xl","shadow-2xl"],Ix=Dx.map(e=>({id:y_(),content:"",name:e,parentId:null,scope:As.THEME})),ew=e=>pe(gf(e),n=>{var r,a;return((a=(r=n==null?void 0:n.content)==null?void 0:r.metadata)==null?void 0:a.styles)||[]}),B3=(e,n)=>pe(ew(e),r=>n.map(a=>{switch(!0){case a===As.LOCAL:return r.map(i=>({...i,scope:As.LOCAL}));case a===As.THEME:return Ix;default:return[]}}).flat()),U3=e=>pe(ew(e),n=>[...n.map(r=>({...r,scope:As.LOCAL})),...Ix]),z3=pe(e=>e,e=>{var n;return[...(((n=e.sharedCSS)==null?void 0:n.styles)||[]).map(r=>({...r,scope:As.SHARED}))]}),H3=e=>pe(gf(e),n=>n==null?void 0:n.flags),mf=pe(e=>e.webforms,e=>e),Mx=pe(mf,e=>(e==null?void 0:e.components)||[]),ep=pe(mf,e=>e.inspector),G3=pe(ep,e=>e.css),q3=pe(ep,e=>e.datasource),kx=pe(mf,e=>e.templates||{data:[]}),V3=pe(kx,e=>e.data||[]),Y3=e=>pe(Mx,n=>n.find(r=>r.id===e)),K3=e=>pe(ep,n=>n[e]),X3=pe(mf,e=>e.datasources.theme),J3=pe(e=>e.catalog,e=>e.sharedDatasources,e=>e.sharedCSS,(e,n,r)=>[e.state,n.state,r.state].every(a=>["loaded","error"].includes(a)));var tw=(e=>(e.SHOW_AFTER_TIMEOUT="show_after_timeout",e.HIDE_AFTER_TIMEOUT="hide_after_timeout",e))(tw||{}),$x=(e=>(e.AIRY="airy",e.COMPACT="neutral",e))($x||{});const Nx={metadata:{v:"1.0",datasources:[],styles:[]},components:{ROOT:{parent:"",type:{resolvedName:"Container"},isCanvas:!0,props:{className:"bg-white h-full w-full px-6",classNames:[],events:[],airyMode:!1},displayName:"App",custom:{},hidden:!1,nodes:[],linkedNodes:{}}}};var If,Z3=new Uint8Array(16);function jx(){if(!If&&(If=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!If))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return If(Z3)}const Q3=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function tp(e){return typeof e=="string"&&Q3.test(e)}var Fr=[];for(var c1=0;c1<256;++c1)Fr.push((c1+256).toString(16).substr(1));function rp(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(Fr[e[n+0]]+Fr[e[n+1]]+Fr[e[n+2]]+Fr[e[n+3]]+"-"+Fr[e[n+4]]+Fr[e[n+5]]+"-"+Fr[e[n+6]]+Fr[e[n+7]]+"-"+Fr[e[n+8]]+Fr[e[n+9]]+"-"+Fr[e[n+10]]+Fr[e[n+11]]+Fr[e[n+12]]+Fr[e[n+13]]+Fr[e[n+14]]+Fr[e[n+15]]).toLowerCase();if(!tp(r))throw TypeError("Stringified UUID is invalid");return r}var IS,l1,f1=0,d1=0;function e4(e,n,r){var a=n&&r||0,i=n||new Array(16);e=e||{};var u=e.node||IS,c=e.clockseq!==void 0?e.clockseq:l1;if(u==null||c==null){var f=e.random||(e.rng||jx)();u==null&&(u=IS=[f[0]|1,f[1],f[2],f[3],f[4],f[5]]),c==null&&(c=l1=(f[6]<<8|f[7])&16383)}var p=e.msecs!==void 0?e.msecs:Date.now(),h=e.nsecs!==void 0?e.nsecs:d1+1,m=p-f1+(h-d1)/1e4;if(m<0&&e.clockseq===void 0&&(c=c+1&16383),(m<0||p>f1)&&e.nsecs===void 0&&(h=0),h>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f1=p,d1=h,l1=c,p+=122192928e5;var b=((p&268435455)*1e4+h)%4294967296;i[a++]=b>>>24&255,i[a++]=b>>>16&255,i[a++]=b>>>8&255,i[a++]=b&255;var E=p/4294967296*1e4&268435455;i[a++]=E>>>8&255,i[a++]=E&255,i[a++]=E>>>24&15|16,i[a++]=E>>>16&255,i[a++]=c>>>8|128,i[a++]=c&255;for(var O=0;O<6;++O)i[a+O]=u[O];return n||rp(i)}function Lx(e){if(!tp(e))throw TypeError("Invalid UUID");var n,r=new Uint8Array(16);return r[0]=(n=parseInt(e.slice(0,8),16))>>>24,r[1]=n>>>16&255,r[2]=n>>>8&255,r[3]=n&255,r[4]=(n=parseInt(e.slice(9,13),16))>>>8,r[5]=n&255,r[6]=(n=parseInt(e.slice(14,18),16))>>>8,r[7]=n&255,r[8]=(n=parseInt(e.slice(19,23),16))>>>8,r[9]=n&255,r[10]=(n=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=n/4294967296&255,r[12]=n>>>24&255,r[13]=n>>>16&255,r[14]=n>>>8&255,r[15]=n&255,r}function t4(e){e=unescape(encodeURIComponent(e));for(var n=[],r=0;r<e.length;++r)n.push(e.charCodeAt(r));return n}var r4="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n4="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Fx(e,n,r){function a(i,u,c,f){if(typeof i=="string"&&(i=t4(i)),typeof u=="string"&&(u=Lx(u)),u.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var p=new Uint8Array(16+i.length);if(p.set(u),p.set(i,u.length),p=r(p),p[6]=p[6]&15|n,p[8]=p[8]&63|128,c){f=f||0;for(var h=0;h<16;++h)c[f+h]=p[h];return c}return rp(p)}try{a.name=e}catch{}return a.DNS=r4,a.URL=n4,a}function o4(e){if(typeof e=="string"){var n=unescape(encodeURIComponent(e));e=new Uint8Array(n.length);for(var r=0;r<n.length;++r)e[r]=n.charCodeAt(r)}return a4(i4(s4(e),e.length*8))}function a4(e){for(var n=[],r=e.length*32,a="0123456789abcdef",i=0;i<r;i+=8){var u=e[i>>5]>>>i%32&255,c=parseInt(a.charAt(u>>>4&15)+a.charAt(u&15),16);n.push(c)}return n}function Wx(e){return(e+64>>>9<<4)+14+1}function i4(e,n){e[n>>5]|=128<<n%32,e[Wx(n)-1]=n;for(var r=1732584193,a=-271733879,i=-1732584194,u=271733878,c=0;c<e.length;c+=16){var f=r,p=a,h=i,m=u;r=Vr(r,a,i,u,e[c],7,-680876936),u=Vr(u,r,a,i,e[c+1],12,-389564586),i=Vr(i,u,r,a,e[c+2],17,606105819),a=Vr(a,i,u,r,e[c+3],22,-1044525330),r=Vr(r,a,i,u,e[c+4],7,-176418897),u=Vr(u,r,a,i,e[c+5],12,1200080426),i=Vr(i,u,r,a,e[c+6],17,-1473231341),a=Vr(a,i,u,r,e[c+7],22,-45705983),r=Vr(r,a,i,u,e[c+8],7,1770035416),u=Vr(u,r,a,i,e[c+9],12,-1958414417),i=Vr(i,u,r,a,e[c+10],17,-42063),a=Vr(a,i,u,r,e[c+11],22,-1990404162),r=Vr(r,a,i,u,e[c+12],7,1804603682),u=Vr(u,r,a,i,e[c+13],12,-40341101),i=Vr(i,u,r,a,e[c+14],17,-1502002290),a=Vr(a,i,u,r,e[c+15],22,1236535329),r=Yr(r,a,i,u,e[c+1],5,-165796510),u=Yr(u,r,a,i,e[c+6],9,-1069501632),i=Yr(i,u,r,a,e[c+11],14,643717713),a=Yr(a,i,u,r,e[c],20,-373897302),r=Yr(r,a,i,u,e[c+5],5,-701558691),u=Yr(u,r,a,i,e[c+10],9,38016083),i=Yr(i,u,r,a,e[c+15],14,-660478335),a=Yr(a,i,u,r,e[c+4],20,-405537848),r=Yr(r,a,i,u,e[c+9],5,568446438),u=Yr(u,r,a,i,e[c+14],9,-1019803690),i=Yr(i,u,r,a,e[c+3],14,-187363961),a=Yr(a,i,u,r,e[c+8],20,1163531501),r=Yr(r,a,i,u,e[c+13],5,-1444681467),u=Yr(u,r,a,i,e[c+2],9,-51403784),i=Yr(i,u,r,a,e[c+7],14,1735328473),a=Yr(a,i,u,r,e[c+12],20,-1926607734),r=Kr(r,a,i,u,e[c+5],4,-378558),u=Kr(u,r,a,i,e[c+8],11,-2022574463),i=Kr(i,u,r,a,e[c+11],16,1839030562),a=Kr(a,i,u,r,e[c+14],23,-35309556),r=Kr(r,a,i,u,e[c+1],4,-1530992060),u=Kr(u,r,a,i,e[c+4],11,1272893353),i=Kr(i,u,r,a,e[c+7],16,-155497632),a=Kr(a,i,u,r,e[c+10],23,-1094730640),r=Kr(r,a,i,u,e[c+13],4,681279174),u=Kr(u,r,a,i,e[c],11,-358537222),i=Kr(i,u,r,a,e[c+3],16,-722521979),a=Kr(a,i,u,r,e[c+6],23,76029189),r=Kr(r,a,i,u,e[c+9],4,-640364487),u=Kr(u,r,a,i,e[c+12],11,-421815835),i=Kr(i,u,r,a,e[c+15],16,530742520),a=Kr(a,i,u,r,e[c+2],23,-995338651),r=Xr(r,a,i,u,e[c],6,-198630844),u=Xr(u,r,a,i,e[c+7],10,1126891415),i=Xr(i,u,r,a,e[c+14],15,-1416354905),a=Xr(a,i,u,r,e[c+5],21,-57434055),r=Xr(r,a,i,u,e[c+12],6,1700485571),u=Xr(u,r,a,i,e[c+3],10,-1894986606),i=Xr(i,u,r,a,e[c+10],15,-1051523),a=Xr(a,i,u,r,e[c+1],21,-2054922799),r=Xr(r,a,i,u,e[c+8],6,1873313359),u=Xr(u,r,a,i,e[c+15],10,-30611744),i=Xr(i,u,r,a,e[c+6],15,-1560198380),a=Xr(a,i,u,r,e[c+13],21,1309151649),r=Xr(r,a,i,u,e[c+4],6,-145523070),u=Xr(u,r,a,i,e[c+11],10,-1120210379),i=Xr(i,u,r,a,e[c+2],15,718787259),a=Xr(a,i,u,r,e[c+9],21,-343485551),r=Ja(r,f),a=Ja(a,p),i=Ja(i,h),u=Ja(u,m)}return[r,a,i,u]}function s4(e){if(e.length===0)return[];for(var n=e.length*8,r=new Uint32Array(Wx(n)),a=0;a<n;a+=8)r[a>>5]|=(e[a/8]&255)<<a%32;return r}function Ja(e,n){var r=(e&65535)+(n&65535),a=(e>>16)+(n>>16)+(r>>16);return a<<16|r&65535}function u4(e,n){return e<<n|e>>>32-n}function np(e,n,r,a,i,u){return Ja(u4(Ja(Ja(n,e),Ja(a,u)),i),r)}function Vr(e,n,r,a,i,u,c){return np(n&r|~n&a,e,n,i,u,c)}function Yr(e,n,r,a,i,u,c){return np(n&a|r&~a,e,n,i,u,c)}function Kr(e,n,r,a,i,u,c){return np(n^r^a,e,n,i,u,c)}function Xr(e,n,r,a,i,u,c){return np(r^(n|~a),e,n,i,u,c)}var c4=Fx("v3",48,o4);const l4=c4;function f4(e,n,r){e=e||{};var a=e.random||(e.rng||jx)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){r=r||0;for(var i=0;i<16;++i)n[r+i]=a[i];return n}return rp(a)}function d4(e,n,r,a){switch(e){case 0:return n&r^~n&a;case 1:return n^r^a;case 2:return n&r^n&a^r&a;case 3:return n^r^a}}function p1(e,n){return e<<n|e>>>32-n}function p4(e){var n=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){var a=unescape(encodeURIComponent(e));e=[];for(var i=0;i<a.length;++i)e.push(a.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var u=e.length/4+2,c=Math.ceil(u/16),f=new Array(c),p=0;p<c;++p){for(var h=new Uint32Array(16),m=0;m<16;++m)h[m]=e[p*64+m*4]<<24|e[p*64+m*4+1]<<16|e[p*64+m*4+2]<<8|e[p*64+m*4+3];f[p]=h}f[c-1][14]=(e.length-1)*8/Math.pow(2,32),f[c-1][14]=Math.floor(f[c-1][14]),f[c-1][15]=(e.length-1)*8&4294967295;for(var b=0;b<c;++b){for(var E=new Uint32Array(80),O=0;O<16;++O)E[O]=f[b][O];for(var R=16;R<80;++R)E[R]=p1(E[R-3]^E[R-8]^E[R-14]^E[R-16],1);for(var C=r[0],k=r[1],j=r[2],F=r[3],D=r[4],M=0;M<80;++M){var S=Math.floor(M/20),q=p1(C,5)+d4(S,k,j,F)+D+n[S]+E[M]>>>0;D=F,F=j,j=p1(k,30)>>>0,k=C,C=q}r[0]=r[0]+C>>>0,r[1]=r[1]+k>>>0,r[2]=r[2]+j>>>0,r[3]=r[3]+F>>>0,r[4]=r[4]+D>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var h4=Fx("v5",80,p4);const v4=h4,g4="00000000-0000-0000-0000-000000000000";function m4(e){if(!tp(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}const y4=Object.freeze(Object.defineProperty({__proto__:null,NIL:g4,parse:Lx,stringify:rp,v1:e4,v3:l4,v4:f4,v5:v4,validate:tp,version:m4},Symbol.toStringTag,{value:"Module"})),b4=cA(y4);function rw(e,n){if(!e||!n||!e.length||!n.length)throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=n}rw.prototype.convert=function(e){var n,r,a,i={},u=this.srcAlphabet.length,c=this.dstAlphabet.length,f=e.length,p=typeof e=="string"?"":[];if(!this.isValid(e))throw new Error('Number "'+e+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return e;for(n=0;n<f;n++)i[n]=this.srcAlphabet.indexOf(e[n]);do{for(r=0,a=0,n=0;n<f;n++)r=r*u+i[n],r>=c?(i[a++]=parseInt(r/c,10),r=r%c):a>0&&(i[a++]=0);f=a,p=this.dstAlphabet.slice(r,r+1).concat(p)}while(a!==0);return p};rw.prototype.isValid=function(e){for(var n=0;n<e.length;++n)if(this.srcAlphabet.indexOf(e[n])===-1)return!1;return!0};var _4=rw,w4=_4;function yf(e,n){var r=new w4(e,n);return function(a){return r.convert(a)}}yf.BIN="01";yf.OCT="01234567";yf.DEC="0123456789";yf.HEX="0123456789abcdef";var E4=yf;const{v4:h1}=b4,Mf=E4,v1="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",S4="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",O4={consistentLength:!0};let g1;const MS=(e,n,r)=>{const a=n(e.toLowerCase().replace(/-/g,""));return!r||!r.consistentLength?a:a.padStart(r.shortIdLength,r.paddingChar)},T4=(e,n)=>{const a=n(e).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/);return[a[1],a[2],a[3],a[4],a[5]].join("-")},x4=e=>Math.ceil(Math.log(2**128)/Math.log(e));var _d=(()=>{const e=(n,r)=>{const a=n||v1,i={...O4,...r};if([...new Set(Array.from(a))].length!==a.length)throw new Error("The provided Alphabet has duplicate characters resulting in unreliable results");const u=x4(a.length),c={shortIdLength:u,consistentLength:i.consistentLength,paddingChar:a[0]},f=Mf(Mf.HEX,a),p=Mf(a,Mf.HEX),h=()=>MS(h1(),f,c),m={new:h,generate:h,uuid:h1,fromUUID:b=>MS(b,f,c),toUUID:b=>T4(b,p),alphabet:a,maxLength:u};return Object.freeze(m),m};return e.constants={flickrBase58:v1,cookieBase90:S4},e.uuid=h1,e.generate=()=>(g1||(g1=e(v1).generate),g1()),e})(),gt=(e=>(e.DATACLASS="dataclass",e.METHOD="method",e.ATTRIBUTE="attribute",e.DATASTORE="datastore",e))(gt||{});const C4=[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE,gt.METHOD],wd="guest",nw=[{key:"read",label:"Read",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"create",label:"Create",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"update",label:"Update",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"drop",label:"Delete",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE]},{key:"describe",label:"Describe",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.ATTRIBUTE,gt.METHOD]},{key:"execute",label:"Execute",canApplyTo:[gt.DATASTORE,gt.DATACLASS,gt.METHOD]},{key:"promote",label:"Promote",canApplyTo:[gt.METHOD]}];function Gn(e,...n){return Array.from(new Set([...e,...n]))}function Bx(e){const n={},r=new Map;e.forEach(p=>{const h=p.id||_d.generate();n[h]={...p,id:h,parents:[],includes:Gn(p.includes||[]),resources:[]},r.set(p.privilege,h)}),Object.entries(n).forEach(([p,h])=>{const m=h.includes.map(b=>{const E=r.get(b);return E?(n[E].parents=Gn(n[E].parents,E),E):""}).filter(Boolean);n[p]={...h,includes:m}});const a=Ux(n),i=new Set;function u(p){i.add(p.id),p.includes=p.includes.filter(h=>!i.has(h))}if(a.forEach(u),a.forEach(p=>p.parents=[]),a.forEach(p=>{p.includes.forEach(h=>n[h].parents.push(p.id))}),Object.values(n).find(({privilege:p})=>p===wd))return n;const f=_d.generate();return{[f]:{id:f,privilege:wd,includes:[],parents:[],resources:[]},...n}}function Ux(e){return Object.values(e).sort((n,r)=>n.parents.length-r.parents.length)}function op(e,n){const r=n[e];let a=[];return r&&r.parents.forEach(i=>{a=Gn(a,...op(i,n),i)}),a}function Ed(e,n){const r=n[e];let a=[];return r&&r.includes.forEach(i=>{a=Gn(a,...Ed(i,n),i)}),a}function R4(e,n){const r=n[e];if(!r)return[];const a=[e,...op(e,n),...r.includes];return Object.keys(n).filter(i=>!a.includes(i))}function A4(e,n){return n[e]?Object.keys(n).reduce((a,i)=>i===e?a:{...a,[i]:{...n[i],parents:n[i].parents.filter(u=>u!==e),includes:n[i].includes.filter(u=>u!==e)}},{}):n}function P4(e,n,r){const a=r[e],i=r[n];return!a||!i?r:{...r,[e]:{...r[e],includes:Gn(a.includes,n)},[n]:{...r[n],parents:Gn(i.parents,e)}}}function D4(e,n,r){const a=r[e],i=r[n];return!a||!i?r:{...r,[e]:{...r[e],includes:r[e].includes.filter(u=>u!==n)},[n]:{...r[n],parents:r[n].parents.filter(u=>u!==e)}}}function zx(e,n){vT(e),Object.entries(n).forEach(([,{privilege:a}])=>{if(e.toLowerCase()===a.toLowerCase())throw new Error(`There's already a Privilege with the name ${e}`)});const r=_d.generate();return{[r]:{id:r,privilege:e,includes:[],parents:[],resources:[]},...n}}function I4(e,n,r,a,i){let u=zx(e,i);const c=Object.entries(u).find(([,f])=>f.privilege===e);return c?(u=Vx(c[1].id,n,r,a,u),u):i}function M4(e,n,r){if(!e)throw new Error("Please enter a name");if(!r[n])throw new Error("Invalid privilege");return Object.entries(r).forEach(([,{privilege:a,id:i}])=>{if(e.toLowerCase()===a.toLowerCase()&&n!==i)throw new Error(`There's already a Privilege with the name ${e}`)}),{...r,[n]:{...r[n],privilege:e}}}function k4(e,n){return e.map(r=>Ha(r,n))}function Ha(e,n){return n[e]?n[e]:null}function Hx({applyTo:e,type:n,...r}){return Object.entries(r).reduce((a,[i,u])=>{const c=Bt.find(nw,["key",i]);return!c||!c.canApplyTo.includes(n)||(typeof u=="string"?u.split(","):u).forEach(p=>{a[p]=Gn(a[p]||[],i)}),a},{})}const o_=(e,n=!1)=>["read","create","update","delete"].includes(e.toLowerCase())?`All ${n?"dataclasses and ":""}attributes have the '${e.toLowerCase()}' permission`:e.toLowerCase()==="execute"?`All functions defined ${n?"through the model (DataStore, Dataclasses, Entity selections, Entities) have the execute permission":"on this Dataclass, Entity selection class, Entity class have the execute permission"}`:`All ${n?"dataclasses, ":""}attributes and functions have the '${e.toLowerCase()}' permission`;function ow(e){return{permissions:nw.filter(({canApplyTo:n})=>n.includes(e.type)).map(({key:n,label:r})=>{const a={name:n,from:[]};switch(e.type){case gt.DATASTORE:return{...a,info:o_(r,!0)};case gt.DATACLASS:return{...a,info:o_(r)};default:return a}}),resource:e.applyTo,type:e.type}}function Gx(e,n){const r=qx(n),a={};return e.filter(({type:i})=>C4.includes(i)).forEach(i=>{const u=Hx(i);Object.entries(u).forEach(([c,f])=>{var m;const p=(m=r[c])==null?void 0:m.id;if(!p)return;a[p]=a[p]||{...n[p]};let h=Bt.find(a[p].resources,{resource:i.applyTo,type:i.type});h||(h=ow(i),a[p].resources.push(h)),h.permissions=h.permissions.map(b=>({...b,checked:b.checked||f.includes(b.name)}))})}),{...n,...a}}function qx(e){return Object.values(e).reduce((n,r)=>({...n,[r.privilege]:r}),{})}function ap(e){var r;const n=Bx(e.privileges||[]);return{privileges:Gx(((r=e.permissions)==null?void 0:r.allowed)||[],n),roles:(e.roles||[]).map(({id:a=_d.generate(),role:i,privileges:u=[]})=>({id:a,role:i,privileges:Gn(u).map(c=>{var f;return(f=Object.values(n).find(({privilege:p})=>p===c))==null?void 0:f.id}).filter(Boolean)})).reduce((a,i)=>({...a,[i.id]:{...i}}),{})}}function aw(e){const n=Object.values(e.privileges).filter(({includes:a})=>a.length===0).map(({id:a})=>a),r=[...n,...n.map(a=>op(a,e.privileges).reverse())].flat().filter((a,i,u)=>u.indexOf(a)===i).map(a=>e.privileges[a]);return{permissions:{allowed:Object.values(e.privileges).reduce((a,i)=>(i.resources.forEach(({permissions:u,resource:c,type:f})=>{let p=Bt.find(a,{applyTo:c,type:f});p||(p={applyTo:c,type:f},a.push(p)),u.forEach(({name:h,checked:m})=>{m&&p&&(p[h]=p[h]||[],p[h].push(i.privilege))})}),a),[])},privileges:r.filter(({privilege:a})=>a!==wd).map(({id:a,includes:i,privilege:u})=>({id:a,privilege:u,includes:i.map(c=>e.privileges[c].privilege)})),roles:Object.values(e.roles).map(a=>({...a,privileges:a.privileges.map(i=>{var u;return(u=e.privileges[i])==null?void 0:u.privilege}).filter(Boolean)}))}}function $4(e,n){const r=n[e],a={children:[],links:[],parents:[],selected:e};if(!r)return a;function i(f,p,h=[]){const m=f.reduce((b,E)=>[...b,...n[E][p]],[]);return m.length===0?h:(h.push(m),i(m,p,h))}function u(f){const p=[],h=[];for(let m=f.length-1;m>=0;m-=1){const b=f[m].filter(E=>p.includes(E)?!1:(p.push(E),!0));b.length>0&&h.unshift(Gn(b))}return h}function c(f,p){const h=[];return f.reduce((m,b)=>(b.forEach(E=>{n[E][p==="parents"?"includes":"parents"].forEach(R=>{h.includes(R)&&m.push(p==="parents"?{source:E,target:R}:{source:R,target:E})}),h.push(E)}),m),[])}return a.children=i([e],"includes"),a.children=u(a.children),a.parents=i([e],"parents"),a.parents=u(a.parents),a.links=[...c([[e],...a.parents],"parents"),...c([[e],...a.children],"includes")],a}function N4(e,n,r){const a=Ha(e,r);if(!a||Bt.find(a.resources,{resource:n.applyTo,type:n.type}))return r;const i={...a,resources:[...a.resources,ow(n)]};return{...r,[e]:i}}function j4(e,n,r){const a=Ha(e,r);if(!a)return r;const i={...a,resources:a.resources.filter(({resource:u,type:c})=>u!==n.applyTo||c!==n.type)};return{...r,[e]:i}}function L4(e,n){const r=Ha(e,n);if(!r)return n;const a={...r,resources:r.resources.filter(i=>i.permissions.some(u=>u.from.length)).map(i=>({...i,permissions:i.permissions.map(u=>({...u,checked:!1}))}))};return{...n,[e]:a}}function Vx(e,n,r,a,i){const u=Ha(e,i);if(!u)return i;const f=Bt.find(u.resources,{type:r,resource:n})?{...u,resources:u.resources.map(p=>p.type===r&&p.resource===n?{...p,permissions:p.permissions.map(h=>h.name===a?{...h,checked:!h.checked,from:[]}:h)}:p)}:{...u,resources:[...u.resources,{type:r,resource:n,permissions:nw.filter(p=>p.canApplyTo.includes(r)).map(p=>({from:[],name:p.key,checked:p.key===a,info:o_(p.key,r===gt.DATASTORE)}))}]};return{...i,[e]:f}}function F4(e,n,r,a){const i=Ha(e,a);if(!i)return a;const c=Bt.find(i.resources,{type:n.type,resource:n.resource})?{...i,resources:i.resources.map(f=>f.type===n.type&&f.resource===n.resource?{...f,permissions:n.permissions.map(p=>p.name===r.name?{...p,checked:!p.checked,from:[]}:p)}:f)}:{...i,resources:[...i.resources,{...n,permissions:n.permissions.map(f=>({...f,checked:r.name===f.name,from:[]}))}]};return{...a,[e]:c}}function W4(e,n){var p;const r=Yx(e,n)||[],a=((p=Ha(e,n))==null?void 0:p.resources)||[],c=([...r,...a].filter(({type:h})=>h===gt.METHOD)||[]).map(({resource:h})=>h);return Object.entries(n).reduce((h,[m,{resources:b}])=>(b.filter(({resource:E,type:O})=>O===gt.METHOD&&c.includes(E)).forEach(({permissions:E,resource:O})=>{var C;((C=E.find(({name:k})=>k==="promote"))==null?void 0:C.checked)&&(h[O]=Gn(h[O]||[],m))}),h),{})}function Yx(e,n){var c;const r=Ha(e,n);if(!r)return[];const a=(c=Object.values(n).find(f=>f.privilege===wd))==null?void 0:c.id;return(a&&a!==e?Gn(Ed(e,n),a):Ed(e,n)).reduce((f,p)=>(n[p].resources.forEach(m=>{if(m.permissions.filter(({checked:O})=>O).length===0)return;const E=Bt.find(f,{type:m.type,resource:m.resource});if(!E){f.push({...m,permissions:m.permissions.map(O=>({...O,from:O.checked?[p]:[],checked:!1}))});return}E.permissions=E.permissions.map((O,R)=>{let{from:C=[]}=O;return m.permissions[R].checked&&!C.includes(p)&&(C=[...C,p]),{...O,from:C,checked:O.checked}})}),f),Bt.clone(r.resources.map(f=>({...f,permissions:f.permissions.map(({checked:p,...h})=>({...h,checked:!!p}))}))))}const B4=e=>e.reduce((n,r)=>({...n,[r.id]:{...r}}),{}),U4=(e,n)=>n[e]?Object.values(n).reduce((r,a)=>e===a.id||a.role===""?r:{...r,[a.id]:a},{}):n,z4=(e,n,r)=>r[e]?Object.values(r).reduce((a,i)=>e===i.id?{...a,[i.id]:{...i,name:n}}:{...a,[i.id]:i},{}):r,H4=(e,n)=>{const r={id:e,role:"",privileges:[]};return{...n,[r.id]:r}},G4=(e,n)=>{if(vT(e.role),Object.values(n).find(a=>a.role===e.role))throw new Error(`a role with the name ${e.role} already exists`);return Object.values(n).reduce((a,i)=>e.id===i.id?{...a,[e.id]:e}:{...a,[i.id]:i},{})},q4={list:[]},kS=(e,n)=>e.list.filter(r=>r.id!==n),Kx=qn({name:"modals",initialState:q4,reducers:{createModal:(e,n)=>{e.list.push(n.payload)},editModal:(e,n)=>{const{id:r,...a}=n.payload,i=e.list.find(QM(r));i&&Object.assign(i,{...a})},removeModal:(e,n)=>{const r=n.payload;e.list=kS(e,r)},closeModal:(e,n)=>{const{id:r,reason:a}=n.payload;if(a){const i=e.list.find(u=>u.id===r);i&&(i.closeReason=a,i.isOpen=!1)}else e.list=kS(e,r)}}}),{createModal:Xx,removeModal:Jx,closeModal:V4,editModal:Y4}=Kx.actions;var Zx={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$S=ie.createContext&&ie.createContext(Zx),ei=globalThis&&globalThis.__assign||function(){return ei=Object.assign||function(e){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ei.apply(this,arguments)},K4=globalThis&&globalThis.__rest||function(e,n){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(r[a[i]]=e[a[i]]);return r};function Qx(e){return e&&e.map(function(n,r){return ie.createElement(n.tag,ei({key:r},n.attr),Qx(n.child))})}function ip(e){return function(n){return ie.createElement(X4,ei({attr:ei({},e.attr)},n),Qx(e.child))}}function X4(e){var n=function(r){var a=e.attr,i=e.size,u=e.title,c=K4(e,["attr","size","title"]),f=i||r.size||"1em",p;return r.className&&(p=r.className),e.className&&(p=(p?p+" ":"")+e.className),ie.createElement("svg",ei({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,a,c,{className:p,style:ei(ei({color:e.color||r.color},r.style),e.style),height:f,width:f,xmlns:"http://www.w3.org/2000/svg"}),u&&ie.createElement("title",null,u),e.children)};return $S!==void 0?ie.createElement($S.Consumer,null,function(r){return n(r)}):n(Zx)}function J4(e){return ip({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"}}]})(e)}function Z4(e){return ip({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"}}]})(e)}function Q4(e){return ip({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11.953 2C6.465 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.493 2 11.953 2zM12 20c-4.411 0-8-3.589-8-8s3.567-8 7.953-8C16.391 4 20 7.589 20 12s-3.589 8-8 8z"}},{tag:"path",attr:{d:"M11 7h2v7h-2zm0 8h2v2h-2z"}}]})(e)}function e6(e){return ip({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zM480 416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416zm32 352a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"}}]})(e)}const t6={FaSave:J4,AiFillWarning:e6,BiErrorCircle:Q4,BsFillInfoCircleFill:Z4};var Hn=(e=>(e.ALERT="alert",e.CONFIRM="confirm",e))(Hn||{}),Ga=(e=>(e.PRIMARY="primary",e.WARNING="warning",e.DANGER="danger",e))(Ga||{}),iw=(e=>(e.CONFIRMED="confirmed",e.CANCELED="canceled",e))(iw||{});const Eo=xe("modals/open",async(e,{dispatch:n})=>{const{type:r=Hn.ALERT}=e,a=y_();switch(n(Xx({id:a,type:r,isOpen:!0,...e})),r){case Hn.CONFIRM:return new Promise(i=>{const u=Ds.subscribe(()=>{var p;const{modals:c}=Ds.getState(),f=c.list.find(h=>h.id===a);if(f&&!f.isOpen){const h=f.closeReason===iw.CONFIRMED,m=Bt.entries((p=f.views)==null?void 0:p.toggles).reduce((b,E)=>({...b,[E[0]]:E[1].value}),{});n(Jx(a)),u(),i({confirmed:h,options:m})}})});default:return{}}}),eC=()=>hk({name:Ur}),tC="Roles & Privileges",Sd=xe("roles/fetchRoles",async(e,{dispatch:n,rejectWithValue:r})=>{var u;let a;try{a=await eC()}catch(c){if(!Array.isArray((u=c==null?void 0:c.data)==null?void 0:u.__ERROR))return r("Error while loading the roles");a={name:Ur,date:new Date().toISOString(),content:{permissions:{allowed:[]},privileges:[],roles:[]}}}const i={name:tC,type:le.ROLES,date:a.date,view:{panel:{isOpen:!1,type:"",current:""}},path:Ur,flags:{},content:{}};return n(wn(i)),{...a,content:ap(a.content)}}),rC=xe("roles/fetchRolesChanges",async(e,{getState:n})=>{const{tabs:r}=n().root;if(r.find(i=>i.path===Ur)){const{date:i}=n().roles;if(i&&await sw(i))return{old:!0}}return{}}),sw=async e=>{if(!e)return!1;try{const n=await eC();if(n.date){const r=new Date(e),a=new Date(n.date);if(r>a)return!0}}catch(n){if(!Array.isArray(n==null?void 0:n.data.__ERROR))throw n}return!1},a_=xe("roles/saveRoles",async(e,{getState:n,rejectWithValue:r,dispatch:a})=>{try{const{flags:i,date:u}=n().roles;if(i.old||await sw(u)){const{confirmed:p}=await a(Eo({title:tC,message:"New content has been found on the server. Are you sure you want to continue?",type:Hn.CONFIRM,icon:"FaSave"})).unwrap();if(!p)return r({old:!0})}return await Gd({name:Ur,content:aw(e)})}catch{return r("Error while loading the roles")}}),r6=nu().roles,{roles:n6={},privileges:o6={},flags:a6={touched:!1},date:i6,selectedTab:s6="roles"}=r6||{},u6={flags:a6,roles:n6,privileges:o6,date:i6,selectedTab:s6},nC=qn({name:"roles",initialState:u6,reducers:{updatePrivileges:(e,n)=>{e.privileges=n.payload,e.flags.touched=!0},updateRoles:(e,n)=>{e.roles=n.payload,e.flags.touched=!0},updateRolesAndPrivileges:(e,n)=>{e.roles=n.payload.roles,e.privileges=n.payload.privileges},toggleTab:(e,n)=>{e.selectedTab=n.payload},setRolesContent(e,n){const{content:r,date:a}=n.payload,i=ap(r);return{...e,...i,date:a}}},extraReducers(e){e.addCase(Sd.fulfilled,(n,r)=>{const{content:a,date:i}=r.payload;n={...n,...a,date:i}}).addCase(Sd.rejected,n=>({...n,roles:{},privileges:{},flags:{touched:!1},date:void 0})).addCase(a_.fulfilled,(n,r)=>({...n,flags:{...n.flags,touched:!1,old:!1},date:r.payload.date})).addCase(a_.rejected,(n,r)=>FT.isString(r.payload)?n:{...n,flags:{...n.flags,...r.payload}}).addCase(rC.fulfilled,(n,r)=>({...n,flags:{...n.flags,...r.payload}})).addCase(Ys.fulfilled,(n,r)=>{!r.payload||r.payload.path!==Ur||(n.flags.touched=!1,n.flags.old=!1)}).addCase(hw.fulfilled,(n,r)=>{r.meta.arg!==Ur||!r.payload||(n.flags.touched=!1,n.flags.old=!1)})}}),{updatePrivileges:oC,updateRoles:aC,setRolesContent:uw,toggleTab:c6,updateRolesAndPrivileges:cw}=nC.actions,l6=nC.reducer,oi="qodlyApp.json",lw=xe("settings/fetch",async()=>await ni({verb:Zt.GET_INFO,path:oi,content:!0,as:"json"})),iC=xe("settings/app",uk),f6=IT(),NS={session:{"studio.tips":!0,"studio.notifications":!0,"webforms.tooltip.behavior":tw.SHOW_AFTER_TIMEOUT,"webforms.tooltip.timeout":3e3,"webforms.renderer.showPopOver":!0,"welcometour.active":!0,"webforms.properties.advanced-mode":!1,"monaco.zoom":0},project:{"webforms.renderer.indexPage":"","webforms.display-mode":"neutral"},server:{projectOpened:!1,remoteDebuggerMode:W_.DISABLED,baseUrl:"",qodly:!0,urls:{renderer:"/$lib/renderer/",debugger:"",lsp:""},isRestActive:!0}},d6={...NS,session:{...NS.session,...f6},welcometour:{}},sC=qn({name:"settings",initialState:d6,reducers:{setSetting(e,n){const{path:r,settingsKey:a,value:i}=n.payload;e[r][a]=i},setSettings(e,n){const{path:r,value:a}=n.payload;e[r]={...e[r],...a}},setSettingsAsText(e,n){const{path:r,settings:a}=n.payload;e[r]=a}},extraReducers(e){e.addCase(lw.fulfilled,(n,r)=>{n.project={...n.project,...r.payload.content}}),e.addCase(iC.fulfilled,(n,r)=>{n.server=r.payload,n.server.qodly&&(n.project["webforms.display-mode"]="airy")})}}),{setSetting:uC,setSettings:sp,setSettingsAsText:p6}=sC.actions,h6=sC.reducer,i_=e=>{const n=["folder","file"];return e.sort((r,a)=>r.type===a.type?r.name.localeCompare(a.name):n.indexOf(r.type)-n.indexOf(a.type))},ct=(e,n)=>e.reduce((r,a)=>a.path===n.path&&a.type===n.type?[...r,n]:a.children?[...r,{...a,children:i_(ct(a.children,n))}]:[...r,a],[]),Tr=(e,n)=>e.reduce((r,a)=>r||(a.path===n?a:a.children?Tr(a.children,n):null),null),v6=[{name:Wt.WEBFORMS,type:le.FOLDER,children:[],path:Wt.WEBFORMS,error:null,flags:{expanded:!1,loading:!1,cached:!1},tipKey:"editors:webform:explorer:webforms",config:{},isRoot:!0},{name:Wt.METHODS,type:le.FOLDER,children:[],path:Wt.METHODS,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:Wt.CLASSES,type:le.FOLDER,children:[],path:Wt.CLASSES,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:Wt.SHARED,type:le.FOLDER,children:[],path:Wt.SHARED,error:null,flags:{expanded:!1,loading:!1,cached:!1},config:{},isRoot:!0},{name:"Debugger",type:le.FOLDER,children:[],path:"Debugger",error:null,flags:{expanded:!1,cached:!0},config:{},isRoot:!0},{name:"Roles And Privileges",type:le.FILE,ext:"json",path:"roles",error:null,flags:{},config:{editor:{key:"editors:roles"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]},isRoot:!0},{name:"Model",type:le.MODEL,ext:"4DModel",path:"model",error:null,flags:{},config:{editor:{key:"editors:model"},supportedEditors:[{key:"editors:code",config:{language:"json",theme:"vs-dark"}}]}},{name:"Settings",type:le.FILE,ext:"json",path:"qodlyApp",error:null,flags:{},config:{editor:{key:"editors:settings"}},isRoot:!0}],cC=qn({name:"explorer",initialState:v6,reducers:{toggleExpandFolder:(e,n)=>(e=ct(e,{...n.payload,flags:{...n.payload.flags,expanded:!n.payload.flags.expanded}}),e),expandFolder:(e,n)=>(e=ct(e,{...n.payload,flags:{...n.payload.flags,expanded:!0}}),e),openAddFileInput:(e,n)=>ct(e,{...n.payload,flags:{...n.payload.flags,adding:!0}}),addNewFile:(e,n)=>{const{parent:r,child:a}=n.payload;return ct(e,{...r,children:[a,...r.children||[]]})},removeFile:(e,n)=>{const{parent:r,child:a}=n.payload;return ct(e,{...r,children:r.children.filter(i=>i.path!==a.path)})},refreshFile:(e,n)=>{const{parent:r,child:a}=n.payload,i=(r.children||[]).filter(u=>u.path!==a.path&&!a.error);return ct(e,{...r,children:[a,...i]})},setFolderChildren:(e,n)=>{const r=Tr(e,n.payload.parentPath);return r?ct(e,{...r,children:n.payload.children}):e}},extraReducers:e=>{e.addCase(Vs.pending,(n,r)=>{const{file:a,newname:i}=r.meta.arg,u=Tr(n,a.path);if(!u)return n;const c=a.path.split("/");c.pop();const f=`${c.join("/")}/${a.name}.${a.ext}`,p=`${c.join("/")}/${i}.${a.ext}`;switch(a.ext){case"4dm":case"4qs":Xa.next({action:ka.WILL_RENAME,payload:{oldPath:f,newPath:p}});break}return ct(n,{...u,flags:{...u.flags,loading:!0}})}),e.addCase(Vs.fulfilled,(n,r)=>{const{meta:{arg:{file:a}},payload:i}=r,u=Tr(n,a.path);if(!u)return n;switch(i.old.ext){case"4dm":case"4qs":Xa.next({action:ka.DID_RENAME,payload:{oldPath:i.old.path,newPath:i.new.path}});break}return ct(n,{...u,flags:{...u.flags,loading:!1}})}),e.addCase(Vs.rejected,(n,r)=>{const{file:a}=r.meta.arg,i=Tr(n,a.path);return i?ct(n,{...i,flags:{...i.flags,loading:!1}}):n}),e.addCase(Po.pending,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,flags:{...i.flags,loading:!0}}):n}),e.addCase(Po.fulfilled,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,children:i_(r.payload),flags:{...i.flags,loading:!1,cached:!0,expanded:!0},error:null}):n}),e.addCase(Po.rejected,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,error:{message:r.payload},flags:{...i.flags,loading:!1,cached:!0,expanded:!0}}):n}),e.addCase(zl.pending,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,flags:{...i.flags,loading:!0}}):n}),e.addCase(zl.fulfilled,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,children:i_(r.payload),flags:{...i.flags,loading:!1,cached:!0,expanded:!1},error:null}):n}),e.addCase(zl.rejected,(n,r)=>{const a=r.meta.arg,i=Tr(n,a);return i?ct(n,{...i,error:{message:r.payload},flags:{...i.flags,loading:!1,cached:!0,expanded:!1}}):n}),e.addCase(qf.pending,(n,r)=>{const{fileName:a,parentNode:i,path:u,type:c}=r.meta.arg;return ct(n,{...i,children:[{name:a,path:`${u}/${a}`,type:c,error:null,flags:{loading:!0},config:{}},...i.children]})}),e.addCase(qf.fulfilled,(n,r)=>{const{path:a,fileName:i,type:u}=r.meta.arg,c=Ws(u),{editor:f,supportedEditors:p}=bo(`${a}${c?`.${c.toLowerCase()}`:""}`);return ct(n,{name:i,path:`${a}/${i}`,type:u,error:null,flags:{loading:!1},config:{editor:f,supportedEditors:p}})}),e.addCase(qf.rejected,(n,r)=>{const{path:a,fileName:i,type:u}=r.meta.arg;return ct(n,{name:i,path:`${a}/${i}`,type:u,error:{message:r.payload},flags:{loading:!1},config:{}})}),e.addCase(Vf.pending,(n,r)=>{const{node:a,parentNode:i}=r.meta.arg;return ct(n,{...i,children:[{name:`${a.name}_copy`,path:`${a.path}/${a.name}_copy`,type:a.type,error:null,flags:{loading:!0},permissions:{canRename:!0,canDelete:!0}},...i.children]})}),e.addCase(Vf.fulfilled,(n,r)=>{const{node:a}=r.payload,{node:{path:i,ext:u}}=r.meta.arg,{editor:c,supportedEditors:f}=bo(`${i}${u?`.${u.toLowerCase()}`:""}`);return ct(n,{name:`${a.name}`,path:`${i}/${a.name}`,type:a.type,error:null,flags:{loading:!1},config:{editor:c,supportedEditors:f}})}),e.addCase(Vf.rejected,(n,r)=>{const a=r.payload,{node:i}=r.meta.arg;return ct(n,{name:`${i.name}_copy`,path:`${i.path}/${i.name}_copy`,type:i.type,error:{message:a},flags:{loading:!1},config:{}})}),e.addCase(Gl.pending,(n,r)=>{}),e.addCase(Gl.fulfilled,(n,r)=>{var b;const{draggedNode:a,newLocation:i}=r.meta.arg,u=dx(a.path),c=Tr(n,u),f=Tr(n,i.path),p=(b=c==null?void 0:c.children)==null?void 0:b.filter(E=>E.path!==a.path),h=i.path.split("/").length,m=a.path.split("/").length;return h>=m?(n=ct(n,{...c,children:p}),n=ct(n,{...f,children:[{...a,path:`${f.path}/${a.name}`},...f!=null&&f.children?f==null?void 0:f.children:[]],flags:{...f.flags,expanded:!0}})):(n=ct(n,{...f,children:[{...a,path:`${f.path}/${a.name}`},...f!=null&&f.children?f==null?void 0:f.children:[]],flags:{...f.flags,expanded:!0}}),n=ct(n,{...c,children:p})),n}),e.addCase(Gl.rejected,(n,r)=>{Ao.next({message:"Error moving file",kind:"danger"})}),e.addCase(qs.pending,(n,r)=>{var C;const{fileName:a,parentNode:i,path:u,type:c,qodly:f}=r.meta.arg,p=Ws(c,f),h=`${u}/${a}${p?`.${p.toLowerCase()}`:""}`,{editor:m,supportedEditors:b}=bo(h);switch(c){case le.CLASS:case le.METHOD:Xa.next({action:ka.WILL_CREATE,payload:{filePath:h}});break}const E=(C=i.children)==null?void 0:C.filter(k=>k.path!==`${u}/${a}`),O=[{name:a,path:`${u}/${a}`,type:le.FILE,error:null,flags:{loading:!0},config:{editor:m,supportedEditors:b},ext:p,date:new Date().toISOString()},...E],R=ct(n,{...i,children:O});return FT.merge(n,R)}),e.addCase(qs.fulfilled,(n,r)=>{const{fileName:a,path:i,type:u,qodly:c}=r.meta.arg,f=Ws(u,c),p=`${i}/${a}${f?`.${f.toLowerCase()}`:""}`,{editor:h,supportedEditors:m}=bo(p),b=ct(n,{name:a,path:`${i}/${a}`,type:le.FILE,error:null,flags:{},config:{editor:h,supportedEditors:m},ext:f,date:new Date().toISOString()});switch(u){case le.CLASS:case le.METHOD:Xa.next({action:ka.DID_CREATE,payload:{filePath:p}});break}return n=b,n}),e.addCase(qs.rejected,(n,r)=>{const{fileName:a,path:i,type:u}=r.meta.arg,c=Ws(u),{editor:f,supportedEditors:p}=bo(`${i}${c?`.${c.toLowerCase()}`:""}`);return n=ct(n,{name:a,path:`${i}/${a}`,type:le.FILE,error:{message:"Failed creating file"},flags:{},config:{editor:f,supportedEditors:p},ext:c,date:new Date().toISOString()}),n}),e.addMatcher(iO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!0}})),n}),e.addMatcher(uO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!1}})),n}),e.addMatcher(sO(Hl),(n,r)=>{const a=Tr(n,r.meta.arg.file.path.split(".")[0]);return a&&(n=ct(n,{...a,flags:{...a.flags,loading:!1}})),Ao.next({message:"Failed to open file, try again",kind:"danger"}),n})}}),{toggleExpandFolder:g6,expandFolder:m6,openAddFileInput:y6,addNewFile:lC,refreshFile:b6,removeFile:s_,setFolderChildren:_6}=cC.actions;function fC(e){switch(e){case le.WEBFORMS:return Nx;case le.METHODS:return`//%attributes = {}
|
|
270
270
|
`;default:return""}}function dC(e,n,r){switch(n){case le.MOBILEFORM:return`${e}.MForm`;case le.WEBFORM:return`${e}.WebForm`;case le.METHOD:case le.CLASS:return`${e}.${r?"4qs":"4dm"}`;default:return e}}function w6(e){switch(e){case Wt.WEBFORMS:return le.WEBFORMS;case Wt.METHODS:return le.METHODS;case Wt.CLASSES:return le.CLASSES;case"Mobile":return le.MOBILE;default:return e}}function pC(e){switch(e){case le.WEBFORMS:return le.WEBFORM;case le.CLASSES:return le.CLASS;case le.METHODS:return le.METHOD;case le.FOLDER:return le.FOLDER;case le.MOBILE:return le.MOBILEFORM;default:return e}}const E6=xe("files/tryEditMethod",async({method:e},{dispatch:n})=>{const r=e.filePath.split("/"),[a]=r[1].split("."),{editor:i}=bo(e.filePath);return await n(fw({file:{name:a,path:e.filePath,date:new Date().toISOString(),type:le.CLASS,editor:i},line:e.startingLine+1})).unwrap()}),u_=xe("explorer/createModelFiles",async(e,{dispatch:n,getState:r})=>{var b;const a=r(),i=Wt.CLASSES,u=a.settings.server.qodly,c=Tr(a.explorer,i);if(!c)return;await n(Po(i));const p=((b=r().explorer.find(E=>E.name===i))==null?void 0:b.children)||[];let h=[{content:"",name:""}];const m=E=>{switch(E){case"dataclass":return{name:e.type==="dataclass"?e.className:"DataStore",content:u?`extends DataClass
|
|
271
271
|
`:`Class extends DataClass
|
|
272
272
|
`};case"collection":return{name:e.type==="dataclass"?e.collectionName:"DataStore",content:u?`extends EntitySelection
|
|
@@ -275,7 +275,7 @@ globstar while`,n,b,r,E,O),this.matchOne(n.slice(b),r.slice(E),a))return this.de
|
|
|
275
275
|
`:`Class extends Entity
|
|
276
276
|
`};case"model":return{name:"DataStore",content:u?`extends DataStoreImplementation
|
|
277
277
|
`:`Class extends DataStoreImplementation
|
|
278
|
-
`}}};e.type==="dataclass"&&!e.toCreate?h=[{...m("dataclass")},{...m("collection")},{...m("entity")}]:e.type==="dataclass"&&e.toCreate?h=[{...m(e.toCreate)}]:h=[{...m("model")}],h=h.filter(E=>!p.find(({name:O,ext:R})=>O===E.name&&R===(u?"4qs":"4dm"))),await Promise.all(h.map(async({name:E,content:O})=>{await n(qs({type:le.CLASS,path:i,fileName:E,parentNode:c,content:O,qodly:a.settings.server.qodly}))})),await n(Po(i))}),Po=xe("explorer/fetchFolderContent",async(e,{rejectWithValue:n})=>{try{return(await ni({verb:Zt.GET_INFO,path:e})).map(a=>{const i=`${e}/${a.name}`,{editor:u,supportedEditors:c}=bo(`${i}${a.ext?`.${a.ext.toLowerCase()}`:""}`);return{name:a.name,size:a.size,type:a.type,date:`${a.date}`,flags:{},error:null,path:i,ext:a.ext,config:a.type==="folder"?{}:{editor:u,supportedEditors:c}}})}catch{return n("Failed loading file content please Reload")}},{getPendingMeta:()=>{}}),zl=xe("explorer/fetchFolderContentWithoutExpanding",async(e,{rejectWithValue:n})=>{try{return(await ni({verb:Zt.GET_INFO,path:e})).map(a=>{const i=`${e}/${a.name}`,{editor:u,supportedEditors:c}=bo(`${i}${a.ext?`.${a.ext.toLowerCase()}`:""}`);return{name:a.name,size:a.size,type:a.type,date:`${a.date}`,flags:{},error:null,path:i,ext:a.ext,config:a.type==="folder"?{}:{editor:u,supportedEditors:c}}})}catch{return n("Failed loading file content please Reload")}},{getPendingMeta:()=>{}});function S6(e){const n=e.split(".");return n.pop(),{name:n.join("."),ext:e.split(".")[e.split(".").length-1]}}const O6=xe("explorer/uploadFile",async e=>{const n=e.type.includes("image/")?"$rawPict=true":"$binary=true";try{const r=await fetch(`/rest/$upload?${n}`,{method:"POST",headers:{"Content-Type":e.type},body:e});return{status:r.status,data:await r.json()}}catch{return{status:500,data:null}}}),T6=xe("explorer/uploadFile",async({file:e,path:n,parentNode:r},{dispatch:a})=>{const{editor:i,supportedEditors:u}=bo(n),{name:c,ext:f}=S6(e.name);a(lC({parent:r,child:{name:c,path:`${n}/${e.name}?t=${Date.now()}`,type:e.type,error:null,flags:{loading:!0},config:{editor:i,supportedEditors:u},ext:f}}));try{const p=await fetch(`/rest/$upload?$sharedFolder=true&$filename=${e.name}&$path=${n}`,{method:"POST",headers:{"Content-Type":e.type},body:e});return p.status>=300?(a(s_({parent:r,child:{name:c,path:`${n}/${e.name}`,type:e.type,error:{message:"error uploading file"},flags:{},config:{editor:i,supportedEditors:u},ext:f}})),p.status!==413&&Ao.next({message:"error uploading file",kind:"danger"})):await a(Po(r.path)),{status:p.status,fileName:e.name}}catch{return a(s_({parent:r,child:{name:c,path:`${n}/${e.name}`,type:e.type,error:{message:"error uploading file"},flags:{},config:{editor:i,supportedEditors:u},ext:f}})),Ao.next({message:"error uploading file",kind:"danger"}),{status:500,fileName:e.name}}}),qs=xe("explorer/createNewFile",async({fileName:e,type:n,path:r,parentNode:a,content:i},{dispatch:u,rejectWithValue:c,getState:f})=>{const{qodly:p}=f().settings.server;try{const h=await Gd({name:dC(e,n,p),content:i||fC(n),path:r,asText:[le.CLASS,le.METHOD].includes(n)});return a.error&&(a.flags.expanded?await u(Po(a.path)):await u(zl(a.path))),{qodly:p,file:h,parentNode:a}}catch{return c("failed to create folder")}});function hC(e,n){const{qodly:r=!0,withExtension:a=!0}=n||{},i=Ws(e.type,r);let u="";switch(e.type){case le.WEBFORM:u=`${Wt.WEBFORMS}/${e.name}`;break;case le.METHOD:u=`${Wt.METHODS}/${e.name}`;break;case le.CLASS:u=`${Wt.CLASSES}/${e.name}`;break;default:return""}return`${u}${a?`.${i}`:""}`}const x6=xe("explorer/createNewFileAndOpen",async(e,{dispatch:n,getState:r})=>{const a=await n(qs(e)).unwrap(),{qodly:i}=r().settings.server;if(a){const{file:u}=a,c=hC(u,{withExtension:!1,qodly:i}),{editor:f}=bo(c);await n(Hl({file:{name:e.fileName,type:u.type,path:c,editor:f,date:new Date().toISOString()}}))}}),qf=xe("explorer/createNewNode",async({fileName:e,path:n,parentNode:r},{rejectWithValue:a})=>{try{return{file:await yk({verb:Zt.CREATE_FOLDER,path:`${n}/${e}`,recursive:!0}),parentNode:r}}catch{return Ao.next({message:"failed to create folder",kind:"danger"}),a("failed to create folder")}}),up=async e=>{try{const n=e.path.split(".").at(-1),r=await ni({verb:Zt.GET_INFO,path:e.path,content:!0,as:kT(n)?"json":"text"}),a={editor:e.editor},i=mT(e.path);i===le.METHOD&&(a.attributes=z_(r.content),r.content=wT(r.content,{}));const{content:u,date:c,ext:f}=r;return{date:c,view:{panel:{isOpen:!1,type:"",current:""}},flags:{enabled:["WebForm","MForm"].includes(f)},extra:a,name:e.name,path:e.path,type:i,initialContent:u,content:u}}catch(n){const{data:r}=n;if(r.__ERROR.find(a=>a.errCode===TT.FILE_NOT_FOUND))switch(e.path){case Ur:{const a={permissions:{allowed:[]},privileges:[],roles:[]};return{date:new Date().toISOString(),flags:{},extra:{editor:{key:"editors:roles"}},name:"Roles & Privileges",path:e.path,type:le.ROLES,initialContent:a,content:a}}case oi:{const a={};return{date:new Date().toISOString(),flags:{},extra:{editor:{key:"editors:settings"}},name:"Settings",path:e.path,type:le.SETTINGS,initialContent:a,content:a}}}throw n}},Hl=xe("explorer/openFile",async({file:e,inactive:n},{getState:r,dispatch:a})=>{const{root:{tabs:i},roles:u}=r(),c=i.find(({path:h})=>e.path===h);if(c){const h={...c,extra:{...c==null?void 0:c.extra,editor:e.editor}};return a(wn(h)),h}if(e.path.startsWith("Debugger")){const h=r().debugger.sessions.find(m=>`Debugger/${m.threadId}`===e.path);if(h){const{source:{content:m},source:b}=h.currentStackFrame,E={name:e.name,type:le.DEBUGGER,date:new Date().toISOString(),path:e.path,content:m,view:{panel:{isOpen:!1,type:"",current:""}},initialContent:m,flags:{},extra:{source:b,editor:e.editor}};return a(wn(E)),E}}const f=await up(e);return e.path===Ur&&!u.flags.touched?a(uw({content:f.content,date:f.date})):e.path===oi&&a(sp({path:"project",value:f.content})),a((n?KC:wn)(f)),f}),fw=xe("explorer/openFileAtLine",async({file:e},{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.find(({path:c})=>e.path===c);if(i){const c={...i,extra:{...i==null?void 0:i.extra,editor:e.editor}};return r(wn(c)),c}const u=await up(e);return r(wn(u)),u}),vC=xe("explorer/injectContentAtLine",async(e,{getState:n,dispatch:r,rejectWithValue:a})=>{const i=n();e.path.split("/").pop();const c=Tr(i.explorer,e.path);if(!c)return a(`Error while trying to inject content in file ${e.path}`);const f=await up({name:c.name,date:c.date||new Date().toISOString(),path:`${c.path}.${c.ext}`,type:le.CLASS,editor:c.config.editor});return await r(wn(f)),{...e,path:`${c.path}.${c.ext}`}}),gC=xe("explorer/openFileAtSelection",async({file:e},{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.find(({path:c})=>e.path===c);if(i){const c={...i,extra:{...i==null?void 0:i.extra,editor:e.editor}};return r(wn(c)),c}const u=await up(e);return r(wn(u)),u}),c_=xe("explorer/deleteFile",async e=>{const{name:n,type:r,path:a,flags:i}=e;if(i.error)return{deleted:!0,node:e};const u=a.split("/");return u.pop(),{deleted:await dk({root:Hs.ROOT,type:pC(r),verb:Zt.DROP,name:n,path:u.join("/")}),node:e}}),C6=xe("explorer/deleteFolder",async e=>{const{path:n,flags:r}=e;if(r.error)return{deleted:!0,node:e};const{deleted:a}=await OT({force:!0,path:n,verb:Zt.REMOVE_ITEM});return{deleted:a,node:e}}),R6=xe("explorer/removeFileNode",async e=>{const{ext:n,path:r}=e;return await OT({verb:Zt.REMOVE_ITEM,path:`${r}.${n}`,force:!0}),r==="Classes/DataStore"&&vf(),{deleted:!0,node:e}}),Vs=xe("explorer/renameFile",async({file:e,newname:n})=>{if(e.type!=="folder"){const a=e.path.split("/");a.pop();const i=`${a.join("/")}/${e.name}.${e.ext}`,u=`${a.join("/")}/${n}.${e.ext}`;return await B1({verb:Zt.MOVE_ITEM,path:i,newpath:u}),{old:{...e,path:i},new:{...e,name:n,path:u}}}const r=e.path.split("/");return r.pop(),await B1({verb:Zt.MOVE_ITEM,path:`${r.join("/")}/${e.name}`,newpath:`${r.join("/")}/${n}`}),{old:e,new:{...e,name:n,path:`${r.join("/")}/${n}`}}}),Gl=xe("explorer/relocateNode",async({draggedNode:e,newLocation:n},{rejectWithValue:r})=>{try{await B1({verb:Zt.MOVE_ITEM,path:`${e.path}.${e.ext}`,newpath:`${n.path}/${e.name}.${e.ext}`})}catch{return r("can't move item")}}),Vf=xe("explorer/duplicateNode",async({node:e,duplicateName:n},{rejectWithValue:r,fulfillWithValue:a,getState:i})=>{const u=e.path.split("/");u.pop();try{const{tabs:c}=i().root,f=c.find(({path:b})=>b===`${e.path}${e.ext?`.${e.ext}`:""}`),p=["4dm","4qm","4qs"].includes(e.ext),{content:h}=f||await ni({verb:Zt.GET_INFO,path:`${e.path}.${e.ext}`,content:!0,as:p?"text":"json"}),m=await Gd({name:`${n}.${e.ext}`,content:h,path:u.join("/"),asText:p});return a({node:{...m,path:u.join("/")}})}catch{return r("failed to duplicate file")}}),A6=xe("explorer/executeMethod",async({methodName:e,params:n=[],resultingDataSource:r={},namespace:a=""},{rejectWithValue:i})=>{var u,c;try{const p=await window.Method4D.buildMethod({methodName:e,parameters:n,resultingDataSource:r},{namespace:a},null).callServerSide({id:"",serverSideRef:""},"onclick",{});return p!=null&&p.__NOTIFICATION?Ao.next({message:`${((u=p.__NOTIFICATION)==null?void 0:u.message)||""}`,kind:`${((c=p.__NOTIFICATION)==null?void 0:c.type)||"info"}`}):Ao.next({message:"Method executed Successfully",kind:"message"}),p}catch(f){return Ao.next({message:f.message||`Error executing the method "**${e}**"`,kind:"danger",markdown:!0}),i("can't execute method")}}),P6=xe("files/fetchFiles",async()=>lk(Hs.WEBFORMS,Hs.METHODS,Hs.CLASSES)),dw=xe("tabs/renameDatasource",async(e,{dispatch:n,getState:r})=>{var O,R;const a=!!e.datasourceNamespace,{confirmed:i}=await n(Eo({message:"Are you sure you want to rename the datasource?",title:"Rename Datasource",type:Hn.CONFIRM,color:Ga.WARNING,views:{toggles:{},tips:a?[{type:"warning",message:"The datasource property of components bound with this datasource will also be updated on opened web forms only"},{type:"warning",message:"The origin of some other datasources might be also renamed (if this datasource is the origin of other datasources)"}]:[{type:"warning",message:"The datasource property of components bound with this datasource will also be updated"},{type:"warning",message:"The origin of some other datasources might be also renamed (if this datasource is the origin of other datasources)"}]}})).unwrap();if(!i)return null;const{autoUpdateReferences:u,datasourceId:c,datasourceNamespace:f,value:p,path:h}=e,m=r();let b=[];if(a){const C=m.sharedDatasources.sources[f]||[];b.push(...C)}else if(h){const C=m.root.tabs.find(bn("path",h));if(b=(R=(O=C==null?void 0:C.content)==null?void 0:O.metadata)==null?void 0:R.datasources,!b)return null}const E=new RegExp(`^${c}\\b`,"");if(b=b.map(C=>{const k=(U_(C)||!bT(C))&&C.from&&E.test(C.from),j=C.events?C.events.map(F=>{var D,M,S,q;switch(F==null?void 0:F.type){case"method":{const U=F;return U.params?{...U,params:U.params.map(V=>{var Ee;return{...V,datasource:(Ee=V.datasource)==null?void 0:Ee.replace(new RegExp(`^${c}`,""),p)}}),returns:(D=U.returns)!=null&&D.datasource?{...U.returns,datasource:(M=U.returns.datasource)==null?void 0:M.replace(new RegExp(`^${c}`,""),p)}:U.returns}:U}case"simple-action":{const U=F;return U.datasource?{...U,datasource:{...U.datasource,name:(S=U.datasource.name)==null?void 0:S.replace(new RegExp(`^${c}`,""),p),from:(q=U.datasource.from)==null?void 0:q.replace(new RegExp(`^${c}`,""),p)}}:U}default:return F}}):C.events;return C.id===c?{...C,id:p,events:j}:k&&C.from?{...C,from:C.from.replace(new RegExp(`^${c}`,""),p),events:j}:{...C,events:j}}),u){const C=a?`${f}:${c}`:`${c}`,k=a?`${f}:${p}`:`${p}`;hT.next({path:h??"",action:F_.RENAME,old_reference:C,new_reference:k,is_shared:a})}return{path:h,namespace:f,datasources:b}}),pw=xe("tabs/edit-datasource",(e,{getState:n})=>{var u,c;const r=n();let a=[];if(e.namespace)a=r.sharedDatasources.sources[e.namespace];else{const f=r.root.tabs.find(bn("path",e.path));f&&(a=((c=(u=f.content)==null?void 0:u.metadata)==null?void 0:c.datasources)||[])}return a.map(f=>f.id===e.datasourceId?Object.assign({},f,{[e.propertyKey]:e.value}):f)}),mC=xe("tabs/fetchChanges",async(e,{getState:n})=>{const a=cu(n()).filter(i=>[le.METHOD,le.CLASS].includes(i.type));return ST(...a.map(i=>{const[u]=i.path.split("/").filter(Boolean);return{name:i.name,type:i.type,root:u,path:"."}}))}),D6=xe("files/saveAll",async(e,{getState:n,dispatch:r})=>{const a=Z_(n());for(const i of a)r(Ys({tab:i}))}),hw=xe("files/tryCloseTab",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.findIndex(c=>c.path===e);if(i===-1)return!1;const u=a[i];if(u!=null&&u.flags.touched){const{confirmed:c}=await r(Eo({title:qd(u),message:"Your unsaved changes will be lost. Proceed anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!c)return!1}return r(UC(i)),u.path===Ur&&u.flags.touched&&(async()=>{const f=await ni({verb:Zt.GET_INFO,path:Ur,content:!0,as:"json"});r(uw({content:f.content,date:f.date}))})(),!0}),I6=xe("files/tryCloseOtherTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;if(a.some(u=>u.path!==e&&u.flags.touched===!0)){const{confirmed:u}=await r(Eo({title:"Closing other tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(qC(e))}),M6=xe("files/tryCloseAllTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;if(a.some(u=>u.flags.touched===!0)){const{confirmed:u}=await r(Eo({title:"Closing all tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(HC())}),k6=xe("files/tryCloseRightTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;let i=!1;for(let u=a.length-1;u>e;u-=1)if(a[u].flags.touched){i=!0;break}if(i){const{confirmed:u}=await r(Eo({title:"Closing right tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(GC(e))}),$6=xe("files/tryCloseLeftTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;let i=!1;for(let u=0;u<e;u+=1)if(a[u].flags.touched){i=!0;break}if(i){const{confirmed:u}=await r(Eo({title:"Closing left tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(VC(e))}),l_=xe("files/reloadTab",async(e,{dispatch:n})=>{if(e.flags.touched){const{confirmed:i}=await n(Eo({title:qd(e),message:"Changes made to the file will be lost. Continue?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!i)return}const r=px(e.path),a=await ni({verb:Zt.GET_INFO,path:e.path,content:!0,as:r});if(e.path===Ur){const{roles:i,privileges:u}=ap(a.content);n(cw({roles:i,privileges:u})),n(ww({path:e.path,flags:{old:!1}}))}else if(e.path===oi){const{content:i}=a;n(sp({path:"project",value:i}))}else{const{content:i}=a;return e.type===le.WEBFORM?KM.next({path:e.path,action:pT.RELOAD,payload:i.components}):e.type===le.MODEL&&_x.next({action:"reload",payload:i}),a}}),Ys=xe("files/saveTab",async({tab:e},{dispatch:n,getState:r})=>{const{path:a,content:i}=e;if(e.type===le.DEBUGGER)return{...e,errors:[]};a.split("/").pop();const c=await ST({path:a});if(c.files[0]){const m=new Date(e.date),b=new Date(c.files[0].date);if(m.getTime()<b.getTime()){const{confirmed:E}=await n(Eo({title:qd(e),message:"New content has been found on the server. Are you sure you want to continue?",type:Hn.CONFIRM,icon:"FaSave"})).unwrap();if(!E)return n(ww({path:a,flags:{old:!0}})),null}}const f=await bk({verb:Zt.SAVE_CONTENT,content:N6(e,r()),path:a});(e.type===le.CLASS||e.type===le.MODEL)&&vf();const p=(f.modelErrors||[]).map(m=>m.message),h=(f.permissionsErrors||[]).map(m=>m.message);return{...e,content:i,date:f.date,initialContent:i,errors:p.length>0||h.length>0?[{title:"Model errors",messages:p},{title:"Permissions errors",messages:h}]:[]}}),N6=(e,n)=>{switch(!0){case e.path==="settings.json":case e.path===oi:return n.settings.project;case e.type===le.ROLES:return aw(n.roles);case e.type===le.MODEL:return e.content||{toJSON:!0,dataClasses:[],extraProperties:{}};default:return e.content}},jS=async e=>{if(e.type===le.DATA_EXPLORER)return{name:"Data Explorer",path:e.path,flags:{},view:{panel:{isOpen:!1,type:"",current:""}},type:e.type,date:new Date().toISOString()};const n=e.path.split("/").filter(Boolean)[0],r=await fk({root:n,type:e.type,verb:Zt.GET,name:e.name}),a={};r.type===le.METHOD&&(a.attributes=z_(r.content));const{date:i,name:u,type:c,content:f}=r;return{date:i,flags:{enabled:e.type===le.WEBFORM},extra:a,view:{panel:{isOpen:!1,type:"",current:""}},name:u,path:e.path,type:c,initialContent:f,content:c===le.MODEL?MT(f):f}},yC=xe("files/tryInjectMethod",async({type:e,dataclass:n},{getState:r,dispatch:a})=>{const{root:{tabs:i},settings:{server:{qodly:u}}}=r(),c=Ws("class",u);let f="",p="",h=null;if(!n)f="DataStore",p=`Classes/DataStore.${c}`;else switch(e){case"dataclass":f=n,p=`Classes/${n}.${c}`;break;case"collection":f=`${n}Selection`,p=`Classes/${n}Selection.${c}`;break;case"entity":f=`${n}Entity`,p=`Classes/${n}Entity.${c}`;break;default:return h}const m=i.find(bn("path",p));if(m)return a(wn(m)),m;try{h=await jS({name:f,date:new Date().toISOString(),path:`class/${f}.${c}`,type:le.CLASS})}catch{n?await a(u_({type:"dataclass",className:n,collectionName:`${n}Selection`,toCreate:e})):await a(u_({type:"model"}))}return h=await jS({name:f,date:new Date().toISOString(),path:`class/${f}.${c}`,type:le.CLASS}),h.path=p,a(wn(h)),h}),j6=xe("roles/open",async(e,{dispatch:n,getState:r})=>{const{tabs:a}=r().root,i=a.find(u=>u.path===Ur);if(i)return n(wn(i)),i;n(Sd())}),{debugger:Ls={meta:{state:Na.DETACHED},list:[],sessions:[],expressions:[]}}=nu();var HS,GS;const L6={meta:{...Ls.meta,state:((HS=Ls.meta)==null?void 0:HS.state)===Na.ATTACHED?(GS=Ls.meta)==null?void 0:GS.state:Na.DETACHED},list:Ls.list||[],sessions:Ls.sessions||[],expressions:Ls.expressions||[]};function LS(e,n){const{line:r,offset:a,type:i="saved"}=n;e.breakpoints[i].locations.push({line:r}),Bt.isNumber(a)&&(e.breakpoints[i].offset=a)}function FS(e,n,r,a){e.breakpoints[r].locations=n,Bt.isNumber(a)&&(e.breakpoints[r].offset=a)}function WS({filePath:e,fileType:n,methodName:r,className:a,ext:i,source:u}){return{filePath:e,fileType:n,methodName:r,className:a,ext:i,source:u,breakpoints:{draft:{locations:[],offset:0},saved:{locations:[],offset:0}}}}function BS(e,n,r){let a=!1;const i=e.map(u=>u[r]!==n[r]?u:(a=!0,{...u,...n}));return a?i:[...i,n]}function kf(e){return e.map(({label:n})=>({label:n}))}const bC=qn({name:"debugger",initialState:L6,reducers:{addBreakpointDecoration(e,n){const{filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f,breakpoint:p}=n.payload,h=Ps(e.list,r,i,u);if(h)LS(h,p);else{if(a===le.CLASS&&p.offset===void 0)throw new Error(`Cannot add a breakpoint on a function without offset. Try editing the ${u} class.`);const m=WS({filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f});LS(m,p),e.list.push(m)}},removeBreakpointDecoration(e,n){const{filePath:r,methodName:a,line:i,offset:u=0,type:c="saved"}=n.payload;if(r.startsWith("Classes/")){const f=e.list.filter(p=>p.filePath===r);if(f.length>0){const p=i+u;f.forEach(h=>{const m=h.breakpoints[c].offset||0;h.breakpoints[c].locations=h.breakpoints[c].locations.filter(b=>b.line+m!==p),c==="saved"&&(h.breakpoints.draft.locations=h.breakpoints.draft.locations.filter(b=>b.line+m!==p))})}}else{const f=Ps(e.list,r,a);f&&(f.breakpoints[c].locations=f.breakpoints[c].locations.filter(p=>p.line!==i),c==="saved"&&(f.breakpoints.draft.locations=f.breakpoints.draft.locations.filter(p=>p.line!==i)))}},setBreakpointsDecoration(e,n){const{filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f,breakpoints:p,offset:h,type:m="saved",clearDraft:b}=n.payload,E=Ps(e.list,r,i);if(E)FS(E,p,m,h),b&&m!=="draft"&&(E.breakpoints.draft.locations=[]);else{const O=WS({filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f});FS(O,p,m,h),e.list.push(O)}},clearBreakpoints(e,n){const{filePath:r,type:a="saved"}=n.payload;e.list=e.list.map(i=>({...i,breakpoints:i.filePath===r?{draft:!a||a==="draft"?{locations:[],offset:0}:i.breakpoints.draft,saved:!a||a==="saved"?{locations:[],offset:0}:i.breakpoints.saved}:i.breakpoints}))},setActiveLine(e,n){const{threadId:r,line:a,highlight:i}=n.payload,u=dr(e.sessions,r);u&&(u.activeLine=a,i&&(u.highlightedLines={start:a,end:a}))},addExpression(e,n){const{threadId:r,label:a,save:i}=n.payload,u=dr(e.sessions,r);u&&u.stopped&&(u.expressions=[...u.expressions||[],{label:a}],i&&(e.expressions=kf(u.expressions)))},removeExpression(e,n){const{threadId:r,index:a,save:i}=n.payload,u=dr(e.sessions,r);u&&(u.expressions=u.expressions.filter((c,f)=>f!==a),i&&(e.expressions=kf(u.expressions)))},removeAllExpressions(e,n){const{threadId:r,save:a}=n.payload,i=dr(e.sessions,r);i&&(i.expressions=[],a&&(e.expressions=[]))},renameExpression(e,n){const{threadId:r,index:a,replacement:i,save:u}=n.payload,c=dr(e.sessions,r);c&&c.expressions[a]&&(c.expressions[a].label=i,u&&(e.expressions=kf(c.expressions)))},setExpression(e,n){const{threadId:r,expression:a}=n.payload,i=dr(e.sessions,r);if(i){const u=a.index>=0?a.index:i.expressions.length>0?i.expressions.length-1:0,c=i.expressions[u];c?(c.result=a.result,c.nakedResult=a.nakedResult,c.variablesReference=a.variablesReference||0,c.presentationHint=a.presentationHint):i.expressions.push(a)}},updateExpressionAt(e,n){const{threadId:r,index:a,value:i}=n.payload,u=dr(e.sessions,r);if(u){const c=u.expressions[a];c&&(c.result=`"${i}"`,c.nakedResult=i)}},saveExpressions(e,n){const{expressions:r}=n.payload;e.expressions=kf(r)},addSession(e,n){const{threadId:r,channelId:a,stackFrames:i,exceptions:u=[]}=n.payload,c=dr(e.sessions,r),f=i[0],{expressions:p=[]}=e;if(c)c.expressions=p;else{const h=V_(r);e.sessions.push({tabPath:h,threadId:r,channelId:a,stackFrames:i,currentStackFrame:f,exceptions:u,expressions:p,variables:{callchain:[],expressions:[]},highlightedLines:null,activeLine:null,stopped:!0})}},updateSession(e,n){const{threadId:r,changes:a}=n.payload;e.sessions=e.sessions.map(i=>i.threadId===r?{...i,...a}:i)},removeSession(e,n){const{threadId:r}=n.payload;e.sessions=e.sessions.filter(a=>a.threadId!==r)},removeSessionByIndex(e,n){const r=n.payload;e.sessions.splice(r,1)},setSessions(e,n){const r=n.payload;e.sessions=r},setCallChainVariables(e,n){const{threadId:r,frameId:a,variables:i}=n.payload;e.sessions=e.sessions.map(u=>{var c;return u.threadId===r?{...u,variables:{...u.variables,callchain:BS((c=u.variables)==null?void 0:c.callchain,{frameId:a,items:i},"frameId")}}:u})},setExpressionVariables(e,n){const{threadId:r,variablesReference:a,variables:i}=n.payload;e.sessions=e.sessions.map(u=>{var c;return u.threadId===r?{...u,variables:{...u.variables,expressions:BS((c=u.variables)==null?void 0:c.expressions,{variablesReference:a,items:i},"variablesReference")}}:u})},setSourceContent(e,n){const{threadId:r,content:a}=n.payload,i=dr(e.sessions,r);i&&(i.currentStackFrame.source={...i.currentStackFrame.source,content:a})},setDebuggerMeta(e,n){if(n.payload.state===Na.ERROR){e.meta.error={...e.meta.error,time:Date.now()};const{override:r,error:a={code:null,reason:"",type:pd.SOCKET_ERROR}}=n.payload;if((r||e.meta.state!==Na.ERROR)&&(e.meta.error={...e.meta.error,...a}),(a==null?void 0:a.type)===pd.SOCKET_CLOSURE&&!(a!=null&&a.reason)&&e.meta.state===Na.DETACHED)return}e.meta.state=n.payload.state}},extraReducers:e=>{e.addCase(wC.fulfilled,n=>{n.sessions=[]})}}),{addBreakpointDecoration:F6,removeBreakpointDecoration:W6,setBreakpointsDecoration:B6,clearBreakpoints:U6,setActiveLine:z6,addExpression:H6,renameExpression:G6,removeExpression:q6,removeAllExpressions:V6,setExpression:Y6,updateExpressionAt:K6,saveExpressions:X6,addSession:J6,updateSession:Z6,removeSession:Q6,removeSessionByIndex:eF,setSessions:_C,setCallChainVariables:tF,setExpressionVariables:rF,setSourceContent:nF,setDebuggerMeta:oF}=bC.actions,wC=xe("files/wipeDebuggerSessions",async(e,{getState:n,dispatch:r})=>{const{sessions:a}=n().debugger;for(const{threadId:i}of a){const u=V_(i);r(hw(u))}}),EC=xe("files/removeDebuggerSessionsNotIn",async(e,{getState:n,dispatch:r})=>{const{threadIds:a}=e,{sessions:i}=n().debugger,u=[],c=i.filter(f=>{const p=a.includes(f.threadId);return p||u.push(f.threadId),p});return r(_C(c)),{staleThreadIds:u}});var vw=(e=>(e.UUID="uuid",e.STRING="string",e.TEXT="text",e.DATE="date",e.TIME="duration",e.BOOLEAN="bool",e.BYTE="byte",e.INTEGER="word",e.LONG="long",e.LONG64="long64",e.FLOAT="number",e.BLOB="blob",e.IMAGE="image",e.OBJECT="object",e))(vw||{}),Ia=(e=>(e.STORAGE="storage",e.RELATEDENTITY="relatedEntity",e.RELATEDENTITIES="relatedEntities",e.CALCULATED="calculated",e.COMPOSITION="composition",e.ALIAS="alias",e))(Ia||{});const aF=e=>["string","uuid","number","long"].includes(e.type),iF=[{label:"Storage",value:"storage"},{label:"Calculated",value:"calculated"}],sF=[{title:"UUID",kind:"storage",value:"uuid",calculatedType:"uuid",calculatedKind:"storage"},{title:"Long",kind:"storage",value:"long",calculatedType:"long",calculatedKind:"storage"}],uF=[{title:"String",kind:"storage",value:"string",calculatedType:"string",calculatedKind:"storage"},{title:"Text",kind:"storage",value:"text",calculatedType:"text",calculatedKind:"storage"},{title:"UUID",kind:"storage",value:"uuid",calculatedType:"uuid",calculatedKind:"storage"},{title:"Date",kind:"storage",value:"date",calculatedType:"date",calculatedKind:"storage"},{title:"Duration",kind:"storage",value:"duration",calculatedType:"duration",calculatedKind:"storage"},{title:"Bool",kind:"storage",value:"bool",calculatedType:"bool",calculatedKind:"storage"},{title:"Byte",kind:"storage",value:"byte",calculatedType:"byte",calculatedKind:"storage"},{title:"Word",kind:"storage",value:"word",calculatedType:"word",calculatedKind:"storage"},{title:"Number",kind:"storage",value:"number",calculatedType:"number",calculatedKind:"storage"},{title:"Long",kind:"storage",value:"long",calculatedType:"long",calculatedKind:"storage"},{title:"Object",kind:"storage",value:"object",calculatedType:"object",calculatedKind:"storage"},{title:"Image",kind:"storage",value:"image",calculatedType:"image",calculatedKind:"storage"},{title:"Blob",kind:"storage",value:"blob",calculatedType:"blob",calculatedKind:"storage"}],cF=[{label:"Expose as REST",value:"public"},{label:"Do not expose as REST",value:"publicOnServer"}],lF=[{label:"Expose as REST",value:"public"},{label:"Do not expose as REST",value:"publicOnServer"}],fF=[{label:"None",value:"none"},{label:"B-tree",value:"btree"},{label:"Cluster",value:"cluster"},{label:"Automatic",value:"auto"}],SC=_n("model/add-dataclass"),OC=_n("model/rename-dataclass"),TC=_n("model/remove-dataclass"),xC=_n("model/add-attribute"),dF=_n("model/edit-attribute-property"),CC=_n("model/remove-attribute"),RC=_n("model/rename-attribute"),AC=_n("model/edit-primary-key"),pF=_n("model/edit-dataclass-property"),PC=_n("model/rename-collection"),hF=(e,n)=>({toJSON:!0,extraProperties:n,dataClasses:e.map(r=>{var a;return{...r.data,extraProperties:{position:{x:r.position.x,y:r.position.y},panelColor:(a=r.data.extraProperties)==null?void 0:a.panelColor}}})});function Yf(e,n,r){const a=e;let i=0;for(;r[`${a}${i||""}`];)i++;return`${a}${i||""}`}const ql=e=>e.kind===Ia.RELATEDENTITY,Od=e=>e.kind===Ia.RELATEDENTITIES,vF=e=>Od(e)||ql(e),gw=xe("models/fetch",async()=>{try{return(await hr(en,{method:"POST",body:JSON.stringify({verb:Zt.GET_INFO,path:B_,as:"json",content:!0}),headers:new Headers({"Content-Type":"application/json"})})).content}catch(e){return e.message}}),Td=xe("models/save",async(e,{getState:n,rejectWithValue:r})=>{const{tabs:a}=n().root,i=a.find(u=>u.path===B_);if(!i)return r("Error while saving the model");try{const u=await hr(en,{method:"POST",body:JSON.stringify({verb:"save",path:i.path,content:i.content}),headers:new Headers({"Content-Type":"application/json"})});return vf(),{...u,path:i.path,content:e.content||{toJSON:!0,dataClasses:[],extraProperties:{}}}}catch{return r("Error while saving the model")}}),gF=xe("models/open",async(e,{dispatch:n,getState:r})=>{const{tabs:a}=r().root,i=a.find(u=>u.path==="models/main");if(i)return n(wn(i)),i;n(gw())}),mF=xe("model/rename-dataclass",async(e,{getState:n,dispatch:r})=>{var b,E;const{dataclassId:a,selectionId:i,name:u}=e;let c=n();const f=c.explorer.find(O=>O.path===Wt.CLASSES);if(!f)throw new Error("Classes folder was not found!");await r(Po(f.path)),c=n();const p={class:{found:!1,newNameTaken:!1,file:null,filename_update:u},entity:{found:!1,newNameTaken:!1,file:null,filename_update:`${u}Entity`},selection:{found:!1,newNameTaken:!1,file:null,filename_update:`${u}Selection`}};(E=(b=c.explorer.find(O=>O.path===Wt.CLASSES))==null?void 0:b.children)==null||E.forEach(O=>{O.name===p.class.filename_update&&(p.class.newNameTaken=!0),O.name===p.entity.filename_update&&(p.entity.newNameTaken=!0),O.name===p.selection.filename_update&&(p.selection.newNameTaken=!0),O.name===a?(p.class.found=!0,p.class.file=O):O.name===`${a}Entity`?(p.entity.found=!0,p.entity.file=O):O.name===i&&(p.selection.found=!0,p.selection.file=O)});const h=Object.entries(p).reduce((O,R)=>{const[C,k]=R;return k.found?k.newNameTaken?[...O,{type:"error",message:`Cannot rename ${C} file to ${k.filename_update} because it already exists. The existing file will be used instead!`}]:O:[...O,{type:"warning",message:`${a} ${C} file was not found`}]},[]);h.length>0&&r(Eo({message:"The following errors were encountered during dataclass rename:",views:{tips:h}}));const m=Object.values(p).filter(O=>O.found&&O.file&&!O.newNameTaken);await Promise.all(m.map(async O=>await r(Vs({file:O.file,newname:O.filename_update})))),m.length>0&&r(Po("Classes"))}),nf={DATACLASS_DELETE:"dataclass.delete",DATACLASS_DRAGGABLE:"dataclass.draggable"},yF={model:{dataClasses:{},collections:{},extraProperties:{}},draft:{dataClasses:{},collections:{},extraProperties:{}},flags:{[nf.DATACLASS_DELETE]:!0,[nf.DATACLASS_DRAGGABLE]:!0}},DC=qn({name:"Models",initialState:yF,reducers:{setModelFlag(e,n){e.flags={...e.flags,...n.payload}}},extraReducers(e){e.addCase(SC,({draft:{dataClasses:n}},r)=>{var c,f;const{dataclassID:a}=r.payload,i=Yf(a||"DataClass","className",n),u={className:i,collectionName:`${i}Selection`,attributes:[{name:"ID",kind:Ia.STORAGE,type:vw.LONG,scope:"public",indexKind:"auto",unique:!0,primKey:!0,autosequence:!0}],name:i,scope:"public",extraProperties:{position:{x:((c=r.payload.position)==null?void 0:c.x)||0,y:((f=r.payload.position)==null?void 0:f.y)||0}}};n[u.name]=u}).addCase(TC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a}=r.payload;n[a]&&(delete n[a],Object.values(n).forEach(u=>{u.attributes=u.attributes.filter(c=>c.type!==a&&c.type!==u.collectionName)}))}).addCase(OC,({draft:{dataClasses:n,collections:r}},a)=>{const{dataclassID:i,newName:u}=a.payload;if(!n[i]||n[u])return;const c=n[i].collectionName,f=Yf(`${u}Selection`,"collectionName",r);Object.values(n).forEach(p=>{p.className===i&&(p.className=u,p.name=u,p.collectionName=f),p.attributes.forEach(h=>{h.type===i?(h.type=u,h.path=u):h.type===c&&(h.type=f)})})}).addCase(xC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeName:i,attributeType:u,attributeKind:c,target:f}=r.payload;if(!n[a]||ek("name",i,n[a].attributes))return;const h={name:i,kind:c,type:u,exposed:!0,scope:"public"};if(c===Ia.RELATEDENTITY){if(!n[u])return;h.path=u;const b={name:Yf(n[u].collectionName,"name",n[u].attributes),type:n[a].collectionName,kind:Ia.RELATEDENTITIES,reversePath:!0,path:i,scope:"public",exposed:!0};n[u].attributes.push(b)}else if(c===Ia.RELATEDENTITIES){const m=n[u];if(!m)return;const b=m.attributes.find(bn("name",f));if(b){if(!ql(b)||b.type!==n[a].className)return}else{h.path=f,h.reversePath=!0,h.type=u;const E={name:f,kind:Ia.RELATEDENTITY,scope:"public",path:m.className,type:m.className,exposed:!0};m.attributes.push(E)}}n[a].attributes.push(h)}).addCase(RC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeID:i,newName:u}=r.payload,c=n[a].attributes.find(bn("name",i)),f=n[a].attributes.find(bn("name",u));!c||f||Object.values(n).forEach(({collectionName:p,attributes:h,className:m})=>{h.forEach(b=>{ql(c)&&Od(b)&&b.type===p&&b.path===i&&(b.path=u),m===a&&b.name===i&&(b.name=u)})})}).addCase(CC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeID:i}=r.payload;if(!n[a])return;const u=n[a].attributes.find(bn("name",i));u&&(ql(u)&&Object.values(n).forEach(c=>{c.attributes=c.attributes.filter(f=>!(Od(f)&&f.type===c.collectionName&&f.path===u.name))}),n[a].attributes=n[a].attributes.filter(JM("name",i)))}).addCase(PC,({draft:{dataClasses:n,collections:r}},a)=>{const{dataclassID:i,collectionName:u}=a.payload;if(!n[i])return;const c=n[i].collectionName;r[u]||(n[i].collectionName=u,r[u]=n[i],delete r[c],Object.values(n).forEach(f=>f.attributes.forEach(p=>{p.type===c&&(p.type=u)})))}).addCase(AC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,newPrimKey:i}=r.payload;n[a]&&n[a].attributes.forEach(u=>{u.name===i?u.primKey=!0:u.primKey=!1})}),e.addCase(gw.fulfilled,(n,r)=>{var c;const a={},i={},u=r.payload.extraProperties||{};(c=r.payload.dataClasses)==null||c.forEach(f=>{a[f.name]=f,i[f.collectionName]=f}),n.draft.dataClasses=a,n.draft.collections=i,n.draft.extraProperties=u,n.model.dataClasses=a,n.model.collections=i,n.model.extraProperties=u}),e.addCase(Td.pending,()=>{}).addCase(Td.fulfilled,(n,r)=>{const a={},i={},u=r.payload.content.extraProperties||{};r.payload.content.dataClasses.forEach(c=>{a[c.name]=c,i[c.collectionName]=c}),n.draft.dataClasses=a,n.draft.collections=i,n.draft.extraProperties=u,n.model.dataClasses=a,n.model.collections=i,n.model.extraProperties=u})}}),{setModelFlag:bF}=DC.actions,_F=()=>Ua(e=>e.model.draft.dataClasses),wF=()=>Ua(e=>e.model.draft.collections),EF=e=>Ua(n=>n.model.draft.dataClasses[e]),SF=(e,n)=>Ua(r=>r.model.draft.dataClasses[e].attributes.find(bn("name",n))),OF=()=>Ua(e=>e.model.draft.extraProperties),TF=()=>{const e=Ua(i=>i.model.flags),n=i=>i in e?e[i]:void 0,r=n(nf.DATACLASS_DELETE),a=n(nf.DATACLASS_DRAGGABLE);return{deleteDataclass:r,draggableDataclass:a,flags:e}},xF=DC.reducer;function m1(e,n){const r=e.tabs.find(({path:a})=>a===oi);r&&(r.flags.touched=n)}const IC={SIDEBAR_SECTION_RESIZABLE:"sidebar.section.resizable"},{webforms:$f}=nu(),MC={[IC.SIDEBAR_SECTION_RESIZABLE]:!0},kC={...$f,templates:{data:[],selectedGroup:""},datasources:{...G_.webforms.datasources,...$f==null?void 0:$f.datasources},flags:MC},$C=qn({name:"webforms",initialState:kC,reducers:{toggleInspector:(e,n)=>{const{type:r}=n.payload;e.inspector[r].active=!e.inspector[r].active,e.inspector[r].active||(e.inspector[r].data=void 0)},inspect:(e,n)=>{const{type:r,data:a}=n.payload;e.inspector[r].active&&(e.inspector[r].data=a)},addComponent:(e,n)=>{e.components.push(n.payload)},editComponent:(e,n)=>{const{id:r,changes:a}=n.payload;e.components=e.components.map(i=>i.id===r?{...i,...a}:i)},removeComponent:(e,n)=>{const{payload:r}=n,a=e.components.findIndex(i=>i.id===r);a!==-1&&e.components.splice(a,1)},setSelectedGroup:(e,n)=>{e.templates.selectedGroup=n.payload.selectedGroup},setTemplatesData:(e,n)=>{e.templates.data=n.payload},setTemplateData:(e,n)=>{const{group:r,components:a}=n.payload,i=e.templates.data.find(u=>u.group===r);i&&(i.components=a)},setDatasourcesTheme:(e,n)=>{e.datasources.theme=n.payload},setWebformsFlag(e,n){e.flags={...e.flags,...n.payload}}},extraReducers(e){e.addCase(BC.fulfilled,(n,r)=>{n.components=r.payload})}}),{toggleInspector:CF,inspect:RF,addComponent:NC,editComponent:jC,removeComponent:LC,setSelectedGroup:AF,setTemplatesData:FC,setTemplateData:WC,setDatasourcesTheme:PF,setWebformsFlag:DF}=$C.actions,IF=$C.reducer,mw=Bt.curry((e,n)=>{var i,u;const r={...n.sharedDatasources.sources},a=(u=((i=n.root.tabs.find(bn("path",e)))==null?void 0:i.content).metadata)==null?void 0:u.datasources;return a&&(r[e]=a),Bt.cloneDeep(r)}),MF=xe("webforms/fetchTemplates",async(e,{dispatch:n,getState:r})=>{const{data:a}=r().webforms.templates;if(!Bt.isEmpty(a))return a;try{const u=await(await fetch(`https://raw.githubusercontent.com/4d/Web-studio-TIPS/gh-build/build/index.json?t=${Date.now()}`)).json();return n(FC(u)),u}catch{return[]}}),kF=xe("webforms/fetchTemplate",async({name:e},{dispatch:n,getState:r})=>{const{data:a}=r().webforms.templates,i=a.find(u=>u.group===e);if(i&&!Bt.isEmpty(i.components))return i.components;try{const c=await(await fetch(`${i==null?void 0:i.link}?t=${Date.now()}`)).json();return n(WC({group:e,components:c})),c}catch{return[]}}),BC=xe("webforms/fetchCraftedComponents",async(e,{rejectWithValue:n})=>{try{return(await ni({path:"WebForms/crafted_components.json",verb:Zt.GET_INFO,content:!0,as:"json"})).content}catch{return n("Error while loading the crafted components")}}),$F=xe("webforms/addCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(NC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while adding the crafted component")}}),NF=xe("webforms/editCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(jC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while editing the crafted component")}}),jF=xe("webforms/removeCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(LC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while removing the crafted component")}}),yw=xe("datasources/add-datasource",async(e,{getState:n,rejectWithValue:r})=>{var a,i;try{const u=n(),c=e.datasource,f=!!c.namespace,p=[];if(f){const h={...u.sharedDatasources.sources,[c.namespace]:[...u.sharedDatasources.sources[c.namespace],c]};p.push(...h[c.namespace]),await ri(h)}else(((i=(a=u.root.tabs.find(bn("path",e.path)).content)==null?void 0:a.metadata)==null?void 0:i.datasources)||[]).push(c);return{list:p,path:e.path,namespace:e.datasource.namespace}}catch{console.error("Error while adding the datasource",e.datasource.id),r("Error while adding the datasource")}}),bw=xe("datasources/edit-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const{namespace:a,path:i}=e,u=n(),c=!!e.namespace,f=mw(i,u);let p=Bt.defaultTo(f[a||i],[]);return p=p.map(h=>h.id===e.id?{...h,[e.property]:e.value}:h),c&&await ri({...u.sharedDatasources.sources,[e.namespace]:p}),{list:p,path:e.path,namespace:e.namespace}}catch{r(`Error while editing datasource ${e.id}`)}}),LF=e=>e.type===Ks.fulfilled.type,Ks=xe("datasources/rename-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const a=n(),i=!!e.namespace,u=e.namespace||e.path,c=mw(e.path,a),f=Bt.defaultTo(c[u],[]),p=new RegExp(`^${e.id}\\b`,"");if(f.forEach(h=>{var b;const m=(U_(h)||!bT(h))&&h.from&&p.test(h.from);e.updateRefs&&((b=h.events)==null||b.forEach(E=>{var O,R,C,k,j;switch(E.type){case"method":{const F=E;F.params.forEach(D=>{D.datasource&&Object.assign(D,{datasource:D.datasource.replace(new RegExp(`^${e.id}`,""),e.new_name)})}),F.returns&&Object.assign(F.returns,{datasource:(R=(O=F.returns)==null?void 0:O.datasource)==null?void 0:R.replace(new RegExp(`^${e.id}`,""),e.new_name)});return}case"simple-action":{const F=E;F.datasource&&Object.assign(F.datasource,{name:(C=F.datasource.name)==null?void 0:C.replace(new RegExp(`^${e.id}`,""),e.new_name),from:(k=F.datasource.from)==null?void 0:k.replace(new RegExp(`^${e.id}`,""),e.new_name),target:(j=F.datasource.target)==null?void 0:j.replace(new RegExp(`^${e.id}`,""),e.new_name)});return}default:return}})),h.id===e.id?h.id=e.new_name:m&&h.from&&(h.from=h.from.replace(new RegExp(`^${e.id}`,""),e.new_name))}),e.updateRefs){const h=fd({id:e.id,namespace:e.namespace}),m=fd({id:e.new_name,namespace:e.namespace});hT.next({path:e.path??"",action:F_.RENAME,old_reference:h,new_reference:m,is_shared:i})}return i&&await ri({...a.sharedDatasources.sources,[e.namespace]:f}),{list:f,path:e.path,namespace:e.namespace}}catch{return r(`Error while renaming datasource ${e.namespace}:${e.id}`)}}),Vl=xe("datasources/delete-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const a=n(),i=!!e.namespace,u=e.namespace||e.path,f=mw(e.path,a)[u].filter(ZM(e.id));return i&&await ri({...a.sharedDatasources.sources,[e.namespace]:f}),{list:f,path:e.path,namespace:e.namespace}}catch{return r(`Error while removing datasource ${e.id}`)}}),y1=nu(),FF={filesLoading:!1,tabs:y1.tabs||[],activeTab:y1.activeTab,recent:y1.recent||[]},_w=qn({name:"root",initialState:FF,reducers:{setPanelState(e,n){const{path:r,...a}=n.payload;e.tabs.forEach(i=>{i.path===r&&(i.view||(i.view={panel:{isOpen:!1,type:"",current:""}}),Object.assign(i.view.panel,a))})},addDataSource(e,n){var u;const{payload:{path:r,datasourceDef:a}}=n,i=e.tabs.find(c=>c.path===r);i&&(i.content.metadata.datasources=i.content.metadata.datasources||[],(u=i.content.metadata.datasources)!=null&&u.find(f=>f.id===a.id)||(i.content.metadata.datasources=[...i.content.metadata.datasources,{...a,events:[]}],i.flags={...i.flags,touched:!0}))},openSettingsTab(e){const n={date:new Date().toISOString(),flags:{},view:{panel:{isOpen:!1,type:"",current:""}},extra:{editor:{key:"editors:settings"}},name:"Settings",path:oi,type:le.SETTINGS,initialContent:{},content:{}};let r=e.tabs.find(a=>a.path===n.path);if(r||(e.tabs.push(n),r=e.tabs[e.tabs.length-1]),e.activeTab!==n.path){const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);e.activeTab=n.path,r.weight=((a==null?void 0:a.weight)||0)+1}},removeDataSource(e,n){const{path:r,datasourceID:a}=n.payload;e.tabs=e.tabs.map(i=>i.path===r?{...i,flags:{...i.flags,touched:!0},content:{...i.content,metadata:{...i.content.metadata,datasources:i.content.metadata.datasources.filter(u=>u.id!==a)}}}:i)},setDataSources(e,n){const{payload:{path:r,datasourceArr:a}}=n;e.tabs=e.tabs.map(i=>{var u;return i.path===r?{...i,flags:{...i.flags,touched:!0},content:{...i.content,metadata:{...(u=i.content)==null?void 0:u.metadata,datasources:a}}}:i})},setTabs(e,n){e.tabs=n.payload},closeTab(e,n){const r=n.payload;e.tabs.splice(r,1);const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);e.activeTab=(a==null?void 0:a.path)||""},closeOthers(e,n){e.tabs=e.tabs.filter(r=>r.path===n.payload),e.activeTab=n.payload},closeAllTabs(e){e.tabs=[],e.activeTab=""},closeRightTabs(e,n){e.tabs.splice(n.payload+1),e.activeTab=e.tabs[n.payload].path},closeLeftTabs(e,n){e.tabs.splice(0,n.payload)},closeSavedTabs(e){e.tabs=e.tabs.filter(({flags:{touched:r}})=>r);const n=e.tabs.reduce((r,a)=>(a==null?void 0:a.weight)>((r==null?void 0:r.weight)||0)?a:r,null);e.activeTab=(n==null?void 0:n.path)||""},selectTab(e,n){const r=e.tabs.find(({path:i})=>i===n.payload);if(!r||e.activeTab===n.payload)return;const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);r.weight=a?(a.weight||0)+1:1,e.activeTab=n.payload},openTabUnselected(e,n){const r=n.payload;let a=e.tabs.find(({path:u})=>r.path===u);a||(e.tabs.push(r),a=e.tabs[e.tabs.length-1]);const i=e.tabs.reduce((u,c)=>(c==null?void 0:c.weight)>((u==null?void 0:u.weight)||0)?c:u,null);a.weight=i?(i.weight||0)+1:1,a.extra={...a.extra,...r.extra}},selectTabByReference(e,n){const r=n.payload;let a=e.tabs.find(({path:i})=>r.path===i);if(a||(e.tabs.push(r),a=e.tabs[e.tabs.length-1]),e.activeTab!==r.path){const i=e.tabs.reduce((u,c)=>(c==null?void 0:c.weight)>((u==null?void 0:u.weight)||0)?c:u,null);e.activeTab=r.path,a.weight=((i==null?void 0:i.weight)||0)+1}a.extra={...a.extra,...r.extra}},setContent(e,n){const{path:r,content:a,contentPath:i}=n.payload;e.tabs=e.tabs.map(u=>{if(u.path!==r)return u;let c=!1;if(typeof a=="string")c=u.initialContent!==a;else{const f=JSON.stringify(Bt.get(u.initialContent,i||"",u.initialContent)),p=JSON.stringify(Bt.get(a,i||"",a));c=f!==p}return a&&typeof a=="object"&&(i?Bt.set(u.content,i,a):u.content=a),typeof a=="string"&&(u.content=a),{...u,flags:{...u.flags,touched:c}}})},setTabFlags(e,n){const{path:r,flags:a}=n.payload;e.tabs=e.tabs.map(i=>i.path===r?{...i,flags:{...i.flags,...a}}:i)},setTabsFlags(e,n){const{tabs:r,flags:a}=n.payload;e.tabs=e.tabs.map(i=>r.includes(i.path)?{...i,flags:{...i.flags,...a}}:i)},setTabExtra(e,n){const{path:r,extra:a,flags:i}=n.payload;e.tabs=e.tabs.map(u=>u.path===r?{...u,extra:{...u.extra,...a},flags:i?{...u.flags,...i}:u.flags}:u)},addWebFormStyles(e,n){const{path:r,styles:a=[]}=n.payload,i=e.tabs.find(u=>u.path===r);if(i){const u=i.content.metadata.styles.map(({name:f})=>f),c=a.filter(({name:f})=>!u.includes(f));i.content.metadata.styles=[...i.content.metadata.styles,...c].map(({scope:f,...p})=>({...p}))}},changeTabEditor(e,n){return e.tabs=e.tabs.map(r=>r.path===n.payload.path?n.payload:r),e}},extraReducers:e=>{e.addCase(vC.fulfilled,(n,r)=>{if(!r.payload)return;const{content:a,line:i,path:u}=r.payload,c=n.tabs.find(f=>f.path===u);if(c&&typeof c.content=="string"){const f=c.content.trim().split(`
|
|
278
|
+
`}}};e.type==="dataclass"&&!e.toCreate?h=[{...m("dataclass")},{...m("collection")},{...m("entity")}]:e.type==="dataclass"&&e.toCreate?h=[{...m(e.toCreate)}]:h=[{...m("model")}],h=h.filter(E=>!p.find(({name:O,ext:R})=>O===E.name&&R===(u?"4qs":"4dm"))),await Promise.all(h.map(async({name:E,content:O})=>{await n(qs({type:le.CLASS,path:i,fileName:E,parentNode:c,content:O,qodly:a.settings.server.qodly}))})),await n(Po(i))}),Po=xe("explorer/fetchFolderContent",async(e,{rejectWithValue:n})=>{try{return(await ni({verb:Zt.GET_INFO,path:e})).map(a=>{const i=`${e}/${a.name}`,{editor:u,supportedEditors:c}=bo(`${i}${a.ext?`.${a.ext.toLowerCase()}`:""}`);return{name:a.name,size:a.size,type:a.type,date:`${a.date}`,flags:{},error:null,path:i,ext:a.ext,config:a.type==="folder"?{}:{editor:u,supportedEditors:c}}})}catch{return n("Failed loading file content please Reload")}},{getPendingMeta:()=>{}}),zl=xe("explorer/fetchFolderContentWithoutExpanding",async(e,{rejectWithValue:n})=>{try{return(await ni({verb:Zt.GET_INFO,path:e})).map(a=>{const i=`${e}/${a.name}`,{editor:u,supportedEditors:c}=bo(`${i}${a.ext?`.${a.ext.toLowerCase()}`:""}`);return{name:a.name,size:a.size,type:a.type,date:`${a.date}`,flags:{},error:null,path:i,ext:a.ext,config:a.type==="folder"?{}:{editor:u,supportedEditors:c}}})}catch{return n("Failed loading file content please Reload")}},{getPendingMeta:()=>{}});function S6(e){const n=e.split(".");return n.pop(),{name:n.join("."),ext:e.split(".")[e.split(".").length-1]}}const O6=xe("explorer/uploadFile",async e=>{const n=e.type.includes("image/")?"$rawPict=true":"$binary=true";try{const r=await fetch(`/rest/$upload?${n}`,{method:"POST",headers:{"Content-Type":e.type},body:e});return{status:r.status,data:await r.json()}}catch{return{status:500,data:null}}}),T6=xe("explorer/uploadFile",async({file:e,path:n,parentNode:r},{dispatch:a})=>{const{editor:i,supportedEditors:u}=bo(n),{name:c,ext:f}=S6(e.name);a(lC({parent:r,child:{name:c,path:`${n}/${e.name}?t=${Date.now()}`,type:e.type,error:null,flags:{loading:!0},config:{editor:i,supportedEditors:u},ext:f}}));try{const p=await fetch(`/rest/$upload?$sharedFolder=true&$filename=${e.name}&$path=${n}`,{method:"POST",headers:{"Content-Type":e.type},body:e});return p.status>=300?(a(s_({parent:r,child:{name:c,path:`${n}/${e.name}`,type:e.type,error:{message:"error uploading file"},flags:{},config:{editor:i,supportedEditors:u},ext:f}})),p.status!==413&&Ao.next({message:"error uploading file",kind:"danger"})):await a(Po(r.path)),{status:p.status,fileName:e.name}}catch{return a(s_({parent:r,child:{name:c,path:`${n}/${e.name}`,type:e.type,error:{message:"error uploading file"},flags:{},config:{editor:i,supportedEditors:u},ext:f}})),Ao.next({message:"error uploading file",kind:"danger"}),{status:500,fileName:e.name}}}),qs=xe("explorer/createNewFile",async({fileName:e,type:n,path:r,parentNode:a,content:i},{dispatch:u,rejectWithValue:c,getState:f})=>{const{qodly:p}=f().settings.server;try{const h=await Gd({name:dC(e,n,p),content:i||fC(n),path:r,asText:[le.CLASS,le.METHOD].includes(n)});return a.error&&(a.flags.expanded?await u(Po(a.path)):await u(zl(a.path))),{qodly:p,file:h,parentNode:a}}catch{return c("failed to create folder")}});function hC(e,n){const{qodly:r=!0,withExtension:a=!0}=n||{},i=Ws(e.type,r);let u="";switch(e.type){case le.WEBFORM:u=`${Wt.WEBFORMS}/${e.name}`;break;case le.METHOD:u=`${Wt.METHODS}/${e.name}`;break;case le.CLASS:u=`${Wt.CLASSES}/${e.name}`;break;default:return""}return`${u}${a?`.${i}`:""}`}const x6=xe("explorer/createNewFileAndOpen",async(e,{dispatch:n,getState:r})=>{const a=await n(qs(e)).unwrap(),{qodly:i}=r().settings.server;if(a){const{file:u}=a,c=hC(u,{withExtension:!1,qodly:i}),{editor:f}=bo(c);await n(Hl({file:{name:e.fileName,type:u.type,path:c,editor:f,date:new Date().toISOString()}}))}}),qf=xe("explorer/createNewNode",async({fileName:e,path:n,parentNode:r},{rejectWithValue:a})=>{try{return{file:await yk({verb:Zt.CREATE_FOLDER,path:`${n}/${e}`,recursive:!0}),parentNode:r}}catch{return Ao.next({message:"failed to create folder",kind:"danger"}),a("failed to create folder")}}),up=async e=>{try{const n=e.path.split(".").at(-1),r=await ni({verb:Zt.GET_INFO,path:e.path,content:!0,as:kT(n)?"json":"text"}),a={editor:e.editor},i=mT(e.path);i===le.METHOD&&(a.attributes=z_(r.content),r.content=wT(r.content,{}));const{content:u,date:c,ext:f}=r;return{date:c,view:{panel:{isOpen:!1,type:"",current:""}},flags:{enabled:["WebForm","MForm"].includes(f)},extra:a,name:e.name,path:e.path,type:i,initialContent:u,content:u}}catch(n){const{data:r}=n;if(r.__ERROR.find(a=>a.errCode===TT.FILE_NOT_FOUND))switch(e.path){case Ur:{const a={permissions:{allowed:[]},privileges:[],roles:[]};return{date:new Date().toISOString(),flags:{},extra:{editor:{key:"editors:roles"}},name:"Roles & Privileges",path:e.path,type:le.ROLES,initialContent:a,content:a}}case oi:{const a={};return{date:new Date().toISOString(),flags:{},extra:{editor:{key:"editors:settings"}},name:"Settings",path:e.path,type:le.SETTINGS,initialContent:a,content:a}}}throw n}},Hl=xe("explorer/openFile",async({file:e,inactive:n,flags:r={}},{getState:a,dispatch:i})=>{const{root:{tabs:u},roles:c}=a(),f=u.find(({path:m})=>e.path===m);if(f){const m={...f,extra:{...f==null?void 0:f.extra,editor:e.editor},flags:{...f==null?void 0:f.flags,...r}};return i(wn(m)),m}if(e.path.startsWith("Debugger")){const m=a().debugger.sessions.find(b=>`Debugger/${b.threadId}`===e.path);if(m){const{source:{content:b},source:E}=m.currentStackFrame,O={name:e.name,type:le.DEBUGGER,date:new Date().toISOString(),path:e.path,content:b,view:{panel:{isOpen:!1,type:"",current:""}},initialContent:b,flags:{},extra:{source:E,editor:e.editor}};return i(wn(O)),O}}const p=await up(e);return e.path===Ur&&!c.flags.touched?i(uw({content:p.content,date:p.date})):e.path===oi&&i(sp({path:"project",value:p.content})),i((n?KC:wn)(p)),p}),fw=xe("explorer/openFileAtLine",async({file:e},{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.find(({path:c})=>e.path===c);if(i){const c={...i,extra:{...i==null?void 0:i.extra,editor:e.editor}};return r(wn(c)),c}const u=await up(e);return r(wn(u)),u}),vC=xe("explorer/injectContentAtLine",async(e,{getState:n,dispatch:r,rejectWithValue:a})=>{const i=n();e.path.split("/").pop();const c=Tr(i.explorer,e.path);if(!c)return a(`Error while trying to inject content in file ${e.path}`);const f=await up({name:c.name,date:c.date||new Date().toISOString(),path:`${c.path}.${c.ext}`,type:le.CLASS,editor:c.config.editor});return await r(wn(f)),{...e,path:`${c.path}.${c.ext}`}}),gC=xe("explorer/openFileAtSelection",async({file:e},{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.find(({path:c})=>e.path===c);if(i){const c={...i,extra:{...i==null?void 0:i.extra,editor:e.editor}};return r(wn(c)),c}const u=await up(e);return r(wn(u)),u}),c_=xe("explorer/deleteFile",async e=>{const{name:n,type:r,path:a,flags:i}=e;if(i.error)return{deleted:!0,node:e};const u=a.split("/");return u.pop(),{deleted:await dk({root:Hs.ROOT,type:pC(r),verb:Zt.DROP,name:n,path:u.join("/")}),node:e}}),C6=xe("explorer/deleteFolder",async e=>{const{path:n,flags:r}=e;if(r.error)return{deleted:!0,node:e};const{deleted:a}=await OT({force:!0,path:n,verb:Zt.REMOVE_ITEM});return{deleted:a,node:e}}),R6=xe("explorer/removeFileNode",async e=>{const{ext:n,path:r}=e;return await OT({verb:Zt.REMOVE_ITEM,path:`${r}.${n}`,force:!0}),r==="Classes/DataStore"&&vf(),{deleted:!0,node:e}}),Vs=xe("explorer/renameFile",async({file:e,newname:n})=>{if(e.type!=="folder"){const a=e.path.split("/");a.pop();const i=`${a.join("/")}/${e.name}.${e.ext}`,u=`${a.join("/")}/${n}.${e.ext}`;return await B1({verb:Zt.MOVE_ITEM,path:i,newpath:u}),{old:{...e,path:i},new:{...e,name:n,path:u}}}const r=e.path.split("/");return r.pop(),await B1({verb:Zt.MOVE_ITEM,path:`${r.join("/")}/${e.name}`,newpath:`${r.join("/")}/${n}`}),{old:e,new:{...e,name:n,path:`${r.join("/")}/${n}`}}}),Gl=xe("explorer/relocateNode",async({draggedNode:e,newLocation:n},{rejectWithValue:r})=>{try{await B1({verb:Zt.MOVE_ITEM,path:`${e.path}.${e.ext}`,newpath:`${n.path}/${e.name}.${e.ext}`})}catch{return r("can't move item")}}),Vf=xe("explorer/duplicateNode",async({node:e,duplicateName:n},{rejectWithValue:r,fulfillWithValue:a,getState:i})=>{const u=e.path.split("/");u.pop();try{const{tabs:c}=i().root,f=c.find(({path:b})=>b===`${e.path}${e.ext?`.${e.ext}`:""}`),p=["4dm","4qm","4qs"].includes(e.ext),{content:h}=f||await ni({verb:Zt.GET_INFO,path:`${e.path}.${e.ext}`,content:!0,as:p?"text":"json"}),m=await Gd({name:`${n}.${e.ext}`,content:h,path:u.join("/"),asText:p});return a({node:{...m,path:u.join("/")}})}catch{return r("failed to duplicate file")}}),A6=xe("explorer/executeMethod",async({methodName:e,params:n=[],resultingDataSource:r={},namespace:a=""},{rejectWithValue:i})=>{var u,c;try{const p=await window.Method4D.buildMethod({methodName:e,parameters:n,resultingDataSource:r},{namespace:a},null).callServerSide({id:"",serverSideRef:""},"onclick",{});return p!=null&&p.__NOTIFICATION?Ao.next({message:`${((u=p.__NOTIFICATION)==null?void 0:u.message)||""}`,kind:`${((c=p.__NOTIFICATION)==null?void 0:c.type)||"info"}`}):Ao.next({message:"Method executed Successfully",kind:"message"}),p}catch(f){return Ao.next({message:f.message||`Error executing the method "**${e}**"`,kind:"danger",markdown:!0}),i("can't execute method")}}),P6=xe("files/fetchFiles",async()=>lk(Hs.WEBFORMS,Hs.METHODS,Hs.CLASSES)),dw=xe("tabs/renameDatasource",async(e,{dispatch:n,getState:r})=>{var O,R;const a=!!e.datasourceNamespace,{confirmed:i}=await n(Eo({message:"Are you sure you want to rename the datasource?",title:"Rename Datasource",type:Hn.CONFIRM,color:Ga.WARNING,views:{toggles:{},tips:a?[{type:"warning",message:"The datasource property of components bound with this datasource will also be updated on opened web forms only"},{type:"warning",message:"The origin of some other datasources might be also renamed (if this datasource is the origin of other datasources)"}]:[{type:"warning",message:"The datasource property of components bound with this datasource will also be updated"},{type:"warning",message:"The origin of some other datasources might be also renamed (if this datasource is the origin of other datasources)"}]}})).unwrap();if(!i)return null;const{autoUpdateReferences:u,datasourceId:c,datasourceNamespace:f,value:p,path:h}=e,m=r();let b=[];if(a){const C=m.sharedDatasources.sources[f]||[];b.push(...C)}else if(h){const C=m.root.tabs.find(bn("path",h));if(b=(R=(O=C==null?void 0:C.content)==null?void 0:O.metadata)==null?void 0:R.datasources,!b)return null}const E=new RegExp(`^${c}\\b`,"");if(b=b.map(C=>{const k=(U_(C)||!bT(C))&&C.from&&E.test(C.from),j=C.events?C.events.map(F=>{var D,M,S,q;switch(F==null?void 0:F.type){case"method":{const U=F;return U.params?{...U,params:U.params.map(V=>{var Ee;return{...V,datasource:(Ee=V.datasource)==null?void 0:Ee.replace(new RegExp(`^${c}`,""),p)}}),returns:(D=U.returns)!=null&&D.datasource?{...U.returns,datasource:(M=U.returns.datasource)==null?void 0:M.replace(new RegExp(`^${c}`,""),p)}:U.returns}:U}case"simple-action":{const U=F;return U.datasource?{...U,datasource:{...U.datasource,name:(S=U.datasource.name)==null?void 0:S.replace(new RegExp(`^${c}`,""),p),from:(q=U.datasource.from)==null?void 0:q.replace(new RegExp(`^${c}`,""),p)}}:U}default:return F}}):C.events;return C.id===c?{...C,id:p,events:j}:k&&C.from?{...C,from:C.from.replace(new RegExp(`^${c}`,""),p),events:j}:{...C,events:j}}),u){const C=a?`${f}:${c}`:`${c}`,k=a?`${f}:${p}`:`${p}`;hT.next({path:h??"",action:F_.RENAME,old_reference:C,new_reference:k,is_shared:a})}return{path:h,namespace:f,datasources:b}}),pw=xe("tabs/edit-datasource",(e,{getState:n})=>{var u,c;const r=n();let a=[];if(e.namespace)a=r.sharedDatasources.sources[e.namespace];else{const f=r.root.tabs.find(bn("path",e.path));f&&(a=((c=(u=f.content)==null?void 0:u.metadata)==null?void 0:c.datasources)||[])}return a.map(f=>f.id===e.datasourceId?Object.assign({},f,{[e.propertyKey]:e.value}):f)}),mC=xe("tabs/fetchChanges",async(e,{getState:n})=>{const a=cu(n()).filter(i=>[le.METHOD,le.CLASS].includes(i.type));return ST(...a.map(i=>{const[u]=i.path.split("/").filter(Boolean);return{name:i.name,type:i.type,root:u,path:"."}}))}),D6=xe("files/saveAll",async(e,{getState:n,dispatch:r})=>{const a=Z_(n());for(const i of a)r(Ys({tab:i}))}),hw=xe("files/tryCloseTab",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root,i=a.findIndex(c=>c.path===e);if(i===-1)return!1;const u=a[i];if(u!=null&&u.flags.touched){const{confirmed:c}=await r(Eo({title:qd(u),message:"Your unsaved changes will be lost. Proceed anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!c)return!1}return r(UC(i)),u.path===Ur&&u.flags.touched&&(async()=>{const f=await ni({verb:Zt.GET_INFO,path:Ur,content:!0,as:"json"});r(uw({content:f.content,date:f.date}))})(),!0}),I6=xe("files/tryCloseOtherTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;if(a.some(u=>u.path!==e&&u.flags.touched===!0)){const{confirmed:u}=await r(Eo({title:"Closing other tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(qC(e))}),M6=xe("files/tryCloseAllTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;if(a.some(u=>u.flags.touched===!0)){const{confirmed:u}=await r(Eo({title:"Closing all tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(HC())}),k6=xe("files/tryCloseRightTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;let i=!1;for(let u=a.length-1;u>e;u-=1)if(a[u].flags.touched){i=!0;break}if(i){const{confirmed:u}=await r(Eo({title:"Closing right tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(GC(e))}),$6=xe("files/tryCloseLeftTabs",async(e,{getState:n,dispatch:r})=>{const{tabs:a}=n().root;let i=!1;for(let u=0;u<e;u+=1)if(a[u].flags.touched){i=!0;break}if(i){const{confirmed:u}=await r(Eo({title:"Closing left tabs",message:"Your changes will be lost if you do not save them. Close anyway?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!u)return}r(VC(e))}),l_=xe("files/reloadTab",async(e,{dispatch:n})=>{if(e.flags.touched){const{confirmed:i}=await n(Eo({title:qd(e),message:"Changes made to the file will be lost. Continue?",type:Hn.CONFIRM,color:Ga.WARNING,icon:"AiFillWarning"})).unwrap();if(!i)return}const r=px(e.path),a=await ni({verb:Zt.GET_INFO,path:e.path,content:!0,as:r});if(e.path===Ur){const{roles:i,privileges:u}=ap(a.content);n(cw({roles:i,privileges:u})),n(ww({path:e.path,flags:{old:!1}}))}else if(e.path===oi){const{content:i}=a;n(sp({path:"project",value:i}))}else{const{content:i}=a;return e.type===le.WEBFORM?KM.next({path:e.path,action:pT.RELOAD,payload:i.components}):e.type===le.MODEL&&_x.next({action:"reload",payload:i}),a}}),Ys=xe("files/saveTab",async({tab:e},{dispatch:n,getState:r})=>{const{path:a,content:i}=e;if(e.type===le.DEBUGGER)return{...e,errors:[]};a.split("/").pop();const c=await ST({path:a});if(c.files[0]){const m=new Date(e.date),b=new Date(c.files[0].date);if(m.getTime()<b.getTime()){const{confirmed:E}=await n(Eo({title:qd(e),message:"New content has been found on the server. Are you sure you want to continue?",type:Hn.CONFIRM,icon:"FaSave"})).unwrap();if(!E)return n(ww({path:a,flags:{old:!0}})),null}}const f=await bk({verb:Zt.SAVE_CONTENT,content:N6(e,r()),path:a});(e.type===le.CLASS||e.type===le.MODEL)&&vf();const p=(f.modelErrors||[]).map(m=>m.message),h=(f.permissionsErrors||[]).map(m=>m.message);return{...e,content:i,date:f.date,initialContent:i,errors:p.length>0||h.length>0?[{title:"Model errors",messages:p},{title:"Permissions errors",messages:h}]:[]}}),N6=(e,n)=>{switch(!0){case e.path==="settings.json":case e.path===oi:return n.settings.project;case e.type===le.ROLES:return aw(n.roles);case e.type===le.MODEL:return e.content||{toJSON:!0,dataClasses:[],extraProperties:{}};default:return e.content}},jS=async e=>{if(e.type===le.DATA_EXPLORER)return{name:"Data Explorer",path:e.path,flags:{},view:{panel:{isOpen:!1,type:"",current:""}},type:e.type,date:new Date().toISOString()};const n=e.path.split("/").filter(Boolean)[0],r=await fk({root:n,type:e.type,verb:Zt.GET,name:e.name}),a={};r.type===le.METHOD&&(a.attributes=z_(r.content));const{date:i,name:u,type:c,content:f}=r;return{date:i,flags:{enabled:e.type===le.WEBFORM},extra:a,view:{panel:{isOpen:!1,type:"",current:""}},name:u,path:e.path,type:c,initialContent:f,content:c===le.MODEL?MT(f):f}},yC=xe("files/tryInjectMethod",async({type:e,dataclass:n},{getState:r,dispatch:a})=>{const{root:{tabs:i},settings:{server:{qodly:u}}}=r(),c=Ws("class",u);let f="",p="",h=null;if(!n)f="DataStore",p=`Classes/DataStore.${c}`;else switch(e){case"dataclass":f=n,p=`Classes/${n}.${c}`;break;case"collection":f=`${n}Selection`,p=`Classes/${n}Selection.${c}`;break;case"entity":f=`${n}Entity`,p=`Classes/${n}Entity.${c}`;break;default:return h}const m=i.find(bn("path",p));if(m)return a(wn(m)),m;try{h=await jS({name:f,date:new Date().toISOString(),path:`class/${f}.${c}`,type:le.CLASS})}catch{n?await a(u_({type:"dataclass",className:n,collectionName:`${n}Selection`,toCreate:e})):await a(u_({type:"model"}))}return h=await jS({name:f,date:new Date().toISOString(),path:`class/${f}.${c}`,type:le.CLASS}),h.path=p,a(wn(h)),h}),j6=xe("roles/open",async(e,{dispatch:n,getState:r})=>{const{tabs:a}=r().root,i=a.find(u=>u.path===Ur);if(i)return n(wn(i)),i;n(Sd())}),{debugger:Ls={meta:{state:Na.DETACHED},list:[],sessions:[],expressions:[]}}=nu();var HS,GS;const L6={meta:{...Ls.meta,state:((HS=Ls.meta)==null?void 0:HS.state)===Na.ATTACHED?(GS=Ls.meta)==null?void 0:GS.state:Na.DETACHED},list:Ls.list||[],sessions:Ls.sessions||[],expressions:Ls.expressions||[]};function LS(e,n){const{line:r,offset:a,type:i="saved"}=n;e.breakpoints[i].locations.push({line:r}),Bt.isNumber(a)&&(e.breakpoints[i].offset=a)}function FS(e,n,r,a){e.breakpoints[r].locations=n,Bt.isNumber(a)&&(e.breakpoints[r].offset=a)}function WS({filePath:e,fileType:n,methodName:r,className:a,ext:i,source:u}){return{filePath:e,fileType:n,methodName:r,className:a,ext:i,source:u,breakpoints:{draft:{locations:[],offset:0},saved:{locations:[],offset:0}}}}function BS(e,n,r){let a=!1;const i=e.map(u=>u[r]!==n[r]?u:(a=!0,{...u,...n}));return a?i:[...i,n]}function kf(e){return e.map(({label:n})=>({label:n}))}const bC=qn({name:"debugger",initialState:L6,reducers:{addBreakpointDecoration(e,n){const{filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f,breakpoint:p}=n.payload,h=Ps(e.list,r,i,u);if(h)LS(h,p);else{if(a===le.CLASS&&p.offset===void 0)throw new Error(`Cannot add a breakpoint on a function without offset. Try editing the ${u} class.`);const m=WS({filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f});LS(m,p),e.list.push(m)}},removeBreakpointDecoration(e,n){const{filePath:r,methodName:a,line:i,offset:u=0,type:c="saved"}=n.payload;if(r.startsWith("Classes/")){const f=e.list.filter(p=>p.filePath===r);if(f.length>0){const p=i+u;f.forEach(h=>{const m=h.breakpoints[c].offset||0;h.breakpoints[c].locations=h.breakpoints[c].locations.filter(b=>b.line+m!==p),c==="saved"&&(h.breakpoints.draft.locations=h.breakpoints.draft.locations.filter(b=>b.line+m!==p))})}}else{const f=Ps(e.list,r,a);f&&(f.breakpoints[c].locations=f.breakpoints[c].locations.filter(p=>p.line!==i),c==="saved"&&(f.breakpoints.draft.locations=f.breakpoints.draft.locations.filter(p=>p.line!==i)))}},setBreakpointsDecoration(e,n){const{filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f,breakpoints:p,offset:h,type:m="saved",clearDraft:b}=n.payload,E=Ps(e.list,r,i);if(E)FS(E,p,m,h),b&&m!=="draft"&&(E.breakpoints.draft.locations=[]);else{const O=WS({filePath:r,fileType:a,methodName:i,className:u,ext:c,source:f});FS(O,p,m,h),e.list.push(O)}},clearBreakpoints(e,n){const{filePath:r,type:a="saved"}=n.payload;e.list=e.list.map(i=>({...i,breakpoints:i.filePath===r?{draft:!a||a==="draft"?{locations:[],offset:0}:i.breakpoints.draft,saved:!a||a==="saved"?{locations:[],offset:0}:i.breakpoints.saved}:i.breakpoints}))},setActiveLine(e,n){const{threadId:r,line:a,highlight:i}=n.payload,u=dr(e.sessions,r);u&&(u.activeLine=a,i&&(u.highlightedLines={start:a,end:a}))},addExpression(e,n){const{threadId:r,label:a,save:i}=n.payload,u=dr(e.sessions,r);u&&u.stopped&&(u.expressions=[...u.expressions||[],{label:a}],i&&(e.expressions=kf(u.expressions)))},removeExpression(e,n){const{threadId:r,index:a,save:i}=n.payload,u=dr(e.sessions,r);u&&(u.expressions=u.expressions.filter((c,f)=>f!==a),i&&(e.expressions=kf(u.expressions)))},removeAllExpressions(e,n){const{threadId:r,save:a}=n.payload,i=dr(e.sessions,r);i&&(i.expressions=[],a&&(e.expressions=[]))},renameExpression(e,n){const{threadId:r,index:a,replacement:i,save:u}=n.payload,c=dr(e.sessions,r);c&&c.expressions[a]&&(c.expressions[a].label=i,u&&(e.expressions=kf(c.expressions)))},setExpression(e,n){const{threadId:r,expression:a}=n.payload,i=dr(e.sessions,r);if(i){const u=a.index>=0?a.index:i.expressions.length>0?i.expressions.length-1:0,c=i.expressions[u];c?(c.result=a.result,c.nakedResult=a.nakedResult,c.variablesReference=a.variablesReference||0,c.presentationHint=a.presentationHint):i.expressions.push(a)}},updateExpressionAt(e,n){const{threadId:r,index:a,value:i}=n.payload,u=dr(e.sessions,r);if(u){const c=u.expressions[a];c&&(c.result=`"${i}"`,c.nakedResult=i)}},saveExpressions(e,n){const{expressions:r}=n.payload;e.expressions=kf(r)},addSession(e,n){const{threadId:r,channelId:a,stackFrames:i,exceptions:u=[]}=n.payload,c=dr(e.sessions,r),f=i[0],{expressions:p=[]}=e;if(c)c.expressions=p;else{const h=V_(r);e.sessions.push({tabPath:h,threadId:r,channelId:a,stackFrames:i,currentStackFrame:f,exceptions:u,expressions:p,variables:{callchain:[],expressions:[]},highlightedLines:null,activeLine:null,stopped:!0})}},updateSession(e,n){const{threadId:r,changes:a}=n.payload;e.sessions=e.sessions.map(i=>i.threadId===r?{...i,...a}:i)},removeSession(e,n){const{threadId:r}=n.payload;e.sessions=e.sessions.filter(a=>a.threadId!==r)},removeSessionByIndex(e,n){const r=n.payload;e.sessions.splice(r,1)},setSessions(e,n){const r=n.payload;e.sessions=r},setCallChainVariables(e,n){const{threadId:r,frameId:a,variables:i}=n.payload;e.sessions=e.sessions.map(u=>{var c;return u.threadId===r?{...u,variables:{...u.variables,callchain:BS((c=u.variables)==null?void 0:c.callchain,{frameId:a,items:i},"frameId")}}:u})},setExpressionVariables(e,n){const{threadId:r,variablesReference:a,variables:i}=n.payload;e.sessions=e.sessions.map(u=>{var c;return u.threadId===r?{...u,variables:{...u.variables,expressions:BS((c=u.variables)==null?void 0:c.expressions,{variablesReference:a,items:i},"variablesReference")}}:u})},setSourceContent(e,n){const{threadId:r,content:a}=n.payload,i=dr(e.sessions,r);i&&(i.currentStackFrame.source={...i.currentStackFrame.source,content:a})},setDebuggerMeta(e,n){if(n.payload.state===Na.ERROR){e.meta.error={...e.meta.error,time:Date.now()};const{override:r,error:a={code:null,reason:"",type:pd.SOCKET_ERROR}}=n.payload;if((r||e.meta.state!==Na.ERROR)&&(e.meta.error={...e.meta.error,...a}),(a==null?void 0:a.type)===pd.SOCKET_CLOSURE&&!(a!=null&&a.reason)&&e.meta.state===Na.DETACHED)return}e.meta.state=n.payload.state}},extraReducers:e=>{e.addCase(wC.fulfilled,n=>{n.sessions=[]})}}),{addBreakpointDecoration:F6,removeBreakpointDecoration:W6,setBreakpointsDecoration:B6,clearBreakpoints:U6,setActiveLine:z6,addExpression:H6,renameExpression:G6,removeExpression:q6,removeAllExpressions:V6,setExpression:Y6,updateExpressionAt:K6,saveExpressions:X6,addSession:J6,updateSession:Z6,removeSession:Q6,removeSessionByIndex:eF,setSessions:_C,setCallChainVariables:tF,setExpressionVariables:rF,setSourceContent:nF,setDebuggerMeta:oF}=bC.actions,wC=xe("files/wipeDebuggerSessions",async(e,{getState:n,dispatch:r})=>{const{sessions:a}=n().debugger;for(const{threadId:i}of a){const u=V_(i);r(hw(u))}}),EC=xe("files/removeDebuggerSessionsNotIn",async(e,{getState:n,dispatch:r})=>{const{threadIds:a}=e,{sessions:i}=n().debugger,u=[],c=i.filter(f=>{const p=a.includes(f.threadId);return p||u.push(f.threadId),p});return r(_C(c)),{staleThreadIds:u}});var vw=(e=>(e.UUID="uuid",e.STRING="string",e.TEXT="text",e.DATE="date",e.TIME="duration",e.BOOLEAN="bool",e.BYTE="byte",e.INTEGER="word",e.LONG="long",e.LONG64="long64",e.FLOAT="number",e.BLOB="blob",e.IMAGE="image",e.OBJECT="object",e))(vw||{}),Ia=(e=>(e.STORAGE="storage",e.RELATEDENTITY="relatedEntity",e.RELATEDENTITIES="relatedEntities",e.CALCULATED="calculated",e.COMPOSITION="composition",e.ALIAS="alias",e))(Ia||{});const aF=e=>["string","uuid","number","long"].includes(e.type),iF=[{label:"Storage",value:"storage"},{label:"Calculated",value:"calculated"}],sF=[{title:"UUID",kind:"storage",value:"uuid",calculatedType:"uuid",calculatedKind:"storage"},{title:"Long",kind:"storage",value:"long",calculatedType:"long",calculatedKind:"storage"}],uF=[{title:"String",kind:"storage",value:"string",calculatedType:"string",calculatedKind:"storage"},{title:"Text",kind:"storage",value:"text",calculatedType:"text",calculatedKind:"storage"},{title:"UUID",kind:"storage",value:"uuid",calculatedType:"uuid",calculatedKind:"storage"},{title:"Date",kind:"storage",value:"date",calculatedType:"date",calculatedKind:"storage"},{title:"Duration",kind:"storage",value:"duration",calculatedType:"duration",calculatedKind:"storage"},{title:"Bool",kind:"storage",value:"bool",calculatedType:"bool",calculatedKind:"storage"},{title:"Byte",kind:"storage",value:"byte",calculatedType:"byte",calculatedKind:"storage"},{title:"Word",kind:"storage",value:"word",calculatedType:"word",calculatedKind:"storage"},{title:"Number",kind:"storage",value:"number",calculatedType:"number",calculatedKind:"storage"},{title:"Long",kind:"storage",value:"long",calculatedType:"long",calculatedKind:"storage"},{title:"Object",kind:"storage",value:"object",calculatedType:"object",calculatedKind:"storage"},{title:"Image",kind:"storage",value:"image",calculatedType:"image",calculatedKind:"storage"},{title:"Blob",kind:"storage",value:"blob",calculatedType:"blob",calculatedKind:"storage"}],cF=[{label:"Expose as REST",value:"public"},{label:"Do not expose as REST",value:"publicOnServer"}],lF=[{label:"Expose as REST",value:"public"},{label:"Do not expose as REST",value:"publicOnServer"}],fF=[{label:"None",value:"none"},{label:"B-tree",value:"btree"},{label:"Cluster",value:"cluster"},{label:"Automatic",value:"auto"}],SC=_n("model/add-dataclass"),OC=_n("model/rename-dataclass"),TC=_n("model/remove-dataclass"),xC=_n("model/add-attribute"),dF=_n("model/edit-attribute-property"),CC=_n("model/remove-attribute"),RC=_n("model/rename-attribute"),AC=_n("model/edit-primary-key"),pF=_n("model/edit-dataclass-property"),PC=_n("model/rename-collection"),hF=(e,n)=>({toJSON:!0,extraProperties:n,dataClasses:e.map(r=>{var a;return{...r.data,extraProperties:{position:{x:r.position.x,y:r.position.y},panelColor:(a=r.data.extraProperties)==null?void 0:a.panelColor}}})});function Yf(e,n,r){const a=e;let i=0;for(;r[`${a}${i||""}`];)i++;return`${a}${i||""}`}const ql=e=>e.kind===Ia.RELATEDENTITY,Od=e=>e.kind===Ia.RELATEDENTITIES,vF=e=>Od(e)||ql(e),gw=xe("models/fetch",async()=>{try{return(await hr(en,{method:"POST",body:JSON.stringify({verb:Zt.GET_INFO,path:B_,as:"json",content:!0}),headers:new Headers({"Content-Type":"application/json"})})).content}catch(e){return e.message}}),Td=xe("models/save",async(e,{getState:n,rejectWithValue:r})=>{const{tabs:a}=n().root,i=a.find(u=>u.path===B_);if(!i)return r("Error while saving the model");try{const u=await hr(en,{method:"POST",body:JSON.stringify({verb:"save",path:i.path,content:i.content}),headers:new Headers({"Content-Type":"application/json"})});return vf(),{...u,path:i.path,content:e.content||{toJSON:!0,dataClasses:[],extraProperties:{}}}}catch{return r("Error while saving the model")}}),gF=xe("models/open",async(e,{dispatch:n,getState:r})=>{const{tabs:a}=r().root,i=a.find(u=>u.path==="models/main");if(i)return n(wn(i)),i;n(gw())}),mF=xe("model/rename-dataclass",async(e,{getState:n,dispatch:r})=>{var b,E;const{dataclassId:a,selectionId:i,name:u}=e;let c=n();const f=c.explorer.find(O=>O.path===Wt.CLASSES);if(!f)throw new Error("Classes folder was not found!");await r(Po(f.path)),c=n();const p={class:{found:!1,newNameTaken:!1,file:null,filename_update:u},entity:{found:!1,newNameTaken:!1,file:null,filename_update:`${u}Entity`},selection:{found:!1,newNameTaken:!1,file:null,filename_update:`${u}Selection`}};(E=(b=c.explorer.find(O=>O.path===Wt.CLASSES))==null?void 0:b.children)==null||E.forEach(O=>{O.name===p.class.filename_update&&(p.class.newNameTaken=!0),O.name===p.entity.filename_update&&(p.entity.newNameTaken=!0),O.name===p.selection.filename_update&&(p.selection.newNameTaken=!0),O.name===a?(p.class.found=!0,p.class.file=O):O.name===`${a}Entity`?(p.entity.found=!0,p.entity.file=O):O.name===i&&(p.selection.found=!0,p.selection.file=O)});const h=Object.entries(p).reduce((O,R)=>{const[C,k]=R;return k.found?k.newNameTaken?[...O,{type:"error",message:`Cannot rename ${C} file to ${k.filename_update} because it already exists. The existing file will be used instead!`}]:O:[...O,{type:"warning",message:`${a} ${C} file was not found`}]},[]);h.length>0&&r(Eo({message:"The following errors were encountered during dataclass rename:",views:{tips:h}}));const m=Object.values(p).filter(O=>O.found&&O.file&&!O.newNameTaken);await Promise.all(m.map(async O=>await r(Vs({file:O.file,newname:O.filename_update})))),m.length>0&&r(Po("Classes"))}),nf={DATACLASS_DELETE:"dataclass.delete",DATACLASS_DRAGGABLE:"dataclass.draggable"},yF={model:{dataClasses:{},collections:{},extraProperties:{}},draft:{dataClasses:{},collections:{},extraProperties:{}},flags:{[nf.DATACLASS_DELETE]:!0,[nf.DATACLASS_DRAGGABLE]:!0}},DC=qn({name:"Models",initialState:yF,reducers:{setModelFlag(e,n){e.flags={...e.flags,...n.payload}}},extraReducers(e){e.addCase(SC,({draft:{dataClasses:n}},r)=>{var c,f;const{dataclassID:a}=r.payload,i=Yf(a||"DataClass","className",n),u={className:i,collectionName:`${i}Selection`,attributes:[{name:"ID",kind:Ia.STORAGE,type:vw.LONG,scope:"public",indexKind:"auto",unique:!0,primKey:!0,autosequence:!0}],name:i,scope:"public",extraProperties:{position:{x:((c=r.payload.position)==null?void 0:c.x)||0,y:((f=r.payload.position)==null?void 0:f.y)||0}}};n[u.name]=u}).addCase(TC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a}=r.payload;n[a]&&(delete n[a],Object.values(n).forEach(u=>{u.attributes=u.attributes.filter(c=>c.type!==a&&c.type!==u.collectionName)}))}).addCase(OC,({draft:{dataClasses:n,collections:r}},a)=>{const{dataclassID:i,newName:u}=a.payload;if(!n[i]||n[u])return;const c=n[i].collectionName,f=Yf(`${u}Selection`,"collectionName",r);Object.values(n).forEach(p=>{p.className===i&&(p.className=u,p.name=u,p.collectionName=f),p.attributes.forEach(h=>{h.type===i?(h.type=u,h.path=u):h.type===c&&(h.type=f)})})}).addCase(xC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeName:i,attributeType:u,attributeKind:c,target:f}=r.payload;if(!n[a]||ek("name",i,n[a].attributes))return;const h={name:i,kind:c,type:u,exposed:!0,scope:"public"};if(c===Ia.RELATEDENTITY){if(!n[u])return;h.path=u;const b={name:Yf(n[u].collectionName,"name",n[u].attributes),type:n[a].collectionName,kind:Ia.RELATEDENTITIES,reversePath:!0,path:i,scope:"public",exposed:!0};n[u].attributes.push(b)}else if(c===Ia.RELATEDENTITIES){const m=n[u];if(!m)return;const b=m.attributes.find(bn("name",f));if(b){if(!ql(b)||b.type!==n[a].className)return}else{h.path=f,h.reversePath=!0,h.type=u;const E={name:f,kind:Ia.RELATEDENTITY,scope:"public",path:m.className,type:m.className,exposed:!0};m.attributes.push(E)}}n[a].attributes.push(h)}).addCase(RC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeID:i,newName:u}=r.payload,c=n[a].attributes.find(bn("name",i)),f=n[a].attributes.find(bn("name",u));!c||f||Object.values(n).forEach(({collectionName:p,attributes:h,className:m})=>{h.forEach(b=>{ql(c)&&Od(b)&&b.type===p&&b.path===i&&(b.path=u),m===a&&b.name===i&&(b.name=u)})})}).addCase(CC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,attributeID:i}=r.payload;if(!n[a])return;const u=n[a].attributes.find(bn("name",i));u&&(ql(u)&&Object.values(n).forEach(c=>{c.attributes=c.attributes.filter(f=>!(Od(f)&&f.type===c.collectionName&&f.path===u.name))}),n[a].attributes=n[a].attributes.filter(JM("name",i)))}).addCase(PC,({draft:{dataClasses:n,collections:r}},a)=>{const{dataclassID:i,collectionName:u}=a.payload;if(!n[i])return;const c=n[i].collectionName;r[u]||(n[i].collectionName=u,r[u]=n[i],delete r[c],Object.values(n).forEach(f=>f.attributes.forEach(p=>{p.type===c&&(p.type=u)})))}).addCase(AC,({draft:{dataClasses:n}},r)=>{const{dataclassID:a,newPrimKey:i}=r.payload;n[a]&&n[a].attributes.forEach(u=>{u.name===i?u.primKey=!0:u.primKey=!1})}),e.addCase(gw.fulfilled,(n,r)=>{var c;const a={},i={},u=r.payload.extraProperties||{};(c=r.payload.dataClasses)==null||c.forEach(f=>{a[f.name]=f,i[f.collectionName]=f}),n.draft.dataClasses=a,n.draft.collections=i,n.draft.extraProperties=u,n.model.dataClasses=a,n.model.collections=i,n.model.extraProperties=u}),e.addCase(Td.pending,()=>{}).addCase(Td.fulfilled,(n,r)=>{const a={},i={},u=r.payload.content.extraProperties||{};r.payload.content.dataClasses.forEach(c=>{a[c.name]=c,i[c.collectionName]=c}),n.draft.dataClasses=a,n.draft.collections=i,n.draft.extraProperties=u,n.model.dataClasses=a,n.model.collections=i,n.model.extraProperties=u})}}),{setModelFlag:bF}=DC.actions,_F=()=>Ua(e=>e.model.draft.dataClasses),wF=()=>Ua(e=>e.model.draft.collections),EF=e=>Ua(n=>n.model.draft.dataClasses[e]),SF=(e,n)=>Ua(r=>r.model.draft.dataClasses[e].attributes.find(bn("name",n))),OF=()=>Ua(e=>e.model.draft.extraProperties),TF=()=>{const e=Ua(i=>i.model.flags),n=i=>i in e?e[i]:void 0,r=n(nf.DATACLASS_DELETE),a=n(nf.DATACLASS_DRAGGABLE);return{deleteDataclass:r,draggableDataclass:a,flags:e}},xF=DC.reducer;function m1(e,n){const r=e.tabs.find(({path:a})=>a===oi);r&&(r.flags.touched=n)}const IC={SIDEBAR_SECTION_RESIZABLE:"sidebar.section.resizable"},{webforms:$f}=nu(),MC={[IC.SIDEBAR_SECTION_RESIZABLE]:!0},kC={...$f,templates:{data:[],selectedGroup:""},datasources:{...G_.webforms.datasources,...$f==null?void 0:$f.datasources},flags:MC},$C=qn({name:"webforms",initialState:kC,reducers:{toggleInspector:(e,n)=>{const{type:r}=n.payload;e.inspector[r].active=!e.inspector[r].active,e.inspector[r].active||(e.inspector[r].data=void 0)},inspect:(e,n)=>{const{type:r,data:a}=n.payload;e.inspector[r].active&&(e.inspector[r].data=a)},addComponent:(e,n)=>{e.components.push(n.payload)},editComponent:(e,n)=>{const{id:r,changes:a}=n.payload;e.components=e.components.map(i=>i.id===r?{...i,...a}:i)},removeComponent:(e,n)=>{const{payload:r}=n,a=e.components.findIndex(i=>i.id===r);a!==-1&&e.components.splice(a,1)},setSelectedGroup:(e,n)=>{e.templates.selectedGroup=n.payload.selectedGroup},setTemplatesData:(e,n)=>{e.templates.data=n.payload},setTemplateData:(e,n)=>{const{group:r,components:a}=n.payload,i=e.templates.data.find(u=>u.group===r);i&&(i.components=a)},setDatasourcesTheme:(e,n)=>{e.datasources.theme=n.payload},setWebformsFlag(e,n){e.flags={...e.flags,...n.payload}}},extraReducers(e){e.addCase(BC.fulfilled,(n,r)=>{n.components=r.payload})}}),{toggleInspector:CF,inspect:RF,addComponent:NC,editComponent:jC,removeComponent:LC,setSelectedGroup:AF,setTemplatesData:FC,setTemplateData:WC,setDatasourcesTheme:PF,setWebformsFlag:DF}=$C.actions,IF=$C.reducer,mw=Bt.curry((e,n)=>{var i,u;const r={...n.sharedDatasources.sources},a=(u=((i=n.root.tabs.find(bn("path",e)))==null?void 0:i.content).metadata)==null?void 0:u.datasources;return a&&(r[e]=a),Bt.cloneDeep(r)}),MF=xe("webforms/fetchTemplates",async(e,{dispatch:n,getState:r})=>{const{data:a}=r().webforms.templates;if(!Bt.isEmpty(a))return a;try{const u=await(await fetch(`https://raw.githubusercontent.com/4d/Web-studio-TIPS/gh-build/build/index.json?t=${Date.now()}`)).json();return n(FC(u)),u}catch{return[]}}),kF=xe("webforms/fetchTemplate",async({name:e},{dispatch:n,getState:r})=>{const{data:a}=r().webforms.templates,i=a.find(u=>u.group===e);if(i&&!Bt.isEmpty(i.components))return i.components;try{const c=await(await fetch(`${i==null?void 0:i.link}?t=${Date.now()}`)).json();return n(WC({group:e,components:c})),c}catch{return[]}}),BC=xe("webforms/fetchCraftedComponents",async(e,{rejectWithValue:n})=>{try{return(await ni({path:"WebForms/crafted_components.json",verb:Zt.GET_INFO,content:!0,as:"json"})).content}catch{return n("Error while loading the crafted components")}}),$F=xe("webforms/addCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(NC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while adding the crafted component")}}),NF=xe("webforms/editCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(jC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while editing the crafted component")}}),jF=xe("webforms/removeCraftedComponent",async(e,{dispatch:n,rejectWithValue:r,getState:a})=>{try{n(LC(e));const{webforms:{components:i}}=a();H_(i)}catch{return r("Error while removing the crafted component")}}),yw=xe("datasources/add-datasource",async(e,{getState:n,rejectWithValue:r})=>{var a,i;try{const u=n(),c=e.datasource,f=!!c.namespace,p=[];if(f){const h={...u.sharedDatasources.sources,[c.namespace]:[...u.sharedDatasources.sources[c.namespace],c]};p.push(...h[c.namespace]),await ri(h)}else(((i=(a=u.root.tabs.find(bn("path",e.path)).content)==null?void 0:a.metadata)==null?void 0:i.datasources)||[]).push(c);return{list:p,path:e.path,namespace:e.datasource.namespace}}catch{console.error("Error while adding the datasource",e.datasource.id),r("Error while adding the datasource")}}),bw=xe("datasources/edit-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const{namespace:a,path:i}=e,u=n(),c=!!e.namespace,f=mw(i,u);let p=Bt.defaultTo(f[a||i],[]);return p=p.map(h=>h.id===e.id?{...h,[e.property]:e.value}:h),c&&await ri({...u.sharedDatasources.sources,[e.namespace]:p}),{list:p,path:e.path,namespace:e.namespace}}catch{r(`Error while editing datasource ${e.id}`)}}),LF=e=>e.type===Ks.fulfilled.type,Ks=xe("datasources/rename-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const a=n(),i=!!e.namespace,u=e.namespace||e.path,c=mw(e.path,a),f=Bt.defaultTo(c[u],[]),p=new RegExp(`^${e.id}\\b`,"");if(f.forEach(h=>{var b;const m=(U_(h)||!bT(h))&&h.from&&p.test(h.from);e.updateRefs&&((b=h.events)==null||b.forEach(E=>{var O,R,C,k,j;switch(E.type){case"method":{const F=E;F.params.forEach(D=>{D.datasource&&Object.assign(D,{datasource:D.datasource.replace(new RegExp(`^${e.id}`,""),e.new_name)})}),F.returns&&Object.assign(F.returns,{datasource:(R=(O=F.returns)==null?void 0:O.datasource)==null?void 0:R.replace(new RegExp(`^${e.id}`,""),e.new_name)});return}case"simple-action":{const F=E;F.datasource&&Object.assign(F.datasource,{name:(C=F.datasource.name)==null?void 0:C.replace(new RegExp(`^${e.id}`,""),e.new_name),from:(k=F.datasource.from)==null?void 0:k.replace(new RegExp(`^${e.id}`,""),e.new_name),target:(j=F.datasource.target)==null?void 0:j.replace(new RegExp(`^${e.id}`,""),e.new_name)});return}default:return}})),h.id===e.id?h.id=e.new_name:m&&h.from&&(h.from=h.from.replace(new RegExp(`^${e.id}`,""),e.new_name))}),e.updateRefs){const h=fd({id:e.id,namespace:e.namespace}),m=fd({id:e.new_name,namespace:e.namespace});hT.next({path:e.path??"",action:F_.RENAME,old_reference:h,new_reference:m,is_shared:i})}return i&&await ri({...a.sharedDatasources.sources,[e.namespace]:f}),{list:f,path:e.path,namespace:e.namespace}}catch{return r(`Error while renaming datasource ${e.namespace}:${e.id}`)}}),Vl=xe("datasources/delete-datasource",async(e,{getState:n,rejectWithValue:r})=>{try{const a=n(),i=!!e.namespace,u=e.namespace||e.path,f=mw(e.path,a)[u].filter(ZM(e.id));return i&&await ri({...a.sharedDatasources.sources,[e.namespace]:f}),{list:f,path:e.path,namespace:e.namespace}}catch{return r(`Error while removing datasource ${e.id}`)}}),y1=nu(),FF={filesLoading:!1,tabs:y1.tabs||[],activeTab:y1.activeTab,recent:y1.recent||[]},_w=qn({name:"root",initialState:FF,reducers:{setPanelState(e,n){const{path:r,...a}=n.payload;e.tabs.forEach(i=>{i.path===r&&(i.view||(i.view={panel:{isOpen:!1,type:"",current:""}}),Object.assign(i.view.panel,a))})},addDataSource(e,n){var u;const{payload:{path:r,datasourceDef:a}}=n,i=e.tabs.find(c=>c.path===r);i&&(i.content.metadata.datasources=i.content.metadata.datasources||[],(u=i.content.metadata.datasources)!=null&&u.find(f=>f.id===a.id)||(i.content.metadata.datasources=[...i.content.metadata.datasources,{...a,events:[]}],i.flags={...i.flags,touched:!0}))},openSettingsTab(e){const n={date:new Date().toISOString(),flags:{},view:{panel:{isOpen:!1,type:"",current:""}},extra:{editor:{key:"editors:settings"}},name:"Settings",path:oi,type:le.SETTINGS,initialContent:{},content:{}};let r=e.tabs.find(a=>a.path===n.path);if(r||(e.tabs.push(n),r=e.tabs[e.tabs.length-1]),e.activeTab!==n.path){const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);e.activeTab=n.path,r.weight=((a==null?void 0:a.weight)||0)+1}},removeDataSource(e,n){const{path:r,datasourceID:a}=n.payload;e.tabs=e.tabs.map(i=>i.path===r?{...i,flags:{...i.flags,touched:!0},content:{...i.content,metadata:{...i.content.metadata,datasources:i.content.metadata.datasources.filter(u=>u.id!==a)}}}:i)},setDataSources(e,n){const{payload:{path:r,datasourceArr:a}}=n;e.tabs=e.tabs.map(i=>{var u;return i.path===r?{...i,flags:{...i.flags,touched:!0},content:{...i.content,metadata:{...(u=i.content)==null?void 0:u.metadata,datasources:a}}}:i})},setTabs(e,n){e.tabs=n.payload},closeTab(e,n){const r=n.payload;e.tabs.splice(r,1);const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);e.activeTab=(a==null?void 0:a.path)||""},closeOthers(e,n){e.tabs=e.tabs.filter(r=>r.path===n.payload),e.activeTab=n.payload},closeAllTabs(e){e.tabs=[],e.activeTab=""},closeRightTabs(e,n){e.tabs.splice(n.payload+1),e.activeTab=e.tabs[n.payload].path},closeLeftTabs(e,n){e.tabs.splice(0,n.payload)},closeSavedTabs(e){e.tabs=e.tabs.filter(({flags:{touched:r}})=>r);const n=e.tabs.reduce((r,a)=>(a==null?void 0:a.weight)>((r==null?void 0:r.weight)||0)?a:r,null);e.activeTab=(n==null?void 0:n.path)||""},selectTab(e,n){const r=e.tabs.find(({path:i})=>i===n.payload);if(!r||e.activeTab===n.payload)return;const a=e.tabs.reduce((i,u)=>(u==null?void 0:u.weight)>((i==null?void 0:i.weight)||0)?u:i,null);r.weight=a?(a.weight||0)+1:1,e.activeTab=n.payload},openTabUnselected(e,n){const r=n.payload;let a=e.tabs.find(({path:u})=>r.path===u);a||(e.tabs.push(r),a=e.tabs[e.tabs.length-1]);const i=e.tabs.reduce((u,c)=>(c==null?void 0:c.weight)>((u==null?void 0:u.weight)||0)?c:u,null);a.weight=i?(i.weight||0)+1:1,a.extra={...a.extra,...r.extra}},selectTabByReference(e,n){const r=n.payload;let a=e.tabs.find(({path:i})=>r.path===i);if(a||(e.tabs.push(r),a=e.tabs[e.tabs.length-1]),e.activeTab!==r.path){const i=e.tabs.reduce((u,c)=>(c==null?void 0:c.weight)>((u==null?void 0:u.weight)||0)?c:u,null);e.activeTab=r.path,a.weight=((i==null?void 0:i.weight)||0)+1}a.extra={...a.extra,...r.extra},a.flags={...a.flags||{},...r.flags||{}}},setContent(e,n){const{path:r,content:a,contentPath:i}=n.payload;e.tabs=e.tabs.map(u=>{if(u.path!==r)return u;let c=!1;if(typeof a=="string")c=u.initialContent!==a;else{const f=JSON.stringify(Bt.get(u.initialContent,i||"",u.initialContent)),p=JSON.stringify(Bt.get(a,i||"",a));c=f!==p}return a&&typeof a=="object"&&(i?Bt.set(u.content,i,a):u.content=a),typeof a=="string"&&(u.content=a),{...u,flags:{...u.flags,touched:c}}})},setTabFlags(e,n){const{path:r,flags:a}=n.payload;e.tabs=e.tabs.map(i=>i.path===r?{...i,flags:{...i.flags,...a}}:i)},setTabsFlags(e,n){const{tabs:r,flags:a}=n.payload;e.tabs=e.tabs.map(i=>r.includes(i.path)?{...i,flags:{...i.flags,...a}}:i)},setTabExtra(e,n){const{path:r,extra:a,flags:i}=n.payload;e.tabs=e.tabs.map(u=>u.path===r?{...u,extra:{...u.extra,...a},flags:i?{...u.flags,...i}:u.flags}:u)},addWebFormStyles(e,n){const{path:r,styles:a=[]}=n.payload,i=e.tabs.find(u=>u.path===r);if(i){const u=i.content.metadata.styles.map(({name:f})=>f),c=a.filter(({name:f})=>!u.includes(f));i.content.metadata.styles=[...i.content.metadata.styles,...c].map(({scope:f,...p})=>({...p}))}},changeTabEditor(e,n){return e.tabs=e.tabs.map(r=>r.path===n.payload.path?n.payload:r),e}},extraReducers:e=>{e.addCase(vC.fulfilled,(n,r)=>{if(!r.payload)return;const{content:a,line:i,path:u}=r.payload,c=n.tabs.find(f=>f.path===u);if(c&&typeof c.content=="string"){const f=c.content.trim().split(`
|
|
279
279
|
`);f.splice(i,0,a),c.content=f.join(`
|
|
280
280
|
`)}}),e.addCase(Ys.pending,(n,r)=>{const{tab:a}=r.meta.arg;switch(a.type){case le.CLASS:case le.METHOD:Xa.next({action:ka.WILL_SAVE,payload:{filePath:a.path}});break}}),e.addCase(Ys.fulfilled,(n,r)=>{if(!r.payload)return;const a=n.tabs.find(({path:i})=>{var u;return i===((u=r.payload)==null?void 0:u.path)});if(a){switch(a.content=r.payload.content,a.date=r.payload.date,a.initialContent=r.payload.initialContent,a.flags.touched=!1,a.flags.old=!1,a.type){case le.CLASS:case le.METHOD:Xa.next({action:ka.DID_SAVE,payload:{filePath:a.path,content:a.content}});break}r.payload.errors.length>0&&Ao.next({kind:"error",message:r.payload.errors})}}),e.addCase(Ys.rejected,(n,r)=>{Ao.next({kind:"danger",message:"Cannot save file"})}),e.addCase(mC.fulfilled,(n,r)=>{const a=[...r.payload.files];n.tabs=n.tabs.map(i=>{if([le.CLASS,le.METHOD].includes(i.type)){const u=a.find(c=>c.name===i.name&&c.type===i.type);if(u){const c=new Date(i.date),f=new Date(u.date);if(c.getTime()!==f.getTime())return{...i,flags:{...i.flags,old:!0}}}}return i})}),e.addCase(l_.pending,(n,r)=>{n.tabs=n.tabs.map(a=>a.path===r.meta.arg.path?{...a,flags:{...a.flags,loading:!0}}:a)}),e.addCase(l_.fulfilled,(n,r)=>{const a=r.payload;if(a){const i=r.meta.arg;n.tabs=n.tabs.map(u=>{if(u.name===i.name&&u.type===i.type){const c=u.extra||{};return i.type===le.METHOD&&(c.attributes=z_(a.content),a.content=wT(a.content,{})),{...u,initialContent:a.content,content:a.content,date:a.date,flags:{},extra:c}}return u})}}),e.addCase(fw.fulfilled,(n,r)=>{if(!r.payload)return;const{line:a,offset:i}=r.meta.arg,u=n.tabs.find(({path:c})=>{var f;return c===((f=r.payload)==null?void 0:f.path)});u&&(u.extra={...u.extra,initialLineInfo:{line:a,offset:i,lastModification:Date.now()}})}),e.addCase(gC.fulfilled,(n,r)=>{if(!r.payload)return;const{selection:a}=r.meta.arg,i=n.tabs.find(({path:u})=>{var c;return u===((c=r.payload)==null?void 0:c.path)});i&&(i.extra={...i.extra,initialSelectionInfo:{selection:a,lastModification:Date.now()}})}),e.addCase(Vs.fulfilled,(n,r)=>{r.payload.new!==r.payload.old&&(n.tabs=[...n.tabs].map(a=>a.path===r.payload.old.path?{...a,path:r.payload.new.path,name:r.payload.new.name}:a),n.activeTab===r.payload.old.path&&(n.activeTab=r.payload.new.path))}),e.addCase(c_.pending,(n,r)=>{const a=r.meta.arg,i=`${a.path}${a.ext?`.${a.ext}`:""}`;switch(a.ext){case"4dm":case"4qs":Xa.next({action:ka.WILL_DELETE,payload:{filePath:i}});break}}),e.addCase(c_.fulfilled,(n,r)=>{const{deleted:a,node:i}=r.payload;if(!a)return;const u=`${i.path}${i.ext?`.${i.ext}`:""}`;switch(i.ext){case"4dm":case"4qs":Xa.next({action:ka.DID_DELETE,payload:{filePath:u}});break}if(n.tabs=n.tabs.filter(c=>c.path!==u),n.recent=n.recent.filter(({path:c})=>u!==c),n.tabs.length){n.activeTab=n.tabs[n.tabs.length-1].path;return}n.activeTab=""}),e.addCase(Gl.fulfilled,(n,r)=>{const{draggedNode:a,newLocation:i}=r.meta.arg;if(n.tabs.find(u=>u.path===`${a.path}${a.ext?`.${a.ext}`:""}`))return n.tabs=n.tabs.map(u=>u.path===`${a.path}${a.ext?`.${a.ext}`:""}`?{...u,path:`${i.path}/${a.name}.${a.ext}`}:u),n.recent=n.recent.map(u=>u.path===`${a.path}${a.ext?`.${a.ext}`:""}`?{...u,path:`${i.path}/${a.name}.${a.ext}`}:u),n.activeTab=`${i.path}/${a.name}.${a.ext}`,n}),e.addCase(Td.fulfilled,(n,r)=>{const a=n.tabs.find(i=>i.path===r.payload.path);a&&(a.flags.touched=!1,a.date=r.payload.date,a.content=r.payload.content,a.initialContent=r.payload.content)}),e.addCase(yC.fulfilled,(n,r)=>{var u;if(!((u=r.payload)!=null&&u.path))return;const a=n.tabs.find(bn("path",r.payload.path));if(!a)return;a.content=a.content+`
|
|
281
281
|
|