@pb33f/cowboy-components 0.4.0 → 0.5.1

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 CHANGED
@@ -6,4 +6,4 @@ If you're not [pb33f](https://pb33f.io), you probably don't want to use this.
6
6
 
7
7
  Thanks for stopping by though!
8
8
 
9
- Bye.
9
+ Bye for now.
@@ -375,8 +375,9 @@ let SpecEditor = class SpecEditor extends LitElement {
375
375
  }
376
376
  const uri = link.fullDefinition.split("#/");
377
377
  if (uri.length == 2) {
378
- if (uri[0] !== '/')
378
+ if (uri[0] !== '/' && uri[0] !== '') {
379
379
  linkMeta.push({ value: `File: **${uri[0]}**` });
380
+ }
380
381
  }
381
382
  else {
382
383
  linkMeta.push({ value: `Location: **${link.fullDefinition}**` });
@@ -98,7 +98,7 @@ let ProblemMainView = class ProblemMainView extends LitElement {
98
98
  renderProblem(problem) {
99
99
  let sourceLocation = html ``;
100
100
  if (problem.sourceLocation && problem.sourceLocation.length > 0 &&
101
- (problem.sourceLocation != 'root.yaml' && problem.sourceLocation != 'root')) {
101
+ (problem.sourceLocation != 'root.yaml' && problem.sourceLocation != 'root' && problem.sourceLocation != '/root.yaml')) {
102
102
  sourceLocation = html `<div class="source-location">Problem file:<br/> <strong>${problem.sourceLocation}</strong></div>`;
103
103
  }
104
104
  return html `
@@ -224,6 +224,7 @@ export default css `
224
224
  position: absolute;
225
225
  top: 3px;
226
226
  right: 25px;
227
+ z-index: 1;
227
228
  }
228
229
 
229
230
  .spinner-draw-closed {
@@ -200,7 +200,7 @@ let TheDoctor = class TheDoctor extends LitElement {
200
200
  this.busPort = "443"; // default port
201
201
  }
202
202
  if (!this.busHost) {
203
- this.busHost = "https://doctor.pb33f.io"; // default host
203
+ this.busHost = "doctor.pb33f.io"; // default host
204
204
  }
205
205
  const useTLS = sessionStorage.getItem("pb33f-doctor-tls");
206
206
  if (useTLS && useTLS == 'true') {
@@ -580,7 +580,7 @@ let TheDoctor = class TheDoctor extends LitElement {
580
580
  modelTreeNodeClicked(evt) {
581
581
  const node = this.nodeIdHashMap.get(evt.detail.nodeHashId);
582
582
  if (node) {
583
- if (node.origin && node.origin != this.rolodexActivePath && node.origin != '/root.yaml') {
583
+ if (node.origin && node.origin != this.rolodexActivePath && (node.origin != '/root.yaml' && node.origin != 'root.yaml')) {
584
584
  // extract the rolodex id using the path
585
585
  let hashId = '';
586
586
  const fb = this.rolodexFilesBag?.get(RolodexFilesBag);
@@ -781,7 +781,7 @@ let TheDoctor = class TheDoctor extends LitElement {
781
781
  this.rolodexProblemMap.clear();
782
782
  results.forEach((problem) => {
783
783
  // check if the source location is '/root.yaml'
784
- if (problem.sourceLocation === '/root.yaml') {
784
+ if (problem.sourceLocation === '/root.yaml' || problem.sourceLocation === 'root.yaml') {
785
785
  problem.sourceLocation = "root";
786
786
  }
787
787
  if (this.rolodexProblemMap.has(problem.sourceLocation)) {
@@ -247,6 +247,9 @@ let ExplorerComponent = class ExplorerComponent extends HasEyes {
247
247
  if (width2 >= this.zoomMax || width2 <= this.zoomMin) {
248
248
  return;
249
249
  }
250
+ if (Number.isNaN(x2) || Number.isNaN(y2) || Number.isNaN(width2) || Number.isNaN(height2)) {
251
+ return;
252
+ }
250
253
  requestAnimationFrame(() => {
251
254
  this.svgItem.setAttribute('viewBox', `${x2} ${y2} ${width2} ${height2}`);
252
255
  });
@@ -2573,7 +2573,7 @@ Please report this to https://github.com/markedjs/marked.`,p){const m="<p>An err
2573
2573
  <div class="main-view">
2574
2574
  ${this.renderProblem(this.problems[0].problemObject)}
2575
2575
  </div>`}return I.html`
2576
- <div class="main-view empty">Pick a problem...<br/><sl-icon name="pin-angle"></sl-icon><br/></div>`}renderProblem(b){let p=I.html``;return b.sourceLocation&&b.sourceLocation.length>0&&b.sourceLocation!="root.yaml"&&b.sourceLocation!="root"&&(p=I.html`<div class="source-location">Problem file:<br/> <strong>${b.sourceLocation}</strong></div>`),I.html`
2576
+ <div class="main-view empty">Pick a problem...<br/><sl-icon name="pin-angle"></sl-icon><br/></div>`}renderProblem(b){let p=I.html``;return b.sourceLocation&&b.sourceLocation.length>0&&b.sourceLocation!="root.yaml"&&b.sourceLocation!="root"&&b.sourceLocation!="/root.yaml"&&(p=I.html`<div class="source-location">Problem file:<br/> <strong>${b.sourceLocation}</strong></div>`),I.html`
2577
2577
  <div class="problem">
2578
2578
  <div class="icon ${uQ(b)}">
2579
2579
  <sl-icon name="${aQ(b)}"></sl-icon>
@@ -2994,7 +2994,7 @@ Please report this to https://github.com/markedjs/marked.`,p){const m="<p>An err
2994
2994
  ${Pmt(this.container)}>
2995
2995
  </div>
2996
2996
  ${this.showBreadcrumb?this.breadcumb:null}
2997
- `}getFile(){return this.children.length>0?this.children[0]:null}getCode(){if(this.code)return this.code;const b=this.getFile();if(b)return b.innerHTML.trim()}getTheme(){return this.theme?this.theme:this.isDark()?"vs-dark":"vs-light"}switchLanguage(b){if(this.editor){const p=this.editor.getModel();p&&yc.editor.setModelLanguage(p,b)}}isDark(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}setValue(b,p=!1){var f;p&&(this.firstboot=p),(f=this.editor)==null||f.setValue(b)}getValue(){var b;return(b=this.editor)==null?void 0:b.getValue()}clearDecorations(){var b;this.linkDecorations.clear(),(b=this.editor)==null||b.deltaDecorations([],[])}clearAllMarkers(){yc.editor.removeAllMarkers("owner-"+this.id)}setMarkers(b){yc.editor.removeAllMarkers("owner-"+this.id),yc.editor.setModelMarkers(this.model,"owner-"+this.id,b)}toggleMinimap(){var b;this.minimapVisible=!this.minimapVisible,(b=this.editor)==null||b.updateOptions({minimap:{enabled:this.minimapVisible}})}firstUpdated(){Kmt();const b=yc.Uri.parse("inmemory://doc-"+this.id),p=this.getCode();this.model=yc.editor.createModel(p,"yaml",b),this.editor=yc.editor.create(this.container.value,{model:this.model,language:"json",theme:"pb33f",glyphMargin:!0,readOnly:this.readOnly,automaticLayout:!0,fontFamily:"BerkeleyMono-Regular",fontSize:14,minimap:{enabled:this.minimapVisible},hover:{enabled:!0,delay:100,above:!1,sticky:!0}}),yc.languages.registerLinkProvider("yaml",{provideLinks:this.provideLinks.bind(this)}),yc.editor.registerLinkOpener({open:this.open.bind(this)}),yc.languages.registerHoverProvider("yaml",{provideHover:(f,v)=>{const m=this.links.find(M=>new yc.Range(M.line,M.startColumn,M.line,M.endColumn).containsPosition(v));let C=new Array;if(m){C=[{value:`#### **&rightarrow; ${m.fullDefinition.split("/").pop()}**`},{value:`XPath: _${m.definition}_`}],m.isPolymorphic&&C.push({value:"`Polymorphic Pointer`"}),m.jsonPath&&C.push({value:`JSON Pointer: __${m.jsonPath}__`});const H=m.fullDefinition.split("#/");H.length==2?H[0]!=="/"&&C.push({value:`File: **${H[0]}**`}):C.push({value:`Location: **${m.fullDefinition}**`}),m.targetLine&&m.targetColumn&&C.push({value:`Target: Line [**${m.targetLine}]**, Column **[${m.targetColumn}]**`})}return m?{range:new yc.Range(m.line,m.startColumn,m.line,m.endColumn),contents:C}:null}}),this.linkDecorations=this.editor.createDecorationsCollection(),this.model.onDidChangeContent(()=>{this.firstboot?this.firstboot=!1:this.dispatchEvent(new CustomEvent(eQ,{bubbles:!0,composed:!0,detail:{content:this.editor.getValue(),id:this.id}}))}),this.editor.onMouseDown(f=>{var v,m;this.dispatchEvent(new CustomEvent(wve,{bubbles:!0,composed:!0,detail:{line:(v=f.target.position)==null?void 0:v.lineNumber,column:(m=f.target.position)==null?void 0:m.column}}))}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{yc.editor.setTheme(this.getTheme())})}open(b){return b.scheme=="doctor"&&this.dispatchEvent(new CustomEvent(lQ,{bubbles:!0,composed:!0,detail:{jsonPath:b.authority}})),Promise.resolve(!0)}applyLinkDecorations(){if(this.editor){this.linkDecorations.clear();const b=this.links.map(f=>{let v="ref",m="ref-margin",C={value:"Reference (_JSON Pointer_) to: **"+f.fullDefinition+"**"},M=Hmt;return f.isPolymorphic&&(v="ref-poly",m="ref-poly-margin",C={value:"Polymorphic Reference (_JSON Pointer_) to: **"+f.fullDefinition+"**"},M=Umt),{range:new yc.Range(f.line,f.startColumn,f.line,f.endColumn),options:{inlineClassName:v,glyphMarginClassName:m,glyphMarginHoverMessage:C,minimap:{color:M,position:yc.editor.MinimapPosition.Inline}}}}),p=this.linkDecorations.set(b);this.decorationIdToLinkTarget.clear(),p.forEach((f,v)=>{const m=this.links[v].jsonPath+"||"+this.links[v].targetLine+":"+this.links[v].targetColumn+"||"+this.links[v].fullDefinition+"||"+this.links[v].rolodexIdHash;this.decorationIdToLinkTarget.set(f,m)})}}provideLinks(b,p){return{links:this.links.map(v=>{const m=new yc.Range(v.line,v.startColumn,v.line,v.endColumn),C=v.jsonPath+"||"+v.targetLine+":"+v.targetColumn+"||"+v.fullDefinition+"||"+v.rolodexIdHash;return{range:m,url:yc.Uri.parse(`doctor://${encodeURIComponent(C)}`)}})}}};kd.styles=[Fmt],vm([z.property({type:Boolean,attribute:"readonly"})],kd.prototype,"readOnly",2),vm([z.property()],kd.prototype,"theme",2),vm([z.property()],kd.prototype,"language",2),vm([z.property()],kd.prototype,"code",2),vm([z.state()],kd.prototype,"links",2),vm([z.property()],kd.prototype,"minimapVisible",2),vm([z.property()],kd.prototype,"currentPath",2),vm([z.property()],kd.prototype,"id",2),vm([z.state()],kd.prototype,"showBreadcrumb",2),kd=vm([z.customElement("pb33f-editor")],kd);const zx="bags",Wmt="saddlebag";let Ymt=class{constructor(p){Hr(this,"_bags");Hr(this,"_stateful");Hr(this,"_db");this._bags=new Map,this._stateful=p}loadStatefulBags(){return new Promise(p=>{const f=indexedDB.open(Wmt,1);f.onupgradeneeded=()=>{this._db=f.result,this._db.createObjectStore(zx)},f.onsuccess=()=>{if(this._db=f.result,this._db){const v=this._db.transaction(zx).objectStore(zx).openCursor();v.onsuccess=m=>{let C=m.target.result;if(C){let M=C.primaryKey,H=C.value;const q=this.createBag(M);q.populate(H),this._bags.set(M,q),C.continue()}else p({db:this._db})}}}})}get db(){return this._db?this._db:null}createBag(p){const f=Vmt(p,this._stateful);return f.db=this._db,this._bags.set(p,f),f}getBag(p){return this._bags.has(p)?this._bags.get(p):this.createBag(p)}resetBags(){this._bags.forEach(p=>{p.reset()})}},vQ;function u3e(b){return vQ||(vQ=new Ymt(b)),vQ}function Vmt(b,p){return new Qmt(b,p)}class yQ{constructor(p,f){Hr(this,"_allChangesBit");Hr(this,"_key");Hr(this,"_subFunction");Hr(this,"_allChangesFunction");Hr(this,"_populatedFunction");Hr(this,"_bag");this._bag=p,this._allChangesBit=f,this._key="",this._subFunction=void 0,this._allChangesFunction=void 0,this._populatedFunction=void 0}set allChangeFunction(p){this._allChangesFunction=p}set populatedFunction(p){this._populatedFunction=p}set subscriptionFunction(p){this._subFunction=p}set key(p){this._key=p}unsubscribe(){switch(this._allChangesBit){case 0:const p=this._bag._subscriptions.get(this._key);p&&this._bag._subscriptions.set(this._key,p.filter(f=>f!==this._subFunction));break;case 1:this._bag._allChangesSubscriptions=this._bag._allChangesSubscriptions.filter(f=>f!==this._allChangesFunction);break;case 2:this._bag._storePopulatedSubscriptions=this._bag._storePopulatedSubscriptions.filter(f=>f!==this._populatedFunction)}}}let Qmt=class{constructor(p,f){Hr(this,"_id");Hr(this,"_stateful");Hr(this,"_values");Hr(this,"_db");Hr(this,"_subscriptions");Hr(this,"_allChangesSubscriptions");Hr(this,"_storePopulatedSubscriptions");this._values=new Map,this._subscriptions=new Map,this._allChangesSubscriptions=[],this._storePopulatedSubscriptions=[],this._stateful=f||!1,this._id=p}set(p,f){this._values.set(p,structuredClone(f)),this.alertSubscribers(p,f),this._stateful&&this._db&&this._db.transaction([zx],"readwrite").objectStore(zx).put(this._values,this._id)}get id(){return this._id}set db(p){this._db=p}reset(){this._values.forEach((p,f)=>{this.alertSubscribers(f,void 0)}),this._values=new Map,this._stateful&&this._db&&this._db.transaction([zx],"readwrite").objectStore(zx).delete(this._id)}alertSubscribers(p,f){var v;this._subscriptions.has(p)&&((v=this._subscriptions.get(p))==null||v.forEach(m=>m(f))),this._allChangesSubscriptions.length>0&&this._allChangesSubscriptions.forEach(m=>m(p,f))}get(p){return this._values.get(p)}populate(p){p&&p.size>0&&(this._values=structuredClone(p),this._storePopulatedSubscriptions.length>0&&this._storePopulatedSubscriptions.forEach(f=>f(p)))}export(){return this._values}subscribe(p,f){if(!this._subscriptions.has(p))this._subscriptions.set(p,[f]);else{const m=this._subscriptions.get(p);m&&this._subscriptions.set(p,[...m,f])}const v=new yQ(this,0);return v.key=p,v.subscriptionFunction=f,v}onAllChanges(p){this._allChangesSubscriptions.push(p);const f=new yQ(this,1);return f.allChangeFunction=p,f}onPopulated(p){this._storePopulatedSubscriptions.push(p);const f=new yQ(this,2);return f.populatedFunction=p,f}};class NO{static buildDefaultHeaders(p){const f={};return NO.addBrokerHeader(f,p),NO.addJSONHeader(f),f}static addBrokerHeader(p,f){f&&(p["x-pb33f-broker"]=f)}static addJSONHeader(p){p["Content-Type"]="application/json"}}const O0=class O0{static compareProblems(p,f){return p.startLineNumber<f.startLineNumber?-1:p.startLineNumber>f.startLineNumber?1:p.startColumn<f.startColumn?-1:p.startColumn>f.startColumn?1:p.jsonPath<f.jsonPath?-1:0}static async lintFile(p,f,v,m){return new Promise(async(C,M)=>{try{const H=NO.buildDefaultHeaders(f);let q;v?q=await fetch(O0.doctorEndpoint+"/lint-lsp?url="+encodeURIComponent(v),{method:"GET",credentials:"include",headers:H}):m?q=await fetch(O0.doctorEndpoint+"/lint-lsp?currentPath="+encodeURIComponent(m),{method:"POST",credentials:"include",headers:H,body:p}):q=await fetch(O0.doctorEndpoint+"/lint-lsp",{method:"POST",credentials:"include",headers:H,body:p});const ce=await q.json();if(!ce){M([]);return}if(ce!=null&&ce.type&&(ce!=null&&ce.title)&&(ce!=null&&ce.status)){M(ce);return}const Y=ce,me=[];if(Y&&Array.isArray(Y))for(let ve=0;ve<Y.length;ve++){const De=Y[ve];me.push(new f2(De.category,De.jsonPath,De.endColumn,De.endLineNumber,De.message,De.severity,De.startColumn,De.startLineNumber,De.source,De.id,De.sourceLocation))}if(Y&&!Array.isArray(Y)){const ve=Y;me.push(new f2(ve.category,ve.jsonPath,ve.endColumn,ve.endLineNumber,ve.message,ve.severity,ve.startColumn,ve.startLineNumber,ve.source,ve.id,ve.sourceLocation))}me.sort(O0.compareProblems),C(me)}catch{M({detail:"the pb33f platform is unresponsive"})}})}static async fetchAllHowToFix(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/rules/howtofix",{method:"GET",credentials:"include"})).json();m.title&&m.status&&m.error&&f(m),p(m)}catch{f({tile:"platform error",detail:"the pb33f platform is unresponsive, please try again later."})}})}static async fetchStatistics(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/lint-statistics",{method:"GET",credentials:"include"})).json();m.type&&m.title&&m.status&&f(m),p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}static async startSession(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/start-session",{method:"GET",credentials:"include"})).json();m.type&&m.title&&m.status&&f(m),p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}static async bootstrapEditor(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/bootstrap/train-travel",{method:"GET",credentials:"include"})).text();p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}};O0.doctorEndpoint="https://doctor.pb33f.io";let k3=O0;const Zmt=I.css`
2997
+ `}getFile(){return this.children.length>0?this.children[0]:null}getCode(){if(this.code)return this.code;const b=this.getFile();if(b)return b.innerHTML.trim()}getTheme(){return this.theme?this.theme:this.isDark()?"vs-dark":"vs-light"}switchLanguage(b){if(this.editor){const p=this.editor.getModel();p&&yc.editor.setModelLanguage(p,b)}}isDark(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}setValue(b,p=!1){var f;p&&(this.firstboot=p),(f=this.editor)==null||f.setValue(b)}getValue(){var b;return(b=this.editor)==null?void 0:b.getValue()}clearDecorations(){var b;this.linkDecorations.clear(),(b=this.editor)==null||b.deltaDecorations([],[])}clearAllMarkers(){yc.editor.removeAllMarkers("owner-"+this.id)}setMarkers(b){yc.editor.removeAllMarkers("owner-"+this.id),yc.editor.setModelMarkers(this.model,"owner-"+this.id,b)}toggleMinimap(){var b;this.minimapVisible=!this.minimapVisible,(b=this.editor)==null||b.updateOptions({minimap:{enabled:this.minimapVisible}})}firstUpdated(){Kmt();const b=yc.Uri.parse("inmemory://doc-"+this.id),p=this.getCode();this.model=yc.editor.createModel(p,"yaml",b),this.editor=yc.editor.create(this.container.value,{model:this.model,language:"json",theme:"pb33f",glyphMargin:!0,readOnly:this.readOnly,automaticLayout:!0,fontFamily:"BerkeleyMono-Regular",fontSize:14,minimap:{enabled:this.minimapVisible},hover:{enabled:!0,delay:100,above:!1,sticky:!0}}),yc.languages.registerLinkProvider("yaml",{provideLinks:this.provideLinks.bind(this)}),yc.editor.registerLinkOpener({open:this.open.bind(this)}),yc.languages.registerHoverProvider("yaml",{provideHover:(f,v)=>{const m=this.links.find(M=>new yc.Range(M.line,M.startColumn,M.line,M.endColumn).containsPosition(v));let C=new Array;if(m){C=[{value:`#### **&rightarrow; ${m.fullDefinition.split("/").pop()}**`},{value:`XPath: _${m.definition}_`}],m.isPolymorphic&&C.push({value:"`Polymorphic Pointer`"}),m.jsonPath&&C.push({value:`JSON Pointer: __${m.jsonPath}__`});const H=m.fullDefinition.split("#/");H.length==2?H[0]!=="/"&&H[0]!==""&&C.push({value:`File: **${H[0]}**`}):C.push({value:`Location: **${m.fullDefinition}**`}),m.targetLine&&m.targetColumn&&C.push({value:`Target: Line [**${m.targetLine}]**, Column **[${m.targetColumn}]**`})}return m?{range:new yc.Range(m.line,m.startColumn,m.line,m.endColumn),contents:C}:null}}),this.linkDecorations=this.editor.createDecorationsCollection(),this.model.onDidChangeContent(()=>{this.firstboot?this.firstboot=!1:this.dispatchEvent(new CustomEvent(eQ,{bubbles:!0,composed:!0,detail:{content:this.editor.getValue(),id:this.id}}))}),this.editor.onMouseDown(f=>{var v,m;this.dispatchEvent(new CustomEvent(wve,{bubbles:!0,composed:!0,detail:{line:(v=f.target.position)==null?void 0:v.lineNumber,column:(m=f.target.position)==null?void 0:m.column}}))}),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{yc.editor.setTheme(this.getTheme())})}open(b){return b.scheme=="doctor"&&this.dispatchEvent(new CustomEvent(lQ,{bubbles:!0,composed:!0,detail:{jsonPath:b.authority}})),Promise.resolve(!0)}applyLinkDecorations(){if(this.editor){this.linkDecorations.clear();const b=this.links.map(f=>{let v="ref",m="ref-margin",C={value:"Reference (_JSON Pointer_) to: **"+f.fullDefinition+"**"},M=Hmt;return f.isPolymorphic&&(v="ref-poly",m="ref-poly-margin",C={value:"Polymorphic Reference (_JSON Pointer_) to: **"+f.fullDefinition+"**"},M=Umt),{range:new yc.Range(f.line,f.startColumn,f.line,f.endColumn),options:{inlineClassName:v,glyphMarginClassName:m,glyphMarginHoverMessage:C,minimap:{color:M,position:yc.editor.MinimapPosition.Inline}}}}),p=this.linkDecorations.set(b);this.decorationIdToLinkTarget.clear(),p.forEach((f,v)=>{const m=this.links[v].jsonPath+"||"+this.links[v].targetLine+":"+this.links[v].targetColumn+"||"+this.links[v].fullDefinition+"||"+this.links[v].rolodexIdHash;this.decorationIdToLinkTarget.set(f,m)})}}provideLinks(b,p){return{links:this.links.map(v=>{const m=new yc.Range(v.line,v.startColumn,v.line,v.endColumn),C=v.jsonPath+"||"+v.targetLine+":"+v.targetColumn+"||"+v.fullDefinition+"||"+v.rolodexIdHash;return{range:m,url:yc.Uri.parse(`doctor://${encodeURIComponent(C)}`)}})}}};kd.styles=[Fmt],vm([z.property({type:Boolean,attribute:"readonly"})],kd.prototype,"readOnly",2),vm([z.property()],kd.prototype,"theme",2),vm([z.property()],kd.prototype,"language",2),vm([z.property()],kd.prototype,"code",2),vm([z.state()],kd.prototype,"links",2),vm([z.property()],kd.prototype,"minimapVisible",2),vm([z.property()],kd.prototype,"currentPath",2),vm([z.property()],kd.prototype,"id",2),vm([z.state()],kd.prototype,"showBreadcrumb",2),kd=vm([z.customElement("pb33f-editor")],kd);const zx="bags",Wmt="saddlebag";let Ymt=class{constructor(p){Hr(this,"_bags");Hr(this,"_stateful");Hr(this,"_db");this._bags=new Map,this._stateful=p}loadStatefulBags(){return new Promise(p=>{const f=indexedDB.open(Wmt,1);f.onupgradeneeded=()=>{this._db=f.result,this._db.createObjectStore(zx)},f.onsuccess=()=>{if(this._db=f.result,this._db){const v=this._db.transaction(zx).objectStore(zx).openCursor();v.onsuccess=m=>{let C=m.target.result;if(C){let M=C.primaryKey,H=C.value;const q=this.createBag(M);q.populate(H),this._bags.set(M,q),C.continue()}else p({db:this._db})}}}})}get db(){return this._db?this._db:null}createBag(p){const f=Vmt(p,this._stateful);return f.db=this._db,this._bags.set(p,f),f}getBag(p){return this._bags.has(p)?this._bags.get(p):this.createBag(p)}resetBags(){this._bags.forEach(p=>{p.reset()})}},vQ;function u3e(b){return vQ||(vQ=new Ymt(b)),vQ}function Vmt(b,p){return new Qmt(b,p)}class yQ{constructor(p,f){Hr(this,"_allChangesBit");Hr(this,"_key");Hr(this,"_subFunction");Hr(this,"_allChangesFunction");Hr(this,"_populatedFunction");Hr(this,"_bag");this._bag=p,this._allChangesBit=f,this._key="",this._subFunction=void 0,this._allChangesFunction=void 0,this._populatedFunction=void 0}set allChangeFunction(p){this._allChangesFunction=p}set populatedFunction(p){this._populatedFunction=p}set subscriptionFunction(p){this._subFunction=p}set key(p){this._key=p}unsubscribe(){switch(this._allChangesBit){case 0:const p=this._bag._subscriptions.get(this._key);p&&this._bag._subscriptions.set(this._key,p.filter(f=>f!==this._subFunction));break;case 1:this._bag._allChangesSubscriptions=this._bag._allChangesSubscriptions.filter(f=>f!==this._allChangesFunction);break;case 2:this._bag._storePopulatedSubscriptions=this._bag._storePopulatedSubscriptions.filter(f=>f!==this._populatedFunction)}}}let Qmt=class{constructor(p,f){Hr(this,"_id");Hr(this,"_stateful");Hr(this,"_values");Hr(this,"_db");Hr(this,"_subscriptions");Hr(this,"_allChangesSubscriptions");Hr(this,"_storePopulatedSubscriptions");this._values=new Map,this._subscriptions=new Map,this._allChangesSubscriptions=[],this._storePopulatedSubscriptions=[],this._stateful=f||!1,this._id=p}set(p,f){this._values.set(p,structuredClone(f)),this.alertSubscribers(p,f),this._stateful&&this._db&&this._db.transaction([zx],"readwrite").objectStore(zx).put(this._values,this._id)}get id(){return this._id}set db(p){this._db=p}reset(){this._values.forEach((p,f)=>{this.alertSubscribers(f,void 0)}),this._values=new Map,this._stateful&&this._db&&this._db.transaction([zx],"readwrite").objectStore(zx).delete(this._id)}alertSubscribers(p,f){var v;this._subscriptions.has(p)&&((v=this._subscriptions.get(p))==null||v.forEach(m=>m(f))),this._allChangesSubscriptions.length>0&&this._allChangesSubscriptions.forEach(m=>m(p,f))}get(p){return this._values.get(p)}populate(p){p&&p.size>0&&(this._values=structuredClone(p),this._storePopulatedSubscriptions.length>0&&this._storePopulatedSubscriptions.forEach(f=>f(p)))}export(){return this._values}subscribe(p,f){if(!this._subscriptions.has(p))this._subscriptions.set(p,[f]);else{const m=this._subscriptions.get(p);m&&this._subscriptions.set(p,[...m,f])}const v=new yQ(this,0);return v.key=p,v.subscriptionFunction=f,v}onAllChanges(p){this._allChangesSubscriptions.push(p);const f=new yQ(this,1);return f.allChangeFunction=p,f}onPopulated(p){this._storePopulatedSubscriptions.push(p);const f=new yQ(this,2);return f.populatedFunction=p,f}};class NO{static buildDefaultHeaders(p){const f={};return NO.addBrokerHeader(f,p),NO.addJSONHeader(f),f}static addBrokerHeader(p,f){f&&(p["x-pb33f-broker"]=f)}static addJSONHeader(p){p["Content-Type"]="application/json"}}const O0=class O0{static compareProblems(p,f){return p.startLineNumber<f.startLineNumber?-1:p.startLineNumber>f.startLineNumber?1:p.startColumn<f.startColumn?-1:p.startColumn>f.startColumn?1:p.jsonPath<f.jsonPath?-1:0}static async lintFile(p,f,v,m){return new Promise(async(C,M)=>{try{const H=NO.buildDefaultHeaders(f);let q;v?q=await fetch(O0.doctorEndpoint+"/lint-lsp?url="+encodeURIComponent(v),{method:"GET",credentials:"include",headers:H}):m?q=await fetch(O0.doctorEndpoint+"/lint-lsp?currentPath="+encodeURIComponent(m),{method:"POST",credentials:"include",headers:H,body:p}):q=await fetch(O0.doctorEndpoint+"/lint-lsp",{method:"POST",credentials:"include",headers:H,body:p});const ce=await q.json();if(!ce){M([]);return}if(ce!=null&&ce.type&&(ce!=null&&ce.title)&&(ce!=null&&ce.status)){M(ce);return}const Y=ce,me=[];if(Y&&Array.isArray(Y))for(let ve=0;ve<Y.length;ve++){const De=Y[ve];me.push(new f2(De.category,De.jsonPath,De.endColumn,De.endLineNumber,De.message,De.severity,De.startColumn,De.startLineNumber,De.source,De.id,De.sourceLocation))}if(Y&&!Array.isArray(Y)){const ve=Y;me.push(new f2(ve.category,ve.jsonPath,ve.endColumn,ve.endLineNumber,ve.message,ve.severity,ve.startColumn,ve.startLineNumber,ve.source,ve.id,ve.sourceLocation))}me.sort(O0.compareProblems),C(me)}catch{M({detail:"the pb33f platform is unresponsive"})}})}static async fetchAllHowToFix(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/rules/howtofix",{method:"GET",credentials:"include"})).json();m.title&&m.status&&m.error&&f(m),p(m)}catch{f({tile:"platform error",detail:"the pb33f platform is unresponsive, please try again later."})}})}static async fetchStatistics(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/lint-statistics",{method:"GET",credentials:"include"})).json();m.type&&m.title&&m.status&&f(m),p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}static async startSession(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/start-session",{method:"GET",credentials:"include"})).json();m.type&&m.title&&m.status&&f(m),p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}static async bootstrapEditor(){return new Promise(async(p,f)=>{try{const m=await(await fetch(O0.doctorEndpoint+"/bootstrap/train-travel",{method:"GET",credentials:"include"})).text();p(m)}catch{f({detail:"the pb33f platform is unresponsive"})}})}};O0.doctorEndpoint="https://doctor.pb33f.io";let k3=O0;const Zmt=I.css`
2998
2998
 
2999
2999
  label {
3000
3000
  font-size: 0.8rem;
@@ -5173,6 +5173,7 @@ Please report this to https://github.com/markedjs/marked.`,p){const m="<p>An err
5173
5173
  position: absolute;
5174
5174
  top: 3px;
5175
5175
  right: 25px;
5176
+ z-index: 1;
5176
5177
  }
5177
5178
 
5178
5179
  .spinner-draw-closed {
@@ -7399,7 +7400,7 @@ Consider installing the package or pass your own 'workerFactory' to ELK's constr
7399
7400
  ${this.equalizerOpen?this.equalizer():null}
7400
7401
  ${this.keyOpen?this.key():null}
7401
7402
  </div>
7402
- `}};zh.styles=[AQ,ru,N3,qp],j0([z.query("form")],zh.prototype,"form",2),j0([z.property({type:Number})],zh.prototype,"nodeNodeBetweenLayers",2),j0([z.property({type:Number})],zh.prototype,"nodeNode",2),j0([z.property({type:Number})],zh.prototype,"edgeNodeBetweenLayers",2),j0([z.property({type:Number})],zh.prototype,"edgeNode",2),j0([z.property({type:Boolean})],zh.prototype,"bendEdges",2),j0([z.property({type:Boolean})],zh.prototype,"bendPoints",2),j0([z.property({type:Boolean})],zh.prototype,"renderRefs",2),j0([z.property({type:Boolean})],zh.prototype,"renderPoly",2),j0([z.property({type:Boolean})],zh.prototype,"dimDependencies",2),zh=j0([z.customElement("pb33f-explorer-equalizer")],zh);function Wvt(b){return new Worker("/assets/graph-dependent.worker-CpVhp0-T.js",{name:b==null?void 0:b.name})}var Yvt=Object.defineProperty,Vvt=Object.getOwnPropertyDescriptor,Vx=(b,p,f,v)=>{for(var m=v>1?void 0:v?Vvt(p,f):p,C=b.length-1,M;C>=0;C--)(M=b[C])&&(m=(v?M(p,f,m):M(m))||m);return v&&m&&Yvt(p,f,m),m};let xm=class extends PQ{constructor(){super(),this.nodeComponents=[],this.edgeComponents=[],this.scale=1,this.dragStartViewBoxX=0,this.dragStartViewBoxY=0,this.zoomMax=8e3,this.zoomMin=50,this.collapsedNodes=new Map,this.collapsedEdges=new Map,this.elk=new y2t,this.ready=!1,this.direction="RIGHT",this.nodeMap=new Map,this.renderGraphMap=new Map,this.edgeComponentMap=new Map,this.renderedNodeMap=new Map,this.collapsedNodes=new Map,this.nodes=[],this.edges=[],this.nodeNodeBetweenLayers="100",this.nodeNode="80",this.edgeNodeBetweenLayers="30",this.edgeNode="120",this.bendEdges=!0,this.bendPoints=!0,this.renderRefs=!1,this.renderPoly=!1,this.nodeLimitExceeded=!1,this.nodeLimit=-1,this.equalizer=new zh,this.equalizer.nodeNodeBetweenLayers=parseInt(this.nodeNodeBetweenLayers),this.equalizer.nodeNode=parseInt(this.nodeNode),this.equalizer.edgeNodeBetweenLayers=parseInt(this.edgeNodeBetweenLayers),this.equalizer.edgeNode=parseInt(this.edgeNode),this.equalizer.bendEdges=this.bendEdges,this.equalizer.bendPoints=this.bendPoints,this.equalizer.renderRefs=this.renderRefs,this.equalizer.renderPoly=this.renderPoly,this.dimDependencies=!1,this.graphDependentWorker=new Wvt,this.equalizer.addEventListener(Tve,this.zoomIn.bind(this)),this.equalizer.addEventListener(Ove,this.zoomOut.bind(this)),this.equalizer.addEventListener(Dve,this.rotate.bind(this)),this.equalizer.addEventListener(Rve,this.reset.bind(this)),this.equalizer.addEventListener(oQ,this.equalizerChanged.bind(this)),this.equalizer.addEventListener(cQ,this.equalizerFiltered.bind(this)),this.addEventListener(_ve,this.dependentNodeClicked.bind(this)),this.graphDependentWorker.onmessage=b=>{this.toggleNodeVisibility(b.data.filteredNodes,b.data.filteredEdges,b.data.collapse)}}toggleNodeVisibility(b,p,f){b.forEach(v=>{const m=this.nodeComponents.find(C=>C.id===v.idHash);m&&(m.visible&&f&&(m.visible=!1,this.collapsedNodes.set(v.idHash,!0)),!m.visible&&!f&&(m.visible=!0,this.collapsedNodes.delete(v.idHash)))}),p.forEach(v=>{const m=this.edgeComponents.find(C=>C.edge.id===v.id);m&&(m.visible&&f&&(m.visible=!1,this.collapsedEdges.set(v.id,!0)),!m.visible&&!f&&(m.visible=!0,this.collapsedEdges.delete(v.id)))}),this.requestUpdate()}dependentNodeClicked(b){this.graphDependentWorker&&this.graphDependentWorker.postMessage({dependentNode:b.detail.node,collapse:b.detail.collapse,nodes:this.graphResponse.nodes,edges:this.graphResponse.edges})}updateGraphResponse(b){this.graphResponse=b,this.equalizer.graphResponse=b,this.equalizer.controls.searchComponent.graphResponse=b}rotate(){switch(this.direction){case"LEFT":this.direction="UP";break;case"DOWN":this.direction="LEFT";break;case"RIGHT":this.direction="DOWN";break;case"UP":this.direction="RIGHT";break}this.resetNodes(),this.buildGraph(),setTimeout(()=>{if(this.activeNode){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash}}));return}})}mouseMove(b){this.grabbed&&requestAnimationFrame(()=>{const p=this.svgItem.viewBox.baseVal,f=(b.clientX-this.startX)*(p.width/this.svgItem.clientWidth),v=(b.clientY-this.startY)*(p.height/this.svgItem.clientHeight);p.x=this.dragStartViewBoxX-f,p.y=this.dragStartViewBoxY-v})}mouseDown(b){this.grabbed=!0;const p=this.svgItem.viewBox.baseVal;this.startX=b.clientX,this.startY=b.clientY,this.dragStartViewBoxX=p.x,this.dragStartViewBoxY=p.y}mouseUp(){this.grabbed=!1}zoom(b){var me;b=Math.abs(b)<.02?b/Math.abs(b)*.02:b;let[p,f,v,m]=(me=this.svgItem.getAttribute("viewBox"))==null?void 0:me.split(" ").map(Number),C=p+v/2,M=f+m/2,[H,q]=[v+v*b,m+m*b],ce=C-H/2,Y=M-q/2;H>=this.zoomMax||H<=this.zoomMin||this.svgItem.setAttribute("viewBox",`${ce} ${Y} ${H} ${q}`)}zoomIn(){this.zoom(-.1)}zoomOut(){this.zoom(.1)}onWheel(b){var De,Nt;b.preventDefault();let p=b.deltaY/1e3;p=Math.abs(p)<.02?.02*b.deltaY/Math.abs(b.deltaY):p;let f=new DOMPoint(b.clientX,b.clientY);f=f.matrixTransform((De=this.svgItem.getScreenCTM())==null?void 0:De.inverse());let[v,m,C,M]=(Nt=this.svgItem.getAttribute("viewBox"))==null?void 0:Nt.split(" ").map(Number),[H,q]=[(f.x-v)/C,(f.y-m)/M],[ce,Y]=[C+C*p,M+M*p],me=f.x-H*ce,ve=f.y-q*Y;ce>=this.zoomMax||ce<=this.zoomMin||requestAnimationFrame(()=>{this.svgItem.setAttribute("viewBox",`${me} ${ve} ${ce} ${Y}`)})}equalizerFiltered(b){this.graphResponse=b.detail.graph,this.buildGraph()}equalizerChanged(b){var p;b.detail.graph.nodes.length>0&&(this.graphResponse=b.detail.graph),b.detail.spacing&&(b.detail.spacing.nodeNodeBetweenLayers&&(this.nodeNodeBetweenLayers=b.detail.spacing.nodeNodeBetweenLayers.toString()),b.detail.spacing.nodeNode&&(this.nodeNode=b.detail.spacing.nodeNode.toString()),b.detail.spacing.edgeNodeBetweenLayers&&(this.edgeNodeBetweenLayers=b.detail.spacing.edgeNodeBetweenLayers.toString()),b.detail.spacing.edgeNode&&(this.edgeNode=b.detail.spacing.edgeNode.toString()),this.bendEdges=!!b.detail.spacing.bendEdges,this.bendPoints=!!b.detail.spacing.bendPoints,this.dimDependencies=!!((p=b.detail.options)!=null&&p.dimDependents)),b.detail.references&&(this.renderRefs=!!b.detail.references.renderRefs,this.renderPoly=!!b.detail.references.renderPoly),this.buildGraph(),setTimeout(()=>{if(this.activeNode&&this._visible){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash,first:!0}}));return}},150)}buildLayout(){this.elk.layout(this.graph,{layoutOptions:{algorithm:"layered"},logging:!0,measureExecutionTime:!0}).then(this.readyGo.bind(this))}resetNodes(){var b,p;(b=this.graph.children)==null||b.forEach(f=>{const v=f;delete v.x,delete v.y}),(p=this.graph.edges)==null||p.forEach(f=>{delete f.sections})}generateOptions(){return{"spacing.nodeNodeBetweenLayers":this.nodeNodeBetweenLayers,"spacing.nodeNode":this.nodeNode,"elk.nodeLabels.placement":"INSIDE V_CENTER H_RIGHT","elk.algorithm":"layered","elk.direction":this.direction,"org.eclipse.elk.edgeRouting":"ORTHOGONAL","elk.layered.unnecessaryBendpoints":"true","elk.layered.spacing.edgeNodeBetweenLayers":this.edgeNodeBetweenLayers,"org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","org.eclipse.elk.layered.cycleBreaking.strategy":"DEPTH_FIRST","nodePlacement.strategy":"BRANDES_KOEPF","org.eclipse.elk.spacing.edgeLabel":"0","org.eclipse.elk.spacing.edgeNode":this.edgeNode,"org.eclipse.elk.layered.edgeLabels.sideSelection":"ALWAYS_UP","org.eclipse.elk.spacing.portPort":"10"}}buildGraph(){const b={id:"root",layoutOptions:this.generateOptions(),children:this.graphResponse.nodes,edges:this.graphResponse.edges};return this.graph=b,this.nodeMap.clear(),this.buildLayout(),this.equalizer.graphResponse||(this.equalizer.graphResponse=this.graphResponse),b}generateNodeType(b){switch(b){case de.DOCUMENT:return new zO;case de.INFO:return new HO;case de.LICENSE:return new UO;case de.CONTACT:return new GO;case de.TAG:return new qO;case de.SERVER:return new KO;case de.COMPONENTS:return new WO;case de.SCHEMA:return new AI;case de.SECURITY_SCHEME:return new YO;case de.PARAMETER:return new VO;case de.HEADER:return new QO;case de.REQUEST_BODY:return new ZO;case de.MEDIA_TYPE:return new XO;case de.RESPONSE:return new JO;case de.LINK:return new eD;case de.CALLBACK:return new tD;case de.PATH_ITEM:return new nD;case de.OPERATION:return new iD;case de.XML:return new rD;default:return new jc}}buildNodes(){var b,p;this.nodes=[],this.nodeComponents=[],this.renderGraphMap.clear(),this.renderedNodeMap.clear(),(b=this.graphResponse.nodesRendered)==null||b.forEach(f=>{this.renderedNodeMap.set(f.id,f)}),(p=this.graph.children)==null||p.forEach(f=>{var M,H;const v=f,m=new NI;m.id=v.idHash,v.x&&v.y&&(m.x=v.x,m.y=v.y),m.width=v.width,m.height=v.height;const C=this.generateNodeType(v.type);C.height=v.height,C.width=v.width-2,C.id=v.idHash,C.label=v.label,C.isLeaf=!(v.nodes&&v.nodes.length>0),C.node=v,v.active&&(C.active=v.active,m.active=v.active),!v.active&&this.activeNode&&this.activeNode.idHash===v.idHash&&(C.active=!0,m.active=!0),v.dependency&&(C.isDependency=!0,this.dimDependencies&&(C.dim=!0)),this.collapsedNodes.has(v.idHash)&&(m.visible=!1),C.nodeInstance=(M=this.renderedNodeMap.get(v.id))==null?void 0:M.instance,v.results=(H=this.renderedNodeMap.get(v.id))==null?void 0:H.results,this.renderGraphMap.set(v.id,C),m.body=C,this.nodeComponents.push(m),this.nodes.push(v)})}buildEdges(){var b;this.edgeComponents=[],this.edgeComponentMap.clear(),this.edges=[],(b=this.graph.edges)==null||b.forEach(p=>{const f=p;let v=this.renderGraphMap.get(f.sources[0]);v==null||v.outputs.push(f);let m=this.renderGraphMap.get(f.targets[0]);m==null||m.inputs.push(f),f.ref.length>0&&v&&(v.isRef=!0);const C=new Wx(f);this.collapsedEdges.has(f.id)&&(C.visible=!1),this.nodeLimitExceeded&&(C.animated=!1),this.edges.push(f),this.edgeComponents.push(C),this.edgeComponentMap.set(f.id,C),C.bendPoints=this.bendPoints,C.bendCurve=this.bendEdges,f.dependency&&(C.isDependency=!0,this.dimDependencies&&(C.dim=!0))}),this.renderGraphMap.forEach(p=>{p.outputs.length<=0?p.inputs.forEach(f=>{const v=this.edgeComponentMap.get(f.id);v&&(v.targetIsLeaf=!0)}):p.outputs.forEach(f=>{if(f.ref!=""){const v=this.edgeComponentMap.get(f.id);v&&v.targetIsLeaf&&(v.targetIsLeaf=!1,p.isLeaf=!1,p.isRef=!0)}})})}readyGo(){this.buildNodes(),this.buildEdges(),this.ready=!0,this.requestUpdate()}reset(){this.direction="RIGHT";const b=this.buildBaseViewBox();this.svgItem.setAttribute("viewBox",`${b.offset} 80 ${b.base} ${b.base}`),this.resetNodes(),this.buildGraph(),setTimeout(()=>{if(this.activeNode){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash,first:!0}}));return}this.navigateToRoot()},150)}navigateToRoot(){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:"root",first:!0}}))}animateViewBox(b,p,f){const v=this.svgItem.viewBox.baseVal,m=v.x,C=v.y,M=performance.now(),H=ce=>ce<.5?4*ce*ce*ce:1-Math.pow(-2*ce+2,3)/2;function q(ce){const Y=ce-M,me=Math.min(Y/f,1),ve=H(me);v.x=m+(b-m)*ve,v.y=C+(p-C)*ve,me<1&&requestAnimationFrame(q)}requestAnimationFrame(q)}moveToNode(b,p=!1){if(this.svgItem){const f=this.svgItem.viewBox.baseVal,v=this.graphResponse.nodes.find(m=>m.idHash===b.idHash);v!=null&&v.x&&v.y&&!v.filtered&&(p?this.animateViewBox(v.x-100,v.y-100,200):this.animateViewBox(v.x-f.width/2+v.width/2,v.y-f.height/2+v.height/2,200))}}buildBaseViewBox(){var f;let b=600,p=0;return(f=this.graph.children)==null||f.forEach(()=>{b+=1,p+=20}),p>900&&(p=900),{base:b,offset:p}}render(){if(!this.ready)return I.html`
7403
+ `}};zh.styles=[AQ,ru,N3,qp],j0([z.query("form")],zh.prototype,"form",2),j0([z.property({type:Number})],zh.prototype,"nodeNodeBetweenLayers",2),j0([z.property({type:Number})],zh.prototype,"nodeNode",2),j0([z.property({type:Number})],zh.prototype,"edgeNodeBetweenLayers",2),j0([z.property({type:Number})],zh.prototype,"edgeNode",2),j0([z.property({type:Boolean})],zh.prototype,"bendEdges",2),j0([z.property({type:Boolean})],zh.prototype,"bendPoints",2),j0([z.property({type:Boolean})],zh.prototype,"renderRefs",2),j0([z.property({type:Boolean})],zh.prototype,"renderPoly",2),j0([z.property({type:Boolean})],zh.prototype,"dimDependencies",2),zh=j0([z.customElement("pb33f-explorer-equalizer")],zh);function Wvt(b){return new Worker("/assets/graph-dependent.worker-CpVhp0-T.js",{name:b==null?void 0:b.name})}var Yvt=Object.defineProperty,Vvt=Object.getOwnPropertyDescriptor,Vx=(b,p,f,v)=>{for(var m=v>1?void 0:v?Vvt(p,f):p,C=b.length-1,M;C>=0;C--)(M=b[C])&&(m=(v?M(p,f,m):M(m))||m);return v&&m&&Yvt(p,f,m),m};let xm=class extends PQ{constructor(){super(),this.nodeComponents=[],this.edgeComponents=[],this.scale=1,this.dragStartViewBoxX=0,this.dragStartViewBoxY=0,this.zoomMax=8e3,this.zoomMin=50,this.collapsedNodes=new Map,this.collapsedEdges=new Map,this.elk=new y2t,this.ready=!1,this.direction="RIGHT",this.nodeMap=new Map,this.renderGraphMap=new Map,this.edgeComponentMap=new Map,this.renderedNodeMap=new Map,this.collapsedNodes=new Map,this.nodes=[],this.edges=[],this.nodeNodeBetweenLayers="100",this.nodeNode="80",this.edgeNodeBetweenLayers="30",this.edgeNode="120",this.bendEdges=!0,this.bendPoints=!0,this.renderRefs=!1,this.renderPoly=!1,this.nodeLimitExceeded=!1,this.nodeLimit=-1,this.equalizer=new zh,this.equalizer.nodeNodeBetweenLayers=parseInt(this.nodeNodeBetweenLayers),this.equalizer.nodeNode=parseInt(this.nodeNode),this.equalizer.edgeNodeBetweenLayers=parseInt(this.edgeNodeBetweenLayers),this.equalizer.edgeNode=parseInt(this.edgeNode),this.equalizer.bendEdges=this.bendEdges,this.equalizer.bendPoints=this.bendPoints,this.equalizer.renderRefs=this.renderRefs,this.equalizer.renderPoly=this.renderPoly,this.dimDependencies=!1,this.graphDependentWorker=new Wvt,this.equalizer.addEventListener(Tve,this.zoomIn.bind(this)),this.equalizer.addEventListener(Ove,this.zoomOut.bind(this)),this.equalizer.addEventListener(Dve,this.rotate.bind(this)),this.equalizer.addEventListener(Rve,this.reset.bind(this)),this.equalizer.addEventListener(oQ,this.equalizerChanged.bind(this)),this.equalizer.addEventListener(cQ,this.equalizerFiltered.bind(this)),this.addEventListener(_ve,this.dependentNodeClicked.bind(this)),this.graphDependentWorker.onmessage=b=>{this.toggleNodeVisibility(b.data.filteredNodes,b.data.filteredEdges,b.data.collapse)}}toggleNodeVisibility(b,p,f){b.forEach(v=>{const m=this.nodeComponents.find(C=>C.id===v.idHash);m&&(m.visible&&f&&(m.visible=!1,this.collapsedNodes.set(v.idHash,!0)),!m.visible&&!f&&(m.visible=!0,this.collapsedNodes.delete(v.idHash)))}),p.forEach(v=>{const m=this.edgeComponents.find(C=>C.edge.id===v.id);m&&(m.visible&&f&&(m.visible=!1,this.collapsedEdges.set(v.id,!0)),!m.visible&&!f&&(m.visible=!0,this.collapsedEdges.delete(v.id)))}),this.requestUpdate()}dependentNodeClicked(b){this.graphDependentWorker&&this.graphDependentWorker.postMessage({dependentNode:b.detail.node,collapse:b.detail.collapse,nodes:this.graphResponse.nodes,edges:this.graphResponse.edges})}updateGraphResponse(b){this.graphResponse=b,this.equalizer.graphResponse=b,this.equalizer.controls.searchComponent.graphResponse=b}rotate(){switch(this.direction){case"LEFT":this.direction="UP";break;case"DOWN":this.direction="LEFT";break;case"RIGHT":this.direction="DOWN";break;case"UP":this.direction="RIGHT";break}this.resetNodes(),this.buildGraph(),setTimeout(()=>{if(this.activeNode){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash}}));return}})}mouseMove(b){this.grabbed&&requestAnimationFrame(()=>{const p=this.svgItem.viewBox.baseVal,f=(b.clientX-this.startX)*(p.width/this.svgItem.clientWidth),v=(b.clientY-this.startY)*(p.height/this.svgItem.clientHeight);p.x=this.dragStartViewBoxX-f,p.y=this.dragStartViewBoxY-v})}mouseDown(b){this.grabbed=!0;const p=this.svgItem.viewBox.baseVal;this.startX=b.clientX,this.startY=b.clientY,this.dragStartViewBoxX=p.x,this.dragStartViewBoxY=p.y}mouseUp(){this.grabbed=!1}zoom(b){var me;b=Math.abs(b)<.02?b/Math.abs(b)*.02:b;let[p,f,v,m]=(me=this.svgItem.getAttribute("viewBox"))==null?void 0:me.split(" ").map(Number),C=p+v/2,M=f+m/2,[H,q]=[v+v*b,m+m*b],ce=C-H/2,Y=M-q/2;H>=this.zoomMax||H<=this.zoomMin||this.svgItem.setAttribute("viewBox",`${ce} ${Y} ${H} ${q}`)}zoomIn(){this.zoom(-.1)}zoomOut(){this.zoom(.1)}onWheel(b){var De,Nt;b.preventDefault();let p=b.deltaY/1e3;p=Math.abs(p)<.02?.02*b.deltaY/Math.abs(b.deltaY):p;let f=new DOMPoint(b.clientX,b.clientY);f=f.matrixTransform((De=this.svgItem.getScreenCTM())==null?void 0:De.inverse());let[v,m,C,M]=(Nt=this.svgItem.getAttribute("viewBox"))==null?void 0:Nt.split(" ").map(Number),[H,q]=[(f.x-v)/C,(f.y-m)/M],[ce,Y]=[C+C*p,M+M*p],me=f.x-H*ce,ve=f.y-q*Y;ce>=this.zoomMax||ce<=this.zoomMin||Number.isNaN(me)||Number.isNaN(ve)||Number.isNaN(ce)||Number.isNaN(Y)||requestAnimationFrame(()=>{this.svgItem.setAttribute("viewBox",`${me} ${ve} ${ce} ${Y}`)})}equalizerFiltered(b){this.graphResponse=b.detail.graph,this.buildGraph()}equalizerChanged(b){var p;b.detail.graph.nodes.length>0&&(this.graphResponse=b.detail.graph),b.detail.spacing&&(b.detail.spacing.nodeNodeBetweenLayers&&(this.nodeNodeBetweenLayers=b.detail.spacing.nodeNodeBetweenLayers.toString()),b.detail.spacing.nodeNode&&(this.nodeNode=b.detail.spacing.nodeNode.toString()),b.detail.spacing.edgeNodeBetweenLayers&&(this.edgeNodeBetweenLayers=b.detail.spacing.edgeNodeBetweenLayers.toString()),b.detail.spacing.edgeNode&&(this.edgeNode=b.detail.spacing.edgeNode.toString()),this.bendEdges=!!b.detail.spacing.bendEdges,this.bendPoints=!!b.detail.spacing.bendPoints,this.dimDependencies=!!((p=b.detail.options)!=null&&p.dimDependents)),b.detail.references&&(this.renderRefs=!!b.detail.references.renderRefs,this.renderPoly=!!b.detail.references.renderPoly),this.buildGraph(),setTimeout(()=>{if(this.activeNode&&this._visible){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash,first:!0}}));return}},150)}buildLayout(){this.elk.layout(this.graph,{layoutOptions:{algorithm:"layered"},logging:!0,measureExecutionTime:!0}).then(this.readyGo.bind(this))}resetNodes(){var b,p;(b=this.graph.children)==null||b.forEach(f=>{const v=f;delete v.x,delete v.y}),(p=this.graph.edges)==null||p.forEach(f=>{delete f.sections})}generateOptions(){return{"spacing.nodeNodeBetweenLayers":this.nodeNodeBetweenLayers,"spacing.nodeNode":this.nodeNode,"elk.nodeLabels.placement":"INSIDE V_CENTER H_RIGHT","elk.algorithm":"layered","elk.direction":this.direction,"org.eclipse.elk.edgeRouting":"ORTHOGONAL","elk.layered.unnecessaryBendpoints":"true","elk.layered.spacing.edgeNodeBetweenLayers":this.edgeNodeBetweenLayers,"org.eclipse.elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","org.eclipse.elk.layered.cycleBreaking.strategy":"DEPTH_FIRST","nodePlacement.strategy":"BRANDES_KOEPF","org.eclipse.elk.spacing.edgeLabel":"0","org.eclipse.elk.spacing.edgeNode":this.edgeNode,"org.eclipse.elk.layered.edgeLabels.sideSelection":"ALWAYS_UP","org.eclipse.elk.spacing.portPort":"10"}}buildGraph(){const b={id:"root",layoutOptions:this.generateOptions(),children:this.graphResponse.nodes,edges:this.graphResponse.edges};return this.graph=b,this.nodeMap.clear(),this.buildLayout(),this.equalizer.graphResponse||(this.equalizer.graphResponse=this.graphResponse),b}generateNodeType(b){switch(b){case de.DOCUMENT:return new zO;case de.INFO:return new HO;case de.LICENSE:return new UO;case de.CONTACT:return new GO;case de.TAG:return new qO;case de.SERVER:return new KO;case de.COMPONENTS:return new WO;case de.SCHEMA:return new AI;case de.SECURITY_SCHEME:return new YO;case de.PARAMETER:return new VO;case de.HEADER:return new QO;case de.REQUEST_BODY:return new ZO;case de.MEDIA_TYPE:return new XO;case de.RESPONSE:return new JO;case de.LINK:return new eD;case de.CALLBACK:return new tD;case de.PATH_ITEM:return new nD;case de.OPERATION:return new iD;case de.XML:return new rD;default:return new jc}}buildNodes(){var b,p;this.nodes=[],this.nodeComponents=[],this.renderGraphMap.clear(),this.renderedNodeMap.clear(),(b=this.graphResponse.nodesRendered)==null||b.forEach(f=>{this.renderedNodeMap.set(f.id,f)}),(p=this.graph.children)==null||p.forEach(f=>{var M,H;const v=f,m=new NI;m.id=v.idHash,v.x&&v.y&&(m.x=v.x,m.y=v.y),m.width=v.width,m.height=v.height;const C=this.generateNodeType(v.type);C.height=v.height,C.width=v.width-2,C.id=v.idHash,C.label=v.label,C.isLeaf=!(v.nodes&&v.nodes.length>0),C.node=v,v.active&&(C.active=v.active,m.active=v.active),!v.active&&this.activeNode&&this.activeNode.idHash===v.idHash&&(C.active=!0,m.active=!0),v.dependency&&(C.isDependency=!0,this.dimDependencies&&(C.dim=!0)),this.collapsedNodes.has(v.idHash)&&(m.visible=!1),C.nodeInstance=(M=this.renderedNodeMap.get(v.id))==null?void 0:M.instance,v.results=(H=this.renderedNodeMap.get(v.id))==null?void 0:H.results,this.renderGraphMap.set(v.id,C),m.body=C,this.nodeComponents.push(m),this.nodes.push(v)})}buildEdges(){var b;this.edgeComponents=[],this.edgeComponentMap.clear(),this.edges=[],(b=this.graph.edges)==null||b.forEach(p=>{const f=p;let v=this.renderGraphMap.get(f.sources[0]);v==null||v.outputs.push(f);let m=this.renderGraphMap.get(f.targets[0]);m==null||m.inputs.push(f),f.ref.length>0&&v&&(v.isRef=!0);const C=new Wx(f);this.collapsedEdges.has(f.id)&&(C.visible=!1),this.nodeLimitExceeded&&(C.animated=!1),this.edges.push(f),this.edgeComponents.push(C),this.edgeComponentMap.set(f.id,C),C.bendPoints=this.bendPoints,C.bendCurve=this.bendEdges,f.dependency&&(C.isDependency=!0,this.dimDependencies&&(C.dim=!0))}),this.renderGraphMap.forEach(p=>{p.outputs.length<=0?p.inputs.forEach(f=>{const v=this.edgeComponentMap.get(f.id);v&&(v.targetIsLeaf=!0)}):p.outputs.forEach(f=>{if(f.ref!=""){const v=this.edgeComponentMap.get(f.id);v&&v.targetIsLeaf&&(v.targetIsLeaf=!1,p.isLeaf=!1,p.isRef=!0)}})})}readyGo(){this.buildNodes(),this.buildEdges(),this.ready=!0,this.requestUpdate()}reset(){this.direction="RIGHT";const b=this.buildBaseViewBox();this.svgItem.setAttribute("viewBox",`${b.offset} 80 ${b.base} ${b.base}`),this.resetNodes(),this.buildGraph(),setTimeout(()=>{if(this.activeNode){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:this.activeNode.idHash,first:!0}}));return}this.navigateToRoot()},150)}navigateToRoot(){this.dispatchEvent(new CustomEvent(h2,{bubbles:!0,composed:!0,detail:{nodeHashId:"root",first:!0}}))}animateViewBox(b,p,f){const v=this.svgItem.viewBox.baseVal,m=v.x,C=v.y,M=performance.now(),H=ce=>ce<.5?4*ce*ce*ce:1-Math.pow(-2*ce+2,3)/2;function q(ce){const Y=ce-M,me=Math.min(Y/f,1),ve=H(me);v.x=m+(b-m)*ve,v.y=C+(p-C)*ve,me<1&&requestAnimationFrame(q)}requestAnimationFrame(q)}moveToNode(b,p=!1){if(this.svgItem){const f=this.svgItem.viewBox.baseVal,v=this.graphResponse.nodes.find(m=>m.idHash===b.idHash);v!=null&&v.x&&v.y&&!v.filtered&&(p?this.animateViewBox(v.x-100,v.y-100,200):this.animateViewBox(v.x-f.width/2+v.width/2,v.y-f.height/2+v.height/2,200))}}buildBaseViewBox(){var f;let b=600,p=0;return(f=this.graph.children)==null||f.forEach(()=>{b+=1,p+=20}),p>900&&(p=900),{base:b,offset:p}}render(){if(!this.ready)return I.html`
7403
7404
  <div class="pb33f-loader" style="padding: 20px;">
7404
7405
  <div class="spin"></div>
7405
7406
  loading explorer...
@@ -9812,7 +9813,7 @@ ${n2t(b)}`}}))}render(){var q,ce,Y,me,ve;let b=I.html``,p=I.html``,f=I.html``,v=
9812
9813
  </sl-animation>
9813
9814
  </div>
9814
9815
  </div>
9815
- `}};P3.styles=[Ayt],GI([z.property()],P3.prototype,"credits",2),GI([z.property()],P3.prototype,"visible",2),GI([z.query(".arrow")],P3.prototype,"downArrow",2),GI([z.query("#arrowAnimation")],P3.prototype,"arrowAnimation",2),P3=GI([z.customElement("pb33f-credit-ticker")],P3);var jyt=Object.defineProperty,$yt=Object.getOwnPropertyDescriptor,uo=(b,p,f,v)=>{for(var m=v>1?void 0:v?$yt(p,f):p,C=b.length-1,M;C>=0;C--)(M=b[C])&&(m=(v?M(p,f,m):M(m))||m);return v&&m&&jyt(p,f,m),m};const ID="pb33f-doctor-graph",T0="pb33f-doctor-panel-state",GQ="pb33f-doctor-rolodex-response",qI="pb33f-doctor-rolodex-files",km="pb33f-doctor-rolodex-state",ND="pb33f-doctor-reference-map",Tyt="pb33f-doctor-editor",Oyt="pb33f-doctor-howtofix",Dyt="pb33f-doctor-funcdocs",qQ="pb33f-doctor-doc-expiration",Ryt="pb33f-doctor-ruledocs",KQ="pb33f-doctor-diagnostic",WQ="pb33f-doctor-default-ruleset",YQ="pb33f-doctor-owasp-ruleset",VQ="pb33f-doctor-all-ruleset",KI="pb33f-doctor-functions",WI="pb33f-doctor-function-schema",YI="pb33f-doctor-custom-ruleset",k8="pb33f-doctor-rule-configuration",ED="pb33f-doctor-session-rulesetmap",VI="pb33f-doctor-document",AD="pb33f-doctor-problems",Byt="doctor-endpoint";let Us=class extends I.LitElement{constructor(b="https://doctor.pb33f.io"){super(),this.debounceTime=400,this.debounceTimeRuleset=900,this.bounceId=0,this.useTLS=!1,this.rolodexDividerPosition=40,this._firstRun=!0,this.bus=A3t(),this.doctorServiceChannel=this.bus.createChannel(LD),this.specStreamChannel=this.bus.createChannel(_Q),this.creditStreamChannel=this.bus.createChannel(zQ),this.bus.mapChannelToBrokerDestination(HQ+LD,LD),this.bus.mapChannelToBrokerDestination(HQ+_Q,_Q),this.bus.mapChannelToBrokerDestination(HQ+zQ,zQ),this.doctorChannelSubscription=this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.specChannelSubscription=this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditChannelSubscription=this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bagManager=u3e(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new kd,this.uploadArchive=new Cd,this.nukeWorkspace=new x8,this.rulesetEditor=new kd("ruleset-editor"),this.problemList=new vI,this.detailsDrawer=new c8,this.problemsOverview=new L3,this.errorBanner=new Hx,this.statusBar=new Ux,this.ruleDocsWorker=new Wwt,this.unavailable=!1,this.feedback=new I3,this.activitySpinner=new $O,this.manageRuleset=new P1,this.toastManager=new RO,this.creditTicker=new P3,this.editorMap=new Map,this.editorMap.set("spec",this.editor),this.editorMap.set("ruleset-editor",this.rulesetEditor),this.selectedEditorTab="spec",this.sidebarClosed=!1,this.explorerVisible=!1,this.explorerBooted=!1,this.rolodexNeedsReset=!1,this.rolodexProblemMap=new Map,this.rolodexRootHash="",this.rolodexRootPath="",this.importDisabled=!1,this.pendingLine=0,this.nodeMap=new Map,this.nodeIdMap=new Map,this.nodeIdHashMap=new Map,this.renderedNodeMap=new Map,this.filteredNodes=new Map,this.modelTree=new P0(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexTree=new P0(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexActiveHash="",this.explorer=new xm,this.renderedNode=new UI,this.references=[],this.minimapVisible=!0,this.nodeLimit=150;const p=sessionStorage.getItem(Byt);p?this.doctorEndpoint=p:this.doctorEndpoint=b,this.addEventListener(eQ,this.specChanged),this.addEventListener(wve,this.specClicked),this.addEventListener(xO,this.problemClicked),this.addEventListener(Bh,this.ruleDocsClicked),this.addEventListener(Lve,this.ruleGroupClicked),this.addEventListener(tQ,this.customRulesetEnabled),this.addEventListener(nQ,this.rulesetSaved),this.addEventListener(_x,this.addToastEvent),this.addEventListener(Sve,this.exportRuleset),this.addEventListener(Ave,this.ruleClicked),this.addEventListener(kO,this.builtInRulesetSelected),this.addEventListener(h2,this.modelTreeNodeClicked),this.addEventListener(fI,this.rolodexTreeNodeClicked),this.addEventListener(jve,this.rolodexRootFileSelected),this.addEventListener(rQ,this.explorerReferenceClicked),this.addEventListener(iQ,this.explorerNodeClicked.bind(this)),this.addEventListener(zve,this.fetchUrl.bind(this)),this.addEventListener(lQ,this.documentReferenceClicked.bind(this)),this.explorer.equalizer.addEventListener(oQ,this.filterTreeModel.bind(this)),this.explorer.equalizer.addEventListener(cQ,this.filterTreeModel.bind(this)),this.nukeWorkspace.addEventListener(Hve,this.nukeWorkspaceHandler.bind(this)),this.busPort=sessionStorage.getItem("pb33f-doctor-port"),this.busHost=sessionStorage.getItem("pb33f-doctor-host"),this.busPort||(this.busPort="443"),this.busHost||(this.busHost="https://doctor.pb33f.io");const f=sessionStorage.getItem("pb33f-doctor-tls");f&&f=="true"&&(this.useTLS=!0),window.addEventListener("popstate",v=>{const m=v.state;m&&(m.activeNode&&this.modelTreeNodeClicked(new CustomEvent(iQ,{detail:{nodeHashId:m.activeNode,noState:!0}})),m.ref&&this.documentReferenceClicked(new CustomEvent(lQ,{detail:{jsonPath:m.ref,noState:!0}})))})}nukeWorkspaceHandler(){this.bagManager.resetBags(),Fh.resetWorkspace().then(()=>{window.location.reload()})}minimapToggled(){this.minimapVisible=!this.minimapVisible,this.editor.toggleMinimap(),this.rulesetEditor.toggleMinimap()}firstUpdated(){this.editor=this.querySelector("pb33f-editor#spec-editor"),this.rulesetEditor=this.querySelector("pb33f-editor#ruleset-editor")}whoAmI(){this.bus.publish({destination:"/p/q/"+LD,body:JSON.stringify({request:G3e.WhoAmI})})}connectToBroker(){let b="ws://";this.useTLS&&(b="wss://");const p={brokerURL:b+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.whoAmI()}};this.bus.connectToBroker(p)}addClickTrack(b){history.pushState({activeNode:b.idHash},"",`?view=explore&node=${b.idHash}`)}addRefTrack(b){history.pushState({ref:b},"",`?view=spec&ref=${b}`)}doctorServiceHandler(){return b=>{var p;((p=b.payload)==null?void 0:p.payload)!=null&&kyt(b.payload.payload)&&(this.brokerConnectionId=b.payload.payload.broker,console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you.","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor())}}startTheDoctor(){this.boostrap(),this.loadingOverlay.hide()}specStreamHandler(){return b=>{var p,f;if(((p=b.payload)==null?void 0:p.payload)!=null){const v=atob(b.payload.payload);this.docBag&&this.docBag.set(VI,v),(f=this.editor)==null||f.setValue(v,!0),this.requestUpdate()}}}creditStreamHandler(){return b=>{var p;((p=b.payload)==null?void 0:p.payload)!=null&&(this.creditTicker.credits=parseInt(b.payload.payload))}}filterTreeModel(b){this.filteredNodes=new Map,b.detail.graph.nodes.forEach(p=>{this.filteredNodes.set(p.idHash,p)}),this.modelTree.filteredNodes=this.filteredNodes,this.modelTree.renderedNodes=this.renderedNodeMap}documentReferenceClicked(b){var q,ce;let p="",f,v=1,m=b.detail.jsonPath,C="",M="",H="";if(b.detail.jsonPath.includes("||")&&(p=b.detail.jsonPath.split("||")[1],m=b.detail.jsonPath.split("||")[0],f=parseInt(p.split(":")[0]),v=parseInt(p.split(":")[1]),C=b.detail.jsonPath.split("||")[2],C!=""&&(M=C.split("#")[0]),H=b.detail.jsonPath.split("||")[3]),(q=this.editor.editor)==null||q.setPosition({lineNumber:f,column:v}),(ce=this.editor.editor)==null||ce.revealLineInCenter(f),this.nodeIdMap.has(m)){const Y=this.nodeIdMap.get(m);if(Y){if(this.nodeIdHashMap.has(Y.idHash)){const me=this.renderedNodeMap.get(Y.idHash);me&&(this.renderedNode.node=me,this.modelTree.explorerClicked(Y.idHash),b.detail.noState||this.addRefTrack(b.detail.jsonPath))}}else this.toastManager.addToastManually({id:crypto.randomUUID(),type:Ol.INFO,title:"Reference not found",body:`Something went wrong, '${m}' not found`})}else this.rolodexActivePath!=null&&this.rolodexActivePath!=M&&Fh.queryRolodex(H,M).then(Y=>{var me,ve;if(this.editor.showBreadcrumb=!0,this.rolodexActivePath=M,this.editor.clearDecorations(),this.editor.setValue(Y.rolodexRoot.instance,!0),(me=this.editor.editor)==null||me.setPosition({lineNumber:f,column:1}),(ve=this.editor.editor)==null||ve.revealLineInCenter(f),this.rolodexTree.explorerClicked(H),this.editor.setCurrentPath(M),this.lintSpec(Y.rolodexRoot.instance),this.rolodexProblemMap.has(this.rolodexActivePath)){const De=this.rolodexProblemMap.get(this.rolodexActivePath);De&&this.editor.setMarkers(De)}}).catch(Y=>{console.error("rolodex query failed",Y)})}explorerReferenceClicked(b){let p="";if(this.explorer.nodeComponents.forEach(f=>{var v,m;if(f.body.node.nodePath===b.detail.nodePath){const C=this.renderedNodeMap.get(f.body.node.idHash);C&&((v=this.editor.editor)==null||v.setPosition({lineNumber:C.keyLine,column:0}),(m=this.editor.editor)==null||m.revealLineInCenter(C.keyLine),this.renderedNode.node=C,p=f.body.node.idHash,this.explorer.moveToNode(f.body.node),this.activeNode=f.body.node,this.explorer.activeNode=f.body.node,this.explorer.equalizer.activeNode=f.body.node),f.body.active=!0}else f.body.active=!1}),p&&(this.modelTree.explorerClicked(p),this.explorer.requestUpdate(),this.viewerPanel.click()),b.detail.nodePath){let f=b.detail.nodePath;!f.startsWith("/")&&!f.includes("#")&&(f=this.rolodexRootPath.substring(0,this.rolodexRootPath.lastIndexOf("/")+1)+f),f.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{path:f}}))}}rolodexTreeNodeClicked(b){var v;const p=(v=this.rolodexFilesBag)==null?void 0:v.get(qI),f=m=>{var me,ve,De,Nt,Yn,zn,Xi;this.rolodexActivePath=b.detail.path,this.rolodexActiveHash=b.detail.nodeHashId,this.editor.setValue(m.instance,!0),this.editor.setCurrentPath(this.rolodexActivePath);const C=this.rolodexProblemMap.get(this.rolodexActivePath);C&&this.editor.setMarkers(C);let M="yaml";const H=(ve=(me=b.detail)==null?void 0:me.path)==null?void 0:ve.split(".").pop();if(H)switch(H){case de.JSON:M=de.JSON;break;case de.GO:M=de.GO;break;case de.PY:M="python";break;case de.JS:M="javascript";break;case de.TS:M="typescript";break;case de.PHP:M=de.PHP;break;case de.XML:M=de.XML;break;case de.JAVA:M=de.JAVA;break;case de.RB:M="ruby";break;case de.RS:M="rust";break;case de.C:M=de.C;break;case de.CPP:M=de.CPP;break;case de.CS:M="csharp";break;case de.MD:M="markdown";break}const q=(De=this.rolodexStateBag)==null?void 0:De.get(km);if(q)q.activePath=b.detail.path,q.activeHash=b.detail.nodeHashId,q.activeLanguage=M,q.activeNode=m,q.rootPath=this.rolodexRootPath,(Nt=this.rolodexStateBag)==null||Nt.set(km,q);else{const Ur={activePath:b.detail.path,activeHash:b.detail.nodeHashId,activeLanguage:M,activeNode:m,rootHash:this.rolodexRootHash,rootPath:this.rolodexRootPath};(Yn=this.rolodexStateBag)==null||Yn.set(km,Ur)}this.editor.switchLanguage(M);let ce=1,Y=0;return b.detail.line&&(ce=b.detail.line),b.detail.column&&(Y=b.detail.column),(zn=this.editor.editor)==null||zn.setPosition({lineNumber:ce,column:Y}),(Xi=this.editor.editor)==null||Xi.revealLineInCenter(ce,Y),this.lintSpec(m.instance),b.detail.path&&this.rolodexTree.openNodeByPath(b.detail.path),M};Fh.queryRolodex(b.detail.nodeHashId,b.detail.path).then(m=>{var C,M,H;if(this.editor.showBreadcrumb=!0,(C=this.referenceMapBag)==null||C.reset(),f(m.rolodexRoot),b.detail.path&&(p&&!p.files[b.detail.path]&&(p.files[b.detail.path]=m.rolodexRoot,(M=this.rolodexFilesBag)==null||M.set(qI,p)),!p)){const q={files:{[b.detail.path]:m.rolodexRoot}};(H=this.rolodexFilesBag)==null||H.set(qI,q)}})}rolodexRootFileSelected(b){var f,v,m;this.rolodexActivePath=b.detail.path,this.rolodexActiveHash=b.detail.nodeHashId,this.rolodexRootPath=b.detail.path,this.importDisabled=!0;const p=(f=this.rolodexStateBag)==null?void 0:f.get(km);if(p)p.activePath=b.detail.path,p.activeHash=b.detail.nodeHashId,p.rootPath=b.detail.path,p.rootHash=b.detail.nodeHashId,(v=this.rolodexStateBag)==null||v.set(km,p);else{const C={activePath:b.detail.path,activeHash:b.detail.nodeHashId,rootPath:b.detail.path,rootHash:b.detail.nodeHashId};(m=this.rolodexStateBag)==null||m.set(km,C)}b.detail.nodeHashId&&(this.rolodexRootHash=b.detail.nodeHashId),b.detail.content&&(this.rolodexNeedsReset=!0,this.editor.setValue(b.detail.content,!0),this.lintSpec(b.detail.content))}modelTreeNodeClicked(b){var f,v,m;const p=this.nodeIdHashMap.get(b.detail.nodeHashId);if(p){if(p.origin&&p.origin!=this.rolodexActivePath&&p.origin!="/root.yaml"){let M="";const H=(f=this.rolodexFilesBag)==null?void 0:f.get(qI);H&&H.files[p.origin]&&(M=H.files[p.origin].idHash),this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{nodeHashId:M,path:p.origin}}));return}(v=this.editor.editor)==null||v.setPosition({lineNumber:p.keyLine,column:0}),(m=this.editor.editor)==null||m.revealLineInCenter(p.keyLine),this.explorerVisible&&this.explorer.moveToNode(p,b.detail.first),this.activeNode=p,this.explorer.activeNode=p,this.explorer.equalizer.activeNode=p;const C=this.renderedNodeMap.get(p.idHash);C&&(this.renderedNode.node=C),b.detail.noState||(this.addClickTrack(p),b.detail.noState=!0),this.explorerNodeClicked(b),this._firstRun?this._firstRun=!1:this.viewerPanel.click()}}explorerNodeClicked(b){let p=!1,f;if(this.explorer.nodeComponents.forEach(v=>{if(v.id===b.detail.nodeHashId){const m=this.renderedNodeMap.get(v.id);m&&!this._firstRun&&(this.renderedNode.node=m),this.selectedNodeHashId=v.body.node.idHash,v.body.active=!0,this.activeNode=v.body.node,this.explorer.activeNode=v.body.node,p=!0,f=m,b.detail.noState||this.addClickTrack(v.body.node)}else v.body.active=!1}),!p){const v=this.nodeIdHashMap.get(b.detail.nodeHashId);v&&(this.selectedNodeHashId=b.detail.nodeHashId,this.activeNode=v,this.explorer.activeNode=v,this.explorer.equalizer.activeNode=v)}f&&(this.pendingLine=f.keyLine),this.modelTree.explorerClicked(b.detail.nodeHashId),this._firstRun||this.viewerPanel.click(),this.explorer.requestUpdate()}exportRuleset(){this.exportRulesetDialog.show()}addToastEvent(b){this.sendToast(b.detail.toast)}sendToast(b){this.toastManager.addToastManually(b)}ruleGroupClicked(b){this.problemsPanel.focus();const p=new CustomEvent(Cve,{bubbles:!0,composed:!0,detail:{rule:b.detail.rule}});this.problemsPanel.focus(),this.problemList.dispatchEvent(p),history.pushState({rule:b.detail.rule},"",`/${Tu.Problems}?rule=${b.detail.rule}`),this.controlTabGroup.show(Tu.Problems)}ruleDocsClicked(b){var f,v,m;const p=b.detail.rule;if(p)switch(b.detail.type){case iu.RULE_DOCS:const C=(f=this.ruleDocsBag)==null?void 0:f.get(p);C?(b.detail.body=C.body,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"Rule documentation unavailable",body:`Documentation for '${p}' not available`});break;case iu.HOW_TO_FIX:const M=(v=this.howToFixBag)==null?void 0:v.get(p);M?(b.detail.body=M.howToFix,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"How to fix unavailable",body:`Information on how to fix '${p}' not available`});break;case iu.FUNCTION_DOCS:const H=(m=this.functionDocsBag)==null?void 0:m.get(p);H?(b.detail.body=H.body,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"Function documentation unavailable",body:`Documentation for '${p}' not available`});break}else switch(b.detail.type){case iu.RENDERED_EXAMPLE:case iu.MARKDOWN:this.detailsDrawer.open(b.detail)}}rulesetSaved(b){var p,f,v;if(this.docBag){const m=this.docBag.get(VI),C=(p=this.ruleConfigBag)==null?void 0:p.get(k8);if(b.detail.rules){if((f=this.customRulesetBag)==null||f.set(YI,b.detail.rules),C){const M=b.detail.config;M&&this.ruleConfigBag&&(M.returnedRuleset=b.detail.returnedRules,(v=this.ruleConfigBag)==null||v.set(k8,M))}_h.getSessionRulesetAsYAML().then(M=>{this.selectedEditorTab=="spec"&&(this.rulesetPulse=!0),this.rulesetEditor.setValue(M,!0),this.fetchRulesetMap()}),this.lintSpec(m,"")}}}buildRolodexResultMap(b){return this.rolodexProblemMap.clear(),b.forEach(p=>{if(p.sourceLocation==="/root.yaml"&&(p.sourceLocation="root"),this.rolodexProblemMap.has(p.sourceLocation)){const f=this.rolodexProblemMap.get(p.sourceLocation);f&&(f.push(p),p.sourceLocation?this.rolodexProblemMap.set(p.sourceLocation,f):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,f):this.rolodexProblemMap.set("root",f))}else p.sourceLocation?this.rolodexProblemMap.set(p.sourceLocation,[p]):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,[p]):this.rolodexProblemMap.set("root",[p])}),this.rolodexProblemMap}lintSpec(b,p){var M;this.activitySpinner.show(),this.editor.breadcumb.isInvalid=!1,p?p==="root"?p="":(this.urlProblem.style.display="none",this.urlOverlay.style.display="block",this.urlSpinner.style.display="block",(M=this.referenceMapBag)==null||M.reset()):(this.urlProblem.style.display="none",this.urlOverlay.style.display="none",this.urlSpinner.style.display="none");let f=!1,v=this.rolodexActivePath;if((this.rolodexActivePath===this.rolodexRootPath||this.rolodexActivePath==="root")&&(f=!0,v="",this.editor.showBreadcrumb=!1),p&&p!="")try{const H=new URL(p);H&&(v=H.pathname,this.rolodexActivePath=v,this.rolodexRootPath=v,f=!0)}catch{}const m=(H=!1)=>{var q;(q=this.referenceMapBag)==null||q.export().size,Fh.fetchReferenceMap().then(ce=>{H?(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!0,this.editor.dead(),this.problemList.isInvalid=!0,this.editor.requestUpdate()):(this.references=ce,this.editor.links=ce,this.editor.applyLinkDecorations()),this.updateRefmapBag(v,ce)}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.toastManager.addToastManually({id:crypto.randomUUID(),type:Ol.INFO,title:"File not analyzed",body:"This file is not a JSON or YAML file, it has not been analyzed."})})};let C=!0;k3.lintFile(b,this.brokerConnectionId,p,v).then(H=>{var ce,Y;this.buildRolodexResultMap(H),p&&(this.urlOverlay.style.display="none",this.urlSpinner.style.display="none",this.urlProblem.style.display="none");let q=this.rolodexProblemMap.get("root");if(this.rolodexRoot||(q=[]),H&&!Array.isArray(H)){const me=[H];if(this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const ve=this.rolodexProblemMap.get(this.rolodexActivePath);ve?(q&&ve.push(...q),this.editor.setMarkers(ve)):(q&&me.push(...q),this.editor.setMarkers(me))}else q&&me.push(...q),this.editor.setMarkers(me);(ce=this.problemBag)==null||ce.set(AD,me),this.problemList.problems=me,this.problems=me,this.problemsOverview.problems=this.problemList.problemItems}if(H&&Array.isArray(H)){if(H.length==0&&(this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!1,this.editor.showBreadcrumb=!1,C=!0,this.problemList.isInvalid=!1),H.length==1&&H[0].message.startsWith("unable to parse")&&(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.setMarkers(H),this.editor.breadcumb.isInvalid=!0,this.editor.showBreadcrumb=!0,this.editor.dead(),this.problemList.isInvalid=!0,C=!1),C&&this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const me=this.rolodexProblemMap.get(this.rolodexActivePath);me?(q&&me.push(...q),this.editor.setMarkers(me)):(q&&H.push(...q),this.editor.setMarkers(H))}else if(f)this.editor.setMarkers(H);else{m();return}(Y=this.problemBag)==null||Y.set(AD,H),this.problemList.problems=H,this.problems=H,this.problemsOverview.problems=this.problemList.problemItems,this.problemsOverview.statistics&&H.length==1&&(this.problemsOverview.statistics.statistics.totalErrors=1,this.problemsOverview.statistics.statistics.overallScore=0,this.problemsOverview.statistics.evaluation="Useless",this.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+H[0].message)}if(C)this.editor.revive();else return;(this.rolodexRootPath==this.rolodexActivePath||this.rolodexActivePath=="root")&&Fh.createGraph().then(me=>{this.extractGraph(me)}),m(),this.rolodexNeedsReset&&Fh.queryRolodex().then(me=>{var De,Nt,Yn;if(this.importDisabled=!0,this.editor.showBreadcrumb=!0,this.rolodexNeedsReset=!1,me.rolodexRoot.treeExpanded=!0,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=me.rolodexRoot,this.rolodexRoot=me.rolodexRoot,this.rolodexActiveHash&&(this.rolodexTree.pendingNavigationHash=this.rolodexActiveHash),this.rolodexActivePath&&(this.rolodexTree.pendingNavigationPath=this.rolodexActivePath),(De=this.rolodexResponseBag)==null||De.set(GQ,me),!((Nt=this.rolodexStateBag)==null?void 0:Nt.get(km))){const zn={activePath:this.rolodexActivePath,rootPath:this.rolodexRootPath};(Yn=this.rolodexStateBag)==null||Yn.set(km,zn)}this.requestUpdate()}),k3.fetchStatistics().then(me=>{var ve;this.problemsOverview.statistics&&this.problemsOverview.statistics.statistics.overallScore,(ve=this.diagnosticBag)==null||ve.set(KQ,me),this.activitySpinner.hide(),(me==null?void 0:me.remainingCredit)<=10&&(this.statusBar.callsRemaining=me.remainingCredit,this.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+me.remainingCredit+" credits remaining.")),this.problemsOverview.statistics=me}).catch(me=>{console.error("statistics service is down",me),this.platformUnavailable(me)}),this.explorerBooted||(this.explorer.equalizer.initializeEqualizer(),this.explorerBooted=!0)}).catch(H=>{p?this.showUrlError(H):(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),H&&(console.error(H.detail),H.instance==="https://pb33f.io/errors/no-credit-remaining"&&(this.statusBar.callsRemaining=0,this.statusBar.visible=!0,this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:"Run out of credit, please authenticate for more or wait 24 hours.",title:"Credit exhausted!"}))))})}updateInspectorDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.inspectorPanel=this.splitPanelInspector.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{inspectorPanel:this.splitPanelInspector.position})}updateExplorerDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.explorerPanel=this.splitPanelExplorer.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{explorerPanel:this.splitPanelExplorer.position})}updateRolodexDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.rolodexPanel=this.splitPanelRolodex.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{rolodexPanel:this.splitPanelRolodex.position}),this.rolodexDividerPosition=this.splitPanelRolodex.position}updateRefmapBag(b,p){var m,C;let f=(m=this.referenceMapBag)==null?void 0:m.get(ND),v=b;f?f.references[v]=p:f={references:{[v]:p}},(C=this.referenceMapBag)==null||C.set(ND,f)}platformUnavailable(b){this.unavailable||(this.loadingOverlay.hide(),this.activitySpinner.hide(),this.errorBanner.errorTitle="The doctor is out.",b?this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because "+b.detail:this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because there is no response from the platform.",this.errorBanner.visible=!0,this.unavailable=!0,this.problemsOverview.unavailable=!0,this.controlTabGroup.show(Tu.Overview))}specClicked(b){var p,f,v;if(this.detailsDrawer.close(),this.selectedEditorTab=="spec"){let m=!1;for(let M=0;M<((p=this.problems)==null?void 0:p.length);M++)if(this.problems[M].startLineNumber===b.detail.line){this.problemList.lineClicked(b.detail.line,!0),this.controlTabGroup.show(Tu.Problems),this.sidebarClosed&&this.toggleSidebar(),m=!0;break}const C=(f=this.graphBag)==null?void 0:f.get(ID);if(C&&C.graphMap&&b.detail.line){const M=C.graphMap[b.detail.line];if(M){this.modelTree.explorerClicked(M);const H=this.renderedNodeMap.get(M);H&&(this.renderedNode.node=H),m||this.viewerPanel.click();const q=this.nodeIdHashMap.get(M);q&&(this.explorer.activeNode=q,this.explorer.equalizer.activeNode=q)}}}if(this.selectedEditorTab==Tu.Ruleset){const m=(v=this.sessionRulesetMapBag)==null?void 0:v.get(ED);if(m!=null&&m.rulesMap){for(let C=0;C<m.rulesMap.length;C++)if(m.rulesMap[C].line===b.detail.line){this.controlTabGroup.show(Tu.Ruleset),this.sidebarClosed&&this.toggleSidebar();break}}}}problemClicked(b){var v,m;this.selectedEditorTab!="spec"&&(this.editorTabGroup.show("spec"),this.selectedEditorTab="spec");let p=b.detail.problem.problemObject.sourceLocation;(p==""||p==null||p=="root")&&(p=this.rolodexRootPath);const f=b3e(this.rolodexRoot,p);if(f){this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{nodeHashId:f.idHash,path:p,line:b.detail.problem.problemObject.startLineNumber,column:b.detail.problem.problemObject.startColumn}})),this.detailsDrawer.close(),this.rolodexTree.openNodeByPath(p);return}this.controlTabGroup.show(Tu.Problems),(v=this.editor.editor)==null||v.revealLineInCenter(b.detail.problem.line),(m=this.editor.editor)==null||m.setPosition({lineNumber:b.detail.problem.line,column:b.detail.problem.column}),this.detailsDrawer.close(),b.detail.launchedFromProblems||this.problemList.lineClicked(b.detail.problem.problemObject.startLineNumber)}loadState(){if(k3.doctorEndpoint=this.doctorEndpoint,jO.doctorEndpoint=this.doctorEndpoint,_h.doctorEndpoint=this.doctorEndpoint,Fh.doctorEndpoint=this.doctorEndpoint,this.connectToBroker(),this.graphBag=this.bagManager.getBag(ID),this.docBag=this.bagManager.getBag(Tyt),this.rolodexResponseBag=this.bagManager.getBag(GQ),this.rolodexFilesBag=this.bagManager.getBag(qI),this.rolodexStateBag=this.bagManager.getBag(km),this.referenceMapBag=this.bagManager.getBag(ND),this.docExpirationBag=this.bagManager.getBag(qQ),this.panelStateBag=this.bagManager.getBag(T0),this.rolodexResponseBag){const v=this.rolodexResponseBag.get(GQ);v&&(this.rolodexRoot=v.rolodexRoot,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=v.rolodexRoot,v.rolodexRoot.treeExpanded=!0,this.requestUpdate())}let b=!1;const p=v=>{var C;let m=(C=this.referenceMapBag)==null?void 0:C.get(ND);m?setTimeout(()=>{let M=m==null?void 0:m.references[v];M||(M=m==null?void 0:m.references[""]),M&&(this.references=M,this.editor.links=M,this.editor.applyLinkDecorations())},5):Fh.fetchReferenceMap().then(M=>{this.references=M,this.editor.links=M,this.editor.applyLinkDecorations()}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers()})};if(this.rolodexStateBag){const v=this.rolodexStateBag.get(km);v?(this.rolodexActivePath=v.activePath,this.rolodexActiveHash=v.activeHash,v.rootHash&&(this.rolodexTree.pendingNavigationHash=v.rootHash),v.rootPath&&(this.rolodexRootPath=v.rootPath,v.activePath&&p(v.activePath),Fh.selectRootPath(v.rootPath).then(()=>{}).catch(m=>{console.error("could not select the root path on boot bro",m)})),v.rootHash&&(this.rolodexRootHash=v.rootHash),v.activePath&&(this.rolodexTree.pendingNavigationPath=v.activePath,this.rolodexTree.requestUpdate()),v.activeNode&&(v.activeLanguage&&this.editor.switchLanguage(v.activeLanguage),this.editor.setValue(v.activeNode.instance,!0),b=!0)):(this.rolodexActivePath="root",p(this.rolodexActivePath))}if(this.docBag&&!b){const v=this.docBag.get(VI);v&&this.editor.setValue(v,!0)}if(this.problemBag=this.bagManager.getBag(AD),this.problemBag){const v=this.problemBag.get(AD);if(v){this.problems=v;for(let m=0;m<v.length;m++)v[m]=f2.reconstruct(v[m]);if(this.buildRolodexResultMap(v),this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m)}this.problemList.problems=v,this.problemsOverview.problems=this.problemList.problemItems}}if(this.howToFixBag=this.bagManager.getBag(Oyt),this.diagnosticBag=this.bagManager.getBag(KQ),this.diagnosticBag){const v=this.diagnosticBag.get(KQ);v&&(this.problemsOverview.statistics=v)}if(this.graphBag){const v=this.graphBag.get(ID);v&&this.extractGraph(v)}if(this.panelStateBag){const v=this.panelStateBag.get(T0);v&&v.explorerPanel&&(this.splitPanelExplorer.position=v.explorerPanel),v&&v.rolodexPanel&&(this.splitPanelRolodex&&(this.splitPanelRolodex.position=v.rolodexPanel),this.rolodexDividerPosition=v.rolodexPanel),v&&v.inspectorPanel&&(this.splitPanelInspector.position=v.inspectorPanel)}this.rolodexRoot?this.importDisabled=!0:this.importDisabled=!1;const f=[];if(this.defaultRulesetBag=this.bagManager.getBag(WQ),this.defaultRulesetBag){const v=this.defaultRulesetBag.get(WQ);v?this.defaultRuleset=v:f.push(this.fetchDefaultRuleset())}if(this.OWASPRulesetBag=this.bagManager.getBag(YQ),this.OWASPRulesetBag){const v=this.OWASPRulesetBag.get(YQ);v?this.OWASPRuleset=v:f.push(this.fetchOWASPRuleset())}if(this.allRulesetBag=this.bagManager.getBag(VQ),this.allRulesetBag){const v=this.allRulesetBag.get(VQ);v?this.allRuleset=v:f.push(this.fetchAllRuleset())}if(this.functionsBag=this.bagManager.getBag(KI),this.functionSchemaBag=this.bagManager.getBag(WI),this.functionsBag){const v=this.functionsBag.get(KI);v?this.functions=v:f.push(this.fetchFunctions())}if(this.customRulesetBag=this.bagManager.getBag(YI),this.customRulesetBag){const v=this.customRulesetBag.get(YI);v&&(this.customRuleset=v)}this.ruleConfigBag=this.bagManager.getBag(k8),this.sessionRulesetMapBag=this.bagManager.getBag(ED),Promise.all(f).then(()=>{var m;this.manageRuleset.defaultRuleset=this.defaultRuleset,this.manageRuleset.owaspRuleset=this.OWASPRuleset,this.manageRuleset.allRuleset=this.allRuleset,this.manageRuleset.functions=this.functions;const v=(m=this.ruleConfigBag)==null?void 0:m.get(k8);v?this.manageRuleset.rulesetConfig=v:this.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.manageRuleset.buildRulesets(),this.customRuleset&&this.customRuleset.rules.size>0&&(this.manageRuleset.customRuleset=this.customRuleset),this.fetchSessionRulesetAsYaml().then(C=>{var M;(M=this.rulesetEditor)==null||M.setValue(C,!0),this.fetchRulesetMap()}).catch(C=>{this.platformUnavailable(C)})},50)}),this.fetchDocs()}extractGraph(b){var f,v,m,C;b.stripped?(this.explorer.nodeLimitExceeded=!0,this.modelTree.nodeLimitExceeded=!0,b.strippedCount&&(this.explorer.nodeLimit=b.strippedCount,this.modelTree.nodeLimit=b.strippedCount)):(this.explorer.nodeLimitExceeded=!1,this.modelTree.nodeLimitExceeded=!1),this.explorer.renderedNodeMap.clear(),this.nodeMap.clear(),this.nodeIdMap.clear(),this.nodeIdHashMap.clear();const p=new Map;(f=b==null?void 0:b.nodesRendered)==null||f.forEach(M=>{this.explorer.renderedNodeMap.set(M.id,M),p.set(M.idHash,M)});for(let M=0;M<((v=b==null?void 0:b.nodesRendered)==null?void 0:v.length);M++)this.renderedNodeMap.set(b.nodesRendered[M].idHash,b.nodesRendered[M]);(m=b==null?void 0:b.nodes)==null||m.forEach(M=>{var q;this.nodeMap.set("model-"+M.idHash,M),this.nodeIdMap.set(M.id,M),this.nodeIdHashMap.set(M.idHash,M),M.filtered&&this.filteredNodes.set(M.idHash,M);const H=this.renderedNodeMap.get(M.idHash);((q=this.activeNode)==null?void 0:q.id)===M.id&&this.renderedNodeMap.get(M.idHash)&&this.renderedNode&&H&&(this.renderedNode.node=H)}),(C=this.graphBag)==null||C.set(ID,b),this.explorer.updateGraphResponse(b),b&&b.nodes&&(this.modelTree.node=b==null?void 0:b.nodes[0]),this.explorer.equalizer.isInitialized()?this.explorer.equalizer.runEQ(!0):this.explorer.equalizer.initializeEqualizer()}customRulesetEnabled(b){var f,v,m;const p={rules:new Map};p.id=crypto.randomUUID(),p.owner=this.session.sessionId,b.detail.rules.forEach(C=>{C.rule.id!=C.ruleId&&(C.rule.id=C.ruleId),p.rules.set(C.ruleId,C.rule)}),(f=this.customRulesetBag)==null||f.set(YI,p),b.detail.ruleConfig?(v=this.ruleConfigBag)==null||v.set(k8,b.detail.ruleConfig):((m=this.ruleConfigBag)==null||m.reset(),_h.resetSessionRuleset(b.detail.rulesetReset).then(()=>{if(this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.docBag){const C=this.docBag.get(VI);this.rolodexActivePath,this.lintSpec(C,this.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(C=>{var M;(M=this.rulesetEditor)==null||M.setValue(C,!0)})}).catch(C=>{this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:C.detail,title:"Cannot reset ruleset"})}))}async fetchSessionRulesetAsYaml(){return new Promise(async(b,p)=>{_h.getSessionRulesetAsYAML().then(f=>{b(f)}).catch(f=>{console.error("cannot fetch session ruleset: ",f.title),p(f)})})}async fetchFunctions(){return new Promise(async b=>{_h.getFunctions().then(p=>{var v;this.functions=p,(v=this.functionsBag)==null||v.set(KI,p);const f=[];p.forEach(m=>{f.push(this.fetchFunctionSchema(m))}),Promise.all(f).then(()=>{b(p)})})})}async fetchFunctionSchema(b){return new Promise(async p=>{_h.getFunctionSchema(b).then(f=>{var m,C;let v=(m=this.functionSchemaBag)==null?void 0:m.get(WI);v||(v=new Map),v.set(b,f),(C=this.functionSchemaBag)==null||C.set(WI,v),p(f)})})}async fetchDefaultRuleset(){return new Promise(async b=>{_h.getDefaultRuleset().then(p=>{var f;this.defaultRuleset=p,(f=this.defaultRulesetBag)==null||f.set(WQ,p),b(p)})})}async fetchOWASPRuleset(){return new Promise(async b=>{_h.getOWASPRuleset().then(p=>{var f;this.OWASPRuleset=p,(f=this.OWASPRulesetBag)==null||f.set(YQ,p),b(p)})})}async fetchAllRuleset(){return new Promise(async b=>{_h.getAllRuleset().then(p=>{var f;this.allRuleset=p,(f=this.allRulesetBag)==null||f.set(VQ,p),b(p)})})}fetchDocs(){this.activitySpinner.show(),k3.startSession().then(b=>{this.session=b,this.session.creditsRemaining?this.creditTicker.credits=this.session.creditsRemaining:this.creditTicker.credits=this.session.creditsRemaining,this.creditTicker.visible=!0,k3.fetchAllHowToFix().then(m=>{m&&m.forEach(C=>{var M;(M=this.howToFixBag)==null||M.set(C.ruleId,C)})}).catch(m=>{this.platformUnavailable(m),console.error("documentation service is down")}),this.ruleDocsBag=this.bagManager.getBag(Ryt),this.functionDocsBag=this.bagManager.getBag(Dyt),this.ruleDocsWorker.addEventListener("message",m=>{var M;const C=m.data;C&&((M=this.docExpirationBag)==null||M.set(qQ,new Date().toISOString()),C.forEach(H=>{var q,ce;H.ruleId&&((q=this.ruleDocsBag)==null||q.set(H.ruleId,H)),H.functionId&&((ce=this.functionDocsBag)==null||ce.set(H.functionId,H))}),this.activitySpinner.hide())});let p=[],f=[];this.ruleDocsBag&&(p=Array.from(this.ruleDocsBag.export().keys())),this.functionDocsBag&&(f=Array.from(this.functionDocsBag.export().keys()));const v=()=>{this.ruleDocsWorker.postMessage({start:!0,endpoint:this.doctorEndpoint,existingRules:p,existingFunctions:f})};if(this.docExpirationBag){const m=this.docExpirationBag.get(qQ);if(m){const C=new Date().getTime(),M=new Date(m).getTime();C-M>1296e6?v():this.activitySpinner.hide()}else v()}else v()}).catch(b=>{this.platformUnavailable(b),console.error("cannot start session")})}fetchRulesetMap(){_h.getSessionRulesetMap().then(b=>{var p;(p=this.sessionRulesetMapBag)==null||p.set(ED,b)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.sendToast({id:crypto.randomUUID(),type:Ol.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}ruleClicked(b){var f,v,m;const p=(f=this.sessionRulesetMapBag)==null?void 0:f.get(ED);if(p){const C=p.rulesMap.find(M=>M.ruleId===b.detail.ruleId);C&&(this.selectedEditorTab="ruleset",this.editorTabGroup.show(Tu.Ruleset),(v=this.rulesetEditor.editor)==null||v.setPosition({lineNumber:C.line,column:C.start}),(m=this.rulesetEditor.editor)==null||m.revealLineInCenter(C.line))}}builtInRulesetSelected(){}rulesetManuallyChanged(){clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{var p;const b=(p=this.rulesetEditor.editor)==null?void 0:p.getValue();_h.validateRuleset(b).then(f=>{var m;this.manageRuleset.clearRuleProblems();let v={rules:new Map};v.id=crypto.randomUUID(),v.owner=this.session.sessionId,v.rules=new Map(Object.entries(f.rules)),v.rules.forEach((C,M)=>{C.id=M}),(m=this.customRulesetBag)==null||m.set(YI,v),this.customRuleset=v,v.rules.size>0&&(this.manageRuleset.customRulesetManual=v),this.selectedEditorTab=Tu.Ruleset,this.controlTabGroup.show(Tu.Ruleset),this.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(f=>{this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:f.detail,title:f.title}),console.error("unable to validate ruleset",f);const v=f.body,m=[];v==null||v.forEach(C=>{m.push({severity:w3.MarkerSeverity.Error,message:C.ruleError,startLineNumber:C.line,startColumn:C.startCol,endLineNumber:C.line,endColumn:C.endCol})}),_h.convertToJSON(b).then(C=>{let M={rules:new Map};M.id=crypto.randomUUID(),M.owner=this.session.sessionId,M.rules=new Map(Object.entries(C.rules)),M.rules.forEach((H,q)=>{H.id!=q&&(H.id=q)}),this.customRuleset=M,M.rules.size>0&&(this.manageRuleset.customRulesetManual=M),this.rulesetEditor.setMarkers([]),this.manageRuleset.clearRuleProblems(),this.rulesetEditor.setMarkers(m),this.manageRuleset.processBadRules(v),this.controlTabGroup.show(Tu.Ruleset)}).catch(C=>{console.error("unable to convert ruleset to JSON",C)})})},this.debounceTimeRuleset)}specChanged(b){if(this.editorMap.get(b.detail.id)&&b.detail.id==="ruleset-editor"){this.rulesetManuallyChanged();return}this.docBag&&this.docBag.set(VI,b.detail.content),clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{this.lintSpec(b.detail.content)},this.debounceTime)}boostrap(){const p=new URL(window.location.href).searchParams.get("url");if(p){this.urlInput.value=p,this.activeURL=p,this.lintSpec("",p);return}(this.editor.getValue()===""||!this.problems)&&k3.bootstrapEditor().then(f=>{this.editor.setValue(f,!0),this.rolodexActivePath="",this.specChanged(new CustomEvent(eQ,{detail:{content:f,id:"spec"}}))})}exportJSON(){let b;if(this.ruleConfigBag){const p=this.ruleConfigBag.get(k8);p&&p.returnedRuleset&&(b=p.returnedRuleset)}if(b){let p="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(b,null,2));this.downloadRulesetLink.download="ruleset.json",this.downloadRulesetLink.href=p,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()}}exportYAML(){_h.getSessionRulesetAsYAML().then(b=>{let p="data:text/yaml;charset=utf-8,"+encodeURIComponent(b);this.downloadRulesetLink.download="ruleset.yaml",this.downloadRulesetLink.href=p,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()})}confirmExport(){switch(this.exportSelection.value){case"json":this.exportJSON();break;case"yaml":this.exportYAML();break}}closeWelcome(){this.welcomeBox.hide(),localStorage.setItem("pb33f-doctor-welcome","closed")}selectEditorTab(b){switch(this.selectedEditorTab=b.detail.name,b.detail.name){case Tu.Ruleset:this.rulesetPulse&&(this.rulesetPulse=!1),this.controlTabGroup.show(Tu.Ruleset);break}}selectControlTab(b){switch(b.detail.name){case Tu.Problems:case Tu.Overview:this.selectedEditorTab!="spec"&&(this.selectedEditorTab="spec",this.editorTabGroup.show("spec"));break;case Tu.Ruleset:this.selectedEditorTab!=Tu.Ruleset&&(this.editorTabGroup.show(Tu.Ruleset),this.selectedEditorTab=Tu.Ruleset);break}}toggleSidebar(){var p;const b=(p=this.shadowRoot)==null?void 0:p.querySelector("sl-split-panel.split-panel");this.sidebarClosed?b&&(this.collapseButton.name="chevron-bar-right",b.style.setProperty("--min","600px"),b.style.setProperty("--max","calc(100vw - 600px)"),b.position=60,b.disabled=!1,this.problemsDataDiv.style.display="block",this.splitDivider.style.display="block",this.activitySpinner.classList.remove("spinner-draw-closed")):b&&(this.collapseButton.name="chevron-bar-left",this.problemsDataDiv.style.display="none",b.style.setProperty("--min","40px"),b.style.setProperty("--max","calc(100vw - 40px)"),b.position=99,b.disabled=!0,this.splitDivider.style.display="none",this.activitySpinner.classList.add("spinner-draw-closed")),this.sidebarClosed=!this.sidebarClosed}toggleExplorer(){this.explorerVisible=!this.explorerVisible,this.explorerVisible&&this.activeNode&&this.explorer.moveToNode(this.activeNode),this.explorerBooted=!0}closeExplorer(){this.explorerVisible=!1,setTimeout(()=>{var b,p;this.pendingLine>0&&((b=this.editor.editor)==null||b.setPosition({lineNumber:this.pendingLine,column:1}),(p=this.editor.editor)==null||p.revealLineInCenter(this.pendingLine),this.pendingLine=0)},20)}render(){var M;let b=I.html``;this.unavailable&&(b=I.html`
9816
+ `}};P3.styles=[Ayt],GI([z.property()],P3.prototype,"credits",2),GI([z.property()],P3.prototype,"visible",2),GI([z.query(".arrow")],P3.prototype,"downArrow",2),GI([z.query("#arrowAnimation")],P3.prototype,"arrowAnimation",2),P3=GI([z.customElement("pb33f-credit-ticker")],P3);var jyt=Object.defineProperty,$yt=Object.getOwnPropertyDescriptor,uo=(b,p,f,v)=>{for(var m=v>1?void 0:v?$yt(p,f):p,C=b.length-1,M;C>=0;C--)(M=b[C])&&(m=(v?M(p,f,m):M(m))||m);return v&&m&&jyt(p,f,m),m};const ID="pb33f-doctor-graph",T0="pb33f-doctor-panel-state",GQ="pb33f-doctor-rolodex-response",qI="pb33f-doctor-rolodex-files",km="pb33f-doctor-rolodex-state",ND="pb33f-doctor-reference-map",Tyt="pb33f-doctor-editor",Oyt="pb33f-doctor-howtofix",Dyt="pb33f-doctor-funcdocs",qQ="pb33f-doctor-doc-expiration",Ryt="pb33f-doctor-ruledocs",KQ="pb33f-doctor-diagnostic",WQ="pb33f-doctor-default-ruleset",YQ="pb33f-doctor-owasp-ruleset",VQ="pb33f-doctor-all-ruleset",KI="pb33f-doctor-functions",WI="pb33f-doctor-function-schema",YI="pb33f-doctor-custom-ruleset",k8="pb33f-doctor-rule-configuration",ED="pb33f-doctor-session-rulesetmap",VI="pb33f-doctor-document",AD="pb33f-doctor-problems",Byt="doctor-endpoint";let Us=class extends I.LitElement{constructor(b="https://doctor.pb33f.io"){super(),this.debounceTime=400,this.debounceTimeRuleset=900,this.bounceId=0,this.useTLS=!1,this.rolodexDividerPosition=40,this._firstRun=!0,this.bus=A3t(),this.doctorServiceChannel=this.bus.createChannel(LD),this.specStreamChannel=this.bus.createChannel(_Q),this.creditStreamChannel=this.bus.createChannel(zQ),this.bus.mapChannelToBrokerDestination(HQ+LD,LD),this.bus.mapChannelToBrokerDestination(HQ+_Q,_Q),this.bus.mapChannelToBrokerDestination(HQ+zQ,zQ),this.doctorChannelSubscription=this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.specChannelSubscription=this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditChannelSubscription=this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bagManager=u3e(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new kd,this.uploadArchive=new Cd,this.nukeWorkspace=new x8,this.rulesetEditor=new kd("ruleset-editor"),this.problemList=new vI,this.detailsDrawer=new c8,this.problemsOverview=new L3,this.errorBanner=new Hx,this.statusBar=new Ux,this.ruleDocsWorker=new Wwt,this.unavailable=!1,this.feedback=new I3,this.activitySpinner=new $O,this.manageRuleset=new P1,this.toastManager=new RO,this.creditTicker=new P3,this.editorMap=new Map,this.editorMap.set("spec",this.editor),this.editorMap.set("ruleset-editor",this.rulesetEditor),this.selectedEditorTab="spec",this.sidebarClosed=!1,this.explorerVisible=!1,this.explorerBooted=!1,this.rolodexNeedsReset=!1,this.rolodexProblemMap=new Map,this.rolodexRootHash="",this.rolodexRootPath="",this.importDisabled=!1,this.pendingLine=0,this.nodeMap=new Map,this.nodeIdMap=new Map,this.nodeIdHashMap=new Map,this.renderedNodeMap=new Map,this.filteredNodes=new Map,this.modelTree=new P0(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexTree=new P0(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexActiveHash="",this.explorer=new xm,this.renderedNode=new UI,this.references=[],this.minimapVisible=!0,this.nodeLimit=150;const p=sessionStorage.getItem(Byt);p?this.doctorEndpoint=p:this.doctorEndpoint=b,this.addEventListener(eQ,this.specChanged),this.addEventListener(wve,this.specClicked),this.addEventListener(xO,this.problemClicked),this.addEventListener(Bh,this.ruleDocsClicked),this.addEventListener(Lve,this.ruleGroupClicked),this.addEventListener(tQ,this.customRulesetEnabled),this.addEventListener(nQ,this.rulesetSaved),this.addEventListener(_x,this.addToastEvent),this.addEventListener(Sve,this.exportRuleset),this.addEventListener(Ave,this.ruleClicked),this.addEventListener(kO,this.builtInRulesetSelected),this.addEventListener(h2,this.modelTreeNodeClicked),this.addEventListener(fI,this.rolodexTreeNodeClicked),this.addEventListener(jve,this.rolodexRootFileSelected),this.addEventListener(rQ,this.explorerReferenceClicked),this.addEventListener(iQ,this.explorerNodeClicked.bind(this)),this.addEventListener(zve,this.fetchUrl.bind(this)),this.addEventListener(lQ,this.documentReferenceClicked.bind(this)),this.explorer.equalizer.addEventListener(oQ,this.filterTreeModel.bind(this)),this.explorer.equalizer.addEventListener(cQ,this.filterTreeModel.bind(this)),this.nukeWorkspace.addEventListener(Hve,this.nukeWorkspaceHandler.bind(this)),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 f=sessionStorage.getItem("pb33f-doctor-tls");f&&f=="true"&&(this.useTLS=!0),window.addEventListener("popstate",v=>{const m=v.state;m&&(m.activeNode&&this.modelTreeNodeClicked(new CustomEvent(iQ,{detail:{nodeHashId:m.activeNode,noState:!0}})),m.ref&&this.documentReferenceClicked(new CustomEvent(lQ,{detail:{jsonPath:m.ref,noState:!0}})))})}nukeWorkspaceHandler(){this.bagManager.resetBags(),Fh.resetWorkspace().then(()=>{window.location.reload()})}minimapToggled(){this.minimapVisible=!this.minimapVisible,this.editor.toggleMinimap(),this.rulesetEditor.toggleMinimap()}firstUpdated(){this.editor=this.querySelector("pb33f-editor#spec-editor"),this.rulesetEditor=this.querySelector("pb33f-editor#ruleset-editor")}whoAmI(){this.bus.publish({destination:"/p/q/"+LD,body:JSON.stringify({request:G3e.WhoAmI})})}connectToBroker(){let b="ws://";this.useTLS&&(b="wss://");const p={brokerURL:b+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.whoAmI()}};this.bus.connectToBroker(p)}addClickTrack(b){history.pushState({activeNode:b.idHash},"",`?view=explore&node=${b.idHash}`)}addRefTrack(b){history.pushState({ref:b},"",`?view=spec&ref=${b}`)}doctorServiceHandler(){return b=>{var p;((p=b.payload)==null?void 0:p.payload)!=null&&kyt(b.payload.payload)&&(this.brokerConnectionId=b.payload.payload.broker,console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you.","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor())}}startTheDoctor(){this.boostrap(),this.loadingOverlay.hide()}specStreamHandler(){return b=>{var p,f;if(((p=b.payload)==null?void 0:p.payload)!=null){const v=atob(b.payload.payload);this.docBag&&this.docBag.set(VI,v),(f=this.editor)==null||f.setValue(v,!0),this.requestUpdate()}}}creditStreamHandler(){return b=>{var p;((p=b.payload)==null?void 0:p.payload)!=null&&(this.creditTicker.credits=parseInt(b.payload.payload))}}filterTreeModel(b){this.filteredNodes=new Map,b.detail.graph.nodes.forEach(p=>{this.filteredNodes.set(p.idHash,p)}),this.modelTree.filteredNodes=this.filteredNodes,this.modelTree.renderedNodes=this.renderedNodeMap}documentReferenceClicked(b){var q,ce;let p="",f,v=1,m=b.detail.jsonPath,C="",M="",H="";if(b.detail.jsonPath.includes("||")&&(p=b.detail.jsonPath.split("||")[1],m=b.detail.jsonPath.split("||")[0],f=parseInt(p.split(":")[0]),v=parseInt(p.split(":")[1]),C=b.detail.jsonPath.split("||")[2],C!=""&&(M=C.split("#")[0]),H=b.detail.jsonPath.split("||")[3]),(q=this.editor.editor)==null||q.setPosition({lineNumber:f,column:v}),(ce=this.editor.editor)==null||ce.revealLineInCenter(f),this.nodeIdMap.has(m)){const Y=this.nodeIdMap.get(m);if(Y){if(this.nodeIdHashMap.has(Y.idHash)){const me=this.renderedNodeMap.get(Y.idHash);me&&(this.renderedNode.node=me,this.modelTree.explorerClicked(Y.idHash),b.detail.noState||this.addRefTrack(b.detail.jsonPath))}}else this.toastManager.addToastManually({id:crypto.randomUUID(),type:Ol.INFO,title:"Reference not found",body:`Something went wrong, '${m}' not found`})}else this.rolodexActivePath!=null&&this.rolodexActivePath!=M&&Fh.queryRolodex(H,M).then(Y=>{var me,ve;if(this.editor.showBreadcrumb=!0,this.rolodexActivePath=M,this.editor.clearDecorations(),this.editor.setValue(Y.rolodexRoot.instance,!0),(me=this.editor.editor)==null||me.setPosition({lineNumber:f,column:1}),(ve=this.editor.editor)==null||ve.revealLineInCenter(f),this.rolodexTree.explorerClicked(H),this.editor.setCurrentPath(M),this.lintSpec(Y.rolodexRoot.instance),this.rolodexProblemMap.has(this.rolodexActivePath)){const De=this.rolodexProblemMap.get(this.rolodexActivePath);De&&this.editor.setMarkers(De)}}).catch(Y=>{console.error("rolodex query failed",Y)})}explorerReferenceClicked(b){let p="";if(this.explorer.nodeComponents.forEach(f=>{var v,m;if(f.body.node.nodePath===b.detail.nodePath){const C=this.renderedNodeMap.get(f.body.node.idHash);C&&((v=this.editor.editor)==null||v.setPosition({lineNumber:C.keyLine,column:0}),(m=this.editor.editor)==null||m.revealLineInCenter(C.keyLine),this.renderedNode.node=C,p=f.body.node.idHash,this.explorer.moveToNode(f.body.node),this.activeNode=f.body.node,this.explorer.activeNode=f.body.node,this.explorer.equalizer.activeNode=f.body.node),f.body.active=!0}else f.body.active=!1}),p&&(this.modelTree.explorerClicked(p),this.explorer.requestUpdate(),this.viewerPanel.click()),b.detail.nodePath){let f=b.detail.nodePath;!f.startsWith("/")&&!f.includes("#")&&(f=this.rolodexRootPath.substring(0,this.rolodexRootPath.lastIndexOf("/")+1)+f),f.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{path:f}}))}}rolodexTreeNodeClicked(b){var v;const p=(v=this.rolodexFilesBag)==null?void 0:v.get(qI),f=m=>{var me,ve,De,Nt,Yn,zn,Xi;this.rolodexActivePath=b.detail.path,this.rolodexActiveHash=b.detail.nodeHashId,this.editor.setValue(m.instance,!0),this.editor.setCurrentPath(this.rolodexActivePath);const C=this.rolodexProblemMap.get(this.rolodexActivePath);C&&this.editor.setMarkers(C);let M="yaml";const H=(ve=(me=b.detail)==null?void 0:me.path)==null?void 0:ve.split(".").pop();if(H)switch(H){case de.JSON:M=de.JSON;break;case de.GO:M=de.GO;break;case de.PY:M="python";break;case de.JS:M="javascript";break;case de.TS:M="typescript";break;case de.PHP:M=de.PHP;break;case de.XML:M=de.XML;break;case de.JAVA:M=de.JAVA;break;case de.RB:M="ruby";break;case de.RS:M="rust";break;case de.C:M=de.C;break;case de.CPP:M=de.CPP;break;case de.CS:M="csharp";break;case de.MD:M="markdown";break}const q=(De=this.rolodexStateBag)==null?void 0:De.get(km);if(q)q.activePath=b.detail.path,q.activeHash=b.detail.nodeHashId,q.activeLanguage=M,q.activeNode=m,q.rootPath=this.rolodexRootPath,(Nt=this.rolodexStateBag)==null||Nt.set(km,q);else{const Ur={activePath:b.detail.path,activeHash:b.detail.nodeHashId,activeLanguage:M,activeNode:m,rootHash:this.rolodexRootHash,rootPath:this.rolodexRootPath};(Yn=this.rolodexStateBag)==null||Yn.set(km,Ur)}this.editor.switchLanguage(M);let ce=1,Y=0;return b.detail.line&&(ce=b.detail.line),b.detail.column&&(Y=b.detail.column),(zn=this.editor.editor)==null||zn.setPosition({lineNumber:ce,column:Y}),(Xi=this.editor.editor)==null||Xi.revealLineInCenter(ce,Y),this.lintSpec(m.instance),b.detail.path&&this.rolodexTree.openNodeByPath(b.detail.path),M};Fh.queryRolodex(b.detail.nodeHashId,b.detail.path).then(m=>{var C,M,H;if(this.editor.showBreadcrumb=!0,(C=this.referenceMapBag)==null||C.reset(),f(m.rolodexRoot),b.detail.path&&(p&&!p.files[b.detail.path]&&(p.files[b.detail.path]=m.rolodexRoot,(M=this.rolodexFilesBag)==null||M.set(qI,p)),!p)){const q={files:{[b.detail.path]:m.rolodexRoot}};(H=this.rolodexFilesBag)==null||H.set(qI,q)}})}rolodexRootFileSelected(b){var f,v,m;this.rolodexActivePath=b.detail.path,this.rolodexActiveHash=b.detail.nodeHashId,this.rolodexRootPath=b.detail.path,this.importDisabled=!0;const p=(f=this.rolodexStateBag)==null?void 0:f.get(km);if(p)p.activePath=b.detail.path,p.activeHash=b.detail.nodeHashId,p.rootPath=b.detail.path,p.rootHash=b.detail.nodeHashId,(v=this.rolodexStateBag)==null||v.set(km,p);else{const C={activePath:b.detail.path,activeHash:b.detail.nodeHashId,rootPath:b.detail.path,rootHash:b.detail.nodeHashId};(m=this.rolodexStateBag)==null||m.set(km,C)}b.detail.nodeHashId&&(this.rolodexRootHash=b.detail.nodeHashId),b.detail.content&&(this.rolodexNeedsReset=!0,this.editor.setValue(b.detail.content,!0),this.lintSpec(b.detail.content))}modelTreeNodeClicked(b){var f,v,m;const p=this.nodeIdHashMap.get(b.detail.nodeHashId);if(p){if(p.origin&&p.origin!=this.rolodexActivePath&&p.origin!="/root.yaml"&&p.origin!="root.yaml"){let M="";const H=(f=this.rolodexFilesBag)==null?void 0:f.get(qI);H&&H.files[p.origin]&&(M=H.files[p.origin].idHash),this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{nodeHashId:M,path:p.origin}}));return}(v=this.editor.editor)==null||v.setPosition({lineNumber:p.keyLine,column:0}),(m=this.editor.editor)==null||m.revealLineInCenter(p.keyLine),this.explorerVisible&&this.explorer.moveToNode(p,b.detail.first),this.activeNode=p,this.explorer.activeNode=p,this.explorer.equalizer.activeNode=p;const C=this.renderedNodeMap.get(p.idHash);C&&(this.renderedNode.node=C),b.detail.noState||(this.addClickTrack(p),b.detail.noState=!0),this.explorerNodeClicked(b),this._firstRun?this._firstRun=!1:this.viewerPanel.click()}}explorerNodeClicked(b){let p=!1,f;if(this.explorer.nodeComponents.forEach(v=>{if(v.id===b.detail.nodeHashId){const m=this.renderedNodeMap.get(v.id);m&&!this._firstRun&&(this.renderedNode.node=m),this.selectedNodeHashId=v.body.node.idHash,v.body.active=!0,this.activeNode=v.body.node,this.explorer.activeNode=v.body.node,p=!0,f=m,b.detail.noState||this.addClickTrack(v.body.node)}else v.body.active=!1}),!p){const v=this.nodeIdHashMap.get(b.detail.nodeHashId);v&&(this.selectedNodeHashId=b.detail.nodeHashId,this.activeNode=v,this.explorer.activeNode=v,this.explorer.equalizer.activeNode=v)}f&&(this.pendingLine=f.keyLine),this.modelTree.explorerClicked(b.detail.nodeHashId),this._firstRun||this.viewerPanel.click(),this.explorer.requestUpdate()}exportRuleset(){this.exportRulesetDialog.show()}addToastEvent(b){this.sendToast(b.detail.toast)}sendToast(b){this.toastManager.addToastManually(b)}ruleGroupClicked(b){this.problemsPanel.focus();const p=new CustomEvent(Cve,{bubbles:!0,composed:!0,detail:{rule:b.detail.rule}});this.problemsPanel.focus(),this.problemList.dispatchEvent(p),history.pushState({rule:b.detail.rule},"",`/${Tu.Problems}?rule=${b.detail.rule}`),this.controlTabGroup.show(Tu.Problems)}ruleDocsClicked(b){var f,v,m;const p=b.detail.rule;if(p)switch(b.detail.type){case iu.RULE_DOCS:const C=(f=this.ruleDocsBag)==null?void 0:f.get(p);C?(b.detail.body=C.body,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"Rule documentation unavailable",body:`Documentation for '${p}' not available`});break;case iu.HOW_TO_FIX:const M=(v=this.howToFixBag)==null?void 0:v.get(p);M?(b.detail.body=M.howToFix,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"How to fix unavailable",body:`Information on how to fix '${p}' not available`});break;case iu.FUNCTION_DOCS:const H=(m=this.functionDocsBag)==null?void 0:m.get(p);H?(b.detail.body=H.body,this.detailsDrawer.open(b.detail)):this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,title:"Function documentation unavailable",body:`Documentation for '${p}' not available`});break}else switch(b.detail.type){case iu.RENDERED_EXAMPLE:case iu.MARKDOWN:this.detailsDrawer.open(b.detail)}}rulesetSaved(b){var p,f,v;if(this.docBag){const m=this.docBag.get(VI),C=(p=this.ruleConfigBag)==null?void 0:p.get(k8);if(b.detail.rules){if((f=this.customRulesetBag)==null||f.set(YI,b.detail.rules),C){const M=b.detail.config;M&&this.ruleConfigBag&&(M.returnedRuleset=b.detail.returnedRules,(v=this.ruleConfigBag)==null||v.set(k8,M))}_h.getSessionRulesetAsYAML().then(M=>{this.selectedEditorTab=="spec"&&(this.rulesetPulse=!0),this.rulesetEditor.setValue(M,!0),this.fetchRulesetMap()}),this.lintSpec(m,"")}}}buildRolodexResultMap(b){return this.rolodexProblemMap.clear(),b.forEach(p=>{if((p.sourceLocation==="/root.yaml"||p.sourceLocation==="root.yaml")&&(p.sourceLocation="root"),this.rolodexProblemMap.has(p.sourceLocation)){const f=this.rolodexProblemMap.get(p.sourceLocation);f&&(f.push(p),p.sourceLocation?this.rolodexProblemMap.set(p.sourceLocation,f):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,f):this.rolodexProblemMap.set("root",f))}else p.sourceLocation?this.rolodexProblemMap.set(p.sourceLocation,[p]):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,[p]):this.rolodexProblemMap.set("root",[p])}),this.rolodexProblemMap}lintSpec(b,p){var M;this.activitySpinner.show(),this.editor.breadcumb.isInvalid=!1,p?p==="root"?p="":(this.urlProblem.style.display="none",this.urlOverlay.style.display="block",this.urlSpinner.style.display="block",(M=this.referenceMapBag)==null||M.reset()):(this.urlProblem.style.display="none",this.urlOverlay.style.display="none",this.urlSpinner.style.display="none");let f=!1,v=this.rolodexActivePath;if((this.rolodexActivePath===this.rolodexRootPath||this.rolodexActivePath==="root")&&(f=!0,v="",this.editor.showBreadcrumb=!1),p&&p!="")try{const H=new URL(p);H&&(v=H.pathname,this.rolodexActivePath=v,this.rolodexRootPath=v,f=!0)}catch{}const m=(H=!1)=>{var q;(q=this.referenceMapBag)==null||q.export().size,Fh.fetchReferenceMap().then(ce=>{H?(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!0,this.editor.dead(),this.problemList.isInvalid=!0,this.editor.requestUpdate()):(this.references=ce,this.editor.links=ce,this.editor.applyLinkDecorations()),this.updateRefmapBag(v,ce)}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.toastManager.addToastManually({id:crypto.randomUUID(),type:Ol.INFO,title:"File not analyzed",body:"This file is not a JSON or YAML file, it has not been analyzed."})})};let C=!0;k3.lintFile(b,this.brokerConnectionId,p,v).then(H=>{var ce,Y;this.buildRolodexResultMap(H),p&&(this.urlOverlay.style.display="none",this.urlSpinner.style.display="none",this.urlProblem.style.display="none");let q=this.rolodexProblemMap.get("root");if(this.rolodexRoot||(q=[]),H&&!Array.isArray(H)){const me=[H];if(this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const ve=this.rolodexProblemMap.get(this.rolodexActivePath);ve?(q&&ve.push(...q),this.editor.setMarkers(ve)):(q&&me.push(...q),this.editor.setMarkers(me))}else q&&me.push(...q),this.editor.setMarkers(me);(ce=this.problemBag)==null||ce.set(AD,me),this.problemList.problems=me,this.problems=me,this.problemsOverview.problems=this.problemList.problemItems}if(H&&Array.isArray(H)){if(H.length==0&&(this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!1,this.editor.showBreadcrumb=!1,C=!0,this.problemList.isInvalid=!1),H.length==1&&H[0].message.startsWith("unable to parse")&&(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.setMarkers(H),this.editor.breadcumb.isInvalid=!0,this.editor.showBreadcrumb=!0,this.editor.dead(),this.problemList.isInvalid=!0,C=!1),C&&this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const me=this.rolodexProblemMap.get(this.rolodexActivePath);me?(q&&me.push(...q),this.editor.setMarkers(me)):(q&&H.push(...q),this.editor.setMarkers(H))}else if(f)this.editor.setMarkers(H);else{m();return}(Y=this.problemBag)==null||Y.set(AD,H),this.problemList.problems=H,this.problems=H,this.problemsOverview.problems=this.problemList.problemItems,this.problemsOverview.statistics&&H.length==1&&(this.problemsOverview.statistics.statistics.totalErrors=1,this.problemsOverview.statistics.statistics.overallScore=0,this.problemsOverview.statistics.evaluation="Useless",this.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+H[0].message)}if(C)this.editor.revive();else return;(this.rolodexRootPath==this.rolodexActivePath||this.rolodexActivePath=="root")&&Fh.createGraph().then(me=>{this.extractGraph(me)}),m(),this.rolodexNeedsReset&&Fh.queryRolodex().then(me=>{var De,Nt,Yn;if(this.importDisabled=!0,this.editor.showBreadcrumb=!0,this.rolodexNeedsReset=!1,me.rolodexRoot.treeExpanded=!0,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=me.rolodexRoot,this.rolodexRoot=me.rolodexRoot,this.rolodexActiveHash&&(this.rolodexTree.pendingNavigationHash=this.rolodexActiveHash),this.rolodexActivePath&&(this.rolodexTree.pendingNavigationPath=this.rolodexActivePath),(De=this.rolodexResponseBag)==null||De.set(GQ,me),!((Nt=this.rolodexStateBag)==null?void 0:Nt.get(km))){const zn={activePath:this.rolodexActivePath,rootPath:this.rolodexRootPath};(Yn=this.rolodexStateBag)==null||Yn.set(km,zn)}this.requestUpdate()}),k3.fetchStatistics().then(me=>{var ve;this.problemsOverview.statistics&&this.problemsOverview.statistics.statistics.overallScore,(ve=this.diagnosticBag)==null||ve.set(KQ,me),this.activitySpinner.hide(),(me==null?void 0:me.remainingCredit)<=10&&(this.statusBar.callsRemaining=me.remainingCredit,this.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+me.remainingCredit+" credits remaining.")),this.problemsOverview.statistics=me}).catch(me=>{console.error("statistics service is down",me),this.platformUnavailable(me)}),this.explorerBooted||(this.explorer.equalizer.initializeEqualizer(),this.explorerBooted=!0)}).catch(H=>{p?this.showUrlError(H):(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),H&&(console.error(H.detail),H.instance==="https://pb33f.io/errors/no-credit-remaining"&&(this.statusBar.callsRemaining=0,this.statusBar.visible=!0,this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:"Run out of credit, please authenticate for more or wait 24 hours.",title:"Credit exhausted!"}))))})}updateInspectorDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.inspectorPanel=this.splitPanelInspector.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{inspectorPanel:this.splitPanelInspector.position})}updateExplorerDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.explorerPanel=this.splitPanelExplorer.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{explorerPanel:this.splitPanelExplorer.position})}updateRolodexDivider(){var p,f,v;const b=(p=this.panelStateBag)==null?void 0:p.get(T0);b?(b.rolodexPanel=this.splitPanelRolodex.position,(f=this.panelStateBag)==null||f.set(T0,b)):(v=this.panelStateBag)==null||v.set(T0,{rolodexPanel:this.splitPanelRolodex.position}),this.rolodexDividerPosition=this.splitPanelRolodex.position}updateRefmapBag(b,p){var m,C;let f=(m=this.referenceMapBag)==null?void 0:m.get(ND),v=b;f?f.references[v]=p:f={references:{[v]:p}},(C=this.referenceMapBag)==null||C.set(ND,f)}platformUnavailable(b){this.unavailable||(this.loadingOverlay.hide(),this.activitySpinner.hide(),this.errorBanner.errorTitle="The doctor is out.",b?this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because "+b.detail:this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because there is no response from the platform.",this.errorBanner.visible=!0,this.unavailable=!0,this.problemsOverview.unavailable=!0,this.controlTabGroup.show(Tu.Overview))}specClicked(b){var p,f,v;if(this.detailsDrawer.close(),this.selectedEditorTab=="spec"){let m=!1;for(let M=0;M<((p=this.problems)==null?void 0:p.length);M++)if(this.problems[M].startLineNumber===b.detail.line){this.problemList.lineClicked(b.detail.line,!0),this.controlTabGroup.show(Tu.Problems),this.sidebarClosed&&this.toggleSidebar(),m=!0;break}const C=(f=this.graphBag)==null?void 0:f.get(ID);if(C&&C.graphMap&&b.detail.line){const M=C.graphMap[b.detail.line];if(M){this.modelTree.explorerClicked(M);const H=this.renderedNodeMap.get(M);H&&(this.renderedNode.node=H),m||this.viewerPanel.click();const q=this.nodeIdHashMap.get(M);q&&(this.explorer.activeNode=q,this.explorer.equalizer.activeNode=q)}}}if(this.selectedEditorTab==Tu.Ruleset){const m=(v=this.sessionRulesetMapBag)==null?void 0:v.get(ED);if(m!=null&&m.rulesMap){for(let C=0;C<m.rulesMap.length;C++)if(m.rulesMap[C].line===b.detail.line){this.controlTabGroup.show(Tu.Ruleset),this.sidebarClosed&&this.toggleSidebar();break}}}}problemClicked(b){var v,m;this.selectedEditorTab!="spec"&&(this.editorTabGroup.show("spec"),this.selectedEditorTab="spec");let p=b.detail.problem.problemObject.sourceLocation;(p==""||p==null||p=="root")&&(p=this.rolodexRootPath);const f=b3e(this.rolodexRoot,p);if(f){this.rolodexTreeNodeClicked(new CustomEvent(fI,{detail:{nodeHashId:f.idHash,path:p,line:b.detail.problem.problemObject.startLineNumber,column:b.detail.problem.problemObject.startColumn}})),this.detailsDrawer.close(),this.rolodexTree.openNodeByPath(p);return}this.controlTabGroup.show(Tu.Problems),(v=this.editor.editor)==null||v.revealLineInCenter(b.detail.problem.line),(m=this.editor.editor)==null||m.setPosition({lineNumber:b.detail.problem.line,column:b.detail.problem.column}),this.detailsDrawer.close(),b.detail.launchedFromProblems||this.problemList.lineClicked(b.detail.problem.problemObject.startLineNumber)}loadState(){if(k3.doctorEndpoint=this.doctorEndpoint,jO.doctorEndpoint=this.doctorEndpoint,_h.doctorEndpoint=this.doctorEndpoint,Fh.doctorEndpoint=this.doctorEndpoint,this.connectToBroker(),this.graphBag=this.bagManager.getBag(ID),this.docBag=this.bagManager.getBag(Tyt),this.rolodexResponseBag=this.bagManager.getBag(GQ),this.rolodexFilesBag=this.bagManager.getBag(qI),this.rolodexStateBag=this.bagManager.getBag(km),this.referenceMapBag=this.bagManager.getBag(ND),this.docExpirationBag=this.bagManager.getBag(qQ),this.panelStateBag=this.bagManager.getBag(T0),this.rolodexResponseBag){const v=this.rolodexResponseBag.get(GQ);v&&(this.rolodexRoot=v.rolodexRoot,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=v.rolodexRoot,v.rolodexRoot.treeExpanded=!0,this.requestUpdate())}let b=!1;const p=v=>{var C;let m=(C=this.referenceMapBag)==null?void 0:C.get(ND);m?setTimeout(()=>{let M=m==null?void 0:m.references[v];M||(M=m==null?void 0:m.references[""]),M&&(this.references=M,this.editor.links=M,this.editor.applyLinkDecorations())},5):Fh.fetchReferenceMap().then(M=>{this.references=M,this.editor.links=M,this.editor.applyLinkDecorations()}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers()})};if(this.rolodexStateBag){const v=this.rolodexStateBag.get(km);v?(this.rolodexActivePath=v.activePath,this.rolodexActiveHash=v.activeHash,v.rootHash&&(this.rolodexTree.pendingNavigationHash=v.rootHash),v.rootPath&&(this.rolodexRootPath=v.rootPath,v.activePath&&p(v.activePath),Fh.selectRootPath(v.rootPath).then(()=>{}).catch(m=>{console.error("could not select the root path on boot bro",m)})),v.rootHash&&(this.rolodexRootHash=v.rootHash),v.activePath&&(this.rolodexTree.pendingNavigationPath=v.activePath,this.rolodexTree.requestUpdate()),v.activeNode&&(v.activeLanguage&&this.editor.switchLanguage(v.activeLanguage),this.editor.setValue(v.activeNode.instance,!0),b=!0)):(this.rolodexActivePath="root",p(this.rolodexActivePath))}if(this.docBag&&!b){const v=this.docBag.get(VI);v&&this.editor.setValue(v,!0)}if(this.problemBag=this.bagManager.getBag(AD),this.problemBag){const v=this.problemBag.get(AD);if(v){this.problems=v;for(let m=0;m<v.length;m++)v[m]=f2.reconstruct(v[m]);if(this.buildRolodexResultMap(v),this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m)}this.problemList.problems=v,this.problemsOverview.problems=this.problemList.problemItems}}if(this.howToFixBag=this.bagManager.getBag(Oyt),this.diagnosticBag=this.bagManager.getBag(KQ),this.diagnosticBag){const v=this.diagnosticBag.get(KQ);v&&(this.problemsOverview.statistics=v)}if(this.graphBag){const v=this.graphBag.get(ID);v&&this.extractGraph(v)}if(this.panelStateBag){const v=this.panelStateBag.get(T0);v&&v.explorerPanel&&(this.splitPanelExplorer.position=v.explorerPanel),v&&v.rolodexPanel&&(this.splitPanelRolodex&&(this.splitPanelRolodex.position=v.rolodexPanel),this.rolodexDividerPosition=v.rolodexPanel),v&&v.inspectorPanel&&(this.splitPanelInspector.position=v.inspectorPanel)}this.rolodexRoot?this.importDisabled=!0:this.importDisabled=!1;const f=[];if(this.defaultRulesetBag=this.bagManager.getBag(WQ),this.defaultRulesetBag){const v=this.defaultRulesetBag.get(WQ);v?this.defaultRuleset=v:f.push(this.fetchDefaultRuleset())}if(this.OWASPRulesetBag=this.bagManager.getBag(YQ),this.OWASPRulesetBag){const v=this.OWASPRulesetBag.get(YQ);v?this.OWASPRuleset=v:f.push(this.fetchOWASPRuleset())}if(this.allRulesetBag=this.bagManager.getBag(VQ),this.allRulesetBag){const v=this.allRulesetBag.get(VQ);v?this.allRuleset=v:f.push(this.fetchAllRuleset())}if(this.functionsBag=this.bagManager.getBag(KI),this.functionSchemaBag=this.bagManager.getBag(WI),this.functionsBag){const v=this.functionsBag.get(KI);v?this.functions=v:f.push(this.fetchFunctions())}if(this.customRulesetBag=this.bagManager.getBag(YI),this.customRulesetBag){const v=this.customRulesetBag.get(YI);v&&(this.customRuleset=v)}this.ruleConfigBag=this.bagManager.getBag(k8),this.sessionRulesetMapBag=this.bagManager.getBag(ED),Promise.all(f).then(()=>{var m;this.manageRuleset.defaultRuleset=this.defaultRuleset,this.manageRuleset.owaspRuleset=this.OWASPRuleset,this.manageRuleset.allRuleset=this.allRuleset,this.manageRuleset.functions=this.functions;const v=(m=this.ruleConfigBag)==null?void 0:m.get(k8);v?this.manageRuleset.rulesetConfig=v:this.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.manageRuleset.buildRulesets(),this.customRuleset&&this.customRuleset.rules.size>0&&(this.manageRuleset.customRuleset=this.customRuleset),this.fetchSessionRulesetAsYaml().then(C=>{var M;(M=this.rulesetEditor)==null||M.setValue(C,!0),this.fetchRulesetMap()}).catch(C=>{this.platformUnavailable(C)})},50)}),this.fetchDocs()}extractGraph(b){var f,v,m,C;b.stripped?(this.explorer.nodeLimitExceeded=!0,this.modelTree.nodeLimitExceeded=!0,b.strippedCount&&(this.explorer.nodeLimit=b.strippedCount,this.modelTree.nodeLimit=b.strippedCount)):(this.explorer.nodeLimitExceeded=!1,this.modelTree.nodeLimitExceeded=!1),this.explorer.renderedNodeMap.clear(),this.nodeMap.clear(),this.nodeIdMap.clear(),this.nodeIdHashMap.clear();const p=new Map;(f=b==null?void 0:b.nodesRendered)==null||f.forEach(M=>{this.explorer.renderedNodeMap.set(M.id,M),p.set(M.idHash,M)});for(let M=0;M<((v=b==null?void 0:b.nodesRendered)==null?void 0:v.length);M++)this.renderedNodeMap.set(b.nodesRendered[M].idHash,b.nodesRendered[M]);(m=b==null?void 0:b.nodes)==null||m.forEach(M=>{var q;this.nodeMap.set("model-"+M.idHash,M),this.nodeIdMap.set(M.id,M),this.nodeIdHashMap.set(M.idHash,M),M.filtered&&this.filteredNodes.set(M.idHash,M);const H=this.renderedNodeMap.get(M.idHash);((q=this.activeNode)==null?void 0:q.id)===M.id&&this.renderedNodeMap.get(M.idHash)&&this.renderedNode&&H&&(this.renderedNode.node=H)}),(C=this.graphBag)==null||C.set(ID,b),this.explorer.updateGraphResponse(b),b&&b.nodes&&(this.modelTree.node=b==null?void 0:b.nodes[0]),this.explorer.equalizer.isInitialized()?this.explorer.equalizer.runEQ(!0):this.explorer.equalizer.initializeEqualizer()}customRulesetEnabled(b){var f,v,m;const p={rules:new Map};p.id=crypto.randomUUID(),p.owner=this.session.sessionId,b.detail.rules.forEach(C=>{C.rule.id!=C.ruleId&&(C.rule.id=C.ruleId),p.rules.set(C.ruleId,C.rule)}),(f=this.customRulesetBag)==null||f.set(YI,p),b.detail.ruleConfig?(v=this.ruleConfigBag)==null||v.set(k8,b.detail.ruleConfig):((m=this.ruleConfigBag)==null||m.reset(),_h.resetSessionRuleset(b.detail.rulesetReset).then(()=>{if(this.sendToast({id:crypto.randomUUID(),type:Ol.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.docBag){const C=this.docBag.get(VI);this.rolodexActivePath,this.lintSpec(C,this.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(C=>{var M;(M=this.rulesetEditor)==null||M.setValue(C,!0)})}).catch(C=>{this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:C.detail,title:"Cannot reset ruleset"})}))}async fetchSessionRulesetAsYaml(){return new Promise(async(b,p)=>{_h.getSessionRulesetAsYAML().then(f=>{b(f)}).catch(f=>{console.error("cannot fetch session ruleset: ",f.title),p(f)})})}async fetchFunctions(){return new Promise(async b=>{_h.getFunctions().then(p=>{var v;this.functions=p,(v=this.functionsBag)==null||v.set(KI,p);const f=[];p.forEach(m=>{f.push(this.fetchFunctionSchema(m))}),Promise.all(f).then(()=>{b(p)})})})}async fetchFunctionSchema(b){return new Promise(async p=>{_h.getFunctionSchema(b).then(f=>{var m,C;let v=(m=this.functionSchemaBag)==null?void 0:m.get(WI);v||(v=new Map),v.set(b,f),(C=this.functionSchemaBag)==null||C.set(WI,v),p(f)})})}async fetchDefaultRuleset(){return new Promise(async b=>{_h.getDefaultRuleset().then(p=>{var f;this.defaultRuleset=p,(f=this.defaultRulesetBag)==null||f.set(WQ,p),b(p)})})}async fetchOWASPRuleset(){return new Promise(async b=>{_h.getOWASPRuleset().then(p=>{var f;this.OWASPRuleset=p,(f=this.OWASPRulesetBag)==null||f.set(YQ,p),b(p)})})}async fetchAllRuleset(){return new Promise(async b=>{_h.getAllRuleset().then(p=>{var f;this.allRuleset=p,(f=this.allRulesetBag)==null||f.set(VQ,p),b(p)})})}fetchDocs(){this.activitySpinner.show(),k3.startSession().then(b=>{this.session=b,this.session.creditsRemaining?this.creditTicker.credits=this.session.creditsRemaining:this.creditTicker.credits=this.session.creditsRemaining,this.creditTicker.visible=!0,k3.fetchAllHowToFix().then(m=>{m&&m.forEach(C=>{var M;(M=this.howToFixBag)==null||M.set(C.ruleId,C)})}).catch(m=>{this.platformUnavailable(m),console.error("documentation service is down")}),this.ruleDocsBag=this.bagManager.getBag(Ryt),this.functionDocsBag=this.bagManager.getBag(Dyt),this.ruleDocsWorker.addEventListener("message",m=>{var M;const C=m.data;C&&((M=this.docExpirationBag)==null||M.set(qQ,new Date().toISOString()),C.forEach(H=>{var q,ce;H.ruleId&&((q=this.ruleDocsBag)==null||q.set(H.ruleId,H)),H.functionId&&((ce=this.functionDocsBag)==null||ce.set(H.functionId,H))}),this.activitySpinner.hide())});let p=[],f=[];this.ruleDocsBag&&(p=Array.from(this.ruleDocsBag.export().keys())),this.functionDocsBag&&(f=Array.from(this.functionDocsBag.export().keys()));const v=()=>{this.ruleDocsWorker.postMessage({start:!0,endpoint:this.doctorEndpoint,existingRules:p,existingFunctions:f})};if(this.docExpirationBag){const m=this.docExpirationBag.get(qQ);if(m){const C=new Date().getTime(),M=new Date(m).getTime();C-M>1296e6?v():this.activitySpinner.hide()}else v()}else v()}).catch(b=>{this.platformUnavailable(b),console.error("cannot start session")})}fetchRulesetMap(){_h.getSessionRulesetMap().then(b=>{var p;(p=this.sessionRulesetMapBag)==null||p.set(ED,b)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.sendToast({id:crypto.randomUUID(),type:Ol.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}ruleClicked(b){var f,v,m;const p=(f=this.sessionRulesetMapBag)==null?void 0:f.get(ED);if(p){const C=p.rulesMap.find(M=>M.ruleId===b.detail.ruleId);C&&(this.selectedEditorTab="ruleset",this.editorTabGroup.show(Tu.Ruleset),(v=this.rulesetEditor.editor)==null||v.setPosition({lineNumber:C.line,column:C.start}),(m=this.rulesetEditor.editor)==null||m.revealLineInCenter(C.line))}}builtInRulesetSelected(){}rulesetManuallyChanged(){clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{var p;const b=(p=this.rulesetEditor.editor)==null?void 0:p.getValue();_h.validateRuleset(b).then(f=>{var m;this.manageRuleset.clearRuleProblems();let v={rules:new Map};v.id=crypto.randomUUID(),v.owner=this.session.sessionId,v.rules=new Map(Object.entries(f.rules)),v.rules.forEach((C,M)=>{C.id=M}),(m=this.customRulesetBag)==null||m.set(YI,v),this.customRuleset=v,v.rules.size>0&&(this.manageRuleset.customRulesetManual=v),this.selectedEditorTab=Tu.Ruleset,this.controlTabGroup.show(Tu.Ruleset),this.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(f=>{this.sendToast({id:crypto.randomUUID(),type:Ol.ERROR,body:f.detail,title:f.title}),console.error("unable to validate ruleset",f);const v=f.body,m=[];v==null||v.forEach(C=>{m.push({severity:w3.MarkerSeverity.Error,message:C.ruleError,startLineNumber:C.line,startColumn:C.startCol,endLineNumber:C.line,endColumn:C.endCol})}),_h.convertToJSON(b).then(C=>{let M={rules:new Map};M.id=crypto.randomUUID(),M.owner=this.session.sessionId,M.rules=new Map(Object.entries(C.rules)),M.rules.forEach((H,q)=>{H.id!=q&&(H.id=q)}),this.customRuleset=M,M.rules.size>0&&(this.manageRuleset.customRulesetManual=M),this.rulesetEditor.setMarkers([]),this.manageRuleset.clearRuleProblems(),this.rulesetEditor.setMarkers(m),this.manageRuleset.processBadRules(v),this.controlTabGroup.show(Tu.Ruleset)}).catch(C=>{console.error("unable to convert ruleset to JSON",C)})})},this.debounceTimeRuleset)}specChanged(b){if(this.editorMap.get(b.detail.id)&&b.detail.id==="ruleset-editor"){this.rulesetManuallyChanged();return}this.docBag&&this.docBag.set(VI,b.detail.content),clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{this.lintSpec(b.detail.content)},this.debounceTime)}boostrap(){const p=new URL(window.location.href).searchParams.get("url");if(p){this.urlInput.value=p,this.activeURL=p,this.lintSpec("",p);return}(this.editor.getValue()===""||!this.problems)&&k3.bootstrapEditor().then(f=>{this.editor.setValue(f,!0),this.rolodexActivePath="",this.specChanged(new CustomEvent(eQ,{detail:{content:f,id:"spec"}}))})}exportJSON(){let b;if(this.ruleConfigBag){const p=this.ruleConfigBag.get(k8);p&&p.returnedRuleset&&(b=p.returnedRuleset)}if(b){let p="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(b,null,2));this.downloadRulesetLink.download="ruleset.json",this.downloadRulesetLink.href=p,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()}}exportYAML(){_h.getSessionRulesetAsYAML().then(b=>{let p="data:text/yaml;charset=utf-8,"+encodeURIComponent(b);this.downloadRulesetLink.download="ruleset.yaml",this.downloadRulesetLink.href=p,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()})}confirmExport(){switch(this.exportSelection.value){case"json":this.exportJSON();break;case"yaml":this.exportYAML();break}}closeWelcome(){this.welcomeBox.hide(),localStorage.setItem("pb33f-doctor-welcome","closed")}selectEditorTab(b){switch(this.selectedEditorTab=b.detail.name,b.detail.name){case Tu.Ruleset:this.rulesetPulse&&(this.rulesetPulse=!1),this.controlTabGroup.show(Tu.Ruleset);break}}selectControlTab(b){switch(b.detail.name){case Tu.Problems:case Tu.Overview:this.selectedEditorTab!="spec"&&(this.selectedEditorTab="spec",this.editorTabGroup.show("spec"));break;case Tu.Ruleset:this.selectedEditorTab!=Tu.Ruleset&&(this.editorTabGroup.show(Tu.Ruleset),this.selectedEditorTab=Tu.Ruleset);break}}toggleSidebar(){var p;const b=(p=this.shadowRoot)==null?void 0:p.querySelector("sl-split-panel.split-panel");this.sidebarClosed?b&&(this.collapseButton.name="chevron-bar-right",b.style.setProperty("--min","600px"),b.style.setProperty("--max","calc(100vw - 600px)"),b.position=60,b.disabled=!1,this.problemsDataDiv.style.display="block",this.splitDivider.style.display="block",this.activitySpinner.classList.remove("spinner-draw-closed")):b&&(this.collapseButton.name="chevron-bar-left",this.problemsDataDiv.style.display="none",b.style.setProperty("--min","40px"),b.style.setProperty("--max","calc(100vw - 40px)"),b.position=99,b.disabled=!0,this.splitDivider.style.display="none",this.activitySpinner.classList.add("spinner-draw-closed")),this.sidebarClosed=!this.sidebarClosed}toggleExplorer(){this.explorerVisible=!this.explorerVisible,this.explorerVisible&&this.activeNode&&this.explorer.moveToNode(this.activeNode),this.explorerBooted=!0}closeExplorer(){this.explorerVisible=!1,setTimeout(()=>{var b,p;this.pendingLine>0&&((b=this.editor.editor)==null||b.setPosition({lineNumber:this.pendingLine,column:1}),(p=this.editor.editor)==null||p.revealLineInCenter(this.pendingLine),this.pendingLine=0)},20)}render(){var M;let b=I.html``;this.unavailable&&(b=I.html`
9816
9817
  <div class="overlay" @click="return false"></div>`);let p=I.html`
9817
9818
  <pb33f-attention-box id="welcome" type="success"
9818
9819
  headerText="Welcome to the clinic, I am the OpenAPI doctor." closeable>
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.4.0",
6
+ "version": "0.5.1",
7
7
  "type": "module",
8
8
  "main": "./dist/cowboy-components.umd.cjs",
9
9
  "module": "./dist/cowboy-components.js",