turn-1}return n}getLine(){let n=this.lineEndPos;return(typeof n!="number"||n!==-1&&n<this.pos)&&(n=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=n),n===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[n-1]==="\r"&&(n-=1),this.buffer.substring(this.pos,n))}hasChars(n){return this.pos+n<=this.buffer.length}setNext(n){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=n,null}peek(n){return this.buffer.substr(this.pos,n)}*parseNext(n){switch(n){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let n=this.getLine();if(n===null)return this.setNext("stream");if(n[0]===Cl&&(yield*this.pushCount(1),n=n.substring(1)),n[0]==="%"){let r=n.length,l=n.indexOf("#");for(;l!==-1;){const u=n[l-1];if(u===" "||u==="	"){r=l-1;break}else l=n.indexOf("#",l+1)}for(;;){const u=n[r-1];if(u===" "||u==="	")r-=1;else break}const o=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(n.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){const r=yield*this.pushSpaces(!0);return yield*this.pushCount(n.length-r),yield*this.pushNewline(),"stream"}return yield Ll,yield*this.parseLineStart()}*parseLineStart(){const n=this.charAt(0);if(!n&&!this.atEnd)return this.setNext("line-start");if(n==="-"||n==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const r=this.peek(3);if((r==="---"||r==="...")&&Rt(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Rt(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[n,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((n==="-"||n==="?"||n===":")&&Rt(r)){const l=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=l,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const n=this.getLine();if(n===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(n[r]){case"#":yield*this.pushCount(n.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Da),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(n.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let n,r,l=-1;do n=yield*this.pushNewline(),n>0?(r=yield*this.pushSpaces(!1),this.indentValue=l=r):r=0,r+=yield*this.pushSpaces(!0);while(n+r>0);const o=this.getLine();if(o===null)return this.setNext("flow");if((l!==-1&&l<this.indentNext&&o[0]!=="#"||l===0&&(o.startsWith("---")||o.startsWith("..."))&&Rt(o[3]))&&!(l===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield Ol,yield*this.parseLineStart();let u=0;for(;o[u]===",";)u+=yield*this.pushCount(1),u+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(u+=yield*this.pushIndicators(),o[u]){case void 0:return"flow";case"#":return yield*this.pushCount(o.length-u),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Da),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const f=this.charAt(1);if(this.flowKey||Rt(f)||f===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const n=this.charAt(0);let r=this.buffer.indexOf(n,this.pos+1);if(n==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let u=0;for(;this.buffer[r-1-u]==="\\";)u+=1;if(u%2===0)break;r=this.buffer.indexOf('"',r+1)}const l=this.buffer.substring(0,r);let o=l.indexOf(`
`,this.pos);if(o!==-1){for(;o!==-1;){const u=this.continueScalar(o+1);if(u===-1)break;o=l.indexOf(`
`,u)}o!==-1&&(r=o-(l[o-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let n=this.pos;for(;;){const r=this.buffer[++n];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>Rt(r)||r==="#")}*parseBlockScalar(){let n=this.pos-1,r=0,l;e:for(let u=this.pos;l=this.buffer[u];++u)switch(l){case" ":r+=1;break;case`
`:n=u,r=0;break;case"\r":{const f=this.buffer[u+1];if(!f&&!this.atEnd)return this.setNext("block-scalar");if(f===`
`)break}default:break e}if(!l&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const u=this.continueScalar(n+1);if(u===-1)break;n=this.buffer.indexOf(`
`,u)}while(n!==-1);if(n===-1){if(!this.atEnd)return this.setNext("block-scalar");n=this.buffer.length}}let o=n+1;for(l=this.buffer[o];l===" ";)l=this.buffer[++o];if(l==="	"){for(;l==="	"||l===" "||l==="\r"||l===`
`;)l=this.buffer[++o];n=o-1}else if(!this.blockScalarKeep)do{let u=n-1,f=this.buffer[u];f==="\r"&&(f=this.buffer[--u]);const h=u;for(;f===" ";)f=this.buffer[--u];if(f===`
`&&u>=this.pos&&u+1+r>h)n=u;else break}while(!0);return yield $s,yield*this.pushToIndex(n+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const n=this.flowLevel>0;let r=this.pos-1,l=this.pos-1,o;for(;o=this.buffer[++l];)if(o===":"){const u=this.buffer[l+1];if(Rt(u)||n&&Yi.has(u))break;r=l}else if(Rt(o)){let u=this.buffer[l+1];if(o==="\r"&&(u===`
`?(l+=1,o=`
`,u=this.buffer[l+1]):r=l),u==="#"||n&&Yi.has(u))break;if(o===`
`){const f=this.continueScalar(l+1);if(f===-1)break;l=Math.max(l,f-2)}}else{if(n&&Yi.has(o))break;r=l}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield $s,yield*this.pushToIndex(r+1,!0),n?"flow":"doc")}*pushCount(n){return n>0?(yield this.buffer.substr(this.pos,n),this.pos+=n,n):0}*pushToIndex(n,r){const l=this.buffer.slice(this.pos,n);return l?(yield l,this.pos+=l.length,l.length):(r&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Da))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const n=this.flowLevel>0,r=this.charAt(1);if(Rt(r)||n&&Yi.has(r))return n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let n=this.pos+2,r=this.buffer[n];for(;!Rt(r)&&r!==">";)r=this.buffer[++n];return yield*this.pushToIndex(r===">"?n+1:n,!1)}else{let n=this.pos+1,r=this.buffer[n];for(;r;)if(h0.has(r))r=this.buffer[++n];else if(r==="%"&&Pd.has(this.buffer[n+1])&&Pd.has(this.buffer[n+2]))r=this.buffer[n+=3];else break;return yield*this.pushToIndex(n,!1)}}*pushNewline(){const n=this.buffer[this.pos];return n===`
`?yield*this.pushCount(1):n==="\r"&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(n){let r=this.pos-1,l;do l=this.buffer[++r];while(l===" "||n&&l==="	");const o=r-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=r),o}*pushUntil(n){let r=this.pos,l=this.buffer[r];for(;!n(l);)l=this.buffer[++r];return yield*this.pushToIndex(r,!1)}}class Gh{constructor(){this.lineStarts=[],this.addNewLine=n=>this.lineStarts.push(n),this.linePos=n=>{let r=0,l=this.lineStarts.length;for(;r<l;){const u=r+l>>1;this.lineStarts[u]<n?r=u+1:l=u}if(this.lineStarts[r]===n)return{line:r+1,col:1};if(r===0)return{line:0,col:n};const o=this.lineStarts[r-1];return{line:r,col:n-o+1}}}}function Fn(i,n){for(let r=0;r<i.length;++r)if(i[r].type===n)return!0;return!1}function Md(i){for(let n=0;n<i.length;++n)switch(i[n].type){case"space":case"comment":case"newline":break;default:return n}return-1}function Xh(i){switch(i==null?void 0:i.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Gi(i){switch(i.type){case"document":return i.start;case"block-map":{const n=i.items[i.items.length-1];return n.sep??n.start}case"block-seq":return i.items[i.items.length-1].start;default:return[]}}function wr(i){var r;if(i.length===0)return[];let n=i.length;e:for(;--n>=0;)switch(i[n].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;((r=i[++n])==null?void 0:r.type)==="space";);return i.splice(n,i.length)}function jd(i){if(i.start.type==="flow-seq-start")for(const n of i.items)n.sep&&!n.value&&!Fn(n.start,"explicit-key-ind")&&!Fn(n.sep,"map-value-ind")&&(n.key&&(n.value=n.key),delete n.key,Xh(n.value)?n.value.end?Array.prototype.push.apply(n.value.end,n.sep):n.value.end=n.sep:Array.prototype.push.apply(n.start,n.sep),delete n.sep)}class cu{constructor(n){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Yh,this.onNewLine=n}*parse(n,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const l of this.lexer.lex(n,r))yield*this.next(l);r||(yield*this.end())}*next(n){if(this.source=n,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=n.length;return}const r=Jh(n);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+n.length);break;case"space":this.atNewLine&&n[0]===" "&&(this.indent+=n.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=n.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=n.length}else{const l=`Not a YAML token: ${n}`;yield*this.pop({type:"error",offset:this.offset,message:l,source:n}),this.offset+=n.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const n=this.peek(1);if(this.type==="doc-end"&&(!n||n.type!=="doc-end")){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!n)return yield*this.stream();switch(n.type){case"document":return yield*this.document(n);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(n);case"block-scalar":return yield*this.blockScalar(n);case"block-map":return yield*this.blockMap(n);case"block-seq":return yield*this.blockSequence(n);case"flow-collection":return yield*this.flowCollection(n);case"doc-end":return yield*this.documentEnd(n)}yield*this.pop()}peek(n){return this.stack[this.stack.length-n]}*pop(n){const r=n??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{const l=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in l?l.indent:0:r.type==="flow-collection"&&l.type==="document"&&(r.indent=0),r.type==="flow-collection"&&jd(r),l.type){case"document":l.value=r;break;case"block-scalar":l.props.push(r);break;case"block-map":{const o=l.items[l.items.length-1];if(o.value){l.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=r;else{Object.assign(o,{key:r,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{const o=l.items[l.items.length-1];o.value?l.items.push({start:[],value:r}):o.value=r;break}case"flow-collection":{const o=l.items[l.items.length-1];!o||o.value?l.items.push({start:[],key:r,sep:[]}):o.sep?o.value=r:Object.assign(o,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((l.type==="document"||l.type==="block-map"||l.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){const o=r.items[r.items.length-1];o&&!o.sep&&!o.value&&o.start.length>0&&Md(o.start)===-1&&(r.indent===0||o.start.every(u=>u.type!=="comment"||u.indent<r.indent))&&(l.type==="document"?l.end=o.start:l.items.push({start:o.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const n={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&n.start.push(this.sourceToken),this.stack.push(n);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(n){if(n.value)return yield*this.lineEnd(n);switch(this.type){case"doc-start":{Md(n.start)!==-1?(yield*this.pop(),yield*this.step()):n.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":n.start.push(this.sourceToken);return}const r=this.startBlockValue(n);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(n){if(this.type==="map-value-ind"){const r=Gi(this.peek(2)),l=wr(r);let o;n.end?(o=n.end,o.push(this.sourceToken),delete n.end):o=[this.sourceToken];const u={type:"block-map",offset:n.offset,indent:n.indent,items:[{start:l,key:n,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=u}else yield*this.lineEnd(n)}*blockScalar(n){switch(this.type){case"space":case"comment":case"newline":n.props.push(this.sourceToken);return;case"scalar":if(n.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
`,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(n){var l;const r=n.items[n.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){const o="end"in r.value?r.value.end:void 0,u=Array.isArray(o)?o[o.length-1]:void 0;(u==null?void 0:u.type)==="comment"?o==null||o.push(this.sourceToken):n.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)n.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,n.indent)){const o=n.items[n.items.length-2],u=(l=o==null?void 0:o.value)==null?void 0:l.end;if(Array.isArray(u)){Array.prototype.push.apply(u,r.start),u.push(this.sourceToken),n.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=n.indent){const o=!this.onKeyLine&&this.indent===n.indent,u=o&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind";let f=[];if(u&&r.sep&&!r.value){const h=[];for(let p=0;p<r.sep.length;++p){const g=r.sep[p];switch(g.type){case"newline":h.push(p);break;case"space":break;case"comment":g.indent>n.indent&&(h.length=0);break;default:h.length=0}}h.length>=2&&(f=r.sep.splice(h[1]))}switch(this.type){case"anchor":case"tag":u||r.value?(f.push(this.sourceToken),n.items.push({start:f}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):u||r.value?(f.push(this.sourceToken),n.items.push({start:f,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)n.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Fn(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:f,key:null,sep:[this.sourceToken]}]});else if(Xh(r.key)&&!Fn(r.sep,"newline")){const h=wr(r.start),p=r.key,g=r.sep;g.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:p,sep:g}]})}else f.length>0?r.sep=r.sep.concat(f,this.sourceToken):r.sep.push(this.sourceToken);else if(Fn(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{const h=wr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||u?n.items.push({start:f,key:null,sep:[this.sourceToken]}):Fn(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const h=this.flowScalar(this.type);u||r.value?(n.items.push({start:f,key:h,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(h):(Object.assign(r,{key:h,sep:[]}),this.onKeyLine=!0);return}default:{const h=this.startBlockValue(n);if(h){o&&h.type!=="block-seq"&&n.items.push({start:f}),this.stack.push(h);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(n){var l;const r=n.items[n.items.length-1];switch(this.type){case"newline":if(r.value){const o="end"in r.value?r.value.end:void 0,u=Array.isArray(o)?o[o.length-1]:void 0;(u==null?void 0:u.type)==="comment"?o==null||o.push(this.sourceToken):n.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)n.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,n.indent)){const o=n.items[n.items.length-2],u=(l=o==null?void 0:o.value)==null?void 0:l.end;if(Array.isArray(u)){Array.prototype.push.apply(u,r.start),u.push(this.sourceToken),n.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=n.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==n.indent)break;r.value||Fn(r.start,"seq-item-ind")?n.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>n.indent){const o=this.startBlockValue(n);if(o){this.stack.push(o);return}}yield*this.pop(),yield*this.step()}*flowCollection(n){const r=n.items[n.items.length-1];if(this.type==="flow-error-end"){let l;do yield*this.pop(),l=this.peek(1);while(l&&l.type==="flow-collection")}else if(n.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?n.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?n.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?n.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);!r||r.value?n.items.push({start:[],key:o,sep:[]}):r.sep?this.stack.push(o):Object.assign(r,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":n.end.push(this.sourceToken);return}const l=this.startBlockValue(n);l?this.stack.push(l):(yield*this.pop(),yield*this.step())}else{const l=this.peek(2);if(l.type==="block-map"&&(this.type==="map-value-ind"&&l.indent===n.indent||this.type==="newline"&&!l.items[l.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&l.type!=="flow-collection"){const o=Gi(l),u=wr(o);jd(n);const f=n.end.splice(1,n.end.length);f.push(this.sourceToken);const h={type:"block-map",offset:n.offset,indent:n.indent,items:[{start:u,key:n,sep:f}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=h}else yield*this.lineEnd(n)}}flowScalar(n){if(this.onNewLine){let r=this.source.indexOf(`
`)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
`,r)+1}return{type:n,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(n){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const r=Gi(n),l=wr(r);return l.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const r=Gi(n),l=wr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(n,r){return this.type!=="comment"||this.indent<=r?!1:n.every(l=>l.type==="newline"||l.type==="space")}*documentEnd(n){this.type!=="doc-mode"&&(n.end?n.end.push(this.sourceToken):n.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(n){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:n.end?n.end.push(this.sourceToken):n.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Zh(i){const n=i.prettyErrors!==!1;return{lineCounter:i.lineCounter||n&&new Gh||null,prettyErrors:n}}function m0(i,n={}){const{lineCounter:r,prettyErrors:l}=Zh(n),o=new cu(r==null?void 0:r.addNewLine),u=new uu(n),f=Array.from(u.compose(o.parse(i)));if(l&&r)for(const h of f)h.errors.forEach(cl(i,r)),h.warnings.forEach(cl(i,r));return f.length>0?f:Object.assign([],{empty:!0},u.streamInfo())}function ep(i,n={}){const{lineCounter:r,prettyErrors:l}=Zh(n),o=new cu(r==null?void 0:r.addNewLine),u=new uu(n);let f=null;for(const h of u.compose(o.parse(i),!0,i.length))if(!f)f=h;else if(f.options.logLevel!=="silent"){f.errors.push(new Un(h.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return l&&r&&(f.errors.forEach(cl(i,r)),f.warnings.forEach(cl(i,r))),f}function g0(i,n,r){let l;typeof n=="function"?l=n:r===void 0&&n&&typeof n=="object"&&(r=n);const o=ep(i,r);if(!o)return null;if(o.warnings.forEach(u=>Sh(o.options.logLevel,u)),o.errors.length>0){if(o.options.logLevel!=="silent")throw o.errors[0];o.errors=[]}return o.toJS(Object.assign({reviver:l},r))}function y0(i,n,r){let l=null;if(typeof n=="function"||Array.isArray(n)?l=n:r===void 0&&n&&(r=n),typeof r=="string"&&(r=r.length),typeof r=="number"){const o=Math.round(r);r=o<1?void 0:o>8?{indent:8}:{indent:o}}if(i===void 0){const{keepUndefined:o}=r??n??{};if(!o)return}return qn(i)&&!l?i.toString(r):new br(i,l,r).toString(r)}const v0=Object.freeze(Object.defineProperty({__proto__:null,Alias:yl,CST:d0,Composer:uu,Document:br,Lexer:Yh,LineCounter:Gh,Pair:Ze,Parser:cu,Scalar:ie,Schema:_l,YAMLError:ou,YAMLMap:wt,YAMLParseError:Un,YAMLSeq:xn,YAMLWarning:Fh,isAlias:Wn,isCollection:Ie,isDocument:qn,isMap:Mr,isNode:$e,isPair:Ce,isScalar:ve,isSeq:jr,parse:g0,parseAllDocuments:m0,parseDocument:ep,stringify:y0,visit:Nn,visitAsync:gl},Symbol.toStringTag,{value:"Module"}));function w0(i,n,r={}){var T;const l=new i.LineCounter,o={keepSourceTokens:!0,lineCounter:l,...r},u=i.parseDocument(n,o),f=[],h=E=>[l.linePos(E[0]),l.linePos(E[1])],p=E=>{f.push({message:E.message,range:[l.linePos(E.pos[0]),l.linePos(E.pos[1])]})},g=(E,O)=>{for(const v of O.items){if(v instanceof i.Scalar&&typeof v.value=="string"){const A=dl.parse(v,o,f);A&&(E.children=E.children||[],E.children.push(A));continue}if(v instanceof i.YAMLMap){x(E,v);continue}f.push({message:"Sequence items should be strings or maps",range:h(v.range||O.range)})}},x=(E,O)=>{for(const v of O.items){if(E.children=E.children||[],!(v.key instanceof i.Scalar&&typeof v.key.value=="string")){f.push({message:"Only string keys are supported",range:h(v.key.range||O.range)});continue}const $=v.key,A=v.value;if($.value==="text"){if(!(A instanceof i.Scalar&&typeof A.value=="string")){f.push({message:"Text value should be a string",range:h(v.value.range||O.range)});continue}E.children.push({kind:"text",text:ba(A.value)});continue}if($.value==="/children"){if(!(A instanceof i.Scalar&&typeof A.value=="string")||A.value!=="contain"&&A.value!=="equal"&&A.value!=="deep-equal"){f.push({message:'Strict value should be "contain", "equal" or "deep-equal"',range:h(v.value.range||O.range)});continue}E.containerMode=A.value;continue}if($.value.startsWith("/")){if(!(A instanceof i.Scalar&&typeof A.value=="string")){f.push({message:"Property value should be a string",range:h(v.value.range||O.range)});continue}E.props=E.props??{},E.props[$.value.slice(1)]=ba(A.value);continue}const B=dl.parse($,o,f);if(!B)continue;if(A instanceof i.Scalar){const j=typeof A.value;if(j!=="string"&&j!=="number"&&j!=="boolean"){f.push({message:"Node value should be a string or a sequence",range:h(v.value.range||O.range)});continue}E.children.push({...B,children:[{kind:"text",text:ba(String(A.value))}]});continue}if(A instanceof i.YAMLSeq){E.children.push(B),g(B,A);continue}f.push({message:"Map values should be strings or sequences",range:h(v.value.range||O.range)})}},S={kind:"role",role:"fragment"};return u.errors.forEach(p),f.length?{errors:f,fragment:S}:(u.contents instanceof i.YAMLSeq||f.push({message:'Aria snapshot must be a YAML sequence, elements starting with " -"',range:u.contents?h(u.contents.range):[{line:0,col:0},{line:0,col:0}]}),f.length?{errors:f,fragment:S}:(g(S,u.contents),f.length?{errors:f,fragment:S0}:((T=S.children)==null?void 0:T.length)===1?{fragment:S.children[0],errors:f}:{fragment:S,errors:f}))}const S0={kind:"role",role:"fragment"};function tp(i){return i.replace(/[\u200b\u00ad]/g,"").replace(/[\r\n\s\t]+/g," ").trim()}function ba(i){return i.startsWith("/")&&i.endsWith("/")&&i.length>1?{pattern:i.slice(1,-1)}:tp(i)}class dl{static parse(n,r,l){try{return new dl(n.value)._parse()}catch(o){if(o instanceof Rd){const u=r.prettyErrors===!1?o.message:o.message+`:

`+n.value+`
`+" ".repeat(o.pos)+`^
`;return l.push({message:u,range:[r.lineCounter.linePos(n.range[0]),r.lineCounter.linePos(n.range[0]+o.pos)]}),null}throw o}}constructor(n){this._input=n,this._pos=0,this._length=n.length}_peek(){return this._input[this._pos]||""}_next(){return this._pos<this._length?this._input[this._pos++]:null}_eof(){return this._pos>=this._length}_isWhitespace(){return!this._eof()&&/\s/.test(this._peek())}_skipWhitespace(){for(;this._isWhitespace();)this._pos++}_readIdentifier(n){this._eof()&&this._throwError(`Unexpected end of input when expecting ${n}`);const r=this._pos;for(;!this._eof()&&/[a-zA-Z]/.test(this._peek());)this._pos++;return this._input.slice(r,this._pos)}_readString(){let n="",r=!1;for(;!this._eof();){const l=this._next();if(r)n+=l,r=!1;else if(l==="\\")r=!0;else{if(l==='"')return n;n+=l}}this._throwError("Unterminated string")}_throwError(n,r=0){throw new Rd(n,r||this._pos)}_readRegex(){let n="",r=!1,l=!1;for(;!this._eof();){const o=this._next();if(r)n+=o,r=!1;else if(o==="\\")r=!0,n+=o;else{if(o==="/"&&!l)return{pattern:n};o==="["?(l=!0,n+=o):o==="]"&&l?(n+=o,l=!1):n+=o}}this._throwError("Unterminated regex")}_readStringOrRegex(){const n=this._peek();return n==='"'?(this._next(),tp(this._readString())):n==="/"?(this._next(),this._readRegex()):null}_readAttributes(n){let r=this._pos;for(;this._skipWhitespace(),this._peek()==="[";){this._next(),this._skipWhitespace(),r=this._pos;const l=this._readIdentifier("attribute");this._skipWhitespace();let o="";if(this._peek()==="=")for(this._next(),this._skipWhitespace(),r=this._pos;this._peek()!=="]"&&!this._isWhitespace()&&!this._eof();)o+=this._next();this._skipWhitespace(),this._peek()!=="]"&&this._throwError("Expected ]"),this._next(),this._applyAttribute(n,l,o||"true",r)}}_parse(){this._skipWhitespace();const n=this._readIdentifier("role");this._skipWhitespace();const r=this._readStringOrRegex()||"",l={kind:"role",role:n,name:r};return this._readAttributes(l),this._skipWhitespace(),this._eof()||this._throwError("Unexpected input"),l}_applyAttribute(n,r,l,o){if(r==="checked"){this._assert(l==="true"||l==="false"||l==="mixed",'Value of "checked" attribute must be a boolean or "mixed"',o),n.checked=l==="true"?!0:l==="false"?!1:"mixed";return}if(r==="disabled"){this._assert(l==="true"||l==="false",'Value of "disabled" attribute must be a boolean',o),n.disabled=l==="true";return}if(r==="expanded"){this._assert(l==="true"||l==="false",'Value of "expanded" attribute must be a boolean',o),n.expanded=l==="true";return}if(r==="level"){this._assert(!isNaN(Number(l)),'Value of "level" attribute must be a number',o),n.level=Number(l);return}if(r==="pressed"){this._assert(l==="true"||l==="false"||l==="mixed",'Value of "pressed" attribute must be a boolean or "mixed"',o),n.pressed=l==="true"?!0:l==="false"?!1:"mixed";return}if(r==="selected"){this._assert(l==="true"||l==="false",'Value of "selected" attribute must be a boolean',o),n.selected=l==="true";return}this._assert(!1,`Unsupported attribute [${r}]`,o)}_assert(n,r,l){n||this._throwError(r||"Assertion error",l)}}class Rd extends Error{constructor(n,r){super(n),this.pos=r}}const k0=({sources:i,paused:n,log:r,mode:l})=>{var W;const[o,u]=ye.useState(),[f,h]=ye.useState(),[p,g]=Fa("recorderPropertiesTab","log"),[x,S]=ye.useState(),[T,E]=ye.useState(),O=o||f||((W=i[0])==null?void 0:W.id),v=ye.useMemo(()=>{if(O){const j=i.find(Y=>Y.id===O);if(j)return j}return $g()},[i,O]),[w,$]=ye.useState("");window.playwrightElementPicked=(j,Y)=>{const z=v.language;$(oh(z,j.selector)),S(j.ariaSnapshot),E([]),Y&&p!=="locator"&&p!=="aria"&&g("locator"),l==="inspecting"&&p==="aria"||window.dispatch({event:"setMode",params:{mode:l==="inspecting"?"standby":"recording"}}).catch(()=>{})},window.playwrightSetRunningFile=h;const A=ye.useRef(null);ye.useLayoutEffect(()=>{var j;(j=A.current)==null||j.scrollIntoView({block:"center",inline:"nearest"})},[A]),ye.useEffect(()=>{const j=Y=>{switch(Y.key){case"F8":Y.preventDefault(),n?window.dispatch({event:"resume"}):window.dispatch({event:"pause"});break;case"F10":Y.preventDefault(),n&&window.dispatch({event:"step"});break}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]);const B=ye.useCallback(j=>{(l==="none"||l==="inspecting")&&window.dispatch({event:"setMode",params:{mode:"standby"}}),$(j),window.dispatch({event:"highlightRequested",params:{selector:j}})},[l]),V=ye.useCallback(j=>{(l==="none"||l==="inspecting")&&window.dispatch({event:"setMode",params:{mode:"standby"}});const{fragment:Y,errors:z}=w0(v0,j,{prettyErrors:!1}),P=z.map(le=>({message:le.message,line:le.range[1].line,column:le.range[1].col,type:"subtle-error"}));E(P),S(j),z.length||window.dispatch({event:"highlightRequested",params:{ariaTemplate:Y}})},[l]);return H.jsxs("div",{className:"recorder",children:[H.jsxs(bd,{children:[H.jsx(vt,{icon:"circle-large-filled",title:"Record",toggled:l==="recording"||l==="recording-inspecting"||l==="assertingText"||l==="assertingVisibility",onClick:()=>{window.dispatch({event:"setMode",params:{mode:l==="none"||l==="standby"||l==="inspecting"?"recording":"standby"}})},children:"Record"}),H.jsx(kd,{}),H.jsx(vt,{icon:"inspect",title:"Pick locator",toggled:l==="inspecting"||l==="recording-inspecting",onClick:()=>{const j={inspecting:"standby",none:"inspecting",standby:"inspecting",recording:"recording-inspecting","recording-inspecting":"recording",assertingText:"recording-inspecting",assertingVisibility:"recording-inspecting",assertingValue:"recording-inspecting",assertingSnapshot:"recording-inspecting"}[l];window.dispatch({event:"setMode",params:{mode:j}}).catch(()=>{})}}),H.jsx(vt,{icon:"eye",title:"Assert visibility",toggled:l==="assertingVisibility",disabled:l==="none"||l==="standby"||l==="inspecting",onClick:()=>{window.dispatch({event:"setMode",params:{mode:l==="assertingVisibility"?"recording":"assertingVisibility"}})}}),H.jsx(vt,{icon:"whole-word",title:"Assert text",toggled:l==="assertingText",disabled:l==="none"||l==="standby"||l==="inspecting",onClick:()=>{window.dispatch({event:"setMode",params:{mode:l==="assertingText"?"recording":"assertingText"}})}}),H.jsx(vt,{icon:"symbol-constant",title:"Assert value",toggled:l==="assertingValue",disabled:l==="none"||l==="standby"||l==="inspecting",onClick:()=>{window.dispatch({event:"setMode",params:{mode:l==="assertingValue"?"recording":"assertingValue"}})}}),H.jsx(vt,{icon:"gist",title:"Assert snapshot",toggled:l==="assertingSnapshot",disabled:l==="none"||l==="standby"||l==="inspecting",onClick:()=>{window.dispatch({event:"setMode",params:{mode:l==="assertingSnapshot"?"recording":"assertingSnapshot"}})}}),H.jsx(kd,{}),H.jsx(vt,{icon:"files",title:"Copy",disabled:!v||!v.text,onClick:()=>{cd(v.text)}}),H.jsx(vt,{icon:"debug-continue",title:"Resume (F8)",ariaLabel:"Resume",disabled:!n,onClick:()=>{window.dispatch({event:"resume"})}}),H.jsx(vt,{icon:"debug-pause",title:"Pause (F8)",ariaLabel:"Pause",disabled:n,onClick:()=>{window.dispatch({event:"pause"})}}),H.jsx(vt,{icon:"debug-step-over",title:"Step over (F10)",ariaLabel:"Step over",disabled:!n,onClick:()=>{window.dispatch({event:"step"})}}),H.jsx("div",{style:{flex:"auto"}}),H.jsx("div",{children:"Target:"}),H.jsx(Og,{fileId:O,sources:i,setFileId:j=>{u(j),window.dispatch({event:"fileChanged",params:{file:j}})}}),H.jsx(vt,{icon:"clear-all",title:"Clear",disabled:!v||!v.text,onClick:()=>{window.dispatch({event:"clear"})}}),H.jsx(vt,{icon:"color-mode",title:"Toggle color mode",toggled:!1,onClick:()=>og()})]}),H.jsx(_g,{sidebarSize:200,main:H.jsx(Oa,{text:v.text,language:v.language,highlight:v.highlight,revealLine:v.revealLine,readOnly:!0,lineNumbers:!0}),sidebar:H.jsx(Cg,{rightToolbar:p==="locator"||p==="aria"?[H.jsx(vt,{icon:"files",title:"Copy",onClick:()=>cd((p==="locator"?w:x)||"")},1)]:[],tabs:[{id:"locator",title:"Locator",render:()=>H.jsx(Oa,{text:w,placeholder:"Type locator to inspect",language:v.language,focusOnChange:!0,onChange:B,wrapLines:!0})},{id:"log",title:"Log",render:()=>H.jsx(oy,{language:v.language,log:Array.from(r.values())})},{id:"aria",title:"Aria",render:()=>H.jsx(Oa,{text:x||"",placeholder:"Type aria template to match",language:"yaml",onChange:V,highlight:T,wrapLines:!0})}],selectedTab:p,setSelectedTab:g})})]})},E0=({})=>{const[i,n]=ye.useState([]),[r,l]=ye.useState(!1),[o,u]=ye.useState(new Map),[f,h]=ye.useState("none");return ye.useLayoutEffect(()=>{window.playwrightSetMode=h,window.playwrightSetSources=(p,g)=>{n(p),window.playwrightSourcesEchoForTest=p,document.title=g?`Playwright Inspector - ${g}`:"Playwright Inspector"},window.playwrightSetPaused=l,window.playwrightUpdateLogs=p=>{u(g=>{const x=new Map(g);for(const S of p)S.reveal=!g.has(S.id),x.set(S.id,S);return x})}},[]),H.jsx(k0,{sources:i,paused:r,log:o,mode:f})};(async()=>(ig(),pg.createRoot(document.querySelector("#root")).render(H.jsx(E0,{}))))();export{Xm as g};
