import{__require as e}from"./configurationError.mjs";import{__require as r}from"./isSingleLineString.mjs";import{__require as n}from"./isWhitespace.mjs";var t,i;function a(){if(i)return t;i=1;const a=e(),o=r(),c=n();function l(e){return null!=e}return t=function(e,r,n){let t;function i({source:e,index:i,err:c,errTarget:l,lineCheckStr:s,onlyOneChar:d=!1,allowIndentation:g=!1}){switch(t={source:e,index:i,err:c,errTarget:l,onlyOneChar:d,allowIndentation:g},r){case"always":f();break;case"never":u();break;case"always-single-line":if(!o(s||e))return;f(n.expectedBeforeSingleLine);break;case"never-single-line":if(!o(s||e))return;u(n.rejectedBeforeSingleLine);break;case"always-multi-line":if(o(s||e))return;f(n.expectedBeforeMultiLine);break;case"never-multi-line":if(o(s||e))return;u(n.rejectedBeforeMultiLine);break;default:throw a(`Unknown expectation "${r}"`)}}function s({source:e,index:i,err:c,errTarget:l,lineCheckStr:s,onlyOneChar:f=!1}){switch(t={source:e,index:i,err:c,errTarget:l,onlyOneChar:f},r){case"always":d();break;case"never":g();break;case"always-single-line":if(!o(s||e))return;d(n.expectedAfterSingleLine);break;case"never-single-line":if(!o(s||e))return;g(n.rejectedAfterSingleLine);break;case"always-multi-line":if(o(s||e))return;d(n.expectedAfterMultiLine);break;case"never-multi-line":if(o(s||e))return;g(n.rejectedAfterMultiLine);break;case"at-least-one-space":d(n.expectedAfterAtLeast);break;default:throw a(`Unknown expectation "${r}"`)}}function f(r=n.expectedBefore){if(t.allowIndentation)return void function(r=n.expectedBefore){const{source:i,index:a,err:o}=t,c="newline"===e?"\n":"space"===e?" ":void 0;let l=a-1;for(;i[l]!==c;){if("\t"!==i[l]&&" "!==i[l])return void o(r(t.errTarget?t.errTarget:i[a]));l--}}(r);const{source:i,index:a}=t,o=i[a-1],s=i[a-2];if(l(o)){if("newline"===e){if("\n"===o&&"\r"===s&&(t.onlyOneChar||!c(i[a-3])))return;if("\n"===o&&"\r"!==s&&(t.onlyOneChar||!c(s)))return}("space"!==e||" "!==o||!t.onlyOneChar&&c(s))&&t.err(r(t.errTarget?t.errTarget:i[a]))}}function u(e=n.rejectedBefore){const{source:r,index:i}=t,a=r[i-1];l(a)&&c(a)&&t.err(e(t.errTarget?t.errTarget:r[i]))}function d(i=n.expectedAfter){const{source:a,index:o}=t,s=o+1<a.length?a[o+1]:"",f=o+2<a.length?a[o+2]:"";if(l(s)){if("newline"===e){if("\r"===s&&"\n"===f){const e=o+3<a.length?a[o+3]:"";if(t.onlyOneChar||!c(e))return}if("\n"===s&&(t.onlyOneChar||!c(f)))return}("space"!==e||" "!==s||"at-least-one-space"!==r&&!t.onlyOneChar&&c(f))&&t.err(i(t.errTarget?t.errTarget:a[o]))}}function g(e=n.rejectedAfter){const{source:r,index:i}=t,a=i+1<r.length?r[i+1]:"";l(a)&&c(a)&&t.err(e(t.errTarget?t.errTarget:r[i]))}return{before:i,beforeAllowingIndentation:function(e){i(Object.assign({},e,{allowIndentation:!0}))},after:s,afterOneOnly:function(e){s(Object.assign({},e,{onlyOneChar:!0}))}}}}export{a as __require};