3 Object.defineProperty(exports, "__esModule", {
6 exports.default = tokenizeAtRule;
8 var _globals = require('./globals');
10 var _unclosed = require('./unclosed');
12 var _unclosed2 = _interopRequireDefault(_unclosed);
14 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 function tokenizeAtRule(state) {
17 // it's an interpolation
18 if (state.css.charCodeAt(state.pos + 1) === _globals.openedCurlyBracket) {
19 state.nextPos = state.css.indexOf('}', state.pos + 2);
21 if (state.nextPos === -1) {
22 (0, _unclosed2.default)(state, 'interpolation');
25 state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
26 state.lines = state.cssPart.split('\n');
27 state.lastLine = state.lines.length - 1;
29 if (state.lastLine > 0) {
30 state.nextLine = state.line + state.lastLine;
31 state.nextOffset = state.nextPos - state.lines[state.lastLine].length;
33 state.nextLine = state.line;
34 state.nextOffset = state.offset;
37 state.tokens.push(['word', state.cssPart, state.line, state.pos - state.offset, state.nextLine, state.nextPos - state.nextOffset]);
39 state.offset = state.nextOffset;
40 state.line = state.nextLine;
42 _globals.atEndPattern.lastIndex = state.pos + 1;
43 _globals.atEndPattern.test(state.css);
45 if (_globals.atEndPattern.lastIndex === 0) {
46 state.nextPos = state.css.length - 1;
48 state.nextPos = _globals.atEndPattern.lastIndex - 2;
51 state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
52 state.token = 'at-word';
54 // check if it's a variable
55 if (_globals.variablePattern.test(state.cssPart)) {
56 _globals.wordEndPattern.lastIndex = state.pos + 1;
57 _globals.wordEndPattern.test(state.css);
58 if (_globals.wordEndPattern.lastIndex === 0) {
59 state.nextPos = state.css.length - 1;
61 state.nextPos = _globals.wordEndPattern.lastIndex - 2;
64 state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
68 state.tokens.push([state.token, state.cssPart, state.line, state.pos - state.offset, state.line, state.nextPos - state.offset]);
71 state.pos = state.nextPos;
73 module.exports = exports['default'];