function s(t){for(var n={},e=t.split(" "),r=0;r<e.length;++r)n[e[r]]=!0;return n}var f="body catch class do else enum for foreach foreach_reverse if in interface mixin out scope struct switch try union unittest version while with",a={keywords:s("abstract alias align asm assert auto break case cast cdouble cent cfloat const continue debug default delegate delete deprecated export extern final finally function goto immutable import inout invariant is lazy macro module new nothrow override package pragma private protected public pure ref return shared short static super synchronized template this throw typedef typeid typeof volatile __FILE__ __LINE__ __gshared __traits __vector __parameters "+f),blockKeywords:s(f),builtin:s("bool byte char creal dchar double float idouble ifloat int ireal long real short ubyte ucent uint ulong ushort wchar wstring void size_t sizediff_t"),atoms:s("exit failure success true false null"),hooks:{"@":function(t,n){return t.eatWhile(/[\w\$_]/),"meta"}}},v=a.statementIndentUnit,x=a.keywords,_=a.builtin,d=a.blockKeywords,w=a.atoms,m=a.hooks,g=a.multiLineStrings,p=/[+\-*&%=<>!?|\/]/,o;function y(t,n){var e=t.next();if(m[e]){var r=m[e](t,n);if(r!==!1)return r}if(e=='"'||e=="'"||e=="`")return n.tokenize=z(e),n.tokenize(t,n);if(/[\[\]{}\(\),;\:\.]/.test(e))return o=e,null;if(/\d/.test(e))return t.eatWhile(/[\w\.]/),"number";if(e=="/"){if(t.eat("+"))return n.tokenize=b,b(t,n);if(t.eat("*"))return n.tokenize=h,h(t,n);if(t.eat("/"))return t.skipToEnd(),"comment"}if(p.test(e))return t.eatWhile(p),"operator";t.eatWhile(/[\w\$_\xa1-\uffff]/);var i=t.current();return x.propertyIsEnumerable(i)?(d.propertyIsEnumerable(i)&&(o="newstatement"),"keyword"):_.propertyIsEnumerable(i)?(d.propertyIsEnumerable(i)&&(o="newstatement"),"builtin"):w.propertyIsEnumerable(i)?"atom":"variable"}function z(t){return function(n,e){for(var r=!1,i,u=!1;(i=n.next())!=null;){if(i==t&&!r){u=!0;break}r=!r&&i=="\\"}return(u||!(r||g))&&(e.tokenize=null),"string"}}function h(t,n){for(var e=!1,r;r=t.next();){if(r=="/"&&e){n.tokenize=null;break}e=r=="*"}return"comment"}function b(t,n){for(var e=!1,r;r=t.next();){if(r=="/"&&e){n.tokenize=null;break}e=r=="+"}return"comment"}function k(t,n,e,r,i){this.indented=t,this.column=n,this.type=e,this.align=r,this.prev=i}function c(t,n,e){var r=t.indented;return t.context&&t.context.type=="statement"&&(r=t.context.indented),t.context=new k(r,n,e,null,t.context)}function l(t){var n=t.context.type;return(n==")"||n=="]"||n=="}")&&(t.indented=t.context.indented),t.context=t.context.prev}const I={name:"d",startState:function(t){return{tokenize:null,context:new k(-t,0,"top",!1),indented:0,startOfLine:!0}},token:function(t,n){var e=n.context;if(t.sol()&&(e.align??(e.align=!1),n.indented=t.indentation(),n.startOfLine=!0),t.eatSpace())return null;o=null;var r=(n.tokenize||y)(t,n);if(r=="comment"||r=="meta")return r;if(e.align??(e.align=!0),(o==";"||o==":"||o==",")&&e.type=="statement")l(n);else if(o=="{")c(n,t.column(),"}");else if(o=="[")c(n,t.column(),"]");else if(o=="(")c(n,t.column(),")");else if(o=="}"){for(;e.type=="statement";)e=l(n);for(e.type=="}"&&(e=l(n));e.type=="statement";)e=l(n)}else o==e.type?l(n):((e.type=="}"||e.type=="top")&&o!=";"||e.type=="statement"&&o=="newstatement")&&c(n,t.column(),"statement");return n.startOfLine=!1,r},indent:function(t,n,e){if(t.tokenize!=y&&t.tokenize!=null)return null;var r=t.context,i=n&&n.charAt(0);r.type=="statement"&&i=="}"&&(r=r.prev);var u=i==r.type;return r.type=="statement"?r.indented+(i=="{"?0:v||e.unit):r.align?r.column+(u?0:1):r.indented+(u?0:e.unit)},languageData:{indentOnInput:/^\s*[{}]$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}};export{I as t};
