@pb33f/cowboy-components 0.7.11 → 0.7.12
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.
|
@@ -58,7 +58,14 @@ export class BrokerController extends EventTarget {
|
|
|
58
58
|
const memVersion = localStorage.getItem("pb33f-doctor-version");
|
|
59
59
|
if (memVersion) {
|
|
60
60
|
if (this.currentVersion != memVersion) {
|
|
61
|
-
this.doc.
|
|
61
|
+
if (!this.doc.authController.authenticated) {
|
|
62
|
+
this.doc.nukeWorkspaceHandler();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.doc.bagManager.resetBags();
|
|
66
|
+
localStorage.removeItem("pb33f-doctor-version");
|
|
67
|
+
window.location.reload();
|
|
68
|
+
}
|
|
62
69
|
return;
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -12400,7 +12400,7 @@ ${w8t(h)}`}}))}render(){var M,E,I,N,T;let h=A.html``,c=A.html``,l=A.html``,d=A.h
|
|
|
12400
12400
|
color: var(--error-color);
|
|
12401
12401
|
}
|
|
12402
12402
|
|
|
12403
|
-
`;class zIt extends EventTarget{constructor(c){super(),this.doc=c}rolodexTreeNodeClicked(c){var p;const l=(p=this.doc.rolodexFilesBag)==null?void 0:p.get(HP),d=m=>{var T,j,q,ne,ie,re,ee;this.doc.rolodexActivePath=c.detail.path,this.doc.rolodexActiveHash=c.detail.nodeHashId,this.doc.editor.setValue(m.instance,!0),this.doc.editor.setCurrentPath(this.doc.rolodexActivePath),this.doc.modelController.fetchRefMap(this.doc.rolodexActivePath);const w=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);w&&this.doc.editor.setMarkers(w);let k="yaml";const M=(j=(T=c.detail)==null?void 0:T.path)==null?void 0:j.split(".").pop();if(M)switch(M){case Ne.JSON:k=Ne.JSON;break;case Ne.GO:k=Ne.GO;break;case Ne.PY:k="python";break;case Ne.JS:k="javascript";break;case Ne.TS:k="typescript";break;case Ne.PHP:k=Ne.PHP;break;case Ne.XML:k=Ne.XML;break;case Ne.JAVA:k=Ne.JAVA;break;case Ne.RB:k="ruby";break;case Ne.RS:k="rust";break;case Ne.C:k=Ne.C;break;case Ne.CPP:k=Ne.CPP;break;case Ne.CS:k="csharp";break;case Ne.MD:k="markdown";break}const E=(q=this.doc.rolodexStateBag)==null?void 0:q.get(u2);if(E)E.activePath=c.detail.path,E.activeHash=c.detail.nodeHashId,E.activeLanguage=k,E.activeNode=m,E.rootPath=this.doc.rolodexRootPath,(ne=this.doc.rolodexStateBag)==null||ne.set(u2,E);else{const X={activePath:c.detail.path,activeHash:c.detail.nodeHashId,activeLanguage:k,activeNode:m,rootHash:this.doc.rolodexRootHash,rootPath:this.doc.rolodexRootPath};(ie=this.doc.rolodexStateBag)==null||ie.set(u2,X)}this.doc.editor.switchLanguage(k);let I=1,N=0;return c.detail.line&&(I=c.detail.line),c.detail.column&&(N=c.detail.column),(re=this.doc.editor.editor)==null||re.setPosition({lineNumber:I,column:N}),(ee=this.doc.editor.editor)==null||ee.revealLineInCenter(I,N),c.detail.path&&this.doc.rolodexTree.openNodeByPath(c.detail.path),k};sh.queryRolodex(c.detail.nodeHashId,c.detail.path).then(m=>{var w,k,M;if(this.doc.editor.showBreadcrumb=!0,(w=this.doc.referenceMapBag)==null||w.reset(),d(m.rolodexRoot),c.detail.path&&(l&&!l.files[c.detail.path]&&(l.files[c.detail.path]=m.rolodexRoot,(k=this.doc.rolodexFilesBag)==null||k.set(HP,l)),!l)){const E={files:{[c.detail.path]:m.rolodexRoot}};(M=this.doc.rolodexFilesBag)==null||M.set(HP,E)}})}explorerNodeClicked(c,l=!0){let d=!1,p;if(this.doc.explorer.nodeComponents.forEach(m=>{if(m.id===c.detail.nodeId){let w;l&&(w=this.doc.renderedNodeMap.get(m.id),w&&!this.doc.firstRun&&(this.doc.renderedNode.node=w)),this.doc.selectedNodeHashId=m.body.node.idHash,m.body.active=!0,this.doc.activeNode=m.body.node,this.doc.explorer.activeNode=m.body.node,d=!0,l&&(p=w),c.detail.noState||this.doc.addClickTrack(m.body.node)}else m.body.active=!1}),!d){const m=this.doc.nodeIdMap.get(c.detail.nodeId);m&&(this.doc.selectedNodeHashId=m.idHash,this.doc.activeNode=m,this.doc.explorer.activeNode=m,this.doc.explorer.equalizer.activeNode=m)}p&&(this.doc.pendingLine=p.keyLine),this.doc.modelTree.explorerClicked(c.detail.nodeId),this.doc.firstRun||this.doc.viewerPanel.click(),this.doc.explorer.requestUpdate()}modelTreeNodeClicked(c){var d,p,m;let l=this.doc.nodeIdMap.get(c.detail.nodeId);if(l||(l=this.doc.nodeIdHashMap.get(c.detail.nodeId)),l){if(l.origin&&l.origin!=this.doc.rolodexActivePath&&l.origin!="/root.yaml"&&l.origin!="root.yaml"){let k="",M="";const E=(d=this.doc.rolodexFilesBag)==null?void 0:d.get(HP);E&&l.origin&&E.files[l.origin]&&(k=E.files[l.origin].idHash,M=l.origin),this.explorerNodeClicked(c,!0),this.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{nodeHashId:k,path:M}}));return}l.idHash!=="root"&&((p=this.doc.editor.editor)==null||p.setPosition({lineNumber:l.keyLine,column:0}),(m=this.doc.editor.editor)==null||m.revealLineInCenter(l.keyLine)),this.doc.explorerVisible&&this.doc.explorer.moveToNode(l,c.detail.first),this.doc.activeNode=l,c.detail.changes&&(l.timeline=c.detail.changes),this.doc.explorer.activeNode=l,this.doc.explorer.equalizer.activeNode=l;const w=structuredClone(this.doc.renderedNodeMap.get(l.id));w?(c.detail.changes&&(w.timeline=c.detail.changes),this.doc.renderedNode.node=w):alert("no id found"),c.detail.noState||(this.doc.addClickTrack(l),c.detail.noState=!0),this.explorerNodeClicked(c,!0),this.doc.firstRun?this.doc.firstRun=!1:this.doc.viewerPanel.click()}else this.doc.sendToast({id:crypto.randomUUID(),title:"Unable to load change model",type:ys.WARNING,body:"There is no-longer a model with the path `"+c.detail.nodeId+"` in the document"}),console.error("cannot navigate to node, path not found",c.detail.nodeId)}explorerReferenceClicked(c){let l="";if(this.doc.explorer.nodeComponents.forEach(d=>{var p,m;if(d.body.node.nodePath===c.detail.nodePath){const w=this.doc.renderedNodeMap.get(d.body.node.id);w&&((p=this.doc.editor.editor)==null||p.setPosition({lineNumber:w.keyLine,column:0}),(m=this.doc.editor.editor)==null||m.revealLineInCenter(w.keyLine),this.doc.renderedNode.node=w,l=d.body.node.id,this.doc.explorer.moveToNode(d.body.node),this.doc.activeNode=d.body.node,this.doc.explorer.activeNode=d.body.node,this.doc.explorer.equalizer.activeNode=d.body.node),d.body.active=!0}else d.body.active=!1}),l&&(this.doc.modelTree.explorerClicked(l),this.doc.explorer.requestUpdate(),this.doc.viewerPanel.click()),c.detail.nodePath){let d=c.detail.nodePath;!d.startsWith("/")&&!d.includes("#")&&(d=this.doc.rolodexRootPath.substring(0,this.doc.rolodexRootPath.lastIndexOf("/")+1)+d),d.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{path:d}}))}}documentReferenceClicked(c){var E,I;let l="",d,p=1,m=c.detail.jsonPath,w="",k="",M="";if(c.detail.jsonPath.includes("||")&&(l=c.detail.jsonPath.split("||")[1],m=c.detail.jsonPath.split("||")[0],d=parseInt(l.split(":")[0]),p=parseInt(l.split(":")[1]),w=c.detail.jsonPath.split("||")[2],w!=""&&(k=w.split("#")[0]),M=c.detail.jsonPath.split("||")[3]),(E=this.doc.editor.editor)==null||E.setPosition({lineNumber:d,column:p}),(I=this.doc.editor.editor)==null||I.revealLineInCenter(d),this.doc.nodeIdMap.has(m)){const N=this.doc.nodeIdMap.get(m);if(N){if(this.doc.nodeIdHashMap.has(N.idHash)){const T=this.doc.renderedNodeMap.get(N.id);T&&(this.doc.renderedNode.node=T,this.doc.modelTree.explorerClicked(N.id),c.detail.noState||this.doc.addRefTrack(c.detail.jsonPath))}}else this.doc.toastManager.addToastManually({id:crypto.randomUUID(),type:ys.INFO,title:"Reference not found",body:`Something went wrong, '${m}' not found`})}else this.doc.rolodexActivePath!=null&&this.doc.rolodexActivePath!=k&&sh.queryRolodex(M,k).then(N=>{var T,j;if(this.doc.editor.showBreadcrumb=!0,this.doc.rolodexActivePath=k,this.doc.editor.clearDecorations(),this.doc.editor.setValue(N.rolodexRoot.instance,!0),(T=this.doc.editor.editor)==null||T.setPosition({lineNumber:d,column:1}),(j=this.doc.editor.editor)==null||j.revealLineInCenter(d),this.doc.rolodexTree.explorerClicked(M),this.doc.editor.setCurrentPath(k),this.doc.modelController.fetchRefMap(k),this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const q=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);q&&this.doc.editor.setMarkers(q)}}).catch(N=>{console.error("rolodex query failed",N)})}}const Iz="doctor-service",_ne="spec-stream",Rne="credit-stream",Bne="/q/";function HIt(h){return typeof h=="object"&&h!==null&&typeof h.broker=="string"}var Tke=(h=>(h.WhoAmI="whoami",h))(Tke||{});class UIt extends EventTarget{constructor(c){super(),this.useTLS=!1,this.doc=c,this.bus=c.bus,this.doctorServiceChannel=this.bus.createChannel(Iz),this.specStreamChannel=this.bus.createChannel(_ne),this.creditStreamChannel=this.bus.createChannel(Rne),this.bus.mapChannelToBrokerDestination(Bne+Iz,Iz),this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.busPort=sessionStorage.getItem("pb33f-doctor-port"),this.busHost=sessionStorage.getItem("pb33f-doctor-host"),this.busPort||(this.busPort="443"),this.busHost||(this.busHost="doctor.pb33f.io");const l=sessionStorage.getItem("pb33f-doctor-tls");l&&l=="true"&&(this.useTLS=!0)}connectToBroker(){let c="ws://";this.useTLS&&(c="wss://");const l={brokerURL:c+this.busHost+":"+this.busPort+"/ranch",heartbeatIncoming:0,heartbeatOutgoing:0,onConnect:()=>{console.log("💊 Connected to the %cOpenAPI Doctor%c, we are ready to communicate.","background: #0d1117; color: #62C4FFFF; font-weight: bold","color: default"),this.bus.mapChannels(),this.whoAmI()}};this.bus.connectToBroker(l)}doctorServiceHandler(){return c=>{var l;((l=c.payload)==null?void 0:l.payload)!=null&&HIt(c.payload.payload)&&(this.brokerConnectionId=c.payload.payload.broker,this.doc.authController.associateBroker(this.brokerConnectionId).then(()=>{const d=c.payload.payload.version;d!==""&&(this.currentVersion=d);const p=localStorage.getItem("pb33f-doctor-version");if(p){if(this.currentVersion!=p){this.doc.nukeWorkspaceHandler();return}}else localStorage.setItem("pb33f-doctor-version",this.currentVersion);console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you. [v"+d+"]","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor()}))}}whoAmI(){this.bus.publish({destination:"/p/q/"+Iz,body:JSON.stringify({request:Tke.WhoAmI})})}startTheDoctor(){this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bus.mapChannelToBrokerDestination(Bne+_ne,_ne),this.bus.mapChannelToBrokerDestination(Bne+Rne,Rne),this.doc.boostrap()}specStreamHandler(){return c=>{var l,d;if(((l=c.payload)==null?void 0:l.payload)!=null){const p=atob(c.payload.payload);this.doc.docBag&&this.doc.docBag.set(BM,p),(d=this.doc.editor)==null||d.setValue(p,!0),this.doc.requestUpdate()}}}creditStreamHandler(){return c=>{var l;if(((l=c.payload)==null?void 0:l.payload)!=null){const d=parseInt(c.payload.payload);this.doc.creditTicker.credits=d,this.doc.dispatchEvent(new CustomEvent(e8e,{bubbles:!0,composed:!0,detail:{credits:d}}))}}}}class qIt extends EventTarget{constructor(c){super(),this.doc=c}rolodexRootFileSelected(c){var d,p,m;this.doc.rolodexActivePath=c.detail.path,this.doc.rolodexActiveHash=c.detail.nodeHashId,this.doc.rolodexRootPath=c.detail.path,this.doc.importDisabled=!0;const l=(d=this.doc.rolodexStateBag)==null?void 0:d.get(u2);if(l)l.activePath=c.detail.path,l.activeHash=c.detail.nodeHashId,l.rootPath=c.detail.path,l.rootHash=c.detail.nodeHashId,(p=this.doc.rolodexStateBag)==null||p.set(u2,l);else{const w={activePath:c.detail.path,activeHash:c.detail.nodeHashId,rootPath:c.detail.path,rootHash:c.detail.nodeHashId};(m=this.doc.rolodexStateBag)==null||m.set(u2,w)}c.detail.nodeHashId&&(this.doc.rolodexRootHash=c.detail.nodeHashId),c.detail.content&&(this.doc.rolodexNeedsReset=!0,this.doc.editor.setValue(c.detail.content,!0),this.doc.diagnosticController.lintSpec(c.detail.content))}buildRolodexResultMap(c){return this.doc.rolodexProblemMap.clear(),c.forEach(l=>{if((l.sourceLocation==="/root.yaml"||l.sourceLocation==="root.yaml")&&(l.sourceLocation="root"),this.doc.rolodexProblemMap.has(l.sourceLocation)){const d=this.doc.rolodexProblemMap.get(l.sourceLocation);d&&(d.push(l),l.sourceLocation?this.doc.rolodexProblemMap.set(l.sourceLocation,d):this.doc.rolodexRootPath?this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,d):this.doc.rolodexProblemMap.set("root",d))}else if(l.sourceLocation)this.doc.rolodexProblemMap.set(l.sourceLocation,[l]);else if(this.doc.rolodexRootPath){const d=this.doc.rolodexProblemMap.get(this.doc.rolodexRootPath);d?(d.push(l),this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,d)):this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,[l])}else{const d=this.doc.rolodexProblemMap.get("root");d?(d.push(l),this.doc.rolodexProblemMap.set("root",d)):this.doc.rolodexProblemMap.set("root",[l])}}),this.doc.rolodexProblemMap}queryRolodex(c){sh.queryRolodex().then(l=>{var p,m,w,k;if(this.doc.modelController.fetchRefMap(c),this.doc.editor.showBreadcrumb=!0,this.doc.rolodexNeedsReset=!1,l.rolodexRoot.treeExpanded=!0,this.doc.rolodexTree.isRolodex=!0,this.doc.rolodexTree.node=l.rolodexRoot,this.doc.rolodexRoot=l.rolodexRoot,this.doc.rolodexActiveHash&&(this.doc.rolodexTree.pendingNavigationHash=this.doc.rolodexActiveHash),this.doc.rolodexActivePath&&(this.doc.rolodexTree.pendingNavigationPath=this.doc.rolodexActivePath),((p=l.rolodexRoot.nodes)==null?void 0:p.length)>0&&(this.doc.importDisabled=!0),(m=this.doc.rolodexResponseBag)==null||m.set(zne,l),!((w=this.doc.rolodexStateBag)==null?void 0:w.get(u2))){const M={activePath:this.doc.rolodexActivePath,rootPath:this.doc.rolodexRootPath};(k=this.doc.rolodexStateBag)==null||k.set(u2,M)}this.doc.requestUpdate()}).catch(l=>{console.info("rolodex returned and error:",l.detail)})}}class GIt extends EventTarget{constructor(c){super(),this.doc=c}specChanged(c){if(this.doc.editorMap.get(c.detail.id)&&c.detail.id==="ruleset-editor"){this.doc.ruleController.rulesetManuallyChanged();return}this.doc.docBag&&this.doc.docBag.set(BM,c.detail.content),this.doc.autoDiagnose&&(clearTimeout(this.doc.bounceId),this.doc.bounceId=window.setTimeout(()=>{this.doc.diagnosticController.lintSpec(c.detail.content)},this.doc.debounceTime))}specClicked(c){var l,d,p;if(this.doc.detailsDrawer.close(),this.doc.selectedEditorTab=="spec"){let m=!1;for(let k=0;k<((l=this.doc.problems)==null?void 0:l.length);k++)if(this.doc.problems[k].startLineNumber===c.detail.line){this.doc.problemList.lineClicked(c.detail.line,!0),this.doc.controlTabGroup.show(ju.Problems),this.doc.sidebarClosed&&this.doc.toggleSidebar(),m=!0;break}const w=(d=this.doc.graphBag)==null?void 0:d.get($z);if(w&&w.graphMap&&c.detail.line){const k=w.graphMap[c.detail.line];if(k){this.doc.modelTree.explorerClicked(k);const M=this.doc.renderedNodeMap.get(k);M&&(this.doc.renderedNode.node=M),m||this.doc.viewerPanel.click();const E=this.doc.nodeIdHashMap.get(k);E&&(this.doc.explorer.activeNode=E,this.doc.explorer.equalizer.activeNode=E)}}}if(this.doc.selectedEditorTab==ju.Ruleset){const m=(p=this.doc.sessionRulesetMapBag)==null?void 0:p.get(Dz);if(m!=null&&m.rulesMap){for(let w=0;w<m.rulesMap.length;w++)if(m.rulesMap[w].line===c.detail.line){this.doc.controlTabGroup.show(ju.Ruleset),this.doc.sidebarClosed&&this.doc.toggleSidebar();break}}}}}class WIt extends EventTarget{constructor(c){super(),this.doc=c}ruleClicked(c){var d,p,m;const l=(d=this.doc.sessionRulesetMapBag)==null?void 0:d.get(Dz);if(l){const w=l.rulesMap.find(k=>k.ruleId===c.detail.ruleId);w&&(this.doc.selectedEditorTab="ruleset",this.doc.editorTabGroup.show(ju.Ruleset),(p=this.doc.rulesetEditor.editor)==null||p.setPosition({lineNumber:w.line,column:w.start}),(m=this.doc.rulesetEditor.editor)==null||m.revealLineInCenter(w.line))}}rulesetSaved(c){var l,d,p;if(this.doc.docBag){const m=this.doc.docBag.get(BM),w=(l=this.doc.ruleConfigBag)==null?void 0:l.get(_M);if(c.detail.rules){if((d=this.doc.customRulesetBag)==null||d.set(GP,c.detail.rules),w){const k=c.detail.config;k&&this.doc.ruleConfigBag&&(k.returnedRuleset=c.detail.returnedRules,(p=this.doc.ruleConfigBag)==null||p.set(_M,k))}Jf.getSessionRulesetAsYAML().then(k=>{this.doc.selectedEditorTab=="spec"&&(this.doc.rulesetPulse=!0),this.doc.rulesetEditor.setValue(k,!0),this.fetchRulesetMap()}),this.doc.diagnosticController.lintSpec(m,"")}}}customRulesetEnabled(c){var d,p,m;const l={rules:new Map};l.id=crypto.randomUUID(),l.owner=this.doc.authController.session.sessionId,c.detail.rules.forEach(w=>{w.rule.id!=w.ruleId&&(w.rule.id=w.ruleId),l.rules.set(w.ruleId,w.rule)}),(d=this.doc.customRulesetBag)==null||d.set(GP,l),c.detail.ruleConfig?(p=this.doc.ruleConfigBag)==null||p.set(_M,c.detail.ruleConfig):((m=this.doc.ruleConfigBag)==null||m.reset(),Jf.resetSessionRuleset(c.detail.rulesetReset).then(()=>{if(this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.doc.docBag){const w=this.doc.docBag.get(BM);this.doc.rolodexActivePath,this.doc.diagnosticController.lintSpec(w,this.doc.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(w=>{var k;(k=this.doc.rulesetEditor)==null||k.setValue(w,!0)})}).catch(w=>{this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:w.detail,title:"Cannot reset ruleset"})}))}ruleGroupClicked(c){this.doc.problemsPanel.focus();const l=new CustomEvent(vxe,{bubbles:!0,composed:!0,detail:{rule:c.detail.rule}});this.doc.problemsPanel.focus(),this.doc.problemList.dispatchEvent(l),history.pushState({rule:c.detail.rule},"",`/${ju.Problems}?rule=${c.detail.rule}`),this.doc.controlTabGroup.show(ju.Problems)}rulesetManuallyChanged(){clearTimeout(this.doc.bounceId),this.doc.bounceId=window.setTimeout(()=>{var l;const c=(l=this.doc.rulesetEditor.editor)==null?void 0:l.getValue();Jf.validateRuleset(c).then(d=>{var m;this.doc.manageRuleset.clearRuleProblems();let p={rules:new Map};p.id=crypto.randomUUID(),p.owner=this.doc.authController.session.sessionId,p.rules=new Map(Object.entries(d.rules)),p.rules.forEach((w,k)=>{w.id=k}),(m=this.doc.customRulesetBag)==null||m.set(GP,p),this.doc.customRuleset=p,p.rules.size>0&&(this.doc.manageRuleset.customRulesetManual=p),this.doc.selectedEditorTab=ju.Ruleset,this.doc.controlTabGroup.show(ju.Ruleset),this.doc.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(d=>{this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:d.detail,title:d.title}),console.error("unable to validate ruleset",d);const p=d.body,m=[];p==null||p.forEach(w=>{m.push({severity:v4.MarkerSeverity.Error,message:w.ruleError,startLineNumber:w.line,startColumn:w.startCol,endLineNumber:w.line,endColumn:w.endCol})}),Jf.convertToJSON(c).then(w=>{let k={rules:new Map};k.id=crypto.randomUUID(),k.owner=this.doc.authController.session.sessionId,k.rules=new Map(Object.entries(w.rules)),k.rules.forEach((M,E)=>{M.id!=E&&(M.id=E)}),this.doc.customRuleset=k,k.rules.size>0&&(this.doc.manageRuleset.customRulesetManual=k),this.doc.rulesetEditor.setMarkers([]),this.doc.manageRuleset.clearRuleProblems(),this.doc.rulesetEditor.setMarkers(m),this.doc.manageRuleset.processBadRules(p),this.doc.controlTabGroup.show(ju.Ruleset)}).catch(w=>{console.error("unable to convert ruleset to JSON",w)})})},this.doc.debounceTimeRuleset)}fetchRulesetMap(){Jf.getSessionRulesetMap().then(c=>{var l;(l=this.doc.sessionRulesetMapBag)==null||l.set(Dz,c)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.doc.sendToast({id:crypto.randomUUID(),type:ys.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}exportJSON(){let c;if(this.doc.ruleConfigBag){const l=this.doc.ruleConfigBag.get(_M);l&&l.returnedRuleset&&(c=l.returnedRuleset)}if(c){let l="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(c,null,2));this.doc.downloadRulesetLink.download="ruleset.json",this.doc.downloadRulesetLink.href=l,this.doc.downloadRulesetLink.click(),this.doc.exportRulesetDialog.hide()}}exportYAML(){Jf.getSessionRulesetAsYAML().then(c=>{let l="data:text/yaml;charset=utf-8,"+encodeURIComponent(c);this.doc.downloadRulesetLink.download="ruleset.yaml",this.doc.downloadRulesetLink.href=l,this.doc.downloadRulesetLink.click(),this.doc.exportRulesetDialog.hide()})}async fetchSessionRulesetAsYaml(){return new Promise(async(c,l)=>{Jf.getSessionRulesetAsYAML().then(d=>{c(d)}).catch(d=>{console.error("cannot fetch session ruleset: ",d.title),l(d)})})}async fetchAllRuleset(){return new Promise(async c=>{Jf.getAllRuleset().then(l=>{var d;this.doc.allRuleset=l,(d=this.doc.allRulesetBag)==null||d.set(Gne,l),c(l)})})}async fetchDefaultRuleset(){return new Promise(async c=>{Jf.getDefaultRuleset().then(l=>{var d;this.doc.defaultRuleset=l,(d=this.doc.defaultRulesetBag)==null||d.set(Une,l),c(l)})})}async fetchOWASPRuleset(){return new Promise(async c=>{Jf.getOWASPRuleset().then(l=>{var d;this.doc.OWASPRuleset=l,(d=this.doc.OWASPRulesetBag)==null||d.set(qne,l),c(l)})})}}function Oke(h,c){if(!h)return null;if(h.path===c)return h;if(h.nodes&&h.nodes.length>0)for(let l of h.nodes){let d=Oke(l,c);if(d)return d}return null}class KIt extends EventTarget{constructor(c){super(),this.doc=c}problemClicked(c){var p,m;this.doc.selectedEditorTab!="spec"&&(this.doc.editorTabGroup.show("spec"),this.doc.selectedEditorTab="spec");let l=c.detail.problem.problemObject.sourceLocation;(l==""||l==null||l=="root")&&(l=this.doc.rolodexRootPath);const d=Oke(this.doc.rolodexRoot,l);if(d){this.doc.nodeClickerController.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{nodeHashId:d.idHash,path:l,line:c.detail.problem.problemObject.startLineNumber,column:c.detail.problem.problemObject.startColumn}})),this.doc.detailsDrawer.close(),this.doc.rolodexTree.openNodeByPath(l);return}this.doc.controlTabGroup.show(ju.Problems),(p=this.doc.editor.editor)==null||p.revealLineInCenter(c.detail.problem.line),(m=this.doc.editor.editor)==null||m.setPosition({lineNumber:c.detail.problem.line,column:c.detail.problem.column}),this.doc.detailsDrawer.close(),c.detail.launchedFromProblems||this.doc.problemList.lineClicked(c.detail.problem.problemObject.startLineNumber)}}class VIt extends EventTarget{constructor(c){super(),this.doc=c}fetchDocs(){const c=this.doc.bagManager.getBag(gAt),l=this.doc.bagManager.getBag(dAt);if(this.doc.ruleDocsBag=c,this.doc.functionDocsBag=l,((l==null?void 0:l.export().size)??!1)&&((c==null?void 0:c.export().size)??!1))return;this.doc.activitySpinner.show();const p=new URL(window.location.href).searchParams.get("url");p&&(this.doc.activeURL=p,this.doc.diagnosticController.lintSpec("",p)),p8.fetchAllHowToFix().then(w=>{w&&w.forEach(k=>{var M;(M=this.doc.howToFixBag)==null||M.set(k.ruleId,k)})}).catch(w=>{this.doc.platformUnavailable(w),console.error("documentation service is down")}),this.doc.ruleDocsWorker.addEventListener("message",w=>{const k=w.data;k&&(k.forEach(M=>{var E,I;M.ruleId&&((E=this.doc.ruleDocsBag)==null||E.set(M.ruleId,M)),M.functionId&&((I=this.doc.functionDocsBag)==null||I.set(M.functionId,M))}),this.doc.activitySpinner.hide())}),(()=>{this.doc.ruleDocsWorker.postMessage({start:!0,endpoint:this.doc.doctorEndpoint,existingRules:[],existingFunctions:[]})})()}ruleDocsClicked(c){var d,p,m;const l=c.detail.rule;if(l)switch(c.detail.type){case ru.RULE_DOCS:const w=(d=this.doc.ruleDocsBag)==null?void 0:d.get(l);w?(c.detail.body=w.body,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"Rule documentation unavailable",body:`Documentation for '${l}' not available`});break;case ru.HOW_TO_FIX:const k=(p=this.doc.howToFixBag)==null?void 0:p.get(l);k?(c.detail.body=k.howToFix,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"How to fix unavailable",body:`Information on how to fix '${l}' not available`});break;case ru.FUNCTION_DOCS:const M=(m=this.doc.functionDocsBag)==null?void 0:m.get(l);M?(c.detail.body=M.body,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"Function documentation unavailable",body:`Documentation for '${l}' not available`});break}else switch(c.detail.type){case ru.RENDERED_EXAMPLE:case ru.MARKDOWN:this.doc.detailsDrawer.open(c.detail)}}}class YIt extends EventTarget{constructor(c){super(),this.doc=c}fetchRefMap(c=""){sh.fetchReferenceMap(c).then(l=>{this.doc.editor.clearDecorations(),this.doc.references=l,this.doc.editor.links=l,this.doc.editor.applyLinkDecorations(),this.doc.updateRefmapBag(c,l)}).catch(l=>{console.error("an error occurred fetching the reference map",c,l),this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers(),this.doc.toastManager.addToastManually({id:crypto.randomUUID(),type:ys.INFO,title:"File not analyzed",body:"Cannot extract the references from this file."})})}extractGraph(c){var d,p,m,w;c.stripped?(this.doc.explorer.nodeLimitExceeded=!0,this.doc.modelTree.nodeLimitExceeded=!0,c.strippedCount&&(this.doc.explorer.nodeLimit=c.strippedCount,this.doc.modelTree.nodeLimit=c.strippedCount)):(this.doc.explorer.nodeLimitExceeded=!1,this.doc.modelTree.nodeLimitExceeded=!1),this.doc.explorer.renderedNodeMap.clear(),this.doc.nodeMap.clear(),this.doc.nodeIdMap.clear(),this.doc.nodeIdHashMap.clear();const l=new Map;(d=c==null?void 0:c.nodesRendered)==null||d.forEach(k=>{this.doc.explorer.renderedNodeMap.set(k.id,k),l.set(k.id,k)});for(let k=0;k<((p=c==null?void 0:c.nodesRendered)==null?void 0:p.length);k++)this.doc.renderedNodeMap.set(c.nodesRendered[k].id,c.nodesRendered[k]);(m=c==null?void 0:c.nodes)==null||m.forEach(k=>{var E;this.doc.nodeMap.set(k.id,k),k.idHash.includes("root")?(this.doc.nodeIdMap.set("root",k),this.doc.nodeIdHashMap.set(k.id,k)):(this.doc.nodeIdMap.set(k.id,k),this.doc.nodeIdHashMap.set(k.idHash,k)),k.filtered&&this.doc.filteredNodes.set(k.id,k);const M=this.doc.renderedNodeMap.get(k.id);((E=this.doc.activeNode)==null?void 0:E.id)===k.id&&this.doc.renderedNodeMap.get(k.id)&&this.doc.renderedNode&&M&&(this.doc.renderedNode.node=M)}),(w=this.doc.graphBag)==null||w.set($z,c),this.doc.explorer.updateGraphResponse(c),c&&c.nodes&&(this.doc.modelTree.node=c==null?void 0:c.nodesRendered[0]),this.doc.explorer.equalizer.isInitialized()?this.doc.explorer.equalizer.runEQ(!0):this.doc.explorer.equalizer.initializeEqualizer()}}class ZIt extends EventTarget{constructor(c){super(),this.doc=c,this.oldScore=0}lintSpec(c,l){var w,k;((w=this.doc.problemsOverview.statistics)==null?void 0:w.statistics.overallScore)>0&&(this.oldScore=this.doc.problemsOverview.statistics.statistics.overallScore),this.doc.activitySpinner.show(),this.doc.editor.breadcumb.isInvalid=!1,l?l==="root"?l="":(this.doc.urlProblem.style.display="none",this.doc.urlOverlay.style.display="block",this.doc.urlSpinner.style.display="block",(k=this.doc.referenceMapBag)==null||k.reset()):(this.doc.urlProblem.style.display="none",this.doc.urlOverlay.style.display="none",this.doc.urlSpinner.style.display="none");let d=!1,p=this.doc.rolodexActivePath;if((this.doc.rolodexActivePath===this.doc.rolodexRootPath||this.doc.rolodexActivePath==="root")&&(d=!0,p="",this.doc.editor.showBreadcrumb=!1),l&&l!="")try{const M=new URL(l);M&&(p=M.pathname,this.doc.rolodexActivePath=p,this.doc.rolodexRootPath=p,d=!0)}catch{}let m=!0;p8.lintFile(c,this.doc.brokerController.brokerConnectionId,l,p,this.doc.skipTimeline).then(M=>{var I,N;this.doc.activitySpinner.hide(),this.doc.rolodexController.buildRolodexResultMap(M),l&&(this.doc.urlOverlay.style.display="none",this.doc.urlSpinner.style.display="none",this.doc.urlProblem.style.display="none");let E=this.doc.rolodexProblemMap.get("root");if(this.doc.rolodexRoot||(E=[]),M&&!Array.isArray(M)){const T=[M];if(this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const j=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);j?(E&&j.push(...E),this.doc.editor.setMarkers(j)):(E&&T.push(...E),this.doc.editor.setMarkers(T))}else E&&T.push(...E),this.doc.editor.setMarkers(T);(I=this.doc.problemBag)==null||I.set(Tz,T),this.doc.problemList.problems=T,this.doc.problems=T,this.doc.problemsOverview.problems=this.doc.problemList.problemItems}if(M&&Array.isArray(M)){if(M.length==0&&(this.doc.editor.clearAllMarkers(),this.doc.editor.breadcumb.isInvalid=!1,this.doc.editor.showBreadcrumb=!1,m=!0,this.doc.problemList.isInvalid=!1),M.length==1&&M[0].message.startsWith("unable to parse")&&(this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers(),this.doc.editor.setMarkers(M),this.doc.editor.breadcumb.isInvalid=!0,this.doc.editor.showBreadcrumb=!0,this.doc.editor.dead(),this.doc.problemList.isInvalid=!0,m=!1),m&&this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const T=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);T?(E&&T.push(...E),this.doc.editor.setMarkers(T)):(E&&M.push(...E),this.doc.editor.setMarkers(M))}else if(d)this.doc.editor.setMarkers(M);else{this.doc.modelController.fetchRefMap(p),(this.doc.rolodexRootPath==this.doc.rolodexActivePath||this.doc.rolodexActivePath=="root"||l||p!="")&&sh.fetchLatestGraph().then(T=>{this.doc.modelController.extractGraph(T),this.doc.timeVortex.checkHistory()});return}(N=this.doc.problemBag)==null||N.set(Tz,M),this.doc.problemList.problems=M,this.doc.problems=M,this.doc.problemsOverview.problems=this.doc.problemList.problemItems,this.doc.problemsOverview.statistics&&M.length==1&&(this.doc.problemsOverview.statistics.statistics.totalErrors=1,this.doc.problemsOverview.statistics.statistics.overallScore=0,this.doc.problemsOverview.statistics.evaluation="Useless",this.doc.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+M[0].message)}if(m)this.doc.editor.revive();else return;(this.doc.rolodexRootPath==this.doc.rolodexActivePath||this.doc.rolodexActivePath=="root"||l||p!="")&&sh.fetchLatestGraph().then(T=>{this.doc.modelController.extractGraph(T),this.doc.timeVortex.checkHistory()}),this.doc.rolodexNeedsReset?this.doc.rolodexController.queryRolodex(p):this.doc.modelController.fetchRefMap(p),p8.fetchStatistics().then(T=>{var q,ne;(q=this.doc.diagnosticBag)==null||q.set(Hne,T),this.doc.activitySpinner.hide(),(T==null?void 0:T.remainingCredit)<=10&&(this.doc.statusBar.callsRemaining=T.remainingCredit,this.doc.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+T.remainingCredit+" credits remaining.")),this.doc.problemsOverview.statistics=T;const j=(ne=this.doc.settingsBag)==null?void 0:ne.get(RM);if(!(j!=null&&j.autoDiagnose)&&this.doc.problemsOverview.statistics){const ie=T.statistics.overallScore;this.oldScore>ie&&this.doc.sendToast({id:crypto.randomUUID(),type:ys.SCOREDOWN,body:"Your score has decreased. It is now "+ie+"%",title:"Score went down by "+(this.oldScore-ie)+"%"}),this.oldScore<ie&&this.doc.sendToast({id:crypto.randomUUID(),type:ys.SCOREUP,body:"Your score has increased to "+ie+"%",title:"Score went up by "+(ie-this.oldScore)+"%"})}}).catch(T=>{console.error("statistics service is down",T),this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:T.detail,title:"Statistics request failed"})}),this.doc.explorerBooted||(this.doc.explorer.equalizer.initializeEqualizer(),this.doc.explorerBooted=!0)}).catch(M=>{if(this.doc.activitySpinner.hide(),l)this.doc.showUrlError(M);else if(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),M)if(console.error(M.detail),M.instance==="https://pb33f.io/errors/no-credit-remaining"){this.doc.statusBar.callsRemaining=0,this.doc.statusBar.visible=!0;let E="Run out of credit, please authenticate for more or wait 24 hours.";this.doc.authController.authenticated&&(E="Run out of credit, please purchase more, or come back tomorrow for more free credits."),this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:E,title:"💰 Credit Exhausted!"})}else this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:M.detail,title:"Platform Error"})})}}class XIt extends EventTarget{constructor(c){super(),this.doc=c}loadState(){var p;if((p=this.doc.settingsBag)==null||p.onAllChanges(this.doc.settingsChanged.bind(this)),this.doc.settingsComponent.settingsBag=this.doc.settingsBag,this.doc.settingsBag&&this.doc.settingsChanged("",this.doc.settingsBag.get(RM)),this.doc.settingsComponent.bootstrap(),this.doc.rolodexNeedsReset=!0,this.doc.rolodexResponseBag){const m=this.doc.rolodexResponseBag.get(zne);m&&(this.doc.rolodexRoot=m.rolodexRoot,this.doc.rolodexTree.isRolodex=!0,this.doc.rolodexTree.node=m.rolodexRoot,m.rolodexRoot.treeExpanded=!0,this.doc.requestUpdate())}let c=!1;const l=m=>{var k;let w=(k=this.doc.referenceMapBag)==null?void 0:k.get(Nz);w?setTimeout(()=>{let M=w==null?void 0:w.references[m];M||(M=w==null?void 0:w.references[""]),M&&(this.doc.references=M,this.doc.editor.links=M,this.doc.editor.applyLinkDecorations())},5):sh.fetchReferenceMap().then(M=>{this.doc.references=M,this.doc.editor.links=M,this.doc.editor.applyLinkDecorations()}).catch(()=>{this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers()})};if(this.doc.rolodexStateBag){const m=this.doc.rolodexStateBag.get(u2);m?(this.doc.rolodexActivePath=m.activePath,this.doc.rolodexActiveHash=m.activeHash,m.rootHash&&(this.doc.rolodexTree.pendingNavigationHash=m.rootHash),m.rootPath&&(this.doc.rolodexRootPath=m.rootPath,m.activePath&&l(m.activePath),sh.selectRootPath(m.rootPath).then(()=>{}).catch(w=>{console.error("could not select the root path on boot bro",w)})),m.rootHash&&(this.doc.rolodexRootHash=m.rootHash),m.activePath&&(this.doc.rolodexTree.pendingNavigationPath=m.activePath,this.doc.rolodexTree.requestUpdate()),m.activeNode&&(m.activeLanguage&&this.doc.editor.switchLanguage(m.activeLanguage),this.doc.editor.setValue(m.activeNode.instance,!0),c=!0)):(this.doc.rolodexActivePath="root",l(this.doc.rolodexActivePath))}if(this.doc.docBag&&!c){const m=this.doc.docBag.get(BM);m&&this.doc.editor.setValue(m,!0)}if(this.doc.problemBag=this.doc.bagManager.getBag(Tz),this.doc.problemBag){const m=this.doc.problemBag.get(Tz);if(m){this.doc.problems=m;for(let w=0;w<m.length;w++)m[w]=e2.reconstruct(m[w]);if(this.doc.rolodexController.buildRolodexResultMap(m),this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const w=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);w&&this.doc.editor.setMarkers(w)}this.doc.problemList.problems=m,this.doc.problemsOverview.problems=this.doc.problemList.problemItems}}if(this.doc.howToFixBag=this.doc.bagManager.getBag(fAt),this.doc.diagnosticBag=this.doc.bagManager.getBag(Hne),this.doc.diagnosticBag){const m=this.doc.diagnosticBag.get(Hne);m&&(this.doc.problemsOverview.statistics=m)}if(this.doc.graphBag){const m=this.doc.graphBag.get($z);m&&this.doc.modelController.extractGraph(m)}if(this.doc.panelStateBag){const m=this.doc.panelStateBag.get(gm);m&&m.explorerPanel&&(this.doc.splitPanelExplorer.position=m.explorerPanel),m&&m.rolodexPanel&&(this.doc.splitPanelRolodex&&(this.doc.splitPanelRolodex.position=m.rolodexPanel),this.doc.rolodexDividerPosition=m.rolodexPanel),m&&m.inspectorPanel&&(this.doc.splitPanelInspector.position=m.inspectorPanel)}this.doc.rolodexRoot;const d=[];if(this.doc.defaultRulesetBag=this.doc.bagManager.getBag(Une),this.doc.defaultRulesetBag){const m=this.doc.defaultRulesetBag.get(Une);m?this.doc.defaultRuleset=m:d.push(this.doc.ruleController.fetchDefaultRuleset())}if(this.doc.OWASPRulesetBag=this.doc.bagManager.getBag(qne),this.doc.OWASPRulesetBag){const m=this.doc.OWASPRulesetBag.get(qne);m?this.doc.OWASPRuleset=m:d.push(this.doc.ruleController.fetchOWASPRuleset())}if(this.doc.allRulesetBag=this.doc.bagManager.getBag(Gne),this.doc.allRulesetBag){const m=this.doc.allRulesetBag.get(Gne);m?this.doc.allRuleset=m:d.push(this.doc.ruleController.fetchAllRuleset())}if(this.doc.functionsBag=this.doc.bagManager.getBag(UP),this.doc.functionSchemaBag=this.doc.bagManager.getBag(qP),this.doc.functionsBag){const m=this.doc.functionsBag.get(UP);m?this.doc.functions=m:d.push(this.fetchFunctions())}if(this.doc.customRulesetBag=this.doc.bagManager.getBag(GP),this.doc.customRulesetBag){const m=this.doc.customRulesetBag.get(GP);m&&(this.doc.customRuleset=m)}this.doc.ruleConfigBag=this.doc.bagManager.getBag(_M),this.doc.sessionRulesetMapBag=this.doc.bagManager.getBag(Dz),Promise.all(d).then(()=>{var w;this.doc.manageRuleset.defaultRuleset=this.doc.defaultRuleset,this.doc.manageRuleset.owaspRuleset=this.doc.OWASPRuleset,this.doc.manageRuleset.allRuleset=this.doc.allRuleset,this.doc.manageRuleset.functions=this.doc.functions;const m=(w=this.doc.ruleConfigBag)==null?void 0:w.get(_M);m?this.doc.manageRuleset.rulesetConfig=m:this.doc.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.doc.manageRuleset.buildRulesets(),this.doc.customRuleset&&this.doc.customRuleset.rules.size>0&&(this.doc.manageRuleset.customRuleset=this.doc.customRuleset),this.doc.ruleController.fetchSessionRulesetAsYaml().then(k=>{var M;(M=this.doc.rulesetEditor)==null||M.setValue(k,!0),this.doc.ruleController.fetchRulesetMap()}).catch(k=>{this.doc.platformUnavailable(k)})},50)}),this.doc.docsController.fetchDocs()}async fetchFunctions(){return new Promise(async c=>{Jf.getFunctions().then(l=>{var p;this.doc.functions=l,(p=this.doc.functionsBag)==null||p.set(UP,l);const d=[];l.forEach(m=>{d.push(this.fetchFunctionSchema(m))}),Promise.all(d).then(()=>{c(l)})})})}async fetchFunctionSchema(c){return new Promise(async l=>{Jf.getFunctionSchema(c).then(d=>{var m,w;let p=(m=this.doc.functionSchemaBag)==null?void 0:m.get(qP);p||(p=new Map),p.set(c,d),(w=this.doc.functionSchemaBag)==null||w.set(qP,p),l(d)})})}}var Hd=(h=>(h.Text="text",h.Number="number",h.Boolean="boolean",h.Array="array",h))(Hd||{}),rd=(h=>(h.Text="text",h.Textarea="textarea",h.Select="select",h.Radio="radio",h.Checkbox="checkbox",h.Slider="slider",h.Switch="switch",h.Hidden="hidden",h.Ignored="ignored",h))(rd||{}),QIt=Object.defineProperty,M0=(h,c,l,d)=>{for(var p=void 0,m=h.length-1,w;m>=0;m--)(w=h[m])&&(p=w(c,l,p)||p);return p&&QIt(c,l,p),p};const Wne=class Wne extends A.LitElement{constructor(c){super(),this.model={},this.formData={},this.originalData={},this.isDirty=!1,this.errors=[],this.hints=[],this.validationErrors=new Map,this.topError=null,this.loadingMessage=null,this.isLoading=!1,this.onFormSubmit=null,this.autoFocus=!1,c&&(this.doc=c)}setHints(c){this.hints=c,this.requestUpdate()}renderErrors(c){this.errors=c,this.validationErrors.clear(),c.forEach(l=>{this.validationErrors.set(l.key,l.message)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent($5t,{bubbles:!0,composed:!0,detail:{errors:c}}))}clearErrors(){this.errors=[],this.validationErrors.clear(),this.requestUpdate(),this.dispatchEvent(new CustomEvent(P5t,{bubbles:!0,composed:!0}))}setTopError(c){this.topError=c,this.requestUpdate()}clearTopError(){this.topError=null,this.requestUpdate()}setLoading(c){this.loadingMessage=c,this.isLoading=!0,this.requestUpdate()}notLoading(){this.loadingMessage=null,this.isLoading=!1,this.requestUpdate()}renderForm(){return{...this.formData}}wipeModel(c){if(!this.model||typeof this.model!="object")return;const l={};Object.keys(this.model).forEach(d=>{const p=this.getHintForKey(d);if((p==null?void 0:p.renderType)===rd.Ignored)return;if(c&&c.hasOwnProperty(d)){l[d]=c[d];return}const m=this.model[d];switch(this.getFieldType(m)){case Hd.Text:l[d]="";break;case Hd.Number:l[d]=0;break;case Hd.Boolean:l[d]=!1;break;case Hd.Array:l[d]=Array.isArray(m)?m:[];break;default:l[d]="";break}}),this.model=l,this.formData={...l},this.originalData={...l},this.isDirty=!1,this.clearErrors(),this.clearTopError(),this.requestUpdate()}renderCancelButton(c){return A.html`
|
|
12403
|
+
`;class zIt extends EventTarget{constructor(c){super(),this.doc=c}rolodexTreeNodeClicked(c){var p;const l=(p=this.doc.rolodexFilesBag)==null?void 0:p.get(HP),d=m=>{var T,j,q,ne,ie,re,ee;this.doc.rolodexActivePath=c.detail.path,this.doc.rolodexActiveHash=c.detail.nodeHashId,this.doc.editor.setValue(m.instance,!0),this.doc.editor.setCurrentPath(this.doc.rolodexActivePath),this.doc.modelController.fetchRefMap(this.doc.rolodexActivePath);const w=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);w&&this.doc.editor.setMarkers(w);let k="yaml";const M=(j=(T=c.detail)==null?void 0:T.path)==null?void 0:j.split(".").pop();if(M)switch(M){case Ne.JSON:k=Ne.JSON;break;case Ne.GO:k=Ne.GO;break;case Ne.PY:k="python";break;case Ne.JS:k="javascript";break;case Ne.TS:k="typescript";break;case Ne.PHP:k=Ne.PHP;break;case Ne.XML:k=Ne.XML;break;case Ne.JAVA:k=Ne.JAVA;break;case Ne.RB:k="ruby";break;case Ne.RS:k="rust";break;case Ne.C:k=Ne.C;break;case Ne.CPP:k=Ne.CPP;break;case Ne.CS:k="csharp";break;case Ne.MD:k="markdown";break}const E=(q=this.doc.rolodexStateBag)==null?void 0:q.get(u2);if(E)E.activePath=c.detail.path,E.activeHash=c.detail.nodeHashId,E.activeLanguage=k,E.activeNode=m,E.rootPath=this.doc.rolodexRootPath,(ne=this.doc.rolodexStateBag)==null||ne.set(u2,E);else{const X={activePath:c.detail.path,activeHash:c.detail.nodeHashId,activeLanguage:k,activeNode:m,rootHash:this.doc.rolodexRootHash,rootPath:this.doc.rolodexRootPath};(ie=this.doc.rolodexStateBag)==null||ie.set(u2,X)}this.doc.editor.switchLanguage(k);let I=1,N=0;return c.detail.line&&(I=c.detail.line),c.detail.column&&(N=c.detail.column),(re=this.doc.editor.editor)==null||re.setPosition({lineNumber:I,column:N}),(ee=this.doc.editor.editor)==null||ee.revealLineInCenter(I,N),c.detail.path&&this.doc.rolodexTree.openNodeByPath(c.detail.path),k};sh.queryRolodex(c.detail.nodeHashId,c.detail.path).then(m=>{var w,k,M;if(this.doc.editor.showBreadcrumb=!0,(w=this.doc.referenceMapBag)==null||w.reset(),d(m.rolodexRoot),c.detail.path&&(l&&!l.files[c.detail.path]&&(l.files[c.detail.path]=m.rolodexRoot,(k=this.doc.rolodexFilesBag)==null||k.set(HP,l)),!l)){const E={files:{[c.detail.path]:m.rolodexRoot}};(M=this.doc.rolodexFilesBag)==null||M.set(HP,E)}})}explorerNodeClicked(c,l=!0){let d=!1,p;if(this.doc.explorer.nodeComponents.forEach(m=>{if(m.id===c.detail.nodeId){let w;l&&(w=this.doc.renderedNodeMap.get(m.id),w&&!this.doc.firstRun&&(this.doc.renderedNode.node=w)),this.doc.selectedNodeHashId=m.body.node.idHash,m.body.active=!0,this.doc.activeNode=m.body.node,this.doc.explorer.activeNode=m.body.node,d=!0,l&&(p=w),c.detail.noState||this.doc.addClickTrack(m.body.node)}else m.body.active=!1}),!d){const m=this.doc.nodeIdMap.get(c.detail.nodeId);m&&(this.doc.selectedNodeHashId=m.idHash,this.doc.activeNode=m,this.doc.explorer.activeNode=m,this.doc.explorer.equalizer.activeNode=m)}p&&(this.doc.pendingLine=p.keyLine),this.doc.modelTree.explorerClicked(c.detail.nodeId),this.doc.firstRun||this.doc.viewerPanel.click(),this.doc.explorer.requestUpdate()}modelTreeNodeClicked(c){var d,p,m;let l=this.doc.nodeIdMap.get(c.detail.nodeId);if(l||(l=this.doc.nodeIdHashMap.get(c.detail.nodeId)),l){if(l.origin&&l.origin!=this.doc.rolodexActivePath&&l.origin!="/root.yaml"&&l.origin!="root.yaml"){let k="",M="";const E=(d=this.doc.rolodexFilesBag)==null?void 0:d.get(HP);E&&l.origin&&E.files[l.origin]&&(k=E.files[l.origin].idHash,M=l.origin),this.explorerNodeClicked(c,!0),this.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{nodeHashId:k,path:M}}));return}l.idHash!=="root"&&((p=this.doc.editor.editor)==null||p.setPosition({lineNumber:l.keyLine,column:0}),(m=this.doc.editor.editor)==null||m.revealLineInCenter(l.keyLine)),this.doc.explorerVisible&&this.doc.explorer.moveToNode(l,c.detail.first),this.doc.activeNode=l,c.detail.changes&&(l.timeline=c.detail.changes),this.doc.explorer.activeNode=l,this.doc.explorer.equalizer.activeNode=l;const w=structuredClone(this.doc.renderedNodeMap.get(l.id));w?(c.detail.changes&&(w.timeline=c.detail.changes),this.doc.renderedNode.node=w):alert("no id found"),c.detail.noState||(this.doc.addClickTrack(l),c.detail.noState=!0),this.explorerNodeClicked(c,!0),this.doc.firstRun?this.doc.firstRun=!1:this.doc.viewerPanel.click()}else this.doc.sendToast({id:crypto.randomUUID(),title:"Unable to load change model",type:ys.WARNING,body:"There is no-longer a model with the path `"+c.detail.nodeId+"` in the document"}),console.error("cannot navigate to node, path not found",c.detail.nodeId)}explorerReferenceClicked(c){let l="";if(this.doc.explorer.nodeComponents.forEach(d=>{var p,m;if(d.body.node.nodePath===c.detail.nodePath){const w=this.doc.renderedNodeMap.get(d.body.node.id);w&&((p=this.doc.editor.editor)==null||p.setPosition({lineNumber:w.keyLine,column:0}),(m=this.doc.editor.editor)==null||m.revealLineInCenter(w.keyLine),this.doc.renderedNode.node=w,l=d.body.node.id,this.doc.explorer.moveToNode(d.body.node),this.doc.activeNode=d.body.node,this.doc.explorer.activeNode=d.body.node,this.doc.explorer.equalizer.activeNode=d.body.node),d.body.active=!0}else d.body.active=!1}),l&&(this.doc.modelTree.explorerClicked(l),this.doc.explorer.requestUpdate(),this.doc.viewerPanel.click()),c.detail.nodePath){let d=c.detail.nodePath;!d.startsWith("/")&&!d.includes("#")&&(d=this.doc.rolodexRootPath.substring(0,this.doc.rolodexRootPath.lastIndexOf("/")+1)+d),d.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{path:d}}))}}documentReferenceClicked(c){var E,I;let l="",d,p=1,m=c.detail.jsonPath,w="",k="",M="";if(c.detail.jsonPath.includes("||")&&(l=c.detail.jsonPath.split("||")[1],m=c.detail.jsonPath.split("||")[0],d=parseInt(l.split(":")[0]),p=parseInt(l.split(":")[1]),w=c.detail.jsonPath.split("||")[2],w!=""&&(k=w.split("#")[0]),M=c.detail.jsonPath.split("||")[3]),(E=this.doc.editor.editor)==null||E.setPosition({lineNumber:d,column:p}),(I=this.doc.editor.editor)==null||I.revealLineInCenter(d),this.doc.nodeIdMap.has(m)){const N=this.doc.nodeIdMap.get(m);if(N){if(this.doc.nodeIdHashMap.has(N.idHash)){const T=this.doc.renderedNodeMap.get(N.id);T&&(this.doc.renderedNode.node=T,this.doc.modelTree.explorerClicked(N.id),c.detail.noState||this.doc.addRefTrack(c.detail.jsonPath))}}else this.doc.toastManager.addToastManually({id:crypto.randomUUID(),type:ys.INFO,title:"Reference not found",body:`Something went wrong, '${m}' not found`})}else this.doc.rolodexActivePath!=null&&this.doc.rolodexActivePath!=k&&sh.queryRolodex(M,k).then(N=>{var T,j;if(this.doc.editor.showBreadcrumb=!0,this.doc.rolodexActivePath=k,this.doc.editor.clearDecorations(),this.doc.editor.setValue(N.rolodexRoot.instance,!0),(T=this.doc.editor.editor)==null||T.setPosition({lineNumber:d,column:1}),(j=this.doc.editor.editor)==null||j.revealLineInCenter(d),this.doc.rolodexTree.explorerClicked(M),this.doc.editor.setCurrentPath(k),this.doc.modelController.fetchRefMap(k),this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const q=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);q&&this.doc.editor.setMarkers(q)}}).catch(N=>{console.error("rolodex query failed",N)})}}const Iz="doctor-service",_ne="spec-stream",Rne="credit-stream",Bne="/q/";function HIt(h){return typeof h=="object"&&h!==null&&typeof h.broker=="string"}var Tke=(h=>(h.WhoAmI="whoami",h))(Tke||{});class UIt extends EventTarget{constructor(c){super(),this.useTLS=!1,this.doc=c,this.bus=c.bus,this.doctorServiceChannel=this.bus.createChannel(Iz),this.specStreamChannel=this.bus.createChannel(_ne),this.creditStreamChannel=this.bus.createChannel(Rne),this.bus.mapChannelToBrokerDestination(Bne+Iz,Iz),this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.busPort=sessionStorage.getItem("pb33f-doctor-port"),this.busHost=sessionStorage.getItem("pb33f-doctor-host"),this.busPort||(this.busPort="443"),this.busHost||(this.busHost="doctor.pb33f.io");const l=sessionStorage.getItem("pb33f-doctor-tls");l&&l=="true"&&(this.useTLS=!0)}connectToBroker(){let c="ws://";this.useTLS&&(c="wss://");const l={brokerURL:c+this.busHost+":"+this.busPort+"/ranch",heartbeatIncoming:0,heartbeatOutgoing:0,onConnect:()=>{console.log("💊 Connected to the %cOpenAPI Doctor%c, we are ready to communicate.","background: #0d1117; color: #62C4FFFF; font-weight: bold","color: default"),this.bus.mapChannels(),this.whoAmI()}};this.bus.connectToBroker(l)}doctorServiceHandler(){return c=>{var l;((l=c.payload)==null?void 0:l.payload)!=null&&HIt(c.payload.payload)&&(this.brokerConnectionId=c.payload.payload.broker,this.doc.authController.associateBroker(this.brokerConnectionId).then(()=>{const d=c.payload.payload.version;d!==""&&(this.currentVersion=d);const p=localStorage.getItem("pb33f-doctor-version");if(p){if(this.currentVersion!=p){this.doc.authController.authenticated?(this.doc.bagManager.resetBags(),localStorage.removeItem("pb33f-doctor-version"),window.location.reload()):this.doc.nukeWorkspaceHandler();return}}else localStorage.setItem("pb33f-doctor-version",this.currentVersion);console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you. [v"+d+"]","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor()}))}}whoAmI(){this.bus.publish({destination:"/p/q/"+Iz,body:JSON.stringify({request:Tke.WhoAmI})})}startTheDoctor(){this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bus.mapChannelToBrokerDestination(Bne+_ne,_ne),this.bus.mapChannelToBrokerDestination(Bne+Rne,Rne),this.doc.boostrap()}specStreamHandler(){return c=>{var l,d;if(((l=c.payload)==null?void 0:l.payload)!=null){const p=atob(c.payload.payload);this.doc.docBag&&this.doc.docBag.set(BM,p),(d=this.doc.editor)==null||d.setValue(p,!0),this.doc.requestUpdate()}}}creditStreamHandler(){return c=>{var l;if(((l=c.payload)==null?void 0:l.payload)!=null){const d=parseInt(c.payload.payload);this.doc.creditTicker.credits=d,this.doc.dispatchEvent(new CustomEvent(e8e,{bubbles:!0,composed:!0,detail:{credits:d}}))}}}}class qIt extends EventTarget{constructor(c){super(),this.doc=c}rolodexRootFileSelected(c){var d,p,m;this.doc.rolodexActivePath=c.detail.path,this.doc.rolodexActiveHash=c.detail.nodeHashId,this.doc.rolodexRootPath=c.detail.path,this.doc.importDisabled=!0;const l=(d=this.doc.rolodexStateBag)==null?void 0:d.get(u2);if(l)l.activePath=c.detail.path,l.activeHash=c.detail.nodeHashId,l.rootPath=c.detail.path,l.rootHash=c.detail.nodeHashId,(p=this.doc.rolodexStateBag)==null||p.set(u2,l);else{const w={activePath:c.detail.path,activeHash:c.detail.nodeHashId,rootPath:c.detail.path,rootHash:c.detail.nodeHashId};(m=this.doc.rolodexStateBag)==null||m.set(u2,w)}c.detail.nodeHashId&&(this.doc.rolodexRootHash=c.detail.nodeHashId),c.detail.content&&(this.doc.rolodexNeedsReset=!0,this.doc.editor.setValue(c.detail.content,!0),this.doc.diagnosticController.lintSpec(c.detail.content))}buildRolodexResultMap(c){return this.doc.rolodexProblemMap.clear(),c.forEach(l=>{if((l.sourceLocation==="/root.yaml"||l.sourceLocation==="root.yaml")&&(l.sourceLocation="root"),this.doc.rolodexProblemMap.has(l.sourceLocation)){const d=this.doc.rolodexProblemMap.get(l.sourceLocation);d&&(d.push(l),l.sourceLocation?this.doc.rolodexProblemMap.set(l.sourceLocation,d):this.doc.rolodexRootPath?this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,d):this.doc.rolodexProblemMap.set("root",d))}else if(l.sourceLocation)this.doc.rolodexProblemMap.set(l.sourceLocation,[l]);else if(this.doc.rolodexRootPath){const d=this.doc.rolodexProblemMap.get(this.doc.rolodexRootPath);d?(d.push(l),this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,d)):this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath,[l])}else{const d=this.doc.rolodexProblemMap.get("root");d?(d.push(l),this.doc.rolodexProblemMap.set("root",d)):this.doc.rolodexProblemMap.set("root",[l])}}),this.doc.rolodexProblemMap}queryRolodex(c){sh.queryRolodex().then(l=>{var p,m,w,k;if(this.doc.modelController.fetchRefMap(c),this.doc.editor.showBreadcrumb=!0,this.doc.rolodexNeedsReset=!1,l.rolodexRoot.treeExpanded=!0,this.doc.rolodexTree.isRolodex=!0,this.doc.rolodexTree.node=l.rolodexRoot,this.doc.rolodexRoot=l.rolodexRoot,this.doc.rolodexActiveHash&&(this.doc.rolodexTree.pendingNavigationHash=this.doc.rolodexActiveHash),this.doc.rolodexActivePath&&(this.doc.rolodexTree.pendingNavigationPath=this.doc.rolodexActivePath),((p=l.rolodexRoot.nodes)==null?void 0:p.length)>0&&(this.doc.importDisabled=!0),(m=this.doc.rolodexResponseBag)==null||m.set(zne,l),!((w=this.doc.rolodexStateBag)==null?void 0:w.get(u2))){const M={activePath:this.doc.rolodexActivePath,rootPath:this.doc.rolodexRootPath};(k=this.doc.rolodexStateBag)==null||k.set(u2,M)}this.doc.requestUpdate()}).catch(l=>{console.info("rolodex returned and error:",l.detail)})}}class GIt extends EventTarget{constructor(c){super(),this.doc=c}specChanged(c){if(this.doc.editorMap.get(c.detail.id)&&c.detail.id==="ruleset-editor"){this.doc.ruleController.rulesetManuallyChanged();return}this.doc.docBag&&this.doc.docBag.set(BM,c.detail.content),this.doc.autoDiagnose&&(clearTimeout(this.doc.bounceId),this.doc.bounceId=window.setTimeout(()=>{this.doc.diagnosticController.lintSpec(c.detail.content)},this.doc.debounceTime))}specClicked(c){var l,d,p;if(this.doc.detailsDrawer.close(),this.doc.selectedEditorTab=="spec"){let m=!1;for(let k=0;k<((l=this.doc.problems)==null?void 0:l.length);k++)if(this.doc.problems[k].startLineNumber===c.detail.line){this.doc.problemList.lineClicked(c.detail.line,!0),this.doc.controlTabGroup.show(ju.Problems),this.doc.sidebarClosed&&this.doc.toggleSidebar(),m=!0;break}const w=(d=this.doc.graphBag)==null?void 0:d.get($z);if(w&&w.graphMap&&c.detail.line){const k=w.graphMap[c.detail.line];if(k){this.doc.modelTree.explorerClicked(k);const M=this.doc.renderedNodeMap.get(k);M&&(this.doc.renderedNode.node=M),m||this.doc.viewerPanel.click();const E=this.doc.nodeIdHashMap.get(k);E&&(this.doc.explorer.activeNode=E,this.doc.explorer.equalizer.activeNode=E)}}}if(this.doc.selectedEditorTab==ju.Ruleset){const m=(p=this.doc.sessionRulesetMapBag)==null?void 0:p.get(Dz);if(m!=null&&m.rulesMap){for(let w=0;w<m.rulesMap.length;w++)if(m.rulesMap[w].line===c.detail.line){this.doc.controlTabGroup.show(ju.Ruleset),this.doc.sidebarClosed&&this.doc.toggleSidebar();break}}}}}class WIt extends EventTarget{constructor(c){super(),this.doc=c}ruleClicked(c){var d,p,m;const l=(d=this.doc.sessionRulesetMapBag)==null?void 0:d.get(Dz);if(l){const w=l.rulesMap.find(k=>k.ruleId===c.detail.ruleId);w&&(this.doc.selectedEditorTab="ruleset",this.doc.editorTabGroup.show(ju.Ruleset),(p=this.doc.rulesetEditor.editor)==null||p.setPosition({lineNumber:w.line,column:w.start}),(m=this.doc.rulesetEditor.editor)==null||m.revealLineInCenter(w.line))}}rulesetSaved(c){var l,d,p;if(this.doc.docBag){const m=this.doc.docBag.get(BM),w=(l=this.doc.ruleConfigBag)==null?void 0:l.get(_M);if(c.detail.rules){if((d=this.doc.customRulesetBag)==null||d.set(GP,c.detail.rules),w){const k=c.detail.config;k&&this.doc.ruleConfigBag&&(k.returnedRuleset=c.detail.returnedRules,(p=this.doc.ruleConfigBag)==null||p.set(_M,k))}Jf.getSessionRulesetAsYAML().then(k=>{this.doc.selectedEditorTab=="spec"&&(this.doc.rulesetPulse=!0),this.doc.rulesetEditor.setValue(k,!0),this.fetchRulesetMap()}),this.doc.diagnosticController.lintSpec(m,"")}}}customRulesetEnabled(c){var d,p,m;const l={rules:new Map};l.id=crypto.randomUUID(),l.owner=this.doc.authController.session.sessionId,c.detail.rules.forEach(w=>{w.rule.id!=w.ruleId&&(w.rule.id=w.ruleId),l.rules.set(w.ruleId,w.rule)}),(d=this.doc.customRulesetBag)==null||d.set(GP,l),c.detail.ruleConfig?(p=this.doc.ruleConfigBag)==null||p.set(_M,c.detail.ruleConfig):((m=this.doc.ruleConfigBag)==null||m.reset(),Jf.resetSessionRuleset(c.detail.rulesetReset).then(()=>{if(this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.doc.docBag){const w=this.doc.docBag.get(BM);this.doc.rolodexActivePath,this.doc.diagnosticController.lintSpec(w,this.doc.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(w=>{var k;(k=this.doc.rulesetEditor)==null||k.setValue(w,!0)})}).catch(w=>{this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:w.detail,title:"Cannot reset ruleset"})}))}ruleGroupClicked(c){this.doc.problemsPanel.focus();const l=new CustomEvent(vxe,{bubbles:!0,composed:!0,detail:{rule:c.detail.rule}});this.doc.problemsPanel.focus(),this.doc.problemList.dispatchEvent(l),history.pushState({rule:c.detail.rule},"",`/${ju.Problems}?rule=${c.detail.rule}`),this.doc.controlTabGroup.show(ju.Problems)}rulesetManuallyChanged(){clearTimeout(this.doc.bounceId),this.doc.bounceId=window.setTimeout(()=>{var l;const c=(l=this.doc.rulesetEditor.editor)==null?void 0:l.getValue();Jf.validateRuleset(c).then(d=>{var m;this.doc.manageRuleset.clearRuleProblems();let p={rules:new Map};p.id=crypto.randomUUID(),p.owner=this.doc.authController.session.sessionId,p.rules=new Map(Object.entries(d.rules)),p.rules.forEach((w,k)=>{w.id=k}),(m=this.doc.customRulesetBag)==null||m.set(GP,p),this.doc.customRuleset=p,p.rules.size>0&&(this.doc.manageRuleset.customRulesetManual=p),this.doc.selectedEditorTab=ju.Ruleset,this.doc.controlTabGroup.show(ju.Ruleset),this.doc.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(d=>{this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:d.detail,title:d.title}),console.error("unable to validate ruleset",d);const p=d.body,m=[];p==null||p.forEach(w=>{m.push({severity:v4.MarkerSeverity.Error,message:w.ruleError,startLineNumber:w.line,startColumn:w.startCol,endLineNumber:w.line,endColumn:w.endCol})}),Jf.convertToJSON(c).then(w=>{let k={rules:new Map};k.id=crypto.randomUUID(),k.owner=this.doc.authController.session.sessionId,k.rules=new Map(Object.entries(w.rules)),k.rules.forEach((M,E)=>{M.id!=E&&(M.id=E)}),this.doc.customRuleset=k,k.rules.size>0&&(this.doc.manageRuleset.customRulesetManual=k),this.doc.rulesetEditor.setMarkers([]),this.doc.manageRuleset.clearRuleProblems(),this.doc.rulesetEditor.setMarkers(m),this.doc.manageRuleset.processBadRules(p),this.doc.controlTabGroup.show(ju.Ruleset)}).catch(w=>{console.error("unable to convert ruleset to JSON",w)})})},this.doc.debounceTimeRuleset)}fetchRulesetMap(){Jf.getSessionRulesetMap().then(c=>{var l;(l=this.doc.sessionRulesetMapBag)==null||l.set(Dz,c)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.doc.sendToast({id:crypto.randomUUID(),type:ys.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}exportJSON(){let c;if(this.doc.ruleConfigBag){const l=this.doc.ruleConfigBag.get(_M);l&&l.returnedRuleset&&(c=l.returnedRuleset)}if(c){let l="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(c,null,2));this.doc.downloadRulesetLink.download="ruleset.json",this.doc.downloadRulesetLink.href=l,this.doc.downloadRulesetLink.click(),this.doc.exportRulesetDialog.hide()}}exportYAML(){Jf.getSessionRulesetAsYAML().then(c=>{let l="data:text/yaml;charset=utf-8,"+encodeURIComponent(c);this.doc.downloadRulesetLink.download="ruleset.yaml",this.doc.downloadRulesetLink.href=l,this.doc.downloadRulesetLink.click(),this.doc.exportRulesetDialog.hide()})}async fetchSessionRulesetAsYaml(){return new Promise(async(c,l)=>{Jf.getSessionRulesetAsYAML().then(d=>{c(d)}).catch(d=>{console.error("cannot fetch session ruleset: ",d.title),l(d)})})}async fetchAllRuleset(){return new Promise(async c=>{Jf.getAllRuleset().then(l=>{var d;this.doc.allRuleset=l,(d=this.doc.allRulesetBag)==null||d.set(Gne,l),c(l)})})}async fetchDefaultRuleset(){return new Promise(async c=>{Jf.getDefaultRuleset().then(l=>{var d;this.doc.defaultRuleset=l,(d=this.doc.defaultRulesetBag)==null||d.set(Une,l),c(l)})})}async fetchOWASPRuleset(){return new Promise(async c=>{Jf.getOWASPRuleset().then(l=>{var d;this.doc.OWASPRuleset=l,(d=this.doc.OWASPRulesetBag)==null||d.set(qne,l),c(l)})})}}function Oke(h,c){if(!h)return null;if(h.path===c)return h;if(h.nodes&&h.nodes.length>0)for(let l of h.nodes){let d=Oke(l,c);if(d)return d}return null}class KIt extends EventTarget{constructor(c){super(),this.doc=c}problemClicked(c){var p,m;this.doc.selectedEditorTab!="spec"&&(this.doc.editorTabGroup.show("spec"),this.doc.selectedEditorTab="spec");let l=c.detail.problem.problemObject.sourceLocation;(l==""||l==null||l=="root")&&(l=this.doc.rolodexRootPath);const d=Oke(this.doc.rolodexRoot,l);if(d){this.doc.nodeClickerController.rolodexTreeNodeClicked(new CustomEvent(PA,{detail:{nodeHashId:d.idHash,path:l,line:c.detail.problem.problemObject.startLineNumber,column:c.detail.problem.problemObject.startColumn}})),this.doc.detailsDrawer.close(),this.doc.rolodexTree.openNodeByPath(l);return}this.doc.controlTabGroup.show(ju.Problems),(p=this.doc.editor.editor)==null||p.revealLineInCenter(c.detail.problem.line),(m=this.doc.editor.editor)==null||m.setPosition({lineNumber:c.detail.problem.line,column:c.detail.problem.column}),this.doc.detailsDrawer.close(),c.detail.launchedFromProblems||this.doc.problemList.lineClicked(c.detail.problem.problemObject.startLineNumber)}}class VIt extends EventTarget{constructor(c){super(),this.doc=c}fetchDocs(){const c=this.doc.bagManager.getBag(gAt),l=this.doc.bagManager.getBag(dAt);if(this.doc.ruleDocsBag=c,this.doc.functionDocsBag=l,((l==null?void 0:l.export().size)??!1)&&((c==null?void 0:c.export().size)??!1))return;this.doc.activitySpinner.show();const p=new URL(window.location.href).searchParams.get("url");p&&(this.doc.activeURL=p,this.doc.diagnosticController.lintSpec("",p)),p8.fetchAllHowToFix().then(w=>{w&&w.forEach(k=>{var M;(M=this.doc.howToFixBag)==null||M.set(k.ruleId,k)})}).catch(w=>{this.doc.platformUnavailable(w),console.error("documentation service is down")}),this.doc.ruleDocsWorker.addEventListener("message",w=>{const k=w.data;k&&(k.forEach(M=>{var E,I;M.ruleId&&((E=this.doc.ruleDocsBag)==null||E.set(M.ruleId,M)),M.functionId&&((I=this.doc.functionDocsBag)==null||I.set(M.functionId,M))}),this.doc.activitySpinner.hide())}),(()=>{this.doc.ruleDocsWorker.postMessage({start:!0,endpoint:this.doc.doctorEndpoint,existingRules:[],existingFunctions:[]})})()}ruleDocsClicked(c){var d,p,m;const l=c.detail.rule;if(l)switch(c.detail.type){case ru.RULE_DOCS:const w=(d=this.doc.ruleDocsBag)==null?void 0:d.get(l);w?(c.detail.body=w.body,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"Rule documentation unavailable",body:`Documentation for '${l}' not available`});break;case ru.HOW_TO_FIX:const k=(p=this.doc.howToFixBag)==null?void 0:p.get(l);k?(c.detail.body=k.howToFix,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"How to fix unavailable",body:`Information on how to fix '${l}' not available`});break;case ru.FUNCTION_DOCS:const M=(m=this.doc.functionDocsBag)==null?void 0:m.get(l);M?(c.detail.body=M.body,this.doc.detailsDrawer.open(c.detail)):this.doc.sendToast({id:crypto.randomUUID(),type:ys.INFO,title:"Function documentation unavailable",body:`Documentation for '${l}' not available`});break}else switch(c.detail.type){case ru.RENDERED_EXAMPLE:case ru.MARKDOWN:this.doc.detailsDrawer.open(c.detail)}}}class YIt extends EventTarget{constructor(c){super(),this.doc=c}fetchRefMap(c=""){sh.fetchReferenceMap(c).then(l=>{this.doc.editor.clearDecorations(),this.doc.references=l,this.doc.editor.links=l,this.doc.editor.applyLinkDecorations(),this.doc.updateRefmapBag(c,l)}).catch(l=>{console.error("an error occurred fetching the reference map",c,l),this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers(),this.doc.toastManager.addToastManually({id:crypto.randomUUID(),type:ys.INFO,title:"File not analyzed",body:"Cannot extract the references from this file."})})}extractGraph(c){var d,p,m,w;c.stripped?(this.doc.explorer.nodeLimitExceeded=!0,this.doc.modelTree.nodeLimitExceeded=!0,c.strippedCount&&(this.doc.explorer.nodeLimit=c.strippedCount,this.doc.modelTree.nodeLimit=c.strippedCount)):(this.doc.explorer.nodeLimitExceeded=!1,this.doc.modelTree.nodeLimitExceeded=!1),this.doc.explorer.renderedNodeMap.clear(),this.doc.nodeMap.clear(),this.doc.nodeIdMap.clear(),this.doc.nodeIdHashMap.clear();const l=new Map;(d=c==null?void 0:c.nodesRendered)==null||d.forEach(k=>{this.doc.explorer.renderedNodeMap.set(k.id,k),l.set(k.id,k)});for(let k=0;k<((p=c==null?void 0:c.nodesRendered)==null?void 0:p.length);k++)this.doc.renderedNodeMap.set(c.nodesRendered[k].id,c.nodesRendered[k]);(m=c==null?void 0:c.nodes)==null||m.forEach(k=>{var E;this.doc.nodeMap.set(k.id,k),k.idHash.includes("root")?(this.doc.nodeIdMap.set("root",k),this.doc.nodeIdHashMap.set(k.id,k)):(this.doc.nodeIdMap.set(k.id,k),this.doc.nodeIdHashMap.set(k.idHash,k)),k.filtered&&this.doc.filteredNodes.set(k.id,k);const M=this.doc.renderedNodeMap.get(k.id);((E=this.doc.activeNode)==null?void 0:E.id)===k.id&&this.doc.renderedNodeMap.get(k.id)&&this.doc.renderedNode&&M&&(this.doc.renderedNode.node=M)}),(w=this.doc.graphBag)==null||w.set($z,c),this.doc.explorer.updateGraphResponse(c),c&&c.nodes&&(this.doc.modelTree.node=c==null?void 0:c.nodesRendered[0]),this.doc.explorer.equalizer.isInitialized()?this.doc.explorer.equalizer.runEQ(!0):this.doc.explorer.equalizer.initializeEqualizer()}}class ZIt extends EventTarget{constructor(c){super(),this.doc=c,this.oldScore=0}lintSpec(c,l){var w,k;((w=this.doc.problemsOverview.statistics)==null?void 0:w.statistics.overallScore)>0&&(this.oldScore=this.doc.problemsOverview.statistics.statistics.overallScore),this.doc.activitySpinner.show(),this.doc.editor.breadcumb.isInvalid=!1,l?l==="root"?l="":(this.doc.urlProblem.style.display="none",this.doc.urlOverlay.style.display="block",this.doc.urlSpinner.style.display="block",(k=this.doc.referenceMapBag)==null||k.reset()):(this.doc.urlProblem.style.display="none",this.doc.urlOverlay.style.display="none",this.doc.urlSpinner.style.display="none");let d=!1,p=this.doc.rolodexActivePath;if((this.doc.rolodexActivePath===this.doc.rolodexRootPath||this.doc.rolodexActivePath==="root")&&(d=!0,p="",this.doc.editor.showBreadcrumb=!1),l&&l!="")try{const M=new URL(l);M&&(p=M.pathname,this.doc.rolodexActivePath=p,this.doc.rolodexRootPath=p,d=!0)}catch{}let m=!0;p8.lintFile(c,this.doc.brokerController.brokerConnectionId,l,p,this.doc.skipTimeline).then(M=>{var I,N;this.doc.activitySpinner.hide(),this.doc.rolodexController.buildRolodexResultMap(M),l&&(this.doc.urlOverlay.style.display="none",this.doc.urlSpinner.style.display="none",this.doc.urlProblem.style.display="none");let E=this.doc.rolodexProblemMap.get("root");if(this.doc.rolodexRoot||(E=[]),M&&!Array.isArray(M)){const T=[M];if(this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const j=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);j?(E&&j.push(...E),this.doc.editor.setMarkers(j)):(E&&T.push(...E),this.doc.editor.setMarkers(T))}else E&&T.push(...E),this.doc.editor.setMarkers(T);(I=this.doc.problemBag)==null||I.set(Tz,T),this.doc.problemList.problems=T,this.doc.problems=T,this.doc.problemsOverview.problems=this.doc.problemList.problemItems}if(M&&Array.isArray(M)){if(M.length==0&&(this.doc.editor.clearAllMarkers(),this.doc.editor.breadcumb.isInvalid=!1,this.doc.editor.showBreadcrumb=!1,m=!0,this.doc.problemList.isInvalid=!1),M.length==1&&M[0].message.startsWith("unable to parse")&&(this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers(),this.doc.editor.setMarkers(M),this.doc.editor.breadcumb.isInvalid=!0,this.doc.editor.showBreadcrumb=!0,this.doc.editor.dead(),this.doc.problemList.isInvalid=!0,m=!1),m&&this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const T=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);T?(E&&T.push(...E),this.doc.editor.setMarkers(T)):(E&&M.push(...E),this.doc.editor.setMarkers(M))}else if(d)this.doc.editor.setMarkers(M);else{this.doc.modelController.fetchRefMap(p),(this.doc.rolodexRootPath==this.doc.rolodexActivePath||this.doc.rolodexActivePath=="root"||l||p!="")&&sh.fetchLatestGraph().then(T=>{this.doc.modelController.extractGraph(T),this.doc.timeVortex.checkHistory()});return}(N=this.doc.problemBag)==null||N.set(Tz,M),this.doc.problemList.problems=M,this.doc.problems=M,this.doc.problemsOverview.problems=this.doc.problemList.problemItems,this.doc.problemsOverview.statistics&&M.length==1&&(this.doc.problemsOverview.statistics.statistics.totalErrors=1,this.doc.problemsOverview.statistics.statistics.overallScore=0,this.doc.problemsOverview.statistics.evaluation="Useless",this.doc.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+M[0].message)}if(m)this.doc.editor.revive();else return;(this.doc.rolodexRootPath==this.doc.rolodexActivePath||this.doc.rolodexActivePath=="root"||l||p!="")&&sh.fetchLatestGraph().then(T=>{this.doc.modelController.extractGraph(T),this.doc.timeVortex.checkHistory()}),this.doc.rolodexNeedsReset?this.doc.rolodexController.queryRolodex(p):this.doc.modelController.fetchRefMap(p),p8.fetchStatistics().then(T=>{var q,ne;(q=this.doc.diagnosticBag)==null||q.set(Hne,T),this.doc.activitySpinner.hide(),(T==null?void 0:T.remainingCredit)<=10&&(this.doc.statusBar.callsRemaining=T.remainingCredit,this.doc.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+T.remainingCredit+" credits remaining.")),this.doc.problemsOverview.statistics=T;const j=(ne=this.doc.settingsBag)==null?void 0:ne.get(RM);if(!(j!=null&&j.autoDiagnose)&&this.doc.problemsOverview.statistics){const ie=T.statistics.overallScore;this.oldScore>ie&&this.doc.sendToast({id:crypto.randomUUID(),type:ys.SCOREDOWN,body:"Your score has decreased. It is now "+ie+"%",title:"Score went down by "+(this.oldScore-ie)+"%"}),this.oldScore<ie&&this.doc.sendToast({id:crypto.randomUUID(),type:ys.SCOREUP,body:"Your score has increased to "+ie+"%",title:"Score went up by "+(ie-this.oldScore)+"%"})}}).catch(T=>{console.error("statistics service is down",T),this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:T.detail,title:"Statistics request failed"})}),this.doc.explorerBooted||(this.doc.explorer.equalizer.initializeEqualizer(),this.doc.explorerBooted=!0)}).catch(M=>{if(this.doc.activitySpinner.hide(),l)this.doc.showUrlError(M);else if(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),M)if(console.error(M.detail),M.instance==="https://pb33f.io/errors/no-credit-remaining"){this.doc.statusBar.callsRemaining=0,this.doc.statusBar.visible=!0;let E="Run out of credit, please authenticate for more or wait 24 hours.";this.doc.authController.authenticated&&(E="Run out of credit, please purchase more, or come back tomorrow for more free credits."),this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:E,title:"💰 Credit Exhausted!"})}else this.doc.sendToast({id:crypto.randomUUID(),type:ys.ERROR,body:M.detail,title:"Platform Error"})})}}class XIt extends EventTarget{constructor(c){super(),this.doc=c}loadState(){var p;if((p=this.doc.settingsBag)==null||p.onAllChanges(this.doc.settingsChanged.bind(this)),this.doc.settingsComponent.settingsBag=this.doc.settingsBag,this.doc.settingsBag&&this.doc.settingsChanged("",this.doc.settingsBag.get(RM)),this.doc.settingsComponent.bootstrap(),this.doc.rolodexNeedsReset=!0,this.doc.rolodexResponseBag){const m=this.doc.rolodexResponseBag.get(zne);m&&(this.doc.rolodexRoot=m.rolodexRoot,this.doc.rolodexTree.isRolodex=!0,this.doc.rolodexTree.node=m.rolodexRoot,m.rolodexRoot.treeExpanded=!0,this.doc.requestUpdate())}let c=!1;const l=m=>{var k;let w=(k=this.doc.referenceMapBag)==null?void 0:k.get(Nz);w?setTimeout(()=>{let M=w==null?void 0:w.references[m];M||(M=w==null?void 0:w.references[""]),M&&(this.doc.references=M,this.doc.editor.links=M,this.doc.editor.applyLinkDecorations())},5):sh.fetchReferenceMap().then(M=>{this.doc.references=M,this.doc.editor.links=M,this.doc.editor.applyLinkDecorations()}).catch(()=>{this.doc.editor.clearDecorations(),this.doc.editor.clearAllMarkers()})};if(this.doc.rolodexStateBag){const m=this.doc.rolodexStateBag.get(u2);m?(this.doc.rolodexActivePath=m.activePath,this.doc.rolodexActiveHash=m.activeHash,m.rootHash&&(this.doc.rolodexTree.pendingNavigationHash=m.rootHash),m.rootPath&&(this.doc.rolodexRootPath=m.rootPath,m.activePath&&l(m.activePath),sh.selectRootPath(m.rootPath).then(()=>{}).catch(w=>{console.error("could not select the root path on boot bro",w)})),m.rootHash&&(this.doc.rolodexRootHash=m.rootHash),m.activePath&&(this.doc.rolodexTree.pendingNavigationPath=m.activePath,this.doc.rolodexTree.requestUpdate()),m.activeNode&&(m.activeLanguage&&this.doc.editor.switchLanguage(m.activeLanguage),this.doc.editor.setValue(m.activeNode.instance,!0),c=!0)):(this.doc.rolodexActivePath="root",l(this.doc.rolodexActivePath))}if(this.doc.docBag&&!c){const m=this.doc.docBag.get(BM);m&&this.doc.editor.setValue(m,!0)}if(this.doc.problemBag=this.doc.bagManager.getBag(Tz),this.doc.problemBag){const m=this.doc.problemBag.get(Tz);if(m){this.doc.problems=m;for(let w=0;w<m.length;w++)m[w]=e2.reconstruct(m[w]);if(this.doc.rolodexController.buildRolodexResultMap(m),this.doc.rolodexProblemMap.size>0&&this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)){const w=this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);w&&this.doc.editor.setMarkers(w)}this.doc.problemList.problems=m,this.doc.problemsOverview.problems=this.doc.problemList.problemItems}}if(this.doc.howToFixBag=this.doc.bagManager.getBag(fAt),this.doc.diagnosticBag=this.doc.bagManager.getBag(Hne),this.doc.diagnosticBag){const m=this.doc.diagnosticBag.get(Hne);m&&(this.doc.problemsOverview.statistics=m)}if(this.doc.graphBag){const m=this.doc.graphBag.get($z);m&&this.doc.modelController.extractGraph(m)}if(this.doc.panelStateBag){const m=this.doc.panelStateBag.get(gm);m&&m.explorerPanel&&(this.doc.splitPanelExplorer.position=m.explorerPanel),m&&m.rolodexPanel&&(this.doc.splitPanelRolodex&&(this.doc.splitPanelRolodex.position=m.rolodexPanel),this.doc.rolodexDividerPosition=m.rolodexPanel),m&&m.inspectorPanel&&(this.doc.splitPanelInspector.position=m.inspectorPanel)}this.doc.rolodexRoot;const d=[];if(this.doc.defaultRulesetBag=this.doc.bagManager.getBag(Une),this.doc.defaultRulesetBag){const m=this.doc.defaultRulesetBag.get(Une);m?this.doc.defaultRuleset=m:d.push(this.doc.ruleController.fetchDefaultRuleset())}if(this.doc.OWASPRulesetBag=this.doc.bagManager.getBag(qne),this.doc.OWASPRulesetBag){const m=this.doc.OWASPRulesetBag.get(qne);m?this.doc.OWASPRuleset=m:d.push(this.doc.ruleController.fetchOWASPRuleset())}if(this.doc.allRulesetBag=this.doc.bagManager.getBag(Gne),this.doc.allRulesetBag){const m=this.doc.allRulesetBag.get(Gne);m?this.doc.allRuleset=m:d.push(this.doc.ruleController.fetchAllRuleset())}if(this.doc.functionsBag=this.doc.bagManager.getBag(UP),this.doc.functionSchemaBag=this.doc.bagManager.getBag(qP),this.doc.functionsBag){const m=this.doc.functionsBag.get(UP);m?this.doc.functions=m:d.push(this.fetchFunctions())}if(this.doc.customRulesetBag=this.doc.bagManager.getBag(GP),this.doc.customRulesetBag){const m=this.doc.customRulesetBag.get(GP);m&&(this.doc.customRuleset=m)}this.doc.ruleConfigBag=this.doc.bagManager.getBag(_M),this.doc.sessionRulesetMapBag=this.doc.bagManager.getBag(Dz),Promise.all(d).then(()=>{var w;this.doc.manageRuleset.defaultRuleset=this.doc.defaultRuleset,this.doc.manageRuleset.owaspRuleset=this.doc.OWASPRuleset,this.doc.manageRuleset.allRuleset=this.doc.allRuleset,this.doc.manageRuleset.functions=this.doc.functions;const m=(w=this.doc.ruleConfigBag)==null?void 0:w.get(_M);m?this.doc.manageRuleset.rulesetConfig=m:this.doc.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.doc.manageRuleset.buildRulesets(),this.doc.customRuleset&&this.doc.customRuleset.rules.size>0&&(this.doc.manageRuleset.customRuleset=this.doc.customRuleset),this.doc.ruleController.fetchSessionRulesetAsYaml().then(k=>{var M;(M=this.doc.rulesetEditor)==null||M.setValue(k,!0),this.doc.ruleController.fetchRulesetMap()}).catch(k=>{this.doc.platformUnavailable(k)})},50)}),this.doc.docsController.fetchDocs()}async fetchFunctions(){return new Promise(async c=>{Jf.getFunctions().then(l=>{var p;this.doc.functions=l,(p=this.doc.functionsBag)==null||p.set(UP,l);const d=[];l.forEach(m=>{d.push(this.fetchFunctionSchema(m))}),Promise.all(d).then(()=>{c(l)})})})}async fetchFunctionSchema(c){return new Promise(async l=>{Jf.getFunctionSchema(c).then(d=>{var m,w;let p=(m=this.doc.functionSchemaBag)==null?void 0:m.get(qP);p||(p=new Map),p.set(c,d),(w=this.doc.functionSchemaBag)==null||w.set(qP,p),l(d)})})}}var Hd=(h=>(h.Text="text",h.Number="number",h.Boolean="boolean",h.Array="array",h))(Hd||{}),rd=(h=>(h.Text="text",h.Textarea="textarea",h.Select="select",h.Radio="radio",h.Checkbox="checkbox",h.Slider="slider",h.Switch="switch",h.Hidden="hidden",h.Ignored="ignored",h))(rd||{}),QIt=Object.defineProperty,M0=(h,c,l,d)=>{for(var p=void 0,m=h.length-1,w;m>=0;m--)(w=h[m])&&(p=w(c,l,p)||p);return p&&QIt(c,l,p),p};const Wne=class Wne extends A.LitElement{constructor(c){super(),this.model={},this.formData={},this.originalData={},this.isDirty=!1,this.errors=[],this.hints=[],this.validationErrors=new Map,this.topError=null,this.loadingMessage=null,this.isLoading=!1,this.onFormSubmit=null,this.autoFocus=!1,c&&(this.doc=c)}setHints(c){this.hints=c,this.requestUpdate()}renderErrors(c){this.errors=c,this.validationErrors.clear(),c.forEach(l=>{this.validationErrors.set(l.key,l.message)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent($5t,{bubbles:!0,composed:!0,detail:{errors:c}}))}clearErrors(){this.errors=[],this.validationErrors.clear(),this.requestUpdate(),this.dispatchEvent(new CustomEvent(P5t,{bubbles:!0,composed:!0}))}setTopError(c){this.topError=c,this.requestUpdate()}clearTopError(){this.topError=null,this.requestUpdate()}setLoading(c){this.loadingMessage=c,this.isLoading=!0,this.requestUpdate()}notLoading(){this.loadingMessage=null,this.isLoading=!1,this.requestUpdate()}renderForm(){return{...this.formData}}wipeModel(c){if(!this.model||typeof this.model!="object")return;const l={};Object.keys(this.model).forEach(d=>{const p=this.getHintForKey(d);if((p==null?void 0:p.renderType)===rd.Ignored)return;if(c&&c.hasOwnProperty(d)){l[d]=c[d];return}const m=this.model[d];switch(this.getFieldType(m)){case Hd.Text:l[d]="";break;case Hd.Number:l[d]=0;break;case Hd.Boolean:l[d]=!1;break;case Hd.Array:l[d]=Array.isArray(m)?m:[];break;default:l[d]="";break}}),this.model=l,this.formData={...l},this.originalData={...l},this.isDirty=!1,this.clearErrors(),this.clearTopError(),this.requestUpdate()}renderCancelButton(c){return A.html`
|
|
12404
12404
|
<sl-button class="close-button" ?disabled="${this.isLoading}" @click="${c||(()=>{})}">
|
|
12405
12405
|
Cancel
|
|
12406
12406
|
</sl-button>
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Princess Beef Heavy Industries Cowboy Components",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
|
-
"version": "0.7.
|
|
6
|
+
"version": "0.7.12",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/cowboy-components.umd.cjs",
|
|
9
9
|
"module": "./dist/cowboy-components.js",
|