var KEYCODE_ENTER=13,l10n_strings={},access_token;function callback(a,c){setTimeout(function(){var b=$("#SU_BRIDGE");b.text("");if(void 0!==c){var d=JSON.stringify(c);b.text(d)}window.location="skp:callback@"+a},0)}$(document).ready(function(){create_bridge();disable_select();hook_up_default_button();sketchup.html_ready("")});
function log_error(a){if("SyntaxError"==a.name)debugger;callback("log_error",{code:a.number,filename:a.fileName,name:a.name,line:a.lineNumber,col:a.columnNumber,stack:a.stack,string:a.toString()})}function create_bridge(){var a=$("<textarea id='SU_BRIDGE'></textarea>");a.hide();$("body").append(a)}
function hook_up_default_button(){var a=$("button[type=submit]");1==a.length&&$(document).keypress(function(c){if(c.which==KEYCODE_ENTER)return a.trigger("click"),c.preventDefault(),c.stopPropagation(),!1})}function disable_select(){$(document).on("mousedown selectstart",function(a){return $(a.target).is("input, textarea, select, option")})}
function disable_context_menu(){$(document).on("contextmenu",function(a){return $(a.target).is("input[type=text], input[type=email], input[type=password], textarea")})}function is_a_string(a){return a instanceof String||"string"==typeof a}function loading_image(){return"../images/ajax-loader.gif"}function missing_image(){return"../images/missing-image.svg"}
function default_item_image(a){switch(a.type){case "FOLDER":return"../images/folder_60.svg";case "FILE":return"../images/file_60.svg";default:return missing_image()}}function debug(a){sketchup.debug(a)}function set_access_token(a){access_token=a}var request_id=0;
function load_image(a,c){debug("load_image("+a+")");debug("> "+c);if("http"!=c.substring(0,4))debug("> Not an absolute URI."),$("#"+a).attr("src",c);else{var b=request_id+1;request_id++;debug("download ("+b+")");var d=new XMLHttpRequest,e=c.split("#")[0];debug(c);debug(e);d.open("GET",e,!0);try{d.responseType="arraybuffer";if("arraybuffer"!==d.responseType)throw"Array buffer not supported.";if("undefined"===typeof Uint8Array)throw"Uint8Array not supported.";}catch(f){set_failed_image(a);debug(f.message);
return}d.setRequestHeader("Authorization","Bearer "+access_token);d.onreadystatechange=function(){if(4==d.readyState)if(debug("> ready ("+b+")"),debug(c),debug(a),debug(d.status),200==d.status){debug("Success!");try{set_binary_image_data(d,a)}catch(e){set_failed_image(a),debug(e.message)}}else{set_failed_image(a);debug("Failure!");var f=String.fromCharCode.apply(null,new Uint8Array(d.response));debug(f)}};d.send()}}function set_failed_image(a){$("#"+a).attr("src",missing_image())}
function set_binary_image_data(a,c){var b=a.getResponseHeader("content-type"),d=base64ArrayBuffer(a.response),b="data:"+b+";base64,"+d;$("#"+c).attr("src",b)}function formatBytes(a,c){if(0==a)return"0 Bytes";if(1==a)return"1 Byte";var b=Math.floor(Math.log(a)/Math.log(1E3));return(a/Math.pow(1E3,b)).toPrecision(c+1||3)+" "+"Bytes KB MB GB TB PB EB ZB YB".split(" ")[b]}function l10n(a){var c=l10n_strings[a];return void 0===c?a:c}
function localize(a){l10n_strings=a;$(".localize").each(function(){var a=$(this),b;switch(a.prop("tagName").toLowerCase()){case "input":b=a.attr("placeholder");b=l10n(b);a.attr("placeholder",b);break;default:b=a.text(),b=l10n(b),a.text(b)}})};
