/*

 CSS Beautifier
---------------

    Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)

    Based on code initially developed by: Einar Lielmanis, <elfz@laacz.lv>
        http://jsbeautifier.org/


    You are free to use this in any way you want, in case you find this useful or working for you.

    Usage:
        css_beautify(source_text);
        css_beautify(source_text, options);

    The options are:
        indent_size (default 4)          — indentation size,
        indent_char (default space)      — character to indent with,

    e.g

    css_beautify(css_source_text, {
      'indent_size': 1,
      'indent_char': '\t'
    });
*/// http://www.w3.org/TR/CSS21/syndata.html#tokenization
// http://www.w3.org/TR/css3-syntax/
//inside_using("qybase");
//qyboot.forbidLoadDefaultBase();
//using("wwliu_qiyun/qybase");
function css_beautify(e,t){function a(){return u=e.charAt(++o)}function f(){return e.charAt(o+1)}function l(t){var n=o;while(a())if(u=="\\")a(),a();else{if(u==t)break;if(u=="\n")break}return e.substring(n,o+1)}function c(){var e=o;while(i.test(f()))o++;return o!=e}function h(){var e=o;do;while(i.test(a()));return o!=e+1}function p(){var t=o;a();while(a())if(u=="*"&&f()=="/"){o++;break}return e.substring(t,o+1)}function d(e,t){return w.slice(-e.length+(t||0),t).join("").toLowerCase()==e}function y(){g++,v+=m}function b(){g--,v=v.slice(0,-n)}t=t||{};var n=t.indent_size||4,r=t.indent_char||" ";typeof n=="string"&&(n=parseInt(n));var i=/^\s+$/,s=/[\w$\-_]/,o=-1,u,v=e.match(/^[\r\n]*[\t ]*/)[0],m=Array(n+1).join(r),g=0;print={},print["{"]=function(e){print.singleSpace(),w.push(e),print.newLine()},print["}"]=function(e){print.newLine(),w.push(e),print.newLine()},print.newLine=function(e){if(!e)while(i.test(w[w.length-1]))w.pop();w.length&&w.push("\n"),v&&w.push(v)},print.singleSpace=function(){w.length&&!i.test(w[w.length-1])&&w.push(" ")};var w=[];v&&w.push(v);for(;;){var E=h();if(!u)break;u=="{"?(y(),print["{"](u)):u=="}"?(b(),print["}"](u)):u=='"'||u=="'"?w.push(l(u)):u==";"?w.push(u,"\n",v):u=="/"&&f()=="*"?(print.newLine(),w.push(p(),"\n",v)):u=="("?(w.push(u),c(),d("url",-1)&&a()&&(u!=")"&&u!='"'&&u!="'"?w.push(l(")")):o--)):u==")"?w.push(u):u==","?(c(),w.push(u),print.singleSpace()):u=="]"?w.push(u):u=="["||u=="="?(c(),w.push(u)):(E&&print.singleSpace(),w.push(u))}var S=w.join("").replace(/[\n ]+$/,"");return S}window.css_beautify=css_beautify;