{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \n\t\t\t\t\n\t\t\t\t \n\t\t\t\t ' . $connection . '\n\t\t\t\t \n\t\t\t\t\n\t\t\t ';\n\n\t\t$header['Content-Type'] = 'text/xml';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 201;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('post', $xml, $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->assertThat(\n\t\t\t$this->object->inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection),\n\t\t\t$this->equalTo($returnData)\n\t\t);\n\t}\n\n\t/**\n\t * Tests the inviteByEmail method - failure\n\t *\n\t * @return void\n\t *\n\t * @expectedException DomainException\n\t * @since 13.1\n\t */\n\tpublic function testInviteByEmailFailure()\n\t{\n\t\t$email = 'example@domain.com';\n\t\t$first_name = 'Frist';\n\t\t$last_name = 'Last';\n\t\t$subject = 'Subject';\n\t\t$body = 'body';\n\t\t$connection = 'friend';\n\n\t\t$path = '/v1/people/~/mailbox';\n\n\t\t// Build the xml.\n\t\t$xml = '\n\t\t\t\t \n\t\t\t\t \t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t' . $first_name . '\n\t\t\t\t\t\t\t' . $last_name . '\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t' . $subject . '\n\t\t\t\t' . $body . '\n\t\t\t\t\n\t\t\t\t \n\t\t\t\t ' . $connection . '\n\t\t\t\t \n\t\t\t\t\n\t\t\t ';\n\n\t\t$header['Content-Type'] = 'text/xml';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 401;\n\t\t$returnData->body = $this->errorString;\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('post', $xml, $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection);\n\t}\n\n\t/**\n\t * Tests the inviteById method\n\t *\n\t * @return void\n\t *\n\t * @since 13.1\n\t */\n\tpublic function testInviteById()\n\t{\n\t\t$id = 'lcnIwDU0S6';\n\t\t$first_name = 'Frist';\n\t\t$last_name = 'Last';\n\t\t$subject = 'Subject';\n\t\t$body = 'body';\n\t\t$connection = 'friend';\n\n\t\t$name = 'NAME_SEARCH';\n\t\t$value = 'mwjY';\n\n\t\t$path = '/v1/people-search:(people:(api-standard-profile-request))';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 200;\n\t\t$returnData->body = '{\"apiStandardProfileRequest\": {\"headers\": {\"_total\": 1,\"values\": [{\"name\": \"x-li-auth-token\",\"value\": \"' .\n\t\t\t$name . ':' . $value . '\"}]}}}';\n\n\t\t$data['format'] = 'json';\n\t\t$data['first-name'] = $first_name;\n\t\t$data['last-name'] = $last_name;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->at(0))\n\t\t\t->method('get')\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$path = '/v1/people/~/mailbox';\n\n\t\t// Build the xml.\n\t\t$xml = '\n\t\t\t\t \n\t\t\t\t \t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t' . $subject . '\n\t\t\t\t' . $body . '\n\t\t\t\t\n\t\t\t\t \n\t\t\t\t ' . $connection . '\n\t\t\t\t \n\t\t\t\t \t' . $name . '\n\t\t\t\t ' . $value . '\n\t\t\t\t \n\t\t\t\t \n\t\t\t\t\n\t\t\t ';\n\n\t\t$header['Content-Type'] = 'text/xml';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 201;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$this->client->expects($this->at(1))\n\t\t\t->method('post', $xml, $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->assertThat(\n\t\t\t$this->object->inviteById($id, $first_name, $last_name, $subject, $body, $connection),\n\t\t\t$this->equalTo($returnData)\n\t\t);\n\t}\n\n\t/**\n\t * Tests the inviteById method - failure\n\t *\n\t * @return void\n\t *\n\t * @expectedException RuntimeException\n\t * @since 13.1\n\t */\n\tpublic function testInviteByIdFailure()\n\t{\n\t\t$id = 'lcnIwDU0S6';\n\t\t$first_name = 'Frist';\n\t\t$last_name = 'Last';\n\t\t$subject = 'Subject';\n\t\t$body = 'body';\n\t\t$connection = 'friend';\n\n\t\t$path = '/v1/people-search:(people:(api-standard-profile-request))';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 200;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$data['format'] = 'json';\n\t\t$data['first-name'] = $first_name;\n\t\t$data['last-name'] = $last_name;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->at(0))\n\t\t\t->method('get')\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->inviteById($id, $first_name, $last_name, $subject, $body, $connection);\n\t}\n\n\t/**\n\t * Tests the sendMessage method\n\t *\n\t * @return void\n\t *\n\t * @since 13.1\n\t */\n\tpublic function testSendMessage()\n\t{\n\t\t$recipient = array('~', 'lcnIwDU0S6');\n\t\t$subject = 'Subject';\n\t\t$body = 'body';\n\n\t\t$path = '/v1/people/~/mailbox';\n\n\t\t// Build the xml.\n\t\t$xml = '\n\t\t\t\t \n\t\t\t\t \t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t \n\t\t\t\t ' . $subject . '\n\t\t\t\t ' . $body . '\n\t\t\t\t';\n\n\t\t$header['Content-Type'] = 'text/xml';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 201;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('post', $xml, $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->assertThat(\n\t\t\t$this->object->sendMessage($recipient, $subject, $body),\n\t\t\t$this->equalTo($returnData)\n\t\t);\n\t}\n\n\t/**\n\t * Tests the sendMessage method - failure\n\t *\n\t * @return void\n\t *\n\t * @expectedException DomainException\n\t * @since 13.1\n\t */\n\tpublic function testSendMessageFailure()\n\t{\n\t\t$recipient = array('~', 'lcnIwDU0S6');\n\t\t$subject = 'Subject';\n\t\t$body = 'body';\n\n\t\t$path = '/v1/people/~/mailbox';\n\n\t\t// Build the xml.\n\t\t$xml = '\n\t\t\t\t \n\t\t\t\t \t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t \n\t\t\t\t ' . $subject . '\n\t\t\t\t ' . $body . '\n\t\t\t\t';\n\n\t\t$header['Content-Type'] = 'text/xml';\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 401;\n\t\t$returnData->body = $this->errorString;\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('post', $xml, $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->sendMessage($recipient, $subject, $body);\n\t}\n}\n"},"repo_name":{"kind":"string","value":"philip-sorokin/joomla-cms"},"path":{"kind":"string","value":"tests/unit/suites/libraries/joomla/linkedin/JLinkedinCommunicationsTest.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":10137,"string":"10,137"}}},{"rowIdx":61538406,"cells":{"code":{"kind":"string","value":" '1',\n\t\t\t\t\t'from' => $from,\n\t\t\t\t\t'to' => $to\n\t\t\t\t),\n\t\t\t\t'http://www.google.com/finance/converter'\n\t\t\t\t);\n\n\t$url = apply_filters( '_wpsc_get_exchange_rate_service_endpoint', $url, $from, $to );\n\n\t$response = wp_remote_retrieve_body( wp_remote_get( $url, array( 'timeout' => 10 ) ) );\n\n\tif ( has_filter( '_wpsc_get_exchange_rate' ) ) {\n\t\treturn (float) apply_filters( '_wpsc_get_exchange_rate', $response, $from, $to );\n\t}\n\n\tif ( empty( $response ) ) {\n\t\treturn $response;\n\t} else {\n\n $rate = explode( 'bld>', $response );\n $rate = explode( $to, $rate[1] );\n\t\t$rate = trim( $rate[0] );\n\t\tset_transient( $key, $rate, DAY_IN_SECONDS );\n\n\t\treturn (float) $rate;\n\t}\n}\n\nfunction wpsc_convert_currency( $amt, $from, $to ) {\n\n\tif ( empty( $from ) || empty( $to ) ) {\n\t\treturn $amt;\n\t}\n\n\t$rate = _wpsc_get_exchange_rate( $from, $to );\n\n\tif ( is_wp_error( $rate ) ) {\n\t\treturn $rate;\n\t}\n\n\treturn $rate * $amt;\n}\n\nfunction wpsc_string_to_float( $string ) {\n\tglobal $wp_locale;\n\n\t$decimal_separator = get_option(\n\t\t'wpsc_decimal_separator',\n\t\t$wp_locale->number_format['decimal_point']\n\t);\n\n\t$string = preg_replace( '/[^0-9\\\\' . $decimal_separator . ']/', '', $string );\n\t$string = str_replace( $decimal_separator, '.', $string );\n\n\treturn (float) $string;\n}\n\nfunction wpsc_format_number( $number, $decimals = 2 ) {\n\tglobal $wp_locale;\n\n\t$decimal_separator = get_option(\n\t\t'wpsc_decimal_separator',\n\t\t$wp_locale->number_format['decimal_point']\n\t);\n\n\t$thousands_separator = get_option(\n\t\t'wpsc_thousands_separator',\n\t\t$wp_locale->number_format['thousands_sep']\n\t);\n\n\t$formatted = number_format(\n\t\t(float) $number,\n\t\t$decimals,\n\t\t$decimal_separator,\n\t\t$thousands_separator\n\t);\n\n\treturn $formatted;\n}"},"repo_name":{"kind":"string","value":"ericbarns/WP-e-Commerce"},"path":{"kind":"string","value":"wpsc-includes/currency.helpers.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":1953,"string":"1,953"}}},{"rowIdx":61538407,"cells":{"code":{"kind":"string","value":"import { Mongo } from \"meteor/mongo\";\n\n/**\n * Client side collections\n */\n\nexport const Countries = new Mongo.Collection(null);\n"},"repo_name":{"kind":"string","value":"deetail/kimchi4u"},"path":{"kind":"string","value":"client/collections/countries.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"gpl-3.0"},"size":{"kind":"number","value":128,"string":"128"}}},{"rowIdx":61538408,"cells":{"code":{"kind":"string","value":"from inspect import ismethod, isfunction\nimport os\nimport time\nimport traceback\n\nfrom CodernityDB.database import RecordDeleted, RecordNotFound\nfrom couchpotato import md5, get_db\nfrom couchpotato.api import addApiView\nfrom couchpotato.core.event import fireEvent, addEvent\nfrom couchpotato.core.helpers.encoding import toUnicode, sp\nfrom couchpotato.core.helpers.variable import getTitle, tryInt\nfrom couchpotato.core.logger import CPLog\nfrom couchpotato.core.plugins.base import Plugin\nfrom .index import ReleaseIndex, ReleaseStatusIndex, ReleaseIDIndex, ReleaseDownloadIndex\nfrom couchpotato.environment import Env\n\n\nlog = CPLog(__name__)\n\n\nclass Release(Plugin):\n\n _database = {\n 'release': ReleaseIndex,\n 'release_status': ReleaseStatusIndex,\n 'release_identifier': ReleaseIDIndex,\n 'release_download': ReleaseDownloadIndex\n }\n\n def __init__(self):\n addApiView('release.manual_download', self.manualDownload, docs = {\n 'desc': 'Send a release manually to the downloaders',\n 'params': {\n 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'}\n }\n })\n addApiView('release.delete', self.deleteView, docs = {\n 'desc': 'Delete releases',\n 'params': {\n 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'}\n }\n })\n addApiView('release.ignore', self.ignore, docs = {\n 'desc': 'Toggle ignore, for bad or wrong releases',\n 'params': {\n 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'}\n }\n })\n\n addEvent('release.add', self.add)\n addEvent('release.download', self.download)\n addEvent('release.try_download_result', self.tryDownloadResult)\n addEvent('release.create_from_search', self.createFromSearch)\n addEvent('release.delete', self.delete)\n addEvent('release.clean', self.clean)\n addEvent('release.update_status', self.updateStatus)\n addEvent('release.with_status', self.withStatus)\n addEvent('release.for_media', self.forMedia)\n\n # Clean releases that didn't have activity in the last week\n addEvent('app.load', self.cleanDone, priority = 1000)\n fireEvent('schedule.interval', 'movie.clean_releases', self.cleanDone, hours = 12)\n\n def cleanDone(self):\n log.debug('Removing releases from dashboard')\n\n now = time.time()\n week = 604800\n\n db = get_db()\n\n # Get (and remove) parentless releases\n releases = db.all('release', with_doc = False)\n media_exist = []\n reindex = 0\n for release in releases:\n if release.get('key') in media_exist:\n continue\n\n try:\n\n try:\n doc = db.get('id', release.get('_id'))\n except RecordDeleted:\n reindex += 1\n continue\n\n db.get('id', release.get('key'))\n media_exist.append(release.get('key'))\n\n try:\n if doc.get('status') == 'ignore':\n doc['status'] = 'ignored'\n db.update(doc)\n except:\n log.error('Failed fixing mis-status tag: %s', traceback.format_exc())\n except ValueError:\n fireEvent('database.delete_corrupted', release.get('key'), traceback_error = traceback.format_exc(0))\n reindex += 1\n except RecordDeleted:\n db.delete(doc)\n log.debug('Deleted orphaned release: %s', doc)\n reindex += 1\n except:\n log.debug('Failed cleaning up orphaned releases: %s', traceback.format_exc())\n\n if reindex > 0:\n db.reindex()\n\n del media_exist\n\n # get movies last_edit more than a week ago\n medias = fireEvent('media.with_status', ['done', 'active'], single = True)\n\n for media in medias:\n if media.get('last_edit', 0) > (now - week):\n continue\n\n for rel in self.forMedia(media['_id']):\n\n # Remove all available releases\n if rel['status'] in ['available']:\n self.delete(rel['_id'])\n\n # Set all snatched and downloaded releases to ignored to make sure they are ignored when re-adding the media\n elif rel['status'] in ['snatched', 'downloaded']:\n self.updateStatus(rel['_id'], status = 'ignored')\n\n if 'recent' in media.get('tags', []):\n fireEvent('media.untag', media.get('_id'), 'recent', single = True)\n\n def add(self, group, update_info = True, update_id = None):\n\n try:\n db = get_db()\n\n release_identifier = '%s.%s.%s' % (group['identifier'], group['meta_data'].get('audio', 'unknown'), group['meta_data']['quality']['identifier'])\n\n # Add movie if it doesn't exist\n try:\n media = db.get('media', 'imdb-%s' % group['identifier'], with_doc = True)['doc']\n except:\n media = fireEvent('movie.add', params = {\n 'identifier': group['identifier'],\n 'profile_id': None,\n }, search_after = False, update_after = update_info, notify_after = False, status = 'done', single = True)\n\n release = None\n if update_id:\n try:\n release = db.get('id', update_id)\n release.update({\n 'identifier': release_identifier,\n 'last_edit': int(time.time()),\n 'status': 'done',\n })\n except:\n log.error('Failed updating existing release: %s', traceback.format_exc())\n else:\n\n # Add Release\n if not release:\n release = {\n '_t': 'release',\n 'media_id': media['_id'],\n 'identifier': release_identifier,\n 'quality': group['meta_data']['quality'].get('identifier'),\n 'is_3d': group['meta_data']['quality'].get('is_3d', 0),\n 'last_edit': int(time.time()),\n 'status': 'done'\n }\n\n try:\n r = db.get('release_identifier', release_identifier, with_doc = True)['doc']\n r['media_id'] = media['_id']\n except:\n log.debug('Failed updating release by identifier \"%s\". Inserting new.', release_identifier)\n r = db.insert(release)\n\n # Update with ref and _id\n release.update({\n '_id': r['_id'],\n '_rev': r['_rev'],\n })\n\n # Empty out empty file groups\n release['files'] = dict((k, [toUnicode(x) for x in v]) for k, v in group['files'].items() if v)\n db.update(release)\n\n fireEvent('media.restatus', media['_id'], allowed_restatus = ['done'], single = True)\n\n return True\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return False\n\n def deleteView(self, id = None, **kwargs):\n\n return {\n 'success': self.delete(id)\n }\n\n def delete(self, release_id):\n\n try:\n db = get_db()\n rel = db.get('id', release_id)\n db.delete(rel)\n return True\n except RecordDeleted:\n log.debug('Already deleted: %s', release_id)\n return True\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return False\n\n def clean(self, release_id):\n\n try:\n db = get_db()\n rel = db.get('id', release_id)\n raw_files = rel.get('files')\n\n if len(raw_files) == 0:\n self.delete(rel['_id'])\n else:\n\n files = {}\n for file_type in raw_files:\n\n for release_file in raw_files.get(file_type, []):\n if os.path.isfile(sp(release_file)):\n if file_type not in files:\n files[file_type] = []\n files[file_type].append(release_file)\n\n rel['files'] = files\n db.update(rel)\n\n return True\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return False\n\n def ignore(self, id = None, **kwargs):\n\n db = get_db()\n\n try:\n if id:\n rel = db.get('id', id, with_doc = True)\n self.updateStatus(id, 'available' if rel['status'] in ['ignored', 'failed'] else 'ignored')\n\n return {\n 'success': True\n }\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return {\n 'success': False\n }\n\n def manualDownload(self, id = None, **kwargs):\n\n db = get_db()\n\n try:\n release = db.get('id', id)\n item = release['info']\n movie = db.get('id', release['media_id'])\n\n fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Snatching \"%s\"' % item['name'])\n\n # Get matching provider\n provider = fireEvent('provider.belongs_to', item['url'], provider = item.get('provider'), single = True)\n\n if item.get('protocol') != 'torrent_magnet':\n item['download'] = provider.loginDownload if provider.urls.get('login') else provider.download\n\n success = self.download(data = item, media = movie, manual = True)\n\n if success:\n fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Successfully snatched \"%s\"' % item['name'])\n\n return {\n 'success': success == True\n }\n\n except:\n log.error('Couldn\\'t find release with id: %s: %s', (id, traceback.format_exc()))\n return {\n 'success': False\n }\n\n def download(self, data, media, manual = False):\n\n # Test to see if any downloaders are enabled for this type\n downloader_enabled = fireEvent('download.enabled', manual, data, single = True)\n if not downloader_enabled:\n log.info('Tried to download, but none of the \"%s\" downloaders are enabled or gave an error', data.get('protocol'))\n return False\n\n # Download NZB or torrent file\n filedata = None\n if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):\n try:\n filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))\n except:\n log.error('Tried to download, but the \"%s\" provider gave an error: %s', (data.get('protocol'), traceback.format_exc()))\n return False\n\n if filedata == 'try_next':\n return filedata\n elif not filedata:\n return False\n\n # Send NZB or torrent file to downloader\n download_result = fireEvent('download', data = data, media = media, manual = manual, filedata = filedata, single = True)\n if not download_result:\n log.info('Tried to download, but the \"%s\" downloader gave an error', data.get('protocol'))\n return False\n log.debug('Downloader result: %s', download_result)\n\n try:\n db = get_db()\n\n try:\n rls = db.get('release_identifier', md5(data['url']), with_doc = True)['doc']\n except:\n log.error('No release found to store download information in')\n return False\n\n renamer_enabled = Env.setting('enabled', 'renamer')\n\n # Save download-id info if returned\n if isinstance(download_result, dict):\n rls['download_info'] = download_result\n db.update(rls)\n\n log_movie = '%s (%s) in %s' % (getTitle(media), media['info'].get('year'), rls['quality'])\n snatch_message = 'Snatched \"%s\": %s from %s' % (data.get('name'), log_movie, (data.get('provider', '') + data.get('provider_extra', '')))\n log.info(snatch_message)\n fireEvent('%s.snatched' % data['type'], message = snatch_message, data = media)\n\n # Mark release as snatched\n if renamer_enabled:\n self.updateStatus(rls['_id'], status = 'snatched')\n\n # If renamer isn't used, mark media done if finished or release downloaded\n else:\n\n if media['status'] == 'active':\n profile = db.get('id', media['profile_id'])\n if fireEvent('quality.isfinish', {'identifier': rls['quality'], 'is_3d': rls.get('is_3d', False)}, profile, single = True):\n log.info('Renamer disabled, marking media as finished: %s', log_movie)\n\n # Mark release done\n self.updateStatus(rls['_id'], status = 'done')\n\n # Mark media done\n fireEvent('media.restatus', media['_id'], single = True)\n\n return True\n\n # Assume release downloaded\n self.updateStatus(rls['_id'], status = 'downloaded')\n\n except:\n log.error('Failed storing download status: %s', traceback.format_exc())\n return False\n\n return True\n\n def tryDownloadResult(self, results, media, quality_custom):\n\n wait_for = False\n let_through = False\n filtered_results = []\n minimum_seeders = tryInt(Env.setting('minimum_seeders', section = 'torrent', default = 1))\n\n # Filter out ignored and other releases we don't want\n for rel in results:\n\n if rel['status'] in ['ignored', 'failed']:\n log.info('Ignored: %s', rel['name'])\n continue\n\n if rel['score'] < quality_custom.get('minimum_score'):\n log.info('Ignored, score \"%s\" to low, need at least \"%s\": %s', (rel['score'], quality_custom.get('minimum_score'), rel['name']))\n continue\n\n if rel['size'] <= 50:\n log.info('Ignored, size \"%sMB\" to low: %s', (rel['size'], rel['name']))\n continue\n\n if 'seeders' in rel and rel.get('seeders') < minimum_seeders:\n log.info('Ignored, not enough seeders, has %s needs %s: %s', (rel.get('seeders'), minimum_seeders, rel['name']))\n continue\n\n # If a single release comes through the \"wait for\", let through all\n rel['wait_for'] = False\n if quality_custom.get('index') != 0 and quality_custom.get('wait_for', 0) > 0 and rel.get('age') <= quality_custom.get('wait_for', 0):\n rel['wait_for'] = True\n else:\n let_through = True\n\n filtered_results.append(rel)\n\n # Loop through filtered results\n for rel in filtered_results:\n\n # Only wait if not a single release is old enough\n if rel.get('wait_for') and not let_through:\n log.info('Ignored, waiting %s days: %s', (quality_custom.get('wait_for') - rel.get('age'), rel['name']))\n wait_for = True\n continue\n\n downloaded = fireEvent('release.download', data = rel, media = media, single = True)\n if downloaded is True:\n return True\n elif downloaded != 'try_next':\n break\n\n return wait_for\n\n def createFromSearch(self, search_results, media, quality):\n\n try:\n db = get_db()\n\n found_releases = []\n\n is_3d = False\n try: is_3d = quality['custom']['3d']\n except: pass\n\n for rel in search_results:\n\n rel_identifier = md5(rel['url'])\n\n release = {\n '_t': 'release',\n 'identifier': rel_identifier,\n 'media_id': media.get('_id'),\n 'quality': quality.get('identifier'),\n 'is_3d': is_3d,\n 'status': rel.get('status', 'available'),\n 'last_edit': int(time.time()),\n 'info': {}\n }\n\n # Add downloader info if provided\n try:\n release['download_info'] = rel['download_info']\n del rel['download_info']\n except:\n pass\n\n try:\n rls = db.get('release_identifier', rel_identifier, with_doc = True)['doc']\n except:\n rls = db.insert(release)\n rls.update(release)\n\n # Update info, but filter out functions\n for info in rel:\n try:\n if not isinstance(rel[info], (str, unicode, int, long, float)):\n continue\n\n rls['info'][info] = toUnicode(rel[info]) if isinstance(rel[info], (str, unicode)) else rel[info]\n except:\n log.debug('Couldn\\'t add %s to ReleaseInfo: %s', (info, traceback.format_exc()))\n\n db.update(rls)\n\n # Update release in search_results\n rel['status'] = rls.get('status')\n\n if rel['status'] == 'available':\n found_releases.append(rel_identifier)\n\n return found_releases\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return []\n\n def updateStatus(self, release_id, status = None):\n if not status: return False\n\n try:\n db = get_db()\n\n rel = db.get('id', release_id)\n if rel and rel.get('status') != status:\n\n release_name = None\n if rel.get('files'):\n for file_type in rel.get('files', {}):\n if file_type == 'movie':\n for release_file in rel['files'][file_type]:\n release_name = os.path.basename(release_file)\n break\n\n if not release_name and rel.get('info'):\n release_name = rel['info'].get('name')\n\n #update status in Db\n log.debug('Marking release %s as %s', (release_name, status))\n rel['status'] = status\n rel['last_edit'] = int(time.time())\n\n db.update(rel)\n\n #Update all movie info as there is no release update function\n fireEvent('notify.frontend', type = 'release.update_status', data = rel)\n\n return True\n except:\n log.error('Failed: %s', traceback.format_exc())\n\n return False\n\n def withStatus(self, status, with_doc = True):\n\n db = get_db()\n\n status = list(status if isinstance(status, (list, tuple)) else [status])\n\n for s in status:\n for ms in db.get_many('release_status', s):\n if with_doc:\n try:\n doc = db.get('id', ms['_id'])\n yield doc\n except RecordNotFound:\n log.debug('Record not found, skipping: %s', ms['_id'])\n else:\n yield ms\n\n def forMedia(self, media_id):\n\n db = get_db()\n raw_releases = db.get_many('release', media_id)\n\n releases = []\n for r in raw_releases:\n try:\n doc = db.get('id', r.get('_id'))\n releases.append(doc)\n except RecordDeleted:\n pass\n except (ValueError, EOFError):\n fireEvent('database.delete_corrupted', r.get('_id'), traceback_error = traceback.format_exc(0))\n\n releases = sorted(releases, key = lambda k: k.get('info', {}).get('score', 0), reverse = True)\n\n # Sort based on preferred search method\n download_preference = self.conf('preferred_method', section = 'searcher')\n if download_preference != 'both':\n releases = sorted(releases, key = lambda k: k.get('info', {}).get('protocol', '')[:3], reverse = (download_preference == 'torrent'))\n\n return releases or []\n"},"repo_name":{"kind":"string","value":"coderb0t/CouchPotatoServer"},"path":{"kind":"string","value":"couchpotato/core/plugins/release/main.py"},"language":{"kind":"string","value":"Python"},"license":{"kind":"string","value":"gpl-3.0"},"size":{"kind":"number","value":20734,"string":"20,734"}}},{"rowIdx":61538409,"cells":{"code":{"kind":"string","value":"package aws\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"math\"\n\t\"regexp\"\n\n\t\"github.com/hashicorp/terraform/helper/resource\"\n\t\"github.com/hashicorp/terraform/helper/schema\"\n\n\t\"github.com/aws/aws-sdk-go/aws\"\n\t\"github.com/aws/aws-sdk-go/aws/awserr\"\n\tevents \"github.com/aws/aws-sdk-go/service/cloudwatchevents\"\n\t\"github.com/hashicorp/terraform/helper/validation\"\n)\n\nfunc resourceAwsCloudWatchEventTarget() *schema.Resource {\n\treturn &schema.Resource{\n\t\tCreate: resourceAwsCloudWatchEventTargetCreate,\n\t\tRead: resourceAwsCloudWatchEventTargetRead,\n\t\tUpdate: resourceAwsCloudWatchEventTargetUpdate,\n\t\tDelete: resourceAwsCloudWatchEventTargetDelete,\n\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"rule\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tForceNew: true,\n\t\t\t\tValidateFunc: validateCloudWatchEventRuleName,\n\t\t\t},\n\n\t\t\t\"target_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tComputed: true,\n\t\t\t\tForceNew: true,\n\t\t\t\tValidateFunc: validateCloudWatchEventTargetId,\n\t\t\t},\n\n\t\t\t\"arn\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t},\n\n\t\t\t\"input\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tConflictsWith: []string{\"input_path\"},\n\t\t\t\t// We could be normalizing the JSON here,\n\t\t\t\t// but for built-in targets input may not be JSON\n\t\t\t},\n\n\t\t\t\"input_path\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tConflictsWith: []string{\"input\"},\n\t\t\t},\n\n\t\t\t\"role_arn\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t},\n\n\t\t\t\"run_command_targets\": {\n\t\t\t\tType: schema.TypeList,\n\t\t\t\tOptional: true,\n\t\t\t\tMaxItems: 5,\n\t\t\t\tElem: &schema.Resource{\n\t\t\t\t\tSchema: map[string]*schema.Schema{\n\t\t\t\t\t\t\"key\": {\n\t\t\t\t\t\t\tType: schema.TypeString,\n\t\t\t\t\t\t\tRequired: true,\n\t\t\t\t\t\t\tValidateFunc: validation.StringLenBetween(1, 128),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"values\": {\n\t\t\t\t\t\t\tType: schema.TypeList,\n\t\t\t\t\t\t\tRequired: true,\n\t\t\t\t\t\t\tElem: &schema.Schema{Type: schema.TypeString},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t\"ecs_target\": {\n\t\t\t\tType: schema.TypeList,\n\t\t\t\tOptional: true,\n\t\t\t\tMaxItems: 1,\n\t\t\t\tElem: &schema.Resource{\n\t\t\t\t\tSchema: map[string]*schema.Schema{\n\t\t\t\t\t\t\"task_count\": {\n\t\t\t\t\t\t\tType: schema.TypeInt,\n\t\t\t\t\t\t\tOptional: true,\n\t\t\t\t\t\t\tValidateFunc: validation.IntBetween(1, math.MaxInt32),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"task_definition_arn\": {\n\t\t\t\t\t\t\tType: schema.TypeString,\n\t\t\t\t\t\t\tRequired: true,\n\t\t\t\t\t\t\tValidateFunc: validation.StringLenBetween(1, 1600),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t\"input_transformer\": {\n\t\t\t\tType: schema.TypeList,\n\t\t\t\tOptional: true,\n\t\t\t\tMaxItems: 1,\n\t\t\t\tElem: &schema.Resource{\n\t\t\t\t\tSchema: map[string]*schema.Schema{\n\t\t\t\t\t\t\"input_paths\": {\n\t\t\t\t\t\t\tType: schema.TypeMap,\n\t\t\t\t\t\t\tOptional: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"input_template\": {\n\t\t\t\t\t\t\tType: schema.TypeString,\n\t\t\t\t\t\t\tRequired: true,\n\t\t\t\t\t\t\tValidateFunc: validation.StringLenBetween(1, 8192),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}\n\nfunc resourceAwsCloudWatchEventTargetCreate(d *schema.ResourceData, meta interface{}) error {\n\tconn := meta.(*AWSClient).cloudwatcheventsconn\n\n\trule := d.Get(\"rule\").(string)\n\n\tvar targetId string\n\tif v, ok := d.GetOk(\"target_id\"); ok {\n\t\ttargetId = v.(string)\n\t} else {\n\t\ttargetId = resource.UniqueId()\n\t\td.Set(\"target_id\", targetId)\n\t}\n\n\tinput := buildPutTargetInputStruct(d)\n\n\tlog.Printf(\"[DEBUG] Creating CloudWatch Event Target: %s\", input)\n\tout, err := conn.PutTargets(input)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Creating CloudWatch Event Target failed: %s\", err)\n\t}\n\n\tif len(out.FailedEntries) > 0 {\n\t\treturn fmt.Errorf(\"Creating CloudWatch Event Target failed: %s\",\n\t\t\tout.FailedEntries)\n\t}\n\n\tid := rule + \"-\" + targetId\n\td.SetId(id)\n\n\tlog.Printf(\"[INFO] CloudWatch Event Target %q created\", d.Id())\n\n\treturn resourceAwsCloudWatchEventTargetRead(d, meta)\n}\n\nfunc resourceAwsCloudWatchEventTargetRead(d *schema.ResourceData, meta interface{}) error {\n\tconn := meta.(*AWSClient).cloudwatcheventsconn\n\n\tt, err := findEventTargetById(\n\t\td.Get(\"target_id\").(string),\n\t\td.Get(\"rule\").(string),\n\t\tnil, conn)\n\tif err != nil {\n\t\tif regexp.MustCompile(\" not found$\").MatchString(err.Error()) {\n\t\t\tlog.Printf(\"[WARN] Removing CloudWatch Event Target %q because it's gone.\", d.Id())\n\t\t\td.SetId(\"\")\n\t\t\treturn nil\n\t\t}\n\t\tif awsErr, ok := err.(awserr.Error); ok {\n\t\t\t// This should never happen, but it's useful\n\t\t\t// for recovering from https://github.com/hashicorp/terraform/issues/5389\n\t\t\tif awsErr.Code() == \"ValidationException\" {\n\t\t\t\tlog.Printf(\"[WARN] Removing CloudWatch Event Target %q because it never existed.\", d.Id())\n\t\t\t\td.SetId(\"\")\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif awsErr.Code() == \"ResourceNotFoundException\" {\n\t\t\t\tlog.Printf(\"[WARN] CloudWatch Event Target (%q) not found. Removing it from state.\", d.Id())\n\t\t\t\td.SetId(\"\")\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t}\n\t\treturn err\n\t}\n\tlog.Printf(\"[DEBUG] Found Event Target: %s\", t)\n\n\td.Set(\"arn\", t.Arn)\n\td.Set(\"target_id\", t.Id)\n\td.Set(\"input\", t.Input)\n\td.Set(\"input_path\", t.InputPath)\n\td.Set(\"role_arn\", t.RoleArn)\n\n\tif t.RunCommandParameters != nil {\n\t\tif err := d.Set(\"run_command_targets\", flattenAwsCloudWatchEventTargetRunParameters(t.RunCommandParameters)); err != nil {\n\t\t\treturn fmt.Errorf(\"[DEBUG] Error setting run_command_targets error: %#v\", err)\n\t\t}\n\t}\n\n\tif t.EcsParameters != nil {\n\t\tif err := d.Set(\"ecs_target\", flattenAwsCloudWatchEventTargetEcsParameters(t.EcsParameters)); err != nil {\n\t\t\treturn fmt.Errorf(\"[DEBUG] Error setting ecs_target error: %#v\", err)\n\t\t}\n\t}\n\n\tif t.InputTransformer != nil {\n\t\tif err := d.Set(\"input_transformer\", flattenAwsCloudWatchInputTransformer(t.InputTransformer)); err != nil {\n\t\t\treturn fmt.Errorf(\"[DEBUG] Error setting input_transformer error: %#v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc findEventTargetById(id, rule string, nextToken *string, conn *events.CloudWatchEvents) (*events.Target, error) {\n\tinput := events.ListTargetsByRuleInput{\n\t\tRule: aws.String(rule),\n\t\tNextToken: nextToken,\n\t\tLimit: aws.Int64(100), // Set limit to allowed maximum to prevent API throttling\n\t}\n\tlog.Printf(\"[DEBUG] Reading CloudWatch Event Target: %s\", input)\n\tout, err := conn.ListTargetsByRule(&input)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, t := range out.Targets {\n\t\tif *t.Id == id {\n\t\t\treturn t, nil\n\t\t}\n\t}\n\n\tif out.NextToken != nil {\n\t\treturn findEventTargetById(id, rule, nextToken, conn)\n\t}\n\n\treturn nil, fmt.Errorf(\"CloudWatch Event Target %q (%q) not found\", id, rule)\n}\n\nfunc resourceAwsCloudWatchEventTargetUpdate(d *schema.ResourceData, meta interface{}) error {\n\tconn := meta.(*AWSClient).cloudwatcheventsconn\n\n\tinput := buildPutTargetInputStruct(d)\n\n\tlog.Printf(\"[DEBUG] Updating CloudWatch Event Target: %s\", input)\n\t_, err := conn.PutTargets(input)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Updating CloudWatch Event Target failed: %s\", err)\n\t}\n\n\treturn resourceAwsCloudWatchEventTargetRead(d, meta)\n}\n\nfunc resourceAwsCloudWatchEventTargetDelete(d *schema.ResourceData, meta interface{}) error {\n\tconn := meta.(*AWSClient).cloudwatcheventsconn\n\n\tinput := events.RemoveTargetsInput{\n\t\tIds: []*string{aws.String(d.Get(\"target_id\").(string))},\n\t\tRule: aws.String(d.Get(\"rule\").(string)),\n\t}\n\tlog.Printf(\"[INFO] Deleting CloudWatch Event Target: %s\", input)\n\t_, err := conn.RemoveTargets(&input)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error deleting CloudWatch Event Target: %s\", err)\n\t}\n\tlog.Println(\"[INFO] CloudWatch Event Target deleted\")\n\n\td.SetId(\"\")\n\n\treturn nil\n}\n\nfunc buildPutTargetInputStruct(d *schema.ResourceData) *events.PutTargetsInput {\n\te := &events.Target{\n\t\tArn: aws.String(d.Get(\"arn\").(string)),\n\t\tId: aws.String(d.Get(\"target_id\").(string)),\n\t}\n\n\tif v, ok := d.GetOk(\"input\"); ok {\n\t\te.Input = aws.String(v.(string))\n\t}\n\tif v, ok := d.GetOk(\"input_path\"); ok {\n\t\te.InputPath = aws.String(v.(string))\n\t}\n\n\tif v, ok := d.GetOk(\"role_arn\"); ok {\n\t\te.RoleArn = aws.String(v.(string))\n\t}\n\n\tif v, ok := d.GetOk(\"run_command_targets\"); ok {\n\t\te.RunCommandParameters = expandAwsCloudWatchEventTargetRunParameters(v.([]interface{}))\n\t}\n\tif v, ok := d.GetOk(\"ecs_target\"); ok {\n\t\te.EcsParameters = expandAwsCloudWatchEventTargetEcsParameters(v.([]interface{}))\n\t}\n\n\tif v, ok := d.GetOk(\"input_transformer\"); ok {\n\t\te.InputTransformer = expandAwsCloudWatchEventTransformerParameters(v.([]interface{}))\n\t}\n\n\tinput := events.PutTargetsInput{\n\t\tRule: aws.String(d.Get(\"rule\").(string)),\n\t\tTargets: []*events.Target{e},\n\t}\n\n\treturn &input\n}\n\nfunc expandAwsCloudWatchEventTargetRunParameters(config []interface{}) *events.RunCommandParameters {\n\n\tcommands := make([]*events.RunCommandTarget, 0)\n\n\tfor _, c := range config {\n\t\tparam := c.(map[string]interface{})\n\t\tcommand := &events.RunCommandTarget{\n\t\t\tKey: aws.String(param[\"key\"].(string)),\n\t\t\tValues: expandStringList(param[\"values\"].([]interface{})),\n\t\t}\n\n\t\tcommands = append(commands, command)\n\t}\n\n\tcommand := &events.RunCommandParameters{\n\t\tRunCommandTargets: commands,\n\t}\n\n\treturn command\n}\n\nfunc expandAwsCloudWatchEventTargetEcsParameters(config []interface{}) *events.EcsParameters {\n\tecsParameters := &events.EcsParameters{}\n\tfor _, c := range config {\n\t\tparam := c.(map[string]interface{})\n\t\tecsParameters.TaskCount = aws.Int64(int64(param[\"task_count\"].(int)))\n\t\tecsParameters.TaskDefinitionArn = aws.String(param[\"task_definition_arn\"].(string))\n\t}\n\n\treturn ecsParameters\n}\n\nfunc expandAwsCloudWatchEventTransformerParameters(config []interface{}) *events.InputTransformer {\n\ttransformerParameters := &events.InputTransformer{}\n\n\tinputPathsMaps := map[string]*string{}\n\n\tfor _, c := range config {\n\t\tparam := c.(map[string]interface{})\n\t\tinputPaths := param[\"input_paths\"].(map[string]interface{})\n\n\t\tfor k, v := range inputPaths {\n\t\t\tinputPathsMaps[k] = aws.String(v.(string))\n\t\t}\n\t\ttransformerParameters.InputTemplate = aws.String(param[\"input_template\"].(string))\n\t}\n\ttransformerParameters.InputPathsMap = inputPathsMaps\n\n\treturn transformerParameters\n}\n\nfunc flattenAwsCloudWatchEventTargetRunParameters(runCommand *events.RunCommandParameters) []map[string]interface{} {\n\tresult := make([]map[string]interface{}, 0)\n\n\tfor _, x := range runCommand.RunCommandTargets {\n\t\tconfig := make(map[string]interface{})\n\n\t\tconfig[\"key\"] = *x.Key\n\t\tconfig[\"values\"] = flattenStringList(x.Values)\n\n\t\tresult = append(result, config)\n\t}\n\n\treturn result\n}\nfunc flattenAwsCloudWatchEventTargetEcsParameters(ecsParameters *events.EcsParameters) []map[string]interface{} {\n\tconfig := make(map[string]interface{})\n\tconfig[\"task_count\"] = *ecsParameters.TaskCount\n\tconfig[\"task_definition_arn\"] = *ecsParameters.TaskDefinitionArn\n\tresult := []map[string]interface{}{config}\n\treturn result\n}\n\nfunc flattenAwsCloudWatchInputTransformer(inputTransformer *events.InputTransformer) []map[string]interface{} {\n\tconfig := make(map[string]interface{})\n\tinputPathsMap := make(map[string]string)\n\tfor k, v := range inputTransformer.InputPathsMap {\n\t\tinputPathsMap[k] = *v\n\t}\n\tconfig[\"input_template\"] = *inputTransformer.InputTemplate\n\tconfig[\"input_paths\"] = inputPathsMap\n\n\tresult := []map[string]interface{}{config}\n\treturn result\n}\n"},"repo_name":{"kind":"string","value":"hartzell/terraform"},"path":{"kind":"string","value":"vendor/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_cloudwatch_event_target.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"mpl-2.0"},"size":{"kind":"number","value":11014,"string":"11,014"}}},{"rowIdx":61538410,"cells":{"code":{"kind":"string","value":"from edxmako.shortcuts import render_to_string\n\nfrom pipeline.conf import settings\nfrom pipeline.packager import Packager\nfrom pipeline.utils import guess_type\nfrom static_replace import try_staticfiles_lookup\n\n\ndef compressed_css(package_name):\n package = settings.PIPELINE_CSS.get(package_name, {})\n if package:\n package = {package_name: package}\n packager = Packager(css_packages=package, js_packages={})\n\n package = packager.package_for('css', package_name)\n\n if settings.PIPELINE:\n return render_css(package, package.output_filename)\n else:\n paths = packager.compile(package.paths)\n return render_individual_css(package, paths)\n\n\ndef render_css(package, path):\n template_name = package.template_name or \"mako/css.html\"\n context = package.extra_context\n\n url = try_staticfiles_lookup(path)\n context.update({\n 'type': guess_type(path, 'text/css'),\n 'url': url,\n })\n return render_to_string(template_name, context)\n\n\ndef render_individual_css(package, paths):\n tags = [render_css(package, path) for path in paths]\n return '\\n'.join(tags)\n\n\ndef compressed_js(package_name):\n package = settings.PIPELINE_JS.get(package_name, {})\n if package:\n package = {package_name: package}\n packager = Packager(css_packages={}, js_packages=package)\n\n package = packager.package_for('js', package_name)\n\n if settings.PIPELINE:\n return render_js(package, package.output_filename)\n else:\n paths = packager.compile(package.paths)\n templates = packager.pack_templates(package)\n return render_individual_js(package, paths, templates)\n\n\ndef render_js(package, path):\n template_name = package.template_name or \"mako/js.html\"\n context = package.extra_context\n context.update({\n 'type': guess_type(path, 'text/javascript'),\n 'url': try_staticfiles_lookup(path)\n })\n return render_to_string(template_name, context)\n\n\ndef render_inline_js(package, js):\n context = package.extra_context\n context.update({\n 'source': js\n })\n return render_to_string(\"mako/inline_js.html\", context)\n\n\ndef render_individual_js(package, paths, templates=None):\n tags = [render_js(package, js) for js in paths]\n if templates:\n tags.append(render_inline_js(package, templates))\n return '\\n'.join(tags)\n"},"repo_name":{"kind":"string","value":"liuqr/edx-xiaodun"},"path":{"kind":"string","value":"common/djangoapps/pipeline_mako/__init__.py"},"language":{"kind":"string","value":"Python"},"license":{"kind":"string","value":"agpl-3.0"},"size":{"kind":"number","value":2354,"string":"2,354"}}},{"rowIdx":61538411,"cells":{"code":{"kind":"string","value":"/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.apache.nifi.hbase;\n\n/**\n * Encapsulates the information for a delete operation.\n */\npublic class DeleteRequest {\n private byte[] rowId;\n private byte[] columnFamily;\n private byte[] columnQualifier;\n private String visibilityLabel;\n\n public DeleteRequest(byte[] rowId, byte[] columnFamily, byte[] columnQualifier, String visibilityLabel) {\n this.rowId = rowId;\n this.columnFamily = columnFamily;\n this.columnQualifier = columnQualifier;\n this.visibilityLabel = visibilityLabel;\n }\n\n public byte[] getRowId() {\n return rowId;\n }\n\n public byte[] getColumnFamily() {\n return columnFamily;\n }\n\n public byte[] getColumnQualifier() {\n return columnQualifier;\n }\n\n public String getVisibilityLabel() {\n return visibilityLabel;\n }\n\n @Override\n public String toString() {\n return new StringBuilder()\n .append(String.format(\"Row ID: %s\\n\", new String(rowId)))\n .append(String.format(\"Column Family: %s\\n\", new String(columnFamily)))\n .append(String.format(\"Column Qualifier: %s\\n\", new String(columnQualifier)))\n .append(visibilityLabel != null ? String.format(\"Visibility Label: %s\", visibilityLabel) : \"\")\n .toString();\n }\n}\n"},"repo_name":{"kind":"string","value":"ijokarumawak/nifi"},"path":{"kind":"string","value":"nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/DeleteRequest.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":2100,"string":"2,100"}}},{"rowIdx":61538412,"cells":{"code":{"kind":"string","value":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n// See the LICENSE file in the project root for more information.\n\n#nullable disable\n\nusing System;\nusing System.Diagnostics;\nusing Roslyn.Utilities;\n\nnamespace Microsoft.CodeAnalysis.Differencing\n{\n /// \n /// Represents an edit operation on a sequence of values.\n /// \n [DebuggerDisplay(\"{GetDebuggerDisplay(), nq}\")]\n internal struct SequenceEdit : IEquatable\n {\n private readonly int _oldIndex;\n private readonly int _newIndex;\n\n internal SequenceEdit(int oldIndex, int newIndex)\n {\n Debug.Assert(oldIndex >= -1);\n Debug.Assert(newIndex >= -1);\n Debug.Assert(newIndex != -1 || oldIndex != -1);\n\n _oldIndex = oldIndex;\n _newIndex = newIndex;\n }\n\n /// \n /// The kind of edit: , , or .\n /// \n public EditKind Kind\n {\n get\n {\n if (_oldIndex == -1)\n {\n return EditKind.Insert;\n }\n\n if (_newIndex == -1)\n {\n return EditKind.Delete;\n }\n\n return EditKind.Update;\n }\n }\n\n /// \n /// Index in the old sequence, or -1 if the edit is insert.\n /// \n public int OldIndex => _oldIndex;\n\n /// \n /// Index in the new sequence, or -1 if the edit is delete.\n /// \n public int NewIndex => _newIndex;\n\n public bool Equals(SequenceEdit other)\n {\n return _oldIndex == other._oldIndex\n && _newIndex == other._newIndex;\n }\n\n public override bool Equals(object obj)\n => obj is SequenceEdit && Equals((SequenceEdit)obj);\n\n public override int GetHashCode()\n => Hash.Combine(_oldIndex, _newIndex);\n\n private string GetDebuggerDisplay()\n {\n var result = Kind.ToString();\n switch (Kind)\n {\n case EditKind.Delete:\n return result + \" (\" + _oldIndex + \")\";\n\n case EditKind.Insert:\n return result + \" (\" + _newIndex + \")\";\n\n case EditKind.Update:\n return result + \" (\" + _oldIndex + \" -> \" + _newIndex + \")\";\n }\n\n return result;\n }\n\n internal TestAccessor GetTestAccessor()\n => new(this);\n\n internal readonly struct TestAccessor\n {\n private readonly SequenceEdit _sequenceEdit;\n\n public TestAccessor(SequenceEdit sequenceEdit)\n => _sequenceEdit = sequenceEdit;\n\n internal string GetDebuggerDisplay()\n => _sequenceEdit.GetDebuggerDisplay();\n }\n }\n}\n"},"repo_name":{"kind":"string","value":"physhi/roslyn"},"path":{"kind":"string","value":"src/Workspaces/Core/Portable/Differencing/SequenceEdit.cs"},"language":{"kind":"string","value":"C#"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":3081,"string":"3,081"}}},{"rowIdx":61538413,"cells":{"code":{"kind":"string","value":"// Copyright 2015 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage icmp\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"golang.org/x/net/internal/iana\"\n\t\"golang.org/x/net/ipv4\"\n\t\"golang.org/x/net/ipv6\"\n)\n\nfunc TestMarshalAndParseExtension(t *testing.T) {\n\tfn := func(t *testing.T, proto int, typ Type, hdr, obj []byte, te Extension) error {\n\t\tb, err := te.Marshal(proto)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !reflect.DeepEqual(b, obj) {\n\t\t\treturn fmt.Errorf(\"got %#v; want %#v\", b, obj)\n\t\t}\n\t\tswitch typ {\n\t\tcase ipv4.ICMPTypeExtendedEchoRequest, ipv6.ICMPTypeExtendedEchoRequest:\n\t\t\texts, l, err := parseExtensions(typ, append(hdr, obj...), 0)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif l != 0 {\n\t\t\t\treturn fmt.Errorf(\"got %d; want 0\", l)\n\t\t\t}\n\t\t\tif !reflect.DeepEqual(exts, []Extension{te}) {\n\t\t\t\treturn fmt.Errorf(\"got %#v; want %#v\", exts[0], te)\n\t\t\t}\n\t\tdefault:\n\t\t\tfor i, wire := range []struct {\n\t\t\t\tdata []byte // original datagram\n\t\t\t\tinlattr int // length of padded original datagram, a hint\n\t\t\t\toutlattr int // length of padded original datagram, a want\n\t\t\t\terr error\n\t\t\t}{\n\t\t\t\t{nil, 0, -1, errNoExtension},\n\t\t\t\t{make([]byte, 127), 128, -1, errNoExtension},\n\n\t\t\t\t{make([]byte, 128), 127, -1, errNoExtension},\n\t\t\t\t{make([]byte, 128), 128, -1, errNoExtension},\n\t\t\t\t{make([]byte, 128), 129, -1, errNoExtension},\n\n\t\t\t\t{append(make([]byte, 128), append(hdr, obj...)...), 127, 128, nil},\n\t\t\t\t{append(make([]byte, 128), append(hdr, obj...)...), 128, 128, nil},\n\t\t\t\t{append(make([]byte, 128), append(hdr, obj...)...), 129, 128, nil},\n\n\t\t\t\t{append(make([]byte, 512), append(hdr, obj...)...), 511, -1, errNoExtension},\n\t\t\t\t{append(make([]byte, 512), append(hdr, obj...)...), 512, 512, nil},\n\t\t\t\t{append(make([]byte, 512), append(hdr, obj...)...), 513, -1, errNoExtension},\n\t\t\t} {\n\t\t\t\texts, l, err := parseExtensions(typ, wire.data, wire.inlattr)\n\t\t\t\tif err != wire.err {\n\t\t\t\t\treturn fmt.Errorf(\"#%d: got %v; want %v\", i, err, wire.err)\n\t\t\t\t}\n\t\t\t\tif wire.err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif l != wire.outlattr {\n\t\t\t\t\treturn fmt.Errorf(\"#%d: got %d; want %d\", i, l, wire.outlattr)\n\t\t\t\t}\n\t\t\t\tif !reflect.DeepEqual(exts, []Extension{te}) {\n\t\t\t\t\treturn fmt.Errorf(\"#%d: got %#v; want %#v\", i, exts[0], te)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\tt.Run(\"MPLSLabelStack\", func(t *testing.T) {\n\t\tfor _, et := range []struct {\n\t\t\tproto int\n\t\t\ttyp Type\n\t\t\thdr []byte\n\t\t\tobj []byte\n\t\t\text Extension\n\t\t}{\n\t\t\t// MPLS label stack with no label\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x04, 0x01, 0x01,\n\t\t\t\t},\n\t\t\t\text: &MPLSLabelStack{\n\t\t\t\t\tClass: classMPLSLabelStack,\n\t\t\t\t\tType: typeIncomingMPLSLabelStack,\n\t\t\t\t},\n\t\t\t},\n\t\t\t// MPLS label stack with a single label\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolIPv6ICMP,\n\t\t\t\ttyp: ipv6.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x08, 0x01, 0x01,\n\t\t\t\t\t0x03, 0xe8, 0xe9, 0xff,\n\t\t\t\t},\n\t\t\t\text: &MPLSLabelStack{\n\t\t\t\t\tClass: classMPLSLabelStack,\n\t\t\t\t\tType: typeIncomingMPLSLabelStack,\n\t\t\t\t\tLabels: []MPLSLabel{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLabel: 16014,\n\t\t\t\t\t\t\tTC: 0x4,\n\t\t\t\t\t\t\tS: true,\n\t\t\t\t\t\t\tTTL: 255,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t// MPLS label stack with multiple labels\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x0c, 0x01, 0x01,\n\t\t\t\t\t0x03, 0xe8, 0xde, 0xfe,\n\t\t\t\t\t0x03, 0xe8, 0xe1, 0xff,\n\t\t\t\t},\n\t\t\t\text: &MPLSLabelStack{\n\t\t\t\t\tClass: classMPLSLabelStack,\n\t\t\t\t\tType: typeIncomingMPLSLabelStack,\n\t\t\t\t\tLabels: []MPLSLabel{\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLabel: 16013,\n\t\t\t\t\t\t\tTC: 0x7,\n\t\t\t\t\t\t\tS: false,\n\t\t\t\t\t\t\tTTL: 254,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLabel: 16014,\n\t\t\t\t\t\t\tTC: 0,\n\t\t\t\t\t\t\tS: true,\n\t\t\t\t\t\t\tTTL: 255,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t} {\n\t\t\tif err := fn(t, et.proto, et.typ, et.hdr, et.obj, et.ext); err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t}\n\t})\n\tt.Run(\"InterfaceInfo\", func(t *testing.T) {\n\t\tfor _, et := range []struct {\n\t\t\tproto int\n\t\t\ttyp Type\n\t\t\thdr []byte\n\t\t\tobj []byte\n\t\t\text Extension\n\t\t}{\n\t\t\t// Interface information with no attribute\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x04, 0x02, 0x00,\n\t\t\t\t},\n\t\t\t\text: &InterfaceInfo{\n\t\t\t\t\tClass: classInterfaceInfo,\n\t\t\t\t},\n\t\t\t},\n\t\t\t// Interface information with ifIndex and name\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x10, 0x02, 0x0a,\n\t\t\t\t\t0x00, 0x00, 0x00, 0x10,\n\t\t\t\t\t0x08, byte('e'), byte('n'), byte('1'),\n\t\t\t\t\tbyte('0'), byte('1'), 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\text: &InterfaceInfo{\n\t\t\t\t\tClass: classInterfaceInfo,\n\t\t\t\t\tType: 0x0a,\n\t\t\t\t\tInterface: &net.Interface{\n\t\t\t\t\t\tIndex: 16,\n\t\t\t\t\t\tName: \"en101\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t// Interface information with ifIndex, IPAddr, name and MTU\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolIPv6ICMP,\n\t\t\t\ttyp: ipv6.ICMPTypeDestinationUnreachable,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x28, 0x02, 0x0f,\n\t\t\t\t\t0x00, 0x00, 0x00, 0x0f,\n\t\t\t\t\t0x00, 0x02, 0x00, 0x00,\n\t\t\t\t\t0xfe, 0x80, 0x00, 0x00,\n\t\t\t\t\t0x00, 0x00, 0x00, 0x00,\n\t\t\t\t\t0x00, 0x00, 0x00, 0x00,\n\t\t\t\t\t0x00, 0x00, 0x00, 0x01,\n\t\t\t\t\t0x08, byte('e'), byte('n'), byte('1'),\n\t\t\t\t\tbyte('0'), byte('1'), 0x00, 0x00,\n\t\t\t\t\t0x00, 0x00, 0x20, 0x00,\n\t\t\t\t},\n\t\t\t\text: &InterfaceInfo{\n\t\t\t\t\tClass: classInterfaceInfo,\n\t\t\t\t\tType: 0x0f,\n\t\t\t\t\tInterface: &net.Interface{\n\t\t\t\t\t\tIndex: 15,\n\t\t\t\t\t\tName: \"en101\",\n\t\t\t\t\t\tMTU: 8192,\n\t\t\t\t\t},\n\t\t\t\t\tAddr: &net.IPAddr{\n\t\t\t\t\t\tIP: net.ParseIP(\"fe80::1\"),\n\t\t\t\t\t\tZone: \"en101\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t} {\n\t\t\tif err := fn(t, et.proto, et.typ, et.hdr, et.obj, et.ext); err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t}\n\t})\n\tt.Run(\"InterfaceIdent\", func(t *testing.T) {\n\t\tfor _, et := range []struct {\n\t\t\tproto int\n\t\t\ttyp Type\n\t\t\thdr []byte\n\t\t\tobj []byte\n\t\t\text Extension\n\t\t}{\n\t\t\t// Interface identification by name\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeExtendedEchoRequest,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x0c, 0x03, 0x01,\n\t\t\t\t\tbyte('e'), byte('n'), byte('1'), byte('0'),\n\t\t\t\t\tbyte('1'), 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\text: &InterfaceIdent{\n\t\t\t\t\tClass: classInterfaceIdent,\n\t\t\t\t\tType: typeInterfaceByName,\n\t\t\t\t\tName: \"en101\",\n\t\t\t\t},\n\t\t\t},\n\t\t\t// Interface identification by index\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolIPv6ICMP,\n\t\t\t\ttyp: ipv6.ICMPTypeExtendedEchoRequest,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x08, 0x03, 0x02,\n\t\t\t\t\t0x00, 0x00, 0x03, 0x8f,\n\t\t\t\t},\n\t\t\t\text: &InterfaceIdent{\n\t\t\t\t\tClass: classInterfaceIdent,\n\t\t\t\t\tType: typeInterfaceByIndex,\n\t\t\t\t\tIndex: 911,\n\t\t\t\t},\n\t\t\t},\n\t\t\t// Interface identification by address\n\t\t\t{\n\t\t\t\tproto: iana.ProtocolICMP,\n\t\t\t\ttyp: ipv4.ICMPTypeExtendedEchoRequest,\n\t\t\t\thdr: []byte{\n\t\t\t\t\t0x20, 0x00, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\tobj: []byte{\n\t\t\t\t\t0x00, 0x10, 0x03, 0x03,\n\t\t\t\t\tbyte(iana.AddrFamily48bitMAC >> 8), byte(iana.AddrFamily48bitMAC & 0x0f), 0x06, 0x00,\n\t\t\t\t\t0x01, 0x23, 0x45, 0x67,\n\t\t\t\t\t0x89, 0xab, 0x00, 0x00,\n\t\t\t\t},\n\t\t\t\text: &InterfaceIdent{\n\t\t\t\t\tClass: classInterfaceIdent,\n\t\t\t\t\tType: typeInterfaceByAddress,\n\t\t\t\t\tAFI: iana.AddrFamily48bitMAC,\n\t\t\t\t\tAddr: []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xab},\n\t\t\t\t},\n\t\t\t},\n\t\t} {\n\t\t\tif err := fn(t, et.proto, et.typ, et.hdr, et.obj, et.ext); err != nil {\n\t\t\t\tt.Error(err)\n\t\t\t}\n\t\t}\n\t})\n}\n\nfunc TestParseInterfaceName(t *testing.T) {\n\tifi := InterfaceInfo{Interface: &net.Interface{}}\n\tfor i, tt := range []struct {\n\t\tb []byte\n\t\terror\n\t}{\n\t\t{[]byte{0, 'e', 'n', '0'}, errInvalidExtension},\n\t\t{[]byte{4, 'e', 'n', '0'}, nil},\n\t\t{[]byte{7, 'e', 'n', '0', 0xff, 0xff, 0xff, 0xff}, errInvalidExtension},\n\t\t{[]byte{8, 'e', 'n', '0', 0xff, 0xff, 0xff}, errMessageTooShort},\n\t} {\n\t\tif _, err := ifi.parseName(tt.b); err != tt.error {\n\t\t\tt.Errorf(\"#%d: got %v; want %v\", i, err, tt.error)\n\t\t}\n\t}\n}\n"},"repo_name":{"kind":"string","value":"muzining/net"},"path":{"kind":"string","value":"x/net/icmp/extension_test.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":8186,"string":"8,186"}}},{"rowIdx":61538414,"cells":{"code":{"kind":"string","value":"//===----------------------------------------------------------------------===//\n//\n// The LLVM Compiler Infrastructure\n//\n// This file is dual licensed under the MIT and the University of Illinois Open\n// Source Licenses. See LICENSE.TXT for details.\n//\n//===----------------------------------------------------------------------===//\n\n// \n\n// quoted\n\n#include \n#include \n#include \n#include \n\n#if _LIBCPP_STD_VER > 11\n\nbool is_skipws ( const std::istream *is ) {\n return ( is->flags() & std::ios_base::skipws ) != 0;\n }\n\n\nbool is_skipws ( const std::wistream *is ) {\n return ( is->flags() & std::ios_base::skipws ) != 0;\n }\n\nvoid both_ways ( const char *p ) {\n std::string str(p);\n auto q = std::quoted(str);\n\n std::stringstream ss;\n bool skippingws = is_skipws ( &ss );\n ss << q;\n ss >> q;\n }\n\nvoid round_trip ( const char *p ) {\n std::stringstream ss;\n bool skippingws = is_skipws ( &ss );\n ss << std::quoted(p);\n std::string s;\n ss >> std::quoted(s);\n assert ( s == p );\n assert ( skippingws == is_skipws ( &ss ));\n }\n\nvoid round_trip_ws ( const char *p ) {\n std::stringstream ss;\n std::noskipws ( ss );\n bool skippingws = is_skipws ( &ss );\n ss << std::quoted(p);\n std::string s;\n ss >> std::quoted(s);\n assert ( s == p );\n assert ( skippingws == is_skipws ( &ss ));\n }\n\nvoid round_trip_d ( const char *p, char delim ) {\n std::stringstream ss;\n ss << std::quoted(p, delim);\n std::string s;\n ss >> std::quoted(s, delim);\n assert ( s == p );\n }\n\nvoid round_trip_e ( const char *p, char escape ) {\n std::stringstream ss;\n ss << std::quoted(p, '\"', escape );\n std::string s;\n ss >> std::quoted(s, '\"', escape );\n assert ( s == p );\n }\n\n\n\nstd::string quote ( const char *p, char delim='\"', char escape='\\\\' ) {\n std::stringstream ss;\n ss << std::quoted(p, delim, escape);\n std::string s;\n ss >> s; // no quote\n return s;\n}\n\nstd::string unquote ( const char *p, char delim='\"', char escape='\\\\' ) {\n std::stringstream ss;\n ss << p;\n std::string s;\n ss >> std::quoted(s, delim, escape);\n return s;\n}\n\nvoid test_padding () {\n {\n std::stringstream ss;\n ss << std::left << std::setw(10) << std::setfill('!') << std::quoted(\"abc\", '`');\n assert ( ss.str() == \"`abc`!!!!!\" );\n }\n \n {\n std::stringstream ss;\n ss << std::right << std::setw(10) << std::setfill('!') << std::quoted(\"abc\", '`');\n assert ( ss.str() == \"!!!!!`abc`\" );\n }\n}\n\n\nvoid round_trip ( const wchar_t *p ) {\n std::wstringstream ss;\n bool skippingws = is_skipws ( &ss );\n ss << std::quoted(p);\n std::wstring s;\n ss >> std::quoted(s);\n assert ( s == p );\n assert ( skippingws == is_skipws ( &ss ));\n }\n \n\nvoid round_trip_ws ( const wchar_t *p ) {\n std::wstringstream ss;\n std::noskipws ( ss );\n bool skippingws = is_skipws ( &ss );\n ss << std::quoted(p);\n std::wstring s;\n ss >> std::quoted(s);\n assert ( s == p );\n assert ( skippingws == is_skipws ( &ss ));\n }\n\nvoid round_trip_d ( const wchar_t *p, wchar_t delim ) {\n std::wstringstream ss;\n ss << std::quoted(p, delim);\n std::wstring s;\n ss >> std::quoted(s, delim);\n assert ( s == p );\n }\n\nvoid round_trip_e ( const wchar_t *p, wchar_t escape ) {\n std::wstringstream ss;\n ss << std::quoted(p, wchar_t('\"'), escape );\n std::wstring s;\n ss >> std::quoted(s, wchar_t('\"'), escape );\n assert ( s == p );\n }\n\n\nstd::wstring quote ( const wchar_t *p, wchar_t delim='\"', wchar_t escape='\\\\' ) {\n std::wstringstream ss;\n ss << std::quoted(p, delim, escape);\n std::wstring s;\n ss >> s; // no quote\n return s;\n}\n\nstd::wstring unquote ( const wchar_t *p, wchar_t delim='\"', wchar_t escape='\\\\' ) {\n std::wstringstream ss;\n ss << p;\n std::wstring s;\n ss >> std::quoted(s, delim, escape);\n return s;\n}\n\nint main()\n{\n both_ways ( \"\" ); // This is a compilation check\n\n round_trip ( \"\" );\n round_trip_ws ( \"\" );\n round_trip_d ( \"\", 'q' );\n round_trip_e ( \"\", 'q' );\n \n round_trip ( L\"\" );\n round_trip_ws ( L\"\" );\n round_trip_d ( L\"\", 'q' );\n round_trip_e ( L\"\", 'q' );\n \n round_trip ( \"Hi\" );\n round_trip_ws ( \"Hi\" );\n round_trip_d ( \"Hi\", '!' );\n round_trip_e ( \"Hi\", '!' );\n assert ( quote ( \"Hi\", '!' ) == \"!Hi!\" );\n assert ( quote ( \"Hi!\", '!' ) == R\"(!Hi\\!!)\" );\n \n round_trip ( L\"Hi\" );\n round_trip_ws ( L\"Hi\" );\n round_trip_d ( L\"Hi\", '!' );\n round_trip_e ( L\"Hi\", '!' );\n assert ( quote ( L\"Hi\", '!' ) == L\"!Hi!\" );\n assert ( quote ( L\"Hi!\", '!' ) == LR\"(!Hi\\!!)\" );\n \n round_trip ( \"Hi Mom\" );\n round_trip_ws ( \"Hi Mom\" );\n round_trip ( L\"Hi Mom\" );\n round_trip_ws ( L\"Hi Mom\" );\n \n assert ( quote ( \"\" ) == \"\\\"\\\"\" );\n assert ( quote ( L\"\" ) == L\"\\\"\\\"\" );\n assert ( quote ( \"a\" ) == \"\\\"a\\\"\" );\n assert ( quote ( L\"a\" ) == L\"\\\"a\\\"\" );\n\n// missing end quote - must not hang\n assert ( unquote ( \"\\\"abc\" ) == \"abc\" );\n assert ( unquote ( L\"\\\"abc\" ) == L\"abc\" );\n \n assert ( unquote ( \"abc\" ) == \"abc\" ); // no delimiter\n assert ( unquote ( L\"abc\" ) == L\"abc\" ); // no delimiter\n assert ( unquote ( \"abc def\" ) == \"abc\" ); // no delimiter\n assert ( unquote ( L\"abc def\" ) == L\"abc\" ); // no delimiter\n\n assert ( unquote ( \"\" ) == \"\" ); // nothing there\n assert ( unquote ( L\"\" ) == L\"\" ); // nothing there\n test_padding ();\n }\n\n#else\nint main() {}\n#endif\n"},"repo_name":{"kind":"string","value":"mxOBS/deb-pkg_trusty_chromium-browser"},"path":{"kind":"string","value":"third_party/libc++/trunk/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":5616,"string":"5,616"}}},{"rowIdx":61538415,"cells":{"code":{"kind":"string","value":"/*\n * Planck.js v0.1.34\n * \n * Copyright (c) 2016-2017 Ali Shakiba http://shakiba.me/planck.js\n * Copyright (c) 2006-2013 Erin Catto http://www.gphysics.com\n * \n * This software is provided 'as-is', without any express or implied\n * warranty. In no event will the authors be held liable for any damages\n * arising from the use of this software.\n * \n * Permission is granted to anyone to use this software for any purpose,\n * including commercial applications, and to alter it and redistribute it\n * freely, subject to the following restrictions:\n * \n * 1. The origin of this software must not be misrepresented; you must not\n * claim that you wrote the original software. If you use this software\n * in a product, an acknowledgment in the product documentation would be\n * appreciated but is not required.\n * 2. Altered source versions must be plainly marked as such, and must not be\n * misrepresented as being the original software.\n * 3. This notice may not be removed or altered from any source distribution.\n */\n/*\n * Stage.js \n * \n * @copyright 2017 Ali Shakiba http://shakiba.me/stage.js\n * @license The MIT License\n */\n!function(e){if(\"object\"==typeof exports&&\"undefined\"!=typeof module)module.exports=e();else if(\"function\"==typeof define&&define.amd)define([],e);else{var f;\"undefined\"!=typeof window?f=window:\"undefined\"!=typeof global?f=global:\"undefined\"!=typeof self&&(f=self),f.planck=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o timeStep) {\n world.step(timeStep);\n elapsedTime -= timeStep;\n }\n this.renderWorld();\n return true;\n }, true);\n world.on(\"remove-fixture\", function(obj) {\n obj.ui && obj.ui.remove();\n });\n world.on(\"remove-joint\", function(obj) {\n obj.ui && obj.ui.remove();\n });\n}\n\nViewer.prototype.renderWorld = function(world) {\n var world = this._world;\n var viewer = this;\n for (var b = world.getBodyList(); b; b = b.getNext()) {\n for (var f = b.getFixtureList(); f; f = f.getNext()) {\n if (!f.ui) {\n if (f.render && f.render.stroke) {\n this._options.strokeStyle = f.render.stroke;\n } else if (b.render && b.render.stroke) {\n this._options.strokeStyle = b.render.stroke;\n } else if (b.isDynamic()) {\n this._options.strokeStyle = \"rgba(255,255,255,0.9)\";\n } else if (b.isKinematic()) {\n this._options.strokeStyle = \"rgba(255,255,255,0.7)\";\n } else if (b.isStatic()) {\n this._options.strokeStyle = \"rgba(255,255,255,0.5)\";\n }\n if (f.render && f.render.fill) {\n this._options.fillStyle = f.render.fill;\n } else if (b.render && b.render.fill) {\n this._options.fillStyle = b.render.fill;\n } else {\n this._options.fillStyle = \"\";\n }\n var type = f.getType();\n var shape = f.getShape();\n if (type == \"circle\") {\n f.ui = viewer.drawCircle(shape, this._options);\n }\n if (type == \"edge\") {\n f.ui = viewer.drawEdge(shape, this._options);\n }\n if (type == \"polygon\") {\n f.ui = viewer.drawPolygon(shape, this._options);\n }\n if (type == \"chain\") {\n f.ui = viewer.drawChain(shape, this._options);\n }\n if (f.ui) {\n f.ui.appendTo(viewer);\n }\n }\n if (f.ui) {\n var p = b.getPosition(), r = b.getAngle();\n if (f.ui.__lastX !== p.x || f.ui.__lastY !== p.y || f.ui.__lastR !== r) {\n f.ui.__lastX = p.x;\n f.ui.__lastY = p.y;\n f.ui.__lastR = r;\n f.ui.offset(p.x, p.y);\n f.ui.rotate(r);\n }\n }\n }\n }\n for (var j = world.getJointList(); j; j = j.getNext()) {\n var type = j.getType();\n var a = j.getAnchorA();\n var b = j.getAnchorB();\n if (!j.ui) {\n this._options.strokeStyle = \"rgba(255,255,255,0.2)\";\n j.ui = viewer.drawJoint(j, this._options);\n j.ui.pin(\"handle\", .5);\n if (j.ui) {\n j.ui.appendTo(viewer);\n }\n }\n if (j.ui) {\n var cx = (a.x + b.x) * .5;\n var cy = (a.y + b.y) * .5;\n var dx = a.x - b.x;\n var dy = a.y - b.y;\n var d = Math.sqrt(dx * dx + dy * dy);\n j.ui.width(d);\n j.ui.rotate(Math.atan2(dy, dx));\n j.ui.offset(cx, cy);\n }\n }\n};\n\nViewer.prototype.drawJoint = function(joint, options) {\n var lw = options.lineWidth;\n var ratio = options.ratio;\n var length = 10;\n var texture = Stage.canvas(function(ctx) {\n this.size(length + 2 * lw, 2 * lw, ratio);\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth;\n ctx.strokeStyle = options.strokeStyle;\n ctx.stroke();\n });\n var image = Stage.image(texture).stretch();\n return image;\n};\n\nViewer.prototype.drawCircle = function(shape, options) {\n var lw = options.lineWidth;\n var ratio = options.ratio;\n var r = shape.m_radius;\n var cx = r + lw;\n var cy = r + lw;\n var w = r * 2 + lw * 2;\n var h = r * 2 + lw * 2;\n var texture = Stage.canvas(function(ctx) {\n this.size(w, h, ratio);\n ctx.scale(ratio, ratio);\n ctx.arc(cx, cy, r, 0, 2 * Math.PI);\n if (options.fillStyle) {\n ctx.fillStyle = options.fillStyle;\n ctx.fill();\n }\n ctx.lineTo(cx, cy);\n ctx.lineWidth = options.lineWidth;\n ctx.strokeStyle = options.strokeStyle;\n ctx.stroke();\n });\n var image = Stage.image(texture).offset(shape.m_p.x - cx, shape.m_p.y - cy);\n var node = Stage.create().append(image);\n return node;\n};\n\nViewer.prototype.drawEdge = function(edge, options) {\n var lw = options.lineWidth;\n var ratio = options.ratio;\n var v1 = edge.m_vertex1;\n var v2 = edge.m_vertex2;\n var dx = v2.x - v1.x;\n var dy = v2.y - v1.y;\n var length = Math.sqrt(dx * dx + dy * dy);\n var texture = Stage.canvas(function(ctx) {\n this.size(length + 2 * lw, 2 * lw, ratio);\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n ctx.moveTo(lw, lw);\n ctx.lineTo(lw + length, lw);\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth;\n ctx.strokeStyle = options.strokeStyle;\n ctx.stroke();\n });\n var minX = Math.min(v1.x, v2.x);\n var minY = Math.min(v1.y, v2.y);\n var image = Stage.image(texture);\n image.rotate(Math.atan2(dy, dx));\n image.offset(minX - lw, minY - lw);\n var node = Stage.create().append(image);\n return node;\n};\n\nViewer.prototype.drawPolygon = function(shape, options) {\n var lw = options.lineWidth;\n var ratio = options.ratio;\n var vertices = shape.m_vertices;\n if (!vertices.length) {\n return;\n }\n var minX = Infinity, minY = Infinity;\n var maxX = -Infinity, maxY = -Infinity;\n for (var i = 0; i < vertices.length; ++i) {\n var v = vertices[i];\n minX = Math.min(minX, v.x);\n maxX = Math.max(maxX, v.x);\n minY = Math.min(minY, v.y);\n maxY = Math.max(maxY, v.y);\n }\n var width = maxX - minX;\n var height = maxY - minY;\n var texture = Stage.canvas(function(ctx) {\n this.size(width + 2 * lw, height + 2 * lw, ratio);\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (var i = 0; i < vertices.length; ++i) {\n var v = vertices[i];\n var x = v.x - minX + lw;\n var y = v.y - minY + lw;\n if (i == 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);\n }\n if (vertices.length > 2) {\n ctx.closePath();\n }\n if (options.fillStyle) {\n ctx.fillStyle = options.fillStyle;\n ctx.fill();\n ctx.closePath();\n }\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth;\n ctx.strokeStyle = options.strokeStyle;\n ctx.stroke();\n });\n var image = Stage.image(texture);\n image.offset(minX - lw, minY - lw);\n var node = Stage.create().append(image);\n return node;\n};\n\nViewer.prototype.drawChain = function(shape, options) {\n var lw = options.lineWidth;\n var ratio = options.ratio;\n var vertices = shape.m_vertices;\n if (!vertices.length) {\n return;\n }\n var minX = Infinity, minY = Infinity;\n var maxX = -Infinity, maxY = -Infinity;\n for (var i = 0; i < vertices.length; ++i) {\n var v = vertices[i];\n minX = Math.min(minX, v.x);\n maxX = Math.max(maxX, v.x);\n minY = Math.min(minY, v.y);\n maxY = Math.max(maxY, v.y);\n }\n var width = maxX - minX;\n var height = maxY - minY;\n var texture = Stage.canvas(function(ctx) {\n this.size(width + 2 * lw, height + 2 * lw, ratio);\n ctx.scale(ratio, ratio);\n ctx.beginPath();\n for (var i = 0; i < vertices.length; ++i) {\n var v = vertices[i];\n var x = v.x - minX + lw;\n var y = v.y - minY + lw;\n if (i == 0) ctx.moveTo(x, y); else ctx.lineTo(x, y);\n }\n if (vertices.length > 2) {}\n if (options.fillStyle) {\n ctx.fillStyle = options.fillStyle;\n ctx.fill();\n ctx.closePath();\n }\n ctx.lineCap = \"round\";\n ctx.lineWidth = options.lineWidth;\n ctx.strokeStyle = options.strokeStyle;\n ctx.stroke();\n });\n var image = Stage.image(texture);\n image.offset(minX - lw, minY - lw);\n var node = Stage.create().append(image);\n return node;\n};\n},{\"../lib/\":27,\"stage-js/platform/web\":82}],2:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Body;\n\nvar common = require(\"./util/common\");\n\nvar options = require(\"./util/options\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar Rot = require(\"./common/Rot\");\n\nvar Math = require(\"./common/Math\");\n\nvar Sweep = require(\"./common/Sweep\");\n\nvar Transform = require(\"./common/Transform\");\n\nvar Velocity = require(\"./common/Velocity\");\n\nvar Position = require(\"./common/Position\");\n\nvar Fixture = require(\"./Fixture\");\n\nvar Shape = require(\"./Shape\");\n\nvar World = require(\"./World\");\n\nvar staticBody = Body.STATIC = \"static\";\n\nvar kinematicBody = Body.KINEMATIC = \"kinematic\";\n\nvar dynamicBody = Body.DYNAMIC = \"dynamic\";\n\nvar BodyDef = {\n type: staticBody,\n position: Vec2.zero(),\n angle: 0,\n linearVelocity: Vec2.zero(),\n angularVelocity: 0,\n linearDamping: 0,\n angularDamping: 0,\n fixedRotation: false,\n bullet: false,\n gravityScale: 1,\n allowSleep: true,\n awake: true,\n active: true,\n userData: null\n};\n\nfunction Body(world, def) {\n def = options(def, BodyDef);\n ASSERT && common.assert(Vec2.isValid(def.position));\n ASSERT && common.assert(Vec2.isValid(def.linearVelocity));\n ASSERT && common.assert(Math.isFinite(def.angle));\n ASSERT && common.assert(Math.isFinite(def.angularVelocity));\n ASSERT && common.assert(Math.isFinite(def.angularDamping) && def.angularDamping >= 0);\n ASSERT && common.assert(Math.isFinite(def.linearDamping) && def.linearDamping >= 0);\n this.m_world = world;\n this.m_awakeFlag = def.awake;\n this.m_autoSleepFlag = def.allowSleep;\n this.m_bulletFlag = def.bullet;\n this.m_fixedRotationFlag = def.fixedRotation;\n this.m_activeFlag = def.active;\n this.m_islandFlag = false;\n this.m_toiFlag = false;\n this.m_userData = def.userData;\n this.m_type = def.type;\n if (this.m_type == dynamicBody) {\n this.m_mass = 1;\n this.m_invMass = 1;\n } else {\n this.m_mass = 0;\n this.m_invMass = 0;\n }\n this.m_I = 0;\n this.m_invI = 0;\n this.m_xf = Transform.identity();\n this.m_xf.p = Vec2.clone(def.position);\n this.m_xf.q.setAngle(def.angle);\n this.m_sweep = new Sweep();\n this.m_sweep.setTransform(this.m_xf);\n this.c_velocity = new Velocity();\n this.c_position = new Position();\n this.m_force = Vec2.zero();\n this.m_torque = 0;\n this.m_linearVelocity = Vec2.clone(def.linearVelocity);\n this.m_angularVelocity = def.angularVelocity;\n this.m_linearDamping = def.linearDamping;\n this.m_angularDamping = def.angularDamping;\n this.m_gravityScale = def.gravityScale;\n this.m_sleepTime = 0;\n this.m_jointList = null;\n this.m_contactList = null;\n this.m_fixtureList = null;\n this.m_prev = null;\n this.m_next = null;\n}\n\nBody.prototype.isWorldLocked = function() {\n return this.m_world && this.m_world.isLocked() ? true : false;\n};\n\nBody.prototype.getWorld = function() {\n return this.m_world;\n};\n\nBody.prototype.getNext = function() {\n return this.m_next;\n};\n\nBody.prototype.setUserData = function(data) {\n this.m_userData = data;\n};\n\nBody.prototype.getUserData = function() {\n return this.m_userData;\n};\n\nBody.prototype.getFixtureList = function() {\n return this.m_fixtureList;\n};\n\nBody.prototype.getJointList = function() {\n return this.m_jointList;\n};\n\nBody.prototype.getContactList = function() {\n return this.m_contactList;\n};\n\nBody.prototype.isStatic = function() {\n return this.m_type == staticBody;\n};\n\nBody.prototype.isDynamic = function() {\n return this.m_type == dynamicBody;\n};\n\nBody.prototype.isKinematic = function() {\n return this.m_type == kinematicBody;\n};\n\nBody.prototype.setStatic = function() {\n this.setType(staticBody);\n return this;\n};\n\nBody.prototype.setDynamic = function() {\n this.setType(dynamicBody);\n return this;\n};\n\nBody.prototype.setKinematic = function() {\n this.setType(kinematicBody);\n return this;\n};\n\nBody.prototype.getType = function() {\n return this.m_type;\n};\n\nBody.prototype.setType = function(type) {\n ASSERT && common.assert(type === staticBody || type === kinematicBody || type === dynamicBody);\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (this.m_type == type) {\n return;\n }\n this.m_type = type;\n this.resetMassData();\n if (this.m_type == staticBody) {\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0;\n this.m_sweep.forward();\n this.synchronizeFixtures();\n }\n this.setAwake(true);\n this.m_force.setZero();\n this.m_torque = 0;\n var ce = this.m_contactList;\n while (ce) {\n var ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n var proxyCount = f.m_proxyCount;\n for (var i = 0; i < proxyCount; ++i) {\n broadPhase.touchProxy(f.m_proxies[i].proxyId);\n }\n }\n};\n\nBody.prototype.isBullet = function() {\n return this.m_bulletFlag;\n};\n\nBody.prototype.setBullet = function(flag) {\n this.m_bulletFlag = !!flag;\n};\n\nBody.prototype.isSleepingAllowed = function() {\n return this.m_autoSleepFlag;\n};\n\nBody.prototype.setSleepingAllowed = function(flag) {\n this.m_autoSleepFlag = !!flag;\n if (this.m_autoSleepFlag == false) {\n this.setAwake(true);\n }\n};\n\nBody.prototype.isAwake = function() {\n return this.m_awakeFlag;\n};\n\nBody.prototype.setAwake = function(flag) {\n if (flag) {\n if (this.m_awakeFlag == false) {\n this.m_awakeFlag = true;\n this.m_sleepTime = 0;\n }\n } else {\n this.m_awakeFlag = false;\n this.m_sleepTime = 0;\n this.m_linearVelocity.setZero();\n this.m_angularVelocity = 0;\n this.m_force.setZero();\n this.m_torque = 0;\n }\n};\n\nBody.prototype.isActive = function() {\n return this.m_activeFlag;\n};\n\nBody.prototype.setActive = function(flag) {\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (flag == this.m_activeFlag) {\n return;\n }\n this.m_activeFlag = !!flag;\n if (this.m_activeFlag) {\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.createProxies(broadPhase, this.m_xf);\n }\n } else {\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.destroyProxies(broadPhase);\n }\n var ce = this.m_contactList;\n while (ce) {\n var ce0 = ce;\n ce = ce.next;\n this.m_world.destroyContact(ce0.contact);\n }\n this.m_contactList = null;\n }\n};\n\nBody.prototype.isFixedRotation = function() {\n return this.m_fixedRotationFlag;\n};\n\nBody.prototype.setFixedRotation = function(flag) {\n if (this.m_fixedRotationFlag == flag) {\n return;\n }\n this.m_fixedRotationFlag = !!flag;\n this.m_angularVelocity = 0;\n this.resetMassData();\n};\n\nBody.prototype.getTransform = function() {\n return this.m_xf;\n};\n\nBody.prototype.setTransform = function(position, angle) {\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n this.m_xf.set(position, angle);\n this.m_sweep.setTransform(this.m_xf);\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, this.m_xf, this.m_xf);\n }\n};\n\nBody.prototype.synchronizeTransform = function() {\n this.m_sweep.getTransform(this.m_xf, 1);\n};\n\nBody.prototype.synchronizeFixtures = function() {\n var xf = Transform.identity();\n this.m_sweep.getTransform(xf, 0);\n var broadPhase = this.m_world.m_broadPhase;\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n f.synchronize(broadPhase, xf, this.m_xf);\n }\n};\n\nBody.prototype.advance = function(alpha) {\n this.m_sweep.advance(alpha);\n this.m_sweep.c.set(this.m_sweep.c0);\n this.m_sweep.a = this.m_sweep.a0;\n this.m_sweep.getTransform(this.m_xf, 1);\n};\n\nBody.prototype.getPosition = function() {\n return this.m_xf.p;\n};\n\nBody.prototype.setPosition = function(p) {\n this.setTransform(p, this.m_sweep.a);\n};\n\nBody.prototype.getAngle = function() {\n return this.m_sweep.a;\n};\n\nBody.prototype.setAngle = function(angle) {\n this.setTransform(this.m_xf.p, angle);\n};\n\nBody.prototype.getWorldCenter = function() {\n return this.m_sweep.c;\n};\n\nBody.prototype.getLocalCenter = function() {\n return this.m_sweep.localCenter;\n};\n\nBody.prototype.getLinearVelocity = function() {\n return this.m_linearVelocity;\n};\n\nBody.prototype.getLinearVelocityFromWorldPoint = function(worldPoint) {\n var localCenter = Vec2.sub(worldPoint, this.m_sweep.c);\n return Vec2.add(this.m_linearVelocity, Vec2.cross(this.m_angularVelocity, localCenter));\n};\n\nBody.prototype.getLinearVelocityFromLocalPoint = function(localPoint) {\n return this.getLinearVelocityFromWorldPoint(this.getWorldPoint(localPoint));\n};\n\nBody.prototype.setLinearVelocity = function(v) {\n if (this.m_type == staticBody) {\n return;\n }\n if (Vec2.dot(v, v) > 0) {\n this.setAwake(true);\n }\n this.m_linearVelocity.set(v);\n};\n\nBody.prototype.getAngularVelocity = function() {\n return this.m_angularVelocity;\n};\n\nBody.prototype.setAngularVelocity = function(w) {\n if (this.m_type == staticBody) {\n return;\n }\n if (w * w > 0) {\n this.setAwake(true);\n }\n this.m_angularVelocity = w;\n};\n\nBody.prototype.getLinearDamping = function() {\n return this.m_linearDamping;\n};\n\nBody.prototype.setLinearDamping = function(linearDamping) {\n this.m_linearDamping = linearDamping;\n};\n\nBody.prototype.getAngularDamping = function() {\n return this.m_angularDamping;\n};\n\nBody.prototype.setAngularDamping = function(angularDamping) {\n this.m_angularDamping = angularDamping;\n};\n\nBody.prototype.getGravityScale = function() {\n return this.m_gravityScale;\n};\n\nBody.prototype.setGravityScale = function(scale) {\n this.m_gravityScale = scale;\n};\n\nBody.prototype.getMass = function() {\n return this.m_mass;\n};\n\nBody.prototype.getInertia = function() {\n return this.m_I + this.m_mass * Vec2.dot(this.m_sweep.localCenter, this.m_sweep.localCenter);\n};\n\nfunction MassData() {\n this.mass = 0;\n this.center = Vec2.zero();\n this.I = 0;\n}\n\nBody.prototype.getMassData = function(data) {\n data.mass = this.m_mass;\n data.I = this.getInertia();\n data.center.set(this.m_sweep.localCenter);\n};\n\nBody.prototype.resetMassData = function() {\n this.m_mass = 0;\n this.m_invMass = 0;\n this.m_I = 0;\n this.m_invI = 0;\n this.m_sweep.localCenter.setZero();\n if (this.isStatic() || this.isKinematic()) {\n this.m_sweep.c0.set(this.m_xf.p);\n this.m_sweep.c.set(this.m_xf.p);\n this.m_sweep.a0 = this.m_sweep.a;\n return;\n }\n ASSERT && common.assert(this.isDynamic());\n var localCenter = Vec2.zero();\n for (var f = this.m_fixtureList; f; f = f.m_next) {\n if (f.m_density == 0) {\n continue;\n }\n var massData = new MassData();\n f.getMassData(massData);\n this.m_mass += massData.mass;\n localCenter.wAdd(massData.mass, massData.center);\n this.m_I += massData.I;\n }\n if (this.m_mass > 0) {\n this.m_invMass = 1 / this.m_mass;\n localCenter.mul(this.m_invMass);\n } else {\n this.m_mass = 1;\n this.m_invMass = 1;\n }\n if (this.m_I > 0 && this.m_fixedRotationFlag == false) {\n this.m_I -= this.m_mass * Vec2.dot(localCenter, localCenter);\n ASSERT && common.assert(this.m_I > 0);\n this.m_invI = 1 / this.m_I;\n } else {\n this.m_I = 0;\n this.m_invI = 0;\n }\n var oldCenter = Vec2.clone(this.m_sweep.c);\n this.m_sweep.setLocalCenter(localCenter, this.m_xf);\n this.m_linearVelocity.add(Vec2.cross(this.m_angularVelocity, Vec2.sub(this.m_sweep.c, oldCenter)));\n};\n\nBody.prototype.setMassData = function(massData) {\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n if (this.m_type != dynamicBody) {\n return;\n }\n this.m_invMass = 0;\n this.m_I = 0;\n this.m_invI = 0;\n this.m_mass = massData.mass;\n if (this.m_mass <= 0) {\n this.m_mass = 1;\n }\n this.m_invMass = 1 / this.m_mass;\n if (massData.I > 0 && this.m_fixedRotationFlag == false) {\n this.m_I = massData.I - this.m_mass * Vec2.dot(massData.center, massData.center);\n ASSERT && common.assert(this.m_I > 0);\n this.m_invI = 1 / this.m_I;\n }\n var oldCenter = Vec2.clone(this.m_sweep.c);\n this.m_sweep.setLocalCenter(massData.center, this.m_xf);\n this.m_linearVelocity.add(Vec2.cross(this.m_angularVelocity, Vec2.sub(this.m_sweep.c, oldCenter)));\n};\n\nBody.prototype.applyForce = function(force, point, wake) {\n if (this.m_type != dynamicBody) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n this.m_torque += Vec2.cross(Vec2.sub(point, this.m_sweep.c), force);\n }\n};\n\nBody.prototype.applyForceToCenter = function(force, wake) {\n if (this.m_type != dynamicBody) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n if (this.m_awakeFlag) {\n this.m_force.add(force);\n }\n};\n\nBody.prototype.applyTorque = function(torque, wake) {\n if (this.m_type != dynamicBody) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n if (this.m_awakeFlag) {\n this.m_torque += torque;\n }\n};\n\nBody.prototype.applyLinearImpulse = function(impulse, point, wake) {\n if (this.m_type != dynamicBody) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n if (this.m_awakeFlag) {\n this.m_linearVelocity.wAdd(this.m_invMass, impulse);\n this.m_angularVelocity += this.m_invI * Vec2.cross(Vec2.sub(point, this.m_sweep.c), impulse);\n }\n};\n\nBody.prototype.applyAngularImpulse = function(impulse, wake) {\n if (this.m_type != dynamicBody) {\n return;\n }\n if (wake && this.m_awakeFlag == false) {\n this.setAwake(true);\n }\n if (this.m_awakeFlag) {\n this.m_angularVelocity += this.m_invI * impulse;\n }\n};\n\nBody.prototype.shouldCollide = function(that) {\n if (this.m_type != dynamicBody && that.m_type != dynamicBody) {\n return false;\n }\n for (var jn = this.m_jointList; jn; jn = jn.next) {\n if (jn.other == that) {\n if (jn.joint.m_collideConnected == false) {\n return false;\n }\n }\n }\n return true;\n};\n\nBody.prototype.createFixture = function(shape, fixdef) {\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return null;\n }\n var fixture = new Fixture(this, shape, fixdef);\n if (this.m_activeFlag) {\n var broadPhase = this.m_world.m_broadPhase;\n fixture.createProxies(broadPhase, this.m_xf);\n }\n fixture.m_next = this.m_fixtureList;\n this.m_fixtureList = fixture;\n if (fixture.m_density > 0) {\n this.resetMassData();\n }\n this.m_world.m_newFixture = true;\n return fixture;\n};\n\nBody.prototype.destroyFixture = function(fixture) {\n ASSERT && common.assert(this.isWorldLocked() == false);\n if (this.isWorldLocked() == true) {\n return;\n }\n ASSERT && common.assert(fixture.m_body == this);\n var node = this.m_fixtureList;\n var found = false;\n while (node != null) {\n if (node == fixture) {\n node = fixture.m_next;\n found = true;\n break;\n }\n node = node.m_next;\n }\n ASSERT && common.assert(found);\n var edge = this.m_contactList;\n while (edge) {\n var c = edge.contact;\n edge = edge.next;\n var fixtureA = c.getFixtureA();\n var fixtureB = c.getFixtureB();\n if (fixture == fixtureA || fixture == fixtureB) {\n this.m_world.destroyContact(c);\n }\n }\n if (this.m_activeFlag) {\n var broadPhase = this.m_world.m_broadPhase;\n fixture.destroyProxies(broadPhase);\n }\n fixture.m_body = null;\n fixture.m_next = null;\n this.m_world.publish(\"remove-fixture\", fixture);\n this.resetMassData();\n};\n\nBody.prototype.getWorldPoint = function(localPoint) {\n return Transform.mul(this.m_xf, localPoint);\n};\n\nBody.prototype.getWorldVector = function(localVector) {\n return Rot.mul(this.m_xf.q, localVector);\n};\n\nBody.prototype.getLocalPoint = function(worldPoint) {\n return Transform.mulT(this.m_xf, worldPoint);\n};\n\nBody.prototype.getLocalVector = function(worldVector) {\n return Rot.mulT(this.m_xf.q, worldVector);\n};\n\n\n},{\"./Fixture\":4,\"./Shape\":8,\"./World\":10,\"./common/Math\":18,\"./common/Position\":19,\"./common/Rot\":20,\"./common/Sweep\":21,\"./common/Transform\":22,\"./common/Vec2\":23,\"./common/Velocity\":25,\"./util/common\":51,\"./util/options\":53}],3:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar DEBUG_SOLVER = false;\n\nvar common = require(\"./util/common\");\n\nvar Math = require(\"./common/Math\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar Transform = require(\"./common/Transform\");\n\nvar Mat22 = require(\"./common/Mat22\");\n\nvar Rot = require(\"./common/Rot\");\n\nvar Settings = require(\"./Settings\");\n\nvar Manifold = require(\"./Manifold\");\n\nvar Distance = require(\"./collision/Distance\");\n\nmodule.exports = Contact;\n\nfunction ContactEdge(contact) {\n this.contact = contact;\n this.prev;\n this.next;\n this.other;\n}\n\nfunction Contact(fA, indexA, fB, indexB, evaluateFcn) {\n this.m_nodeA = new ContactEdge(this);\n this.m_nodeB = new ContactEdge(this);\n this.m_fixtureA = fA;\n this.m_fixtureB = fB;\n this.m_indexA = indexA;\n this.m_indexB = indexB;\n this.m_evaluateFcn = evaluateFcn;\n this.m_manifold = new Manifold();\n this.m_prev = null;\n this.m_next = null;\n this.m_toi = 1;\n this.m_toiCount = 0;\n this.m_toiFlag = false;\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n this.m_tangentSpeed = 0;\n this.m_enabledFlag = true;\n this.m_islandFlag = false;\n this.m_touchingFlag = false;\n this.m_filterFlag = false;\n this.m_bulletHitFlag = false;\n this.v_points = [];\n this.v_normal = Vec2.zero();\n this.v_normalMass = new Mat22();\n this.v_K = new Mat22();\n this.v_pointCount;\n this.v_tangentSpeed;\n this.v_friction;\n this.v_restitution;\n this.v_invMassA;\n this.v_invMassB;\n this.v_invIA;\n this.v_invIB;\n this.p_localPoints = [];\n this.p_localNormal = Vec2.zero();\n this.p_localPoint = Vec2.zero();\n this.p_localCenterA = Vec2.zero();\n this.p_localCenterB = Vec2.zero();\n this.p_type;\n this.p_radiusA;\n this.p_radiusB;\n this.p_pointCount;\n this.p_invMassA;\n this.p_invMassB;\n this.p_invIA;\n this.p_invIB;\n}\n\nContact.prototype.initConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n var shapeA = fixtureA.getShape();\n var shapeB = fixtureB.getShape();\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n var manifold = this.getManifold();\n var pointCount = manifold.pointCount;\n ASSERT && common.assert(pointCount > 0);\n this.v_invMassA = bodyA.m_invMass;\n this.v_invMassB = bodyB.m_invMass;\n this.v_invIA = bodyA.m_invI;\n this.v_invIB = bodyB.m_invI;\n this.v_friction = this.m_friction;\n this.v_restitution = this.m_restitution;\n this.v_tangentSpeed = this.m_tangentSpeed;\n this.v_pointCount = pointCount;\n DEBUG && common.debug(\"pc\", this.v_pointCount, pointCount);\n this.v_K.setZero();\n this.v_normalMass.setZero();\n this.p_invMassA = bodyA.m_invMass;\n this.p_invMassB = bodyB.m_invMass;\n this.p_invIA = bodyA.m_invI;\n this.p_invIB = bodyB.m_invI;\n this.p_localCenterA = Vec2.clone(bodyA.m_sweep.localCenter);\n this.p_localCenterB = Vec2.clone(bodyB.m_sweep.localCenter);\n this.p_radiusA = shapeA.m_radius;\n this.p_radiusB = shapeB.m_radius;\n this.p_type = manifold.type;\n this.p_localNormal = Vec2.clone(manifold.localNormal);\n this.p_localPoint = Vec2.clone(manifold.localPoint);\n this.p_pointCount = pointCount;\n for (var j = 0; j < pointCount; ++j) {\n var cp = manifold.points[j];\n var vcp = this.v_points[j] = new VelocityConstraintPoint();\n if (step.warmStarting) {\n vcp.normalImpulse = step.dtRatio * cp.normalImpulse;\n vcp.tangentImpulse = step.dtRatio * cp.tangentImpulse;\n } else {\n vcp.normalImpulse = 0;\n vcp.tangentImpulse = 0;\n }\n vcp.rA.setZero();\n vcp.rB.setZero();\n vcp.normalMass = 0;\n vcp.tangentMass = 0;\n vcp.velocityBias = 0;\n this.p_localPoints[j] = Vec2.clone(cp.localPoint);\n }\n};\n\nContact.prototype.getManifold = function() {\n return this.m_manifold;\n};\n\nContact.prototype.getWorldManifold = function(worldManifold) {\n var bodyA = this.m_fixtureA.getBody();\n var bodyB = this.m_fixtureB.getBody();\n var shapeA = this.m_fixtureA.getShape();\n var shapeB = this.m_fixtureB.getShape();\n return this.m_manifold.getWorldManifold(worldManifold, bodyA.getTransform(), shapeA.m_radius, bodyB.getTransform(), shapeB.m_radius);\n};\n\nContact.prototype.setEnabled = function(flag) {\n this.m_enabledFlag = !!flag;\n};\n\nContact.prototype.isEnabled = function() {\n return this.m_enabledFlag;\n};\n\nContact.prototype.isTouching = function() {\n return this.m_touchingFlag;\n};\n\nContact.prototype.getNext = function() {\n return this.m_next;\n};\n\nContact.prototype.getFixtureA = function() {\n return this.m_fixtureA;\n};\n\nContact.prototype.getFixtureB = function() {\n return this.m_fixtureB;\n};\n\nContact.prototype.getChildIndexA = function() {\n return this.m_indexA;\n};\n\nContact.prototype.getChildIndexB = function() {\n return this.m_indexB;\n};\n\nContact.prototype.flagForFiltering = function() {\n this.m_filterFlag = true;\n};\n\nContact.prototype.setFriction = function(friction) {\n this.m_friction = friction;\n};\n\nContact.prototype.getFriction = function() {\n return this.m_friction;\n};\n\nContact.prototype.resetFriction = function() {\n this.m_friction = mixFriction(this.m_fixtureA.m_friction, this.m_fixtureB.m_friction);\n};\n\nContact.prototype.setRestitution = function(restitution) {\n this.m_restitution = restitution;\n};\n\nContact.prototype.getRestitution = function() {\n return this.m_restitution;\n};\n\nContact.prototype.resetRestitution = function() {\n this.m_restitution = mixRestitution(this.m_fixtureA.m_restitution, this.m_fixtureB.m_restitution);\n};\n\nContact.prototype.setTangentSpeed = function(speed) {\n this.m_tangentSpeed = speed;\n};\n\nContact.prototype.getTangentSpeed = function() {\n return this.m_tangentSpeed;\n};\n\nContact.prototype.evaluate = function(manifold, xfA, xfB) {\n this.m_evaluateFcn(manifold, xfA, this.m_fixtureA, this.m_indexA, xfB, this.m_fixtureB, this.m_indexB);\n};\n\nContact.prototype.update = function(listener) {\n this.m_enabledFlag = true;\n var touching = false;\n var wasTouching = this.m_touchingFlag;\n var sensorA = this.m_fixtureA.isSensor();\n var sensorB = this.m_fixtureB.isSensor();\n var sensor = sensorA || sensorB;\n var bodyA = this.m_fixtureA.getBody();\n var bodyB = this.m_fixtureB.getBody();\n var xfA = bodyA.getTransform();\n var xfB = bodyB.getTransform();\n if (sensor) {\n var shapeA = this.m_fixtureA.getShape();\n var shapeB = this.m_fixtureB.getShape();\n touching = Distance.testOverlap(shapeA, this.m_indexA, shapeB, this.m_indexB, xfA, xfB);\n this.m_manifold.pointCount = 0;\n } else {\n var oldManifold = this.m_manifold;\n this.m_manifold = new Manifold();\n this.evaluate(this.m_manifold, xfA, xfB);\n touching = this.m_manifold.pointCount > 0;\n for (var i = 0; i < this.m_manifold.pointCount; ++i) {\n var nmp = this.m_manifold.points[i];\n nmp.normalImpulse = 0;\n nmp.tangentImpulse = 0;\n for (var j = 0; j < oldManifold.pointCount; ++j) {\n var omp = oldManifold.points[j];\n if (omp.id.key == nmp.id.key) {\n nmp.normalImpulse = omp.normalImpulse;\n nmp.tangentImpulse = omp.tangentImpulse;\n break;\n }\n }\n }\n if (touching != wasTouching) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n }\n this.m_touchingFlag = touching;\n if (wasTouching == false && touching == true && listener) {\n listener.beginContact(this);\n }\n if (wasTouching == true && touching == false && listener) {\n listener.endContact(this);\n }\n if (sensor == false && touching && listener) {\n listener.preSolve(this, oldManifold);\n }\n};\n\nContact.prototype.solvePositionConstraint = function(step) {\n return this._solvePositionConstraint(step, false);\n};\n\nContact.prototype.solvePositionConstraintTOI = function(step, toiA, toiB) {\n return this._solvePositionConstraint(step, true, toiA, toiB);\n};\n\nContact.prototype._solvePositionConstraint = function(step, toi, toiA, toiB) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n var localCenterA = Vec2.clone(this.p_localCenterA);\n var localCenterB = Vec2.clone(this.p_localCenterB);\n var mA = 0;\n var iA = 0;\n if (!toi || (bodyA == toiA || bodyA == toiB)) {\n mA = this.p_invMassA;\n iA = this.p_invIA;\n }\n var mB = 0;\n var iB = 0;\n if (!toi || (bodyB == toiA || bodyB == toiB)) {\n mB = this.p_invMassB;\n iB = this.p_invIB;\n }\n var cA = Vec2.clone(positionA.c);\n var aA = positionA.a;\n var cB = Vec2.clone(positionB.c);\n var aB = positionB.a;\n var minSeparation = 0;\n for (var j = 0; j < this.p_pointCount; ++j) {\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n xfA.q.set(aA);\n xfB.q.set(aB);\n xfA.p = Vec2.sub(cA, Rot.mul(xfA.q, localCenterA));\n xfB.p = Vec2.sub(cB, Rot.mul(xfB.q, localCenterB));\n var normal, point, separation;\n switch (this.p_type) {\n case Manifold.e_circles:\n var pointA = Transform.mul(xfA, this.p_localPoint);\n var pointB = Transform.mul(xfB, this.p_localPoints[0]);\n normal = Vec2.sub(pointB, pointA);\n normal.normalize();\n point = Vec2.wAdd(.5, pointA, .5, pointB);\n separation = Vec2.dot(Vec2.sub(pointB, pointA), normal) - this.p_radiusA - this.p_radiusB;\n break;\n\n case Manifold.e_faceA:\n normal = Rot.mul(xfA.q, this.p_localNormal);\n var planePoint = Transform.mul(xfA, this.p_localPoint);\n var clipPoint = Transform.mul(xfB, this.p_localPoints[j]);\n separation = Vec2.dot(Vec2.sub(clipPoint, planePoint), normal) - this.p_radiusA - this.p_radiusB;\n point = clipPoint;\n break;\n\n case Manifold.e_faceB:\n normal = Rot.mul(xfB.q, this.p_localNormal);\n var planePoint = Transform.mul(xfB, this.p_localPoint);\n var clipPoint = Transform.mul(xfA, this.p_localPoints[j]);\n separation = Vec2.dot(Vec2.sub(clipPoint, planePoint), normal) - this.p_radiusA - this.p_radiusB;\n point = clipPoint;\n normal.mul(-1);\n break;\n }\n var rA = Vec2.sub(point, cA);\n var rB = Vec2.sub(point, cB);\n minSeparation = Math.min(minSeparation, separation);\n var baumgarte = toi ? Settings.toiBaugarte : Settings.baumgarte;\n var linearSlop = Settings.linearSlop;\n var maxLinearCorrection = Settings.maxLinearCorrection;\n var C = Math.clamp(baumgarte * (separation + linearSlop), -maxLinearCorrection, 0);\n var rnA = Vec2.cross(rA, normal);\n var rnB = Vec2.cross(rB, normal);\n var K = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n var impulse = K > 0 ? -C / K : 0;\n var P = Vec2.mul(impulse, normal);\n cA.wSub(mA, P);\n aA -= iA * Vec2.cross(rA, P);\n cB.wAdd(mB, P);\n aB += iB * Vec2.cross(rB, P);\n }\n positionA.c.set(cA);\n positionA.a = aA;\n positionB.c.set(cB);\n positionB.a = aB;\n return minSeparation;\n};\n\nfunction VelocityConstraintPoint() {\n this.rA = Vec2.zero();\n this.rB = Vec2.zero();\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.normalMass = 0;\n this.tangentMass = 0;\n this.velocityBias = 0;\n}\n\nContact.prototype.initVelocityConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n var radiusA = this.p_radiusA;\n var radiusB = this.p_radiusB;\n var manifold = this.getManifold();\n var mA = this.v_invMassA;\n var mB = this.v_invMassB;\n var iA = this.v_invIA;\n var iB = this.v_invIB;\n var localCenterA = Vec2.clone(this.p_localCenterA);\n var localCenterB = Vec2.clone(this.p_localCenterB);\n var cA = Vec2.clone(positionA.c);\n var aA = positionA.a;\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n var cB = Vec2.clone(positionB.c);\n var aB = positionB.a;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n ASSERT && common.assert(manifold.pointCount > 0);\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n xfA.q.set(aA);\n xfB.q.set(aB);\n xfA.p.wSet(1, cA, -1, Rot.mul(xfA.q, localCenterA));\n xfB.p.wSet(1, cB, -1, Rot.mul(xfB.q, localCenterB));\n var worldManifold = manifold.getWorldManifold(null, xfA, radiusA, xfB, radiusB);\n this.v_normal.set(worldManifold.normal);\n for (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j];\n vcp.rA.set(Vec2.sub(worldManifold.points[j], cA));\n vcp.rB.set(Vec2.sub(worldManifold.points[j], cB));\n DEBUG && common.debug(\"vcp.rA\", worldManifold.points[j].x, worldManifold.points[j].y, cA.x, cA.y, vcp.rA.x, vcp.rA.y);\n var rnA = Vec2.cross(vcp.rA, this.v_normal);\n var rnB = Vec2.cross(vcp.rB, this.v_normal);\n var kNormal = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n vcp.normalMass = kNormal > 0 ? 1 / kNormal : 0;\n var tangent = Vec2.cross(this.v_normal, 1);\n var rtA = Vec2.cross(vcp.rA, tangent);\n var rtB = Vec2.cross(vcp.rB, tangent);\n var kTangent = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n vcp.tangentMass = kTangent > 0 ? 1 / kTangent : 0;\n vcp.velocityBias = 0;\n var vRel = Vec2.dot(this.v_normal, vB) + Vec2.dot(this.v_normal, Vec2.cross(wB, vcp.rB)) - Vec2.dot(this.v_normal, vA) - Vec2.dot(this.v_normal, Vec2.cross(wA, vcp.rA));\n if (vRel < -Settings.velocityThreshold) {\n vcp.velocityBias = -this.v_restitution * vRel;\n }\n }\n if (this.v_pointCount == 2 && step.blockSolve) {\n var vcp1 = this.v_points[0];\n var vcp2 = this.v_points[1];\n var rn1A = Vec2.cross(vcp1.rA, this.v_normal);\n var rn1B = Vec2.cross(vcp1.rB, this.v_normal);\n var rn2A = Vec2.cross(vcp2.rA, this.v_normal);\n var rn2B = Vec2.cross(vcp2.rB, this.v_normal);\n var k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n var k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n var k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n var k_maxConditionNumber = 1e3;\n DEBUG && common.debug(\"k1x2: \", k11, k22, k12, mA, mB, iA, rn1A, rn2A, iB, rn1B, rn2B);\n if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {\n this.v_K.ex.set(k11, k12);\n this.v_K.ey.set(k12, k22);\n this.v_normalMass.set(this.v_K.getInverse());\n } else {\n this.v_pointCount = 1;\n }\n }\n positionA.c.set(cA);\n positionA.a = aA;\n velocityA.v.set(vA);\n velocityA.w = wA;\n positionB.c.set(cB);\n positionB.a = aB;\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\nContact.prototype.warmStartConstraint = function(step) {\n var fixtureA = this.m_fixtureA;\n var fixtureB = this.m_fixtureB;\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n var velocityA = bodyA.c_velocity;\n var velocityB = bodyB.c_velocity;\n var positionA = bodyA.c_position;\n var positionB = bodyB.c_position;\n var mA = this.v_invMassA;\n var iA = this.v_invIA;\n var mB = this.v_invMassB;\n var iB = this.v_invIB;\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n var normal = this.v_normal;\n var tangent = Vec2.cross(normal, 1);\n for (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j];\n var P = Vec2.wAdd(vcp.normalImpulse, normal, vcp.tangentImpulse, tangent);\n DEBUG && common.debug(iA, iB, vcp.rA.x, vcp.rA.y, vcp.rB.x, vcp.rB.y, P.x, P.y);\n wA -= iA * Vec2.cross(vcp.rA, P);\n vA.wSub(mA, P);\n wB += iB * Vec2.cross(vcp.rB, P);\n vB.wAdd(mB, P);\n }\n velocityA.v.set(vA);\n velocityA.w = wA;\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\nContact.prototype.storeConstraintImpulses = function(step) {\n var manifold = this.m_manifold;\n for (var j = 0; j < this.v_pointCount; ++j) {\n manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;\n manifold.points[j].tangentImpulse = this.v_points[j].tangentImpulse;\n }\n};\n\nContact.prototype.solveVelocityConstraint = function(step) {\n var bodyA = this.m_fixtureA.m_body;\n var bodyB = this.m_fixtureB.m_body;\n var velocityA = bodyA.c_velocity;\n var positionA = bodyA.c_position;\n var velocityB = bodyB.c_velocity;\n var positionB = bodyB.c_position;\n var mA = this.v_invMassA;\n var iA = this.v_invIA;\n var mB = this.v_invMassB;\n var iB = this.v_invIB;\n var vA = Vec2.clone(velocityA.v);\n var wA = velocityA.w;\n var vB = Vec2.clone(velocityB.v);\n var wB = velocityB.w;\n var normal = this.v_normal;\n var tangent = Vec2.cross(normal, 1);\n var friction = this.v_friction;\n ASSERT && common.assert(this.v_pointCount == 1 || this.v_pointCount == 2);\n for (var j = 0; j < this.v_pointCount; ++j) {\n var vcp = this.v_points[j];\n var dv = Vec2.zero();\n dv.wAdd(1, vB, 1, Vec2.cross(wB, vcp.rB));\n dv.wSub(1, vA, 1, Vec2.cross(wA, vcp.rA));\n var vt = Vec2.dot(dv, tangent) - this.v_tangentSpeed;\n var lambda = vcp.tangentMass * -vt;\n var maxFriction = friction * vcp.normalImpulse;\n var newImpulse = Math.clamp(vcp.tangentImpulse + lambda, -maxFriction, maxFriction);\n lambda = newImpulse - vcp.tangentImpulse;\n vcp.tangentImpulse = newImpulse;\n var P = Vec2.mul(lambda, tangent);\n vA.wSub(mA, P);\n wA -= iA * Vec2.cross(vcp.rA, P);\n vB.wAdd(mB, P);\n wB += iB * Vec2.cross(vcp.rB, P);\n }\n if (this.v_pointCount == 1 || step.blockSolve == false) {\n for (var i = 0; i < this.v_pointCount; ++i) {\n var vcp = this.v_points[i];\n var dv = Vec2.zero();\n dv.wAdd(1, vB, 1, Vec2.cross(wB, vcp.rB));\n dv.wSub(1, vA, 1, Vec2.cross(wA, vcp.rA));\n var vn = Vec2.dot(dv, normal);\n var lambda = -vcp.normalMass * (vn - vcp.velocityBias);\n var newImpulse = Math.max(vcp.normalImpulse + lambda, 0);\n lambda = newImpulse - vcp.normalImpulse;\n vcp.normalImpulse = newImpulse;\n var P = Vec2.mul(lambda, normal);\n vA.wSub(mA, P);\n wA -= iA * Vec2.cross(vcp.rA, P);\n vB.wAdd(mB, P);\n wB += iB * Vec2.cross(vcp.rB, P);\n }\n } else {\n var vcp1 = this.v_points[0];\n var vcp2 = this.v_points[1];\n var a = Vec2.neo(vcp1.normalImpulse, vcp2.normalImpulse);\n ASSERT && common.assert(a.x >= 0 && a.y >= 0);\n var dv1 = Vec2.zero().add(vB).add(Vec2.cross(wB, vcp1.rB)).sub(vA).sub(Vec2.cross(wA, vcp1.rA));\n var dv2 = Vec2.zero().add(vB).add(Vec2.cross(wB, vcp2.rB)).sub(vA).sub(Vec2.cross(wA, vcp2.rA));\n var vn1 = Vec2.dot(dv1, normal);\n var vn2 = Vec2.dot(dv2, normal);\n var b = Vec2.neo(vn1 - vcp1.velocityBias, vn2 - vcp2.velocityBias);\n b.sub(Mat22.mul(this.v_K, a));\n var k_errorTol = .001;\n for (;;) {\n var x = Vec2.neg(Mat22.mul(this.v_normalMass, b));\n if (x.x >= 0 && x.y >= 0) {\n var d = Vec2.sub(x, a);\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.wSub(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n vB.wAdd(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n if (DEBUG_SOLVER) {\n dv1 = vB + Vec2.cross(wB, vcp1.rB) - vA - Vec2.cross(wA, vcp1.rA);\n dv2 = vB + Vec2.cross(wB, vcp2.rB) - vA - Vec2.cross(wA, vcp2.rA);\n vn1 = Dot(dv1, normal);\n vn2 = Dot(dv2, normal);\n ASSERT && common.assert(Abs(vn1 - vcp1.velocityBias) < k_errorTol);\n ASSERT && common.assert(Abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n x.x = -vcp1.normalMass * b.x;\n x.y = 0;\n vn1 = 0;\n vn2 = this.v_K.ex.y * x.x + b.y;\n if (x.x >= 0 && vn2 >= 0) {\n var d = Vec2.sub(x, a);\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.wSub(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n vB.wAdd(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n if (DEBUG_SOLVER) {\n var dv1B = Vec2.add(vB, Vec2.cross(wB, vcp1.rB));\n var dv1A = Vec2.add(vA, Vec2.cross(wA, vcp1.rA));\n var dv1 = Vec2.sub(dv1B, dv1A);\n vn1 = Vec2.dot(dv1, normal);\n ASSERT && common.assert(Math.abs(vn1 - vcp1.velocityBias) < k_errorTol);\n }\n break;\n }\n x.x = 0;\n x.y = -vcp2.normalMass * b.y;\n vn1 = this.v_K.ey.x * x.y + b.x;\n vn2 = 0;\n if (x.y >= 0 && vn1 >= 0) {\n var d = Vec2.sub(x, a);\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.wSub(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n vB.wAdd(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n if (DEBUG_SOLVER) {\n var dv2B = Vec2.add(vB, Vec2.cross(wB, vcp2.rB));\n var dv2A = Vec2.add(vA, Vec2.cross(wA, vcp2.rA));\n var dv1 = Vec2.sub(dv2B, dv2A);\n vn2 = Vec2.dot(dv2, normal);\n ASSERT && common.assert(Math.abs(vn2 - vcp2.velocityBias) < k_errorTol);\n }\n break;\n }\n x.x = 0;\n x.y = 0;\n vn1 = b.x;\n vn2 = b.y;\n if (vn1 >= 0 && vn2 >= 0) {\n var d = Vec2.sub(x, a);\n var P1 = Vec2.mul(d.x, normal);\n var P2 = Vec2.mul(d.y, normal);\n vA.wSub(mA, P1, mA, P2);\n wA -= iA * (Vec2.cross(vcp1.rA, P1) + Vec2.cross(vcp2.rA, P2));\n vB.wAdd(mB, P1, mB, P2);\n wB += iB * (Vec2.cross(vcp1.rB, P1) + Vec2.cross(vcp2.rB, P2));\n vcp1.normalImpulse = x.x;\n vcp2.normalImpulse = x.y;\n break;\n }\n break;\n }\n }\n velocityA.v.set(vA);\n velocityA.w = wA;\n velocityB.v.set(vB);\n velocityB.w = wB;\n};\n\nfunction mixFriction(friction1, friction2) {\n return Math.sqrt(friction1 * friction2);\n}\n\nfunction mixRestitution(restitution1, restitution2) {\n return restitution1 > restitution2 ? restitution1 : restitution2;\n}\n\nvar s_registers = [];\n\nContact.addType = function(type1, type2, callback) {\n s_registers[type1] = s_registers[type1] || {};\n s_registers[type1][type2] = callback;\n};\n\nContact.create = function(fixtureA, indexA, fixtureB, indexB) {\n var typeA = fixtureA.getType();\n var typeB = fixtureB.getType();\n var contact, evaluateFcn;\n if (evaluateFcn = s_registers[typeA] && s_registers[typeA][typeB]) {\n contact = new Contact(fixtureA, indexA, fixtureB, indexB, evaluateFcn);\n } else if (evaluateFcn = s_registers[typeB] && s_registers[typeB][typeA]) {\n contact = new Contact(fixtureB, indexB, fixtureA, indexA, evaluateFcn);\n } else {\n return null;\n }\n fixtureA = contact.getFixtureA();\n fixtureB = contact.getFixtureB();\n indexA = contact.getChildIndexA();\n indexB = contact.getChildIndexB();\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n contact.m_nodeA.contact = contact;\n contact.m_nodeA.other = bodyB;\n contact.m_nodeA.prev = null;\n contact.m_nodeA.next = bodyA.m_contactList;\n if (bodyA.m_contactList != null) {\n bodyA.m_contactList.prev = contact.m_nodeA;\n }\n bodyA.m_contactList = contact.m_nodeA;\n contact.m_nodeB.contact = contact;\n contact.m_nodeB.other = bodyA;\n contact.m_nodeB.prev = null;\n contact.m_nodeB.next = bodyB.m_contactList;\n if (bodyB.m_contactList != null) {\n bodyB.m_contactList.prev = contact.m_nodeB;\n }\n bodyB.m_contactList = contact.m_nodeB;\n if (fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n return contact;\n};\n\nContact.destroy = function(contact, listener) {\n var fixtureA = contact.m_fixtureA;\n var fixtureB = contact.m_fixtureB;\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n if (contact.isTouching()) {\n listener.endContact(contact);\n }\n if (contact.m_nodeA.prev) {\n contact.m_nodeA.prev.next = contact.m_nodeA.next;\n }\n if (contact.m_nodeA.next) {\n contact.m_nodeA.next.prev = contact.m_nodeA.prev;\n }\n if (contact.m_nodeA == bodyA.m_contactList) {\n bodyA.m_contactList = contact.m_nodeA.next;\n }\n if (contact.m_nodeB.prev) {\n contact.m_nodeB.prev.next = contact.m_nodeB.next;\n }\n if (contact.m_nodeB.next) {\n contact.m_nodeB.next.prev = contact.m_nodeB.prev;\n }\n if (contact.m_nodeB == bodyB.m_contactList) {\n bodyB.m_contactList = contact.m_nodeB.next;\n }\n if (contact.m_manifold.pointCount > 0 && fixtureA.isSensor() == false && fixtureB.isSensor() == false) {\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n }\n var typeA = fixtureA.getType();\n var typeB = fixtureB.getType();\n var destroyFcn = s_registers[typeA][typeB].destroyFcn;\n if (typeof destroyFcn === \"function\") {\n destroyFcn(contact);\n }\n};\n\n\n},{\"./Manifold\":6,\"./Settings\":7,\"./collision/Distance\":13,\"./common/Mat22\":16,\"./common/Math\":18,\"./common/Rot\":20,\"./common/Transform\":22,\"./common/Vec2\":23,\"./util/common\":51}],4:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Fixture;\n\nvar common = require(\"./util/common\");\n\nvar options = require(\"./util/options\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar AABB = require(\"./collision/AABB\");\n\nvar FixtureDef = {\n userData: null,\n friction: .2,\n restitution: 0,\n density: 0,\n isSensor: false,\n filterGroupIndex: 0,\n filterCategoryBits: 1,\n filterMaskBits: 65535\n};\n\nfunction FixtureProxy(fixture, childIndex) {\n this.aabb = new AABB();\n this.fixture = fixture;\n this.childIndex = childIndex;\n this.proxyId;\n}\n\nfunction Fixture(body, shape, def) {\n if (shape.shape) {\n def = shape;\n shape = shape.shape;\n } else if (typeof def === \"number\") {\n def = {\n density: def\n };\n }\n def = options(def, FixtureDef);\n this.m_body = body;\n this.m_friction = def.friction;\n this.m_restitution = def.restitution;\n this.m_density = def.density;\n this.m_isSensor = def.isSensor;\n this.m_filterGroupIndex = def.filterGroupIndex;\n this.m_filterCategoryBits = def.filterCategoryBits;\n this.m_filterMaskBits = def.filterMaskBits;\n this.m_shape = shape;\n this.m_next = null;\n this.m_proxies = [];\n this.m_proxyCount = 0;\n var childCount = this.m_shape.getChildCount();\n for (var i = 0; i < childCount; ++i) {\n this.m_proxies[i] = new FixtureProxy(this, i);\n }\n this.m_userData = def.userData;\n}\n\nFixture.prototype.getType = function() {\n return this.m_shape.getType();\n};\n\nFixture.prototype.getShape = function() {\n return this.m_shape;\n};\n\nFixture.prototype.isSensor = function() {\n return this.m_isSensor;\n};\n\nFixture.prototype.setSensor = function(sensor) {\n if (sensor != this.m_isSensor) {\n this.m_body.setAwake(true);\n this.m_isSensor = sensor;\n }\n};\n\nFixture.prototype.getUserData = function() {\n return this.m_userData;\n};\n\nFixture.prototype.setUserData = function(data) {\n this.m_userData = data;\n};\n\nFixture.prototype.getBody = function() {\n return this.m_body;\n};\n\nFixture.prototype.getNext = function() {\n return this.m_next;\n};\n\nFixture.prototype.getDensity = function() {\n return this.m_density;\n};\n\nFixture.prototype.setDensity = function(density) {\n ASSERT && common.assert(Math.isFinite(density) && density >= 0);\n this.m_density = density;\n};\n\nFixture.prototype.getFriction = function() {\n return this.m_friction;\n};\n\nFixture.prototype.setFriction = function(friction) {\n this.m_friction = friction;\n};\n\nFixture.prototype.getRestitution = function() {\n return this.m_restitution;\n};\n\nFixture.prototype.setRestitution = function(restitution) {\n this.m_restitution = restitution;\n};\n\nFixture.prototype.testPoint = function(p) {\n return this.m_shape.testPoint(this.m_body.getTransform(), p);\n};\n\nFixture.prototype.rayCast = function(output, input, childIndex) {\n return this.m_shape.rayCast(output, input, this.m_body.getTransform(), childIndex);\n};\n\nFixture.prototype.getMassData = function(massData) {\n this.m_shape.computeMass(massData, this.m_density);\n};\n\nFixture.prototype.getAABB = function(childIndex) {\n ASSERT && common.assert(0 <= childIndex && childIndex < this.m_proxyCount);\n return this.m_proxies[childIndex].aabb;\n};\n\nFixture.prototype.createProxies = function(broadPhase, xf) {\n ASSERT && common.assert(this.m_proxyCount == 0);\n this.m_proxyCount = this.m_shape.getChildCount();\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var proxy = this.m_proxies[i];\n this.m_shape.computeAABB(proxy.aabb, xf, i);\n proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);\n }\n};\n\nFixture.prototype.destroyProxies = function(broadPhase) {\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var proxy = this.m_proxies[i];\n broadPhase.destroyProxy(proxy.proxyId);\n proxy.proxyId = null;\n }\n this.m_proxyCount = 0;\n};\n\nFixture.prototype.synchronize = function(broadPhase, xf1, xf2) {\n for (var i = 0; i < this.m_proxyCount; ++i) {\n var proxy = this.m_proxies[i];\n var aabb1 = new AABB();\n var aabb2 = new AABB();\n this.m_shape.computeAABB(aabb1, xf1, proxy.childIndex);\n this.m_shape.computeAABB(aabb2, xf2, proxy.childIndex);\n proxy.aabb.combine(aabb1, aabb2);\n var displacement = Vec2.sub(xf2.p, xf1.p);\n broadPhase.moveProxy(proxy.proxyId, proxy.aabb, displacement);\n }\n};\n\nFixture.prototype.setFilterData = function(filter) {\n this.m_filterGroupIndex = filter.groupIndex;\n this.m_filterCategoryBits = filter.categoryBits;\n this.m_filterMaskBits = filter.maskBits;\n this.refilter();\n};\n\nFixture.prototype.getFilterGroupIndex = function() {\n return this.m_filterGroupIndex;\n};\n\nFixture.prototype.getFilterCategoryBits = function() {\n return this.m_filterCategoryBits;\n};\n\nFixture.prototype.getFilterMaskBits = function() {\n return this.m_filterMaskBits;\n};\n\nFixture.prototype.refilter = function() {\n if (this.m_body == null) {\n return;\n }\n var edge = this.m_body.getContactList();\n while (edge) {\n var contact = edge.contact;\n var fixtureA = contact.getFixtureA();\n var fixtureB = contact.getFixtureB();\n if (fixtureA == this || fixtureB == this) {\n contact.flagForFiltering();\n }\n edge = edge.next;\n }\n var world = this.m_body.getWorld();\n if (world == null) {\n return;\n }\n var broadPhase = world.m_broadPhase;\n for (var i = 0; i < this.m_proxyCount; ++i) {\n broadPhase.touchProxy(this.m_proxies[i].proxyId);\n }\n};\n\nFixture.prototype.shouldCollide = function(that) {\n if (that.m_filterGroupIndex == this.m_filterGroupIndex && that.m_filterGroupIndex != 0) {\n return that.m_filterGroupIndex > 0;\n }\n var collide = (that.m_filterMaskBits & this.m_filterCategoryBits) != 0 && (that.m_filterCategoryBits & this.m_filterMaskBits) != 0;\n return collide;\n};\n\n\n},{\"./collision/AABB\":11,\"./common/Vec2\":23,\"./util/common\":51,\"./util/options\":53}],5:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Joint;\n\nvar common = require(\"./util/common\");\n\nfunction JointEdge() {\n this.other = null;\n this.joint = null;\n this.prev = null;\n this.next = null;\n}\n\nvar JointDef = {\n userData: null,\n collideConnected: false\n};\n\nfunction Joint(def, bodyA, bodyB) {\n bodyA = def.bodyA || bodyA;\n bodyB = def.bodyB || bodyB;\n ASSERT && common.assert(bodyA);\n ASSERT && common.assert(bodyB);\n ASSERT && common.assert(bodyA != bodyB);\n this.m_type = \"unknown-joint\";\n this.m_bodyA = bodyA;\n this.m_bodyB = bodyB;\n this.m_index = 0;\n this.m_collideConnected = !!def.collideConnected;\n this.m_prev = null;\n this.m_next = null;\n this.m_edgeA = new JointEdge();\n this.m_edgeB = new JointEdge();\n this.m_islandFlag = false;\n this.m_userData = def.userData;\n}\n\nJoint.prototype.isActive = function() {\n return this.m_bodyA.isActive() && this.m_bodyB.isActive();\n};\n\nJoint.prototype.getType = function() {\n return this.m_type;\n};\n\nJoint.prototype.getBodyA = function() {\n return this.m_bodyA;\n};\n\nJoint.prototype.getBodyB = function() {\n return this.m_bodyB;\n};\n\nJoint.prototype.getNext = function() {\n return this.m_next;\n};\n\nJoint.prototype.getUserData = function() {\n return this.m_userData;\n};\n\nJoint.prototype.setUserData = function(data) {\n this.m_userData = data;\n};\n\nJoint.prototype.getCollideConnected = function() {\n return this.m_collideConnected;\n};\n\nJoint.prototype.getAnchorA = function() {};\n\nJoint.prototype.getAnchorB = function() {};\n\nJoint.prototype.getReactionForce = function(inv_dt) {};\n\nJoint.prototype.getReactionTorque = function(inv_dt) {};\n\nJoint.prototype.shiftOrigin = function(newOrigin) {};\n\nJoint.prototype.initVelocityConstraints = function(step) {};\n\nJoint.prototype.solveVelocityConstraints = function(step) {};\n\nJoint.prototype.solvePositionConstraints = function(step) {};\n\n\n},{\"./util/common\":51}],6:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"./util/common\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar Transform = require(\"./common/Transform\");\n\nvar Math = require(\"./common/Math\");\n\nvar Rot = require(\"./common/Rot\");\n\nmodule.exports = Manifold;\n\nmodule.exports.clipSegmentToLine = clipSegmentToLine;\n\nmodule.exports.clipVertex = ClipVertex;\n\nmodule.exports.getPointStates = getPointStates;\n\nmodule.exports.PointState = PointState;\n\nManifold.e_circles = 0;\n\nManifold.e_faceA = 1;\n\nManifold.e_faceB = 2;\n\nManifold.e_vertex = 0;\n\nManifold.e_face = 1;\n\nfunction Manifold() {\n this.type;\n this.localNormal = Vec2.zero();\n this.localPoint = Vec2.zero();\n this.points = [ new ManifoldPoint(), new ManifoldPoint() ];\n this.pointCount = 0;\n}\n\nfunction ManifoldPoint() {\n this.localPoint = Vec2.zero();\n this.normalImpulse = 0;\n this.tangentImpulse = 0;\n this.id = new ContactID();\n}\n\nfunction ContactID() {\n this.cf = new ContactFeature();\n this.key;\n}\n\nContactID.prototype.set = function(o) {\n this.key = o.key;\n this.cf.set(o.cf);\n};\n\nfunction ContactFeature() {\n this.indexA;\n this.indexB;\n this.typeA;\n this.typeB;\n}\n\nContactFeature.prototype.set = function(o) {\n this.indexA = o.indexA;\n this.indexB = o.indexB;\n this.typeA = o.typeA;\n this.typeB = o.typeB;\n};\n\nfunction WorldManifold() {\n this.normal;\n this.points = [];\n this.separations = [];\n}\n\nManifold.prototype.getWorldManifold = function(wm, xfA, radiusA, xfB, radiusB) {\n if (this.pointCount == 0) {\n return;\n }\n wm = wm || new WorldManifold();\n var normal = wm.normal;\n var points = wm.points;\n var separations = wm.separations;\n switch (this.type) {\n case Manifold.e_circles:\n normal = Vec2.neo(1, 0);\n var pointA = Transform.mul(xfA, this.localPoint);\n var pointB = Transform.mul(xfB, this.points[0].localPoint);\n var dist = Vec2.sub(pointB, pointA);\n if (Vec2.lengthSquared(dist) > Math.EPSILON * Math.EPSILON) {\n normal.set(dist);\n normal.normalize();\n }\n points[0] = Vec2.mid(pointA, pointB);\n separations[0] = -radiusB - radiusA;\n points.length = 1;\n separations.length = 1;\n break;\n\n case Manifold.e_faceA:\n normal = Rot.mul(xfA.q, this.localNormal);\n var planePoint = Transform.mul(xfA, this.localPoint);\n DEBUG && common.debug(\"faceA\", this.localPoint.x, this.localPoint.y, this.localNormal.x, this.localNormal.y, normal.x, normal.y);\n for (var i = 0; i < this.pointCount; ++i) {\n var clipPoint = Transform.mul(xfB, this.points[i].localPoint);\n var cA = Vec2.clone(clipPoint).wAdd(radiusA - Vec2.dot(Vec2.sub(clipPoint, planePoint), normal), normal);\n var cB = Vec2.clone(clipPoint).wSub(radiusB, normal);\n points[i] = Vec2.mid(cA, cB);\n separations[i] = Vec2.dot(Vec2.sub(cB, cA), normal);\n DEBUG && common.debug(i, this.points[i].localPoint.x, this.points[i].localPoint.y, planePoint.x, planePoint.y, xfA.p.x, xfA.p.y, xfA.q.c, xfA.q.s, xfB.p.x, xfB.p.y, xfB.q.c, xfB.q.s, radiusA, radiusB, clipPoint.x, clipPoint.y, cA.x, cA.y, cB.x, cB.y, separations[i], points[i].x, points[i].y);\n }\n points.length = this.pointCount;\n separations.length = this.pointCount;\n break;\n\n case Manifold.e_faceB:\n normal = Rot.mul(xfB.q, this.localNormal);\n var planePoint = Transform.mul(xfB, this.localPoint);\n for (var i = 0; i < this.pointCount; ++i) {\n var clipPoint = Transform.mul(xfA, this.points[i].localPoint);\n var cB = Vec2.zero().wSet(1, clipPoint, radiusB - Vec2.dot(Vec2.sub(clipPoint, planePoint), normal), normal);\n var cA = Vec2.zero().wSet(1, clipPoint, -radiusA, normal);\n points[i] = Vec2.mid(cA, cB);\n separations[i] = Vec2.dot(Vec2.sub(cA, cB), normal);\n }\n points.length = this.pointCount;\n separations.length = this.pointCount;\n normal.mul(-1);\n break;\n }\n wm.normal = normal;\n wm.points = points;\n wm.separations = separations;\n return wm;\n};\n\nvar PointState = {\n nullState: 0,\n addState: 1,\n persistState: 2,\n removeState: 3\n};\n\nfunction getPointStates(state1, state2, manifold1, manifold2) {\n for (var i = 0; i < manifold1.pointCount; ++i) {\n var id = manifold1.points[i].id;\n state1[i] = PointState.removeState;\n for (var j = 0; j < manifold2.pointCount; ++j) {\n if (manifold2.points[j].id.key == id.key) {\n state1[i] = PointState.persistState;\n break;\n }\n }\n }\n for (var i = 0; i < manifold2.pointCount; ++i) {\n var id = manifold2.points[i].id;\n state2[i] = PointState.addState;\n for (var j = 0; j < manifold1.pointCount; ++j) {\n if (manifold1.points[j].id.key == id.key) {\n state2[i] = PointState.persistState;\n break;\n }\n }\n }\n}\n\nfunction ClipVertex() {\n this.v = Vec2.zero();\n this.id = new ContactID();\n}\n\nClipVertex.prototype.set = function(o) {\n this.v.set(o.v);\n this.id.set(o.id);\n};\n\nfunction clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {\n var numOut = 0;\n var distance0 = Vec2.dot(normal, vIn[0].v) - offset;\n var distance1 = Vec2.dot(normal, vIn[1].v) - offset;\n if (distance0 <= 0) vOut[numOut++].set(vIn[0]);\n if (distance1 <= 0) vOut[numOut++].set(vIn[1]);\n if (distance0 * distance1 < 0) {\n var interp = distance0 / (distance0 - distance1);\n vOut[numOut].v.wSet(1 - interp, vIn[0].v, interp, vIn[1].v);\n vOut[numOut].id.cf.indexA = vertexIndexA;\n vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;\n vOut[numOut].id.cf.typeA = ContactFeature.e_vertex;\n vOut[numOut].id.cf.typeB = ContactFeature.e_face;\n ++numOut;\n }\n return numOut;\n}\n\n\n},{\"./common/Math\":18,\"./common/Rot\":20,\"./common/Transform\":22,\"./common/Vec2\":23,\"./util/common\":51}],7:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar Settings = exports;\n\nSettings.maxManifoldPoints = 2;\n\nSettings.maxPolygonVertices = 12;\n\nSettings.aabbExtension = .1;\n\nSettings.aabbMultiplier = 2;\n\nSettings.linearSlop = .005;\n\nSettings.linearSlopSquared = Settings.linearSlop * Settings.linearSlop;\n\nSettings.angularSlop = 2 / 180 * Math.PI;\n\nSettings.polygonRadius = 2 * Settings.linearSlop;\n\nSettings.maxSubSteps = 8;\n\nSettings.maxTOIContacts = 32;\n\nSettings.maxTOIIterations = 20;\n\nSettings.maxDistnceIterations = 20;\n\nSettings.velocityThreshold = 1;\n\nSettings.maxLinearCorrection = .2;\n\nSettings.maxAngularCorrection = 8 / 180 * Math.PI;\n\nSettings.maxTranslation = 2;\n\nSettings.maxTranslationSquared = Settings.maxTranslation * Settings.maxTranslation;\n\nSettings.maxRotation = .5 * Math.PI;\n\nSettings.maxRotationSquared = Settings.maxRotation * Settings.maxRotation;\n\nSettings.baumgarte = .2;\n\nSettings.toiBaugarte = .75;\n\nSettings.timeToSleep = .5;\n\nSettings.linearSleepTolerance = .01;\n\nSettings.linearSleepToleranceSqr = Math.pow(Settings.linearSleepTolerance, 2);\n\nSettings.angularSleepTolerance = 2 / 180 * Math.PI;\n\nSettings.angularSleepToleranceSqr = Math.pow(Settings.angularSleepTolerance, 2);\n\n\n},{}],8:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Shape;\n\nvar Math = require(\"./common/Math\");\n\nfunction Shape() {\n this.m_type;\n this.m_radius;\n}\n\nShape.isValid = function(shape) {\n return !!shape;\n};\n\nShape.prototype.getRadius = function() {\n return this.m_radius;\n};\n\nShape.prototype.getType = function() {\n return this.m_type;\n};\n\nShape.prototype._clone = function() {};\n\nShape.prototype.getChildCount = function() {};\n\nShape.prototype.testPoint = function(xf, p) {};\n\nShape.prototype.rayCast = function(output, input, transform, childIndex) {};\n\nShape.prototype.computeAABB = function(aabb, xf, childIndex) {};\n\nShape.prototype.computeMass = function(massData, density) {};\n\nShape.prototype.computeDistanceProxy = function(proxy) {};\n\n\n},{\"./common/Math\":18}],9:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Solver;\n\nmodule.exports.TimeStep = TimeStep;\n\nvar Settings = require(\"./Settings\");\n\nvar common = require(\"./util/common\");\n\nvar Timer = require(\"./util/Timer\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar Math = require(\"./common/Math\");\n\nvar Body = require(\"./Body\");\n\nvar Contact = require(\"./Contact\");\n\nvar Joint = require(\"./Joint\");\n\nvar TimeOfImpact = require(\"./collision/TimeOfImpact\");\n\nvar TOIInput = TimeOfImpact.Input;\n\nvar TOIOutput = TimeOfImpact.Output;\n\nvar Distance = require(\"./collision/Distance\");\n\nvar DistanceInput = Distance.Input;\n\nvar DistanceOutput = Distance.Output;\n\nvar DistanceProxy = Distance.Proxy;\n\nvar SimplexCache = Distance.Cache;\n\nfunction Profile() {\n this.solveInit;\n this.solveVelocity;\n this.solvePosition;\n}\n\nfunction TimeStep(dt) {\n this.dt = 0;\n this.inv_dt = 0;\n this.velocityIterations = 0;\n this.positionIterations = 0;\n this.warmStarting = false;\n this.blockSolve = true;\n this.inv_dt0 = 0;\n this.dtRatio = 1;\n}\n\nTimeStep.prototype.reset = function(dt) {\n if (this.dt > 0) {\n this.inv_dt0 = this.inv_dt;\n }\n this.dt = dt;\n this.inv_dt = dt == 0 ? 0 : 1 / dt;\n this.dtRatio = dt * this.inv_dt0;\n};\n\nfunction Solver(world) {\n this.m_world = world;\n this.m_profile = new Profile();\n this.m_stack = [];\n this.m_bodies = [];\n this.m_contacts = [];\n this.m_joints = [];\n}\n\nSolver.prototype.clear = function() {\n this.m_stack.length = 0;\n this.m_bodies.length = 0;\n this.m_contacts.length = 0;\n this.m_joints.length = 0;\n};\n\nSolver.prototype.addBody = function(body) {\n ASSERT && common.assert(body instanceof Body, \"Not a Body!\", body);\n this.m_bodies.push(body);\n};\n\nSolver.prototype.addContact = function(contact) {\n ASSERT && common.assert(contact instanceof Contact, \"Not a Contact!\", contact);\n this.m_contacts.push(contact);\n};\n\nSolver.prototype.addJoint = function(joint) {\n ASSERT && common.assert(joint instanceof Joint, \"Not a Joint!\", joint);\n this.m_joints.push(joint);\n};\n\nSolver.prototype.solveWorld = function(step) {\n var world = this.m_world;\n var profile = this.m_profile;\n profile.solveInit = 0;\n profile.solveVelocity = 0;\n profile.solvePosition = 0;\n for (var b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n }\n for (var c = world.m_contactList; c; c = c.m_next) {\n c.m_islandFlag = false;\n }\n for (var j = world.m_jointList; j; j = j.m_next) {\n j.m_islandFlag = false;\n }\n var stack = this.m_stack;\n var loop = -1;\n for (var seed = world.m_bodyList; seed; seed = seed.m_next) {\n loop++;\n if (seed.m_islandFlag) {\n continue;\n }\n if (seed.isAwake() == false || seed.isActive() == false) {\n continue;\n }\n if (seed.isStatic()) {\n continue;\n }\n this.clear();\n stack.push(seed);\n seed.m_islandFlag = true;\n while (stack.length > 0) {\n var b = stack.pop();\n ASSERT && common.assert(b.isActive() == true);\n this.addBody(b);\n b.setAwake(true);\n if (b.isStatic()) {\n continue;\n }\n for (var ce = b.m_contactList; ce; ce = ce.next) {\n var contact = ce.contact;\n if (contact.m_islandFlag) {\n continue;\n }\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n continue;\n }\n var sensorA = contact.m_fixtureA.m_isSensor;\n var sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n this.addContact(contact);\n contact.m_islandFlag = true;\n var other = ce.other;\n if (other.m_islandFlag) {\n continue;\n }\n stack.push(other);\n other.m_islandFlag = true;\n }\n for (var je = b.m_jointList; je; je = je.next) {\n if (je.joint.m_islandFlag == true) {\n continue;\n }\n var other = je.other;\n if (other.isActive() == false) {\n continue;\n }\n this.addJoint(je.joint);\n je.joint.m_islandFlag = true;\n if (other.m_islandFlag) {\n continue;\n }\n stack.push(other);\n other.m_islandFlag = true;\n }\n }\n this.solveIsland(step);\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var b = this.m_bodies[i];\n if (b.isStatic()) {\n b.m_islandFlag = false;\n }\n }\n }\n};\n\nSolver.prototype.solveIsland = function(step) {\n var world = this.m_world;\n var profile = this.m_profile;\n var gravity = world.m_gravity;\n var allowSleep = world.m_allowSleep;\n var timer = Timer.now();\n var h = step.dt;\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n var c = Vec2.clone(body.m_sweep.c);\n var a = body.m_sweep.a;\n var v = Vec2.clone(body.m_linearVelocity);\n var w = body.m_angularVelocity;\n body.m_sweep.c0.set(body.m_sweep.c);\n body.m_sweep.a0 = body.m_sweep.a;\n DEBUG && common.debug(\"P: \", a, c.x, c.y, w, v.x, v.y);\n if (body.isDynamic()) {\n v.wAdd(h * body.m_gravityScale, gravity);\n v.wAdd(h * body.m_invMass, body.m_force);\n w += h * body.m_invI * body.m_torque;\n DEBUG && common.debug(\"N: \" + h, body.m_gravityScale, gravity.x, gravity.y, body.m_invMass, body.m_force.x, body.m_force.y);\n v.mul(1 / (1 + h * body.m_linearDamping));\n w *= 1 / (1 + h * body.m_angularDamping);\n }\n common.debug(\"A: \", a, c.x, c.y, w, v.x, v.y);\n body.c_position.c = c;\n body.c_position.a = a;\n body.c_velocity.v = v;\n body.c_velocity.w = w;\n }\n timer = Timer.now();\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initConstraint(step);\n }\n DEBUG && this.printBodies(\"M: \");\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initVelocityConstraint(step);\n }\n DEBUG && this.printBodies(\"R: \");\n if (step.warmStarting) {\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.warmStartConstraint(step);\n }\n }\n DEBUG && this.printBodies(\"Q: \");\n for (var i = 0; i < this.m_joints.length; ++i) {\n var joint = this.m_joints[i];\n joint.initVelocityConstraints(step);\n }\n DEBUG && this.printBodies(\"E: \");\n profile.solveInit = Timer.diff(timer);\n timer = Timer.now();\n for (var i = 0; i < step.velocityIterations; ++i) {\n DEBUG && common.debug(\"--\", i);\n for (var j = 0; j < this.m_joints.length; ++j) {\n var joint = this.m_joints[j];\n joint.solveVelocityConstraints(step);\n }\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n contact.solveVelocityConstraint(step);\n }\n }\n DEBUG && this.printBodies(\"D: \");\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.storeConstraintImpulses(step);\n }\n profile.solveVelocity = Timer.diff(timer);\n DEBUG && this.printBodies(\"C: \");\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n var c = Vec2.clone(body.c_position.c);\n var a = body.c_position.a;\n var v = Vec2.clone(body.c_velocity.v);\n var w = body.c_velocity.w;\n var translation = Vec2.mul(h, v);\n if (Vec2.lengthSquared(translation) > Settings.maxTranslationSquared) {\n var ratio = Settings.maxTranslation / translation.length();\n v.mul(ratio);\n }\n var rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n var ratio = Settings.maxRotation / Math.abs(rotation);\n w *= ratio;\n }\n c.wAdd(h, v);\n a += h * w;\n body.c_position.c.set(c);\n body.c_position.a = a;\n body.c_velocity.v.set(v);\n body.c_velocity.w = w;\n }\n DEBUG && this.printBodies(\"B: \");\n timer = Timer.now();\n var positionSolved = false;\n for (var i = 0; i < step.positionIterations; ++i) {\n var minSeparation = 0;\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n var separation = contact.solvePositionConstraint(step);\n minSeparation = Math.min(minSeparation, separation);\n }\n var contactsOkay = minSeparation >= -3 * Settings.linearSlop;\n var jointsOkay = true;\n for (var j = 0; j < this.m_joints.length; ++j) {\n var joint = this.m_joints[j];\n var jointOkay = joint.solvePositionConstraints(step);\n jointsOkay = jointsOkay && jointOkay;\n }\n if (contactsOkay && jointsOkay) {\n positionSolved = true;\n break;\n }\n }\n DEBUG && this.printBodies(\"L: \");\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.m_sweep.c.set(body.c_position.c);\n body.m_sweep.a = body.c_position.a;\n body.m_linearVelocity.set(body.c_velocity.v);\n body.m_angularVelocity = body.c_velocity.w;\n body.synchronizeTransform();\n }\n profile.solvePosition = Timer.diff(timer);\n this.postSolveIsland();\n if (allowSleep) {\n var minSleepTime = Infinity;\n var linTolSqr = Settings.linearSleepToleranceSqr;\n var angTolSqr = Settings.angularSleepToleranceSqr;\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n if (body.isStatic()) {\n continue;\n }\n if (body.m_autoSleepFlag == false || body.m_angularVelocity * body.m_angularVelocity > angTolSqr || Vec2.lengthSquared(body.m_linearVelocity) > linTolSqr) {\n body.m_sleepTime = 0;\n minSleepTime = 0;\n } else {\n body.m_sleepTime += h;\n minSleepTime = Math.min(minSleepTime, body.m_sleepTime);\n }\n }\n if (minSleepTime >= Settings.timeToSleep && positionSolved) {\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.setAwake(false);\n }\n }\n }\n};\n\nSolver.prototype.printBodies = function(tag) {\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var b = this.m_bodies[i];\n common.debug(tag, b.c_position.a, b.c_position.c.x, b.c_position.c.y, b.c_velocity.w, b.c_velocity.v.x, b.c_velocity.v.y);\n }\n};\n\nvar s_subStep = new TimeStep();\n\nSolver.prototype.solveWorldTOI = function(step) {\n DEBUG && common.debug(\"TOI++++++World\");\n var world = this.m_world;\n var profile = this.m_profile;\n DEBUG && common.debug(\"Z:\", world.m_stepComplete);\n if (world.m_stepComplete) {\n for (var b = world.m_bodyList; b; b = b.m_next) {\n b.m_islandFlag = false;\n b.m_sweep.alpha0 = 0;\n DEBUG && common.debug(\"b.alpha0:\", b.m_sweep.alpha0);\n }\n for (var c = world.m_contactList; c; c = c.m_next) {\n c.m_toiFlag = false;\n c.m_islandFlag = false;\n c.m_toiCount = 0;\n c.m_toi = 1;\n }\n }\n if (DEBUG) for (var c = world.m_contactList; c; c = c.m_next) {\n DEBUG && common.debug(\"X:\", c.m_toiFlag);\n }\n for (;;) {\n DEBUG && common.debug(\";;\");\n var minContact = null;\n var minAlpha = 1;\n for (var c = world.m_contactList; c; c = c.m_next) {\n DEBUG && common.debug(\"alpha0::\", c.getFixtureA().getBody().m_sweep.alpha0, c.getFixtureB().getBody().m_sweep.alpha0);\n if (c.isEnabled() == false) {\n continue;\n }\n DEBUG && common.debug(\"toiCount:\", c.m_toiCount, Settings.maxSubSteps);\n if (c.m_toiCount > Settings.maxSubSteps) {\n continue;\n }\n DEBUG && common.debug(\"toiFlag:\", c.m_toiFlag);\n var alpha = 1;\n if (c.m_toiFlag) {\n alpha = c.m_toi;\n } else {\n var fA = c.getFixtureA();\n var fB = c.getFixtureB();\n DEBUG && common.debug(\"sensor:\", fA.isSensor(), fB.isSensor());\n if (fA.isSensor() || fB.isSensor()) {\n continue;\n }\n var bA = fA.getBody();\n var bB = fB.getBody();\n ASSERT && common.assert(bA.isDynamic() || bB.isDynamic());\n var activeA = bA.isAwake() && !bA.isStatic();\n var activeB = bB.isAwake() && !bB.isStatic();\n DEBUG && common.debug(\"awakestatic:\", bA.isAwake(), bA.isStatic());\n DEBUG && common.debug(\"awakestatic:\", bB.isAwake(), bB.isStatic());\n DEBUG && common.debug(\"active:\", activeA, activeB);\n if (activeA == false && activeB == false) {\n continue;\n }\n DEBUG && common.debug(\"alpha:\", alpha, bA.m_sweep.alpha0, bB.m_sweep.alpha0);\n var collideA = bA.isBullet() || !bA.isDynamic();\n var collideB = bB.isBullet() || !bB.isDynamic();\n DEBUG && common.debug(\"collide:\", collideA, collideB);\n if (collideA == false && collideB == false) {\n continue;\n }\n var alpha0 = bA.m_sweep.alpha0;\n if (bA.m_sweep.alpha0 < bB.m_sweep.alpha0) {\n alpha0 = bB.m_sweep.alpha0;\n bA.m_sweep.advance(alpha0);\n } else if (bB.m_sweep.alpha0 < bA.m_sweep.alpha0) {\n alpha0 = bA.m_sweep.alpha0;\n bB.m_sweep.advance(alpha0);\n }\n DEBUG && common.debug(\"alpha0:\", alpha0, bA.m_sweep.alpha0, bB.m_sweep.alpha0);\n ASSERT && common.assert(alpha0 < 1);\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n var sweepA = bA.m_sweep;\n var sweepB = bB.m_sweep;\n DEBUG && common.debug(\"sweepA\", sweepA.localCenter.x, sweepA.localCenter.y, sweepA.c.x, sweepA.c.y, sweepA.a, sweepA.alpha0, sweepA.c0.x, sweepA.c0.y, sweepA.a0);\n DEBUG && common.debug(\"sweepB\", sweepB.localCenter.x, sweepB.localCenter.y, sweepB.c.x, sweepB.c.y, sweepB.a, sweepB.alpha0, sweepB.c0.x, sweepB.c0.y, sweepB.a0);\n var input = new TOIInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.sweepA.set(bA.m_sweep);\n input.sweepB.set(bB.m_sweep);\n input.tMax = 1;\n var output = new TOIOutput();\n TimeOfImpact(output, input);\n var beta = output.t;\n DEBUG && common.debug(\"state:\", output.state, TOIOutput.e_touching);\n if (output.state == TOIOutput.e_touching) {\n alpha = Math.min(alpha0 + (1 - alpha0) * beta, 1);\n } else {\n alpha = 1;\n }\n c.m_toi = alpha;\n c.m_toiFlag = true;\n }\n DEBUG && common.debug(\"minAlpha:\", minAlpha, alpha);\n if (alpha < minAlpha) {\n minContact = c;\n minAlpha = alpha;\n }\n }\n DEBUG && common.debug(\"minContact:\", minContact == null, 1 - 10 * Math.EPSILON < minAlpha, minAlpha);\n if (minContact == null || 1 - 10 * Math.EPSILON < minAlpha) {\n world.m_stepComplete = true;\n break;\n }\n var fA = minContact.getFixtureA();\n var fB = minContact.getFixtureB();\n var bA = fA.getBody();\n var bB = fB.getBody();\n var backup1 = bA.m_sweep.clone();\n var backup2 = bB.m_sweep.clone();\n bA.advance(minAlpha);\n bB.advance(minAlpha);\n minContact.update(world);\n minContact.m_toiFlag = false;\n ++minContact.m_toiCount;\n if (minContact.isEnabled() == false || minContact.isTouching() == false) {\n minContact.setEnabled(false);\n bA.m_sweep.set(backup1);\n bB.m_sweep.set(backup2);\n bA.synchronizeTransform();\n bB.synchronizeTransform();\n continue;\n }\n bA.setAwake(true);\n bB.setAwake(true);\n this.clear();\n this.addBody(bA);\n this.addBody(bB);\n this.addContact(minContact);\n bA.m_islandFlag = true;\n bB.m_islandFlag = true;\n minContact.m_islandFlag = true;\n var bodies = [ bA, bB ];\n for (var i = 0; i < bodies.length; ++i) {\n var body = bodies[i];\n if (body.isDynamic()) {\n for (var ce = body.m_contactList; ce; ce = ce.next) {\n var contact = ce.contact;\n if (contact.m_islandFlag) {\n continue;\n }\n var other = ce.other;\n if (other.isDynamic() && !body.isBullet() && !other.isBullet()) {\n continue;\n }\n var sensorA = contact.m_fixtureA.m_isSensor;\n var sensorB = contact.m_fixtureB.m_isSensor;\n if (sensorA || sensorB) {\n continue;\n }\n var backup = other.m_sweep.clone();\n if (other.m_islandFlag == false) {\n other.advance(minAlpha);\n }\n contact.update(world);\n if (contact.isEnabled() == false || contact.isTouching() == false) {\n other.m_sweep.set(backup);\n other.synchronizeTransform();\n continue;\n }\n contact.m_islandFlag = true;\n this.addContact(contact);\n if (other.m_islandFlag) {\n continue;\n }\n other.m_islandFlag = true;\n if (!other.isStatic()) {\n other.setAwake(true);\n }\n this.addBody(other);\n }\n }\n }\n s_subStep.reset((1 - minAlpha) * step.dt);\n s_subStep.dtRatio = 1;\n s_subStep.positionIterations = 20;\n s_subStep.velocityIterations = step.velocityIterations;\n s_subStep.warmStarting = false;\n this.solveIslandTOI(s_subStep, bA, bB);\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.m_islandFlag = false;\n if (!body.isDynamic()) {\n continue;\n }\n body.synchronizeFixtures();\n for (var ce = body.m_contactList; ce; ce = ce.next) {\n ce.contact.m_toiFlag = false;\n ce.contact.m_islandFlag = false;\n }\n }\n world.findNewContacts();\n if (world.m_subStepping) {\n world.m_stepComplete = false;\n break;\n }\n }\n if (DEBUG) for (var b = world.m_bodyList; b; b = b.m_next) {\n var c = b.m_sweep.c;\n var a = b.m_sweep.a;\n var v = b.m_linearVelocity;\n var w = b.m_angularVelocity;\n DEBUG && common.debug(\"== \", a, c.x, c.y, w, v.x, v.y);\n }\n};\n\nSolver.prototype.solveIslandTOI = function(subStep, toiA, toiB) {\n DEBUG && common.debug(\"TOI++++++Island\");\n var world = this.m_world;\n var profile = this.m_profile;\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n body.c_position.c.set(body.m_sweep.c);\n body.c_position.a = body.m_sweep.a;\n body.c_velocity.v.set(body.m_linearVelocity);\n body.c_velocity.w = body.m_angularVelocity;\n }\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initConstraint(subStep);\n }\n for (var i = 0; i < subStep.positionIterations; ++i) {\n var minSeparation = 0;\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n var separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);\n minSeparation = Math.min(minSeparation, separation);\n }\n var contactsOkay = minSeparation >= -1.5 * Settings.linearSlop;\n if (contactsOkay) {\n break;\n }\n }\n if (false) {\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var c = this.m_contacts[i];\n var fA = c.getFixtureA();\n var fB = c.getFixtureB();\n var bA = fA.getBody();\n var bB = fB.getBody();\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n var input = new DistanceInput();\n input.proxyA.set(fA.getShape(), indexA);\n input.proxyB.set(fB.getShape(), indexB);\n input.transformA = bA.getTransform();\n input.transformB = bB.getTransform();\n input.useRadii = false;\n var output = new DistanceOutput();\n var cache = new SimplexCache();\n Distance(output, cache, input);\n if (output.distance == 0 || cache.count == 3) {\n cache.count += 0;\n }\n }\n }\n toiA.m_sweep.c0.set(toiA.c_position.c);\n toiA.m_sweep.a0 = toiA.c_position.a;\n toiB.m_sweep.c0.set(toiB.c_position.c);\n toiB.m_sweep.a0 = toiB.c_position.a;\n for (var i = 0; i < this.m_contacts.length; ++i) {\n var contact = this.m_contacts[i];\n contact.initVelocityConstraint(subStep);\n }\n for (var i = 0; i < subStep.velocityIterations; ++i) {\n for (var j = 0; j < this.m_contacts.length; ++j) {\n var contact = this.m_contacts[j];\n contact.solveVelocityConstraint(subStep);\n }\n }\n var h = subStep.dt;\n for (var i = 0; i < this.m_bodies.length; ++i) {\n var body = this.m_bodies[i];\n var c = Vec2.clone(body.c_position.c);\n var a = body.c_position.a;\n var v = Vec2.clone(body.c_velocity.v);\n var w = body.c_velocity.w;\n var translation = Vec2.mul(h, v);\n if (Vec2.dot(translation, translation) > Settings.maxTranslationSquared) {\n var ratio = Settings.maxTranslation / translation.length();\n v.mul(ratio);\n }\n var rotation = h * w;\n if (rotation * rotation > Settings.maxRotationSquared) {\n var ratio = Settings.maxRotation / Math.abs(rotation);\n w *= ratio;\n }\n c.wAdd(h, v);\n a += h * w;\n body.c_position.c = c;\n body.c_position.a = a;\n body.c_velocity.v = v;\n body.c_velocity.w = w;\n body.m_sweep.c = c;\n body.m_sweep.a = a;\n body.m_linearVelocity = v;\n body.m_angularVelocity = w;\n body.synchronizeTransform();\n }\n this.postSolveIsland();\n DEBUG && common.debug(\"TOI------Island\");\n};\n\nfunction ContactImpulse() {\n this.normalImpulses = [];\n this.tangentImpulses = [];\n}\n\nSolver.prototype.postSolveIsland = function() {\n var impulse = new ContactImpulse();\n for (var c = 0; c < this.m_contacts.length; ++c) {\n var contact = this.m_contacts[c];\n for (var p = 0; p < contact.v_points.length; ++p) {\n impulse.normalImpulses.push(contact.v_points[p].normalImpulse);\n impulse.tangentImpulses.push(contact.v_points[p].tangentImpulse);\n }\n this.m_world.postSolve(contact, impulse);\n }\n};\n\n\n},{\"./Body\":2,\"./Contact\":3,\"./Joint\":5,\"./Settings\":7,\"./collision/Distance\":13,\"./collision/TimeOfImpact\":15,\"./common/Math\":18,\"./common/Vec2\":23,\"./util/Timer\":50,\"./util/common\":51}],10:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = World;\n\nvar options = require(\"./util/options\");\n\nvar common = require(\"./util/common\");\n\nvar Timer = require(\"./util/Timer\");\n\nvar Vec2 = require(\"./common/Vec2\");\n\nvar BroadPhase = require(\"./collision/BroadPhase\");\n\nvar Solver = require(\"./Solver\");\n\nvar Body = require(\"./Body\");\n\nvar Contact = require(\"./Contact\");\n\nvar WorldDef = {\n gravity: Vec2.zero(),\n allowSleep: true,\n warmStarting: true,\n continuousPhysics: true,\n subStepping: false,\n blockSolve: true,\n velocityIterations: 8,\n positionIterations: 3\n};\n\nfunction World(def) {\n if (!(this instanceof World)) {\n return new World(def);\n }\n if (def && Vec2.isValid(def)) {\n def = {\n gravity: def\n };\n }\n def = options(def, WorldDef);\n this.m_solver = new Solver(this);\n this.m_broadPhase = new BroadPhase();\n this.m_contactList = null;\n this.m_contactCount = 0;\n this.m_bodyList = null;\n this.m_bodyCount = 0;\n this.m_jointList = null;\n this.m_jointCount = 0;\n this.m_stepComplete = true;\n this.m_allowSleep = def.allowSleep;\n this.m_gravity = Vec2.clone(def.gravity);\n this.m_clearForces = true;\n this.m_newFixture = false;\n this.m_locked = false;\n this.m_warmStarting = def.warmStarting;\n this.m_continuousPhysics = def.continuousPhysics;\n this.m_subStepping = def.subStepping;\n this.m_blockSolve = def.blockSolve;\n this.m_velocityIterations = def.velocityIterations;\n this.m_positionIterations = def.positionIterations;\n this.m_t = 0;\n this.m_stepCount = 0;\n this.addPair = this.createContact.bind(this);\n}\n\nWorld.prototype.getBodyList = function() {\n return this.m_bodyList;\n};\n\nWorld.prototype.getJointList = function() {\n return this.m_jointList;\n};\n\nWorld.prototype.getContactList = function() {\n return this.m_contactList;\n};\n\nWorld.prototype.getBodyCount = function() {\n return this.m_bodyCount;\n};\n\nWorld.prototype.getJointCount = function() {\n return this.m_jointCount;\n};\n\nWorld.prototype.getContactCount = function() {\n return this.m_contactCount;\n};\n\nWorld.prototype.setGravity = function(gravity) {\n this.m_gravity = gravity;\n};\n\nWorld.prototype.getGravity = function() {\n return this.m_gravity;\n};\n\nWorld.prototype.isLocked = function() {\n return this.m_locked;\n};\n\nWorld.prototype.setAllowSleeping = function(flag) {\n if (flag == this.m_allowSleep) {\n return;\n }\n this.m_allowSleep = flag;\n if (this.m_allowSleep == false) {\n for (var b = this.m_bodyList; b; b = b.m_next) {\n b.setAwake(true);\n }\n }\n};\n\nWorld.prototype.getAllowSleeping = function() {\n return this.m_allowSleep;\n};\n\nWorld.prototype.setWarmStarting = function(flag) {\n this.m_warmStarting = flag;\n};\n\nWorld.prototype.getWarmStarting = function() {\n return this.m_warmStarting;\n};\n\nWorld.prototype.setContinuousPhysics = function(flag) {\n this.m_continuousPhysics = flag;\n};\n\nWorld.prototype.getContinuousPhysics = function() {\n return this.m_continuousPhysics;\n};\n\nWorld.prototype.setSubStepping = function(flag) {\n this.m_subStepping = flag;\n};\n\nWorld.prototype.getSubStepping = function() {\n return this.m_subStepping;\n};\n\nWorld.prototype.setAutoClearForces = function(flag) {\n this.m_clearForces = flag;\n};\n\nWorld.prototype.getAutoClearForces = function() {\n return this.m_clearForces;\n};\n\nWorld.prototype.clearForces = function() {\n for (var body = this.m_bodyList; body; body = body.getNext()) {\n body.m_force.setZero();\n body.m_torque = 0;\n }\n};\n\nWorld.prototype.queryAABB = function(aabb, queryCallback) {\n ASSERT && common.assert(typeof queryCallback === \"function\");\n var broadPhase = this.m_broadPhase;\n this.m_broadPhase.query(aabb, function(proxyId) {\n var proxy = broadPhase.getUserData(proxyId);\n return queryCallback(proxy.fixture);\n });\n};\n\nWorld.prototype.rayCast = function(point1, point2, reportFixtureCallback) {\n ASSERT && common.assert(typeof reportFixtureCallback === \"function\");\n var broadPhase = this.m_broadPhase;\n this.m_broadPhase.rayCast({\n maxFraction: 1,\n p1: point1,\n p2: point2\n }, function(input, proxyId) {\n var proxy = broadPhase.getUserData(proxyId);\n var fixture = proxy.fixture;\n var index = proxy.childIndex;\n var output = {};\n var hit = fixture.rayCast(output, input, index);\n if (hit) {\n var fraction = output.fraction;\n var point = Vec2.add(Vec2.mul(1 - fraction, input.p1), Vec2.mul(fraction, input.p2));\n return reportFixtureCallback(fixture, point, output.normal, fraction);\n }\n return input.maxFraction;\n });\n};\n\nWorld.prototype.getProxyCount = function() {\n return this.m_broadPhase.getProxyCount();\n};\n\nWorld.prototype.getTreeHeight = function() {\n return this.m_broadPhase.getTreeHeight();\n};\n\nWorld.prototype.getTreeBalance = function() {\n return this.m_broadPhase.getTreeBalance();\n};\n\nWorld.prototype.getTreeQuality = function() {\n return this.m_broadPhase.getTreeQuality();\n};\n\nWorld.prototype.shiftOrigin = function(newOrigin) {\n ASSERT && common.assert(this.m_locked == false);\n if (this.m_locked) {\n return;\n }\n for (var b = this.m_bodyList; b; b = b.m_next) {\n b.m_xf.p.sub(newOrigin);\n b.m_sweep.c0.sub(newOrigin);\n b.m_sweep.c.sub(newOrigin);\n }\n for (var j = this.m_jointList; j; j = j.m_next) {\n j.shiftOrigin(newOrigin);\n }\n this.m_broadPhase.shiftOrigin(newOrigin);\n};\n\nWorld.prototype.createBody = function(def, angle) {\n ASSERT && common.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n if (def && Vec2.isValid(def)) {\n def = {\n position: def,\n angle: angle\n };\n }\n var body = new Body(this, def);\n body.m_prev = null;\n body.m_next = this.m_bodyList;\n if (this.m_bodyList) {\n this.m_bodyList.m_prev = body;\n }\n this.m_bodyList = body;\n ++this.m_bodyCount;\n return body;\n};\n\nWorld.prototype.createDynamicBody = function(def, angle) {\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = {\n position: def,\n angle: angle\n };\n }\n def.type = \"dynamic\";\n return this.createBody(def);\n};\n\nWorld.prototype.createKinematicBody = function(def, angle) {\n if (!def) {\n def = {};\n } else if (Vec2.isValid(def)) {\n def = {\n position: def,\n angle: angle\n };\n }\n def.type = \"kinematic\";\n return this.createBody(def);\n};\n\nWorld.prototype.destroyBody = function(b) {\n ASSERT && common.assert(this.m_bodyCount > 0);\n ASSERT && common.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n if (b.m_destroyed) {\n return false;\n }\n var je = b.m_jointList;\n while (je) {\n var je0 = je;\n je = je.next;\n this.publish(\"remove-joint\", je0.joint);\n this.destroyJoint(je0.joint);\n b.m_jointList = je;\n }\n b.m_jointList = null;\n var ce = b.m_contactList;\n while (ce) {\n var ce0 = ce;\n ce = ce.next;\n this.destroyContact(ce0.contact);\n b.m_contactList = ce;\n }\n b.m_contactList = null;\n var f = b.m_fixtureList;\n while (f) {\n var f0 = f;\n f = f.m_next;\n this.publish(\"remove-fixture\", f0);\n f0.destroyProxies(this.m_broadPhase);\n b.m_fixtureList = f;\n }\n b.m_fixtureList = null;\n if (b.m_prev) {\n b.m_prev.m_next = b.m_next;\n }\n if (b.m_next) {\n b.m_next.m_prev = b.m_prev;\n }\n if (b == this.m_bodyList) {\n this.m_bodyList = b.m_next;\n }\n b.m_destroyed = true;\n --this.m_bodyCount;\n return true;\n};\n\nWorld.prototype.createJoint = function(joint) {\n ASSERT && common.assert(!!joint.m_bodyA);\n ASSERT && common.assert(!!joint.m_bodyB);\n ASSERT && common.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return null;\n }\n joint.m_prev = null;\n joint.m_next = this.m_jointList;\n if (this.m_jointList) {\n this.m_jointList.m_prev = joint;\n }\n this.m_jointList = joint;\n ++this.m_jointCount;\n joint.m_edgeA.joint = joint;\n joint.m_edgeA.other = joint.m_bodyB;\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = joint.m_bodyA.m_jointList;\n if (joint.m_bodyA.m_jointList) joint.m_bodyA.m_jointList.prev = joint.m_edgeA;\n joint.m_bodyA.m_jointList = joint.m_edgeA;\n joint.m_edgeB.joint = joint;\n joint.m_edgeB.other = joint.m_bodyA;\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = joint.m_bodyB.m_jointList;\n if (joint.m_bodyB.m_jointList) joint.m_bodyB.m_jointList.prev = joint.m_edgeB;\n joint.m_bodyB.m_jointList = joint.m_edgeB;\n if (joint.m_collideConnected == false) {\n for (var edge = joint.m_bodyB.getContactList(); edge; edge = edge.next) {\n if (edge.other == joint.m_bodyA) {\n edge.contact.flagForFiltering();\n }\n }\n }\n return joint;\n};\n\nWorld.prototype.destroyJoint = function(joint) {\n ASSERT && common.assert(this.isLocked() == false);\n if (this.isLocked()) {\n return;\n }\n if (joint.m_prev) {\n joint.m_prev.m_next = joint.m_next;\n }\n if (joint.m_next) {\n joint.m_next.m_prev = joint.m_prev;\n }\n if (joint == this.m_jointList) {\n this.m_jointList = joint.m_next;\n }\n var bodyA = joint.m_bodyA;\n var bodyB = joint.m_bodyB;\n bodyA.setAwake(true);\n bodyB.setAwake(true);\n if (joint.m_edgeA.prev) {\n joint.m_edgeA.prev.next = joint.m_edgeA.next;\n }\n if (joint.m_edgeA.next) {\n joint.m_edgeA.next.prev = joint.m_edgeA.prev;\n }\n if (joint.m_edgeA == bodyA.m_jointList) {\n bodyA.m_jointList = joint.m_edgeA.next;\n }\n joint.m_edgeA.prev = null;\n joint.m_edgeA.next = null;\n if (joint.m_edgeB.prev) {\n joint.m_edgeB.prev.next = joint.m_edgeB.next;\n }\n if (joint.m_edgeB.next) {\n joint.m_edgeB.next.prev = joint.m_edgeB.prev;\n }\n if (joint.m_edgeB == bodyB.m_jointList) {\n bodyB.m_jointList = joint.m_edgeB.next;\n }\n joint.m_edgeB.prev = null;\n joint.m_edgeB.next = null;\n ASSERT && common.assert(this.m_jointCount > 0);\n --this.m_jointCount;\n if (joint.m_collideConnected == false) {\n var edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n edge.contact.flagForFiltering();\n }\n edge = edge.next;\n }\n }\n this.publish(\"remove-joint\", joint);\n};\n\nvar s_step = new Solver.TimeStep();\n\nWorld.prototype.step = function(timeStep, velocityIterations, positionIterations) {\n if ((velocityIterations | 0) !== velocityIterations) {\n velocityIterations = 0;\n }\n velocityIterations = velocityIterations || this.m_velocityIterations;\n positionIterations = positionIterations || this.m_positionIterations;\n this.m_stepCount++;\n if (this.m_newFixture) {\n this.findNewContacts();\n this.m_newFixture = false;\n }\n this.m_locked = true;\n s_step.reset(timeStep);\n s_step.velocityIterations = velocityIterations;\n s_step.positionIterations = positionIterations;\n s_step.warmStarting = this.m_warmStarting;\n s_step.blockSolve = this.m_blockSolve;\n this.updateContacts();\n if (this.m_stepComplete && timeStep > 0) {\n this.m_solver.solveWorld(s_step);\n for (var b = this.m_bodyList; b; b = b.getNext()) {\n if (b.m_islandFlag == false) {\n continue;\n }\n if (b.isStatic()) {\n continue;\n }\n b.synchronizeFixtures();\n }\n this.findNewContacts();\n }\n if (this.m_continuousPhysics && timeStep > 0) {\n this.m_solver.solveWorldTOI(s_step);\n }\n if (this.m_clearForces) {\n this.clearForces();\n }\n this.m_locked = false;\n};\n\nWorld.prototype.findNewContacts = function() {\n this.m_broadPhase.updatePairs(this.addPair);\n};\n\nWorld.prototype.createContact = function(proxyA, proxyB) {\n var fixtureA = proxyA.fixture;\n var fixtureB = proxyB.fixture;\n var indexA = proxyA.childIndex;\n var indexB = proxyB.childIndex;\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n if (bodyA == bodyB) {\n return;\n }\n var edge = bodyB.getContactList();\n while (edge) {\n if (edge.other == bodyA) {\n var fA = edge.contact.getFixtureA();\n var fB = edge.contact.getFixtureB();\n var iA = edge.contact.getChildIndexA();\n var iB = edge.contact.getChildIndexB();\n if (fA == fixtureA && fB == fixtureB && iA == indexA && iB == indexB) {\n return;\n }\n if (fA == fixtureB && fB == fixtureA && iA == indexB && iB == indexA) {\n return;\n }\n }\n edge = edge.next;\n }\n if (bodyB.shouldCollide(bodyA) == false) {\n return;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n return;\n }\n var contact = Contact.create(fixtureA, indexA, fixtureB, indexB);\n if (contact == null) {\n return;\n }\n contact.m_prev = null;\n if (this.m_contactList != null) {\n contact.m_next = this.m_contactList;\n this.m_contactList.m_prev = contact;\n }\n this.m_contactList = contact;\n ++this.m_contactCount;\n};\n\nWorld.prototype.updateContacts = function() {\n var c, next_c = this.m_contactList;\n while (c = next_c) {\n next_c = c.getNext();\n var fixtureA = c.getFixtureA();\n var fixtureB = c.getFixtureB();\n var indexA = c.getChildIndexA();\n var indexB = c.getChildIndexB();\n var bodyA = fixtureA.getBody();\n var bodyB = fixtureB.getBody();\n if (c.m_filterFlag) {\n if (bodyB.shouldCollide(bodyA) == false) {\n this.destroyContact(c);\n continue;\n }\n if (fixtureB.shouldCollide(fixtureA) == false) {\n this.destroyContact(c);\n continue;\n }\n c.m_filterFlag = false;\n }\n var activeA = bodyA.isAwake() && !bodyA.isStatic();\n var activeB = bodyB.isAwake() && !bodyB.isStatic();\n if (activeA == false && activeB == false) {\n continue;\n }\n var proxyIdA = fixtureA.m_proxies[indexA].proxyId;\n var proxyIdB = fixtureB.m_proxies[indexB].proxyId;\n var overlap = this.m_broadPhase.testOverlap(proxyIdA, proxyIdB);\n if (overlap == false) {\n this.destroyContact(c);\n continue;\n }\n c.update(this);\n }\n};\n\nWorld.prototype.destroyContact = function(contact) {\n Contact.destroy(contact, this);\n if (contact.m_prev) {\n contact.m_prev.m_next = contact.m_next;\n }\n if (contact.m_next) {\n contact.m_next.m_prev = contact.m_prev;\n }\n if (contact == this.m_contactList) {\n this.m_contactList = contact.m_next;\n }\n --this.m_contactCount;\n};\n\nWorld.prototype._listeners = null;\n\nWorld.prototype.on = function(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n if (!this._listeners) {\n this._listeners = {};\n }\n if (!this._listeners[name]) {\n this._listeners[name] = [];\n }\n this._listeners[name].push(listener);\n return this;\n};\n\nWorld.prototype.off = function(name, listener) {\n if (typeof name !== \"string\" || typeof listener !== \"function\") {\n return this;\n }\n var listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return this;\n }\n var index = listeners.indexOf(listener);\n if (index >= 0) {\n listeners.splice(index, 1);\n }\n return this;\n};\n\nWorld.prototype.publish = function(name, arg1, arg2, arg3) {\n var listeners = this._listeners && this._listeners[name];\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].call(this, arg1, arg2, arg3);\n }\n return listeners.length;\n};\n\nWorld.prototype.beginContact = function(contact) {\n this.publish(\"begin-contact\", contact);\n};\n\nWorld.prototype.endContact = function(contact) {\n this.publish(\"end-contact\", contact);\n};\n\nWorld.prototype.preSolve = function(contact, oldManifold) {\n this.publish(\"pre-solve\", contact, oldManifold);\n};\n\nWorld.prototype.postSolve = function(contact, impulse) {\n this.publish(\"post-solve\", contact, impulse);\n};\n\n\n},{\"./Body\":2,\"./Contact\":3,\"./Solver\":9,\"./collision/BroadPhase\":12,\"./common/Vec2\":23,\"./util/Timer\":50,\"./util/common\":51,\"./util/options\":53}],11:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nmodule.exports = AABB;\n\nfunction AABB(lower, upper) {\n if (!(this instanceof AABB)) {\n return new AABB(lower, upper);\n }\n this.lowerBound = Vec2.zero();\n this.upperBound = Vec2.zero();\n if (typeof lower === \"object\") {\n this.lowerBound.set(lower);\n }\n if (typeof upper === \"object\") {\n this.upperBound.set(upper);\n }\n}\n\nAABB.prototype.isValid = function() {\n return AABB.isValid(this);\n};\n\nAABB.isValid = function(aabb) {\n var d = Vec2.sub(aabb.upperBound, aabb.lowerBound);\n var valid = d.x >= 0 && d.y >= 0 && Vec2.isValid(aabb.lowerBound) && Vec2.isValid(aabb.upperBound);\n return valid;\n};\n\nAABB.prototype.getCenter = function() {\n return Vec2.neo((this.lowerBound.x + this.upperBound.x) * .5, (this.lowerBound.y + this.upperBound.y) * .5);\n};\n\nAABB.prototype.getExtents = function() {\n return Vec2.neo((this.upperBound.x - this.lowerBound.x) * .5, (this.upperBound.y - this.lowerBound.y) * .5);\n};\n\nAABB.prototype.getPerimeter = function() {\n return 2 * (this.upperBound.x - this.lowerBound.x + this.upperBound.y - this.lowerBound.y);\n};\n\nAABB.prototype.combine = function(a, b) {\n b = b || this;\n this.lowerBound.set(Math.min(a.lowerBound.x, b.lowerBound.x), Math.min(a.lowerBound.y, b.lowerBound.y));\n this.upperBound.set(Math.max(a.upperBound.x, b.upperBound.x), Math.max(a.upperBound.y, b.upperBound.y));\n};\n\nAABB.prototype.combinePoints = function(a, b) {\n this.lowerBound.set(Math.min(a.x, b.x), Math.min(a.y, b.y));\n this.upperBound.set(Math.max(a.x, b.x), Math.max(a.y, b.y));\n};\n\nAABB.prototype.set = function(aabb) {\n this.lowerBound.set(aabb.lowerBound.x, aabb.lowerBound.y);\n this.upperBound.set(aabb.upperBound.x, aabb.upperBound.y);\n};\n\nAABB.prototype.contains = function(aabb) {\n var result = true;\n result = result && this.lowerBound.x <= aabb.lowerBound.x;\n result = result && this.lowerBound.y <= aabb.lowerBound.y;\n result = result && aabb.upperBound.x <= this.upperBound.x;\n result = result && aabb.upperBound.y <= this.upperBound.y;\n return result;\n};\n\nAABB.prototype.extend = function(value) {\n AABB.extend(this, value);\n};\n\nAABB.extend = function(aabb, value) {\n aabb.lowerBound.x -= value;\n aabb.lowerBound.y -= value;\n aabb.upperBound.x += value;\n aabb.upperBound.y += value;\n};\n\nAABB.testOverlap = function(a, b) {\n var d1x = b.lowerBound.x - a.upperBound.x;\n var d2x = a.lowerBound.x - b.upperBound.x;\n var d1y = b.lowerBound.y - a.upperBound.y;\n var d2y = a.lowerBound.y - b.upperBound.y;\n if (d1x > 0 || d1y > 0 || d2x > 0 || d2y > 0) {\n return false;\n }\n return true;\n};\n\nAABB.areEqual = function(a, b) {\n return Vec2.areEqual(a.lowerBound, b.lowerBound) && Vec2.areEqual(a.upperBound, b.upperBound);\n};\n\nAABB.diff = function(a, b) {\n var wD = Math.max(0, Math.min(a.upperBound.x, b.upperBound.x) - Math.max(b.lowerBound.x, a.lowerBound.x));\n var hD = Math.max(0, Math.min(a.upperBound.y, b.upperBound.y) - Math.max(b.lowerBound.y, a.lowerBound.y));\n var wA = a.upperBound.x - a.lowerBound.x;\n var hA = a.upperBound.y - a.lowerBound.y;\n var hB = b.upperBound.y - b.lowerBound.y;\n var hB = b.upperBound.y - b.lowerBound.y;\n return wA * hA + wB * hB - wD * hD;\n};\n\nAABB.prototype.rayCast = function(output, input) {\n var tmin = -Infinity;\n var tmax = Infinity;\n var p = input.p1;\n var d = Vec2.sub(input.p2, input.p1);\n var absD = Vec2.abs(d);\n var normal = Vec2.zero();\n for (var f = \"x\"; f !== null; f = f === \"x\" ? \"y\" : null) {\n if (absD.x < Math.EPSILON) {\n if (p[f] < this.lowerBound[f] || this.upperBound[f] < p[f]) {\n return false;\n }\n } else {\n var inv_d = 1 / d[f];\n var t1 = (this.lowerBound[f] - p[f]) * inv_d;\n var t2 = (this.upperBound[f] - p[f]) * inv_d;\n var s = -1;\n if (t1 > t2) {\n var temp = t1;\n t1 = t2, t2 = temp;\n s = 1;\n }\n if (t1 > tmin) {\n normal.setZero();\n normal[f] = s;\n tmin = t1;\n }\n tmax = Math.min(tmax, t2);\n if (tmin > tmax) {\n return false;\n }\n }\n }\n if (tmin < 0 || input.maxFraction < tmin) {\n return false;\n }\n output.fraction = tmin;\n output.normal = normal;\n return true;\n};\n\nAABB.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\n\n},{\"../Settings\":7,\"../common/Math\":18,\"../common/Vec2\":23}],12:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar Settings = require(\"../Settings\");\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"../common/Math\");\n\nvar AABB = require(\"./AABB\");\n\nvar DynamicTree = require(\"./DynamicTree\");\n\nmodule.exports = BroadPhase;\n\nfunction BroadPhase() {\n this.m_tree = new DynamicTree();\n this.m_proxyCount = 0;\n this.m_moveBuffer = [];\n this.queryCallback = this.queryCallback.bind(this);\n}\n\nBroadPhase.prototype.getUserData = function(proxyId) {\n return this.m_tree.getUserData(proxyId);\n};\n\nBroadPhase.prototype.testOverlap = function(proxyIdA, proxyIdB) {\n var aabbA = this.m_tree.getFatAABB(proxyIdA);\n var aabbB = this.m_tree.getFatAABB(proxyIdB);\n return AABB.testOverlap(aabbA, aabbB);\n};\n\nBroadPhase.prototype.getFatAABB = function(proxyId) {\n return this.m_tree.getFatAABB(proxyId);\n};\n\nBroadPhase.prototype.getProxyCount = function() {\n return this.m_proxyCount;\n};\n\nBroadPhase.prototype.getTreeHeight = function() {\n return this.m_tree.getHeight();\n};\n\nBroadPhase.prototype.getTreeBalance = function() {\n return this.m_tree.getMaxBalance();\n};\n\nBroadPhase.prototype.getTreeQuality = function() {\n return this.m_tree.getAreaRatio();\n};\n\nBroadPhase.prototype.query = function(aabb, queryCallback) {\n this.m_tree.query(aabb, queryCallback);\n};\n\nBroadPhase.prototype.rayCast = function(input, rayCastCallback) {\n this.m_tree.rayCast(input, rayCastCallback);\n};\n\nBroadPhase.prototype.shiftOrigin = function(newOrigin) {\n this.m_tree.shiftOrigin(newOrigin);\n};\n\nBroadPhase.prototype.createProxy = function(aabb, userData) {\n ASSERT && common.assert(AABB.isValid(aabb));\n var proxyId = this.m_tree.createProxy(aabb, userData);\n this.m_proxyCount++;\n this.bufferMove(proxyId);\n return proxyId;\n};\n\nBroadPhase.prototype.destroyProxy = function(proxyId) {\n this.unbufferMove(proxyId);\n this.m_proxyCount--;\n this.m_tree.destroyProxy(proxyId);\n};\n\nBroadPhase.prototype.moveProxy = function(proxyId, aabb, displacement) {\n ASSERT && common.assert(AABB.isValid(aabb));\n var changed = this.m_tree.moveProxy(proxyId, aabb, displacement);\n if (changed) {\n this.bufferMove(proxyId);\n }\n};\n\nBroadPhase.prototype.touchProxy = function(proxyId) {\n this.bufferMove(proxyId);\n};\n\nBroadPhase.prototype.bufferMove = function(proxyId) {\n this.m_moveBuffer.push(proxyId);\n};\n\nBroadPhase.prototype.unbufferMove = function(proxyId) {\n for (var i = 0; i < this.m_moveBuffer.length; ++i) {\n if (this.m_moveBuffer[i] == proxyId) {\n this.m_moveBuffer[i] = null;\n }\n }\n};\n\nBroadPhase.prototype.updatePairs = function(addPairCallback) {\n ASSERT && common.assert(typeof addPairCallback === \"function\");\n this.m_callback = addPairCallback;\n while (this.m_moveBuffer.length > 0) {\n this.m_queryProxyId = this.m_moveBuffer.pop();\n if (this.m_queryProxyId === null) {\n continue;\n }\n var fatAABB = this.m_tree.getFatAABB(this.m_queryProxyId);\n this.m_tree.query(fatAABB, this.queryCallback);\n }\n};\n\nBroadPhase.prototype.queryCallback = function(proxyId) {\n if (proxyId == this.m_queryProxyId) {\n return true;\n }\n var proxyIdA = Math.min(proxyId, this.m_queryProxyId);\n var proxyIdB = Math.max(proxyId, this.m_queryProxyId);\n var userDataA = this.m_tree.getUserData(proxyIdA);\n var userDataB = this.m_tree.getUserData(proxyIdB);\n this.m_callback(userDataA, userDataB);\n return true;\n};\n\n\n},{\"../Settings\":7,\"../common/Math\":18,\"../util/common\":51,\"./AABB\":11,\"./DynamicTree\":14}],13:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Distance;\n\nmodule.exports.Input = DistanceInput;\n\nmodule.exports.Output = DistanceOutput;\n\nmodule.exports.Proxy = DistanceProxy;\n\nmodule.exports.Cache = SimplexCache;\n\nvar Settings = require(\"../Settings\");\n\nvar common = require(\"../util/common\");\n\nvar Timer = require(\"../util/Timer\");\n\nvar stats = require(\"../common/stats\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nstats.gjkCalls = 0;\n\nstats.gjkIters = 0;\n\nstats.gjkMaxIters = 0;\n\nfunction DistanceInput() {\n this.proxyA = new DistanceProxy();\n this.proxyB = new DistanceProxy();\n this.transformA = null;\n this.transformB = null;\n this.useRadii = false;\n}\n\nfunction DistanceOutput() {\n this.pointA = Vec2.zero();\n this.pointB = Vec2.zero();\n this.distance;\n this.iterations;\n}\n\nfunction SimplexCache() {\n this.metric = 0;\n this.indexA = [];\n this.indexB = [];\n this.count = 0;\n}\n\nfunction Distance(output, cache, input) {\n ++stats.gjkCalls;\n var proxyA = input.proxyA;\n var proxyB = input.proxyB;\n var xfA = input.transformA;\n var xfB = input.transformB;\n DEBUG && common.debug(\"cahce:\", cache.metric, cache.count);\n DEBUG && common.debug(\"proxyA:\", proxyA.m_count);\n DEBUG && common.debug(\"proxyB:\", proxyB.m_count);\n DEBUG && common.debug(\"xfA:\", xfA.p.x, xfA.p.y, xfA.q.c, xfA.q.s);\n DEBUG && common.debug(\"xfB:\", xfB.p.x, xfB.p.y, xfB.q.c, xfB.q.s);\n var simplex = new Simplex();\n simplex.readCache(cache, proxyA, xfA, proxyB, xfB);\n DEBUG && common.debug(\"cache\", simplex.print());\n var vertices = simplex.m_v;\n var k_maxIters = Settings.maxDistnceIterations;\n var saveA = [];\n var saveB = [];\n var saveCount = 0;\n var distanceSqr1 = Infinity;\n var distanceSqr2 = Infinity;\n var iter = 0;\n while (iter < k_maxIters) {\n saveCount = simplex.m_count;\n for (var i = 0; i < saveCount; ++i) {\n saveA[i] = vertices[i].indexA;\n saveB[i] = vertices[i].indexB;\n }\n simplex.solve();\n if (simplex.m_count == 3) {\n break;\n }\n var p = simplex.getClosestPoint();\n distanceSqr2 = p.lengthSquared();\n if (distanceSqr2 >= distanceSqr1) {}\n distanceSqr1 = distanceSqr2;\n var d = simplex.getSearchDirection();\n if (d.lengthSquared() < Math.EPSILON * Math.EPSILON) {\n break;\n }\n var vertex = vertices[simplex.m_count];\n vertex.indexA = proxyA.getSupport(Rot.mulT(xfA.q, Vec2.neg(d)));\n vertex.wA = Transform.mul(xfA, proxyA.getVertex(vertex.indexA));\n vertex.indexB = proxyB.getSupport(Rot.mulT(xfB.q, d));\n vertex.wB = Transform.mul(xfB, proxyB.getVertex(vertex.indexB));\n vertex.w = Vec2.sub(vertex.wB, vertex.wA);\n ++iter;\n ++stats.gjkIters;\n var duplicate = false;\n for (var i = 0; i < saveCount; ++i) {\n if (vertex.indexA == saveA[i] && vertex.indexB == saveB[i]) {\n duplicate = true;\n break;\n }\n }\n if (duplicate) {\n break;\n }\n ++simplex.m_count;\n }\n stats.gjkMaxIters = Math.max(stats.gjkMaxIters, iter);\n simplex.getWitnessPoints(output.pointA, output.pointB);\n output.distance = Vec2.distance(output.pointA, output.pointB);\n output.iterations = iter;\n DEBUG && common.debug(\"Distance:\", output.distance, output.pointA.x, output.pointA.y, output.pointB.x, output.pointB.y);\n simplex.writeCache(cache);\n if (input.useRadii) {\n var rA = proxyA.m_radius;\n var rB = proxyB.m_radius;\n if (output.distance > rA + rB && output.distance > Math.EPSILON) {\n output.distance -= rA + rB;\n var normal = Vec2.sub(output.pointB, output.pointA);\n normal.normalize();\n output.pointA.wAdd(rA, normal);\n output.pointB.wSub(rB, normal);\n } else {\n var p = Vec2.mid(output.pointA, output.pointB);\n output.pointA.set(p);\n output.pointB.set(p);\n output.distance = 0;\n }\n }\n}\n\nfunction DistanceProxy() {\n this.m_buffer = [];\n this.m_vertices = [];\n this.m_count = 0;\n this.m_radius = 0;\n}\n\nDistanceProxy.prototype.getVertexCount = function() {\n return this.m_count;\n};\n\nDistanceProxy.prototype.getVertex = function(index) {\n ASSERT && common.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n};\n\nDistanceProxy.prototype.getSupport = function(d) {\n var bestIndex = 0;\n var bestValue = Vec2.dot(this.m_vertices[0], d);\n for (var i = 0; i < this.m_count; ++i) {\n var value = Vec2.dot(this.m_vertices[i], d);\n if (value > bestValue) {\n bestIndex = i;\n bestValue = value;\n }\n }\n return bestIndex;\n};\n\nDistanceProxy.prototype.getSupportVertex = function(d) {\n return this.m_vertices[this.getSupport(d)];\n};\n\nDistanceProxy.prototype.set = function(shape, index) {\n ASSERT && common.assert(typeof shape.computeDistanceProxy === \"function\");\n shape.computeDistanceProxy(this, index);\n};\n\nfunction SimplexVertex() {\n this.indexA;\n this.indexB;\n this.wA = Vec2.zero();\n this.wB = Vec2.zero();\n this.w = Vec2.zero();\n this.a;\n}\n\nSimplexVertex.prototype.set = function(v) {\n this.indexA = v.indexA;\n this.indexB = v.indexB;\n this.wA = Vec2.clone(v.wA);\n this.wB = Vec2.clone(v.wB);\n this.w = Vec2.clone(v.w);\n this.a = v.a;\n};\n\nfunction Simplex() {\n this.m_v1 = new SimplexVertex();\n this.m_v2 = new SimplexVertex();\n this.m_v3 = new SimplexVertex();\n this.m_v = [ this.m_v1, this.m_v2, this.m_v3 ];\n this.m_count;\n}\n\nSimplex.prototype.print = function() {\n if (this.m_count == 3) {\n return [ \"+\" + this.m_count, this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y, this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y, this.m_v3.a, this.m_v3.wA.x, this.m_v3.wA.y, this.m_v3.wB.x, this.m_v3.wB.y ].toString();\n } else if (this.m_count == 2) {\n return [ \"+\" + this.m_count, this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y, this.m_v2.a, this.m_v2.wA.x, this.m_v2.wA.y, this.m_v2.wB.x, this.m_v2.wB.y ].toString();\n } else if (this.m_count == 1) {\n return [ \"+\" + this.m_count, this.m_v1.a, this.m_v1.wA.x, this.m_v1.wA.y, this.m_v1.wB.x, this.m_v1.wB.y ].toString();\n } else {\n return \"+\" + this.m_count;\n }\n};\n\nSimplex.prototype.readCache = function(cache, proxyA, transformA, proxyB, transformB) {\n ASSERT && common.assert(cache.count <= 3);\n this.m_count = cache.count;\n for (var i = 0; i < this.m_count; ++i) {\n var v = this.m_v[i];\n v.indexA = cache.indexA[i];\n v.indexB = cache.indexB[i];\n var wALocal = proxyA.getVertex(v.indexA);\n var wBLocal = proxyB.getVertex(v.indexB);\n v.wA = Transform.mul(transformA, wALocal);\n v.wB = Transform.mul(transformB, wBLocal);\n v.w = Vec2.sub(v.wB, v.wA);\n v.a = 0;\n }\n if (this.m_count > 1) {\n var metric1 = cache.metric;\n var metric2 = this.getMetric();\n if (metric2 < .5 * metric1 || 2 * metric1 < metric2 || metric2 < Math.EPSILON) {\n this.m_count = 0;\n }\n }\n if (this.m_count == 0) {\n var v = this.m_v[0];\n v.indexA = 0;\n v.indexB = 0;\n var wALocal = proxyA.getVertex(0);\n var wBLocal = proxyB.getVertex(0);\n v.wA = Transform.mul(transformA, wALocal);\n v.wB = Transform.mul(transformB, wBLocal);\n v.w = Vec2.sub(v.wB, v.wA);\n v.a = 1;\n this.m_count = 1;\n }\n};\n\nSimplex.prototype.writeCache = function(cache) {\n cache.metric = this.getMetric();\n cache.count = this.m_count;\n for (var i = 0; i < this.m_count; ++i) {\n cache.indexA[i] = this.m_v[i].indexA;\n cache.indexB[i] = this.m_v[i].indexB;\n }\n};\n\nSimplex.prototype.getSearchDirection = function() {\n switch (this.m_count) {\n case 1:\n return Vec2.neg(this.m_v1.w);\n\n case 2:\n {\n var e12 = Vec2.sub(this.m_v2.w, this.m_v1.w);\n var sgn = Vec2.cross(e12, Vec2.neg(this.m_v1.w));\n if (sgn > 0) {\n return Vec2.cross(1, e12);\n } else {\n return Vec2.cross(e12, 1);\n }\n }\n\n default:\n ASSERT && common.assert(false);\n return Vec2.zero();\n }\n};\n\nSimplex.prototype.getClosestPoint = function() {\n switch (this.m_count) {\n case 0:\n ASSERT && common.assert(false);\n return Vec2.zero();\n\n case 1:\n return Vec2.clone(this.m_v1.w);\n\n case 2:\n return Vec2.wAdd(this.m_v1.a, this.m_v1.w, this.m_v2.a, this.m_v2.w);\n\n case 3:\n return Vec2.zero();\n\n default:\n ASSERT && common.assert(false);\n return Vec2.zero();\n }\n};\n\nSimplex.prototype.getWitnessPoints = function(pA, pB) {\n switch (this.m_count) {\n case 0:\n ASSERT && common.assert(false);\n break;\n\n case 1:\n DEBUG && common.debug(\"case1\", this.print());\n pA.set(this.m_v1.wA);\n pB.set(this.m_v1.wB);\n break;\n\n case 2:\n DEBUG && common.debug(\"case2\", this.print());\n pA.wSet(this.m_v1.a, this.m_v1.wA, this.m_v2.a, this.m_v2.wA);\n pB.wSet(this.m_v1.a, this.m_v1.wB, this.m_v2.a, this.m_v2.wB);\n break;\n\n case 3:\n DEBUG && common.debug(\"case3\", this.print());\n pA.wSet(this.m_v1.a, this.m_v1.wA, this.m_v2.a, this.m_v2.wA);\n pA.wAdd(this.m_v3.a, this.m_v3.wA);\n pB.set(pA);\n break;\n\n default:\n ASSERT && common.assert(false);\n break;\n }\n};\n\nSimplex.prototype.getMetric = function() {\n switch (this.m_count) {\n case 0:\n ASSERT && common.assert(false);\n return 0;\n\n case 1:\n return 0;\n\n case 2:\n return Vec2.distance(this.m_v1.w, this.m_v2.w);\n\n case 3:\n return Vec2.cross(Vec2.sub(this.m_v2.w, this.m_v1.w), Vec2.sub(this.m_v3.w, this.m_v1.w));\n\n default:\n ASSERT && common.assert(false);\n return 0;\n }\n};\n\nSimplex.prototype.solve = function() {\n switch (this.m_count) {\n case 1:\n break;\n\n case 2:\n this.solve2();\n break;\n\n case 3:\n this.solve3();\n break;\n\n default:\n ASSERT && common.assert(false);\n }\n};\n\nSimplex.prototype.solve2 = function() {\n var w1 = this.m_v1.w;\n var w2 = this.m_v2.w;\n var e12 = Vec2.sub(w2, w1);\n var d12_2 = -Vec2.dot(w1, e12);\n if (d12_2 <= 0) {\n this.m_v1.a = 1;\n this.m_count = 1;\n return;\n }\n var d12_1 = Vec2.dot(w2, e12);\n if (d12_1 <= 0) {\n this.m_v2.a = 1;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n var inv_d12 = 1 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n};\n\nSimplex.prototype.solve3 = function() {\n var w1 = this.m_v1.w;\n var w2 = this.m_v2.w;\n var w3 = this.m_v3.w;\n var e12 = Vec2.sub(w2, w1);\n var w1e12 = Vec2.dot(w1, e12);\n var w2e12 = Vec2.dot(w2, e12);\n var d12_1 = w2e12;\n var d12_2 = -w1e12;\n var e13 = Vec2.sub(w3, w1);\n var w1e13 = Vec2.dot(w1, e13);\n var w3e13 = Vec2.dot(w3, e13);\n var d13_1 = w3e13;\n var d13_2 = -w1e13;\n var e23 = Vec2.sub(w3, w2);\n var w2e23 = Vec2.dot(w2, e23);\n var w3e23 = Vec2.dot(w3, e23);\n var d23_1 = w3e23;\n var d23_2 = -w2e23;\n var n123 = Vec2.cross(e12, e13);\n var d123_1 = n123 * Vec2.cross(w2, w3);\n var d123_2 = n123 * Vec2.cross(w3, w1);\n var d123_3 = n123 * Vec2.cross(w1, w2);\n if (d12_2 <= 0 && d13_2 <= 0) {\n this.m_v1.a = 1;\n this.m_count = 1;\n return;\n }\n if (d12_1 > 0 && d12_2 > 0 && d123_3 <= 0) {\n var inv_d12 = 1 / (d12_1 + d12_2);\n this.m_v1.a = d12_1 * inv_d12;\n this.m_v2.a = d12_2 * inv_d12;\n this.m_count = 2;\n return;\n }\n if (d13_1 > 0 && d13_2 > 0 && d123_2 <= 0) {\n var inv_d13 = 1 / (d13_1 + d13_2);\n this.m_v1.a = d13_1 * inv_d13;\n this.m_v3.a = d13_2 * inv_d13;\n this.m_count = 2;\n this.m_v2.set(this.m_v3);\n return;\n }\n if (d12_1 <= 0 && d23_2 <= 0) {\n this.m_v2.a = 1;\n this.m_count = 1;\n this.m_v1.set(this.m_v2);\n return;\n }\n if (d13_1 <= 0 && d23_1 <= 0) {\n this.m_v3.a = 1;\n this.m_count = 1;\n this.m_v1.set(this.m_v3);\n return;\n }\n if (d23_1 > 0 && d23_2 > 0 && d123_1 <= 0) {\n var inv_d23 = 1 / (d23_1 + d23_2);\n this.m_v2.a = d23_1 * inv_d23;\n this.m_v3.a = d23_2 * inv_d23;\n this.m_count = 2;\n this.m_v1.set(this.m_v3);\n return;\n }\n var inv_d123 = 1 / (d123_1 + d123_2 + d123_3);\n this.m_v1.a = d123_1 * inv_d123;\n this.m_v2.a = d123_2 * inv_d123;\n this.m_v3.a = d123_3 * inv_d123;\n this.m_count = 3;\n};\n\nDistance.testOverlap = function(shapeA, indexA, shapeB, indexB, xfA, xfB) {\n var input = new DistanceInput();\n input.proxyA.set(shapeA, indexA);\n input.proxyB.set(shapeB, indexB);\n input.transformA = xfA;\n input.transformB = xfB;\n input.useRadii = true;\n var cache = new SimplexCache();\n var output = new DistanceOutput();\n Distance(output, cache, input);\n return output.distance < 10 * Math.EPSILON;\n};\n\n\n},{\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../common/stats\":26,\"../util/Timer\":50,\"../util/common\":51}],14:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar Settings = require(\"../Settings\");\n\nvar common = require(\"../util/common\");\n\nvar Pool = require(\"../util/Pool\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Math = require(\"../common/Math\");\n\nvar AABB = require(\"./AABB\");\n\nmodule.exports = DynamicTree;\n\nfunction TreeNode(id) {\n this.id = id;\n this.aabb = new AABB();\n this.userData = null;\n this.parent = null;\n this.child1 = null;\n this.child2 = null;\n this.height = -1;\n this.toString = function() {\n return this.id + \": \" + this.userData;\n };\n}\n\nTreeNode.prototype.isLeaf = function() {\n return this.child1 == null;\n};\n\nfunction DynamicTree() {\n this.m_root = null;\n this.m_nodes = {};\n this.m_lastProxyId = 0;\n this.m_pool = new Pool({\n create: function() {\n return new TreeNode();\n }\n });\n}\n\nDynamicTree.prototype.getUserData = function(id) {\n var node = this.m_nodes[id];\n ASSERT && common.assert(!!node);\n return node.userData;\n};\n\nDynamicTree.prototype.getFatAABB = function(id) {\n var node = this.m_nodes[id];\n ASSERT && common.assert(!!node);\n return node.aabb;\n};\n\nDynamicTree.prototype.allocateNode = function() {\n var node = this.m_pool.allocate();\n node.id = ++this.m_lastProxyId;\n node.userData = null;\n node.parent = null;\n node.child1 = null;\n node.child2 = null;\n node.height = -1;\n this.m_nodes[node.id] = node;\n return node;\n};\n\nDynamicTree.prototype.freeNode = function(node) {\n this.m_pool.release(node);\n node.height = -1;\n delete this.m_nodes[node.id];\n};\n\nDynamicTree.prototype.createProxy = function(aabb, userData) {\n ASSERT && common.assert(AABB.isValid(aabb));\n var node = this.allocateNode();\n node.aabb.set(aabb);\n AABB.extend(node.aabb, Settings.aabbExtension);\n node.userData = userData;\n node.height = 0;\n this.insertLeaf(node);\n return node.id;\n};\n\nDynamicTree.prototype.destroyProxy = function(id) {\n var node = this.m_nodes[id];\n ASSERT && common.assert(!!node);\n ASSERT && common.assert(node.isLeaf());\n this.removeLeaf(node);\n this.freeNode(node);\n};\n\nDynamicTree.prototype.moveProxy = function(id, aabb, d) {\n ASSERT && common.assert(AABB.isValid(aabb));\n ASSERT && common.assert(!d || Vec2.isValid(d));\n var node = this.m_nodes[id];\n ASSERT && common.assert(!!node);\n ASSERT && common.assert(node.isLeaf());\n if (node.aabb.contains(aabb)) {\n return false;\n }\n this.removeLeaf(node);\n node.aabb.set(aabb);\n aabb = node.aabb;\n AABB.extend(aabb, Settings.aabbExtension);\n if (d.x < 0) {\n aabb.lowerBound.x += d.x * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.x += d.x * Settings.aabbMultiplier;\n }\n if (d.y < 0) {\n aabb.lowerBound.y += d.y * Settings.aabbMultiplier;\n } else {\n aabb.upperBound.y += d.y * Settings.aabbMultiplier;\n }\n this.insertLeaf(node);\n return true;\n};\n\nDynamicTree.prototype.insertLeaf = function(leaf) {\n ASSERT && common.assert(AABB.isValid(leaf.aabb));\n if (this.m_root == null) {\n this.m_root = leaf;\n this.m_root.parent = null;\n return;\n }\n var leafAABB = leaf.aabb;\n var index = this.m_root;\n while (index.isLeaf() == false) {\n var child1 = index.child1;\n var child2 = index.child2;\n var area = index.aabb.getPerimeter();\n var combinedAABB = new AABB();\n combinedAABB.combine(index.aabb, leafAABB);\n var combinedArea = combinedAABB.getPerimeter();\n var cost = 2 * combinedArea;\n var inheritanceCost = 2 * (combinedArea - area);\n var cost1;\n if (child1.isLeaf()) {\n var aabb = new AABB();\n aabb.combine(leafAABB, child1.aabb);\n cost1 = aabb.getPerimeter() + inheritanceCost;\n } else {\n var aabb = new AABB();\n aabb.combine(leafAABB, child1.aabb);\n var oldArea = child1.aabb.getPerimeter();\n var newArea = aabb.getPerimeter();\n cost1 = newArea - oldArea + inheritanceCost;\n }\n var cost2;\n if (child2.isLeaf()) {\n var aabb = new AABB();\n aabb.combine(leafAABB, child2.aabb);\n cost2 = aabb.getPerimeter() + inheritanceCost;\n } else {\n var aabb = new AABB();\n aabb.combine(leafAABB, child2.aabb);\n var oldArea = child2.aabb.getPerimeter();\n var newArea = aabb.getPerimeter();\n cost2 = newArea - oldArea + inheritanceCost;\n }\n if (cost < cost1 && cost < cost2) {\n break;\n }\n if (cost1 < cost2) {\n index = child1;\n } else {\n index = child2;\n }\n }\n var sibling = index;\n var oldParent = sibling.parent;\n var newParent = this.allocateNode();\n newParent.parent = oldParent;\n newParent.userData = null;\n newParent.aabb.combine(leafAABB, sibling.aabb);\n newParent.height = sibling.height + 1;\n if (oldParent != null) {\n if (oldParent.child1 == sibling) {\n oldParent.child1 = newParent;\n } else {\n oldParent.child2 = newParent;\n }\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n } else {\n newParent.child1 = sibling;\n newParent.child2 = leaf;\n sibling.parent = newParent;\n leaf.parent = newParent;\n this.m_root = newParent;\n }\n index = leaf.parent;\n while (index != null) {\n index = this.balance(index);\n var child1 = index.child1;\n var child2 = index.child2;\n ASSERT && common.assert(child1 != null);\n ASSERT && common.assert(child2 != null);\n index.height = 1 + Math.max(child1.height, child2.height);\n index.aabb.combine(child1.aabb, child2.aabb);\n index = index.parent;\n }\n};\n\nDynamicTree.prototype.removeLeaf = function(leaf) {\n if (leaf == this.m_root) {\n this.m_root = null;\n return;\n }\n var parent = leaf.parent;\n var grandParent = parent.parent;\n var sibling;\n if (parent.child1 == leaf) {\n sibling = parent.child2;\n } else {\n sibling = parent.child1;\n }\n if (grandParent != null) {\n if (grandParent.child1 == parent) {\n grandParent.child1 = sibling;\n } else {\n grandParent.child2 = sibling;\n }\n sibling.parent = grandParent;\n this.freeNode(parent);\n var index = grandParent;\n while (index != null) {\n index = this.balance(index);\n var child1 = index.child1;\n var child2 = index.child2;\n index.aabb.combine(child1.aabb, child2.aabb);\n index.height = 1 + Math.max(child1.height, child2.height);\n index = index.parent;\n }\n } else {\n this.m_root = sibling;\n sibling.parent = null;\n this.freeNode(parent);\n }\n};\n\nDynamicTree.prototype.balance = function(iA) {\n ASSERT && common.assert(iA != null);\n var A = iA;\n if (A.isLeaf() || A.height < 2) {\n return iA;\n }\n var B = A.child1;\n var C = A.child2;\n var balance = C.height - B.height;\n if (balance > 1) {\n var F = C.child1;\n var G = C.child2;\n C.child1 = A;\n C.parent = A.parent;\n A.parent = C;\n if (C.parent != null) {\n if (C.parent.child1 == iA) {\n C.parent.child1 = C;\n } else {\n C.parent.child2 = C;\n }\n } else {\n this.m_root = C;\n }\n if (F.height > G.height) {\n C.child2 = F;\n A.child2 = G;\n G.parent = A;\n A.aabb.combine(B.aabb, G.aabb);\n C.aabb.combine(A.aabb, F.aabb);\n A.height = 1 + Math.max(B.height, G.height);\n C.height = 1 + Math.max(A.height, F.height);\n } else {\n C.child2 = G;\n A.child2 = F;\n F.parent = A;\n A.aabb.combine(B.aabb, F.aabb);\n C.aabb.combine(A.aabb, G.aabb);\n A.height = 1 + Math.max(B.height, F.height);\n C.height = 1 + Math.max(A.height, G.height);\n }\n return C;\n }\n if (balance < -1) {\n var D = B.child1;\n var E = B.child2;\n B.child1 = A;\n B.parent = A.parent;\n A.parent = B;\n if (B.parent != null) {\n if (B.parent.child1 == A) {\n B.parent.child1 = B;\n } else {\n B.parent.child2 = B;\n }\n } else {\n this.m_root = B;\n }\n if (D.height > E.height) {\n B.child2 = D;\n A.child1 = E;\n E.parent = A;\n A.aabb.combine(C.aabb, E.aabb);\n B.aabb.combine(A.aabb, D.aabb);\n A.height = 1 + Math.max(C.height, E.height);\n B.height = 1 + Math.max(A.height, D.height);\n } else {\n B.child2 = E;\n A.child1 = D;\n D.parent = A;\n A.aabb.combine(C.aabb, D.aabb);\n B.aabb.combine(A.aabb, E.aabb);\n A.height = 1 + Math.max(C.height, D.height);\n B.height = 1 + Math.max(A.height, E.height);\n }\n return B;\n }\n return A;\n};\n\nDynamicTree.prototype.getHeight = function() {\n if (this.m_root == null) {\n return 0;\n }\n return this.m_root.height;\n};\n\nDynamicTree.prototype.getAreaRatio = function() {\n if (this.m_root == null) {\n return 0;\n }\n var root = this.m_root;\n var rootArea = root.aabb.getPerimeter();\n var totalArea = 0;\n var node, it = iteratorPool.allocate().preorder();\n while (node = it.next()) {\n if (node.height < 0) {\n continue;\n }\n totalArea += node.aabb.getPerimeter();\n }\n iteratorPool.release(it);\n return totalArea / rootArea;\n};\n\nDynamicTree.prototype.computeHeight = function(id) {\n var node;\n if (typeof id !== \"undefined\") {\n node = this.m_nodes[id];\n } else {\n node = this.m_root;\n }\n if (node.isLeaf()) {\n return 0;\n }\n var height1 = ComputeHeight(node.child1);\n var height2 = ComputeHeight(node.child2);\n return 1 + Math.max(height1, height2);\n};\n\nDynamicTree.prototype.validateStructure = function(node) {\n if (node == null) {\n return;\n }\n if (node == this.m_root) {\n ASSERT && common.assert(node.parent == null);\n }\n var child1 = node.child1;\n var child2 = node.child2;\n if (node.isLeaf()) {\n ASSERT && common.assert(child1 == null);\n ASSERT && common.assert(child2 == null);\n ASSERT && common.assert(node.height == 0);\n return;\n }\n ASSERT && common.assert(child1.parent == node);\n ASSERT && common.assert(child2.parent == node);\n this.validateStructure(child1);\n this.validateStructure(child2);\n};\n\nDynamicTree.prototype.validateMetrics = function(node) {\n if (node == null) {\n return;\n }\n var child1 = node.child1;\n var child2 = node.child2;\n if (node.isLeaf()) {\n ASSERT && common.assert(child1 == null);\n ASSERT && common.assert(child2 == null);\n ASSERT && common.assert(node.height == 0);\n return;\n }\n var height1 = this.m_nodes[child1].height;\n var height2 = this.m_nodes[child2].height;\n var height = 1 + Math.max(height1, height2);\n ASSERT && common.assert(node.height == height);\n var aabb = new AABB();\n aabb.combine(child1.aabb, child2.aabb);\n ASSERT && common.assert(AABB.areEqual(aabb, node.aabb));\n this.validateMetrics(child1);\n this.validateMetrics(child2);\n};\n\nDynamicTree.prototype.validate = function() {\n ValidateStructure(this.m_root);\n ValidateMetrics(this.m_root);\n ASSERT && common.assert(this.getHeight() == this.computeHeight());\n};\n\nDynamicTree.prototype.getMaxBalance = function() {\n var maxBalance = 0;\n var node, it = iteratorPool.allocate().preorder();\n while (node = it.next()) {\n if (node.height <= 1) {\n continue;\n }\n ASSERT && common.assert(node.isLeaf() == false);\n var balance = Math.abs(node.child2.height - node.child1.height);\n maxBalance = Math.max(maxBalance, balance);\n }\n iteratorPool.release(it);\n return maxBalance;\n};\n\nDynamicTree.prototype.rebuildBottomUp = function() {\n var nodes = [];\n var count = 0;\n var node, it = iteratorPool.allocate().preorder();\n while (node = it.next()) {\n if (node.height < 0) {\n continue;\n }\n if (node.isLeaf()) {\n node.parent = null;\n nodes[count] = node;\n ++count;\n } else {\n this.freeNode(node);\n }\n }\n iteratorPool.release(it);\n while (count > 1) {\n var minCost = Infinity;\n var iMin = -1, jMin = -1;\n for (var i = 0; i < count; ++i) {\n var aabbi = nodes[i].aabb;\n for (var j = i + 1; j < count; ++j) {\n var aabbj = nodes[j].aabb;\n var b = new AABB();\n b.combine(aabbi, aabbj);\n var cost = b.getPerimeter();\n if (cost < minCost) {\n iMin = i;\n jMin = j;\n minCost = cost;\n }\n }\n }\n var child1 = nodes[iMin];\n var child2 = nodes[jMin];\n var parent = this.allocateNode();\n parent.child1 = child1;\n parent.child2 = child2;\n parent.height = 1 + Math.max(child1.height, child2.height);\n parent.aabb.combine(child1.aabb, child2.aabb);\n parent.parent = null;\n child1.parent = parent;\n child2.parent = parent;\n nodes[jMin] = nodes[count - 1];\n nodes[iMin] = parent;\n --count;\n }\n this.m_root = nodes[0];\n this.validate();\n};\n\nDynamicTree.prototype.shiftOrigin = function(newOrigin) {\n var node, it = iteratorPool.allocate().preorder();\n while (node = it.next()) {\n var aabb = node.aabb;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n aabb.lowerBound.x -= newOrigin.x;\n aabb.lowerBound.y -= newOrigin.y;\n }\n iteratorPool.release(it);\n};\n\nDynamicTree.prototype.query = function(aabb, queryCallback) {\n ASSERT && common.assert(typeof queryCallback === \"function\");\n var stack = stackPool.allocate();\n stack.push(this.m_root);\n while (stack.length > 0) {\n var node = stack.pop();\n if (node == null) {\n continue;\n }\n if (AABB.testOverlap(node.aabb, aabb)) {\n if (node.isLeaf()) {\n var proceed = queryCallback(node.id);\n if (proceed == false) {\n return;\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n }\n stackPool.release(stack);\n};\n\nDynamicTree.prototype.rayCast = function(input, rayCastCallback) {\n ASSERT && common.assert(typeof rayCastCallback === \"function\");\n var p1 = input.p1;\n var p2 = input.p2;\n var r = Vec2.sub(p2, p1);\n ASSERT && common.assert(r.lengthSquared() > 0);\n r.normalize();\n var v = Vec2.cross(1, r);\n var abs_v = Vec2.abs(v);\n var maxFraction = input.maxFraction;\n var segmentAABB = new AABB();\n var t = Vec2.wAdd(1 - maxFraction, p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n var stack = stackPool.allocate();\n var subInput = inputPool.allocate();\n stack.push(this.m_root);\n while (stack.length > 0) {\n var node = stack.pop();\n if (node == null) {\n continue;\n }\n if (AABB.testOverlap(node.aabb, segmentAABB) == false) {\n continue;\n }\n var c = node.aabb.getCenter();\n var h = node.aabb.getExtents();\n var separation = Math.abs(Vec2.dot(v, Vec2.sub(p1, c))) - Vec2.dot(abs_v, h);\n if (separation > 0) {\n continue;\n }\n if (node.isLeaf()) {\n subInput.p1 = Vec2.clone(input.p1);\n subInput.p2 = Vec2.clone(input.p2);\n subInput.maxFraction = maxFraction;\n var value = rayCastCallback(subInput, node.id);\n if (value == 0) {\n return;\n }\n if (value > 0) {\n maxFraction = value;\n t = Vec2.wAdd(1 - maxFraction, p1, maxFraction, p2);\n segmentAABB.combinePoints(p1, t);\n }\n } else {\n stack.push(node.child1);\n stack.push(node.child2);\n }\n }\n stackPool.release(stack);\n inputPool.release(subInput);\n};\n\nvar inputPool = new Pool({\n create: function() {\n return {};\n },\n release: function(stack) {}\n});\n\nvar stackPool = new Pool({\n create: function() {\n return [];\n },\n release: function(stack) {\n stack.length = 0;\n }\n});\n\nvar iteratorPool = new Pool({\n create: function() {\n return new Iterator();\n },\n release: function(iterator) {\n iterator.close();\n }\n});\n\nfunction Iterator() {\n var parents = [];\n var states = [];\n return {\n preorder: function(root) {\n parents.length = 0;\n parents.push(root);\n states.length = 0;\n states.push(0);\n return this;\n },\n next: function() {\n while (parents.length > 0) {\n var i = parents.length - 1;\n var node = parents[i];\n if (states[i] === 0) {\n states[i] = 1;\n return node;\n }\n if (states[i] === 1) {\n states[i] = 2;\n if (node.child1) {\n parents.push(node.child1);\n states.push(1);\n return node.child1;\n }\n }\n if (states[i] === 2) {\n states[i] = 3;\n if (node.child2) {\n parents.push(node.child2);\n states.push(1);\n return node.child2;\n }\n }\n parents.pop();\n states.pop();\n }\n },\n close: function() {\n parents.length = 0;\n }\n };\n}\n\n\n},{\"../Settings\":7,\"../common/Math\":18,\"../common/Vec2\":23,\"../util/Pool\":49,\"../util/common\":51,\"./AABB\":11}],15:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = TimeOfImpact;\n\nmodule.exports.Input = TOIInput;\n\nmodule.exports.Output = TOIOutput;\n\nvar Settings = require(\"../Settings\");\n\nvar common = require(\"../util/common\");\n\nvar Timer = require(\"../util/Timer\");\n\nvar stats = require(\"../common/stats\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Distance = require(\"./Distance\");\n\nvar DistanceInput = Distance.Input;\n\nvar DistanceOutput = Distance.Output;\n\nvar DistanceProxy = Distance.Proxy;\n\nvar SimplexCache = Distance.Cache;\n\nfunction TOIInput() {\n this.proxyA = new DistanceProxy();\n this.proxyB = new DistanceProxy();\n this.sweepA = new Sweep();\n this.sweepB = new Sweep();\n this.tMax;\n}\n\nTOIOutput.e_unknown = 0;\n\nTOIOutput.e_failed = 1;\n\nTOIOutput.e_overlapped = 2;\n\nTOIOutput.e_touching = 3;\n\nTOIOutput.e_separated = 4;\n\nfunction TOIOutput() {\n this.state;\n this.t;\n}\n\nstats.toiTime = 0;\n\nstats.toiMaxTime = 0;\n\nstats.toiCalls = 0;\n\nstats.toiIters = 0;\n\nstats.toiMaxIters = 0;\n\nstats.toiRootIters = 0;\n\nstats.toiMaxRootIters = 0;\n\nfunction TimeOfImpact(output, input) {\n var timer = Timer.now();\n ++stats.toiCalls;\n output.state = TOIOutput.e_unknown;\n output.t = input.tMax;\n var proxyA = input.proxyA;\n var proxyB = input.proxyB;\n var sweepA = input.sweepA;\n var sweepB = input.sweepB;\n DEBUG && common.debug(\"sweepA\", sweepA.localCenter.x, sweepA.localCenter.y, sweepA.c.x, sweepA.c.y, sweepA.a, sweepA.alpha0, sweepA.c0.x, sweepA.c0.y, sweepA.a0);\n DEBUG && common.debug(\"sweepB\", sweepB.localCenter.x, sweepB.localCenter.y, sweepB.c.x, sweepB.c.y, sweepB.a, sweepB.alpha0, sweepB.c0.x, sweepB.c0.y, sweepB.a0);\n sweepA.normalize();\n sweepB.normalize();\n var tMax = input.tMax;\n var totalRadius = proxyA.m_radius + proxyB.m_radius;\n var target = Math.max(Settings.linearSlop, totalRadius - 3 * Settings.linearSlop);\n var tolerance = .25 * Settings.linearSlop;\n ASSERT && common.assert(target > tolerance);\n var t1 = 0;\n var k_maxIterations = Settings.maxTOIIterations;\n var iter = 0;\n var cache = new SimplexCache();\n var distanceInput = new DistanceInput();\n distanceInput.proxyA = input.proxyA;\n distanceInput.proxyB = input.proxyB;\n distanceInput.useRadii = false;\n for (;;) {\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n sweepA.getTransform(xfA, t1);\n sweepB.getTransform(xfB, t1);\n DEBUG && common.debug(\"xfA:\", xfA.p.x, xfA.p.y, xfA.q.c, xfA.q.s);\n DEBUG && common.debug(\"xfB:\", xfB.p.x, xfB.p.y, xfB.q.c, xfB.q.s);\n distanceInput.transformA = xfA;\n distanceInput.transformB = xfB;\n var distanceOutput = new DistanceOutput();\n Distance(distanceOutput, cache, distanceInput);\n DEBUG && common.debug(\"distance:\", distanceOutput.distance);\n if (distanceOutput.distance <= 0) {\n output.state = TOIOutput.e_overlapped;\n output.t = 0;\n break;\n }\n if (distanceOutput.distance < target + tolerance) {\n output.state = TOIOutput.e_touching;\n output.t = t1;\n break;\n }\n var fcn = new SeparationFunction();\n fcn.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);\n if (false) {\n var N = 100;\n var dx = 1 / N;\n var xs = [];\n var fs = [];\n var x = 0;\n for (var i = 0; i <= N; ++i) {\n sweepA.getTransform(xfA, x);\n sweepB.getTransform(xfB, x);\n var f = fcn.evaluate(xfA, xfB) - target;\n printf(\"%g %g\\n\", x, f);\n xs[i] = x;\n fs[i] = f;\n x += dx;\n }\n }\n var done = false;\n var t2 = tMax;\n var pushBackIter = 0;\n for (;;) {\n var s2 = fcn.findMinSeparation(t2);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\n if (s2 > target + tolerance) {\n output.state = TOIOutput.e_separated;\n output.t = tMax;\n done = true;\n break;\n }\n if (s2 > target - tolerance) {\n t1 = t2;\n break;\n }\n var s1 = fcn.evaluate(t1);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\n DEBUG && common.debug(\"s1:\", s1, target, tolerance, t1);\n if (s1 < target - tolerance) {\n output.state = TOIOutput.e_failed;\n output.t = t1;\n done = true;\n break;\n }\n if (s1 <= target + tolerance) {\n output.state = TOIOutput.e_touching;\n output.t = t1;\n done = true;\n break;\n }\n var rootIterCount = 0;\n var a1 = t1, a2 = t2;\n for (;;) {\n var t;\n if (rootIterCount & 1) {\n t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);\n } else {\n t = .5 * (a1 + a2);\n }\n ++rootIterCount;\n ++stats.toiRootIters;\n var s = fcn.evaluate(t);\n var indexA = fcn.indexA;\n var indexB = fcn.indexB;\n if (Math.abs(s - target) < tolerance) {\n t2 = t;\n break;\n }\n if (s > target) {\n a1 = t;\n s1 = s;\n } else {\n a2 = t;\n s2 = s;\n }\n if (rootIterCount == 50) {\n break;\n }\n }\n stats.toiMaxRootIters = Math.max(stats.toiMaxRootIters, rootIterCount);\n ++pushBackIter;\n if (pushBackIter == Settings.maxPolygonVertices) {\n break;\n }\n }\n ++iter;\n ++stats.toiIters;\n if (done) {\n break;\n }\n if (iter == k_maxIterations) {\n output.state = TOIOutput.e_failed;\n output.t = t1;\n break;\n }\n }\n stats.toiMaxIters = Math.max(stats.toiMaxIters, iter);\n var time = Timer.diff(timer);\n stats.toiMaxTime = Math.max(stats.toiMaxTime, time);\n stats.toiTime += time;\n}\n\nvar e_points = 1;\n\nvar e_faceA = 2;\n\nvar e_faceB = 3;\n\nfunction SeparationFunction() {\n this.m_proxyA = new DistanceProxy();\n this.m_proxyB = new DistanceProxy();\n this.m_sweepA;\n this.m_sweepB;\n this.m_type;\n this.m_localPoint = Vec2.zero();\n this.m_axis = Vec2.zero();\n}\n\nSeparationFunction.prototype.initialize = function(cache, proxyA, sweepA, proxyB, sweepB, t1) {\n this.m_proxyA = proxyA;\n this.m_proxyB = proxyB;\n var count = cache.count;\n ASSERT && common.assert(0 < count && count < 3);\n this.m_sweepA = sweepA;\n this.m_sweepB = sweepB;\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n this.m_sweepA.getTransform(xfA, t1);\n this.m_sweepB.getTransform(xfB, t1);\n if (count == 1) {\n this.m_type = e_points;\n var localPointA = this.m_proxyA.getVertex(cache.indexA[0]);\n var localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n var pointA = Transform.mul(xfA, localPointA);\n var pointB = Transform.mul(xfB, localPointB);\n this.m_axis.wSet(1, pointB, -1, pointA);\n var s = this.m_axis.normalize();\n return s;\n } else if (cache.indexA[0] == cache.indexA[1]) {\n this.m_type = e_faceB;\n var localPointB1 = proxyB.getVertex(cache.indexB[0]);\n var localPointB2 = proxyB.getVertex(cache.indexB[1]);\n this.m_axis = Vec2.cross(Vec2.sub(localPointB2, localPointB1), 1);\n this.m_axis.normalize();\n var normal = Rot.mul(xfB.q, this.m_axis);\n this.m_localPoint = Vec2.mid(localPointB1, localPointB2);\n var pointB = Transform.mul(xfB, this.m_localPoint);\n var localPointA = proxyA.getVertex(cache.indexA[0]);\n var pointA = Transform.mul(xfA, localPointA);\n var s = Vec2.dot(pointA, normal) - Vec2.dot(pointB, normal);\n if (s < 0) {\n this.m_axis = Vec2.neg(this.m_axis);\n s = -s;\n }\n return s;\n } else {\n this.m_type = e_faceA;\n var localPointA1 = this.m_proxyA.getVertex(cache.indexA[0]);\n var localPointA2 = this.m_proxyA.getVertex(cache.indexA[1]);\n this.m_axis = Vec2.cross(Vec2.sub(localPointA2, localPointA1), 1);\n this.m_axis.normalize();\n var normal = Rot.mul(xfA.q, this.m_axis);\n this.m_localPoint = Vec2.mid(localPointA1, localPointA2);\n var pointA = Transform.mul(xfA, this.m_localPoint);\n var localPointB = this.m_proxyB.getVertex(cache.indexB[0]);\n var pointB = Transform.mul(xfB, localPointB);\n var s = Vec2.dot(pointB, normal) - Vec2.dot(pointA, normal);\n if (s < 0) {\n this.m_axis = Vec2.neg(this.m_axis);\n s = -s;\n }\n return s;\n }\n};\n\nSeparationFunction.prototype.compute = function(find, t) {\n var xfA = Transform.identity();\n var xfB = Transform.identity();\n this.m_sweepA.getTransform(xfA, t);\n this.m_sweepB.getTransform(xfB, t);\n switch (this.m_type) {\n case e_points:\n {\n if (find) {\n var axisA = Rot.mulT(xfA.q, this.m_axis);\n var axisB = Rot.mulT(xfB.q, Vec2.neg(this.m_axis));\n this.indexA = this.m_proxyA.getSupport(axisA);\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n var localPointA = this.m_proxyA.getVertex(this.indexA);\n var localPointB = this.m_proxyB.getVertex(this.indexB);\n var pointA = Transform.mul(xfA, localPointA);\n var pointB = Transform.mul(xfB, localPointB);\n var sep = Vec2.dot(pointB, this.m_axis) - Vec2.dot(pointA, this.m_axis);\n return sep;\n }\n\n case e_faceA:\n {\n var normal = Rot.mul(xfA.q, this.m_axis);\n var pointA = Transform.mul(xfA, this.m_localPoint);\n if (find) {\n var axisB = Rot.mulT(xfB.q, Vec2.neg(normal));\n this.indexA = -1;\n this.indexB = this.m_proxyB.getSupport(axisB);\n }\n var localPointB = this.m_proxyB.getVertex(this.indexB);\n var pointB = Transform.mul(xfB, localPointB);\n var sep = Vec2.dot(pointB, normal) - Vec2.dot(pointA, normal);\n return sep;\n }\n\n case e_faceB:\n {\n var normal = Rot.mul(xfB.q, this.m_axis);\n var pointB = Transform.mul(xfB, this.m_localPoint);\n if (find) {\n var axisA = Rot.mulT(xfA.q, Vec2.neg(normal));\n this.indexB = -1;\n this.indexA = this.m_proxyA.getSupport(axisA);\n }\n var localPointA = this.m_proxyA.getVertex(this.indexA);\n var pointA = Transform.mul(xfA, localPointA);\n var sep = Vec2.dot(pointA, normal) - Vec2.dot(pointB, normal);\n return sep;\n }\n\n default:\n ASSERT && common.assert(false);\n if (find) {\n this.indexA = -1;\n this.indexB = -1;\n }\n return 0;\n }\n};\n\nSeparationFunction.prototype.findMinSeparation = function(t) {\n return this.compute(true, t);\n};\n\nSeparationFunction.prototype.evaluate = function(t) {\n return this.compute(false, t);\n};\n\n\n},{\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../common/stats\":26,\"../util/Timer\":50,\"../util/common\":51,\"./Distance\":13}],16:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Mat22;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"./Math\");\n\nvar Vec2 = require(\"./Vec2\");\n\nfunction Mat22(a, b, c, d) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec2.clone(a);\n this.ey = Vec2.clone(b);\n } else if (typeof a === \"number\") {\n this.ex = Vec2.neo(a, c);\n this.ey = Vec2.neo(b, d);\n } else {\n this.ex = Vec2.zero();\n this.ey = Vec2.zero();\n }\n}\n\nMat22.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nMat22.isValid = function(o) {\n return o && Vec2.isValid(o.ex) && Vec2.isValid(o.ey);\n};\n\nMat22.assert = function(o) {\n if (!ASSERT) return;\n if (!Mat22.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Mat22!\");\n }\n};\n\nMat22.prototype.set = function(a, b, c, d) {\n if (typeof a === \"number\" && typeof b === \"number\" && typeof c === \"number\" && typeof d === \"number\") {\n this.ex.set(a, c);\n this.ey.set(b, d);\n } else if (typeof a === \"object\" && typeof b === \"object\") {\n this.ex.set(a);\n this.ey.set(b);\n } else if (typeof a === \"object\") {\n ASSERT && Mat22.assert(a);\n this.ex.set(a.ex);\n this.ey.set(a.ey);\n } else {\n ASSERT && common.assert(false);\n }\n};\n\nMat22.prototype.setIdentity = function() {\n this.ex.x = 1;\n this.ey.x = 0;\n this.ex.y = 0;\n this.ey.y = 1;\n};\n\nMat22.prototype.setZero = function() {\n this.ex.x = 0;\n this.ey.x = 0;\n this.ex.y = 0;\n this.ey.y = 0;\n};\n\nMat22.prototype.getInverse = function() {\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var det = a * d - b * c;\n if (det != 0) {\n det = 1 / det;\n }\n var imx = new Mat22();\n imx.ex.x = det * d;\n imx.ey.x = -det * b;\n imx.ex.y = -det * c;\n imx.ey.y = det * a;\n return imx;\n};\n\nMat22.prototype.solve = function(v) {\n ASSERT && Vec2.assert(v);\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var det = a * d - b * c;\n if (det != 0) {\n det = 1 / det;\n }\n var w = Vec2.zero();\n w.x = det * (d * v.x - b * v.y);\n w.y = det * (a * v.y - c * v.x);\n return w;\n};\n\nMat22.mul = function(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n ASSERT && Vec2.assert(v);\n var x = mx.ex.x * v.x + mx.ey.x * v.y;\n var y = mx.ex.y * v.x + mx.ey.y * v.y;\n return Vec2.neo(x, y);\n } else if (v && \"ex\" in v && \"ey\" in v) {\n ASSERT && Mat22.assert(v);\n return new Mat22(Vec2.mul(mx, v.ex), Vec2.mul(mx, v.ey));\n }\n ASSERT && common.assert(false);\n};\n\nMat22.mulT = function(mx, v) {\n if (v && \"x\" in v && \"y\" in v) {\n ASSERT && Vec2.assert(v);\n return Vec2.neo(Vec2.dot(v, mx.ex), Vec2.dot(v, mx.ey));\n } else if (v && \"ex\" in v && \"ey\" in v) {\n ASSERT && Mat22.assert(v);\n var c1 = Vec2.neo(Vec2.dot(mx.ex, v.ex), Vec2.dot(mx.ey, v.ex));\n var c2 = Vec2.neo(Vec2.dot(mx.ex, v.ey), Vec2.dot(mx.ey, v.ey));\n return new Mat22(c1, c2);\n }\n ASSERT && common.assert(false);\n};\n\nMat22.abs = function(mx) {\n ASSERT && Mat22.assert(mx);\n return new Mat22(Vec2.abs(mx.ex), Vec2.abs(mx.ey));\n};\n\nMat22.add = function(mx1, mx2) {\n ASSERT && Mat22.assert(mx1);\n ASSERT && Mat22.assert(mx2);\n return new Mat22(Vec2.add(mx1.ex + mx2.ex), Vec2.add(mx1.ey + mx2.ey));\n};\n\n\n},{\"../util/common\":51,\"./Math\":18,\"./Vec2\":23}],17:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Mat33;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"./Math\");\n\nvar Vec2 = require(\"./Vec2\");\n\nvar Vec3 = require(\"./Vec3\");\n\nfunction Mat33(a, b, c) {\n if (typeof a === \"object\" && a !== null) {\n this.ex = Vec3.clone(a);\n this.ey = Vec3.clone(b);\n this.ez = Vec3.clone(c);\n } else {\n this.ex = Vec3();\n this.ey = Vec3();\n this.ez = Vec3();\n }\n}\n\nMat33.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nMat33.isValid = function(o) {\n return o && Vec3.isValid(o.ex) && Vec3.isValid(o.ey) && Vec3.isValid(o.ez);\n};\n\nMat33.assert = function(o) {\n if (!ASSERT) return;\n if (!Mat33.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Mat33!\");\n }\n};\n\nMat33.prototype.setZero = function() {\n this.ex.setZero();\n this.ey.setZero();\n this.ez.setZero();\n return this;\n};\n\nMat33.prototype.solve33 = function(v) {\n var det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det != 0) {\n det = 1 / det;\n }\n var r = new Vec3();\n r.x = det * Vec3.dot(v, Vec3.cross(this.ey, this.ez));\n r.y = det * Vec3.dot(this.ex, Vec3.cross(v, this.ez));\n r.z = det * Vec3.dot(this.ex, Vec3.cross(this.ey, v));\n return r;\n};\n\nMat33.prototype.solve22 = function(v) {\n var a11 = this.ex.x;\n var a12 = this.ey.x;\n var a21 = this.ex.y;\n var a22 = this.ey.y;\n var det = a11 * a22 - a12 * a21;\n if (det != 0) {\n det = 1 / det;\n }\n var r = Vec2.zero();\n r.x = det * (a22 * v.x - a12 * v.y);\n r.y = det * (a11 * v.y - a21 * v.x);\n return r;\n};\n\nMat33.prototype.getInverse22 = function(M) {\n var a = this.ex.x;\n var b = this.ey.x;\n var c = this.ex.y;\n var d = this.ey.y;\n var det = a * d - b * c;\n if (det != 0) {\n det = 1 / det;\n }\n M.ex.x = det * d;\n M.ey.x = -det * b;\n M.ex.z = 0;\n M.ex.y = -det * c;\n M.ey.y = det * a;\n M.ey.z = 0;\n M.ez.x = 0;\n M.ez.y = 0;\n M.ez.z = 0;\n};\n\nMat33.prototype.getSymInverse33 = function(M) {\n var det = Vec3.dot(this.ex, Vec3.cross(this.ey, this.ez));\n if (det != 0) {\n det = 1 / det;\n }\n var a11 = this.ex.x;\n var a12 = this.ey.x;\n var a13 = this.ez.x;\n var a22 = this.ey.y;\n var a23 = this.ez.y;\n var a33 = this.ez.z;\n M.ex.x = det * (a22 * a33 - a23 * a23);\n M.ex.y = det * (a13 * a23 - a12 * a33);\n M.ex.z = det * (a12 * a23 - a13 * a22);\n M.ey.x = M.ex.y;\n M.ey.y = det * (a11 * a33 - a13 * a13);\n M.ey.z = det * (a13 * a12 - a11 * a23);\n M.ez.x = M.ex.z;\n M.ez.y = M.ey.z;\n M.ez.z = det * (a11 * a22 - a12 * a12);\n};\n\nMat33.mul = function(a, b) {\n ASSERT && Mat33.assert(a);\n if (b && \"z\" in b && \"y\" in b && \"x\" in b) {\n ASSERT && Vec3.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y + a.ez.x * b.z;\n var y = a.ex.y * b.x + a.ey.y * b.y + a.ez.y * b.z;\n var z = a.ex.z * b.x + a.ey.z * b.y + a.ez.z * b.z;\n return new Vec3(x, y, z);\n } else if (b && \"y\" in b && \"x\" in b) {\n ASSERT && Vec2.assert(b);\n var x = a.ex.x * b.x + a.ey.x * b.y;\n var y = a.ex.y * b.x + a.ey.y * b.y;\n return Vec2.neo(x, y);\n }\n ASSERT && common.assert(false);\n};\n\nMat33.add = function(a, b) {\n ASSERT && Mat33.assert(a);\n ASSERT && Mat33.assert(b);\n return new Vec3(a.x + b.x, a.y + b.y, a.z + b.z);\n};\n\n\n},{\"../util/common\":51,\"./Math\":18,\"./Vec2\":23,\"./Vec3\":24}],18:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar native = Math;\n\nvar math = module.exports = create(native);\n\nmath.EPSILON = 1e-9;\n\nmath.isFinite = function(x) {\n return typeof x === \"number\" && isFinite(x) && !isNaN(x);\n};\n\nmath.assert = function(x) {\n if (!ASSERT) return;\n if (!math.isFinite(x)) {\n DEBUG && common.debug(x);\n throw new Error(\"Invalid Number!\");\n }\n};\n\nmath.invSqrt = function(x) {\n return 1 / native.sqrt(x);\n};\n\nmath.nextPowerOfTwo = function(x) {\n x |= x >> 1;\n x |= x >> 2;\n x |= x >> 4;\n x |= x >> 8;\n x |= x >> 16;\n return x + 1;\n};\n\nmath.isPowerOfTwo = function(x) {\n return x > 0 && (x & x - 1) == 0;\n};\n\nmath.mod = function(num, min, max) {\n if (typeof min === \"undefined\") {\n max = 1, min = 0;\n } else if (typeof max === \"undefined\") {\n max = min, min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n};\n\nmath.clamp = function(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n};\n\nmath.random = function(min, max) {\n if (typeof min === \"undefined\") {\n max = 1;\n min = 0;\n } else if (typeof max === \"undefined\") {\n max = min;\n min = 0;\n }\n return min == max ? min : native.random() * (max - min) + min;\n};\n\n\n},{\"../util/common\":51,\"../util/create\":52}],19:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Position;\n\nvar Vec2 = require(\"./Vec2\");\n\nvar Rot = require(\"./Rot\");\n\nfunction Position() {\n this.c = Vec2.zero();\n this.a = 0;\n}\n\nPosition.prototype.getTransform = function(xf, p) {\n xf.q.set(this.a);\n xf.p.set(Vec2.sub(this.c, Rot.mul(xf.q, p)));\n return xf;\n};\n\n\n},{\"./Rot\":20,\"./Vec2\":23}],20:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Rot;\n\nvar common = require(\"../util/common\");\n\nvar Vec2 = require(\"./Vec2\");\n\nvar Math = require(\"./Math\");\n\nfunction Rot(angle) {\n if (!(this instanceof Rot)) {\n return new Rot(angle);\n }\n if (typeof angle === \"number\") {\n this.setAngle(angle);\n } else if (typeof angle === \"object\") {\n this.set(angle);\n } else {\n this.setIdentity();\n }\n}\n\nRot.neo = function(angle) {\n var obj = Object.create(Rot.prototype);\n obj.setAngle(angle);\n return obj;\n};\n\nRot.clone = function(rot) {\n ASSERT && Rot.assert(rot);\n var obj = Object.create(Rot.prototype);\n ojb.s = rot.s;\n ojb.c = rot.c;\n return ojb;\n};\n\nRot.identity = function(rot) {\n ASSERT && Rot.assert(rot);\n var obj = Object.create(Rot.prototype);\n obj.s = 0;\n obj.c = 1;\n return obj;\n};\n\nRot.isValid = function(o) {\n return o && Math.isFinite(o.s) && Math.isFinite(o.c);\n};\n\nRot.assert = function(o) {\n if (!ASSERT) return;\n if (!Rot.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Rot!\");\n }\n};\n\nRot.prototype.setIdentity = function() {\n this.s = 0;\n this.c = 1;\n};\n\nRot.prototype.set = function(angle) {\n if (typeof angle === \"object\") {\n ASSERT && Rot.assert(angle);\n this.s = angle.s;\n this.c = angle.c;\n } else {\n ASSERT && Math.assert(angle);\n this.s = Math.sin(angle);\n this.c = Math.cos(angle);\n }\n};\n\nRot.prototype.setAngle = function(angle) {\n ASSERT && Math.assert(angle);\n this.s = Math.sin(angle);\n this.c = Math.cos(angle);\n};\n\nRot.prototype.getAngle = function() {\n return Math.atan2(this.s, this.c);\n};\n\nRot.prototype.getXAxis = function() {\n return Vec2.neo(this.c, this.s);\n};\n\nRot.prototype.getYAxis = function() {\n return Vec2.neo(-this.s, this.c);\n};\n\nRot.mul = function(rot, m) {\n ASSERT && Rot.assert(rot);\n if (\"c\" in m && \"s\" in m) {\n ASSERT && Rot.assert(m);\n var qr = Rot.identity();\n qr.s = rot.s * m.c + rot.c * m.s;\n qr.c = rot.c * m.c - rot.s * m.s;\n return qr;\n } else if (\"x\" in m && \"y\" in m) {\n ASSERT && Vec2.assert(m);\n return Vec2.neo(rot.c * m.x - rot.s * m.y, rot.s * m.x + rot.c * m.y);\n }\n};\n\nRot.mulSub = function(rot, v, w) {\n var x = rot.c * (v.x - w.x) - rot.s * (v.y - w.y);\n var y = rot.s * (v.x - w.y) + rot.c * (v.y - w.y);\n return Vec2.neo(x, y);\n};\n\nRot.mulT = function(rot, m) {\n if (\"c\" in m && \"s\" in m) {\n ASSERT && Rot.assert(m);\n var qr = Rot.identity();\n qr.s = rot.c * m.s - rot.s * m.c;\n qr.c = rot.c * m.c + rot.s * m.s;\n return qr;\n } else if (\"x\" in m && \"y\" in m) {\n ASSERT && Vec2.assert(m);\n return Vec2.neo(rot.c * m.x + rot.s * m.y, -rot.s * m.x + rot.c * m.y);\n }\n};\n\n\n},{\"../util/common\":51,\"./Math\":18,\"./Vec2\":23}],21:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Sweep;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"./Math\");\n\nvar Vec2 = require(\"./Vec2\");\n\nvar Rot = require(\"./Rot\");\n\nvar Transform = require(\"./Transform\");\n\nfunction Sweep(c, a) {\n ASSERT && common.assert(typeof c === \"undefined\");\n ASSERT && common.assert(typeof a === \"undefined\");\n this.localCenter = Vec2.zero();\n this.c = Vec2.zero();\n this.a = 0;\n this.alpha0 = 0;\n this.c0 = Vec2.zero();\n this.a0 = 0;\n}\n\nSweep.prototype.setTransform = function(xf) {\n var c = Transform.mul(xf, this.localCenter);\n this.c.set(c);\n this.c0.set(c);\n this.a = xf.q.getAngle();\n this.a0 = xf.q.getAngle();\n};\n\nSweep.prototype.setLocalCenter = function(localCenter, xf) {\n this.localCenter.set(localCenter);\n var c = Transform.mul(xf, this.localCenter);\n this.c.set(c);\n this.c0.set(c);\n};\n\nSweep.prototype.getTransform = function(xf, beta) {\n beta = typeof beta === \"undefined\" ? 0 : beta;\n xf.q.setAngle((1 - beta) * this.a0 + beta * this.a);\n xf.p.wSet(1 - beta, this.c0, beta, this.c);\n xf.p.sub(Rot.mul(xf.q, this.localCenter));\n};\n\nSweep.prototype.advance = function(alpha) {\n ASSERT && common.assert(this.alpha0 < 1);\n var beta = (alpha - this.alpha0) / (1 - this.alpha0);\n this.c0.wSet(beta, this.c, 1 - beta, this.c0);\n this.a0 = beta * this.a + (1 - beta) * this.a0;\n this.alpha0 = alpha;\n};\n\nSweep.prototype.forward = function() {\n this.a0 = this.a;\n this.c0.set(this.c);\n};\n\nSweep.prototype.normalize = function() {\n var a0 = Math.mod(this.a0, -Math.PI, +Math.PI);\n this.a -= this.a0 - a0;\n this.a0 = a0;\n};\n\nSweep.prototype.clone = function() {\n var clone = new Sweep();\n clone.localCenter.set(this.localCenter);\n clone.alpha0 = this.alpha0;\n clone.a0 = this.a0;\n clone.a = this.a;\n clone.c0.set(this.c0);\n clone.c.set(this.c);\n return clone;\n};\n\nSweep.prototype.set = function(that) {\n this.localCenter.set(that.localCenter);\n this.alpha0 = that.alpha0;\n this.a0 = that.a0;\n this.a = that.a;\n this.c0.set(that.c0);\n this.c.set(that.c);\n};\n\n\n},{\"../util/common\":51,\"./Math\":18,\"./Rot\":20,\"./Transform\":22,\"./Vec2\":23}],22:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Transform;\n\nvar common = require(\"../util/common\");\n\nvar Vec2 = require(\"./Vec2\");\n\nvar Rot = require(\"./Rot\");\n\nfunction Transform(position, rotation) {\n if (!(this instanceof Transform)) {\n return new Transform(position, rotation);\n }\n this.p = Vec2.zero();\n this.q = Rot.identity();\n if (typeof position !== \"undefined\") {\n this.p.set(position);\n }\n if (typeof rotation !== \"undefined\") {\n this.q.set(rotation);\n }\n}\n\nTransform.clone = function(xf) {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(xf.p);\n obj.q = Rot.clone(xf.q);\n return obj;\n};\n\nTransform.neo = function(position, rotation) {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.clone(position);\n obj.q = Rot.clone(rotation);\n return obj;\n};\n\nTransform.identity = function() {\n var obj = Object.create(Transform.prototype);\n obj.p = Vec2.zero();\n obj.q = Rot.identity();\n return obj;\n};\n\nTransform.prototype.setIdentity = function() {\n this.p.setZero();\n this.q.setIdentity();\n};\n\nTransform.prototype.set = function(a, b) {\n if (Transform.isValid(a)) {\n this.p.set(a.p);\n this.q.set(a.q);\n } else {\n this.p.set(a);\n this.q.set(b);\n }\n};\n\nTransform.isValid = function(o) {\n return o && Vec2.isValid(o.p) && Rot.isValid(o.q);\n};\n\nTransform.assert = function(o) {\n if (!ASSERT) return;\n if (!Transform.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Transform!\");\n }\n};\n\nTransform.mul = function(a, b) {\n ASSERT && Transform.assert(a);\n if (Array.isArray(b)) {\n var arr = [];\n for (var i = 0; i < b.length; i++) {\n arr[i] = Transform.mul(a, b[i]);\n }\n return arr;\n } else if (\"x\" in b && \"y\" in b) {\n ASSERT && Vec2.assert(b);\n var x = a.q.c * b.x - a.q.s * b.y + a.p.x;\n var y = a.q.s * b.x + a.q.c * b.y + a.p.y;\n return Vec2.neo(x, y);\n } else if (\"p\" in b && \"q\" in b) {\n ASSERT && Transform.assert(b);\n var xf = Transform.identity();\n xf.q = Rot.mul(a.q, b.q);\n xf.p = Vec2.add(Rot.mul(a.q, b.p), a.p);\n return xf;\n }\n};\n\nTransform.mulT = function(a, b) {\n ASSERT && Transform.assert(a);\n if (\"x\" in b && \"y\" in b) {\n ASSERT && Vec2.assert(b);\n var px = b.x - a.p.x;\n var py = b.y - a.p.y;\n var x = a.q.c * px + a.q.s * py;\n var y = -a.q.s * px + a.q.c * py;\n return Vec2.neo(x, y);\n } else if (\"p\" in b && \"q\" in b) {\n ASSERT && Transform.assert(b);\n var xf = Transform.identity();\n xf.q.set(Rot.mulT(a.q, b.q));\n xf.p.set(Rot.mulT(a.q, Vec2.sub(b.p, a.p)));\n return xf;\n }\n};\n\n\n},{\"../util/common\":51,\"./Rot\":20,\"./Vec2\":23}],23:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Vec2;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"./Math\");\n\nfunction Vec2(x, y) {\n if (!(this instanceof Vec2)) {\n return new Vec2(x, y);\n }\n if (typeof x === \"undefined\") {\n this.x = 0, this.y = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x, this.y = x.y;\n } else {\n this.x = x, this.y = y;\n }\n ASSERT && Vec2.assert(this);\n}\n\nVec2.zero = function() {\n var obj = Object.create(Vec2.prototype);\n obj.x = 0;\n obj.y = 0;\n return obj;\n};\n\nVec2.neo = function(x, y) {\n var obj = Object.create(Vec2.prototype);\n obj.x = x;\n obj.y = y;\n return obj;\n};\n\nVec2.clone = function(v, depricated) {\n ASSERT && Vec2.assert(v);\n ASSERT && common.assert(!depricated);\n return Vec2.neo(v.x, v.y);\n};\n\nVec2.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nVec2.isValid = function(v) {\n return v && Math.isFinite(v.x) && Math.isFinite(v.y);\n};\n\nVec2.assert = function(o) {\n if (!ASSERT) return;\n if (!Vec2.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Vec2!\");\n }\n};\n\nVec2.prototype.clone = function(depricated) {\n return Vec2.clone(this, depricated);\n};\n\nVec2.prototype.setZero = function() {\n this.x = 0;\n this.y = 0;\n return this;\n};\n\nVec2.prototype.set = function(x, y) {\n if (typeof x === \"object\") {\n ASSERT && Vec2.assert(x);\n this.x = x.x;\n this.y = x.y;\n } else {\n ASSERT && Math.assert(x);\n ASSERT && Math.assert(y);\n this.x = x;\n this.y = y;\n }\n return this;\n};\n\nVec2.prototype.wSet = function(a, v, b, w) {\n ASSERT && Math.assert(a);\n ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var y = a * v.y;\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n ASSERT && Math.assert(b);\n ASSERT && Vec2.assert(w);\n x += b * w.x;\n y += b * w.y;\n }\n this.x = x;\n this.y = y;\n return this;\n};\n\nVec2.prototype.add = function(w) {\n ASSERT && Vec2.assert(w);\n this.x += w.x;\n this.y += w.y;\n return this;\n};\n\nVec2.prototype.wAdd = function(a, v, b, w) {\n ASSERT && Math.assert(a);\n ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var y = a * v.y;\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n ASSERT && Math.assert(b);\n ASSERT && Vec2.assert(w);\n x += b * w.x;\n y += b * w.y;\n }\n this.x += x;\n this.y += y;\n return this;\n};\n\nVec2.prototype.wSub = function(a, v, b, w) {\n ASSERT && Math.assert(a);\n ASSERT && Vec2.assert(v);\n var x = a * v.x;\n var y = a * v.y;\n if (typeof b !== \"undefined\" || typeof w !== \"undefined\") {\n ASSERT && Math.assert(b);\n ASSERT && Vec2.assert(w);\n x += b * w.x;\n y += b * w.y;\n }\n this.x -= x;\n this.y -= y;\n return this;\n};\n\nVec2.prototype.sub = function(w) {\n ASSERT && Vec2.assert(w);\n this.x -= w.x;\n this.y -= w.y;\n return this;\n};\n\nVec2.prototype.mul = function(m) {\n ASSERT && Math.assert(m);\n this.x *= m;\n this.y *= m;\n return this;\n};\n\nVec2.prototype.length = function() {\n return Vec2.lengthOf(this);\n};\n\nVec2.prototype.lengthSquared = function() {\n return Vec2.lengthSquared(this);\n};\n\nVec2.prototype.normalize = function() {\n var length = this.length();\n if (length < Math.EPSILON) {\n return 0;\n }\n var invLength = 1 / length;\n this.x *= invLength;\n this.y *= invLength;\n return length;\n};\n\nVec2.lengthOf = function(v) {\n ASSERT && Vec2.assert(v);\n return Math.sqrt(v.x * v.x + v.y * v.y);\n};\n\nVec2.lengthSquared = function(v) {\n ASSERT && Vec2.assert(v);\n return v.x * v.x + v.y * v.y;\n};\n\nVec2.distance = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n var dx = v.x - w.x, dy = v.y - w.y;\n return Math.sqrt(dx * dx + dy * dy);\n};\n\nVec2.distanceSquared = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n var dx = v.x - w.x, dy = v.y - w.y;\n return dx * dx + dy * dy;\n};\n\nVec2.areEqual = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return v == w || typeof w === \"object\" && w !== null && v.x == w.x && v.y == w.y;\n};\n\nVec2.skew = function(v) {\n ASSERT && Vec2.assert(v);\n return Vec2.neo(-v.y, v.x);\n};\n\nVec2.dot = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return v.x * w.x + v.y * w.y;\n};\n\nVec2.cross = function(v, w) {\n if (typeof w === \"number\") {\n ASSERT && Vec2.assert(v);\n ASSERT && Math.assert(w);\n return Vec2.neo(w * v.y, -w * v.x);\n } else if (typeof v === \"number\") {\n ASSERT && Math.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(-v * w.y, v * w.x);\n } else {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return v.x * w.y - v.y * w.x;\n }\n};\n\nVec2.addCross = function(a, v, w) {\n if (typeof w === \"number\") {\n ASSERT && Vec2.assert(v);\n ASSERT && Math.assert(w);\n return Vec2.neo(w * v.y + a.x, -w * v.x + a.y);\n } else if (typeof v === \"number\") {\n ASSERT && Math.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(-v * w.y + a.x, v * w.x + a.y);\n }\n ASSERT && common.assert(false);\n};\n\nVec2.add = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(v.x + w.x, v.y + w.y);\n};\n\nVec2.wAdd = function(a, v, b, w) {\n var r = Vec2.zero();\n r.wAdd(a, v, b, w);\n return r;\n};\n\nVec2.sub = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(v.x - w.x, v.y - w.y);\n};\n\nVec2.mul = function(a, b) {\n if (typeof a === \"object\") {\n ASSERT && Vec2.assert(a);\n ASSERT && Math.assert(b);\n return Vec2.neo(a.x * b, a.y * b);\n } else if (typeof b === \"object\") {\n ASSERT && Math.assert(a);\n ASSERT && Vec2.assert(b);\n return Vec2.neo(a * b.x, a * b.y);\n }\n};\n\nVec2.prototype.neg = function() {\n this.x = -this.x;\n this.y = -this.y;\n return this;\n};\n\nVec2.neg = function(v) {\n ASSERT && Vec2.assert(v);\n return Vec2.neo(-v.x, -v.y);\n};\n\nVec2.abs = function(v) {\n ASSERT && Vec2.assert(v);\n return Vec2.neo(Math.abs(v.x), Math.abs(v.y));\n};\n\nVec2.mid = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo((v.x + w.x) * .5, (v.y + w.y) * .5);\n};\n\nVec2.upper = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(Math.max(v.x, w.x), Math.max(v.y, w.y));\n};\n\nVec2.lower = function(v, w) {\n ASSERT && Vec2.assert(v);\n ASSERT && Vec2.assert(w);\n return Vec2.neo(Math.min(v.x, w.x), Math.min(v.y, w.y));\n};\n\nVec2.prototype.clamp = function(max) {\n var lengthSqr = this.x * this.x + this.y * this.y;\n if (lengthSqr > max * max) {\n var invLength = Math.invSqrt(lengthSqr);\n this.x *= invLength * max;\n this.y *= invLength * max;\n }\n return this;\n};\n\nVec2.clamp = function(v, max) {\n v = Vec2.neo(v.x, v.y);\n v.clamp(max);\n return v;\n};\n\n\n},{\"../util/common\":51,\"./Math\":18}],24:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Vec3;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"./Math\");\n\nfunction Vec3(x, y, z) {\n if (!(this instanceof Vec3)) {\n return new Vec3(x, y, z);\n }\n if (typeof x === \"undefined\") {\n this.x = 0, this.y = 0, this.z = 0;\n } else if (typeof x === \"object\") {\n this.x = x.x, this.y = x.y, this.z = x.z;\n } else {\n this.x = x, this.y = y, this.z = z;\n }\n ASSERT && Vec3.assert(this);\n}\n\nVec3.prototype.toString = function() {\n return JSON.stringify(this);\n};\n\nVec3.isValid = function(v) {\n return v && Math.isFinite(v.x) && Math.isFinite(v.y) && Math.isFinite(v.z);\n};\n\nVec3.assert = function(o) {\n if (!ASSERT) return;\n if (!Vec3.isValid(o)) {\n DEBUG && common.debug(o);\n throw new Error(\"Invalid Vec3!\");\n }\n};\n\nVec3.prototype.setZero = function() {\n this.x = 0;\n this.y = 0;\n this.z = 0;\n return this;\n};\n\nVec3.prototype.set = function(x, y, z) {\n this.x = x;\n this.y = y;\n this.z = z;\n return this;\n};\n\nVec3.prototype.add = function(w) {\n this.x += w.x;\n this.y += w.y;\n this.z += w.z;\n return this;\n};\n\nVec3.prototype.sub = function(w) {\n this.x -= w.x;\n this.y -= w.y;\n this.z -= w.z;\n return this;\n};\n\nVec3.prototype.mul = function(m) {\n this.x *= m;\n this.y *= m;\n this.z *= m;\n return this;\n};\n\nVec3.areEqual = function(v, w) {\n return v == w || typeof w === \"object\" && w !== null && v.x == w.x && v.y == w.y && v.z == w.z;\n};\n\nVec3.dot = function(v, w) {\n return v.x * w.x + v.y * w.y + v.z * w.z;\n};\n\nVec3.cross = function(v, w) {\n return new Vec3(v.y * w.z - v.z * w.y, v.z * w.x - v.x * w.z, v.x * w.y - v.y * w.x);\n};\n\nVec3.add = function(v, w) {\n return new Vec3(v.x + w.x, v.y + w.y, v.z + w.z);\n};\n\nVec3.sub = function(v, w) {\n return new Vec3(v.x - w.x, v.y - w.y, v.z - w.z);\n};\n\nVec3.mul = function(v, m) {\n return new Vec3(m * v.x, m * v.y, m * v.z);\n};\n\nVec3.prototype.neg = function(m) {\n this.x = -this.x;\n this.y = -this.y;\n this.z = -this.z;\n return this;\n};\n\nVec3.neg = function(v) {\n return new Vec3(-v.x, -v.y, -v.z);\n};\n\n\n},{\"../util/common\":51,\"./Math\":18}],25:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Velocity;\n\nvar Vec2 = require(\"./Vec2\");\n\nfunction Velocity() {\n this.v = Vec2.zero();\n this.w = 0;\n}\n\n\n},{\"./Vec2\":23}],26:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nexports.toString = function(newline) {\n newline = typeof newline === \"string\" ? newline : \"\\n\";\n var string = \"\";\n for (var name in this) {\n if (typeof this[name] !== \"function\" && typeof this[name] !== \"object\") {\n string += name + \": \" + this[name] + newline;\n }\n }\n return string;\n};\n\n\n},{}],27:[function(require,module,exports){\nexports.internal = {};\n\nexports.Math = require(\"./common/Math\");\n\nexports.Vec2 = require(\"./common/Vec2\");\n\nexports.Transform = require(\"./common/Transform\");\n\nexports.Rot = require(\"./common/Rot\");\n\nexports.AABB = require(\"./collision/AABB\");\n\nexports.Shape = require(\"./Shape\");\n\nexports.Fixture = require(\"./Fixture\");\n\nexports.Body = require(\"./Body\");\n\nexports.Contact = require(\"./Contact\");\n\nexports.Joint = require(\"./Joint\");\n\nexports.World = require(\"./World\");\n\nexports.Circle = require(\"./shape/CircleShape\");\n\nexports.Edge = require(\"./shape/EdgeShape\");\n\nexports.Polygon = require(\"./shape/PolygonShape\");\n\nexports.Chain = require(\"./shape/ChainShape\");\n\nexports.Box = require(\"./shape/BoxShape\");\n\nrequire(\"./shape/CollideCircle\");\n\nrequire(\"./shape/CollideEdgeCircle\");\n\nexports.internal.CollidePolygons = require(\"./shape/CollidePolygon\");\n\nrequire(\"./shape/CollideCirclePolygone\");\n\nrequire(\"./shape/CollideEdgePolygon\");\n\nexports.DistanceJoint = require(\"./joint/DistanceJoint\");\n\nexports.FrictionJoint = require(\"./joint/FrictionJoint\");\n\nexports.GearJoint = require(\"./joint/GearJoint\");\n\nexports.MotorJoint = require(\"./joint/MotorJoint\");\n\nexports.MouseJoint = require(\"./joint/MouseJoint\");\n\nexports.PrismaticJoint = require(\"./joint/PrismaticJoint\");\n\nexports.PulleyJoint = require(\"./joint/PulleyJoint\");\n\nexports.RevoluteJoint = require(\"./joint/RevoluteJoint\");\n\nexports.RopeJoint = require(\"./joint/RopeJoint\");\n\nexports.WeldJoint = require(\"./joint/WeldJoint\");\n\nexports.WheelJoint = require(\"./joint/WheelJoint\");\n\nexports.internal.Sweep = require(\"./common/Sweep\");\n\nexports.internal.stats = require(\"./common/stats\");\n\nexports.internal.Manifold = require(\"./Manifold\");\n\nexports.internal.Distance = require(\"./collision/Distance\");\n\nexports.internal.TimeOfImpact = require(\"./collision/TimeOfImpact\");\n\nexports.internal.DynamicTree = require(\"./collision/DynamicTree\");\n\nexports.internal.Settings = require(\"./Settings\");\n\n\n},{\"./Body\":2,\"./Contact\":3,\"./Fixture\":4,\"./Joint\":5,\"./Manifold\":6,\"./Settings\":7,\"./Shape\":8,\"./World\":10,\"./collision/AABB\":11,\"./collision/Distance\":13,\"./collision/DynamicTree\":14,\"./collision/TimeOfImpact\":15,\"./common/Math\":18,\"./common/Rot\":20,\"./common/Sweep\":21,\"./common/Transform\":22,\"./common/Vec2\":23,\"./common/stats\":26,\"./joint/DistanceJoint\":28,\"./joint/FrictionJoint\":29,\"./joint/GearJoint\":30,\"./joint/MotorJoint\":31,\"./joint/MouseJoint\":32,\"./joint/PrismaticJoint\":33,\"./joint/PulleyJoint\":34,\"./joint/RevoluteJoint\":35,\"./joint/RopeJoint\":36,\"./joint/WeldJoint\":37,\"./joint/WheelJoint\":38,\"./shape/BoxShape\":39,\"./shape/ChainShape\":40,\"./shape/CircleShape\":41,\"./shape/CollideCircle\":42,\"./shape/CollideCirclePolygone\":43,\"./shape/CollideEdgeCircle\":44,\"./shape/CollideEdgePolygon\":45,\"./shape/CollidePolygon\":46,\"./shape/EdgeShape\":47,\"./shape/PolygonShape\":48}],28:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = DistanceJoint;\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nDistanceJoint.TYPE = \"distance-joint\";\n\nDistanceJoint._super = Joint;\n\nDistanceJoint.prototype = create(DistanceJoint._super.prototype);\n\nvar DistanceJointDef = {\n frequencyHz: 0,\n dampingRatio: 0\n};\n\nfunction DistanceJoint(def, bodyA, anchorA, bodyB, anchorB) {\n if (!(this instanceof DistanceJoint)) {\n return new DistanceJoint(def, bodyA, anchorA, bodyB, anchorB);\n }\n def = options(def, DistanceJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = DistanceJoint.TYPE;\n this.m_localAnchorA = def.localAnchorA || bodyA.getLocalPoint(anchorA);\n this.m_localAnchorB = def.localAnchorB || bodyB.getLocalPoint(anchorB);\n this.m_length = Vec2.distance(anchorB, anchorA);\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = 0;\n this.m_gamma = 0;\n this.m_bias = 0;\n this.m_u;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass;\n}\n\nDistanceJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nDistanceJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nDistanceJoint.prototype.setLength = function(length) {\n this.m_length = length;\n};\n\nDistanceJoint.prototype.getLength = function() {\n return this.m_length;\n};\n\nDistanceJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n};\n\nDistanceJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n};\n\nDistanceJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n};\n\nDistanceJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n};\n\nDistanceJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nDistanceJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nDistanceJoint.prototype.getReactionForce = function(inv_dt) {\n var F = Vec2.mul(inv_dt * this.m_impulse, this.m_u);\n return F;\n};\n\nDistanceJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0;\n};\n\nDistanceJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_u = Vec2.sub(Vec2.add(cB, this.m_rB), Vec2.add(cA, this.m_rA));\n var length = this.m_u.length();\n if (length > Settings.linearSlop) {\n this.m_u.mul(1 / length);\n } else {\n this.m_u.set(0, 0);\n }\n var crAu = Vec2.cross(this.m_rA, this.m_u);\n var crBu = Vec2.cross(this.m_rB, this.m_u);\n var invMass = this.m_invMassA + this.m_invIA * crAu * crAu + this.m_invMassB + this.m_invIB * crBu * crBu;\n this.m_mass = invMass != 0 ? 1 / invMass : 0;\n if (this.m_frequencyHz > 0) {\n var C = length - this.m_length;\n var omega = 2 * Math.PI * this.m_frequencyHz;\n var d = 2 * this.m_mass * this.m_dampingRatio * omega;\n var k = this.m_mass * omega * omega;\n var h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0;\n this.m_bias = C * h * k * this.m_gamma;\n invMass += this.m_gamma;\n this.m_mass = invMass != 0 ? 1 / invMass : 0;\n } else {\n this.m_gamma = 0;\n this.m_bias = 0;\n }\n if (step.warmStarting) {\n this.m_impulse *= step.dtRatio;\n var P = Vec2.mul(this.m_impulse, this.m_u);\n vA.wSub(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.wAdd(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n } else {\n this.m_impulse = 0;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nDistanceJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var vpA = Vec2.add(vA, Vec2.cross(wA, this.m_rA));\n var vpB = Vec2.add(vB, Vec2.cross(wB, this.m_rB));\n var Cdot = Vec2.dot(this.m_u, vpB) - Vec2.dot(this.m_u, vpA);\n var impulse = -this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse);\n this.m_impulse += impulse;\n var P = Vec2.mul(impulse, this.m_u);\n vA.wSub(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.wAdd(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nDistanceJoint.prototype.solvePositionConstraints = function(step) {\n if (this.m_frequencyHz > 0) {\n return true;\n }\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n var u = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n var length = u.normalize();\n var C = length - this.m_length;\n C = Math.clamp(C, -Settings.maxLinearCorrection, Settings.maxLinearCorrection);\n var impulse = -this.m_mass * C;\n var P = Vec2.mul(impulse, u);\n cA.wSub(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.cross(rA, P);\n cB.wAdd(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.cross(rB, P);\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n return Math.abs(C) < Settings.linearSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/create\":52,\"../util/options\":53}],29:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = FrictionJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nFrictionJoint.TYPE = \"friction-joint\";\n\nFrictionJoint._super = Joint;\n\nFrictionJoint.prototype = create(FrictionJoint._super.prototype);\n\nvar FrictionJointDef = {\n maxForce: 0,\n maxTorque: 0\n};\n\nfunction FrictionJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof FrictionJoint)) {\n return new FrictionJoint(def, bodyA, bodyB, anchor);\n }\n def = options(def, FrictionJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = FrictionJoint.TYPE;\n if (anchor) {\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n } else {\n this.m_localAnchorA = Vec2.zero();\n this.m_localAnchorB = Vec2.zero();\n }\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_linearMass;\n this.m_angularMass;\n}\n\nFrictionJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nFrictionJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nFrictionJoint.prototype.setMaxForce = function(force) {\n ASSERT && common.assert(IsValid(force) && force >= 0);\n this.m_maxForce = force;\n};\n\nFrictionJoint.prototype.getMaxForce = function() {\n return this.m_maxForce;\n};\n\nFrictionJoint.prototype.setMaxTorque = function(torque) {\n ASSERT && common.assert(IsValid(torque) && torque >= 0);\n this.m_maxTorque = torque;\n};\n\nFrictionJoint.prototype.getMaxTorque = function() {\n return this.m_maxTorque;\n};\n\nFrictionJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nFrictionJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nFrictionJoint.prototype.getReactionForce = function(inv_dt) {\n return inv_dt * this.m_linearImpulse;\n};\n\nFrictionJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_angularImpulse;\n};\n\nFrictionJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n var K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n this.m_linearMass = K.getInverse();\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0) {\n this.m_angularMass = 1 / this.m_angularMass;\n }\n if (step.warmStarting) {\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n var P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_angularImpulse);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + this.m_angularImpulse);\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0;\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nFrictionJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n var h = step.dt;\n {\n var Cdot = wB - wA;\n var impulse = -this.m_angularMass * Cdot;\n var oldImpulse = this.m_angularImpulse;\n var maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = Math.clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n {\n var Cdot = Vec2.sub(Vec2.add(vB, Vec2.cross(wB, this.m_rB)), Vec2.add(vA, Vec2.cross(wA, this.m_rA)));\n var impulse = Vec2.neg(Mat22.mul(this.m_linearMass, Cdot));\n var oldImpulse = this.m_linearImpulse;\n this.m_linearImpulse.add(impulse);\n var maxImpulse = h * this.m_maxForce;\n if (this.m_linearImpulse.lengthSquared() > maxImpulse * maxImpulse) {\n this.m_linearImpulse.normalize();\n this.m_linearImpulse.mul(maxImpulse);\n }\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n vA.wSub(mA, impulse);\n wA -= iA * Vec2.cross(this.m_rA, impulse);\n vB.wAdd(mB, impulse);\n wB += iB * Vec2.cross(this.m_rB, impulse);\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nFrictionJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],30:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = GearJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nvar RevoluteJoint = require(\"./RevoluteJoint\");\n\nvar PrismaticJoint = require(\"./PrismaticJoint\");\n\nGearJoint.TYPE = \"gear-joint\";\n\nGearJoint._super = Joint;\n\nGearJoint.prototype = create(GearJoint._super.prototype);\n\nvar GearJointDef = {\n ratio: 1\n};\n\nfunction GearJoint(def, bodyA, bodyB, joint1, joint2, ratio) {\n if (!(this instanceof GearJoint)) {\n return new GearJoint(def, bodyA, bodyB, joint1, joint2, ratio);\n }\n def = options(def, GearJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = GearJoint.TYPE;\n ASSERT && common.assert(joint1.m_type == RevoluteJoint.TYPE || joint1.m_type == PrismaticJoint.TYPE);\n ASSERT && common.assert(joint2.m_type == RevoluteJoint.TYPE || joint2.m_type == PrismaticJoint.TYPE);\n this.m_joint1 = joint1;\n this.m_joint2 = joint2;\n this.m_type1 = this.m_joint1.getType();\n this.m_type2 = this.m_joint2.getType();\n var coordinateA, coordinateB;\n this.m_bodyC = this.m_joint1.getBodyA();\n this.m_bodyA = this.m_joint1.getBodyB();\n var xfA = this.m_bodyA.m_xf;\n var aA = this.m_bodyA.m_sweep.a;\n var xfC = this.m_bodyC.m_xf;\n var aC = this.m_bodyC.m_sweep.a;\n if (this.m_type1 == RevoluteJoint.TYPE) {\n var revolute = joint1;\n this.m_localAnchorC = revolute.m_localAnchorA;\n this.m_localAnchorA = revolute.m_localAnchorB;\n this.m_referenceAngleA = revolute.m_referenceAngle;\n this.m_localAxisC = Vec2.zero();\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n var prismatic = joint1;\n this.m_localAnchorC = prismatic.m_localAnchorA;\n this.m_localAnchorA = prismatic.m_localAnchorB;\n this.m_referenceAngleA = prismatic.m_referenceAngle;\n this.m_localAxisC = prismatic.m_localXAxisA;\n var pC = this.m_localAnchorC;\n var pA = Rot.mulT(xfC.q, Vec2.add(Rot.mul(xfA.q, this.m_localAnchorA), Vec2.sub(xfA.p, xfC.p)));\n coordinateA = Vec2.dot(pA, this.m_localAxisC) - Vec2.dot(pC, this.m_localAxisC);\n }\n this.m_bodyD = this.m_joint2.getBodyA();\n this.m_bodyB = this.m_joint2.getBodyB();\n var xfB = this.m_bodyB.m_xf;\n var aB = this.m_bodyB.m_sweep.a;\n var xfD = this.m_bodyD.m_xf;\n var aD = this.m_bodyD.m_sweep.a;\n if (this.m_type2 == RevoluteJoint.TYPE) {\n var revolute = joint2;\n this.m_localAnchorD = revolute.m_localAnchorA;\n this.m_localAnchorB = revolute.m_localAnchorB;\n this.m_referenceAngleB = revolute.m_referenceAngle;\n this.m_localAxisD = Vec2.zero();\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n var prismatic = joint2;\n this.m_localAnchorD = prismatic.m_localAnchorA;\n this.m_localAnchorB = prismatic.m_localAnchorB;\n this.m_referenceAngleB = prismatic.m_referenceAngle;\n this.m_localAxisD = prismatic.m_localXAxisA;\n var pD = this.m_localAnchorD;\n var pB = Rot.mulT(xfD.q, Vec2.add(Rot.mul(xfB.q, this.m_localAnchorB), Vec2.sub(xfB.p, xfD.p)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n this.m_ratio = ratio || def.ratio;\n this.m_constant = coordinateA + this.m_ratio * coordinateB;\n this.m_impulse = 0;\n this.m_lcA, this.m_lcB, this.m_lcC, this.m_lcD;\n this.m_mA, this.m_mB, this.m_mC, this.m_mD;\n this.m_iA, this.m_iB, this.m_iC, this.m_iD;\n this.m_JvAC, this.m_JvBD;\n this.m_JwA, this.m_JwB, this.m_JwC, this.m_JwD;\n this.m_mass;\n}\n\nGearJoint.prototype.getJoint1 = function() {\n return this.m_joint1;\n};\n\nGearJoint.prototype.getJoint2 = function() {\n return this.m_joint2;\n};\n\nGearJoint.prototype.setRatio = function(ratio) {\n ASSERT && common.assert(IsValid(ratio));\n this.m_ratio = ratio;\n};\n\nGearJoint.prototype.setRatio = function() {\n return this.m_ratio;\n};\n\nGearJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nGearJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nGearJoint.prototype.getReactionForce = function(inv_dt) {\n var P = this.m_impulse * this.m_JvAC;\n return inv_dt * P;\n};\n\nGearJoint.prototype.getReactionTorque = function(inv_dt) {\n var L = this.m_impulse * this.m_JwA;\n return inv_dt * L;\n};\n\nGearJoint.prototype.initVelocityConstraints = function(step) {\n this.m_lcA = this.m_bodyA.m_sweep.localCenter;\n this.m_lcB = this.m_bodyB.m_sweep.localCenter;\n this.m_lcC = this.m_bodyC.m_sweep.localCenter;\n this.m_lcD = this.m_bodyD.m_sweep.localCenter;\n this.m_mA = this.m_bodyA.m_invMass;\n this.m_mB = this.m_bodyB.m_invMass;\n this.m_mC = this.m_bodyC.m_invMass;\n this.m_mD = this.m_bodyD.m_invMass;\n this.m_iA = this.m_bodyA.m_invI;\n this.m_iB = this.m_bodyB.m_invI;\n this.m_iC = this.m_bodyC.m_invI;\n this.m_iD = this.m_bodyD.m_invI;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var aC = this.m_bodyC.c_position.a;\n var vC = this.m_bodyC.c_velocity.v;\n var wC = this.m_bodyC.c_velocity.w;\n var aD = this.m_bodyD.c_position.a;\n var vD = this.m_bodyD.c_velocity.v;\n var wD = this.m_bodyD.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var qC = Rot.neo(aC);\n var qD = Rot.neo(aD);\n this.m_mass = 0;\n if (this.m_type1 == RevoluteJoint.TYPE) {\n this.m_JvAC = Vec2.zero();\n this.m_JwA = 1;\n this.m_JwC = 1;\n this.m_mass += this.m_iA + this.m_iC;\n } else {\n var u = Rot.mul(qC, this.m_localAxisC);\n var rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n this.m_JvAC = u;\n this.m_JwC = Vec2.cross(rC, u);\n this.m_JwA = Vec2.cross(rA, u);\n this.m_mass += this.m_mC + this.m_mA + this.m_iC * this.m_JwC * this.m_JwC + this.m_iA * this.m_JwA * this.m_JwA;\n }\n if (this.m_type2 == RevoluteJoint.TYPE) {\n this.m_JvBD = Vec2.zero();\n this.m_JwB = this.m_ratio;\n this.m_JwD = this.m_ratio;\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n } else {\n var u = Rot.mul(qD, this.m_localAxisD);\n var rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n this.m_JvBD = Vec2.mul(this.m_ratio, u);\n this.m_JwD = this.m_ratio * Vec2.cross(rD, u);\n this.m_JwB = this.m_ratio * Vec2.cross(rB, u);\n this.m_mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * this.m_JwD * this.m_JwD + this.m_iB * this.m_JwB * this.m_JwB;\n }\n this.m_mass = this.m_mass > 0 ? 1 / this.m_mass : 0;\n if (step.warmStarting) {\n vA.wAdd(this.m_mA * this.m_impulse, this.m_JvAC);\n wA += this.m_iA * this.m_impulse * this.m_JwA;\n vB.wAdd(this.m_mB * this.m_impulse, this.m_JvBD);\n wB += this.m_iB * this.m_impulse * this.m_JwB;\n vC.wSub(this.m_mC * this.m_impulse, this.m_JvAC);\n wC -= this.m_iC * this.m_impulse * this.m_JwC;\n vD.wSub(this.m_mD * this.m_impulse, this.m_JvBD);\n wD -= this.m_iD * this.m_impulse * this.m_JwD;\n } else {\n this.m_impulse = 0;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.set(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.set(vD);\n this.m_bodyD.c_velocity.w = wD;\n};\n\nGearJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var vC = this.m_bodyC.c_velocity.v;\n var wC = this.m_bodyC.c_velocity.w;\n var vD = this.m_bodyD.c_velocity.v;\n var wD = this.m_bodyD.c_velocity.w;\n var Cdot = Vec2.dot(this.m_JvAC, vA) - Vec2.dot(this.m_JvAC, vC) + Vec2.dot(this.m_JvBD, vB) - Vec2.dot(this.m_JvBD, vD);\n Cdot += this.m_JwA * wA - this.m_JwC * wC + (this.m_JwB * wB - this.m_JwD * wD);\n var impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n vA.wAdd(this.m_mA * impulse, this.m_JvAC);\n wA += this.m_iA * impulse * this.m_JwA;\n vB.wAdd(this.m_mB * impulse, this.m_JvBD);\n wB += this.m_iB * impulse * this.m_JwB;\n vC.wSub(this.m_mC * impulse, this.m_JvAC);\n wC -= this.m_iC * impulse * this.m_JwC;\n vD.wSub(this.m_mD * impulse, this.m_JvBD);\n wD -= this.m_iD * impulse * this.m_JwD;\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n this.m_bodyC.c_velocity.v.set(vC);\n this.m_bodyC.c_velocity.w = wC;\n this.m_bodyD.c_velocity.v.set(vD);\n this.m_bodyD.c_velocity.w = wD;\n};\n\nGearJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var cC = this.m_bodyC.c_position.c;\n var aC = this.m_bodyC.c_position.a;\n var cD = this.m_bodyD.c_position.c;\n var aD = this.m_bodyD.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var qC = Rot.neo(aC);\n var qD = Rot.neo(aD);\n var linearError = 0;\n var coordinateA, coordinateB;\n var JvAC, JvBD;\n var JwA, JwB, JwC, JwD;\n var mass = 0;\n if (this.m_type1 == RevoluteJoint.TYPE) {\n JvAC = Vec2.zero();\n JwA = 1;\n JwC = 1;\n mass += this.m_iA + this.m_iC;\n coordinateA = aA - aC - this.m_referenceAngleA;\n } else {\n var u = Rot.mul(qC, this.m_localAxisC);\n var rC = Rot.mulSub(qC, this.m_localAnchorC, this.m_lcC);\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_lcA);\n JvAC = u;\n JwC = Vec2.cross(rC, u);\n JwA = Vec2.cross(rA, u);\n mass += this.m_mC + this.m_mA + this.m_iC * JwC * JwC + this.m_iA * JwA * JwA;\n var pC = this.m_localAnchorC - this.m_lcC;\n var pA = Rot.mulT(qC, Vec2.add(rA, Vec2.sub(cA, cC)));\n coordinateA = Dot(pA - pC, this.m_localAxisC);\n }\n if (this.m_type2 == RevoluteJoint.TYPE) {\n JvBD = Vec2.zero();\n JwB = this.m_ratio;\n JwD = this.m_ratio;\n mass += this.m_ratio * this.m_ratio * (this.m_iB + this.m_iD);\n coordinateB = aB - aD - this.m_referenceAngleB;\n } else {\n var u = Rot.mul(qD, this.m_localAxisD);\n var rD = Rot.mulSub(qD, this.m_localAnchorD, this.m_lcD);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_lcB);\n JvBD = Vec2.mul(this.m_ratio, u);\n JwD = this.m_ratio * Vec2.cross(rD, u);\n JwB = this.m_ratio * Vec2.cross(rB, u);\n mass += this.m_ratio * this.m_ratio * (this.m_mD + this.m_mB) + this.m_iD * JwD * JwD + this.m_iB * JwB * JwB;\n var pD = Vec2.sub(this.m_localAnchorD, this.m_lcD);\n var pB = Rot.mulT(qD, Vec2.add(rB, Vec2.sub(cB, cD)));\n coordinateB = Vec2.dot(pB, this.m_localAxisD) - Vec2.dot(pD, this.m_localAxisD);\n }\n var C = coordinateA + this.m_ratio * coordinateB - this.m_constant;\n var impulse = 0;\n if (mass > 0) {\n impulse = -C / mass;\n }\n cA.wAdd(this.m_mA * impulse, JvAC);\n aA += this.m_iA * impulse * JwA;\n cB.wAdd(this.m_mB * impulse, JvBD);\n aB += this.m_iB * impulse * JwB;\n cC.wAdd(this.m_mC * impulse, JvAC);\n aC -= this.m_iC * impulse * JwC;\n cD.wAdd(this.m_mD * impulse, JvBD);\n aD -= this.m_iD * impulse * JwD;\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n this.m_bodyC.c_position.c.set(cC);\n this.m_bodyC.c_position.a = aC;\n this.m_bodyD.c_position.c.set(cD);\n this.m_bodyD.c_position.a = aD;\n return linearError < Settings.linearSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53,\"./PrismaticJoint\":33,\"./RevoluteJoint\":35}],31:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = MotorJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nMotorJoint.TYPE = \"motor-joint\";\n\nMotorJoint._super = Joint;\n\nMotorJoint.prototype = create(MotorJoint._super.prototype);\n\nvar MotorJointDef = {\n maxForce: 1,\n maxTorque: 1,\n correctionFactor: .3\n};\n\nfunction MotorJoint(def, bodyA, bodyB) {\n if (!(this instanceof MotorJoint)) {\n return new MotorJoint(def, bodyA, bodyB);\n }\n def = options(def, MotorJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = MotorJoint.TYPE;\n var xB = bodyB.getPosition();\n this.m_linearOffset = bodyA.getLocalPoint(xB);\n var angleA = bodyA.getAngle();\n var angleB = bodyB.getAngle();\n this.m_angularOffset = angleB - angleA;\n this.m_linearImpulse = Vec2.zero();\n this.m_angularImpulse = 0;\n this.m_maxForce = def.maxForce;\n this.m_maxTorque = def.maxTorque;\n this.m_correctionFactor = def.correctionFactor;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_linearError;\n this.m_angularError;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_linearMass;\n this.m_angularMass;\n}\n\nMotorJoint.prototype.setMaxForce = function(force) {\n ASSERT && common.assert(IsValid(force) && force >= 0);\n this.m_maxForce = force;\n};\n\nMotorJoint.prototype.getMaxForce = function() {\n return this.m_maxForce;\n};\n\nMotorJoint.prototype.setMaxTorque = function(torque) {\n ASSERT && common.assert(IsValid(torque) && torque >= 0);\n this.m_maxTorque = torque;\n};\n\nMotorJoint.prototype.getMaxTorque = function() {\n return this.m_maxTorque;\n};\n\nMotorJoint.prototype.setCorrectionFactor = function(factor) {\n ASSERT && common.assert(IsValid(factor) && 0 <= factor && factor <= 1);\n this.m_correctionFactor = factor;\n};\n\nMotorJoint.prototype.getCorrectionFactor = function() {\n return this.m_correctionFactor;\n};\n\nMotorJoint.prototype.setLinearOffset = function(linearOffset) {\n if (linearOffset.x != this.m_linearOffset.x || linearOffset.y != this.m_linearOffset.y) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_linearOffset = linearOffset;\n }\n};\n\nMotorJoint.prototype.getLinearOffset = function() {\n return this.m_linearOffset;\n};\n\nMotorJoint.prototype.setAngularOffset = function(angularOffset) {\n if (angularOffset != this.m_angularOffset) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_angularOffset = angularOffset;\n }\n};\n\nMotorJoint.prototype.getAngularOffset = function() {\n return this.m_angularOffset;\n};\n\nMotorJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getPosition();\n};\n\nMotorJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getPosition();\n};\n\nMotorJoint.prototype.getReactionForce = function(inv_dt) {\n return inv_dt * this.m_linearImpulse;\n};\n\nMotorJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_angularImpulse;\n};\n\nMotorJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.neg(this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.neg(this.m_localCenterB));\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var K = new Mat22();\n K.ex.x = mA + mB + iA * this.m_rA.y * this.m_rA.y + iB * this.m_rB.y * this.m_rB.y;\n K.ex.y = -iA * this.m_rA.x * this.m_rA.y - iB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * this.m_rA.x * this.m_rA.x + iB * this.m_rB.x * this.m_rB.x;\n this.m_linearMass = K.getInverse();\n this.m_angularMass = iA + iB;\n if (this.m_angularMass > 0) {\n this.m_angularMass = 1 / this.m_angularMass;\n }\n this.m_linearError = Vec2.zero();\n this.m_linearError.wAdd(1, cB, 1, this.m_rB);\n this.m_linearError.wSub(1, cA, 1, this.m_rA);\n this.m_linearError.sub(Rot.mul(qA, this.m_linearOffset));\n this.m_angularError = aB - aA - this.m_angularOffset;\n if (step.warmStarting) {\n this.m_linearImpulse.mul(step.dtRatio);\n this.m_angularImpulse *= step.dtRatio;\n var P = Vec2.neo(this.m_linearImpulse.x, this.m_linearImpulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_angularImpulse);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + this.m_angularImpulse);\n } else {\n this.m_linearImpulse.setZero();\n this.m_angularImpulse = 0;\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nMotorJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n var h = step.dt;\n var inv_h = step.inv_dt;\n {\n var Cdot = wB - wA + inv_h * this.m_correctionFactor * this.m_angularError;\n var impulse = -this.m_angularMass * Cdot;\n var oldImpulse = this.m_angularImpulse;\n var maxImpulse = h * this.m_maxTorque;\n this.m_angularImpulse = Math.clamp(this.m_angularImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_angularImpulse - oldImpulse;\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n {\n var Cdot = Vec2.zero();\n Cdot.wAdd(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot.wSub(1, vA, 1, Vec2.cross(wA, this.m_rA));\n Cdot.wAdd(inv_h * this.m_correctionFactor, this.m_linearError);\n var impulse = Vec2.neg(Mat22.mul(this.m_linearMass, Cdot));\n var oldImpulse = Vec2.clone(this.m_linearImpulse);\n this.m_linearImpulse.add(impulse);\n var maxImpulse = h * this.m_maxForce;\n this.m_linearImpulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_linearImpulse, oldImpulse);\n vA.wSub(mA, impulse);\n wA -= iA * Vec2.cross(this.m_rA, impulse);\n vB.wAdd(mB, impulse);\n wB += iB * Vec2.cross(this.m_rB, impulse);\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nMotorJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],32:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = MouseJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nMouseJoint.TYPE = \"mouse-joint\";\n\nMouseJoint._super = Joint;\n\nMouseJoint.prototype = create(MouseJoint._super.prototype);\n\nvar MouseJointDef = {\n maxForce: 0,\n frequencyHz: 5,\n dampingRatio: .7\n};\n\nfunction MouseJoint(def, bodyA, bodyB, target) {\n if (!(this instanceof MouseJoint)) {\n return new MouseJoint(def, bodyA, bodyB, target);\n }\n def = options(def, MouseJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = MouseJoint.TYPE;\n ASSERT && common.assert(Math.isFinite(def.maxForce) && def.maxForce >= 0);\n ASSERT && common.assert(Math.isFinite(def.frequencyHz) && def.frequencyHz >= 0);\n ASSERT && common.assert(Math.isFinite(def.dampingRatio) && def.dampingRatio >= 0);\n this.m_targetA = Vec2.clone(target);\n this.m_localAnchorB = Transform.mulT(this.m_bodyB.getTransform(), this.m_targetA);\n this.m_maxForce = def.maxForce;\n this.m_impulse = Vec2.zero();\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_beta = 0;\n this.m_gamma = 0;\n this.m_rB = Vec2.zero();\n this.m_localCenterB = Vec2.zero();\n this.m_invMassB = 0;\n this.m_invIB = 0;\n this.mass = new Mat22();\n this.m_C = Vec2.zero();\n}\n\nMouseJoint.prototype.setTarget = function(target) {\n if (this.m_bodyB.isAwake() == false) {\n this.m_bodyB.setAwake(true);\n }\n this.m_targetA = Vec2.clone(target);\n};\n\nMouseJoint.prototype.getTarget = function() {\n return this.m_targetA;\n};\n\nMouseJoint.prototype.setMaxForce = function(force) {\n this.m_maxForce = force;\n};\n\nMouseJoint.getMaxForce = function() {\n return this.m_maxForce;\n};\n\nMouseJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n};\n\nMouseJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n};\n\nMouseJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n};\n\nMouseJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n};\n\nMouseJoint.prototype.getAnchorA = function() {\n return Vec2.clone(this.m_targetA);\n};\n\nMouseJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nMouseJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec2.mul(inv_dt, this.m_impulse);\n};\n\nMouseJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * 0;\n};\n\nMouseJoint.prototype.shiftOrigin = function(newOrigin) {\n this.m_targetA.sub(newOrigin);\n};\n\nMouseJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIB = this.m_bodyB.m_invI;\n var position = this.m_bodyB.c_position;\n var velocity = this.m_bodyB.c_velocity;\n var cB = position.c;\n var aB = position.a;\n var vB = velocity.v;\n var wB = velocity.w;\n var qB = Rot.neo(aB);\n var mass = this.m_bodyB.getMass();\n var omega = 2 * Math.PI * this.m_frequencyHz;\n var d = 2 * mass * this.m_dampingRatio * omega;\n var k = mass * (omega * omega);\n var h = step.dt;\n ASSERT && common.assert(d + h * k > Math.EPSILON);\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma != 0) {\n this.m_gamma = 1 / this.m_gamma;\n }\n this.m_beta = h * k * this.m_gamma;\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var K = new Mat22();\n K.ex.x = this.m_invMassB + this.m_invIB * this.m_rB.y * this.m_rB.y + this.m_gamma;\n K.ex.y = -this.m_invIB * this.m_rB.x * this.m_rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = this.m_invMassB + this.m_invIB * this.m_rB.x * this.m_rB.x + this.m_gamma;\n this.m_mass = K.getInverse();\n this.m_C.set(cB);\n this.m_C.wAdd(1, this.m_rB, -1, this.m_targetA);\n this.m_C.mul(this.m_beta);\n wB *= .98;\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n vB.wAdd(this.m_invMassB, this.m_impulse);\n wB += this.m_invIB * Vec2.cross(this.m_rB, this.m_impulse);\n } else {\n this.m_impulse.setZero();\n }\n velocity.v.set(vB);\n velocity.w = wB;\n};\n\nMouseJoint.prototype.solveVelocityConstraints = function(step) {\n var velocity = this.m_bodyB.c_velocity;\n var vB = Vec2.clone(velocity.v);\n var wB = velocity.w;\n var Cdot = Vec2.cross(wB, this.m_rB);\n Cdot.add(vB);\n Cdot.wAdd(1, this.m_C, this.m_gamma, this.m_impulse);\n Cdot.neg();\n var impulse = Mat22.mul(this.m_mass, Cdot);\n var oldImpulse = Vec2.clone(this.m_impulse);\n this.m_impulse.add(impulse);\n var maxImpulse = step.dt * this.m_maxForce;\n this.m_impulse.clamp(maxImpulse);\n impulse = Vec2.sub(this.m_impulse, oldImpulse);\n vB.wAdd(this.m_invMassB, impulse);\n wB += this.m_invIB * Vec2.cross(this.m_rB, impulse);\n velocity.v.set(vB);\n velocity.w = wB;\n};\n\nMouseJoint.prototype.solvePositionConstraints = function(step) {\n return true;\n};\n\n\n},{\"../Joint\":5,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],33:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = PrismaticJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nvar inactiveLimit = 0;\n\nvar atLowerLimit = 1;\n\nvar atUpperLimit = 2;\n\nvar equalLimits = 3;\n\nPrismaticJoint.TYPE = \"prismatic-joint\";\n\nPrismaticJoint._super = Joint;\n\nPrismaticJoint.prototype = create(PrismaticJoint._super.prototype);\n\nvar PrismaticJointDef = {\n enableLimit: false,\n lowerTranslation: 0,\n upperTranslation: 0,\n enableMotor: false,\n maxMotorForce: 0,\n motorSpeed: 0\n};\n\nfunction PrismaticJoint(def, bodyA, bodyB, anchor, axis) {\n if (!(this instanceof PrismaticJoint)) {\n return new PrismaticJoint(def, bodyA, bodyB, anchor, axis);\n }\n def = options(def, PrismaticJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = PrismaticJoint.TYPE;\n this.m_localAnchorA = def.localAnchorA || bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = def.localAnchorB || bodyB.getLocalPoint(anchor);\n this.m_localXAxisA = def.localAxisA || bodyA.getLocalVector(axis);\n this.m_localXAxisA.normalize();\n this.m_localYAxisA = Vec2.cross(1, this.m_localXAxisA);\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n this.m_impulse = Vec3();\n this.m_motorMass = 0;\n this.m_motorImpulse = 0;\n this.m_lowerTranslation = def.lowerTranslation;\n this.m_upperTranslation = def.upperTranslation;\n this.m_maxMotorForce = def.maxMotorForce;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_limitState = inactiveLimit;\n this.m_axis = Vec2.zero();\n this.m_perp = Vec2.zero();\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_axis, this.m_perp;\n this.m_s1, this.m_s2;\n this.m_a1, this.m_a2;\n this.m_K = new Mat33();\n this.m_motorMass;\n}\n\nPrismaticJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nPrismaticJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nPrismaticJoint.prototype.getLocalAxisA = function() {\n return this.m_localXAxisA;\n};\n\nPrismaticJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n};\n\nPrismaticJoint.prototype.getJointTranslation = function() {\n var pA = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n var pB = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n var d = Vec2.sub(pB, pA);\n var axis = this.m_bodyA.getWorldVector(this.m_localXAxisA);\n var translation = Vec2.dot(d, axis);\n return translation;\n};\n\nPrismaticJoint.prototype.getJointSpeed = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n var rA = Mul(bA.m_xf.q, this.m_localAnchorA - bA.m_sweep.localCenter);\n var rB = Mul(bB.m_xf.q, this.m_localAnchorB - bB.m_sweep.localCenter);\n var p1 = bA.m_sweep.c + rA;\n var p2 = bB.m_sweep.c + rB;\n var d = p2 - p1;\n var axis = Mul(bA.m_xf.q, this.m_localXAxisA);\n var vA = bA.m_linearVelocity;\n var vB = bB.m_linearVelocity;\n var wA = bA.m_angularVelocity;\n var wB = bB.m_angularVelocity;\n var speed = Dot(d, Cross(wA, axis)) + Dot(axis, vB + Cross(wB, rB) - vA - Cross(wA, rA));\n return speed;\n};\n\nPrismaticJoint.prototype.isLimitEnabled = function() {\n return this.m_enableLimit;\n};\n\nPrismaticJoint.prototype.enableLimit = function(flag) {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0;\n }\n};\n\nPrismaticJoint.prototype.getLowerLimit = function() {\n return this.m_lowerTranslation;\n};\n\nPrismaticJoint.prototype.getUpperLimit = function() {\n return this.m_upperTranslation;\n};\n\nPrismaticJoint.prototype.setLimits = function(lower, upper) {\n ASSERT && common.assert(lower <= upper);\n if (lower != this.m_lowerTranslation || upper != this.m_upperTranslation) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_lowerTranslation = lower;\n this.m_upperTranslation = upper;\n this.m_impulse.z = 0;\n }\n};\n\nPrismaticJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n};\n\nPrismaticJoint.prototype.enableMotor = function(flag) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n};\n\nPrismaticJoint.prototype.setMotorSpeed = function(speed) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n};\n\nPrismaticJoint.prototype.setMaxMotorForce = function(force) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorForce = force;\n};\n\nPrismaticJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n};\n\nPrismaticJoint.prototype.getMotorForce = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n};\n\nPrismaticJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nPrismaticJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nPrismaticJoint.prototype.getReactionForce = function(inv_dt) {\n return inv_dt * (this.m_impulse.x * this.m_perp + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis);\n};\n\nPrismaticJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.y;\n};\n\nPrismaticJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.wAdd(1, cB, 1, rB);\n d.wSub(1, cA, 1, rA);\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n {\n this.m_axis = Rot.mul(qA, this.m_localXAxisA);\n this.m_a1 = Vec2.cross(Vec2.add(d, rA), this.m_axis);\n this.m_a2 = Vec2.cross(rB, this.m_axis);\n this.m_motorMass = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n if (this.m_motorMass > 0) {\n this.m_motorMass = 1 / this.m_motorMass;\n }\n }\n {\n this.m_perp = Rot.mul(qA, this.m_localYAxisA);\n this.m_s1 = Vec2.cross(Vec2.add(d, rA), this.m_perp);\n this.m_s2 = Vec2.cross(rB, this.m_perp);\n var s1test = Vec2.cross(rA, this.m_perp);\n var k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;\n var k12 = iA * this.m_s1 + iB * this.m_s2;\n var k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;\n var k22 = iA + iB;\n if (k22 == 0) {\n k22 = 1;\n }\n var k23 = iA * this.m_a1 + iB * this.m_a2;\n var k33 = mA + mB + iA * this.m_a1 * this.m_a1 + iB * this.m_a2 * this.m_a2;\n this.m_K.ex.set(k11, k12, k13);\n this.m_K.ey.set(k12, k22, k23);\n this.m_K.ez.set(k13, k23, k33);\n }\n if (this.m_enableLimit) {\n var jointTranslation = Vec2.dot(this.m_axis, d);\n if (Math.abs(this.m_upperTranslation - this.m_lowerTranslation) < 2 * Settings.linearSlop) {\n this.m_limitState = equalLimits;\n } else if (jointTranslation <= this.m_lowerTranslation) {\n if (this.m_limitState != atLowerLimit) {\n this.m_limitState = atLowerLimit;\n this.m_impulse.z = 0;\n }\n } else if (jointTranslation >= this.m_upperTranslation) {\n if (this.m_limitState != atUpperLimit) {\n this.m_limitState = atUpperLimit;\n this.m_impulse.z = 0;\n }\n } else {\n this.m_limitState = inactiveLimit;\n this.m_impulse.z = 0;\n }\n } else {\n this.m_limitState = inactiveLimit;\n this.m_impulse.z = 0;\n }\n if (this.m_enableMotor == false) {\n this.m_motorImpulse = 0;\n }\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n var P = Vec2.wAdd(this.m_impulse.x, this.m_perp, this.m_motorImpulse + this.m_impulse.z, this.m_axis);\n var LA = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;\n var LB = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nPrismaticJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n if (this.m_enableMotor && this.m_limitState != equalLimits) {\n var Cdot = Vec2.dot(this.m_axis, Vec2.sub(vB, vA)) + this.m_a2 * wB - this.m_a1 * wA;\n var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);\n var oldImpulse = this.m_motorImpulse;\n var maxImpulse = step.dt * this.m_maxMotorForce;\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n var P = Vec2.zero().wSet(impulse, this.m_axis);\n var LA = impulse * this.m_a1;\n var LB = impulse * this.m_a2;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n }\n var Cdot1 = Vec2.zero();\n Cdot1.x += Vec2.dot(this.m_perp, vB) + this.m_s2 * wB;\n Cdot1.x -= Vec2.dot(this.m_perp, vA) + this.m_s1 * wA;\n Cdot1.y = wB - wA;\n if (this.m_enableLimit && this.m_limitState != inactiveLimit) {\n var Cdot2 = 0;\n Cdot2 += Vec2.dot(this.m_axis, vB) + this.m_a2 * wB;\n Cdot2 -= Vec2.dot(this.m_axis, vA) + this.m_a1 * wA;\n var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2);\n var f1 = Vec3(this.m_impulse);\n var df = this.m_K.solve33(Vec3.neg(Cdot));\n this.m_impulse.add(df);\n if (this.m_limitState == atLowerLimit) {\n this.m_impulse.z = Math.max(this.m_impulse.z, 0);\n } else if (this.m_limitState == atUpperLimit) {\n this.m_impulse.z = Math.min(this.m_impulse.z, 0);\n }\n var b = Vec2.wAdd(-1, Cdot1, -(this.m_impulse.z - f1.z), Vec2.neo(this.m_K.ez.x, this.m_K.ez.y));\n var f2r = Vec2.add(this.m_K.solve22(b), Vec2.neo(f1.x, f1.y));\n this.m_impulse.x = f2r.x;\n this.m_impulse.y = f2r.y;\n df = Vec3.sub(this.m_impulse, f1);\n var P = Vec2.wAdd(df.x, this.m_perp, df.z, this.m_axis);\n var LA = df.x * this.m_s1 + df.y + df.z * this.m_a1;\n var LB = df.x * this.m_s2 + df.y + df.z * this.m_a2;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n } else {\n var df = this.m_K.solve22(Vec2.neg(Cdot1));\n this.m_impulse.x += df.x;\n this.m_impulse.y += df.y;\n var P = Vec2.zero().wAdd(df.x, this.m_perp);\n var LA = df.x * this.m_s1 + df.y;\n var LB = df.x * this.m_s2 + df.y;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nPrismaticJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.sub(Vec2.add(cB, rB), Vec2.add(cA, rA));\n var axis = Rot.mul(qA, this.m_localXAxisA);\n var a1 = Vec2.cross(Vec2.add(d, rA), axis);\n var a2 = Vec2.cross(rB, axis);\n var perp = Rot.mul(qA, this.m_localYAxisA);\n var s1 = Vec2.cross(Vec2.add(d, rA), perp);\n var s2 = Vec2.cross(rB, perp);\n var impulse = Vec3();\n var C1 = Vec2.zero();\n C1.x = Vec2.dot(perp, d);\n C1.y = aB - aA - this.m_referenceAngle;\n var linearError = Math.abs(C1.x);\n var angularError = Math.abs(C1.y);\n var linearSlop = Settings.linearSlop;\n var maxLinearCorrection = Settings.maxLinearCorrection;\n var active = false;\n var C2 = 0;\n if (this.m_enableLimit) {\n var translation = Vec2.dot(axis, d);\n if (Math.abs(this.m_upperTranslation - this.m_lowerTranslation) < 2 * linearSlop) {\n C2 = Math.clamp(translation, -maxLinearCorrection, maxLinearCorrection);\n linearError = Math.max(linearError, Math.abs(translation));\n active = true;\n } else if (translation <= this.m_lowerTranslation) {\n C2 = Math.clamp(translation - this.m_lowerTranslation + linearSlop, -maxLinearCorrection, 0);\n linearError = Math.max(linearError, this.m_lowerTranslation - translation);\n active = true;\n } else if (translation >= this.m_upperTranslation) {\n C2 = Math.clamp(translation - this.m_upperTranslation - linearSlop, 0, maxLinearCorrection);\n linearError = Math.max(linearError, translation - this.m_upperTranslation);\n active = true;\n }\n }\n if (active) {\n var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n var k12 = iA * s1 + iB * s2;\n var k13 = iA * s1 * a1 + iB * s2 * a2;\n var k22 = iA + iB;\n if (k22 == 0) {\n k22 = 1;\n }\n var k23 = iA * a1 + iB * a2;\n var k33 = mA + mB + iA * a1 * a1 + iB * a2 * a2;\n var K = new Mat33();\n K.ex.set(k11, k12, k13);\n K.ey.set(k12, k22, k23);\n K.ez.set(k13, k23, k33);\n var C = Vec3();\n C.x = C1.x;\n C.y = C1.y;\n C.z = C2;\n impulse = K.solve33(Vec3.neg(C));\n } else {\n var k11 = mA + mB + iA * s1 * s1 + iB * s2 * s2;\n var k12 = iA * s1 + iB * s2;\n var k22 = iA + iB;\n if (k22 == 0) {\n k22 = 1;\n }\n var K = new Mat22();\n K.ex.set(k11, k12);\n K.ey.set(k12, k22);\n var impulse1 = K.solve(Vec2.neg(C1));\n impulse.x = impulse1.x;\n impulse.y = impulse1.y;\n impulse.z = 0;\n }\n var P = Vec2.wAdd(impulse.x, perp, impulse.z, axis);\n var LA = impulse.x * s1 + impulse.y + impulse.z * a1;\n var LB = impulse.x * s2 + impulse.y + impulse.z * a2;\n cA.wSub(mA, P);\n aA -= iA * LA;\n cB.wAdd(mB, P);\n aB += iB * LB;\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n return linearError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],34:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = PulleyJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nPulleyJoint.TYPE = \"pulley-joint\";\n\nPulleyJoint.MIN_PULLEY_LENGTH = 2;\n\nPulleyJoint._super = Joint;\n\nPulleyJoint.prototype = create(PulleyJoint._super.prototype);\n\nvar PulleyJointDef = {\n collideConnected: true\n};\n\nfunction PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio) {\n if (!(this instanceof PulleyJoint)) {\n return new PulleyJoint(def, bodyA, bodyB, groundA, groundB, anchorA, anchorB, ratio);\n }\n def = options(def, PulleyJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = PulleyJoint.TYPE;\n this.m_groundAnchorA = groundA;\n this.m_groundAnchorB = groundB;\n this.m_localAnchorA = bodyA.getLocalPoint(anchorA);\n this.m_localAnchorB = bodyB.getLocalPoint(anchorB);\n this.m_lengthA = Vec2.distance(anchorA, groundA);\n this.m_lengthB = Vec2.distance(anchorB, groundB);\n this.m_ratio = def.ratio || ratio;\n ASSERT && common.assert(ratio > Math.EPSILON);\n this.m_constant = this.m_lengthA + this.m_ratio * this.m_lengthB;\n this.m_impulse = 0;\n this.m_uA;\n this.m_uB;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass;\n}\n\nPulleyJoint.prototype.getGroundAnchorA = function() {\n return this.m_groundAnchorA;\n};\n\nPulleyJoint.prototype.getGroundAnchorB = function() {\n return this.m_groundAnchorB;\n};\n\nPulleyJoint.prototype.getLengthA = function() {\n return this.m_lengthA;\n};\n\nPulleyJoint.prototype.getLengthB = function() {\n return this.m_lengthB;\n};\n\nPulleyJoint.prototype.setRatio = function() {\n return this.m_ratio;\n};\n\nPulleyJoint.prototype.getCurrentLengthA = function() {\n var p = this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n var s = this.m_groundAnchorA;\n return Vec2.distance(p, s);\n};\n\nPulleyJoint.prototype.getCurrentLengthB = function() {\n var p = this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n var s = this.m_groundAnchorB;\n return Vec2.distance(p, s);\n};\n\nPulleyJoint.prototype.shiftOrigin = function(newOrigin) {\n this.m_groundAnchorA -= newOrigin;\n this.m_groundAnchorB -= newOrigin;\n};\n\nPulleyJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nPulleyJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nPulleyJoint.prototype.getReactionForce = function(inv_dt) {\n return Vec3.mul(inv_dt * this.m_impulse, this.m_uB);\n};\n\nPulleyJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0;\n};\n\nPulleyJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n this.m_uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n this.m_uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n var lengthA = this.m_uA.length();\n var lengthB = this.m_uB.length();\n if (lengthA > 10 * Settings.linearSlop) {\n this.m_uA.mul(1 / lengthA);\n } else {\n this.m_uA.setZero();\n }\n if (lengthB > 10 * Settings.linearSlop) {\n this.m_uB.mul(1 / lengthB);\n } else {\n this.m_uB.setZero();\n }\n var ruA = Vec2.cross(this.m_rA, this.m_uA);\n var ruB = Vec2.cross(this.m_rB, this.m_uB);\n var mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n var mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n this.m_mass = mA + this.m_ratio * this.m_ratio * mB;\n if (this.m_mass > 0) {\n this.m_mass = 1 / this.m_mass;\n }\n if (step.warmStarting) {\n this.m_impulse *= step.dtRatio;\n var PA = Vec2.mul(-this.m_impulse, this.m_uA);\n var PB = Vec2.mul(-this.m_ratio * this.m_impulse, this.m_uB);\n vA.wAdd(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.cross(this.m_rA, PA);\n vB.wAdd(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.cross(this.m_rB, PB);\n } else {\n this.m_impulse = 0;\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nPulleyJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var vpA = Vec2.add(vA, Vec2.cross(wA, this.m_rA));\n var vpB = Vec2.add(vB, Vec2.cross(wB, this.m_rB));\n var Cdot = -Vec2.dot(this.m_uA, vpA) - this.m_ratio * Vec2.dot(this.m_uB, vpB);\n var impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n var PA = Vec2.zero().wSet(-impulse, this.m_uA);\n var PB = Vec2.zero().wSet(-this.m_ratio * impulse, this.m_uB);\n vA.wAdd(this.m_invMassA, PA);\n wA += this.m_invIA * Vec2.cross(this.m_rA, PA);\n vB.wAdd(this.m_invMassB, PB);\n wB += this.m_invIB * Vec2.cross(this.m_rB, PB);\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nPulleyJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var uA = Vec2.sub(Vec2.add(cA, this.m_rA), this.m_groundAnchorA);\n var uB = Vec2.sub(Vec2.add(cB, this.m_rB), this.m_groundAnchorB);\n var lengthA = uA.length();\n var lengthB = uB.length();\n if (lengthA > 10 * Settings.linearSlop) {\n uA.mul(1 / lengthA);\n } else {\n uA.setZero();\n }\n if (lengthB > 10 * Settings.linearSlop) {\n uB.mul(1 / lengthB);\n } else {\n uB.setZero();\n }\n var ruA = Vec2.cross(rA, uA);\n var ruB = Vec2.cross(rB, uB);\n var mA = this.m_invMassA + this.m_invIA * ruA * ruA;\n var mB = this.m_invMassB + this.m_invIB * ruB * ruB;\n var mass = mA + this.m_ratio * this.m_ratio * mB;\n if (mass > 0) {\n mass = 1 / mass;\n }\n var C = this.m_constant - lengthA - this.m_ratio * lengthB;\n var linearError = Math.abs(C);\n var impulse = -mass * C;\n var PA = Vec2.zero().wSet(-impulse, uA);\n var PB = Vec2.zero().wSet(-this.m_ratio * impulse, uB);\n cA.wAdd(this.m_invMassA, PA);\n aA += this.m_invIA * Vec2.cross(rA, PA);\n cB.wAdd(this.m_invMassB, PB);\n aB += this.m_invIB * Vec2.cross(rB, PB);\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n return linearError < Settings.linearSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],35:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = RevoluteJoint;\n\nvar common = require(\"../util/common\");\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nvar inactiveLimit = 0;\n\nvar atLowerLimit = 1;\n\nvar atUpperLimit = 2;\n\nvar equalLimits = 3;\n\nRevoluteJoint.TYPE = \"revolute-joint\";\n\nRevoluteJoint._super = Joint;\n\nRevoluteJoint.prototype = create(RevoluteJoint._super.prototype);\n\nvar RevoluteJointDef = {\n lowerAngle: 0,\n upperAngle: 0,\n maxMotorTorque: 0,\n motorSpeed: 0,\n enableLimit: false,\n enableMotor: false\n};\n\nfunction RevoluteJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof RevoluteJoint)) {\n return new RevoluteJoint(def, bodyA, bodyB, anchor);\n }\n def = options(def, RevoluteJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = RevoluteJoint.TYPE;\n this.m_localAnchorA = def.localAnchorA || bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = def.localAnchorB || bodyB.getLocalPoint(anchor);\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n this.m_impulse = Vec3();\n this.m_motorImpulse = 0;\n this.m_lowerAngle = def.lowerAngle;\n this.m_upperAngle = def.upperAngle;\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableLimit = def.enableLimit;\n this.m_enableMotor = def.enableMotor;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass = new Mat33();\n this.m_motorMass;\n this.m_limitState = inactiveLimit;\n}\n\nRevoluteJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nRevoluteJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nRevoluteJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n};\n\nRevoluteJoint.prototype.getJointAngle = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n return bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;\n};\n\nRevoluteJoint.prototype.getJointSpeed = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n return bB.m_angularVelocity - bA.m_angularVelocity;\n};\n\nRevoluteJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n};\n\nRevoluteJoint.prototype.enableMotor = function(flag) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n};\n\nRevoluteJoint.prototype.getMotorTorque = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n};\n\nRevoluteJoint.prototype.setMotorSpeed = function(speed) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n};\n\nRevoluteJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n};\n\nRevoluteJoint.prototype.setMaxMotorTorque = function(torque) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n};\n\nRevoluteJoint.prototype.isLimitEnabled = function() {\n return this.m_enableLimit;\n};\n\nRevoluteJoint.prototype.enableLimit = function(flag) {\n if (flag != this.m_enableLimit) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableLimit = flag;\n this.m_impulse.z = 0;\n }\n};\n\nRevoluteJoint.prototype.getLowerLimit = function() {\n return this.m_lowerAngle;\n};\n\nRevoluteJoint.prototype.getUpperLimit = function() {\n return this.m_upperAngle;\n};\n\nRevoluteJoint.prototype.setLimits = function(lower, upper) {\n ASSERT && common.assert(lower <= upper);\n if (lower != this.m_lowerAngle || upper != this.m_upperAngle) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_impulse.z = 0;\n this.m_lowerAngle = lower;\n this.m_upperAngle = upper;\n }\n};\n\nRevoluteJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nRevoluteJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nRevoluteJoint.prototype.getReactionForce = function(inv_dt) {\n var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n return inv_dt * P;\n};\n\nRevoluteJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.z;\n};\n\nRevoluteJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var fixedRotation = iA + iB == 0;\n this.m_mass.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n this.m_mass.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n this.m_mass.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n this.m_mass.ex.y = this.m_mass.ey.x;\n this.m_mass.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n this.m_mass.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n this.m_mass.ex.z = this.m_mass.ez.x;\n this.m_mass.ey.z = this.m_mass.ez.y;\n this.m_mass.ez.z = iA + iB;\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0) {\n this.m_motorMass = 1 / this.m_motorMass;\n }\n if (this.m_enableMotor == false || fixedRotation) {\n this.m_motorImpulse = 0;\n }\n if (this.m_enableLimit && fixedRotation == false) {\n var jointAngle = aB - aA - this.m_referenceAngle;\n if (Math.abs(this.m_upperAngle - this.m_lowerAngle) < 2 * Settings.angularSlop) {\n this.m_limitState = equalLimits;\n } else if (jointAngle <= this.m_lowerAngle) {\n if (this.m_limitState != atLowerLimit) {\n this.m_impulse.z = 0;\n }\n this.m_limitState = atLowerLimit;\n } else if (jointAngle >= this.m_upperAngle) {\n if (this.m_limitState != atUpperLimit) {\n this.m_impulse.z = 0;\n }\n this.m_limitState = atUpperLimit;\n } else {\n this.m_limitState = inactiveLimit;\n this.m_impulse.z = 0;\n }\n } else {\n this.m_limitState = inactiveLimit;\n }\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n this.m_motorImpulse *= step.dtRatio;\n var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_motorImpulse + this.m_impulse.z);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + this.m_motorImpulse + this.m_impulse.z);\n } else {\n this.m_impulse.setZero();\n this.m_motorImpulse = 0;\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nRevoluteJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var fixedRotation = iA + iB == 0;\n if (this.m_enableMotor && this.m_limitState != equalLimits && fixedRotation == false) {\n var Cdot = wB - wA - this.m_motorSpeed;\n var impulse = -this.m_motorMass * Cdot;\n var oldImpulse = this.m_motorImpulse;\n var maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n if (this.m_enableLimit && this.m_limitState != inactiveLimit && fixedRotation == false) {\n var Cdot1 = Vec2.zero();\n Cdot1.wAdd(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.wSub(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var Cdot2 = wB - wA;\n var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2);\n var impulse = Vec3.neg(this.m_mass.solve33(Cdot));\n if (this.m_limitState == equalLimits) {\n this.m_impulse.add(impulse);\n } else if (this.m_limitState == atLowerLimit) {\n var newImpulse = this.m_impulse.z + impulse.z;\n if (newImpulse < 0) {\n var rhs = Vec2.wAdd(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n var reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0;\n } else {\n this.m_impulse.add(impulse);\n }\n } else if (this.m_limitState == atUpperLimit) {\n var newImpulse = this.m_impulse.z + impulse.z;\n if (newImpulse > 0) {\n var rhs = Vec2.wAdd(-1, Cdot1, this.m_impulse.z, Vec2.neo(this.m_mass.ez.x, this.m_mass.ez.y));\n var reduced = this.m_mass.solve22(rhs);\n impulse.x = reduced.x;\n impulse.y = reduced.y;\n impulse.z = -this.m_impulse.z;\n this.m_impulse.x += reduced.x;\n this.m_impulse.y += reduced.y;\n this.m_impulse.z = 0;\n } else {\n this.m_impulse.add(impulse);\n }\n }\n var P = Vec2.neo(impulse.x, impulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + impulse.z);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + impulse.z);\n } else {\n var Cdot = Vec2.zero();\n Cdot.wAdd(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot.wSub(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var impulse = this.m_mass.solve22(Vec2.neg(Cdot));\n this.m_impulse.x += impulse.x;\n this.m_impulse.y += impulse.y;\n vA.wSub(mA, impulse);\n wA -= iA * Vec2.cross(this.m_rA, impulse);\n vB.wAdd(mB, impulse);\n wB += iB * Vec2.cross(this.m_rB, impulse);\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nRevoluteJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var angularError = 0;\n var positionError = 0;\n var fixedRotation = this.m_invIA + this.m_invIB == 0;\n if (this.m_enableLimit && this.m_limitState != inactiveLimit && fixedRotation == false) {\n var angle = aB - aA - this.m_referenceAngle;\n var limitImpulse = 0;\n if (this.m_limitState == equalLimits) {\n var C = Math.clamp(angle - this.m_lowerAngle, -Settings.maxAngularCorrection, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n angularError = Math.abs(C);\n } else if (this.m_limitState == atLowerLimit) {\n var C = angle - this.m_lowerAngle;\n angularError = -C;\n C = Math.clamp(C + Settings.angularSlop, -Settings.maxAngularCorrection, 0);\n limitImpulse = -this.m_motorMass * C;\n } else if (this.m_limitState == atUpperLimit) {\n var C = angle - this.m_upperAngle;\n angularError = C;\n C = Math.clamp(C - Settings.angularSlop, 0, Settings.maxAngularCorrection);\n limitImpulse = -this.m_motorMass * C;\n }\n aA -= this.m_invIA * limitImpulse;\n aB += this.m_invIB * limitImpulse;\n }\n {\n qA.set(aA);\n qB.set(aB);\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var C = Vec2.zero();\n C.wAdd(1, cB, 1, rB);\n C.wSub(1, cA, 1, rA);\n positionError = C.length();\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var K = new Mat22();\n K.ex.x = mA + mB + iA * rA.y * rA.y + iB * rB.y * rB.y;\n K.ex.y = -iA * rA.x * rA.y - iB * rB.x * rB.y;\n K.ey.x = K.ex.y;\n K.ey.y = mA + mB + iA * rA.x * rA.x + iB * rB.x * rB.x;\n var impulse = Vec2.neg(K.solve(C));\n cA.wSub(mA, impulse);\n aA -= iA * Vec2.cross(rA, impulse);\n cB.wAdd(mB, impulse);\n aB += iB * Vec2.cross(rB, impulse);\n }\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],36:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = RopeJoint;\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nvar inactiveLimit = 0;\n\nvar atLowerLimit = 1;\n\nvar atUpperLimit = 2;\n\nvar equalLimits = 3;\n\nRopeJoint.TYPE = \"rope-joint\";\n\nRopeJoint._super = Joint;\n\nRopeJoint.prototype = create(RopeJoint._super.prototype);\n\nvar RopeJointDef = {\n maxLength: 0\n};\n\nfunction RopeJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof RopeJoint)) {\n return new RopeJoint(def, bodyA, bodyB, anchor);\n }\n def = options(def, RopeJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = RopeJoint.TYPE;\n this.m_localAnchorA = def.localAnchorA || bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = def.localAnchorB || bodyB.getLocalPoint(anchor);\n this.m_maxLength = def.maxLength;\n this.m_mass = 0;\n this.m_impulse = 0;\n this.m_length = 0;\n this.m_state = inactiveLimit;\n this.m_u;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass;\n}\n\nRopeJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nRopeJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nRopeJoint.prototype.setMaxLength = function(length) {\n this.m_maxLength = length;\n};\n\nRopeJoint.prototype.getMaxLength = function() {\n return this.m_maxLength;\n};\n\nRopeJoint.prototype.getLimitState = function() {\n return this.m_state;\n};\n\nRopeJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nRopeJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nRopeJoint.prototype.getReactionForce = function(inv_dt) {\n var F = inv_dt * this.m_impulse * this.m_u;\n return F;\n};\n\nRopeJoint.prototype.getReactionTorque = function(inv_dt) {\n return 0;\n};\n\nRopeJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n this.m_rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n this.m_rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n this.m_u = Vec2.zero();\n this.m_u.wAdd(1, cB, 1, this.m_rB);\n this.m_u.wSub(1, cA, 1, this.m_rA);\n this.m_length = this.m_u.length();\n var C = this.m_length - this.m_maxLength;\n if (C > 0) {\n this.m_state = atUpperLimit;\n } else {\n this.m_state = inactiveLimit;\n }\n if (this.m_length > Settings.linearSlop) {\n this.m_u.mul(1 / this.m_length);\n } else {\n this.m_u.setZero();\n this.m_mass = 0;\n this.m_impulse = 0;\n return;\n }\n var crA = Vec2.cross(this.m_rA, this.m_u);\n var crB = Vec2.cross(this.m_rB, this.m_u);\n var invMass = this.m_invMassA + this.m_invIA * crA * crA + this.m_invMassB + this.m_invIB * crB * crB;\n this.m_mass = invMass != 0 ? 1 / invMass : 0;\n if (step.warmStarting) {\n this.m_impulse *= step.dtRatio;\n var P = Vec2.mul(this.m_impulse, this.m_u);\n vA.wSub(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.wAdd(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n } else {\n this.m_impulse = 0;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nRopeJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var vpA = Vec2.addCross(vA, wA, this.m_rA);\n var vpB = Vec2.addCross(vB, wB, this.m_rB);\n var C = this.m_length - this.m_maxLength;\n var Cdot = Vec2.dot(this.m_u, Vec2.sub(vpB, vpA));\n if (C < 0) {\n Cdot += step.inv_dt * C;\n }\n var impulse = -this.m_mass * Cdot;\n var oldImpulse = this.m_impulse;\n this.m_impulse = Math.min(0, this.m_impulse + impulse);\n impulse = this.m_impulse - oldImpulse;\n var P = Vec2.mul(impulse, this.m_u);\n vA.wSub(this.m_invMassA, P);\n wA -= this.m_invIA * Vec2.cross(this.m_rA, P);\n vB.wAdd(this.m_invMassB, P);\n wB += this.m_invIB * Vec2.cross(this.m_rB, P);\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nRopeJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var rA = Rot.mulSub(qA, this.m_localAnchorA, this.m_localCenterA);\n var rB = Rot.mulSub(qB, this.m_localAnchorB, this.m_localCenterB);\n var u = Vec2.zero();\n u.wAdd(1, cB, 1, rB);\n u.wSub(1, cA, 1, rA);\n var length = u.normalize();\n var C = length - this.m_maxLength;\n C = Math.clamp(C, 0, Settings.maxLinearCorrection);\n var impulse = -this.m_mass * C;\n var P = Vec2.mul(impulse, u);\n cA.wSub(this.m_invMassA, P);\n aA -= this.m_invIA * Vec2.cross(rA, P);\n cB.wAdd(this.m_invMassB, P);\n aB += this.m_invIB * Vec2.cross(rB, P);\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n return length - this.m_maxLength < Settings.linearSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/create\":52,\"../util/options\":53}],37:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = WeldJoint;\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nWeldJoint.TYPE = \"weld-joint\";\n\nWeldJoint._super = Joint;\n\nWeldJoint.prototype = create(WeldJoint._super.prototype);\n\nvar WeldJointDef = {\n frequencyHz: 0,\n dampingRatio: 0\n};\n\nfunction WeldJoint(def, bodyA, bodyB, anchor) {\n if (!(this instanceof WeldJoint)) {\n return new WeldJoint(def, bodyA, bodyB, anchor);\n }\n def = options(def, WeldJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = WeldJoint.TYPE;\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n this.m_referenceAngle = bodyB.getAngle() - bodyA.getAngle();\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_impulse = Vec3();\n this.m_bias = 0;\n this.m_gamma = 0;\n this.m_rA;\n this.m_rB;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_mass = new Mat33();\n}\n\nWeldJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nWeldJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nWeldJoint.prototype.getReferenceAngle = function() {\n return this.m_referenceAngle;\n};\n\nWeldJoint.prototype.setFrequency = function(hz) {\n this.m_frequencyHz = hz;\n};\n\nWeldJoint.prototype.getFrequency = function() {\n return this.m_frequencyHz;\n};\n\nWeldJoint.prototype.setDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n};\n\nWeldJoint.prototype.getDampingRatio = function() {\n return this.m_dampingRatio;\n};\n\nWeldJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nWeldJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nWeldJoint.prototype.getReactionForce = function(inv_dt) {\n var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n return inv_dt * P;\n};\n\nWeldJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_impulse.z;\n};\n\nWeldJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n this.m_rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n this.m_rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var K = new Mat33();\n K.ex.x = mA + mB + this.m_rA.y * this.m_rA.y * iA + this.m_rB.y * this.m_rB.y * iB;\n K.ey.x = -this.m_rA.y * this.m_rA.x * iA - this.m_rB.y * this.m_rB.x * iB;\n K.ez.x = -this.m_rA.y * iA - this.m_rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + this.m_rA.x * this.m_rA.x * iA + this.m_rB.x * this.m_rB.x * iB;\n K.ez.y = this.m_rA.x * iA + this.m_rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n if (this.m_frequencyHz > 0) {\n K.getInverse22(this.m_mass);\n var invM = iA + iB;\n var m = invM > 0 ? 1 / invM : 0;\n var C = aB - aA - this.m_referenceAngle;\n var omega = 2 * Math.PI * this.m_frequencyHz;\n var d = 2 * m * this.m_dampingRatio * omega;\n var k = m * omega * omega;\n var h = step.dt;\n this.m_gamma = h * (d + h * k);\n this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0;\n this.m_bias = C * h * k * this.m_gamma;\n invM += this.m_gamma;\n this.m_mass.ez.z = invM != 0 ? 1 / invM : 0;\n } else if (K.ez.z == 0) {\n K.getInverse22(this.m_mass);\n this.m_gamma = 0;\n this.m_bias = 0;\n } else {\n K.getSymInverse33(this.m_mass);\n this.m_gamma = 0;\n this.m_bias = 0;\n }\n if (step.warmStarting) {\n this.m_impulse.mul(step.dtRatio);\n var P = Vec2.neo(this.m_impulse.x, this.m_impulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + this.m_impulse.z);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + this.m_impulse.z);\n } else {\n this.m_impulse.setZero();\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nWeldJoint.prototype.solveVelocityConstraints = function(step) {\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n if (this.m_frequencyHz > 0) {\n var Cdot2 = wB - wA;\n var impulse2 = -this.m_mass.ez.z * (Cdot2 + this.m_bias + this.m_gamma * this.m_impulse.z);\n this.m_impulse.z += impulse2;\n wA -= iA * impulse2;\n wB += iB * impulse2;\n var Cdot1 = Vec2.zero();\n Cdot1.wAdd(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.wSub(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var impulse1 = Vec2.neg(Mat33.mul(this.m_mass, Cdot1));\n this.m_impulse.x += impulse1.x;\n this.m_impulse.y += impulse1.y;\n var P = Vec2.clone(impulse1);\n vA.wSub(mA, P);\n wA -= iA * Vec2.cross(this.m_rA, P);\n vB.wAdd(mB, P);\n wB += iB * Vec2.cross(this.m_rB, P);\n } else {\n var Cdot1 = Vec2.zero();\n Cdot1.wAdd(1, vB, 1, Vec2.cross(wB, this.m_rB));\n Cdot1.wSub(1, vA, 1, Vec2.cross(wA, this.m_rA));\n var Cdot2 = wB - wA;\n var Cdot = Vec3(Cdot1.x, Cdot1.y, Cdot2);\n var impulse = Vec3.neg(Mat33.mul(this.m_mass, Cdot));\n this.m_impulse.add(impulse);\n var P = Vec2.neo(impulse.x, impulse.y);\n vA.wSub(mA, P);\n wA -= iA * (Vec2.cross(this.m_rA, P) + impulse.z);\n vB.wAdd(mB, P);\n wB += iB * (Vec2.cross(this.m_rB, P) + impulse.z);\n }\n this.m_bodyA.c_velocity.v = vA;\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v = vB;\n this.m_bodyB.c_velocity.w = wB;\n};\n\nWeldJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA), qB = Rot.neo(aB);\n var mA = this.m_invMassA, mB = this.m_invMassB;\n var iA = this.m_invIA, iB = this.m_invIB;\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var positionError, angularError;\n var K = new Mat33();\n K.ex.x = mA + mB + rA.y * rA.y * iA + rB.y * rB.y * iB;\n K.ey.x = -rA.y * rA.x * iA - rB.y * rB.x * iB;\n K.ez.x = -rA.y * iA - rB.y * iB;\n K.ex.y = K.ey.x;\n K.ey.y = mA + mB + rA.x * rA.x * iA + rB.x * rB.x * iB;\n K.ez.y = rA.x * iA + rB.x * iB;\n K.ex.z = K.ez.x;\n K.ey.z = K.ez.y;\n K.ez.z = iA + iB;\n if (this.m_frequencyHz > 0) {\n var C1 = Vec2.zero();\n C1.wAdd(1, cB, 1, rB);\n C1.wSub(1, cA, 1, rA);\n positionError = C1.length();\n angularError = 0;\n var P = Vec2.neg(K.solve22(C1));\n cA.wSub(mA, P);\n aA -= iA * Vec2.cross(rA, P);\n cB.wAdd(mB, P);\n aB += iB * Vec2.cross(rB, P);\n } else {\n var C1 = Vec2.zero();\n C1.wAdd(1, cB, 1, rB);\n C1.wSub(1, cA, 1, rA);\n var C2 = aB - aA - this.m_referenceAngle;\n positionError = C1.length();\n angularError = Math.abs(C2);\n var C = Vec3(C1.x, C1.y, C2);\n var impulse = Vec3();\n if (K.ez.z > 0) {\n impulse = Vec3.neg(K.solve33(C));\n } else {\n var impulse2 = Vec2.neg(K.solve22(C1));\n impulse.set(impulse2.x, impulse2.y, 0);\n }\n var P = Vec2.neo(impulse.x, impulse.y);\n cA.wSub(mA, P);\n aA -= iA * (Vec2.cross(rA, P) + impulse.z);\n cB.wAdd(mB, P);\n aB += iB * (Vec2.cross(rB, P) + impulse.z);\n }\n this.m_bodyA.c_position.c = cA;\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c = cB;\n this.m_bodyB.c_position.a = aB;\n return positionError <= Settings.linearSlop && angularError <= Settings.angularSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/create\":52,\"../util/options\":53}],38:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = WheelJoint;\n\nvar options = require(\"../util/options\");\n\nvar create = require(\"../util/create\");\n\nvar Settings = require(\"../Settings\");\n\nvar Math = require(\"../common/Math\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Vec3 = require(\"../common/Vec3\");\n\nvar Mat22 = require(\"../common/Mat22\");\n\nvar Mat33 = require(\"../common/Mat33\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Sweep = require(\"../common/Sweep\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Velocity = require(\"../common/Velocity\");\n\nvar Position = require(\"../common/Position\");\n\nvar Joint = require(\"../Joint\");\n\nWheelJoint.TYPE = \"wheel-joint\";\n\nWheelJoint._super = Joint;\n\nWheelJoint.prototype = create(WheelJoint._super.prototype);\n\nvar WheelJointDef = {\n enableMotor: false,\n maxMotorTorque: 0,\n motorSpeed: 0,\n frequencyHz: 2,\n dampingRatio: .7\n};\n\nfunction WheelJoint(def, bodyA, bodyB, anchor, axis) {\n if (!(this instanceof WheelJoint)) {\n return new WheelJoint(def, bodyA, bodyB, anchor, axis);\n }\n def = options(def, WheelJointDef);\n Joint.call(this, def, bodyA, bodyB);\n this.m_type = WheelJoint.TYPE;\n this.m_localAnchorA = bodyA.getLocalPoint(anchor);\n this.m_localAnchorB = bodyB.getLocalPoint(anchor);\n this.m_localXAxisA = bodyA.getLocalVector(axis || Vec2.neo(1, 0));\n this.m_localYAxisA = Vec2.cross(1, this.m_localXAxisA);\n this.m_mass = 0;\n this.m_impulse = 0;\n this.m_motorMass = 0;\n this.m_motorImpulse = 0;\n this.m_springMass = 0;\n this.m_springImpulse = 0;\n this.m_maxMotorTorque = def.maxMotorTorque;\n this.m_motorSpeed = def.motorSpeed;\n this.m_enableMotor = def.enableMotor;\n this.m_frequencyHz = def.frequencyHz;\n this.m_dampingRatio = def.dampingRatio;\n this.m_bias = 0;\n this.m_gamma = 0;\n this.m_localCenterA;\n this.m_localCenterB;\n this.m_invMassA;\n this.m_invMassB;\n this.m_invIA;\n this.m_invIB;\n this.m_ax = Vec2.zero();\n this.m_ay = Vec2.zero();\n this.m_sAx;\n this.m_sBx;\n this.m_sAy;\n this.m_sBy;\n}\n\nWheelJoint.prototype.getLocalAnchorA = function() {\n return this.m_localAnchorA;\n};\n\nWheelJoint.prototype.getLocalAnchorB = function() {\n return this.m_localAnchorB;\n};\n\nWheelJoint.prototype.getLocalAxisA = function() {\n return this.m_localXAxisA;\n};\n\nWheelJoint.prototype.getJointTranslation = function() {\n var bA = this.m_bodyA;\n var bB = this.m_bodyB;\n var pA = bA.getWorldPoint(this.m_localAnchorA);\n var pB = bB.getWorldPoint(this.m_localAnchorB);\n var d = pB - pA;\n var axis = bA.getWorldVector(this.m_localXAxisA);\n var translation = Dot(d, axis);\n return translation;\n};\n\nWheelJoint.prototype.getJointSpeed = function() {\n var wA = this.m_bodyA.m_angularVelocity;\n var wB = this.m_bodyB.m_angularVelocity;\n return wB - wA;\n};\n\nWheelJoint.prototype.isMotorEnabled = function() {\n return this.m_enableMotor;\n};\n\nWheelJoint.prototype.enableMotor = function(flag) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_enableMotor = flag;\n};\n\nWheelJoint.prototype.setMotorSpeed = function(speed) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_motorSpeed = speed;\n};\n\nWheelJoint.prototype.getMotorSpeed = function() {\n return this.m_motorSpeed;\n};\n\nWheelJoint.prototype.setMaxMotorTorque = function(torque) {\n this.m_bodyA.setAwake(true);\n this.m_bodyB.setAwake(true);\n this.m_maxMotorTorque = torque;\n};\n\nWheelJoint.prototype.getMaxMotorTorque = function() {\n return this.m_maxMotorTorque;\n};\n\nWheelJoint.prototype.getMotorTorque = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n};\n\nWheelJoint.prototype.setSpringFrequencyHz = function(hz) {\n this.m_frequencyHz = hz;\n};\n\nWheelJoint.prototype.getSpringFrequencyHz = function() {\n return this.m_frequencyHz;\n};\n\nWheelJoint.prototype.setSpringDampingRatio = function(ratio) {\n this.m_dampingRatio = ratio;\n};\n\nWheelJoint.prototype.getSpringDampingRatio = function() {\n return this.m_dampingRatio;\n};\n\nWheelJoint.prototype.getAnchorA = function() {\n return this.m_bodyA.getWorldPoint(this.m_localAnchorA);\n};\n\nWheelJoint.prototype.getAnchorB = function() {\n return this.m_bodyB.getWorldPoint(this.m_localAnchorB);\n};\n\nWheelJoint.prototype.getReactionForce = function(inv_dt) {\n return inv_dt * (this.m_impulse * this.m_ay + this.m_springImpulse * this.m_ax);\n};\n\nWheelJoint.prototype.getReactionTorque = function(inv_dt) {\n return inv_dt * this.m_motorImpulse;\n};\n\nWheelJoint.prototype.initVelocityConstraints = function(step) {\n this.m_localCenterA = this.m_bodyA.m_sweep.localCenter;\n this.m_localCenterB = this.m_bodyB.m_sweep.localCenter;\n this.m_invMassA = this.m_bodyA.m_invMass;\n this.m_invMassB = this.m_bodyB.m_invMass;\n this.m_invIA = this.m_bodyA.m_invI;\n this.m_invIB = this.m_bodyB.m_invI;\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.wAdd(1, cB, 1, rB);\n d.wSub(1, cA, 1, rA);\n {\n this.m_ay = Rot.mul(qA, this.m_localYAxisA);\n this.m_sAy = Vec2.cross(Vec2.add(d, rA), this.m_ay);\n this.m_sBy = Vec2.cross(rB, this.m_ay);\n this.m_mass = mA + mB + iA * this.m_sAy * this.m_sAy + iB * this.m_sBy * this.m_sBy;\n if (this.m_mass > 0) {\n this.m_mass = 1 / this.m_mass;\n }\n }\n this.m_springMass = 0;\n this.m_bias = 0;\n this.m_gamma = 0;\n if (this.m_frequencyHz > 0) {\n this.m_ax = Rot.mul(qA, this.m_localXAxisA);\n this.m_sAx = Vec2.cross(Vec2.add(d, rA), this.m_ax);\n this.m_sBx = Vec2.cross(rB, this.m_ax);\n var invMass = mA + mB + iA * this.m_sAx * this.m_sAx + iB * this.m_sBx * this.m_sBx;\n if (invMass > 0) {\n this.m_springMass = 1 / invMass;\n var C = Vec2.dot(d, this.m_ax);\n var omega = 2 * Math.PI * this.m_frequencyHz;\n var d = 2 * this.m_springMass * this.m_dampingRatio * omega;\n var k = this.m_springMass * omega * omega;\n var h = step.dt;\n this.m_gamma = h * (d + h * k);\n if (this.m_gamma > 0) {\n this.m_gamma = 1 / this.m_gamma;\n }\n this.m_bias = C * h * k * this.m_gamma;\n this.m_springMass = invMass + this.m_gamma;\n if (this.m_springMass > 0) {\n this.m_springMass = 1 / this.m_springMass;\n }\n }\n } else {\n this.m_springImpulse = 0;\n }\n if (this.m_enableMotor) {\n this.m_motorMass = iA + iB;\n if (this.m_motorMass > 0) {\n this.m_motorMass = 1 / this.m_motorMass;\n }\n } else {\n this.m_motorMass = 0;\n this.m_motorImpulse = 0;\n }\n if (step.warmStarting) {\n this.m_impulse *= step.dtRatio;\n this.m_springImpulse *= step.dtRatio;\n this.m_motorImpulse *= step.dtRatio;\n var P = Vec2.wAdd(this.m_impulse, this.m_ay, this.m_springImpulse, this.m_ax);\n var LA = this.m_impulse * this.m_sAy + this.m_springImpulse * this.m_sAx + this.m_motorImpulse;\n var LB = this.m_impulse * this.m_sBy + this.m_springImpulse * this.m_sBx + this.m_motorImpulse;\n vA.wSub(this.m_invMassA, P);\n wA -= this.m_invIA * LA;\n vB.wAdd(this.m_invMassB, P);\n wB += this.m_invIB * LB;\n } else {\n this.m_impulse = 0;\n this.m_springImpulse = 0;\n this.m_motorImpulse = 0;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nWheelJoint.prototype.solveVelocityConstraints = function(step) {\n var mA = this.m_invMassA;\n var mB = this.m_invMassB;\n var iA = this.m_invIA;\n var iB = this.m_invIB;\n var vA = this.m_bodyA.c_velocity.v;\n var wA = this.m_bodyA.c_velocity.w;\n var vB = this.m_bodyB.c_velocity.v;\n var wB = this.m_bodyB.c_velocity.w;\n {\n var Cdot = Vec2.dot(this.m_ax, vB) - Vec2.dot(this.m_ax, vA) + this.m_sBx * wB - this.m_sAx * wA;\n var impulse = -this.m_springMass * (Cdot + this.m_bias + this.m_gamma * this.m_springImpulse);\n this.m_springImpulse += impulse;\n var P = Vec2.zero().wSet(impulse, this.m_ax);\n var LA = impulse * this.m_sAx;\n var LB = impulse * this.m_sBx;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n }\n {\n var Cdot = wB - wA - this.m_motorSpeed;\n var impulse = -this.m_motorMass * Cdot;\n var oldImpulse = this.m_motorImpulse;\n var maxImpulse = step.dt * this.m_maxMotorTorque;\n this.m_motorImpulse = Math.clamp(this.m_motorImpulse + impulse, -maxImpulse, maxImpulse);\n impulse = this.m_motorImpulse - oldImpulse;\n wA -= iA * impulse;\n wB += iB * impulse;\n }\n {\n var Cdot = Vec2.dot(this.m_ay, vB) - Vec2.dot(this.m_ay, vA) + this.m_sBy * wB - this.m_sAy * wA;\n var impulse = -this.m_mass * Cdot;\n this.m_impulse += impulse;\n var P = Vec2.zero().wSet(impulse, this.m_ay);\n var LA = impulse * this.m_sAy;\n var LB = impulse * this.m_sBy;\n vA.wSub(mA, P);\n wA -= iA * LA;\n vB.wAdd(mB, P);\n wB += iB * LB;\n }\n this.m_bodyA.c_velocity.v.set(vA);\n this.m_bodyA.c_velocity.w = wA;\n this.m_bodyB.c_velocity.v.set(vB);\n this.m_bodyB.c_velocity.w = wB;\n};\n\nWheelJoint.prototype.solvePositionConstraints = function(step) {\n var cA = this.m_bodyA.c_position.c;\n var aA = this.m_bodyA.c_position.a;\n var cB = this.m_bodyB.c_position.c;\n var aB = this.m_bodyB.c_position.a;\n var qA = Rot.neo(aA);\n var qB = Rot.neo(aB);\n var rA = Rot.mul(qA, Vec2.sub(this.m_localAnchorA, this.m_localCenterA));\n var rB = Rot.mul(qB, Vec2.sub(this.m_localAnchorB, this.m_localCenterB));\n var d = Vec2.zero();\n d.wAdd(1, cB, 1, rB);\n d.wSub(1, cA, 1, rA);\n var ay = Rot.mul(qA, this.m_localYAxisA);\n var sAy = Vec2.cross(Vec2.sub(d, rA), ay);\n var sBy = Vec2.cross(rB, ay);\n var C = Vec2.dot(d, ay);\n var k = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_sAy * this.m_sAy + this.m_invIB * this.m_sBy * this.m_sBy;\n var impulse;\n if (k != 0) {\n impulse = -C / k;\n } else {\n impulse = 0;\n }\n var P = Vec2.zero().wSet(impulse, ay);\n var LA = impulse * sAy;\n var LB = impulse * sBy;\n cA.wSub(this.m_invMassA, P);\n aA -= this.m_invIA * LA;\n cB.wAdd(this.m_invMassB, P);\n aB += this.m_invIB * LB;\n this.m_bodyA.c_position.c.set(cA);\n this.m_bodyA.c_position.a = aA;\n this.m_bodyB.c_position.c.set(cB);\n this.m_bodyB.c_position.a = aB;\n return Math.abs(C) <= Settings.linearSlop;\n};\n\n\n},{\"../Joint\":5,\"../Settings\":7,\"../common/Mat22\":16,\"../common/Mat33\":17,\"../common/Math\":18,\"../common/Position\":19,\"../common/Rot\":20,\"../common/Sweep\":21,\"../common/Transform\":22,\"../common/Vec2\":23,\"../common/Vec3\":24,\"../common/Velocity\":25,\"../util/create\":52,\"../util/options\":53}],39:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = BoxShape;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar options = require(\"../util/options\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar PolygonShape = require(\"./PolygonShape\");\n\nBoxShape._super = PolygonShape;\n\nBoxShape.prototype = create(BoxShape._super.prototype);\n\nBoxShape.TYPE = \"polygon\";\n\nfunction BoxShape(hx, hy, center, angle) {\n if (!(this instanceof BoxShape)) {\n return new BoxShape(hx, hy, center, angle);\n }\n BoxShape._super.call(this);\n this.m_vertices[0] = Vec2.neo(-hx, -hy);\n this.m_vertices[1] = Vec2.neo(hx, -hy);\n this.m_vertices[2] = Vec2.neo(hx, hy);\n this.m_vertices[3] = Vec2.neo(-hx, hy);\n this.m_normals[0] = Vec2.neo(0, -1);\n this.m_normals[1] = Vec2.neo(1, 0);\n this.m_normals[2] = Vec2.neo(0, 1);\n this.m_normals[3] = Vec2.neo(-1, 0);\n this.m_count = 4;\n if (center && \"x\" in center && \"y\" in center) {\n angle = angle || 0;\n this.m_centroid.set(center);\n var xf = Transform.identity();\n xf.p.set(center);\n xf.q.set(angle);\n for (var i = 0; i < this.m_count; ++i) {\n this.m_vertices[i] = Transform.mul(xf, this.m_vertices[i]);\n this.m_normals[i] = Rot.mul(xf.q, this.m_normals[i]);\n }\n }\n}\n\n\n},{\"../Settings\":7,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53,\"./PolygonShape\":48}],40:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = ChainShape;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar options = require(\"../util/options\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nvar EdgeShape = require(\"./EdgeShape\");\n\nChainShape._super = Shape;\n\nChainShape.prototype = create(ChainShape._super.prototype);\n\nChainShape.TYPE = \"chain\";\n\nfunction ChainShape(vertices, loop) {\n if (!(this instanceof ChainShape)) {\n return new ChainShape(vertices, loop);\n }\n ChainShape._super.call(this);\n this.m_type = ChainShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertices = [];\n this.m_count = 0;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n if (vertices && vertices.length) {\n if (loop) {\n this._createLoop(vertices);\n } else {\n this._createChain(vertices);\n }\n }\n}\n\nChainShape.prototype._createLoop = function(vertices) {\n ASSERT && common.assert(this.m_vertices.length == 0 && this.m_count == 0);\n ASSERT && common.assert(vertices.length >= 3);\n for (var i = 1; i < vertices.length; ++i) {\n var v1 = vertices[i - 1];\n var v2 = vertices[i];\n ASSERT && common.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n this.m_vertices.length = 0;\n this.m_count = vertices.length + 1;\n for (var i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = vertices[i].clone();\n }\n this.m_vertices[vertices.length] = vertices[0].clone();\n this.m_prevVertex = this.m_vertices[this.m_count - 2];\n this.m_nextVertex = this.m_vertices[1];\n this.m_hasPrevVertex = true;\n this.m_hasNextVertex = true;\n return this;\n};\n\nChainShape.prototype._createChain = function(vertices) {\n ASSERT && common.assert(this.m_vertices.length == 0 && this.m_count == 0);\n ASSERT && common.assert(vertices.length >= 2);\n for (var i = 1; i < vertices.length; ++i) {\n var v1 = vertices[i - 1];\n var v2 = vertices[i];\n ASSERT && common.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);\n }\n this.m_count = vertices.length;\n for (var i = 0; i < vertices.length; ++i) {\n this.m_vertices[i] = vertices[i].clone();\n }\n this.m_hasPrevVertex = false;\n this.m_hasNextVertex = false;\n this.m_prevVertex = null;\n this.m_nextVertex = null;\n return this;\n};\n\nChainShape.prototype._setPrevVertex = function(prevVertex) {\n this.m_prevVertex = prevVertex;\n this.m_hasPrevVertex = true;\n};\n\nChainShape.prototype._setNextVertex = function(nextVertex) {\n this.m_nextVertex = nextVertex;\n this.m_hasNextVertex = true;\n};\n\nChainShape.prototype._clone = function() {\n var clone = new ChainShape();\n clone.createChain(this.m_vertices);\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_prevVertex = this.m_prevVertex;\n clone.m_nextVertex = this.m_nextVertex;\n clone.m_hasPrevVertex = this.m_hasPrevVertex;\n clone.m_hasNextVertex = this.m_hasNextVertex;\n return clone;\n};\n\nChainShape.prototype.getChildCount = function() {\n return this.m_count - 1;\n};\n\nChainShape.prototype.getChildEdge = function(edge, childIndex) {\n ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count - 1);\n edge.m_type = EdgeShape.TYPE;\n edge.m_radius = this.m_radius;\n edge.m_vertex1 = this.m_vertices[childIndex];\n edge.m_vertex2 = this.m_vertices[childIndex + 1];\n if (childIndex > 0) {\n edge.m_vertex0 = this.m_vertices[childIndex - 1];\n edge.m_hasVertex0 = true;\n } else {\n edge.m_vertex0 = this.m_prevVertex;\n edge.m_hasVertex0 = this.m_hasPrevVertex;\n }\n if (childIndex < this.m_count - 2) {\n edge.m_vertex3 = this.m_vertices[childIndex + 2];\n edge.m_hasVertex3 = true;\n } else {\n edge.m_vertex3 = this.m_nextVertex;\n edge.m_hasVertex3 = this.m_hasNextVertex;\n }\n};\n\nChainShape.prototype.getVertex = function(index) {\n ASSERT && common.assert(0 <= index && index <= this.m_count);\n if (index < this.m_count) {\n return this.m_vertices[index];\n } else {\n return this.m_vertices[0];\n }\n};\n\nChainShape.prototype.testPoint = function(xf, p) {\n return false;\n};\n\nChainShape.prototype.rayCast = function(output, input, xf, childIndex) {\n ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n var edgeShape = new EdgeShape(this.getVertex(childIndex), this.getVertex(childIndex + 1));\n return edgeShape.rayCast(output, input, xf, 0);\n};\n\nChainShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n var v1 = Transform.mul(xf, this.getVertex(childIndex));\n var v2 = Transform.mul(xf, this.getVertex(childIndex + 1));\n aabb.combinePoints(v1, v2);\n};\n\nChainShape.prototype.computeMass = function(massData, density) {\n massData.mass = 0;\n massData.center = Vec2.neo();\n massData.I = 0;\n};\n\nChainShape.prototype.computeDistanceProxy = function(proxy, childIndex) {\n ASSERT && common.assert(0 <= childIndex && childIndex < this.m_count);\n proxy.m_buffer[0] = this.getVertex(childIndex);\n proxy.m_buffer[1] = this.getVertex(childIndex + 1);\n proxy.m_vertices = proxy.m_buffer;\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n};\n\n\n},{\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53,\"./EdgeShape\":47}],41:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = CircleShape;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar options = require(\"../util/options\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nCircleShape._super = Shape;\n\nCircleShape.prototype = create(CircleShape._super.prototype);\n\nCircleShape.TYPE = \"circle\";\n\nfunction CircleShape(a, b) {\n if (!(this instanceof CircleShape)) {\n return new CircleShape(a, b);\n }\n CircleShape._super.call(this);\n this.m_type = CircleShape.TYPE;\n this.m_p = Vec2.zero();\n this.m_radius = 1;\n if (typeof a === \"object\" && Vec2.isValid(a)) {\n this.m_p.set(a);\n if (typeof b === \"number\") {\n this.m_radius = b;\n }\n } else if (typeof a === \"number\") {\n this.m_radius = a;\n }\n}\n\nCircleShape.prototype.getRadius = function() {\n return this.m_radius;\n};\n\nCircleShape.prototype.getCenter = function() {\n return this.m_p;\n};\n\nCircleShape.prototype.getSupportVertex = function(d) {\n return this.m_p;\n};\n\nCircleShape.prototype.getVertex = function(index) {\n ASSERT && common.assert(index == 0);\n return this.m_p;\n};\n\nCircleShape.prototype.getVertexCount = function(index) {\n return 1;\n};\n\nCircleShape.prototype._clone = function() {\n var clone = new CircleShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_p = this.m_p.clone();\n return clone;\n};\n\nCircleShape.prototype.getChildCount = function() {\n return 1;\n};\n\nCircleShape.prototype.testPoint = function(xf, p) {\n var center = Vec2.add(xf.p, Rot.mul(xf.q, this.m_p));\n var d = Vec2.sub(p, center);\n return Vec2.dot(d, d) <= this.m_radius * this.m_radius;\n};\n\nCircleShape.prototype.rayCast = function(output, input, xf, childIndex) {\n var position = Vec2.add(xf.p, Rot.mul(xf.q, this.m_p));\n var s = Vec2.sub(input.p1, position);\n var b = Vec2.dot(s, s) - this.m_radius * this.m_radius;\n var r = Vec2.sub(input.p2, input.p1);\n var c = Vec2.dot(s, r);\n var rr = Vec2.dot(r, r);\n var sigma = c * c - rr * b;\n if (sigma < 0 || rr < Math.EPSILON) {\n return false;\n }\n var a = -(c + Math.sqrt(sigma));\n if (0 <= a && a <= input.maxFraction * rr) {\n a /= rr;\n output.fraction = a;\n output.normal = Vec2.add(s, Vec2.mul(a, r));\n output.normal.normalize();\n return true;\n }\n return false;\n};\n\nCircleShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var p = Vec2.add(xf.p, Rot.mul(xf.q, this.m_p));\n aabb.lowerBound.set(p.x - this.m_radius, p.y - this.m_radius);\n aabb.upperBound.set(p.x + this.m_radius, p.y + this.m_radius);\n};\n\nCircleShape.prototype.computeMass = function(massData, density) {\n massData.mass = density * Math.PI * this.m_radius * this.m_radius;\n massData.center = this.m_p;\n massData.I = massData.mass * (.5 * this.m_radius * this.m_radius + Vec2.dot(this.m_p, this.m_p));\n};\n\nCircleShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices.push(this.m_p);\n proxy.m_count = 1;\n proxy.m_radius = this.m_radius;\n};\n\n\n},{\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],42:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nvar Contact = require(\"../Contact\");\n\nvar Manifold = require(\"../Manifold\");\n\nvar CircleShape = require(\"./CircleShape\");\n\nContact.addType(CircleShape.TYPE, CircleShape.TYPE, CircleCircleContact);\n\nfunction CircleCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n ASSERT && common.assert(fixtureA.getType() == CircleShape.TYPE);\n ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n CollideCircles(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(), xfB);\n}\n\nfunction CollideCircles(manifold, circleA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n var pA = Transform.mul(xfA, circleA.m_p);\n var pB = Transform.mul(xfB, circleB.m_p);\n var distSqr = Vec2.distanceSquared(pB, pA);\n var rA = circleA.m_radius;\n var rB = circleB.m_radius;\n var radius = rA + rB;\n if (distSqr > radius * radius) {\n return;\n }\n manifold.type = Manifold.e_circles;\n manifold.localPoint.set(circleA.m_p);\n manifold.localNormal.setZero();\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n}\n\nexports.CollideCircles = CollideCircles;\n\n\n},{\"../Contact\":3,\"../Manifold\":6,\"../Settings\":7,\"../Shape\":8,\"../common/Math\":18,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"./CircleShape\":41}],43:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar Manifold = require(\"../Manifold\");\n\nvar Contact = require(\"../Contact\");\n\nvar Shape = require(\"../Shape\");\n\nvar CircleShape = require(\"./CircleShape\");\n\nvar PolygonShape = require(\"./PolygonShape\");\n\nContact.addType(PolygonShape.TYPE, CircleShape.TYPE, PolygonCircleContact);\n\nfunction PolygonCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n ASSERT && common.assert(fixtureA.getType() == PolygonShape.TYPE);\n ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n CollidePolygonCircle(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(), xfB);\n}\n\nfunction CollidePolygonCircle(manifold, polygonA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n var c = Transform.mul(xfB, circleB.m_p);\n var cLocal = Transform.mulT(xfA, c);\n var normalIndex = 0;\n var separation = -Infinity;\n var radius = polygonA.m_radius + circleB.m_radius;\n var vertexCount = polygonA.m_count;\n var vertices = polygonA.m_vertices;\n var normals = polygonA.m_normals;\n for (var i = 0; i < vertexCount; ++i) {\n var s = Vec2.dot(normals[i], Vec2.sub(cLocal, vertices[i]));\n if (s > radius) {\n return;\n }\n if (s > separation) {\n separation = s;\n normalIndex = i;\n }\n }\n var vertIndex1 = normalIndex;\n var vertIndex2 = vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0;\n var v1 = vertices[vertIndex1];\n var v2 = vertices[vertIndex2];\n if (separation < Math.EPSILON) {\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.set(normals[normalIndex]);\n manifold.localPoint.wSet(.5, v1, .5, v2);\n manifold.points[0].localPoint = circleB.m_p;\n manifold.points[0].id.key = 0;\n return;\n }\n var u1 = Vec2.dot(Vec2.sub(cLocal, v1), Vec2.sub(v2, v1));\n var u2 = Vec2.dot(Vec2.sub(cLocal, v2), Vec2.sub(v1, v2));\n if (u1 <= 0) {\n if (Vec2.distanceSquared(cLocal, v1) > radius * radius) {\n return;\n }\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.wSet(1, cLocal, -1, v1);\n manifold.localNormal.normalize();\n manifold.localPoint = v1;\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n } else if (u2 <= 0) {\n if (Vec2.distanceSquared(cLocal, v2) > radius * radius) {\n return;\n }\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.wSet(1, cLocal, -1, v2);\n manifold.localNormal.normalize();\n manifold.localPoint.set(v2);\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n } else {\n var faceCenter = Vec2.mid(v1, v2);\n var separation = Vec2.dot(cLocal, normals[vertIndex1]) - Vec2.dot(faceCenter, normals[vertIndex1]);\n if (separation > radius) {\n return;\n }\n manifold.pointCount = 1;\n manifold.type = Manifold.e_faceA;\n manifold.localNormal.set(normals[vertIndex1]);\n manifold.localPoint.set(faceCenter);\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n }\n}\n\n\n},{\"../Contact\":3,\"../Manifold\":6,\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"./CircleShape\":41,\"./PolygonShape\":48}],44:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nvar Contact = require(\"../Contact\");\n\nvar Manifold = require(\"../Manifold\");\n\nvar EdgeShape = require(\"./EdgeShape\");\n\nvar ChainShape = require(\"./ChainShape\");\n\nvar CircleShape = require(\"./CircleShape\");\n\nContact.addType(EdgeShape.TYPE, CircleShape.TYPE, EdgeCircleContact);\n\nContact.addType(ChainShape.TYPE, CircleShape.TYPE, ChainCircleContact);\n\nfunction EdgeCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n ASSERT && common.assert(fixtureA.getType() == EdgeShape.TYPE);\n ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n var shapeA = fixtureA.getShape();\n var shapeB = fixtureB.getShape();\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction ChainCircleContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n ASSERT && common.assert(fixtureA.getType() == ChainShape.TYPE);\n ASSERT && common.assert(fixtureB.getType() == CircleShape.TYPE);\n var chain = fixtureA.getShape();\n var edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n var shapeA = edge;\n var shapeB = fixtureB.getShape();\n CollideEdgeCircle(manifold, shapeA, xfA, shapeB, xfB);\n}\n\nfunction CollideEdgeCircle(manifold, edgeA, xfA, circleB, xfB) {\n manifold.pointCount = 0;\n var Q = Transform.mulT(xfA, Transform.mul(xfB, circleB.m_p));\n var A = edgeA.m_vertex1;\n var B = edgeA.m_vertex2;\n var e = Vec2.sub(B, A);\n var u = Vec2.dot(e, Vec2.sub(B, Q));\n var v = Vec2.dot(e, Vec2.sub(Q, A));\n var radius = edgeA.m_radius + circleB.m_radius;\n if (v <= 0) {\n var P = Vec2.clone(A);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n if (edgeA.m_hasVertex0) {\n var A1 = edgeA.m_vertex0;\n var B1 = A;\n var e1 = Vec2.sub(B1, A1);\n var u1 = Vec2.dot(e1, Vec2.sub(B1, Q));\n if (u1 > 0) {\n return;\n }\n }\n manifold.type = Manifold.e_circles;\n manifold.localNormal.setZero();\n manifold.localPoint.set(P);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n return;\n }\n if (u <= 0) {\n var P = Vec2.clone(B);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n if (edgeA.m_hasVertex3) {\n var B2 = edgeA.m_vertex3;\n var A2 = B;\n var e2 = Vec2.sub(B2, A2);\n var v2 = Vec2.dot(e2, Vec2.sub(Q, A2));\n if (v2 > 0) {\n return;\n }\n }\n manifold.type = Manifold.e_circles;\n manifold.localNormal.setZero();\n manifold.localPoint.set(P);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 1;\n manifold.points[0].id.cf.typeA = Manifold.e_vertex;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n return;\n }\n var den = Vec2.dot(e, e);\n ASSERT && common.assert(den > 0);\n var P = Vec2.wAdd(u / den, A, v / den, B);\n var d = Vec2.sub(Q, P);\n var dd = Vec2.dot(d, d);\n if (dd > radius * radius) {\n return;\n }\n var n = Vec2.neo(-e.y, e.x);\n if (Vec2.dot(n, Vec2.sub(Q, A)) < 0) {\n n.set(-n.x, -n.y);\n }\n n.normalize();\n manifold.type = Manifold.e_faceA;\n manifold.localNormal = n;\n manifold.localPoint.set(A);\n manifold.pointCount = 1;\n manifold.points[0].localPoint.set(circleB.m_p);\n manifold.points[0].id.key = 0;\n manifold.points[0].id.cf.indexA = 0;\n manifold.points[0].id.cf.typeA = Manifold.e_face;\n manifold.points[0].id.cf.indexB = 0;\n manifold.points[0].id.cf.typeB = Manifold.e_vertex;\n}\n\n\n},{\"../Contact\":3,\"../Manifold\":6,\"../Settings\":7,\"../Shape\":8,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"./ChainShape\":40,\"./CircleShape\":41,\"./EdgeShape\":47}],45:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nvar Contact = require(\"../Contact\");\n\nvar Manifold = require(\"../Manifold\");\n\nvar EdgeShape = require(\"./EdgeShape\");\n\nvar ChainShape = require(\"./ChainShape\");\n\nvar PolygonShape = require(\"./PolygonShape\");\n\nContact.addType(EdgeShape.TYPE, PolygonShape.TYPE, EdgePolygonContact);\n\nContact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);\n\nfunction EdgePolygonContact(manifold, xfA, fA, indexA, xfB, fB, indexB) {\n ASSERT && common.assert(fA.getType() == EdgeShape.TYPE);\n ASSERT && common.assert(fB.getType() == PolygonShape.TYPE);\n CollideEdgePolygon(manifold, fA.getShape(), xfA, fB.getShape(), xfB);\n}\n\nfunction ChainPolygonContact(manifold, xfA, fA, indexA, xfB, fB, indexB) {\n ASSERT && common.assert(fA.getType() == ChainShape.TYPE);\n ASSERT && common.assert(fB.getType() == PolygonShape.TYPE);\n var chain = fA.getShape();\n var edge = new EdgeShape();\n chain.getChildEdge(edge, indexA);\n CollideEdgePolygon(manifold, edge, xfA, fB.getShape(), xfB);\n}\n\nvar e_unknown = -1;\n\nvar e_edgeA = 1;\n\nvar e_edgeB = 2;\n\nvar e_isolated = 0;\n\nvar e_concave = 1;\n\nvar e_convex = 2;\n\nfunction EPAxis() {\n this.type;\n this.index;\n this.separation;\n}\n\nfunction TempPolygon() {\n this.vertices = [];\n this.normals = [];\n this.count = 0;\n}\n\nfunction ReferenceFace() {\n this.i1, this.i2;\n this.v1, this.v2;\n this.normal = Vec2.zero();\n this.sideNormal1 = Vec2.zero();\n this.sideOffset1;\n this.sideNormal2 = Vec2.zero();\n this.sideOffset2;\n}\n\nvar edgeAxis = new EPAxis();\n\nvar polygonAxis = new EPAxis();\n\nvar polygonBA = new TempPolygon();\n\nvar rf = new ReferenceFace();\n\nfunction CollideEdgePolygon(manifold, edgeA, xfA, polygonB, xfB) {\n DEBUG && common.debug(\"CollideEdgePolygon\");\n var m_type1, m_type2;\n var xf = Transform.mulT(xfA, xfB);\n var centroidB = Transform.mul(xf, polygonB.m_centroid);\n var v0 = edgeA.m_vertex0;\n var v1 = edgeA.m_vertex1;\n var v2 = edgeA.m_vertex2;\n var v3 = edgeA.m_vertex3;\n var hasVertex0 = edgeA.m_hasVertex0;\n var hasVertex3 = edgeA.m_hasVertex3;\n var edge1 = Vec2.sub(v2, v1);\n edge1.normalize();\n var normal1 = Vec2.neo(edge1.y, -edge1.x);\n var offset1 = Vec2.dot(normal1, Vec2.sub(centroidB, v1));\n var offset0 = 0;\n var offset2 = 0;\n var convex1 = false;\n var convex2 = false;\n if (hasVertex0) {\n var edge0 = Vec2.sub(v1, v0);\n edge0.normalize();\n var normal0 = Vec2.neo(edge0.y, -edge0.x);\n convex1 = Vec2.cross(edge0, edge1) >= 0;\n offset0 = Vec2.dot(normal0, centroidB) - Vec2.dot(normal0, v0);\n }\n if (hasVertex3) {\n var edge2 = Vec2.sub(v3, v2);\n edge2.normalize();\n var normal2 = Vec2.neo(edge2.y, -edge2.x);\n convex2 = Vec2.cross(edge1, edge2) > 0;\n offset2 = Vec2.dot(normal2, centroidB) - Vec2.dot(normal2, v2);\n }\n var front;\n var normal = Vec2.zero();\n var lowerLimit = Vec2.zero();\n var upperLimit = Vec2.zero();\n if (hasVertex0 && hasVertex3) {\n if (convex1 && convex2) {\n front = offset0 >= 0 || offset1 >= 0 || offset2 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.set(normal2);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.wSet(-1, normal1);\n }\n } else if (convex1) {\n front = offset0 >= 0 || offset1 >= 0 && offset2 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.set(normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal2);\n upperLimit.wSet(-1, normal1);\n }\n } else if (convex2) {\n front = offset2 >= 0 || offset0 >= 0 && offset1 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal2);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.wSet(-1, normal0);\n }\n } else {\n front = offset0 >= 0 && offset1 >= 0 && offset2 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal2);\n upperLimit.wSet(-1, normal0);\n }\n }\n } else if (hasVertex0) {\n if (convex1) {\n front = offset0 >= 0 || offset1 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal0);\n upperLimit.wSet(-1, normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.wSet(-1, normal1);\n }\n } else {\n front = offset0 >= 0 && offset1 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.set(normal1);\n upperLimit.wSet(-1, normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.wSet(-1, normal0);\n }\n }\n } else if (hasVertex3) {\n if (convex2) {\n front = offset1 >= 0 || offset2 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.set(normal2);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.set(normal1);\n }\n } else {\n front = offset1 >= 0 && offset2 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.set(normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.wSet(-1, normal2);\n upperLimit.set(normal1);\n }\n }\n } else {\n front = offset1 >= 0;\n if (front) {\n normal.set(normal1);\n lowerLimit.wSet(-1, normal1);\n upperLimit.wSet(-1, normal1);\n } else {\n normal.wSet(-1, normal1);\n lowerLimit.set(normal1);\n upperLimit.set(normal1);\n }\n }\n polygonBA.count = polygonB.m_count;\n for (var i = 0; i < polygonB.m_count; ++i) {\n polygonBA.vertices[i] = Transform.mul(xf, polygonB.m_vertices[i]);\n polygonBA.normals[i] = Rot.mul(xf.q, polygonB.m_normals[i]);\n }\n var radius = 2 * Settings.polygonRadius;\n manifold.pointCount = 0;\n {\n edgeAxis.type = e_edgeA;\n edgeAxis.index = front ? 0 : 1;\n edgeAxis.separation = Infinity;\n for (var i = 0; i < polygonBA.count; ++i) {\n var s = Vec2.dot(normal, Vec2.sub(polygonBA.vertices[i], v1));\n if (s < edgeAxis.separation) {\n edgeAxis.separation = s;\n }\n }\n }\n if (edgeAxis.type == e_unknown) {\n return;\n }\n if (edgeAxis.separation > radius) {\n return;\n }\n {\n polygonAxis.type = e_unknown;\n polygonAxis.index = -1;\n polygonAxis.separation = -Infinity;\n var perp = Vec2.neo(-normal.y, normal.x);\n for (var i = 0; i < polygonBA.count; ++i) {\n var n = Vec2.neg(polygonBA.normals[i]);\n var s1 = Vec2.dot(n, Vec2.sub(polygonBA.vertices[i], v1));\n var s2 = Vec2.dot(n, Vec2.sub(polygonBA.vertices[i], v2));\n var s = Math.min(s1, s2);\n if (s > radius) {\n polygonAxis.type = e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n break;\n }\n if (Vec2.dot(n, perp) >= 0) {\n if (Vec2.dot(Vec2.sub(n, upperLimit), normal) < -Settings.angularSlop) {\n continue;\n }\n } else {\n if (Vec2.dot(Vec2.sub(n, lowerLimit), normal) < -Settings.angularSlop) {\n continue;\n }\n }\n if (s > polygonAxis.separation) {\n polygonAxis.type = e_edgeB;\n polygonAxis.index = i;\n polygonAxis.separation = s;\n }\n }\n }\n if (polygonAxis.type != e_unknown && polygonAxis.separation > radius) {\n return;\n }\n var k_relativeTol = .98;\n var k_absoluteTol = .001;\n var primaryAxis;\n if (polygonAxis.type == e_unknown) {\n primaryAxis = edgeAxis;\n } else if (polygonAxis.separation > k_relativeTol * edgeAxis.separation + k_absoluteTol) {\n primaryAxis = polygonAxis;\n } else {\n primaryAxis = edgeAxis;\n }\n var ie = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n if (primaryAxis.type == e_edgeA) {\n manifold.type = Manifold.e_faceA;\n var bestIndex = 0;\n var bestValue = Vec2.dot(normal, polygonBA.normals[0]);\n for (var i = 1; i < polygonBA.count; ++i) {\n var value = Vec2.dot(normal, polygonBA.normals[i]);\n if (value < bestValue) {\n bestValue = value;\n bestIndex = i;\n }\n }\n var i1 = bestIndex;\n var i2 = i1 + 1 < polygonBA.count ? i1 + 1 : 0;\n ie[0].v = polygonBA.vertices[i1];\n ie[0].id.cf.indexA = 0;\n ie[0].id.cf.indexB = i1;\n ie[0].id.cf.typeA = Manifold.e_face;\n ie[0].id.cf.typeB = Manifold.e_vertex;\n ie[1].v = polygonBA.vertices[i2];\n ie[1].id.cf.indexA = 0;\n ie[1].id.cf.indexB = i2;\n ie[1].id.cf.typeA = Manifold.e_face;\n ie[1].id.cf.typeB = Manifold.e_vertex;\n if (front) {\n rf.i1 = 0;\n rf.i2 = 1;\n rf.v1 = v1;\n rf.v2 = v2;\n rf.normal.set(normal1);\n } else {\n rf.i1 = 1;\n rf.i2 = 0;\n rf.v1 = v2;\n rf.v2 = v1;\n rf.normal.wSet(-1, normal1);\n }\n } else {\n manifold.type = Manifold.e_faceB;\n ie[0].v = v1;\n ie[0].id.cf.indexA = 0;\n ie[0].id.cf.indexB = primaryAxis.index;\n ie[0].id.cf.typeA = Manifold.e_vertex;\n ie[0].id.cf.typeB = Manifold.e_face;\n ie[1].v = v2;\n ie[1].id.cf.indexA = 0;\n ie[1].id.cf.indexB = primaryAxis.index;\n ie[1].id.cf.typeA = Manifold.e_vertex;\n ie[1].id.cf.typeB = Manifold.e_face;\n rf.i1 = primaryAxis.index;\n rf.i2 = rf.i1 + 1 < polygonBA.count ? rf.i1 + 1 : 0;\n rf.v1 = polygonBA.vertices[rf.i1];\n rf.v2 = polygonBA.vertices[rf.i2];\n rf.normal.set(polygonBA.normals[rf.i1]);\n }\n rf.sideNormal1.set(rf.normal.y, -rf.normal.x);\n rf.sideNormal2.wSet(-1, rf.sideNormal1);\n rf.sideOffset1 = Vec2.dot(rf.sideNormal1, rf.v1);\n rf.sideOffset2 = Vec2.dot(rf.sideNormal2, rf.v2);\n var clipPoints1 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var clipPoints2 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var np;\n np = Manifold.clipSegmentToLine(clipPoints1, ie, rf.sideNormal1, rf.sideOffset1, rf.i1);\n if (np < Settings.maxManifoldPoints) {\n return;\n }\n np = Manifold.clipSegmentToLine(clipPoints2, clipPoints1, rf.sideNormal2, rf.sideOffset2, rf.i2);\n if (np < Settings.maxManifoldPoints) {\n return;\n }\n if (primaryAxis.type == e_edgeA) {\n manifold.localNormal = Vec2.clone(rf.normal);\n manifold.localPoint = Vec2.clone(rf.v1);\n } else {\n manifold.localNormal = Vec2.clone(polygonB.m_normals[rf.i1]);\n manifold.localPoint = Vec2.clone(polygonB.m_vertices[rf.i1]);\n }\n var pointCount = 0;\n for (var i = 0; i < Settings.maxManifoldPoints; ++i) {\n var separation = Vec2.dot(rf.normal, Vec2.sub(clipPoints2[i].v, rf.v1));\n if (separation <= radius) {\n var cp = manifold.points[pointCount];\n if (primaryAxis.type == e_edgeA) {\n cp.localPoint = Transform.mulT(xf, clipPoints2[i].v);\n cp.id = clipPoints2[i].id;\n } else {\n cp.localPoint = clipPoints2[i].v;\n cp.id.cf.typeA = clipPoints2[i].id.cf.typeB;\n cp.id.cf.typeB = clipPoints2[i].id.cf.typeA;\n cp.id.cf.indexA = clipPoints2[i].id.cf.indexB;\n cp.id.cf.indexB = clipPoints2[i].id.cf.indexA;\n }\n ++pointCount;\n }\n }\n manifold.pointCount = pointCount;\n}\n\n\n},{\"../Contact\":3,\"../Manifold\":6,\"../Settings\":7,\"../Shape\":8,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"./ChainShape\":40,\"./EdgeShape\":47,\"./PolygonShape\":48}],46:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar common = require(\"../util/common\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar Manifold = require(\"../Manifold\");\n\nvar Contact = require(\"../Contact\");\n\nvar Shape = require(\"../Shape\");\n\nvar PolygonShape = require(\"./PolygonShape\");\n\nmodule.exports = CollidePolygons;\n\nContact.addType(PolygonShape.TYPE, PolygonShape.TYPE, PolygonContact);\n\nfunction PolygonContact(manifold, xfA, fixtureA, indexA, xfB, fixtureB, indexB) {\n ASSERT && common.assert(fixtureA.getType() == PolygonShape.TYPE);\n ASSERT && common.assert(fixtureB.getType() == PolygonShape.TYPE);\n CollidePolygons(manifold, fixtureA.getShape(), xfA, fixtureB.getShape(), xfB);\n}\n\nfunction FindMaxSeparation(poly1, xf1, poly2, xf2) {\n var count1 = poly1.m_count;\n var count2 = poly2.m_count;\n var n1s = poly1.m_normals;\n var v1s = poly1.m_vertices;\n var v2s = poly2.m_vertices;\n var xf = Transform.mulT(xf2, xf1);\n var bestIndex = 0;\n var maxSeparation = -Infinity;\n for (var i = 0; i < count1; ++i) {\n var n = Rot.mul(xf.q, n1s[i]);\n var v1 = Transform.mul(xf, v1s[i]);\n var si = Infinity;\n for (var j = 0; j < count2; ++j) {\n var sij = Vec2.dot(n, v2s[j]) - Vec2.dot(n, v1);\n if (sij < si) {\n si = sij;\n }\n }\n if (si > maxSeparation) {\n maxSeparation = si;\n bestIndex = i;\n }\n }\n FindMaxSeparation._maxSeparation = maxSeparation;\n FindMaxSeparation._bestIndex = bestIndex;\n}\n\nfunction FindIncidentEdge(c, poly1, xf1, edge1, poly2, xf2) {\n var normals1 = poly1.m_normals;\n var count2 = poly2.m_count;\n var vertices2 = poly2.m_vertices;\n var normals2 = poly2.m_normals;\n ASSERT && common.assert(0 <= edge1 && edge1 < poly1.m_count);\n var normal1 = Rot.mulT(xf2.q, Rot.mul(xf1.q, normals1[edge1]));\n var index = 0;\n var minDot = Infinity;\n for (var i = 0; i < count2; ++i) {\n var dot = Vec2.dot(normal1, normals2[i]);\n if (dot < minDot) {\n minDot = dot;\n index = i;\n }\n }\n var i1 = index;\n var i2 = i1 + 1 < count2 ? i1 + 1 : 0;\n c[0].v = Transform.mul(xf2, vertices2[i1]);\n c[0].id.cf.indexA = edge1;\n c[0].id.cf.indexB = i1;\n c[0].id.cf.typeA = Manifold.e_face;\n c[0].id.cf.typeB = Manifold.e_vertex;\n c[1].v = Transform.mul(xf2, vertices2[i2]);\n c[1].id.cf.indexA = edge1;\n c[1].id.cf.indexB = i2;\n c[1].id.cf.typeA = Manifold.e_face;\n c[1].id.cf.typeB = Manifold.e_vertex;\n}\n\nfunction CollidePolygons(manifold, polyA, xfA, polyB, xfB) {\n manifold.pointCount = 0;\n var totalRadius = polyA.m_radius + polyB.m_radius;\n FindMaxSeparation(polyA, xfA, polyB, xfB);\n var edgeA = FindMaxSeparation._bestIndex;\n var separationA = FindMaxSeparation._maxSeparation;\n if (separationA > totalRadius) return;\n FindMaxSeparation(polyB, xfB, polyA, xfA);\n var edgeB = FindMaxSeparation._bestIndex;\n var separationB = FindMaxSeparation._maxSeparation;\n if (separationB > totalRadius) return;\n var poly1;\n var poly2;\n var xf1;\n var xf2;\n var edge1;\n var flip;\n var k_tol = .1 * Settings.linearSlop;\n if (separationB > separationA + k_tol) {\n poly1 = polyB;\n poly2 = polyA;\n xf1 = xfB;\n xf2 = xfA;\n edge1 = edgeB;\n manifold.type = Manifold.e_faceB;\n flip = 1;\n } else {\n poly1 = polyA;\n poly2 = polyB;\n xf1 = xfA;\n xf2 = xfB;\n edge1 = edgeA;\n manifold.type = Manifold.e_faceA;\n flip = 0;\n }\n var incidentEdge = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);\n var count1 = poly1.m_count;\n var vertices1 = poly1.m_vertices;\n var iv1 = edge1;\n var iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;\n var v11 = vertices1[iv1];\n var v12 = vertices1[iv2];\n var localTangent = Vec2.sub(v12, v11);\n localTangent.normalize();\n var localNormal = Vec2.cross(localTangent, 1);\n var planePoint = Vec2.wAdd(.5, v11, .5, v12);\n var tangent = Rot.mul(xf1.q, localTangent);\n var normal = Vec2.cross(tangent, 1);\n v11 = Transform.mul(xf1, v11);\n v12 = Transform.mul(xf1, v12);\n var frontOffset = Vec2.dot(normal, v11);\n var sideOffset1 = -Vec2.dot(tangent, v11) + totalRadius;\n var sideOffset2 = Vec2.dot(tangent, v12) + totalRadius;\n var clipPoints1 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var clipPoints2 = [ new Manifold.clipVertex(), new Manifold.clipVertex() ];\n var np;\n np = Manifold.clipSegmentToLine(clipPoints1, incidentEdge, Vec2.neg(tangent), sideOffset1, iv1);\n if (np < 2) {\n return;\n }\n np = Manifold.clipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2, iv2);\n if (np < 2) {\n return;\n }\n manifold.localNormal = localNormal;\n manifold.localPoint = planePoint;\n var pointCount = 0;\n for (var i = 0; i < clipPoints2.length; ++i) {\n var separation = Vec2.dot(normal, clipPoints2[i].v) - frontOffset;\n if (separation <= totalRadius) {\n var cp = manifold.points[pointCount];\n cp.localPoint.set(Transform.mulT(xf2, clipPoints2[i].v));\n cp.id = clipPoints2[i].id;\n if (flip) {\n var cf = cp.id.cf;\n var indexA = cf.indexA;\n var indexB = cf.indexB;\n var typeA = cf.typeA;\n var typeB = cf.typeB;\n cf.indexA = indexB;\n cf.indexB = indexA;\n cf.typeA = typeB;\n cf.typeB = typeA;\n }\n ++pointCount;\n }\n }\n manifold.pointCount = pointCount;\n}\n\n\n},{\"../Contact\":3,\"../Manifold\":6,\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"./PolygonShape\":48}],47:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = EdgeShape;\n\nvar create = require(\"../util/create\");\n\nvar options = require(\"../util/options\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nEdgeShape._super = Shape;\n\nEdgeShape.prototype = create(EdgeShape._super.prototype);\n\nEdgeShape.TYPE = \"edge\";\n\nfunction EdgeShape(v1, v2) {\n if (!(this instanceof EdgeShape)) {\n return new EdgeShape(v1, v2);\n }\n EdgeShape._super.call(this);\n this.m_type = EdgeShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_vertex1 = v1 ? Vec2.clone(v1) : Vec2.zero();\n this.m_vertex2 = v2 ? Vec2.clone(v2) : Vec2.zero();\n this.m_vertex0 = Vec2.zero();\n this.m_vertex3 = Vec2.zero();\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n}\n\nEdgeShape.prototype.setNext = function(v3) {\n if (v3) {\n this.m_vertex3.set(v3);\n this.m_hasVertex3 = true;\n } else {\n this.m_vertex3.setZero();\n this.m_hasVertex3 = false;\n }\n return this;\n};\n\nEdgeShape.prototype.setPrev = function(v0) {\n if (v0) {\n this.m_vertex0.set(v0);\n this.m_hasVertex0 = true;\n } else {\n this.m_vertex0.setZero();\n this.m_hasVertex0 = false;\n }\n return this;\n};\n\nEdgeShape.prototype._set = function(v1, v2) {\n this.m_vertex1.set(v1);\n this.m_vertex2.set(v2);\n this.m_hasVertex0 = false;\n this.m_hasVertex3 = false;\n return this;\n};\n\nEdgeShape.prototype._clone = function() {\n var clone = new EdgeShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_vertex1.set(this.m_vertex1);\n clone.m_vertex2.set(this.m_vertex2);\n clone.m_vertex0.set(this.m_vertex0);\n clone.m_vertex3.set(this.m_vertex3);\n clone.m_hasVertex0 = this.m_hasVertex0;\n clone.m_hasVertex3 = this.m_hasVertex3;\n return clone;\n};\n\nEdgeShape.prototype.getChildCount = function() {\n return 1;\n};\n\nEdgeShape.prototype.testPoint = function(xf, p) {\n return false;\n};\n\nEdgeShape.prototype.rayCast = function(output, input, xf, childIndex) {\n var p1 = Rot.mulT(xf.q, Vec2.sub(input.p1, xf.p));\n var p2 = Rot.mulT(xf.q, Vec2.sub(input.p2, xf.p));\n var d = Vec2.sub(p2, p1);\n var v1 = this.m_vertex1;\n var v2 = this.m_vertex2;\n var e = Vec2.sub(v2, v1);\n var normal = Vec2.neo(e.y, -e.x);\n normal.normalize();\n var numerator = Vec2.dot(normal, Vec2.sub(v1, p1));\n var denominator = Vec2.dot(normal, d);\n if (denominator == 0) {\n return false;\n }\n var t = numerator / denominator;\n if (t < 0 || input.maxFraction < t) {\n return false;\n }\n var q = Vec2.add(p1, Vec2.mul(t, d));\n var r = Vec2.sub(v2, v1);\n var rr = Vec2.dot(r, r);\n if (rr == 0) {\n return false;\n }\n var s = Vec2.dot(Vec2.sub(q, v1), r) / rr;\n if (s < 0 || 1 < s) {\n return false;\n }\n output.fraction = t;\n if (numerator > 0) {\n output.normal = Rot.mul(xf.q, normal).neg();\n } else {\n output.normal = Rot.mul(xf.q, normal);\n }\n return true;\n};\n\nEdgeShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var v1 = Transform.mul(xf, this.m_vertex1);\n var v2 = Transform.mul(xf, this.m_vertex2);\n aabb.combinePoints(v1, v2);\n aabb.extend(this.m_radius);\n};\n\nEdgeShape.prototype.computeMass = function(massData, density) {\n massData.mass = 0;\n massData.center.wSet(.5, this.m_vertex1, .5, this.m_vertex2);\n massData.I = 0;\n};\n\nEdgeShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices.push(this.m_vertex1);\n proxy.m_vertices.push(this.m_vertex2);\n proxy.m_count = 2;\n proxy.m_radius = this.m_radius;\n};\n\n\n},{\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/create\":52,\"../util/options\":53}],48:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = PolygonShape;\n\nvar common = require(\"../util/common\");\n\nvar create = require(\"../util/create\");\n\nvar options = require(\"../util/options\");\n\nvar Math = require(\"../common/Math\");\n\nvar Transform = require(\"../common/Transform\");\n\nvar Rot = require(\"../common/Rot\");\n\nvar Vec2 = require(\"../common/Vec2\");\n\nvar AABB = require(\"../collision/AABB\");\n\nvar Settings = require(\"../Settings\");\n\nvar Shape = require(\"../Shape\");\n\nPolygonShape._super = Shape;\n\nPolygonShape.prototype = create(PolygonShape._super.prototype);\n\nPolygonShape.TYPE = \"polygon\";\n\nfunction PolygonShape(vertices) {\n if (!(this instanceof PolygonShape)) {\n return new PolygonShape(vertices);\n }\n PolygonShape._super.call(this);\n this.m_type = PolygonShape.TYPE;\n this.m_radius = Settings.polygonRadius;\n this.m_centroid = Vec2.zero();\n this.m_vertices = [];\n this.m_normals = [];\n this.m_count = 0;\n if (vertices && vertices.length) {\n this._set(vertices);\n }\n}\n\nPolygonShape.prototype.getVertex = function(index) {\n ASSERT && common.assert(0 <= index && index < this.m_count);\n return this.m_vertices[index];\n};\n\nPolygonShape.prototype._clone = function() {\n var clone = new PolygonShape();\n clone.m_type = this.m_type;\n clone.m_radius = this.m_radius;\n clone.m_count = this.m_count;\n clone.m_centroid.set(this.m_centroid);\n for (var i = 0; i < this.m_count; i++) {\n clone.m_vertices.push(this.m_vertices[i].clone());\n }\n for (var i = 0; i < this.m_normals.length; i++) {\n clone.m_normals.push(this.m_normals[i].clone());\n }\n return clone;\n};\n\nPolygonShape.prototype.getChildCount = function() {\n return 1;\n};\n\nfunction ComputeCentroid(vs, count) {\n ASSERT && common.assert(count >= 3);\n var c = Vec2.zero();\n var area = 0;\n var pRef = Vec2.zero();\n if (false) {\n for (var i = 0; i < count; ++i) {\n pRef.add(vs[i]);\n }\n pRef.mul(1 / count);\n }\n var inv3 = 1 / 3;\n for (var i = 0; i < count; ++i) {\n var p1 = pRef;\n var p2 = vs[i];\n var p3 = i + 1 < count ? vs[i + 1] : vs[0];\n var e1 = Vec2.sub(p2, p1);\n var e2 = Vec2.sub(p3, p1);\n var D = Vec2.cross(e1, e2);\n var triangleArea = .5 * D;\n area += triangleArea;\n c.wAdd(triangleArea * inv3, p1);\n c.wAdd(triangleArea * inv3, p2);\n c.wAdd(triangleArea * inv3, p3);\n }\n ASSERT && common.assert(area > Math.EPSILON);\n c.mul(1 / area);\n return c;\n}\n\nPolygonShape.prototype._set = function(vertices) {\n ASSERT && common.assert(3 <= vertices.length && vertices.length <= Settings.maxPolygonVertices);\n if (vertices.length < 3) {\n SetAsBox(1, 1);\n return;\n }\n var n = Math.min(vertices.length, Settings.maxPolygonVertices);\n var ps = [];\n var tempCount = 0;\n for (var i = 0; i < n; ++i) {\n var v = vertices[i];\n var unique = true;\n for (var j = 0; j < tempCount; ++j) {\n if (Vec2.distanceSquared(v, ps[j]) < .25 * Settings.linearSlopSquared) {\n unique = false;\n break;\n }\n }\n if (unique) {\n ps[tempCount++] = v;\n }\n }\n n = tempCount;\n if (n < 3) {\n ASSERT && common.assert(false);\n SetAsBox(1, 1);\n return;\n }\n var i0 = 0;\n var x0 = ps[0].x;\n for (var i = 1; i < n; ++i) {\n var x = ps[i].x;\n if (x > x0 || x == x0 && ps[i].y < ps[i0].y) {\n i0 = i;\n x0 = x;\n }\n }\n var hull = [];\n var m = 0;\n var ih = i0;\n for (;;) {\n hull[m] = ih;\n var ie = 0;\n for (var j = 1; j < n; ++j) {\n if (ie == ih) {\n ie = j;\n continue;\n }\n var r = Vec2.sub(ps[ie], ps[hull[m]]);\n var v = Vec2.sub(ps[j], ps[hull[m]]);\n var c = Vec2.cross(r, v);\n if (c < 0) {\n ie = j;\n }\n if (c == 0 && v.lengthSquared() > r.lengthSquared()) {\n ie = j;\n }\n }\n ++m;\n ih = ie;\n if (ie == i0) {\n break;\n }\n }\n if (m < 3) {\n ASSERT && common.assert(false);\n SetAsBox(1, 1);\n return;\n }\n this.m_count = m;\n for (var i = 0; i < m; ++i) {\n this.m_vertices[i] = ps[hull[i]];\n }\n for (var i = 0; i < m; ++i) {\n var i1 = i;\n var i2 = i + 1 < m ? i + 1 : 0;\n var edge = Vec2.sub(this.m_vertices[i2], this.m_vertices[i1]);\n ASSERT && common.assert(edge.lengthSquared() > Math.EPSILON * Math.EPSILON);\n this.m_normals[i] = Vec2.cross(edge, 1);\n this.m_normals[i].normalize();\n }\n this.m_centroid = ComputeCentroid(this.m_vertices, m);\n};\n\nPolygonShape.prototype.testPoint = function(xf, p) {\n var pLocal = Rot.mulT(xf.q, Vec2.sub(p, xf.p));\n for (var i = 0; i < this.m_count; ++i) {\n var dot = Vec2.dot(this.m_normals[i], Vec2.sub(pLocal, this.m_vertices[i]));\n if (dot > 0) {\n return false;\n }\n }\n return true;\n};\n\nPolygonShape.prototype.rayCast = function(output, input, xf, childIndex) {\n var p1 = Rot.mulT(xf.q, Vec2.sub(input.p1, xf.p));\n var p2 = Rot.mulT(xf.q, Vec2.sub(input.p2, xf.p));\n var d = Vec2.sub(p2, p1);\n var lower = 0;\n var upper = input.maxFraction;\n var index = -1;\n for (var i = 0; i < this.m_count; ++i) {\n var numerator = Vec2.dot(this.m_normals[i], Vec2.sub(this.m_vertices[i], p1));\n var denominator = Vec2.dot(this.m_normals[i], d);\n if (denominator == 0) {\n if (numerator < 0) {\n return false;\n }\n } else {\n if (denominator < 0 && numerator < lower * denominator) {\n lower = numerator / denominator;\n index = i;\n } else if (denominator > 0 && numerator < upper * denominator) {\n upper = numerator / denominator;\n }\n }\n if (upper < lower) {\n return false;\n }\n }\n ASSERT && common.assert(0 <= lower && lower <= input.maxFraction);\n if (index >= 0) {\n output.fraction = lower;\n output.normal = Rot.mul(xf.q, this.m_normals[index]);\n return true;\n }\n return false;\n};\n\nPolygonShape.prototype.computeAABB = function(aabb, xf, childIndex) {\n var minX = Infinity, minY = Infinity;\n var maxX = -Infinity, maxY = -Infinity;\n for (var i = 0; i < this.m_count; ++i) {\n var v = Transform.mul(xf, this.m_vertices[i]);\n minX = Math.min(minX, v.x);\n maxX = Math.max(maxX, v.x);\n minY = Math.min(minY, v.y);\n maxY = Math.max(maxY, v.y);\n }\n aabb.lowerBound.set(minX, minY);\n aabb.upperBound.set(maxX, maxY);\n aabb.extend(this.m_radius);\n};\n\nPolygonShape.prototype.computeMass = function(massData, density) {\n ASSERT && common.assert(this.m_count >= 3);\n var center = Vec2.zero();\n var area = 0;\n var I = 0;\n var s = Vec2.zero();\n for (var i = 0; i < this.m_count; ++i) {\n s.add(this.m_vertices[i]);\n }\n s.mul(1 / this.m_count);\n var k_inv3 = 1 / 3;\n for (var i = 0; i < this.m_count; ++i) {\n var e1 = Vec2.sub(this.m_vertices[i], s);\n var e2 = i + 1 < this.m_count ? Vec2.sub(this.m_vertices[i + 1], s) : Vec2.sub(this.m_vertices[0], s);\n var D = Vec2.cross(e1, e2);\n var triangleArea = .5 * D;\n area += triangleArea;\n center.wAdd(triangleArea * k_inv3, e1, triangleArea * k_inv3, e2);\n var ex1 = e1.x;\n var ey1 = e1.y;\n var ex2 = e2.x;\n var ey2 = e2.y;\n var intx2 = ex1 * ex1 + ex2 * ex1 + ex2 * ex2;\n var inty2 = ey1 * ey1 + ey2 * ey1 + ey2 * ey2;\n I += .25 * k_inv3 * D * (intx2 + inty2);\n }\n massData.mass = density * area;\n ASSERT && common.assert(area > Math.EPSILON);\n center.mul(1 / area);\n massData.center.wSet(1, center, 1, s);\n massData.I = density * I;\n massData.I += massData.mass * (Vec2.dot(massData.center, massData.center) - Vec2.dot(center, center));\n};\n\nPolygonShape.prototype.validate = function() {\n for (var i = 0; i < this.m_count; ++i) {\n var i1 = i;\n var i2 = i < this.m_count - 1 ? i1 + 1 : 0;\n var p = this.m_vertices[i1];\n var e = Vec2.sub(this.m_vertices[i2], p);\n for (var j = 0; j < this.m_count; ++j) {\n if (j == i1 || j == i2) {\n continue;\n }\n var v = Vec2.sub(this.m_vertices[j], p);\n var c = Vec2.cross(e, v);\n if (c < 0) {\n return false;\n }\n }\n }\n return true;\n};\n\nPolygonShape.prototype.computeDistanceProxy = function(proxy) {\n proxy.m_vertices = this.m_vertices;\n proxy.m_count = this.m_count;\n proxy.m_radius = this.m_radius;\n};\n\n\n},{\"../Settings\":7,\"../Shape\":8,\"../collision/AABB\":11,\"../common/Math\":18,\"../common/Rot\":20,\"../common/Transform\":22,\"../common/Vec2\":23,\"../util/common\":51,\"../util/create\":52,\"../util/options\":53}],49:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports = Pool;\n\nfunction Pool(opts) {\n var _list = [];\n var _max = opts.max || Infinity;\n var _createFn = opts.create;\n var _outFn = opts.allocate;\n var _inFn = opts.release;\n var _discardFn = opts.discard;\n var _createCount = 0;\n var _outCount = 0;\n var _inCount = 0;\n var _discardCount = 0;\n this.max = function(n) {\n if (typeof n === \"number\") {\n _max = n;\n return this;\n }\n return _max;\n };\n this.size = function() {\n return _list.length;\n };\n this.allocate = function() {\n var item;\n if (_list.length > 0) {\n item = _list.shift();\n } else {\n _createCount++;\n if (typeof _createFn === \"function\") {\n item = _createFn();\n } else {\n item = {};\n }\n }\n _outCount++;\n if (typeof _outFn === \"function\") {\n _outFn(item);\n }\n return item;\n };\n this.release = function(item) {\n if (_list.length < _max) {\n _inCount++;\n if (typeof _inFn === \"function\") {\n _inFn(item);\n }\n _list.push(item);\n } else {\n _discardCount++;\n if (typeof _discardFn === \"function\") {\n item = _discardFn(item);\n }\n }\n };\n this.toString = function() {\n return \" +\" + _createCount + \" >\" + _outCount + \" <\" + _inCount + \" -\" + _discardCount + \" =\" + _list.length + \"/\" + _max;\n };\n}\n\n\n},{}],50:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nmodule.exports.now = function() {\n return Date.now();\n};\n\nmodule.exports.diff = function(time) {\n return Date.now() - time;\n};\n\n\n},{}],51:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nexports.debug = function() {\n if (!DEBUG) return;\n console.log.apply(console, arguments);\n};\n\nexports.assert = function(statement, err, log) {\n if (!ASSERT) return;\n if (statement) return;\n log && console.log(log);\n throw new Error(err);\n};\n\n\n},{}],52:[function(require,module,exports){\nif (typeof Object.create == \"function\") {\n module.exports = function(proto, props) {\n return Object.create.call(Object, proto, props);\n };\n} else {\n module.exports = function(proto, props) {\n if (props) throw Error(\"Second argument is not supported!\");\n if (typeof proto !== \"object\" || proto === null) throw Error(\"Invalid prototype!\");\n noop.prototype = proto;\n return new noop();\n };\n function noop() {}\n}\n\n\n},{}],53:[function(require,module,exports){\nDEBUG = typeof DEBUG === \"undefined\" ? false : DEBUG;\n\nASSERT = typeof ASSERT === \"undefined\" ? false : ASSERT;\n\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nmodule.exports = function(to, from) {\n if (to === null || typeof to === \"undefined\") {\n to = {};\n }\n for (var key in from) {\n if (from.hasOwnProperty(key) && typeof to[key] === \"undefined\") {\n to[key] = from[key];\n }\n }\n if (typeof Object.getOwnPropertySymbols === \"function\") {\n var symbols = Object.getOwnPropertySymbols(from);\n for (var i = 0; i < symbols.length; i++) {\n var symbol = symbols[i];\n if (from.propertyIsEnumerable(symbol) && typeof to[key] === \"undefined\") {\n to[symbol] = from[symbol];\n }\n }\n }\n return to;\n};\n\n\n},{}],54:[function(require,module,exports){\nfunction _identity(x) {\n return x;\n};\nvar _cache = {};\nvar _modes = {};\nvar _easings = {};\n\nfunction Easing(token) {\n if (typeof token === 'function') {\n return token;\n }\n if (typeof token !== 'string') {\n return _identity;\n }\n var fn = _cache[token];\n if (fn) {\n return fn;\n }\n var match = /^(\\w+)(-(in|out|in-out|out-in))?(\\((.*)\\))?$/i.exec(token);\n if (!match || !match.length) {\n return _identity;\n }\n var easing = _easings[match[1]];\n var mode = _modes[match[3]];\n var params = match[5];\n if (easing && easing.fn) {\n fn = easing.fn;\n } else if (easing && easing.fc) {\n fn = easing.fc.apply(easing.fc, params\n && params.replace(/\\s+/, '').split(','));\n } else {\n fn = _identity;\n }\n if (mode) {\n fn = mode.fn(fn);\n }\n // TODO: It can be a memory leak with different `params`.\n _cache[token] = fn;\n return fn;\n};\n\nEasing.add = function(data) {\n // TODO: create a map of all { name-mode : data }\n var names = (data.name || data.mode).split(/\\s+/);\n for (var i = 0; i < names.length; i++) {\n var name = names[i];\n if (name) {\n (data.name ? _easings : _modes)[name] = data;\n }\n }\n};\n\nEasing.add({\n mode : 'in',\n fn : function(f) {\n return f;\n }\n});\n\nEasing.add({\n mode : 'out',\n fn : function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n }\n});\n\nEasing.add({\n mode : 'in-out',\n fn : function(f) {\n return function(t) {\n return (t < 0.5) ? (f(2 * t) / 2) : (1 - f(2 * (1 - t)) / 2);\n };\n }\n});\n\nEasing.add({\n mode : 'out-in',\n fn : function(f) {\n return function(t) {\n return (t < 0.5) ? (1 - f(2 * (1 - t)) / 2) : (f(2 * t) / 2);\n };\n }\n});\n\nEasing.add({\n name : 'linear',\n fn : function(t) {\n return t;\n }\n});\n\nEasing.add({\n name : 'quad',\n fn : function(t) {\n return t * t;\n }\n});\n\nEasing.add({\n name : 'cubic',\n fn : function(t) {\n return t * t * t;\n }\n});\n\nEasing.add({\n name : 'quart',\n fn : function(t) {\n return t * t * t * t;\n }\n});\n\nEasing.add({\n name : 'quint',\n fn : function(t) {\n return t * t * t * t * t;\n }\n});\n\nEasing.add({\n name : 'sin sine',\n fn : function(t) {\n return 1 - Math.cos(t * Math.PI / 2);\n }\n});\n\nEasing.add({\n name : 'exp expo',\n fn : function(t) {\n return t == 0 ? 0 : Math.pow(2, 10 * (t - 1));\n }\n});\n\nEasing.add({\n name : 'circle circ',\n fn : function(t) {\n return 1 - Math.sqrt(1 - t * t);\n }\n});\n\nEasing.add({\n name : 'bounce',\n fn : function(t) {\n return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625\n * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625\n * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t\n + .984375;\n }\n});\n\nEasing.add({\n name : 'poly',\n fc : function(e) {\n return function(t) {\n return Math.pow(t, e);\n };\n }\n});\n\nEasing.add({\n name : 'elastic',\n fc : function(a, p) {\n p = p || 0.45;\n a = a || 1;\n var s = p / (2 * Math.PI) * Math.asin(1 / a);\n return function(t) {\n return 1 + a * Math.pow(2, -10 * t)\n * Math.sin((t - s) * (2 * Math.PI) / p);\n };\n }\n});\n\nEasing.add({\n name : 'back',\n fc : function(s) {\n s = typeof s !== 'undefined' ? s : 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n }\n});\n\nmodule.exports = Easing;\n\n},{}],55:[function(require,module,exports){\nif (typeof DEBUG === 'undefined')\n DEBUG = true;\n\nrequire('../core')._load(function(stage, elem) {\n Mouse.subscribe(stage, elem);\n});\n\n// TODO: capture mouse\n\nMouse.CLICK = 'click';\nMouse.START = 'touchstart mousedown';\nMouse.MOVE = 'touchmove mousemove';\nMouse.END = 'touchend mouseup';\nMouse.CANCEL = 'touchcancel mousecancel';\n\nMouse.subscribe = function(stage, elem) {\n if (stage.mouse) {\n return;\n }\n\n stage.mouse = new Mouse(stage, elem);\n\n // `click` events are synthesized from start/end events on same nodes\n // `mousecancel` events are synthesized on blur or mouseup outside element\n\n elem.addEventListener('touchstart', handleStart);\n elem.addEventListener('touchend', handleEnd);\n elem.addEventListener('touchmove', handleMove);\n elem.addEventListener('touchcancel', handleCancel);\n\n elem.addEventListener('mousedown', handleStart);\n elem.addEventListener('mouseup', handleEnd);\n elem.addEventListener('mousemove', handleMove);\n\n document.addEventListener('mouseup', handleCancel);\n window.addEventListener(\"blur\", handleCancel);\n\n var clicklist = [], cancellist = [];\n\n function handleStart(event) {\n event.preventDefault();\n stage.mouse.locate(event);\n // DEBUG && console.log('Mouse Start: ' + event.type + ' ' + mouse);\n stage.mouse.publish(event.type, event);\n\n stage.mouse.lookup('click', clicklist);\n stage.mouse.lookup('mousecancel', cancellist);\n }\n\n function handleMove(event) {\n event.preventDefault();\n stage.mouse.locate(event);\n stage.mouse.publish(event.type, event);\n }\n\n function handleEnd(event) {\n event.preventDefault();\n // up/end location is not available, last one is used instead\n // DEBUG && console.log('Mouse End: ' + event.type + ' ' + mouse);\n stage.mouse.publish(event.type, event);\n\n if (clicklist.length) {\n // DEBUG && console.log('Mouse Click: ' + clicklist.length);\n stage.mouse.publish('click', event, clicklist);\n }\n cancellist.length = 0;\n }\n\n function handleCancel(event) {\n if (cancellist.length) {\n // DEBUG && console.log('Mouse Cancel: ' + event.type);\n stage.mouse.publish('mousecancel', event, cancellist);\n }\n clicklist.length = 0;\n }\n};\n\nfunction Mouse(stage, elem) {\n if (!(this instanceof Mouse)) {\n // old-style mouse subscription\n return;\n }\n\n var ratio = stage.viewport().ratio || 1;\n\n stage.on('viewport', function(size) {\n ratio = size.ratio || ratio;\n });\n\n this.x = 0;\n this.y = 0;\n this.toString = function() {\n return (this.x | 0) + 'x' + (this.y | 0);\n };\n this.locate = function(event) {\n locateElevent(elem, event, this);\n this.x *= ratio;\n this.y *= ratio;\n };\n this.lookup = function(type, collect) {\n this.type = type;\n this.root = stage;\n this.event = null;\n collect.length = 0;\n this.collect = collect;\n\n this.root.visit(this.visitor, this);\n };\n this.publish = function(type, event, targets) {\n this.type = type;\n this.root = stage;\n this.event = event;\n this.collect = false;\n this.timeStamp = Date.now();\n\n if (type !== 'mousemove' && type !== 'touchmove') {\n DEBUG && console.log(this.type + ' ' + this);\n }\n\n if (targets) {\n while (targets.length)\n if (this.visitor.end(targets.shift(), this))\n break;\n targets.length = 0;\n } else {\n this.root.visit(this.visitor, this);\n }\n };\n this.visitor = {\n reverse : true,\n visible : true,\n start : function(node, mouse) {\n return !node._flag(mouse.type);\n },\n end : function(node, mouse) {\n // mouse: event/collect, type, root\n rel.raw = mouse.event;\n rel.type = mouse.type;\n rel.timeStamp = mouse.timeStamp;\n rel.abs.x = mouse.x;\n rel.abs.y = mouse.y;\n\n var listeners = node.listeners(mouse.type);\n if (!listeners) {\n return;\n }\n node.matrix().inverse().map(mouse, rel);\n if (!(node === mouse.root || node.hitTest(rel))) {\n return;\n }\n if (mouse.collect) {\n mouse.collect.push(node);\n }\n if (mouse.event) {\n var cancel = false;\n for (var l = 0; l < listeners.length; l++) {\n cancel = listeners[l].call(node, rel) ? true : cancel;\n }\n return cancel;\n }\n }\n };\n};\n\n// TODO: define per mouse object with get-only x and y\nvar rel = {}, abs = {};\n\ndefineValue(rel, 'clone', function(obj) {\n obj = obj || {}, obj.x = this.x, obj.y = this.y;\n return obj;\n});\ndefineValue(rel, 'toString', function() {\n return (this.x | 0) + 'x' + (this.y | 0) + ' (' + this.abs + ')';\n});\ndefineValue(rel, 'abs', abs);\ndefineValue(abs, 'clone', function(obj) {\n obj = obj || {}, obj.x = this.x, obj.y = this.y;\n return obj;\n});\ndefineValue(abs, 'toString', function() {\n return (this.x | 0) + 'x' + (this.y | 0);\n});\n\nfunction defineValue(obj, name, value) {\n Object.defineProperty(obj, name, {\n value : value\n });\n}\n\nfunction locateElevent(el, ev, loc) {\n // pageX/Y if available?\n if (ev.touches && ev.touches.length) {\n loc.x = ev.touches[0].clientX;\n loc.y = ev.touches[0].clientY;\n } else {\n loc.x = ev.clientX;\n loc.y = ev.clientY;\n }\n var rect = el.getBoundingClientRect();\n loc.x -= rect.left;\n loc.y -= rect.top;\n loc.x -= el.clientLeft | 0;\n loc.y -= el.clientTop | 0;\n return loc;\n};\n\nmodule.exports = Mouse;\n\n},{\"../core\":60}],56:[function(require,module,exports){\nvar Easing = require('./easing');\nvar Class = require('../core');\nvar Pin = require('../pin');\n\nClass.prototype.tween = function(duration, delay, append) {\n if (typeof duration !== 'number') {\n append = duration, delay = 0, duration = 0;\n } else if (typeof delay !== 'number') {\n append = delay, delay = 0;\n }\n\n if (!this._tweens) {\n this._tweens = [];\n var ticktime = 0;\n this.tick(function(elapsed, now, last) {\n if (!this._tweens.length) {\n return;\n }\n\n // ignore old elapsed\n var ignore = ticktime != last;\n ticktime = now;\n if (ignore) {\n return true;\n }\n\n var next = this._tweens[0].tick(this, elapsed, now, last);\n if (next) {\n this._tweens.shift();\n }\n\n if (typeof next === 'object') {\n this._tweens.unshift(next);\n }\n\n return true;\n }, true);\n }\n\n this.touch();\n if (!append) {\n this._tweens.length = 0;\n }\n var tween = new Tween(this, duration, delay);\n this._tweens.push(tween);\n return tween;\n};\n\nfunction Tween(owner, duration, delay) {\n this._end = {};\n this._duration = duration || 400;\n this._delay = delay || 0;\n\n this._owner = owner;\n this._time = 0;\n};\n\nTween.prototype.tick = function(node, elapsed, now, last) {\n this._time += elapsed;\n\n if (this._time < this._delay) {\n return;\n }\n\n var time = this._time - this._delay;\n\n if (!this._start) {\n this._start = {};\n for ( var key in this._end) {\n this._start[key] = this._owner.pin(key);\n }\n }\n\n var p, over;\n if (time < this._duration) {\n p = time / this._duration, over = false;\n } else {\n p = 1, over = true;\n }\n p = typeof this._easing == 'function' ? this._easing(p) : p;\n\n var q = 1 - p;\n\n for ( var key in this._end) {\n this._owner.pin(key, this._start[key] * q + this._end[key] * p);\n }\n\n if (over) {\n try {\n this._done && this._done.call(this._owner);\n } catch (e) {\n console.log(e);\n }\n return this._next || true;\n }\n};\n\nTween.prototype.tween = function(duration, delay) {\n return this._next = new Tween(this._owner, duration, delay);\n};\n\nTween.prototype.duration = function(duration) {\n this._duration = duration;\n return this;\n};\n\nTween.prototype.delay = function(delay) {\n this._delay = delay;\n return this;\n};\n\nTween.prototype.ease = function(easing) {\n this._easing = Easing(easing);\n return this;\n};\n\nTween.prototype.done = function(fn) {\n this._done = fn;\n return this;\n};\n\nTween.prototype.hide = function() {\n this.done(function() {\n this.hide();\n });\n return this;\n};\n\nTween.prototype.remove = function() {\n this.done(function() {\n this.remove();\n });\n return this;\n};\n\nTween.prototype.pin = function(a, b) {\n if (typeof a === 'object') {\n for ( var attr in a) {\n pinning(this._owner, this._end, attr, a[attr]);\n }\n } else if (typeof b !== 'undefined') {\n pinning(this._owner, this._end, a, b);\n }\n return this;\n};\n\nfunction pinning(node, map, key, value) {\n if (typeof node.pin(key) === 'number') {\n map[key] = value;\n } else if (typeof node.pin(key + 'X') === 'number'\n && typeof node.pin(key + 'Y') === 'number') {\n map[key + 'X'] = value;\n map[key + 'Y'] = value;\n }\n}\n\nPin._add_shortcuts(Tween);\n\n/**\n * @deprecated Use .done(fn) instead.\n */\nTween.prototype.then = function(fn) {\n this.done(fn);\n return this;\n};\n\n/**\n * @deprecated Use .done(fn) instead.\n */\nTween.prototype.then = function(fn) {\n this.done(fn);\n return this;\n};\n\n/**\n * @deprecated NOOP\n */\nTween.prototype.clear = function(forward) {\n return this;\n};\n\nmodule.exports = Tween;\n},{\"../core\":60,\"../pin\":68,\"./easing\":54}],57:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nrequire('./loop');\n\nvar create = require('./util/create');\nvar math = require('./util/math');\n\nClass.anim = function(frames, fps) {\n var anim = new Anim();\n anim.frames(frames).gotoFrame(0);\n fps && anim.fps(fps);\n return anim;\n};\n\nAnim._super = Class;\nAnim.prototype = create(Anim._super.prototype);\n\n// TODO: replace with atlas fps or texture time\nClass.Anim = {\n FPS : 15\n};\n\nfunction Anim() {\n Anim._super.call(this);\n this.label('Anim');\n\n this._textures = [];\n\n this._fps = Class.Anim.FPS;\n this._ft = 1000 / this._fps;\n\n this._time = -1;\n this._repeat = 0;\n\n this._index = 0;\n this._frames = [];\n\n var lastTime = 0;\n this.tick(function(t, now, last) {\n if (this._time < 0 || this._frames.length <= 1) {\n return;\n }\n\n // ignore old elapsed\n var ignore = lastTime != last;\n lastTime = now;\n if (ignore) {\n return true;\n }\n\n this._time += t;\n if (this._time < this._ft) {\n return true;\n }\n var n = this._time / this._ft | 0;\n this._time -= n * this._ft;\n this.moveFrame(n);\n if (this._repeat > 0 && (this._repeat -= n) <= 0) {\n this.stop();\n this._callback && this._callback();\n return false;\n }\n return true;\n }, false);\n};\n\nAnim.prototype.fps = function(fps) {\n if (typeof fps === 'undefined') {\n return this._fps;\n }\n this._fps = fps > 0 ? fps : Class.Anim.FPS;\n this._ft = 1000 / this._fps;\n return this;\n};\n\n/**\n * @deprecated Use frames\n */\nAnim.prototype.setFrames = function(a, b, c) {\n return this.frames(a, b, c);\n};\n\nAnim.prototype.frames = function(frames) {\n this._index = 0;\n this._frames = Class.texture(frames).array();\n this.touch();\n return this;\n};\n\nAnim.prototype.length = function() {\n return this._frames ? this._frames.length : 0;\n};\n\nAnim.prototype.gotoFrame = function(frame, resize) {\n this._index = math.rotate(frame, this._frames.length) | 0;\n resize = resize || !this._textures[0];\n this._textures[0] = this._frames[this._index];\n if (resize) {\n this.pin('width', this._textures[0].width);\n this.pin('height', this._textures[0].height);\n }\n this.touch();\n return this;\n};\n\nAnim.prototype.moveFrame = function(move) {\n return this.gotoFrame(this._index + move);\n};\n\nAnim.prototype.repeat = function(repeat, callback) {\n this._repeat = repeat * this._frames.length - 1;\n this._callback = callback;\n this.play();\n return this;\n};\n\nAnim.prototype.play = function(frame) {\n if (typeof frame !== 'undefined') {\n this.gotoFrame(frame);\n this._time = 0;\n } else if (this._time < 0) {\n this._time = 0;\n }\n\n this.touch();\n return this;\n};\n\nAnim.prototype.stop = function(frame) {\n this._time = -1;\n if (typeof frame !== 'undefined') {\n this.gotoFrame(frame);\n }\n return this;\n};\n\n},{\"./core\":60,\"./loop\":66,\"./pin\":68,\"./util/create\":74,\"./util/math\":78}],58:[function(require,module,exports){\nif (typeof DEBUG === 'undefined')\n DEBUG = true;\n\nvar Class = require('./core');\nvar Texture = require('./texture');\n\nvar extend = require('./util/extend');\nvar create = require('./util/create');\nvar is = require('./util/is');\n\nvar string = require('./util/string');\n\n// name : atlas\nvar _atlases_map = {};\n// [atlas]\nvar _atlases_arr = [];\n\n// TODO: print subquery not found error\n// TODO: index textures\n\nClass.atlas = function(def) {\n var atlas = is.fn(def.draw) ? def : new Atlas(def);\n if (def.name) {\n _atlases_map[def.name] = atlas;\n }\n _atlases_arr.push(atlas);\n\n deprecated(def, 'imagePath');\n deprecated(def, 'imageRatio');\n\n var url = def.imagePath;\n var ratio = def.imageRatio || 1;\n if (is.string(def.image)) {\n url = def.image;\n } else if (is.hash(def.image)) {\n url = def.image.src || def.image.url;\n ratio = def.image.ratio || ratio;\n }\n url && Class.preload(function(done) {\n url = Class.resolve(url);\n DEBUG && console.log('Loading atlas: ' + url);\n var imageloader = Class.config('image-loader');\n\n imageloader(url, function(image) {\n DEBUG && console.log('Image loaded: ' + url);\n atlas.src(image, ratio);\n done();\n\n }, function(err) {\n DEBUG && console.log('Error loading atlas: ' + url, err);\n done();\n });\n });\n\n return atlas;\n};\n\nAtlas._super = Texture;\nAtlas.prototype = create(Atlas._super.prototype);\n\nfunction Atlas(def) {\n Atlas._super.call(this);\n\n var atlas = this;\n\n deprecated(def, 'filter');\n deprecated(def, 'cutouts');\n deprecated(def, 'sprites');\n deprecated(def, 'factory');\n\n var map = def.map || def.filter;\n var ppu = def.ppu || def.ratio || 1;\n var trim = def.trim || 0;\n var textures = def.textures;\n var factory = def.factory;\n var cutouts = def.cutouts || def.sprites;\n\n function make(def) {\n if (!def || is.fn(def.draw)) {\n return def;\n }\n\n def = extend({}, def);\n\n if (is.fn(map)) {\n def = map(def);\n }\n\n if (ppu != 1) {\n def.x *= ppu, def.y *= ppu;\n def.width *= ppu, def.height *= ppu;\n def.top *= ppu, def.bottom *= ppu;\n def.left *= ppu, def.right *= ppu;\n }\n\n if (trim != 0) {\n def.x += trim, def.y += trim;\n def.width -= 2 * trim, def.height -= 2 * trim;\n def.top -= trim, def.bottom -= trim;\n def.left -= trim, def.right -= trim;\n }\n\n var texture = atlas.pipe();\n texture.top = def.top, texture.bottom = def.bottom;\n texture.left = def.left, texture.right = def.right;\n texture.src(def.x, def.y, def.width, def.height);\n return texture;\n }\n\n function find(query) {\n if (textures) {\n if (is.fn(textures)) {\n return textures(query);\n } else if (is.hash(textures)) {\n return textures[query];\n }\n }\n if (cutouts) { // deprecated\n var result = null, n = 0;\n for (var i = 0; i < cutouts.length; i++) {\n if (string.startsWith(cutouts[i].name, query)) {\n if (n === 0) {\n result = cutouts[i];\n } else if (n === 1) {\n result = [ result, cutouts[i] ];\n } else {\n result.push(cutouts[i]);\n }\n n++;\n }\n }\n if (n === 0 && is.fn(factory)) {\n result = function(subquery) {\n return factory(query + (subquery ? subquery : ''));\n };\n }\n return result;\n }\n }\n\n this.select = function(query) {\n if (!query) {\n // TODO: if `textures` is texture def, map or fn?\n return new Selection(this.pipe());\n }\n var found = find(query);\n if (found) {\n return new Selection(found, find, make);\n }\n };\n\n};\n\nvar nfTexture = new Texture();\nnfTexture.x = nfTexture.y = nfTexture.width = nfTexture.height = 0;\nnfTexture.pipe = nfTexture.src = nfTexture.dest = function() {\n return this;\n};\nnfTexture.draw = function() {\n};\n\nvar nfSelection = new Selection(nfTexture);\n\nfunction Selection(result, find, make) {\n function link(result, subquery) {\n if (!result) {\n return nfTexture;\n\n } else if (is.fn(result.draw)) {\n return result;\n\n } else if (is.hash(result) && is.number(result.width)\n && is.number(result.height) && is.fn(make)) {\n return make(result);\n\n } else if (is.hash(result) && is.defined(subquery)) {\n return link(result[subquery]);\n\n } else if (is.fn(result)) {\n return link(result(subquery));\n\n } else if (is.array(result)) {\n return link(result[0]);\n\n } else if (is.string(result) && is.fn(find)) {\n return link(find(result));\n }\n }\n\n this.one = function(subquery) {\n return link(result, subquery);\n };\n\n this.array = function(arr) {\n var array = is.array(arr) ? arr : [];\n if (is.array(result)) {\n for (var i = 0; i < result.length; i++) {\n array[i] = link(result[i]);\n }\n } else {\n array[0] = link(result);\n }\n return array;\n };\n}\n\nClass.texture = function(query) {\n if (!is.string(query)) {\n return new Selection(query);\n }\n\n var result = null, atlas, i;\n\n if ((i = query.indexOf(':')) > 0 && query.length > i + 1) {\n atlas = _atlases_map[query.slice(0, i)];\n result = atlas && atlas.select(query.slice(i + 1));\n }\n\n if (!result && (atlas = _atlases_map[query])) {\n result = atlas.select();\n }\n\n for (i = 0; !result && i < _atlases_arr.length; i++) {\n result = _atlases_arr[i].select(query);\n }\n\n if (!result) {\n console.error('Texture not found: ' + query);\n result = nfSelection;\n }\n\n return result;\n};\n\nfunction deprecated(hash, name, msg) {\n if (name in hash)\n console.log(msg ? msg.replace('%name', name) : '\\'' + name\n + '\\' field of texture atlas is deprecated.');\n};\n\nmodule.exports = Atlas;\n\n},{\"./core\":60,\"./texture\":71,\"./util/create\":74,\"./util/extend\":76,\"./util/is\":77,\"./util/string\":81}],59:[function(require,module,exports){\nvar Class = require('./core');\nvar Texture = require('./texture');\n\nClass.canvas = function(type, attributes, callback) {\n if (typeof type === 'string') {\n if (typeof attributes === 'object') {\n } else {\n if (typeof attributes === 'function') {\n callback = attributes;\n }\n attributes = {};\n }\n } else {\n if (typeof type === 'function') {\n callback = type;\n }\n attributes = {};\n type = '2d';\n }\n\n var canvas = document.createElement('canvas');\n var context = canvas.getContext(type, attributes);\n var texture = new Texture(canvas);\n\n texture.context = function() {\n return context;\n };\n\n texture.size = function(width, height, ratio) {\n ratio = ratio || 1;\n canvas.width = width * ratio;\n canvas.height = height * ratio;\n this.src(canvas, ratio);\n return this;\n };\n\n texture.canvas = function(fn) {\n if (typeof fn === 'function') {\n fn.call(this, context);\n } else if (typeof fn === 'undefined' && typeof callback === 'function') {\n callback.call(this, context);\n }\n return this;\n };\n\n if (typeof callback === 'function') {\n callback.call(texture, context);\n }\n\n return texture;\n};\n},{\"./core\":60,\"./texture\":71}],60:[function(require,module,exports){\nif (typeof DEBUG === 'undefined')\n DEBUG = true;\n\nvar stats = require('./util/stats');\nvar extend = require('./util/extend');\nvar is = require('./util/is');\nvar _await = require('./util/await');\n\nstats.create = 0;\n\nfunction Class(arg) {\n if (!(this instanceof Class)) {\n if (is.fn(arg)) {\n return Class.app.apply(Class, arguments);\n } else if (is.object(arg)) {\n return Class.atlas.apply(Class, arguments);\n } else {\n return arg;\n }\n }\n\n stats.create++;\n\n for (var i = 0; i < _init.length; i++) {\n _init[i].call(this);\n }\n}\n\nvar _init = [];\n\nClass._init = function(fn) {\n _init.push(fn);\n};\n\nvar _load = [];\n\nClass._load = function(fn) {\n _load.push(fn);\n};\n\nvar _config = {};\n\nClass.config = function() {\n if (arguments.length === 1 && is.string(arguments[0])) {\n return _config[arguments[0]];\n }\n if (arguments.length === 1 && is.object(arguments[0])) {\n extend(_config, arguments[0]);\n }\n if (arguments.length === 2 && is.string(arguments[0])) {\n _config[arguments[0], arguments[1]];\n }\n};\n\nvar _app_queue = [];\nvar _preload_queue = [];\nvar _stages = [];\nvar _loaded = false;\nvar _paused = false;\n\nClass.app = function(app, opts) {\n if (!_loaded) {\n _app_queue.push(arguments);\n return;\n }\n DEBUG && console.log('Creating app...');\n var loader = Class.config('app-loader');\n loader(function(stage, canvas) {\n DEBUG && console.log('Initing app...');\n for (var i = 0; i < _load.length; i++) {\n _load[i].call(this, stage, canvas);\n }\n app(stage, canvas);\n _stages.push(stage);\n DEBUG && console.log('Starting app...');\n stage.start();\n }, opts);\n};\n\nvar loading = _await();\n\nClass.preload = function(load) {\n if (typeof load === 'string') {\n var url = Class.resolve(load);\n if (/\\.js($|\\?|\\#)/.test(url)) {\n DEBUG && console.log('Loading script: ' + url);\n load = function(callback) {\n loadScript(url, callback);\n };\n }\n }\n if (typeof load !== 'function') {\n return;\n }\n // if (!_started) {\n // _preload_queue.push(load);\n // return;\n // }\n load(loading());\n};\n\nClass.start = function(config) {\n DEBUG && console.log('Starting...');\n\n Class.config(config);\n\n // DEBUG && console.log('Preloading...');\n // _started = true;\n // while (_preload_queue.length) {\n // var load = _preload_queue.shift();\n // load(loading());\n // }\n\n loading.then(function() {\n DEBUG && console.log('Loading apps...');\n _loaded = true;\n while (_app_queue.length) {\n var args = _app_queue.shift();\n Class.app.apply(Class, args);\n }\n });\n};\n\nClass.pause = function() {\n if (!_paused) {\n _paused = true;\n for (var i = _stages.length - 1; i >= 0; i--) {\n _stages[i].pause();\n }\n }\n};\n\nClass.resume = function() {\n if (_paused) {\n _paused = false;\n for (var i = _stages.length - 1; i >= 0; i--) {\n _stages[i].resume();\n }\n }\n};\n\nClass.create = function() {\n return new Class();\n};\n\nClass.resolve = (function() {\n\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return function(url) {\n return url;\n };\n }\n\n var scripts = document.getElementsByTagName('script');\n\n function getScriptSrc() {\n // HTML5\n if (document.currentScript) {\n return document.currentScript.src;\n }\n\n // IE>=10\n var stack;\n try {\n var err = new Error();\n if (err.stack) {\n stack = err.stack;\n } else {\n throw err;\n }\n } catch (err) {\n stack = err.stack;\n }\n if (typeof stack === 'string') {\n stack = stack.split('\\n');\n // Uses the last line, where the call started\n for (var i = stack.length; i--;) {\n var url = stack[i].match(/(\\w+\\:\\/\\/[^/]*?\\/.+?)(:\\d+)(:\\d+)?/);\n if (url) {\n return url[1];\n }\n }\n }\n\n // IE<11\n if (scripts.length && 'readyState' in scripts[0]) {\n for (var i = scripts.length; i--;) {\n if (scripts[i].readyState === 'interactive') {\n return scripts[i].src;\n }\n }\n }\n\n return location.href;\n }\n\n return function(url) {\n if (/^\\.\\//.test(url)) {\n var src = getScriptSrc();\n var base = src.substring(0, src.lastIndexOf('/') + 1);\n url = base + url.substring(2);\n // } else if (/^\\.\\.\\//.test(url)) {\n // url = base + url;\n }\n return url;\n };\n})();\n\nmodule.exports = Class;\n\nfunction loadScript(src, callback) {\n var el = document.createElement('script');\n el.addEventListener('load', function() {\n callback();\n });\n el.addEventListener('error', function(err) {\n callback(err || 'Error loading script: ' + src);\n });\n el.src = src;\n el.id = 'preload-' + Date.now();\n document.body.appendChild(el);\n};\n},{\"./util/await\":73,\"./util/extend\":76,\"./util/is\":77,\"./util/stats\":80}],61:[function(require,module,exports){\nrequire('./util/event')(require('./core').prototype, function(obj, name, on) {\n obj._flag(name, on);\n});\n\n},{\"./core\":60,\"./util/event\":75}],62:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nrequire('./loop');\n\nvar repeat = require('./util/repeat');\nvar create = require('./util/create');\n\nClass.image = function(image) {\n var img = new Image();\n image && img.image(image);\n return img;\n};\n\nImage._super = Class;\nImage.prototype = create(Image._super.prototype);\n\nfunction Image() {\n Image._super.call(this);\n this.label('Image');\n this._textures = [];\n this._image = null;\n};\n\n/**\n * @deprecated Use image\n */\nImage.prototype.setImage = function(a, b, c) {\n return this.image(a, b, c);\n};\n\nImage.prototype.image = function(image) {\n this._image = Class.texture(image).one();\n this.pin('width', this._image ? this._image.width : 0);\n this.pin('height', this._image ? this._image.height : 0);\n this._textures[0] = this._image.pipe();\n this._textures.length = 1;\n return this;\n};\n\nImage.prototype.tile = function(inner) {\n this._repeat(false, inner);\n return this;\n};\n\nImage.prototype.stretch = function(inner) {\n this._repeat(true, inner);\n return this;\n};\n\nImage.prototype._repeat = function(stretch, inner) {\n var self = this;\n this.untick(this._repeatTicker);\n this.tick(this._repeatTicker = function() {\n if (this._mo_stretch == this._pin._ts_transform) {\n return;\n }\n this._mo_stretch = this._pin._ts_transform;\n var width = this.pin('width');\n var height = this.pin('height');\n this._textures.length = repeat(this._image, width, height, stretch, inner,\n insert);\n });\n\n function insert(i, sx, sy, sw, sh, dx, dy, dw, dh) {\n var repeat = self._textures.length > i ? self._textures[i]\n : self._textures[i] = self._image.pipe();\n repeat.src(sx, sy, sw, sh);\n repeat.dest(dx, dy, dw, dh);\n }\n};\n\n},{\"./core\":60,\"./loop\":66,\"./pin\":68,\"./util/create\":74,\"./util/repeat\":79}],63:[function(require,module,exports){\nmodule.exports = require('./core');\nmodule.exports.Matrix = require('./matrix');\nmodule.exports.Texture = require('./texture');\nrequire('./atlas');\nrequire('./tree');\nrequire('./event');\nrequire('./pin');\n\nrequire('./loop');\nrequire('./root');\n},{\"./atlas\":58,\"./core\":60,\"./event\":61,\"./loop\":66,\"./matrix\":67,\"./pin\":68,\"./root\":69,\"./texture\":71,\"./tree\":72}],64:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nrequire('./loop');\n\nvar create = require('./util/create');\n\nClass.row = function(align) {\n return Class.create().row(align).label('Row');\n};\n\nClass.prototype.row = function(align) {\n this.sequence('row', align);\n return this;\n};\n\nClass.column = function(align) {\n return Class.create().column(align).label('Row');\n};\n\nClass.prototype.column = function(align) {\n this.sequence('column', align);\n return this;\n};\n\nClass.sequence = function(type, align) {\n return Class.create().sequence(type, align).label('Sequence');\n};\n\nClass.prototype.sequence = function(type, align) {\n\n this._padding = this._padding || 0;\n this._spacing = this._spacing || 0;\n\n this.untick(this._layoutTiker);\n this.tick(this._layoutTiker = function() {\n if (this._mo_seq == this._ts_touch) {\n return;\n }\n this._mo_seq = this._ts_touch;\n\n var alignChildren = (this._mo_seqAlign != this._ts_children);\n this._mo_seqAlign = this._ts_children;\n\n var width = 0, height = 0;\n\n var child, next = this.first(true);\n var first = true;\n while (child = next) {\n next = child.next(true);\n\n child.matrix(true);\n var w = child.pin('boxWidth');\n var h = child.pin('boxHeight');\n\n if (type == 'column') {\n !first && (height += this._spacing);\n child.pin('offsetY') != height && child.pin('offsetY', height);\n width = Math.max(width, w);\n height = height + h;\n alignChildren && child.pin('alignX', align);\n\n } else if (type == 'row') {\n !first && (width += this._spacing);\n child.pin('offsetX') != width && child.pin('offsetX', width);\n width = width + w;\n height = Math.max(height, h);\n alignChildren && child.pin('alignY', align);\n }\n first = false;\n }\n width += 2 * this._padding;\n height += 2 * this._padding;\n this.pin('width') != width && this.pin('width', width);\n this.pin('height') != height && this.pin('height', height);\n });\n return this;\n};\n\nClass.box = function() {\n return Class.create().box().label('Box');\n};\n\nClass.prototype.box = function() {\n this._padding = this._padding || 0;\n\n this.untick(this._layoutTiker);\n this.tick(this._layoutTiker = function() {\n if (this._mo_box == this._ts_touch) {\n return;\n }\n this._mo_box = this._ts_touch;\n\n var width = 0, height = 0;\n var child, next = this.first(true);\n while (child = next) {\n next = child.next(true);\n child.matrix(true);\n var w = child.pin('boxWidth');\n var h = child.pin('boxHeight');\n width = Math.max(width, w);\n height = Math.max(height, h);\n }\n width += 2 * this._padding;\n height += 2 * this._padding;\n this.pin('width') != width && this.pin('width', width);\n this.pin('height') != height && this.pin('height', height);\n });\n return this;\n};\n\nClass.layer = function() {\n return Class.create().layer().label('Layer');\n};\n\nClass.prototype.layer = function() {\n\n this.untick(this._layoutTiker);\n this.tick(this._layoutTiker = function() {\n var parent = this.parent();\n if (parent) {\n var width = parent.pin('width');\n if (this.pin('width') != width) {\n this.pin('width', width);\n }\n var height = parent.pin('height');\n if (this.pin('height') != height) {\n this.pin('height', height);\n }\n }\n }, true);\n return this;\n};\n\n// TODO: move padding to pin\nClass.prototype.padding = function(pad) {\n this._padding = pad;\n return this;\n};\n\nClass.prototype.spacing = function(space) {\n this._spacing = space;\n return this;\n};\n\n},{\"./core\":60,\"./loop\":66,\"./pin\":68,\"./util/create\":74}],65:[function(require,module,exports){\n/**\n * Default loader for web.\n */\n\nif (typeof DEBUG === 'undefined')\n DEBUG = true;\n\nvar Class = require('../core');\n\nClass._supported = (function() {\n var elem = document.createElement('canvas');\n return (elem.getContext && elem.getContext('2d')) ? true : false;\n})();\n\nwindow.addEventListener('load', function() {\n DEBUG && console.log('On load.');\n if (Class._supported) {\n Class.start();\n }\n // TODO if not supported\n}, false);\n\nClass.config({\n 'app-loader' : AppLoader,\n 'image-loader' : ImageLoader\n});\n\nfunction AppLoader(app, configs) {\n configs = configs || {};\n var canvas = configs.canvas, context = null, full = false;\n var width = 0, height = 0, ratio = 1;\n\n if (typeof canvas === 'string') {\n canvas = document.getElementById(canvas);\n }\n\n if (!canvas) {\n canvas = document.getElementById('cutjs')\n || document.getElementById('stage');\n }\n\n if (!canvas) {\n full = true;\n DEBUG && console.log('Creating Canvas...');\n canvas = document.createElement('canvas');\n canvas.style.position = 'absolute';\n canvas.style.top = '0';\n canvas.style.left = '0';\n\n var body = document.body;\n body.insertBefore(canvas, body.firstChild);\n }\n\n context = canvas.getContext('2d');\n\n var devicePixelRatio = window.devicePixelRatio || 1;\n var backingStoreRatio = context.webkitBackingStorePixelRatio\n || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio\n || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;\n ratio = devicePixelRatio / backingStoreRatio;\n\n var requestAnimationFrame = window.requestAnimationFrame\n || window.msRequestAnimationFrame || window.mozRequestAnimationFrame\n || window.webkitRequestAnimationFrame || window.oRequestAnimationFrame\n || function(callback) {\n return window.setTimeout(callback, 1000 / 60);\n };\n\n DEBUG && console.log('Creating stage...');\n var root = Class.root(requestAnimationFrame, render);\n\n function render() {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, width, height);\n root.render(context);\n }\n\n root.background = function(color) {\n canvas.style.backgroundColor = color;\n return this;\n };\n\n app(root, canvas);\n\n resize();\n window.addEventListener('resize', resize, false);\n window.addEventListener('orientationchange', resize, false);\n\n function resize() {\n\n if (full) {\n // screen.availWidth/Height?\n width = (window.innerWidth > 0 ? window.innerWidth : screen.width);\n height = (window.innerHeight > 0 ? window.innerHeight : screen.height);\n\n canvas.style.width = width + 'px';\n canvas.style.height = height + 'px';\n\n } else {\n width = canvas.clientWidth;\n height = canvas.clientHeight;\n }\n\n width *= ratio;\n height *= ratio;\n\n if (canvas.width === width && canvas.height === height) {\n return;\n }\n\n canvas.width = width;\n canvas.height = height;\n\n DEBUG && console.log('Resize: ' + width + ' x ' + height + ' / ' + ratio);\n\n root.viewport(width, height, ratio);\n\n render();\n }\n}\n\nfunction ImageLoader(src, success, error) {\n DEBUG && console.log('Loading image: ' + src);\n var image = new Image();\n image.onload = function() {\n success(image);\n };\n image.onerror = error;\n image.src = src;\n}\n\n},{\"../core\":60}],66:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nvar stats = require('./util/stats');\n\nClass.prototype._textures = null;\nClass.prototype._alpha = 1;\n\nClass.prototype.render = function(context) {\n if (!this._visible) {\n return;\n }\n stats.node++;\n\n var m = this.matrix();\n context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);\n\n // move this elsewhere!\n this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);\n var alpha = this._pin._textureAlpha * this._alpha;\n\n if (context.globalAlpha != alpha) {\n context.globalAlpha = alpha;\n }\n\n if (this._textures !== null) {\n for (var i = 0, n = this._textures.length; i < n; i++) {\n this._textures[i].draw(context);\n }\n }\n\n if (context.globalAlpha != this._alpha) {\n context.globalAlpha = this._alpha;\n }\n\n var child, next = this._first;\n while (child = next) {\n next = child._next;\n child.render(context);\n }\n};\n\nClass.prototype._tickBefore = null;\nClass.prototype._tickAfter = null;\nClass.prototype.MAX_ELAPSE = Infinity;\n\nClass.prototype._tick = function(elapsed, now, last) {\n if (!this._visible) {\n return;\n }\n\n if (elapsed > this.MAX_ELAPSE) {\n elapsed = this.MAX_ELAPSE;\n }\n\n var ticked = false;\n\n if (this._tickBefore !== null) {\n for (var i = 0, n = this._tickBefore.length; i < n; i++) {\n stats.tick++;\n ticked = this._tickBefore[i].call(this, elapsed, now, last) === true\n || ticked;\n }\n }\n\n var child, next = this._first;\n while (child = next) {\n next = child._next;\n if (child._flag('_tick')) {\n ticked = child._tick(elapsed, now, last) === true ? true : ticked;\n }\n }\n\n if (this._tickAfter !== null) {\n for (var i = 0, n = this._tickAfter.length; i < n; i++) {\n stats.tick++;\n ticked = this._tickAfter[i].call(this, elapsed, now, last) === true\n || ticked;\n }\n }\n\n return ticked;\n};\n\nClass.prototype.tick = function(ticker, before) {\n if (typeof ticker !== 'function') {\n return;\n }\n if (before) {\n if (this._tickBefore === null) {\n this._tickBefore = [];\n }\n this._tickBefore.push(ticker);\n } else {\n if (this._tickAfter === null) {\n this._tickAfter = [];\n }\n this._tickAfter.push(ticker);\n }\n this._flag('_tick', this._tickAfter !== null && this._tickAfter.length > 0\n || this._tickBefore !== null && this._tickBefore.length > 0);\n};\n\nClass.prototype.untick = function(ticker) {\n if (typeof ticker !== 'function') {\n return;\n }\n var i;\n if (this._tickBefore !== null && (i = this._tickBefore.indexOf(ticker)) >= 0) {\n this._tickBefore.splice(i, 1);\n }\n if (this._tickAfter !== null && (i = this._tickAfter.indexOf(ticker)) >= 0) {\n this._tickAfter.splice(i, 1);\n }\n};\n\nClass.prototype.timeout = function(fn, time) {\n this.tick(function timer(t) {\n if ((time -= t) < 0) {\n this.untick(timer);\n fn.call(this);\n } else {\n return true;\n }\n });\n};\n\n},{\"./core\":60,\"./pin\":68,\"./util/stats\":80}],67:[function(require,module,exports){\nfunction Matrix(a, b, c, d, e, f) {\n this.reset(a, b, c, d, e, f);\n};\n\nMatrix.prototype.toString = function() {\n return '[' + this.a + ', ' + this.b + ', ' + this.c + ', ' + this.d + ', '\n + this.e + ', ' + this.f + ']';\n};\n\nMatrix.prototype.clone = function() {\n return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);\n};\n\nMatrix.prototype.reset = function(a, b, c, d, e, f) {\n this._dirty = true;\n if (typeof a === 'object') {\n this.a = a.a, this.d = a.d;\n this.b = a.b, this.c = a.c;\n this.e = a.e, this.f = a.f;\n } else {\n this.a = a || 1, this.d = d || 1;\n this.b = b || 0, this.c = c || 0;\n this.e = e || 0, this.f = f || 0;\n }\n return this;\n};\n\nMatrix.prototype.identity = function() {\n this._dirty = true;\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n return this;\n};\n\nMatrix.prototype.rotate = function(angle) {\n if (!angle) {\n return this;\n }\n\n this._dirty = true;\n\n var u = angle ? Math.cos(angle) : 1;\n // android bug may give bad 0 values\n var v = angle ? Math.sin(angle) : 0;\n\n var a = u * this.a - v * this.b;\n var b = u * this.b + v * this.a;\n var c = u * this.c - v * this.d;\n var d = u * this.d + v * this.c;\n var e = u * this.e - v * this.f;\n var f = u * this.f + v * this.e;\n\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n\n return this;\n};\n\nMatrix.prototype.translate = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n this.e += x;\n this.f += y;\n return this;\n};\n\nMatrix.prototype.scale = function(x, y) {\n if (!(x - 1) && !(y - 1)) {\n return this;\n }\n this._dirty = true;\n this.a *= x;\n this.b *= y;\n this.c *= x;\n this.d *= y;\n this.e *= x;\n this.f *= y;\n return this;\n};\n\nMatrix.prototype.skew = function(x, y) {\n if (!x && !y) {\n return this;\n }\n this._dirty = true;\n\n var a = this.a + this.b * x;\n var b = this.b + this.a * y;\n var c = this.c + this.d * x;\n var d = this.d + this.c * y;\n var e = this.e + this.f * x;\n var f = this.f + this.e * y;\n\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n return this;\n};\n\nMatrix.prototype.concat = function(m) {\n this._dirty = true;\n\n var n = this;\n\n var a = n.a * m.a + n.b * m.c;\n var b = n.b * m.d + n.a * m.b;\n var c = n.c * m.a + n.d * m.c;\n var d = n.d * m.d + n.c * m.b;\n var e = n.e * m.a + m.e + n.f * m.c;\n var f = n.f * m.d + m.f + n.e * m.b;\n\n this.a = a;\n this.b = b;\n this.c = c;\n this.d = d;\n this.e = e;\n this.f = f;\n\n return this;\n};\n\nMatrix.prototype.inverse = Matrix.prototype.reverse = function() {\n if (this._dirty) {\n this._dirty = false;\n this.inversed = this.inversed || new Matrix();\n var z = this.a * this.d - this.b * this.c;\n this.inversed.a = this.d / z;\n this.inversed.b = -this.b / z;\n this.inversed.c = -this.c / z;\n this.inversed.d = this.a / z;\n this.inversed.e = (this.c * this.f - this.e * this.d) / z;\n this.inversed.f = (this.e * this.b - this.a * this.f) / z;\n }\n return this.inversed;\n};\n\nMatrix.prototype.map = function(p, q) {\n q = q || {};\n q.x = this.a * p.x + this.c * p.y + this.e;\n q.y = this.b * p.x + this.d * p.y + this.f;\n return q;\n};\n\nMatrix.prototype.mapX = function(x, y) {\n if (typeof x === 'object')\n y = x.y, x = x.x;\n return this.a * x + this.c * y + this.e;\n};\n\nMatrix.prototype.mapY = function(x, y) {\n if (typeof x === 'object')\n y = x.y, x = x.x;\n return this.b * x + this.d * y + this.f;\n};\n\nmodule.exports = Matrix;\n\n},{}],68:[function(require,module,exports){\nvar Class = require('./core');\nvar Matrix = require('./matrix');\n\nvar iid = 0;\n\nClass._init(function() {\n this._pin = new Pin(this);\n});\n\nClass.prototype.matrix = function(relative) {\n if (relative === true) {\n return this._pin.relativeMatrix();\n }\n return this._pin.absoluteMatrix();\n};\n\nClass.prototype.pin = function(a, b) {\n if (typeof a === 'object') {\n this._pin.set(a);\n return this;\n\n } else if (typeof a === 'string') {\n if (typeof b === 'undefined') {\n return this._pin.get(a);\n } else {\n this._pin.set(a, b);\n return this;\n }\n } else if (typeof a === 'undefined') {\n return this._pin;\n }\n};\n\nfunction Pin(owner) {\n\n this._owner = owner;\n this._parent = null;\n\n // relative to parent\n this._relativeMatrix = new Matrix();\n\n // relative to stage\n this._absoluteMatrix = new Matrix();\n\n this.reset();\n};\n\nPin.prototype.reset = function() {\n\n this._textureAlpha = 1;\n this._alpha = 1;\n\n this._width = 0;\n this._height = 0;\n\n this._scaleX = 1;\n this._scaleY = 1;\n this._skewX = 0;\n this._skewY = 0;\n this._rotation = 0;\n\n // scale/skew/rotate center\n this._pivoted = false;\n this._pivotX = null;\n this._pivotY = null;\n\n // self pin point\n this._handled = false;\n this._handleX = 0;\n this._handleY = 0;\n\n // parent pin point\n this._aligned = false;\n this._alignX = 0;\n this._alignY = 0;\n\n // as seen by parent px\n this._offsetX = 0;\n this._offsetY = 0;\n\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n\n // TODO: also set for owner\n this._ts_translate = ++iid;\n this._ts_transform = ++iid;\n this._ts_matrix = ++iid;\n};\n\nPin.prototype._update = function() {\n this._parent = this._owner._parent && this._owner._parent._pin;\n\n // if handled and transformed then be translated\n if (this._handled && this._mo_handle != this._ts_transform) {\n this._mo_handle = this._ts_transform;\n this._ts_translate = ++iid;\n }\n\n if (this._aligned && this._parent\n && this._mo_align != this._parent._ts_transform) {\n this._mo_align = this._parent._ts_transform;\n this._ts_translate = ++iid;\n }\n\n return this;\n};\n\nPin.prototype.toString = function() {\n return this._owner + ' (' + (this._parent ? this._parent._owner : null) + ')';\n};\n\n// TODO: ts fields require refactoring\n\nPin.prototype.absoluteMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate,\n this._parent ? this._parent._ts_matrix : 0);\n if (this._mo_abs == ts) {\n return this._absoluteMatrix;\n }\n this._mo_abs = ts;\n\n var abs = this._absoluteMatrix;\n abs.reset(this.relativeMatrix());\n\n this._parent && abs.concat(this._parent._absoluteMatrix);\n\n this._ts_matrix = ++iid;\n\n return abs;\n};\n\nPin.prototype.relativeMatrix = function() {\n this._update();\n var ts = Math.max(this._ts_transform, this._ts_translate,\n this._parent ? this._parent._ts_transform : 0);\n if (this._mo_rel == ts) {\n return this._relativeMatrix;\n }\n this._mo_rel = ts;\n\n var rel = this._relativeMatrix;\n\n rel.identity();\n if (this._pivoted) {\n rel.translate(-this._pivotX * this._width, -this._pivotY * this._height);\n }\n rel.scale(this._scaleX, this._scaleY);\n rel.skew(this._skewX, this._skewY);\n rel.rotate(this._rotation);\n if (this._pivoted) {\n rel.translate(this._pivotX * this._width, this._pivotY * this._height);\n }\n\n // calculate effective box\n if (this._pivoted) {\n // origin\n this._boxX = 0;\n this._boxY = 0;\n this._boxWidth = this._width;\n this._boxHeight = this._height;\n\n } else {\n // aabb\n var p, q;\n if (rel.a > 0 && rel.c > 0 || rel.a < 0 && rel.c < 0) {\n p = 0, q = rel.a * this._width + rel.c * this._height;\n } else {\n p = rel.a * this._width, q = rel.c * this._height;\n }\n if (p > q) {\n this._boxX = q;\n this._boxWidth = p - q;\n } else {\n this._boxX = p;\n this._boxWidth = q - p;\n }\n if (rel.b > 0 && rel.d > 0 || rel.b < 0 && rel.d < 0) {\n p = 0, q = rel.b * this._width + rel.d * this._height;\n } else {\n p = rel.b * this._width, q = rel.d * this._height;\n }\n if (p > q) {\n this._boxY = q;\n this._boxHeight = p - q;\n } else {\n this._boxY = p;\n this._boxHeight = q - p;\n }\n }\n\n this._x = this._offsetX;\n this._y = this._offsetY;\n\n this._x -= this._boxX + this._handleX * this._boxWidth;\n this._y -= this._boxY + this._handleY * this._boxHeight;\n\n if (this._aligned && this._parent) {\n this._parent.relativeMatrix();\n this._x += this._alignX * this._parent._width;\n this._y += this._alignY * this._parent._height;\n }\n\n rel.translate(this._x, this._y);\n\n return this._relativeMatrix;\n};\n\nPin.prototype.get = function(key) {\n if (typeof getters[key] === 'function') {\n return getters[key](this);\n }\n};\n\n// TODO: Use defineProperty instead? What about multi-field pinning?\nPin.prototype.set = function(a, b) {\n if (typeof a === 'string') {\n if (typeof setters[a] === 'function' && typeof b !== 'undefined') {\n setters[a](this, b);\n }\n } else if (typeof a === 'object') {\n for (b in a) {\n if (typeof setters[b] === 'function' && typeof a[b] !== 'undefined') {\n setters[b](this, a[b], a);\n }\n }\n }\n if (this._owner) {\n this._owner._ts_pin = ++iid;\n this._owner.touch();\n }\n return this;\n};\n\nvar getters = {\n alpha : function(pin) {\n return pin._alpha;\n },\n\n textureAlpha : function(pin) {\n return pin._textureAlpha;\n },\n\n width : function(pin) {\n return pin._width;\n },\n\n height : function(pin) {\n return pin._height;\n },\n\n boxWidth : function(pin) {\n return pin._boxWidth;\n },\n\n boxHeight : function(pin) {\n return pin._boxHeight;\n },\n\n // scale : function(pin) {\n // },\n\n scaleX : function(pin) {\n return pin._scaleX;\n },\n\n scaleY : function(pin) {\n return pin._scaleY;\n },\n\n // skew : function(pin) {\n // },\n\n skewX : function(pin) {\n return pin._skewX;\n },\n\n skewY : function(pin) {\n return pin._skewY;\n },\n\n rotation : function(pin) {\n return pin._rotation;\n },\n\n // pivot : function(pin) {\n // },\n\n pivotX : function(pin) {\n return pin._pivotX;\n },\n\n pivotY : function(pin) {\n return pin._pivotY;\n },\n\n // offset : function(pin) {\n // },\n\n offsetX : function(pin) {\n return pin._offsetX;\n },\n\n offsetY : function(pin) {\n return pin._offsetY;\n },\n\n // align : function(pin) {\n // },\n\n alignX : function(pin) {\n return pin._alignX;\n },\n\n alignY : function(pin) {\n return pin._alignY;\n },\n\n // handle : function(pin) {\n // },\n\n handleX : function(pin) {\n return pin._handleX;\n },\n\n handleY : function(pin) {\n return pin._handleY;\n }\n};\n\nvar setters = {\n alpha : function(pin, value) {\n pin._alpha = value;\n },\n\n textureAlpha : function(pin, value) {\n pin._textureAlpha = value;\n },\n\n width : function(pin, value) {\n pin._width_ = value;\n pin._width = value;\n pin._ts_transform = ++iid;\n },\n\n height : function(pin, value) {\n pin._height_ = value;\n pin._height = value;\n pin._ts_transform = ++iid;\n },\n\n scale : function(pin, value) {\n pin._scaleX = value;\n pin._scaleY = value;\n pin._ts_transform = ++iid;\n },\n\n scaleX : function(pin, value) {\n pin._scaleX = value;\n pin._ts_transform = ++iid;\n },\n\n scaleY : function(pin, value) {\n pin._scaleY = value;\n pin._ts_transform = ++iid;\n },\n\n skew : function(pin, value) {\n pin._skewX = value;\n pin._skewY = value;\n pin._ts_transform = ++iid;\n },\n\n skewX : function(pin, value) {\n pin._skewX = value;\n pin._ts_transform = ++iid;\n },\n\n skewY : function(pin, value) {\n pin._skewY = value;\n pin._ts_transform = ++iid;\n },\n\n rotation : function(pin, value) {\n pin._rotation = value;\n pin._ts_transform = ++iid;\n },\n\n pivot : function(pin, value) {\n pin._pivotX = value;\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid;\n },\n\n pivotX : function(pin, value) {\n pin._pivotX = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid;\n },\n\n pivotY : function(pin, value) {\n pin._pivotY = value;\n pin._pivoted = true;\n pin._ts_transform = ++iid;\n },\n\n offset : function(pin, value) {\n pin._offsetX = value;\n pin._offsetY = value;\n pin._ts_translate = ++iid;\n },\n\n offsetX : function(pin, value) {\n pin._offsetX = value;\n pin._ts_translate = ++iid;\n },\n\n offsetY : function(pin, value) {\n pin._offsetY = value;\n pin._ts_translate = ++iid;\n },\n\n align : function(pin, value) {\n this.alignX(pin, value);\n this.alignY(pin, value);\n },\n\n alignX : function(pin, value) {\n pin._alignX = value;\n pin._aligned = true;\n pin._ts_translate = ++iid;\n\n this.handleX(pin, value);\n },\n\n alignY : function(pin, value) {\n pin._alignY = value;\n pin._aligned = true;\n pin._ts_translate = ++iid;\n\n this.handleY(pin, value);\n },\n\n handle : function(pin, value) {\n this.handleX(pin, value);\n this.handleY(pin, value);\n },\n\n handleX : function(pin, value) {\n pin._handleX = value;\n pin._handled = true;\n pin._ts_translate = ++iid;\n },\n\n handleY : function(pin, value) {\n pin._handleY = value;\n pin._handled = true;\n pin._ts_translate = ++iid;\n },\n\n resizeMode : function(pin, value, all) {\n if (all) {\n if (value == 'in') {\n value = 'in-pad';\n } else if (value == 'out') {\n value = 'out-crop';\n }\n scaleTo(pin, all.resizeWidth, all.resizeHeight, value);\n }\n },\n\n resizeWidth : function(pin, value, all) {\n if (!all || !all.resizeMode) {\n scaleTo(pin, value, null);\n }\n },\n\n resizeHeight : function(pin, value, all) {\n if (!all || !all.resizeMode) {\n scaleTo(pin, null, value);\n }\n },\n\n scaleMode : function(pin, value, all) {\n if (all) {\n scaleTo(pin, all.scaleWidth, all.scaleHeight, value);\n }\n },\n\n scaleWidth : function(pin, value, all) {\n if (!all || !all.scaleMode) {\n scaleTo(pin, value, null);\n }\n },\n\n scaleHeight : function(pin, value, all) {\n if (!all || !all.scaleMode) {\n scaleTo(pin, null, value);\n }\n },\n\n matrix : function(pin, value) {\n this.scaleX(pin, value.a);\n this.skewX(pin, value.c / value.d);\n this.skewY(pin, value.b / value.a);\n this.scaleY(pin, value.d);\n this.offsetX(pin, value.e);\n this.offsetY(pin, value.f);\n this.rotation(pin, 0);\n }\n};\n\nfunction scaleTo(pin, width, height, mode) {\n var w = typeof width === 'number';\n var h = typeof height === 'number';\n var m = typeof mode === 'string';\n pin._ts_transform = ++iid;\n if (w) {\n pin._scaleX = width / pin._width_;\n pin._width = pin._width_;\n }\n if (h) {\n pin._scaleY = height / pin._height_;\n pin._height = pin._height_;\n }\n if (w && h && m) {\n if (mode == 'out' || mode == 'out-crop') {\n pin._scaleX = pin._scaleY = Math.max(pin._scaleX, pin._scaleY);\n } else if (mode == 'in' || mode == 'in-pad') {\n pin._scaleX = pin._scaleY = Math.min(pin._scaleX, pin._scaleY);\n }\n if (mode == 'out-crop' || mode == 'in-pad') {\n pin._width = width / pin._scaleX;\n pin._height = height / pin._scaleY;\n }\n }\n};\n\nClass.prototype.scaleTo = function(a, b, c) {\n if (typeof a === 'object')\n c = b, b = a.y, a = a.x;\n scaleTo(this._pin, a, b, c);\n return this;\n};\n\n// Used by Tween class\nPin._add_shortcuts = function(Class) {\n Class.prototype.size = function(w, h) {\n this.pin('width', w);\n this.pin('height', h);\n return this;\n };\n\n Class.prototype.width = function(w) {\n if (typeof w === 'undefined') {\n return this.pin('width');\n }\n this.pin('width', w);\n return this;\n };\n\n Class.prototype.height = function(h) {\n if (typeof h === 'undefined') {\n return this.pin('height');\n }\n this.pin('height', h);\n return this;\n };\n\n Class.prototype.offset = function(a, b) {\n if (typeof a === 'object')\n b = a.y, a = a.x;\n this.pin('offsetX', a);\n this.pin('offsetY', b);\n return this;\n };\n\n Class.prototype.rotate = function(a) {\n this.pin('rotation', a);\n return this;\n };\n\n Class.prototype.skew = function(a, b) {\n if (typeof a === 'object')\n b = a.y, a = a.x;\n else if (typeof b === 'undefined')\n b = a;\n this.pin('skewX', a);\n this.pin('skewY', b);\n return this;\n };\n\n Class.prototype.scale = function(a, b) {\n if (typeof a === 'object')\n b = a.y, a = a.x;\n else if (typeof b === 'undefined')\n b = a;\n this.pin('scaleX', a);\n this.pin('scaleY', b);\n return this;\n };\n\n Class.prototype.alpha = function(a, ta) {\n this.pin('alpha', a);\n if (typeof ta !== 'undefined') {\n this.pin('textureAlpha', ta);\n }\n return this;\n };\n};\n\nPin._add_shortcuts(Class);\n\nmodule.exports = Pin;\n\n},{\"./core\":60,\"./matrix\":67}],69:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nrequire('./loop');\n\nvar stats = require('./util/stats');\nvar create = require('./util/create');\nvar extend = require('./util/extend');\n\nRoot._super = Class;\nRoot.prototype = create(Root._super.prototype);\n\nClass.root = function(request, render) {\n return new Root(request, render);\n};\n\nfunction Root(request, render) {\n Root._super.call(this);\n this.label('Root');\n\n var paused = true;\n\n var self = this;\n var lastTime = 0;\n var loop = function(now) {\n if (paused === true) {\n return;\n }\n\n stats.tick = stats.node = stats.draw = 0;\n\n var last = lastTime || now;\n var elapsed = now - last;\n lastTime = now;\n\n var ticked = self._tick(elapsed, now, last);\n if (self._mo_touch != self._ts_touch) {\n self._mo_touch = self._ts_touch;\n render(self);\n request(loop);\n } else if (ticked) {\n request(loop);\n } else {\n paused = true;\n }\n\n stats.fps = elapsed ? 1000 / elapsed : 0;\n };\n\n this.start = function() {\n return this.resume();\n };\n\n this.resume = function() {\n if (paused) {\n this.publish('resume');\n paused = false;\n request(loop);\n }\n return this;\n };\n\n this.pause = function() {\n if (!paused) {\n this.publish('pause');\n }\n paused = true;\n return this;\n };\n\n this.touch_root = this.touch;\n this.touch = function() {\n this.resume();\n return this.touch_root();\n };\n};\n\nRoot.prototype.background = function(color) {\n // to be implemented by loaders\n return this;\n};\n\nRoot.prototype.viewport = function(width, height, ratio) {\n if (typeof width === 'undefined') {\n return extend({}, this._viewport);\n }\n this._viewport = {\n width : width,\n height : height,\n ratio : ratio || 1\n };\n this.viewbox();\n var data = extend({}, this._viewport);\n this.visit({\n start : function(node) {\n if (!node._flag('viewport')) {\n return true;\n }\n node.publish('viewport', [ data ]);\n }\n });\n return this;\n};\n\n// TODO: static/fixed viewbox\nRoot.prototype.viewbox = function(width, height, mode) {\n if (typeof width === 'number' && typeof height === 'number') {\n this._viewbox = {\n width : width,\n height : height,\n mode : /^(in|out|in-pad|out-crop)$/.test(mode) ? mode : 'in-pad'\n };\n }\n\n var box = this._viewbox;\n var size = this._viewport;\n if (size && box) {\n this.pin({\n width : box.width,\n height : box.height\n });\n this.scaleTo(size.width, size.height, box.mode);\n } else if (size) {\n this.pin({\n width : size.width,\n height : size.height\n });\n }\n\n return this;\n};\n\n},{\"./core\":60,\"./loop\":66,\"./pin\":68,\"./util/create\":74,\"./util/extend\":76,\"./util/stats\":80}],70:[function(require,module,exports){\nvar Class = require('./core');\nrequire('./pin');\nrequire('./loop');\n\nvar create = require('./util/create');\nvar is = require('./util/is');\n\nClass.string = function(frames) {\n return new Str().frames(frames);\n};\n\nStr._super = Class;\nStr.prototype = create(Str._super.prototype);\n\nfunction Str() {\n Str._super.call(this);\n this.label('String');\n this._textures = [];\n};\n\n/**\n * @deprecated Use frames\n */\nStr.prototype.setFont = function(a, b, c) {\n return this.frames(a, b, c);\n};\n\nStr.prototype.frames = function(frames) {\n this._textures = [];\n if (typeof frames == 'string') {\n frames = Class.texture(frames);\n this._item = function(value) {\n return frames.one(value);\n };\n } else if (typeof frames === 'object') {\n this._item = function(value) {\n return frames[value];\n };\n } else if (typeof frames === 'function') {\n this._item = frames;\n }\n return this;\n};\n\n/**\n * @deprecated Use value\n */\nStr.prototype.setValue = function(a, b, c) {\n return this.value(a, b, c);\n};\n\nStr.prototype.value = function(value) {\n if (typeof value === 'undefined') {\n return this._value;\n }\n if (this._value === value) {\n return this;\n }\n this._value = value;\n\n if (value === null) {\n value = '';\n } else if (typeof value !== 'string' && !is.array(value)) {\n value = value.toString();\n }\n\n this._spacing = this._spacing || 0;\n\n var width = 0, height = 0;\n for (var i = 0; i < value.length; i++) {\n var image = this._textures[i] = this._item(value[i]);\n width += i > 0 ? this._spacing : 0;\n image.dest(width, 0);\n width = width + image.width;\n height = Math.max(height, image.height);\n }\n this.pin('width', width);\n this.pin('height', height);\n this._textures.length = value.length;\n return this;\n};\n\n},{\"./core\":60,\"./loop\":66,\"./pin\":68,\"./util/create\":74,\"./util/is\":77}],71:[function(require,module,exports){\nvar stats = require('./util/stats');\nvar math = require('./util/math');\n\nfunction Texture(image, ratio) {\n if (typeof image === 'object') {\n this.src(image, ratio);\n }\n}\n\nTexture.prototype.pipe = function() {\n return new Texture(this);\n};\n\n/**\n * Signatures: (image), (x, y, w, h), (w, h)\n */\nTexture.prototype.src = function(x, y, w, h) {\n if (typeof x === 'object') {\n var image = x, ratio = y || 1;\n\n this._image = image;\n this._sx = this._dx = 0;\n this._sy = this._dy = 0;\n this._sw = this._dw = image.width / ratio;\n this._sh = this._dh = image.height / ratio;\n\n this.width = image.width / ratio;\n this.height = image.height / ratio;\n\n this.ratio = ratio;\n\n } else {\n if (typeof w === 'undefined') {\n w = x, h = y;\n } else {\n this._sx = x, this._sy = y;\n }\n this._sw = this._dw = w;\n this._sh = this._dh = h;\n\n this.width = w;\n this.height = h;\n }\n return this;\n};\n\n/**\n * Signatures: (x, y, w, h), (x, y)\n */\nTexture.prototype.dest = function(x, y, w, h) {\n this._dx = x, this._dy = y;\n this._dx = x, this._dy = y;\n if (typeof w !== 'undefined') {\n this._dw = w, this._dh = h;\n this.width = w, this.height = h;\n }\n return this;\n};\n\nTexture.prototype.draw = function(context, x1, y1, x2, y2, x3, y3, x4, y4) {\n var image = this._image;\n if (image === null || typeof image !== 'object') {\n return;\n }\n\n var sx = this._sx, sy = this._sy;\n var sw = this._sw, sh = this._sh;\n var dx = this._dx, dy = this._dy;\n var dw = this._dw, dh = this._dh;\n\n if (typeof x3 !== 'undefined') {\n x1 = math.limit(x1, 0, this._sw), x2 = math.limit(x2, 0, this._sw - x1);\n y1 = math.limit(y1, 0, this._sh), y2 = math.limit(y2, 0, this._sh - y1);\n sx += x1, sy += y1, sw = x2, sh = y2;\n dx = x3, dy = y3, dw = x4, dh = y4;\n\n } else if (typeof x2 !== 'undefined') {\n dx = x1, dy = y1, dw = x2, dh = y2;\n\n } else if (typeof x1 !== 'undefined') {\n dw = x1, dh = y1;\n }\n\n var ratio = this.ratio || 1;\n sx *= ratio, sy *= ratio, sw *= ratio, sh *= ratio;\n\n try {\n if (typeof image.draw === 'function') {\n image.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);\n } else {\n stats.draw++;\n context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);\n }\n } catch (ex) {\n if (!image._draw_failed) {\n console.log('Unable to draw: ', image);\n console.log(ex);\n image._draw_failed = true;\n }\n }\n};\n\nmodule.exports = Texture;\n\n},{\"./util/math\":78,\"./util/stats\":80}],72:[function(require,module,exports){\nvar Class = require('./core');\nvar is = require('./util/is');\n\nvar iid = 0;\n\n// TODO: do not clear next/prev/parent on remove\n\nClass.prototype._label = '';\n\nClass.prototype._visible = true;\n\nClass.prototype._parent = null;\nClass.prototype._next = null;\nClass.prototype._prev = null;\n\nClass.prototype._first = null;\nClass.prototype._last = null;\n\nClass.prototype._attrs = null;\nClass.prototype._flags = null;\n\nClass.prototype.toString = function() {\n return '[' + this._label + ']';\n};\n\n/**\n * @deprecated Use label()\n */\nClass.prototype.id = function(id) {\n return this.label(id);\n};\n\nClass.prototype.label = function(label) {\n if (typeof label === 'undefined') {\n return this._label;\n }\n this._label = label;\n return this;\n};\n\nClass.prototype.attr = function(name, value) {\n if (typeof value === 'undefined') {\n return this._attrs !== null ? this._attrs[name] : undefined;\n }\n (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;\n return this;\n};\n\nClass.prototype.visible = function(visible) {\n if (typeof visible === 'undefined') {\n return this._visible;\n }\n this._visible = visible;\n this._parent && (this._parent._ts_children = ++iid);\n this._ts_pin = ++iid;\n this.touch();\n return this;\n};\n\nClass.prototype.hide = function() {\n return this.visible(false);\n};\n\nClass.prototype.show = function() {\n return this.visible(true);\n};\n\nClass.prototype.parent = function() {\n return this._parent;\n};\n\nClass.prototype.next = function(visible) {\n var next = this._next;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n};\n\nClass.prototype.prev = function(visible) {\n var prev = this._prev;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n};\n\nClass.prototype.first = function(visible) {\n var next = this._first;\n while (next && visible && !next._visible) {\n next = next._next;\n }\n return next;\n};\n\nClass.prototype.last = function(visible) {\n var prev = this._last;\n while (prev && visible && !prev._visible) {\n prev = prev._prev;\n }\n return prev;\n};\n\nClass.prototype.visit = function(visitor, data) {\n var reverse = visitor.reverse;\n var visible = visitor.visible;\n if (visitor.start && visitor.start(this, data)) {\n return;\n }\n var child, next = reverse ? this.last(visible) : this.first(visible);\n while (child = next) {\n next = reverse ? child.prev(visible) : child.next(visible);\n if (child.visit(visitor, data)) {\n return true;\n }\n }\n return visitor.end && visitor.end(this, data);\n};\n\nClass.prototype.append = function(child, more) {\n if (is.array(child))\n for (var i = 0; i < child.length; i++)\n append(this, child[i]);\n\n else if (typeof more !== 'undefined') // deprecated\n for (var i = 0; i < arguments.length; i++)\n append(this, arguments[i]);\n\n else if (typeof child !== 'undefined')\n append(this, child);\n\n return this;\n};\n\nClass.prototype.prepend = function(child, more) {\n if (is.array(child))\n for (var i = child.length - 1; i >= 0; i--)\n prepend(this, child[i]);\n\n else if (typeof more !== 'undefined') // deprecated\n for (var i = arguments.length - 1; i >= 0; i--)\n prepend(this, arguments[i]);\n\n else if (typeof child !== 'undefined')\n prepend(this, child);\n\n return this;\n};\n\nClass.prototype.appendTo = function(parent) {\n append(parent, this);\n return this;\n};\n\nClass.prototype.prependTo = function(parent) {\n prepend(parent, this);\n return this;\n};\n\nClass.prototype.insertNext = function(sibling, more) {\n if (is.array(sibling))\n for (var i = 0; i < sibling.length; i++)\n insertAfter(sibling[i], this);\n\n else if (typeof more !== 'undefined') // deprecated\n for (var i = 0; i < arguments.length; i++)\n insertAfter(arguments[i], this);\n\n else if (typeof sibling !== 'undefined')\n insertAfter(sibling, this);\n\n return this;\n};\n\nClass.prototype.insertPrev = function(sibling, more) {\n if (is.array(sibling))\n for (var i = sibling.length - 1; i >= 0; i--)\n insertBefore(sibling[i], this);\n\n else if (typeof more !== 'undefined') // deprecated\n for (var i = arguments.length - 1; i >= 0; i--)\n insertBefore(arguments[i], this);\n\n else if (typeof sibling !== 'undefined')\n insertBefore(sibling, this);\n\n return this;\n};\n\nClass.prototype.insertAfter = function(prev) {\n insertAfter(this, prev);\n return this;\n};\n\nClass.prototype.insertBefore = function(next) {\n insertBefore(this, next);\n return this;\n};\n\nfunction append(parent, child) {\n _ensure(child);\n _ensure(parent);\n\n child.remove();\n\n if (parent._last) {\n parent._last._next = child;\n child._prev = parent._last;\n }\n\n child._parent = parent;\n parent._last = child;\n\n if (!parent._first) {\n parent._first = child;\n }\n\n child._parent._flag(child, true);\n\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n}\n\nfunction prepend(parent, child) {\n _ensure(child);\n _ensure(parent);\n\n child.remove();\n\n if (parent._first) {\n parent._first._prev = child;\n child._next = parent._first;\n }\n\n child._parent = parent;\n parent._first = child;\n\n if (!parent._last) {\n parent._last = child;\n }\n\n child._parent._flag(child, true);\n\n child._ts_parent = ++iid;\n parent._ts_children = ++iid;\n parent.touch();\n};\n\nfunction insertBefore(self, next) {\n _ensure(self);\n _ensure(next);\n\n self.remove();\n\n var parent = next._parent;\n var prev = next._prev;\n\n next._prev = self;\n prev && (prev._next = self) || parent && (parent._first = self);\n\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n\n self._parent._flag(self, true);\n\n self._ts_parent = ++iid;\n self.touch();\n};\n\nfunction insertAfter(self, prev) {\n _ensure(self);\n _ensure(prev);\n\n self.remove();\n\n var parent = prev._parent;\n var next = prev._next;\n\n prev._next = self;\n next && (next._prev = self) || parent && (parent._last = self);\n\n self._parent = parent;\n self._prev = prev;\n self._next = next;\n\n self._parent._flag(self, true);\n\n self._ts_parent = ++iid;\n self.touch();\n};\n\nClass.prototype.remove = function(child, more) {\n if (typeof child !== 'undefined') {\n if (is.array(child)) {\n for (var i = 0; i < child.length; i++)\n _ensure(child[i]).remove();\n\n } else if (typeof more !== 'undefined') {\n for (var i = 0; i < arguments.length; i++)\n _ensure(arguments[i]).remove();\n\n } else {\n _ensure(child).remove();\n }\n return this;\n }\n\n if (this._prev) {\n this._prev._next = this._next;\n }\n if (this._next) {\n this._next._prev = this._prev;\n }\n\n if (this._parent) {\n if (this._parent._first === this) {\n this._parent._first = this._next;\n }\n if (this._parent._last === this) {\n this._parent._last = this._prev;\n }\n\n this._parent._flag(this, false);\n\n this._parent._ts_children = ++iid;\n this._parent.touch();\n }\n\n this._prev = this._next = this._parent = null;\n this._ts_parent = ++iid;\n // this._parent.touch();\n\n return this;\n};\n\nClass.prototype.empty = function() {\n var child, next = this._first;\n while (child = next) {\n next = child._next;\n child._prev = child._next = child._parent = null;\n\n this._flag(child, false);\n }\n\n this._first = this._last = null;\n\n this._ts_children = ++iid;\n this.touch();\n return this;\n};\n\nClass.prototype.touch = function() {\n this._ts_touch = ++iid;\n this._parent && this._parent.touch();\n return this;\n};\n\n/**\n * Deep flags used for optimizing event distribution.\n */\nClass.prototype._flag = function(obj, name) {\n if (typeof name === 'undefined') {\n return this._flags !== null && this._flags[obj] || 0;\n }\n if (typeof obj === 'string') {\n if (name) {\n this._flags = this._flags || {};\n if (!this._flags[obj] && this._parent) {\n this._parent._flag(obj, true);\n }\n this._flags[obj] = (this._flags[obj] || 0) + 1;\n\n } else if (this._flags && this._flags[obj] > 0) {\n if (this._flags[obj] == 1 && this._parent) {\n this._parent._flag(obj, false);\n }\n this._flags[obj] = this._flags[obj] - 1;\n }\n }\n if (typeof obj === 'object') {\n if (obj._flags) {\n for ( var type in obj._flags) {\n if (obj._flags[type] > 0) {\n this._flag(type, name);\n }\n }\n }\n }\n return this;\n};\n\n/**\n * @private\n */\nClass.prototype.hitTest = function(hit) {\n if (this.attr('spy')) {\n return true;\n }\n return hit.x >= 0 && hit.x <= this._pin._width && hit.y >= 0\n && hit.y <= this._pin._height;\n};\n\nfunction _ensure(obj) {\n if (obj && obj instanceof Class) {\n return obj;\n }\n throw 'Invalid node: ' + obj;\n};\n\nmodule.exports = Class;\n\n},{\"./core\":60,\"./util/is\":77}],73:[function(require,module,exports){\nmodule.exports = function() {\n var count = 0;\n function fork(fn, n) {\n count += n = (typeof n === 'number' && n >= 1 ? n : 1);\n return function() {\n fn && fn.apply(this, arguments);\n if (n > 0) {\n n--, count--, call();\n }\n };\n }\n var then = [];\n function call() {\n if (count === 0) {\n while (then.length) {\n setTimeout(then.shift(), 0);\n }\n }\n }\n fork.then = function(fn) {\n if (count === 0) {\n setTimeout(fn, 0);\n } else {\n then.push(fn);\n }\n };\n return fork;\n};\n},{}],74:[function(require,module,exports){\nif (typeof Object.create == 'function') {\n module.exports = function(proto, props) {\n return Object.create.call(Object, proto, props);\n };\n} else {\n module.exports = function(proto, props) {\n if (props)\n throw Error('Second argument is not supported!');\n if (typeof proto !== 'object' || proto === null)\n throw Error('Invalid prototype!');\n noop.prototype = proto;\n return new noop;\n };\n function noop() {\n }\n}\n\n},{}],75:[function(require,module,exports){\nmodule.exports = function(prototype, callback) {\n\n prototype._listeners = null;\n\n prototype.on = prototype.listen = function(types, listener) {\n if (!types || !types.length || typeof listener !== 'function') {\n return this;\n }\n if (this._listeners === null) {\n this._listeners = {};\n }\n var isarray = typeof types !== 'string' && typeof types.join === 'function';\n if (types = (isarray ? types.join(' ') : types).match(/\\S+/g)) {\n for (var i = 0; i < types.length; i++) {\n var type = types[i];\n this._listeners[type] = this._listeners[type] || [];\n this._listeners[type].push(listener);\n if (typeof callback === 'function') {\n callback(this, type, true);\n }\n }\n }\n return this;\n };\n\n prototype.off = function(types, listener) {\n if (!types || !types.length || typeof listener !== 'function') {\n return this;\n }\n if (this._listeners === null) {\n return this;\n }\n var isarray = typeof types !== 'string' && typeof types.join === 'function';\n if (types = (isarray ? types.join(' ') : types).match(/\\S+/g)) {\n for (var i = 0; i < types.length; i++) {\n var type = types[i], all = this._listeners[type], index;\n if (all && (index = all.indexOf(listener)) >= 0) {\n all.splice(index, 1);\n if (!all.length) {\n delete this._listeners[type];\n }\n if (typeof callback === 'function') {\n callback(this, type, false);\n }\n }\n }\n }\n return this;\n };\n\n prototype.listeners = function(type) {\n return this._listeners && this._listeners[type];\n };\n\n prototype.publish = function(name, args) {\n var listeners = this.listeners(name);\n if (!listeners || !listeners.length) {\n return 0;\n }\n for (var l = 0; l < listeners.length; l++) {\n listeners[l].apply(this, args);\n }\n return listeners.length;\n };\n\n prototype.trigger = function(name, args) {\n this.publish(name, args);\n return this;\n };\n\n};\n\n},{}],76:[function(require,module,exports){\nmodule.exports = function(base) {\n for (var i = 1; i < arguments.length; i++) {\n var obj = arguments[i];\n for ( var key in obj) {\n if (obj.hasOwnProperty(key)) {\n base[key] = obj[key];\n }\n }\n }\n return base;\n};\n\n},{}],77:[function(require,module,exports){\n/**\n * ! is the definitive JavaScript type testing library\n * \n * @copyright 2013-2014 Enrico Marino / Jordan Harband\n * @license MIT\n */\n\nvar objProto = Object.prototype;\nvar owns = objProto.hasOwnProperty;\nvar toStr = objProto.toString;\n\nvar NON_HOST_TYPES = {\n 'boolean' : 1,\n 'number' : 1,\n 'string' : 1,\n 'undefined' : 1\n};\n\nvar hexRegex = /^[A-Fa-f0-9]+$/;\n\nvar is = module.exports = {};\n\nis.a = is.an = is.type = function(value, type) {\n return typeof value === type;\n};\n\nis.defined = function(value) {\n return typeof value !== 'undefined';\n};\n\nis.empty = function(value) {\n var type = toStr.call(value);\n var key;\n\n if ('[object Array]' === type || '[object Arguments]' === type\n || '[object String]' === type) {\n return value.length === 0;\n }\n\n if ('[object Object]' === type) {\n for (key in value) {\n if (owns.call(value, key)) {\n return false;\n }\n }\n return true;\n }\n\n return !value;\n};\n\nis.equal = function(value, other) {\n if (value === other) {\n return true;\n }\n\n var type = toStr.call(value);\n var key;\n\n if (type !== toStr.call(other)) {\n return false;\n }\n\n if ('[object Object]' === type) {\n for (key in value) {\n if (!is.equal(value[key], other[key]) || !(key in other)) {\n return false;\n }\n }\n for (key in other) {\n if (!is.equal(value[key], other[key]) || !(key in value)) {\n return false;\n }\n }\n return true;\n }\n\n if ('[object Array]' === type) {\n key = value.length;\n if (key !== other.length) {\n return false;\n }\n while (--key) {\n if (!is.equal(value[key], other[key])) {\n return false;\n }\n }\n return true;\n }\n\n if ('[object Function]' === type) {\n return value.prototype === other.prototype;\n }\n\n if ('[object Date]' === type) {\n return value.getTime() === other.getTime();\n }\n\n return false;\n};\n\nis.instance = function(value, constructor) {\n return value instanceof constructor;\n};\n\nis.nil = function(value) {\n return value === null;\n};\n\nis.undef = function(value) {\n return typeof value === 'undefined';\n};\n\nis.array = function(value) {\n return '[object Array]' === toStr.call(value);\n};\n\nis.emptyarray = function(value) {\n return is.array(value) && value.length === 0;\n};\n\nis.arraylike = function(value) {\n return !!value && !is.boolean(value) && owns.call(value, 'length')\n && isFinite(value.length) && is.number(value.length) && value.length >= 0;\n};\n\nis.boolean = function(value) {\n return '[object Boolean]' === toStr.call(value);\n};\n\nis.element = function(value) {\n return value !== undefined && typeof HTMLElement !== 'undefined'\n && value instanceof HTMLElement && value.nodeType === 1;\n};\n\nis.fn = function(value) {\n return '[object Function]' === toStr.call(value);\n};\n\nis.number = function(value) {\n return '[object Number]' === toStr.call(value);\n};\n\nis.nan = function(value) {\n return !is.number(value) || value !== value;\n};\n\nis.object = function(value) {\n return '[object Object]' === toStr.call(value);\n};\n\nis.hash = function(value) {\n return is.object(value) && value.constructor === Object && !value.nodeType\n && !value.setInterval;\n};\n\nis.regexp = function(value) {\n return '[object RegExp]' === toStr.call(value);\n};\n\nis.string = function(value) {\n return '[object String]' === toStr.call(value);\n};\n\nis.hex = function(value) {\n return is.string(value) && (!value.length || hexRegex.test(value));\n};\n\n},{}],78:[function(require,module,exports){\nvar create = require('./create');\nvar native = Math;\n\nmodule.exports = create(Math);\n\nmodule.exports.random = function(min, max) {\n if (typeof min === 'undefined') {\n max = 1, min = 0;\n } else if (typeof max === 'undefined') {\n max = min, min = 0;\n }\n return min == max ? min : native.random() * (max - min) + min;\n};\n\nmodule.exports.rotate = function(num, min, max) {\n if (typeof min === 'undefined') {\n max = 1, min = 0;\n } else if (typeof max === 'undefined') {\n max = min, min = 0;\n }\n if (max > min) {\n num = (num - min) % (max - min);\n return num + (num < 0 ? max : min);\n } else {\n num = (num - max) % (min - max);\n return num + (num <= 0 ? min : max);\n }\n};\n\nmodule.exports.limit = function(num, min, max) {\n if (num < min) {\n return min;\n } else if (num > max) {\n return max;\n } else {\n return num;\n }\n};\n\nmodule.exports.length = function(x, y) {\n return native.sqrt(x * x + y * y);\n};\n},{\"./create\":74}],79:[function(require,module,exports){\nmodule.exports = function(img, owidth, oheight, stretch, inner, insert) {\n\n var width = img.width;\n var height = img.height;\n var left = img.left;\n var right = img.right;\n var top = img.top;\n var bottom = img.bottom;\n\n left = typeof left === 'number' && left === left ? left : 0;\n right = typeof right === 'number' && right === right ? right : 0;\n top = typeof top === 'number' && top === top ? top : 0;\n bottom = typeof bottom === 'number' && bottom === bottom ? bottom : 0;\n\n width = width - left - right;\n height = height - top - bottom;\n\n if (!inner) {\n owidth = Math.max(owidth - left - right, 0);\n oheight = Math.max(oheight - top - bottom, 0);\n }\n\n var i = 0;\n\n if (top > 0 && left > 0)\n insert(i++, 0, 0, left, top, 0, 0, left, top);\n if (bottom > 0 && left > 0)\n insert(i++, 0, height + top, left, bottom, 0, oheight + top, left, bottom);\n if (top > 0 && right > 0)\n insert(i++, width + left, 0, right, top, owidth + left, 0, right, top);\n if (bottom > 0 && right > 0)\n insert(i++, width + left, height + top, right, bottom, owidth + left,\n oheight + top, right, bottom);\n\n if (stretch) {\n if (top > 0)\n insert(i++, left, 0, width, top, left, 0, owidth, top);\n if (bottom > 0)\n insert(i++, left, height + top, width, bottom, left, oheight + top,\n owidth, bottom);\n if (left > 0)\n insert(i++, 0, top, left, height, 0, top, left, oheight);\n if (right > 0)\n insert(i++, width + left, top, right, height, owidth + left, top, right,\n oheight);\n // center\n insert(i++, left, top, width, height, left, top, owidth, oheight);\n\n } else { // tile\n var l = left, r = owidth, w;\n while (r > 0) {\n w = Math.min(width, r), r -= width;\n var t = top, b = oheight, h;\n while (b > 0) {\n h = Math.min(height, b), b -= height;\n insert(i++, left, top, w, h, l, t, w, h);\n if (r <= 0) {\n if (left)\n insert(i++, 0, top, left, h, 0, t, left, h);\n if (right)\n insert(i++, width + left, top, right, h, l + w, t, right, h);\n }\n t += h;\n }\n if (top)\n insert(i++, left, 0, w, top, l, 0, w, top);\n if (bottom)\n insert(i++, left, height + top, w, bottom, l, t, w, bottom);\n l += w;\n }\n }\n\n return i;\n};\n},{}],80:[function(require,module,exports){\nmodule.exports = {};\n\n},{}],81:[function(require,module,exports){\nmodule.exports.startsWith = function(str, sub) {\n return typeof str === 'string' && typeof sub === 'string'\n && str.substring(0, sub.length) == sub;\n};\n},{}],82:[function(require,module,exports){\nmodule.exports = require('../lib/');\n\nrequire('../lib/canvas');\nrequire('../lib/image');\nrequire('../lib/anim');\nrequire('../lib/str');\nrequire('../lib/layout');\nrequire('../lib/addon/tween');\nmodule.exports.Mouse = require('../lib/addon/mouse');\nmodule.exports.Math = require('../lib/util/math');\nmodule.exports._extend = require('../lib/util/extend');\nmodule.exports._create = require('../lib/util/create');\n\nrequire('../lib/loader/web');\n},{\"../lib/\":63,\"../lib/addon/mouse\":55,\"../lib/addon/tween\":56,\"../lib/anim\":57,\"../lib/canvas\":59,\"../lib/image\":62,\"../lib/layout\":64,\"../lib/loader/web\":65,\"../lib/str\":70,\"../lib/util/create\":74,\"../lib/util/extend\":76,\"../lib/util/math\":78}]},{},[1])(1)\n});"},"repo_name":{"kind":"string","value":"PeterDaveHello/jsdelivr"},"path":{"kind":"string","value":"files/planck/0.1.34/planck-with-testbed.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":464606,"string":"464,606"}}},{"rowIdx":61538416,"cells":{"code":{"kind":"string","value":"module.exports = function isString (value) {\n return Object.prototype.toString.call(value) === '[object String]'\n}\n"},"repo_name":{"kind":"string","value":"chrisdavidmills/express-local-library"},"path":{"kind":"string","value":"node_modules/helmet-csp/lib/is-string.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":116,"string":"116"}}},{"rowIdx":61538417,"cells":{"code":{"kind":"string","value":"/*\n * The MIT License\n * Copyright (c) 2012 Microsoft Corporation\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage microsoft.exchange.webservices.data.core.request;\n\nimport microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;\nimport microsoft.exchange.webservices.data.core.EwsUtilities;\nimport microsoft.exchange.webservices.data.core.ExchangeService;\nimport microsoft.exchange.webservices.data.core.XmlElementNames;\nimport microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling;\nimport microsoft.exchange.webservices.data.core.response.ServiceResponse;\nimport microsoft.exchange.webservices.data.core.service.item.Item;\nimport microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;\nimport microsoft.exchange.webservices.data.misc.ItemIdWrapperList;\n\n/**\n * Represents an abstract Move/Copy Item request.\n *\n * @param The type of the response.\n */\npublic abstract class MoveCopyItemRequest\n extends MoveCopyRequest {\n private ItemIdWrapperList itemIds = new ItemIdWrapperList();\n private Boolean newItemIds;\n\n /**\n * Validates request.\n *\n * @throws Exception the exception\n */\n @Override\n public void validate() throws Exception {\n super.validate();\n EwsUtilities.validateParam(this.getItemIds(), \"ItemIds\");\n }\n\n /**\n * Initializes a new instance of the class.\n *\n * @param service the service\n * @param errorHandlingMode the error handling mode\n * @throws Exception on error\n */\n protected MoveCopyItemRequest(ExchangeService service,\n ServiceErrorHandling errorHandlingMode)\n throws Exception {\n super(service, errorHandlingMode);\n }\n\n /**\n * Writes the ids as XML.\n *\n * @param writer the writer\n * @throws Exception the exception\n */\n @Override\n protected void writeIdsToXml(EwsServiceXmlWriter writer) throws Exception {\n this.getItemIds().writeToXml(writer, XmlNamespace.Messages,\n XmlElementNames.ItemIds);\n if (this.getReturnNewItemIds() != null) {\n writer.writeElementValue(\n XmlNamespace.Messages,\n XmlElementNames.ReturnNewItemIds,\n this.getReturnNewItemIds());\n }\n }\n\n /**\n * Gets the expected response message count.\n *\n * @return Number of expected response messages.\n */\n @Override\n protected int getExpectedResponseMessageCount() {\n return this.getItemIds().getCount();\n }\n\n /**\n * Gets the item ids.\n *\n * @return the item ids\n */\n public ItemIdWrapperList getItemIds() {\n return this.itemIds;\n }\n\n protected Boolean getReturnNewItemIds() {\n return this.newItemIds;\n }\n\n public void setReturnNewItemIds(Boolean value) {\n this.newItemIds = value;\n }\n}\n"},"repo_name":{"kind":"string","value":"KatharineYe/ews-java-api"},"path":{"kind":"string","value":"src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyItemRequest.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":3795,"string":"3,795"}}},{"rowIdx":61538418,"cells":{"code":{"kind":"string","value":"import { Teammates } from \"../../\";\n\nexport = Teammates;\n"},"repo_name":{"kind":"string","value":"georgemarshall/DefinitelyTyped"},"path":{"kind":"string","value":"types/carbon__pictograms-react/lib/teammates/index.d.ts"},"language":{"kind":"string","value":"TypeScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":57,"string":"57"}}},{"rowIdx":61538419,"cells":{"code":{"kind":"string","value":"self.description = \"Install a package from a sync db with fnmatch'ed NoExtract\"\n\nsp = pmpkg(\"dummy\")\nsp.files = [\"bin/dummy\",\n \"usr/share/man/man8\",\n \"usr/share/man/man1/dummy.1\"]\nself.addpkg2db(\"sync\", sp)\n\nself.option[\"NoExtract\"] = [\"usr/share/man/*\"]\n\nself.args = \"-S %s\" % sp.name\n\nself.addrule(\"PACMAN_RETCODE=0\")\nself.addrule(\"PKG_EXIST=dummy\")\nself.addrule(\"FILE_EXIST=bin/dummy\")\nself.addrule(\"!FILE_EXIST=usr/share/man/man8\")\nself.addrule(\"!FILE_EXIST=usr/share/man/man1/dummy.1\")\n"},"repo_name":{"kind":"string","value":"kylon/pacman-fakeroot"},"path":{"kind":"string","value":"test/pacman/tests/sync502.py"},"language":{"kind":"string","value":"Python"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":513,"string":"513"}}},{"rowIdx":61538420,"cells":{"code":{"kind":"string","value":"// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#include \"content/browser/renderer_host/media/audio_sync_reader.h\"\n\n#include \n\n#include \"base/command_line.h\"\n#include \"base/memory/shared_memory.h\"\n#include \"base/metrics/histogram.h\"\n#include \"content/public/common/content_switches.h\"\n#include \"media/audio/audio_buffers_state.h\"\n#include \"media/audio/audio_parameters.h\"\n\nusing media::AudioBus;\n\nnamespace content {\n\nAudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory,\n const media::AudioParameters& params,\n int input_channels)\n : shared_memory_(shared_memory),\n input_channels_(input_channels),\n mute_audio_(CommandLine::ForCurrentProcess()->HasSwitch(\n switches::kMuteAudio)),\n packet_size_(shared_memory_->requested_size()),\n renderer_callback_count_(0),\n renderer_missed_callback_count_(0),\n#if defined(OS_MACOSX)\n maximum_wait_time_(params.GetBufferDuration() / 2),\n#else\n // TODO(dalecurtis): Investigate if we can reduce this on all platforms.\n maximum_wait_time_(base::TimeDelta::FromMilliseconds(20)),\n#endif\n buffer_index_(0) {\n int input_memory_size = 0;\n int output_memory_size = AudioBus::CalculateMemorySize(params);\n if (input_channels_ > 0) {\n // The input storage is after the output storage.\n int frames = params.frames_per_buffer();\n input_memory_size = AudioBus::CalculateMemorySize(input_channels_, frames);\n char* input_data =\n static_cast(shared_memory_->memory()) + output_memory_size;\n input_bus_ = AudioBus::WrapMemory(input_channels_, frames, input_data);\n input_bus_->Zero();\n }\n DCHECK_EQ(packet_size_, output_memory_size + input_memory_size);\n output_bus_ = AudioBus::WrapMemory(params, shared_memory->memory());\n output_bus_->Zero();\n}\n\nAudioSyncReader::~AudioSyncReader() {\n if (!renderer_callback_count_)\n return;\n\n // Recording the percentage of deadline misses gives us a rough overview of\n // how many users might be running into audio glitches.\n int percentage_missed =\n 100.0 * renderer_missed_callback_count_ / renderer_callback_count_;\n UMA_HISTOGRAM_PERCENTAGE(\n \"Media.AudioRendererMissedDeadline\", percentage_missed);\n}\n\n// media::AudioOutputController::SyncReader implementations.\nvoid AudioSyncReader::UpdatePendingBytes(uint32 bytes) {\n // Zero out the entire output buffer to avoid stuttering/repeating-buffers\n // in the anomalous case if the renderer is unable to keep up with real-time.\n output_bus_->Zero();\n socket_->Send(&bytes, sizeof(bytes));\n ++buffer_index_;\n}\n\nvoid AudioSyncReader::Read(const AudioBus* source, AudioBus* dest) {\n ++renderer_callback_count_;\n if (!WaitUntilDataIsReady()) {\n ++renderer_missed_callback_count_;\n dest->Zero();\n return;\n }\n\n // Copy optional synchronized live audio input for consumption by renderer\n // process.\n if (input_bus_) {\n if (source)\n source->CopyTo(input_bus_.get());\n else\n input_bus_->Zero();\n }\n\n if (mute_audio_)\n dest->Zero();\n else\n output_bus_->CopyTo(dest);\n}\n\nvoid AudioSyncReader::Close() {\n socket_->Close();\n}\n\nbool AudioSyncReader::Init() {\n socket_.reset(new base::CancelableSyncSocket());\n foreign_socket_.reset(new base::CancelableSyncSocket());\n return base::CancelableSyncSocket::CreatePair(socket_.get(),\n foreign_socket_.get());\n}\n\n#if defined(OS_WIN)\nbool AudioSyncReader::PrepareForeignSocketHandle(\n base::ProcessHandle process_handle,\n base::SyncSocket::Handle* foreign_handle) {\n ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(),\n process_handle, foreign_handle,\n 0, FALSE, DUPLICATE_SAME_ACCESS);\n return (*foreign_handle != 0);\n}\n#else\nbool AudioSyncReader::PrepareForeignSocketHandle(\n base::ProcessHandle process_handle,\n base::FileDescriptor* foreign_handle) {\n foreign_handle->fd = foreign_socket_->handle();\n foreign_handle->auto_close = false;\n return (foreign_handle->fd != -1);\n}\n#endif\n\nbool AudioSyncReader::WaitUntilDataIsReady() {\n base::TimeDelta timeout = maximum_wait_time_;\n const base::TimeTicks start_time = base::TimeTicks::Now();\n const base::TimeTicks finish_time = start_time + timeout;\n\n // Check if data is ready and if not, wait a reasonable amount of time for it.\n //\n // Data readiness is achieved via parallel counters, one on the renderer side\n // and one here. Every time a buffer is requested via UpdatePendingBytes(),\n // |buffer_index_| is incremented. Subsequently every time the renderer has a\n // buffer ready it increments its counter and sends the counter value over the\n // SyncSocket. Data is ready when |buffer_index_| matches the counter value\n // received from the renderer.\n //\n // The counter values may temporarily become out of sync if the renderer is\n // unable to deliver audio fast enough. It's assumed that the renderer will\n // catch up at some point, which means discarding counter values read from the\n // SyncSocket which don't match our current buffer index.\n size_t bytes_received = 0;\n uint32 renderer_buffer_index = 0;\n while (timeout.InMicroseconds() > 0) {\n bytes_received = socket_->ReceiveWithTimeout(\n &renderer_buffer_index, sizeof(renderer_buffer_index), timeout);\n if (!bytes_received)\n break;\n\n DCHECK_EQ(bytes_received, sizeof(renderer_buffer_index));\n if (renderer_buffer_index == buffer_index_)\n break;\n\n // Reduce the timeout value as receives succeed, but aren't the right index.\n timeout = finish_time - base::TimeTicks::Now();\n }\n\n // Receive timed out or another error occurred. Receive can timeout if the\n // renderer is unable to deliver audio data within the allotted time.\n if (!bytes_received || renderer_buffer_index != buffer_index_) {\n DVLOG(2) << \"AudioSyncReader::WaitUntilDataIsReady() timed out.\";\n\n base::TimeDelta time_since_start = base::TimeTicks::Now() - start_time;\n UMA_HISTOGRAM_CUSTOM_TIMES(\"Media.AudioOutputControllerDataNotReady\",\n time_since_start,\n base::TimeDelta::FromMilliseconds(1),\n base::TimeDelta::FromMilliseconds(1000),\n 50);\n return false;\n }\n\n return true;\n}\n\n} // namespace content\n"},"repo_name":{"kind":"string","value":"qtekfun/htcDesire820Kernel"},"path":{"kind":"string","value":"external/chromium_org/content/browser/renderer_host/media/audio_sync_reader.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":6518,"string":"6,518"}}},{"rowIdx":61538421,"cells":{"code":{"kind":"string","value":"\n \n \t
  • \" >\n \t\n \t\t\n \t\t\n \t\t
    \n \t\t\n \t\t\t\n \t\t\n \t\t\tcomment_approved == '0' ) {\n \t\t\t\t\techo \"\\t\\t\\t\\t\\t\" . '';\n \t\t\t\t\t_e( 'Your comment is awaiting moderation', 'thematic' );\n \t\t\t\t\techo \".\\n\";\n \t\t\t\t}\n \t\t\t?>\n \t\t\t\n
    \n \n \t\t\n \t\t\n \t\t
    \n \t\t\n\t\t\t __( 'Reply','thematic' ), \n\t\t\t\t\t\t'login_text' => __( 'Log in to reply.','thematic' ),\n\t\t\t\t\t\t'depth' => $depth,\n\t\t\t\t\t\t'before' => '
    ', \n\t\t\t\t\t\t'after' => '
    '\n\t\t\t\t\t)));\n\t\t\t\tendif;\n\t\t\t?>\n\t\t\t\n\t\t\t\n\n\n\n \t\t
  • \" >\n \t\t\t
    |' . \"\\n\\n\\t\\t\\t\\t\\t\\t\" . '', ''); ?>\n \t\t\t
    \n \t\t\t\n \t\t\tcomment_approved == '0') {\n \t\t\t\techo \"\\t\\t\\t\\t\\t\" . '';\n \t\t\t\t\t_e( 'Your trackback is awaiting moderation', 'thematic' );\n \t\t\t\t\t\n \t\t\t\techo \".\\n\";\n \t\t\t\t}\n \t\t\t?>\n \t\t\t\n \t
    \n \t\n \t\t\t\t\n \t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\n 0 {\n\t\tif len(args)%2 != 0 {\n\t\t\tcs, ok := args[len(args)-1].(CapturedStacktrace)\n\t\t\tif ok {\n\t\t\t\targs = args[:len(args)-1]\n\t\t\t\tstacktrace = cs\n\t\t\t} else {\n\t\t\t\targs = append(args, \"\")\n\t\t\t}\n\t\t}\n\n\t\tz.w.WriteByte(':')\n\n\tFOR:\n\t\tfor i := 0; i < len(args); i = i + 2 {\n\t\t\tvar (\n\t\t\t\tval string\n\t\t\t\traw bool\n\t\t\t)\n\n\t\t\tswitch st := args[i+1].(type) {\n\t\t\tcase string:\n\t\t\t\tval = st\n\t\t\tcase int:\n\t\t\t\tval = strconv.FormatInt(int64(st), 10)\n\t\t\tcase int64:\n\t\t\t\tval = strconv.FormatInt(int64(st), 10)\n\t\t\tcase int32:\n\t\t\t\tval = strconv.FormatInt(int64(st), 10)\n\t\t\tcase int16:\n\t\t\t\tval = strconv.FormatInt(int64(st), 10)\n\t\t\tcase int8:\n\t\t\t\tval = strconv.FormatInt(int64(st), 10)\n\t\t\tcase uint:\n\t\t\t\tval = strconv.FormatUint(uint64(st), 10)\n\t\t\tcase uint64:\n\t\t\t\tval = strconv.FormatUint(uint64(st), 10)\n\t\t\tcase uint32:\n\t\t\t\tval = strconv.FormatUint(uint64(st), 10)\n\t\t\tcase uint16:\n\t\t\t\tval = strconv.FormatUint(uint64(st), 10)\n\t\t\tcase uint8:\n\t\t\t\tval = strconv.FormatUint(uint64(st), 10)\n\t\t\tcase CapturedStacktrace:\n\t\t\t\tstacktrace = st\n\t\t\t\tcontinue FOR\n\t\t\tcase Format:\n\t\t\t\tval = fmt.Sprintf(st[0].(string), st[1:]...)\n\t\t\tdefault:\n\t\t\t\tv := reflect.ValueOf(st)\n\t\t\t\tif v.Kind() == reflect.Slice {\n\t\t\t\t\tval = z.renderSlice(v)\n\t\t\t\t\traw = true\n\t\t\t\t} else {\n\t\t\t\t\tval = fmt.Sprintf(\"%v\", st)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tz.w.WriteByte(' ')\n\t\t\tz.w.WriteString(args[i].(string))\n\t\t\tz.w.WriteByte('=')\n\n\t\t\tif !raw && strings.ContainsAny(val, \" \\t\\n\\r\") {\n\t\t\t\tz.w.WriteByte('\"')\n\t\t\t\tz.w.WriteString(val)\n\t\t\t\tz.w.WriteByte('\"')\n\t\t\t} else {\n\t\t\t\tz.w.WriteString(val)\n\t\t\t}\n\t\t}\n\t}\n\n\tz.w.WriteString(\"\\n\")\n\n\tif stacktrace != \"\" {\n\t\tz.w.WriteString(string(stacktrace))\n\t}\n}\n\nfunc (z *intLogger) renderSlice(v reflect.Value) string {\n\tvar buf bytes.Buffer\n\n\tbuf.WriteRune('[')\n\n\tfor i := 0; i < v.Len(); i++ {\n\t\tif i > 0 {\n\t\t\tbuf.WriteString(\", \")\n\t\t}\n\n\t\tsv := v.Index(i)\n\n\t\tvar val string\n\n\t\tswitch sv.Kind() {\n\t\tcase reflect.String:\n\t\t\tval = sv.String()\n\t\tcase reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\t\tval = strconv.FormatInt(sv.Int(), 10)\n\t\tcase reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\t\tval = strconv.FormatUint(sv.Uint(), 10)\n\t\tdefault:\n\t\t\tval = fmt.Sprintf(\"%v\", sv.Interface())\n\t\t}\n\n\t\tif strings.ContainsAny(val, \" \\t\\n\\r\") {\n\t\t\tbuf.WriteByte('\"')\n\t\t\tbuf.WriteString(val)\n\t\t\tbuf.WriteByte('\"')\n\t\t} else {\n\t\t\tbuf.WriteString(val)\n\t\t}\n\t}\n\n\tbuf.WriteRune(']')\n\n\treturn buf.String()\n}\n\n// JSON logging function\nfunc (z *intLogger) logJson(t time.Time, level Level, msg string, args ...interface{}) {\n\tvals := map[string]interface{}{\n\t\t\"@message\": msg,\n\t\t\"@timestamp\": t.Format(\"2006-01-02T15:04:05.000000Z07:00\"),\n\t}\n\n\tvar levelStr string\n\tswitch level {\n\tcase Error:\n\t\tlevelStr = \"error\"\n\tcase Warn:\n\t\tlevelStr = \"warn\"\n\tcase Info:\n\t\tlevelStr = \"info\"\n\tcase Debug:\n\t\tlevelStr = \"debug\"\n\tcase Trace:\n\t\tlevelStr = \"trace\"\n\tdefault:\n\t\tlevelStr = \"all\"\n\t}\n\n\tvals[\"@level\"] = levelStr\n\n\tif z.name != \"\" {\n\t\tvals[\"@module\"] = z.name\n\t}\n\n\tif z.caller {\n\t\tif _, file, line, ok := runtime.Caller(3); ok {\n\t\t\tvals[\"@caller\"] = fmt.Sprintf(\"%s:%d\", file, line)\n\t\t}\n\t}\n\n\targs = append(z.implied, args...)\n\n\tif args != nil && len(args) > 0 {\n\t\tif len(args)%2 != 0 {\n\t\t\tcs, ok := args[len(args)-1].(CapturedStacktrace)\n\t\t\tif ok {\n\t\t\t\targs = args[:len(args)-1]\n\t\t\t\tvals[\"stacktrace\"] = cs\n\t\t\t} else {\n\t\t\t\targs = append(args, \"\")\n\t\t\t}\n\t\t}\n\n\t\tfor i := 0; i < len(args); i = i + 2 {\n\t\t\tif _, ok := args[i].(string); !ok {\n\t\t\t\t// As this is the logging function not much we can do here\n\t\t\t\t// without injecting into logs...\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tval := args[i+1]\n\t\t\tswitch sv := val.(type) {\n\t\t\tcase error:\n\t\t\t\t// Check if val is of type error. If error type doesn't\n\t\t\t\t// implement json.Marshaler or encoding.TextMarshaler\n\t\t\t\t// then set val to err.Error() so that it gets marshaled\n\t\t\t\tswitch sv.(type) {\n\t\t\t\tcase json.Marshaler, encoding.TextMarshaler:\n\t\t\t\tdefault:\n\t\t\t\t\tval = sv.Error()\n\t\t\t\t}\n\t\t\tcase Format:\n\t\t\t\tval = fmt.Sprintf(sv[0].(string), sv[1:]...)\n\t\t\t}\n\n\t\t\tvals[args[i].(string)] = val\n\t\t}\n\t}\n\n\terr := json.NewEncoder(z.w).Encode(vals)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\n// Emit the message and args at DEBUG level\nfunc (z *intLogger) Debug(msg string, args ...interface{}) {\n\tz.Log(Debug, msg, args...)\n}\n\n// Emit the message and args at TRACE level\nfunc (z *intLogger) Trace(msg string, args ...interface{}) {\n\tz.Log(Trace, msg, args...)\n}\n\n// Emit the message and args at INFO level\nfunc (z *intLogger) Info(msg string, args ...interface{}) {\n\tz.Log(Info, msg, args...)\n}\n\n// Emit the message and args at WARN level\nfunc (z *intLogger) Warn(msg string, args ...interface{}) {\n\tz.Log(Warn, msg, args...)\n}\n\n// Emit the message and args at ERROR level\nfunc (z *intLogger) Error(msg string, args ...interface{}) {\n\tz.Log(Error, msg, args...)\n}\n\n// Indicate that the logger would emit TRACE level logs\nfunc (z *intLogger) IsTrace() bool {\n\treturn Level(atomic.LoadInt32(z.level)) == Trace\n}\n\n// Indicate that the logger would emit DEBUG level logs\nfunc (z *intLogger) IsDebug() bool {\n\treturn Level(atomic.LoadInt32(z.level)) <= Debug\n}\n\n// Indicate that the logger would emit INFO level logs\nfunc (z *intLogger) IsInfo() bool {\n\treturn Level(atomic.LoadInt32(z.level)) <= Info\n}\n\n// Indicate that the logger would emit WARN level logs\nfunc (z *intLogger) IsWarn() bool {\n\treturn Level(atomic.LoadInt32(z.level)) <= Warn\n}\n\n// Indicate that the logger would emit ERROR level logs\nfunc (z *intLogger) IsError() bool {\n\treturn Level(atomic.LoadInt32(z.level)) <= Error\n}\n\n// Return a sub-Logger for which every emitted log message will contain\n// the given key/value pairs. This is used to create a context specific\n// Logger.\nfunc (z *intLogger) With(args ...interface{}) Logger {\n\tif len(args)%2 != 0 {\n\t\tpanic(\"With() call requires paired arguments\")\n\t}\n\n\tvar nz intLogger = *z\n\n\tresult := make(map[string]interface{}, len(z.implied)+len(args))\n\tkeys := make([]string, 0, len(z.implied)+len(args))\n\n\t// Read existing args, store map and key for consistent sorting\n\tfor i := 0; i < len(z.implied); i += 2 {\n\t\tkey := z.implied[i].(string)\n\t\tkeys = append(keys, key)\n\t\tresult[key] = z.implied[i+1]\n\t}\n\t// Read new args, store map and key for consistent sorting\n\tfor i := 0; i < len(args); i += 2 {\n\t\tkey := args[i].(string)\n\t\t_, exists := result[key]\n\t\tif !exists {\n\t\t\tkeys = append(keys, key)\n\t\t}\n\t\tresult[key] = args[i+1]\n\t}\n\n\t// Sort keys to be consistent\n\tsort.Strings(keys)\n\n\tnz.implied = make([]interface{}, 0, len(z.implied)+len(args))\n\tfor _, k := range keys {\n\t\tnz.implied = append(nz.implied, k)\n\t\tnz.implied = append(nz.implied, result[k])\n\t}\n\n\treturn &nz\n}\n\n// Create a new sub-Logger that a name decending from the current name.\n// This is used to create a subsystem specific Logger.\nfunc (z *intLogger) Named(name string) Logger {\n\tvar nz intLogger = *z\n\n\tif nz.name != \"\" {\n\t\tnz.name = nz.name + \".\" + name\n\t} else {\n\t\tnz.name = name\n\t}\n\n\treturn &nz\n}\n\n// Create a new sub-Logger with an explicit name. This ignores the current\n// name. This is used to create a standalone logger that doesn't fall\n// within the normal hierarchy.\nfunc (z *intLogger) ResetNamed(name string) Logger {\n\tvar nz intLogger = *z\n\n\tnz.name = name\n\n\treturn &nz\n}\n\n// Update the logging level on-the-fly. This will affect all subloggers as\n// well.\nfunc (z *intLogger) SetLevel(level Level) {\n\tatomic.StoreInt32(z.level, int32(level))\n}\n\n// Create a *log.Logger that will send it's data through this Logger. This\n// allows packages that expect to be using the standard library log to actually\n// use this logger.\nfunc (z *intLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger {\n\tif opts == nil {\n\t\topts = &StandardLoggerOptions{}\n\t}\n\n\treturn log.New(&stdlogAdapter{z, opts.InferLevels}, \"\", 0)\n}\n"},"repo_name":{"kind":"string","value":"xanzy/terraform-provider-cosmic"},"path":{"kind":"string","value":"vendor/github.com/hashicorp/go-hclog/int.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":11348,"string":"11,348"}}},{"rowIdx":61538427,"cells":{"code":{"kind":"string","value":"/*\nCopyright 2015 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage podautoscaler\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"time\"\n\n\t\"github.com/golang/glog\"\n\tautoscalingv1 \"k8s.io/api/autoscaling/v1\"\n\tautoscalingv2 \"k8s.io/api/autoscaling/v2beta1\"\n\t\"k8s.io/api/core/v1\"\n\tapiequality \"k8s.io/apimachinery/pkg/api/equality\"\n\t\"k8s.io/apimachinery/pkg/api/errors\"\n\tapimeta \"k8s.io/apimachinery/pkg/api/meta\"\n\t\"k8s.io/apimachinery/pkg/api/resource\"\n\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n\t\"k8s.io/apimachinery/pkg/labels\"\n\t\"k8s.io/apimachinery/pkg/runtime\"\n\t\"k8s.io/apimachinery/pkg/runtime/schema\"\n\tutilruntime \"k8s.io/apimachinery/pkg/util/runtime\"\n\t\"k8s.io/apimachinery/pkg/util/wait\"\n\tautoscalinginformers \"k8s.io/client-go/informers/autoscaling/v1\"\n\t\"k8s.io/client-go/kubernetes/scheme\"\n\tautoscalingclient \"k8s.io/client-go/kubernetes/typed/autoscaling/v1\"\n\tv1core \"k8s.io/client-go/kubernetes/typed/core/v1\"\n\tautoscalinglisters \"k8s.io/client-go/listers/autoscaling/v1\"\n\tscaleclient \"k8s.io/client-go/scale\"\n\t\"k8s.io/client-go/tools/cache\"\n\t\"k8s.io/client-go/tools/record\"\n\t\"k8s.io/client-go/util/workqueue\"\n\t\"k8s.io/kubernetes/pkg/api/legacyscheme\"\n\t\"k8s.io/kubernetes/pkg/controller\"\n)\n\nvar (\n\tscaleUpLimitFactor = 2.0\n\tscaleUpLimitMinimum = 4.0\n)\n\n// HorizontalController is responsible for the synchronizing HPA objects stored\n// in the system with the actual deployments/replication controllers they\n// control.\ntype HorizontalController struct {\n\tscaleNamespacer scaleclient.ScalesGetter\n\thpaNamespacer autoscalingclient.HorizontalPodAutoscalersGetter\n\tmapper apimeta.RESTMapper\n\n\treplicaCalc *ReplicaCalculator\n\teventRecorder record.EventRecorder\n\n\tupscaleForbiddenWindow time.Duration\n\tdownscaleForbiddenWindow time.Duration\n\n\t// hpaLister is able to list/get HPAs from the shared cache from the informer passed in to\n\t// NewHorizontalController.\n\thpaLister autoscalinglisters.HorizontalPodAutoscalerLister\n\thpaListerSynced cache.InformerSynced\n\n\t// Controllers that need to be synced\n\tqueue workqueue.RateLimitingInterface\n}\n\n// NewHorizontalController creates a new HorizontalController.\nfunc NewHorizontalController(\n\tevtNamespacer v1core.EventsGetter,\n\tscaleNamespacer scaleclient.ScalesGetter,\n\thpaNamespacer autoscalingclient.HorizontalPodAutoscalersGetter,\n\tmapper apimeta.RESTMapper,\n\treplicaCalc *ReplicaCalculator,\n\thpaInformer autoscalinginformers.HorizontalPodAutoscalerInformer,\n\tresyncPeriod time.Duration,\n\tupscaleForbiddenWindow time.Duration,\n\tdownscaleForbiddenWindow time.Duration,\n\n) *HorizontalController {\n\tbroadcaster := record.NewBroadcaster()\n\tbroadcaster.StartLogging(glog.Infof)\n\tbroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: evtNamespacer.Events(\"\")})\n\trecorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: \"horizontal-pod-autoscaler\"})\n\n\thpaController := &HorizontalController{\n\t\treplicaCalc: replicaCalc,\n\t\teventRecorder: recorder,\n\t\tscaleNamespacer: scaleNamespacer,\n\t\thpaNamespacer: hpaNamespacer,\n\t\tupscaleForbiddenWindow: upscaleForbiddenWindow,\n\t\tdownscaleForbiddenWindow: downscaleForbiddenWindow,\n\t\tqueue: workqueue.NewNamedRateLimitingQueue(NewDefaultHPARateLimiter(resyncPeriod), \"horizontalpodautoscaler\"),\n\t\tmapper: mapper,\n\t}\n\n\thpaInformer.Informer().AddEventHandlerWithResyncPeriod(\n\t\tcache.ResourceEventHandlerFuncs{\n\t\t\tAddFunc: hpaController.enqueueHPA,\n\t\t\tUpdateFunc: hpaController.updateHPA,\n\t\t\tDeleteFunc: hpaController.deleteHPA,\n\t\t},\n\t\tresyncPeriod,\n\t)\n\thpaController.hpaLister = hpaInformer.Lister()\n\thpaController.hpaListerSynced = hpaInformer.Informer().HasSynced\n\n\treturn hpaController\n}\n\n// Run begins watching and syncing.\nfunc (a *HorizontalController) Run(stopCh <-chan struct{}) {\n\tdefer utilruntime.HandleCrash()\n\tdefer a.queue.ShutDown()\n\n\tglog.Infof(\"Starting HPA controller\")\n\tdefer glog.Infof(\"Shutting down HPA controller\")\n\n\tif !controller.WaitForCacheSync(\"HPA\", stopCh, a.hpaListerSynced) {\n\t\treturn\n\t}\n\n\t// start a single worker (we may wish to start more in the future)\n\tgo wait.Until(a.worker, time.Second, stopCh)\n\n\t<-stopCh\n}\n\n// obj could be an *v1.HorizontalPodAutoscaler, or a DeletionFinalStateUnknown marker item.\nfunc (a *HorizontalController) updateHPA(old, cur interface{}) {\n\ta.enqueueHPA(cur)\n}\n\n// obj could be an *v1.HorizontalPodAutoscaler, or a DeletionFinalStateUnknown marker item.\nfunc (a *HorizontalController) enqueueHPA(obj interface{}) {\n\tkey, err := controller.KeyFunc(obj)\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"couldn't get key for object %+v: %v\", obj, err))\n\t\treturn\n\t}\n\n\t// always add rate-limitted so we don't fetch metrics more that once per resync interval\n\ta.queue.AddRateLimited(key)\n}\n\nfunc (a *HorizontalController) deleteHPA(obj interface{}) {\n\tkey, err := controller.KeyFunc(obj)\n\tif err != nil {\n\t\tutilruntime.HandleError(fmt.Errorf(\"couldn't get key for object %+v: %v\", obj, err))\n\t\treturn\n\t}\n\n\t// TODO: could we leak if we fail to get the key?\n\ta.queue.Forget(key)\n}\n\nfunc (a *HorizontalController) worker() {\n\tfor a.processNextWorkItem() {\n\t}\n\tglog.Infof(\"horizontal pod autoscaler controller worker shutting down\")\n}\n\nfunc (a *HorizontalController) processNextWorkItem() bool {\n\tkey, quit := a.queue.Get()\n\tif quit {\n\t\treturn false\n\t}\n\tdefer a.queue.Done(key)\n\n\terr := a.reconcileKey(key.(string))\n\tif err == nil {\n\t\t// don't \"forget\" here because we want to only process a given HPA once per resync interval\n\t\treturn true\n\t}\n\n\ta.queue.AddRateLimited(key)\n\tutilruntime.HandleError(err)\n\treturn true\n}\n\n// Computes the desired number of replicas for the metric specifications listed in the HPA, returning the maximum\n// of the computed replica counts, a description of the associated metric, and the statuses of all metrics\n// computed.\nfunc (a *HorizontalController) computeReplicasForMetrics(hpa *autoscalingv2.HorizontalPodAutoscaler, scale *autoscalingv1.Scale,\n\tmetricSpecs []autoscalingv2.MetricSpec) (replicas int32, metric string, statuses []autoscalingv2.MetricStatus, timestamp time.Time, err error) {\n\n\tcurrentReplicas := scale.Status.Replicas\n\n\tstatuses = make([]autoscalingv2.MetricStatus, len(metricSpecs))\n\n\tfor i, metricSpec := range metricSpecs {\n\t\tif scale.Status.Selector == \"\" {\n\t\t\terrMsg := \"selector is required\"\n\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"SelectorRequired\", errMsg)\n\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"InvalidSelector\", \"the HPA target's scale is missing a selector\")\n\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(errMsg)\n\t\t}\n\n\t\tselector, err := labels.Parse(scale.Status.Selector)\n\t\tif err != nil {\n\t\t\terrMsg := fmt.Sprintf(\"couldn't convert selector into a corresponding internal selector object: %v\", err)\n\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"InvalidSelector\", errMsg)\n\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"InvalidSelector\", errMsg)\n\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(errMsg)\n\t\t}\n\n\t\tvar replicaCountProposal int32\n\t\tvar utilizationProposal int64\n\t\tvar timestampProposal time.Time\n\t\tvar metricNameProposal string\n\n\t\tswitch metricSpec.Type {\n\t\tcase autoscalingv2.ObjectMetricSourceType:\n\t\t\treplicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetObjectMetricReplicas(currentReplicas, metricSpec.Object.TargetValue.MilliValue(), metricSpec.Object.MetricName, hpa.Namespace, &metricSpec.Object.Target, selector)\n\t\t\tif err != nil {\n\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetObjectMetric\", err.Error())\n\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetObjectMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get object metric value: %v\", err)\n\t\t\t}\n\t\t\tmetricNameProposal = fmt.Sprintf(\"%s metric %s\", metricSpec.Object.Target.Kind, metricSpec.Object.MetricName)\n\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\tType: autoscalingv2.ObjectMetricSourceType,\n\t\t\t\tObject: &autoscalingv2.ObjectMetricStatus{\n\t\t\t\t\tTarget: metricSpec.Object.Target,\n\t\t\t\t\tMetricName: metricSpec.Object.MetricName,\n\t\t\t\t\tCurrentValue: *resource.NewMilliQuantity(utilizationProposal, resource.DecimalSI),\n\t\t\t\t},\n\t\t\t}\n\t\tcase autoscalingv2.PodsMetricSourceType:\n\t\t\treplicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetMetricReplicas(currentReplicas, metricSpec.Pods.TargetAverageValue.MilliValue(), metricSpec.Pods.MetricName, hpa.Namespace, selector)\n\t\t\tif err != nil {\n\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetPodsMetric\", err.Error())\n\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetPodsMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get pods metric value: %v\", err)\n\t\t\t}\n\t\t\tmetricNameProposal = fmt.Sprintf(\"pods metric %s\", metricSpec.Pods.MetricName)\n\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\tType: autoscalingv2.PodsMetricSourceType,\n\t\t\t\tPods: &autoscalingv2.PodsMetricStatus{\n\t\t\t\t\tMetricName: metricSpec.Pods.MetricName,\n\t\t\t\t\tCurrentAverageValue: *resource.NewMilliQuantity(utilizationProposal, resource.DecimalSI),\n\t\t\t\t},\n\t\t\t}\n\t\tcase autoscalingv2.ResourceMetricSourceType:\n\t\t\tif metricSpec.Resource.TargetAverageValue != nil {\n\t\t\t\tvar rawProposal int64\n\t\t\t\treplicaCountProposal, rawProposal, timestampProposal, err = a.replicaCalc.GetRawResourceReplicas(currentReplicas, metricSpec.Resource.TargetAverageValue.MilliValue(), metricSpec.Resource.Name, hpa.Namespace, selector)\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetResourceMetric\", err.Error())\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetResourceMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get %s utilization: %v\", metricSpec.Resource.Name, err)\n\t\t\t\t}\n\t\t\t\tmetricNameProposal = fmt.Sprintf(\"%s resource\", metricSpec.Resource.Name)\n\t\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\t\tType: autoscalingv2.ResourceMetricSourceType,\n\t\t\t\t\tResource: &autoscalingv2.ResourceMetricStatus{\n\t\t\t\t\t\tName: metricSpec.Resource.Name,\n\t\t\t\t\t\tCurrentAverageValue: *resource.NewMilliQuantity(rawProposal, resource.DecimalSI),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// set a default utilization percentage if none is set\n\t\t\t\tif metricSpec.Resource.TargetAverageUtilization == nil {\n\t\t\t\t\terrMsg := \"invalid resource metric source: neither a utilization target nor a value target was set\"\n\t\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetResourceMetric\", errMsg)\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetResourceMetric\", \"the HPA was unable to compute the replica count: %s\", errMsg)\n\t\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(errMsg)\n\t\t\t\t}\n\n\t\t\t\ttargetUtilization := *metricSpec.Resource.TargetAverageUtilization\n\n\t\t\t\tvar percentageProposal int32\n\t\t\t\tvar rawProposal int64\n\t\t\t\treplicaCountProposal, percentageProposal, rawProposal, timestampProposal, err = a.replicaCalc.GetResourceReplicas(currentReplicas, targetUtilization, metricSpec.Resource.Name, hpa.Namespace, selector)\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetResourceMetric\", err.Error())\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetResourceMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get %s utilization: %v\", metricSpec.Resource.Name, err)\n\t\t\t\t}\n\t\t\t\tmetricNameProposal = fmt.Sprintf(\"%s resource utilization (percentage of request)\", metricSpec.Resource.Name)\n\t\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\t\tType: autoscalingv2.ResourceMetricSourceType,\n\t\t\t\t\tResource: &autoscalingv2.ResourceMetricStatus{\n\t\t\t\t\t\tName: metricSpec.Resource.Name,\n\t\t\t\t\t\tCurrentAverageUtilization: &percentageProposal,\n\t\t\t\t\t\tCurrentAverageValue: *resource.NewMilliQuantity(rawProposal, resource.DecimalSI),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\tcase autoscalingv2.ExternalMetricSourceType:\n\t\t\tif metricSpec.External.TargetAverageValue != nil {\n\t\t\t\treplicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetExternalPerPodMetricReplicas(currentReplicas, metricSpec.External.TargetAverageValue.MilliValue(), metricSpec.External.MetricName, hpa.Namespace, metricSpec.External.MetricSelector)\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetExternalMetric\", err.Error())\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetExternalMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get %s external metric: %v\", metricSpec.External.MetricName, err)\n\t\t\t\t}\n\t\t\t\tmetricNameProposal = fmt.Sprintf(\"external metric %s(%+v)\", metricSpec.External.MetricName, metricSpec.External.MetricSelector)\n\t\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\t\tType: autoscalingv2.ExternalMetricSourceType,\n\t\t\t\t\tExternal: &autoscalingv2.ExternalMetricStatus{\n\t\t\t\t\t\tMetricSelector: metricSpec.External.MetricSelector,\n\t\t\t\t\t\tMetricName: metricSpec.External.MetricName,\n\t\t\t\t\t\tCurrentAverageValue: resource.NewMilliQuantity(utilizationProposal, resource.DecimalSI),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t} else if metricSpec.External.TargetValue != nil {\n\t\t\t\treplicaCountProposal, utilizationProposal, timestampProposal, err = a.replicaCalc.GetExternalMetricReplicas(currentReplicas, metricSpec.External.TargetValue.MilliValue(), metricSpec.External.MetricName, hpa.Namespace, metricSpec.External.MetricSelector, selector)\n\t\t\t\tif err != nil {\n\t\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetExternalMetric\", err.Error())\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetExternalMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(\"failed to get external metric %s: %v\", metricSpec.External.MetricName, err)\n\t\t\t\t}\n\t\t\t\tmetricNameProposal = fmt.Sprintf(\"external metric %s(%+v)\", metricSpec.External.MetricName, metricSpec.External.MetricSelector)\n\t\t\t\tstatuses[i] = autoscalingv2.MetricStatus{\n\t\t\t\t\tType: autoscalingv2.ExternalMetricSourceType,\n\t\t\t\t\tExternal: &autoscalingv2.ExternalMetricStatus{\n\t\t\t\t\t\tMetricSelector: metricSpec.External.MetricSelector,\n\t\t\t\t\t\tMetricName: metricSpec.External.MetricName,\n\t\t\t\t\t\tCurrentValue: *resource.NewMilliQuantity(utilizationProposal, resource.DecimalSI),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terrMsg := \"invalid external metric source: neither a value target nor an average value target was set\"\n\t\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetExternalMetric\", errMsg)\n\t\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"FailedGetExternalMetric\", \"the HPA was unable to compute the replica count: %v\", err)\n\t\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(errMsg)\n\t\t\t}\n\t\tdefault:\n\t\t\terrMsg := fmt.Sprintf(\"unknown metric source type %q\", string(metricSpec.Type))\n\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"InvalidMetricSourceType\", errMsg)\n\t\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"InvalidMetricSourceType\", \"the HPA was unable to compute the replica count: %s\", errMsg)\n\t\t\treturn 0, \"\", nil, time.Time{}, fmt.Errorf(errMsg)\n\t\t}\n\n\t\tif replicas == 0 || replicaCountProposal > replicas {\n\t\t\ttimestamp = timestampProposal\n\t\t\treplicas = replicaCountProposal\n\t\t\tmetric = metricNameProposal\n\t\t}\n\t}\n\n\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionTrue, \"ValidMetricFound\", \"the HPA was able to successfully calculate a replica count from %s\", metric)\n\treturn replicas, metric, statuses, timestamp, nil\n}\n\nfunc (a *HorizontalController) reconcileKey(key string) error {\n\tnamespace, name, err := cache.SplitMetaNamespaceKey(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\thpa, err := a.hpaLister.HorizontalPodAutoscalers(namespace).Get(name)\n\tif errors.IsNotFound(err) {\n\t\tglog.Infof(\"Horizontal Pod Autoscaler has been deleted %v\", key)\n\t\treturn nil\n\t}\n\n\treturn a.reconcileAutoscaler(hpa)\n}\n\nfunc (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.HorizontalPodAutoscaler) error {\n\t// make a copy so that we never mutate the shared informer cache (conversion can mutate the object)\n\thpav1 := hpav1Shared.DeepCopy()\n\t// then, convert to autoscaling/v2, which makes our lives easier when calculating metrics\n\thpaRaw, err := unsafeConvertToVersionVia(hpav1, autoscalingv2.SchemeGroupVersion)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpav1, v1.EventTypeWarning, \"FailedConvertHPA\", err.Error())\n\t\treturn fmt.Errorf(\"failed to convert the given HPA to %s: %v\", autoscalingv2.SchemeGroupVersion.String(), err)\n\t}\n\thpa := hpaRaw.(*autoscalingv2.HorizontalPodAutoscaler)\n\thpaStatusOriginal := hpa.Status.DeepCopy()\n\n\treference := fmt.Sprintf(\"%s/%s/%s\", hpa.Spec.ScaleTargetRef.Kind, hpa.Namespace, hpa.Spec.ScaleTargetRef.Name)\n\n\ttargetGV, err := schema.ParseGroupVersion(hpa.Spec.ScaleTargetRef.APIVersion)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetScale\", err.Error())\n\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"FailedGetScale\", \"the HPA controller was unable to get the target's current scale: %v\", err)\n\t\ta.updateStatusIfNeeded(hpaStatusOriginal, hpa)\n\t\treturn fmt.Errorf(\"invalid API version in scale target reference: %v\", err)\n\t}\n\n\ttargetGK := schema.GroupKind{\n\t\tGroup: targetGV.Group,\n\t\tKind: hpa.Spec.ScaleTargetRef.Kind,\n\t}\n\n\tmappings, err := a.mapper.RESTMappings(targetGK)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetScale\", err.Error())\n\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"FailedGetScale\", \"the HPA controller was unable to get the target's current scale: %v\", err)\n\t\ta.updateStatusIfNeeded(hpaStatusOriginal, hpa)\n\t\treturn fmt.Errorf(\"unable to determine resource for scale target reference: %v\", err)\n\t}\n\n\tscale, targetGR, err := a.scaleForResourceMappings(hpa.Namespace, hpa.Spec.ScaleTargetRef.Name, mappings)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedGetScale\", err.Error())\n\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"FailedGetScale\", \"the HPA controller was unable to get the target's current scale: %v\", err)\n\t\ta.updateStatusIfNeeded(hpaStatusOriginal, hpa)\n\t\treturn fmt.Errorf(\"failed to query scale subresource for %s: %v\", reference, err)\n\t}\n\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionTrue, \"SucceededGetScale\", \"the HPA controller was able to get the target's current scale\")\n\tcurrentReplicas := scale.Status.Replicas\n\n\tvar metricStatuses []autoscalingv2.MetricStatus\n\tmetricDesiredReplicas := int32(0)\n\tmetricName := \"\"\n\tmetricTimestamp := time.Time{}\n\n\tdesiredReplicas := int32(0)\n\trescaleReason := \"\"\n\ttimestamp := time.Now()\n\n\trescale := true\n\n\tif scale.Spec.Replicas == 0 {\n\t\t// Autoscaling is disabled for this resource\n\t\tdesiredReplicas = 0\n\t\trescale = false\n\t\tsetCondition(hpa, autoscalingv2.ScalingActive, v1.ConditionFalse, \"ScalingDisabled\", \"scaling is disabled since the replica count of the target is zero\")\n\t} else if currentReplicas > hpa.Spec.MaxReplicas {\n\t\trescaleReason = \"Current number of replicas above Spec.MaxReplicas\"\n\t\tdesiredReplicas = hpa.Spec.MaxReplicas\n\t} else if hpa.Spec.MinReplicas != nil && currentReplicas < *hpa.Spec.MinReplicas {\n\t\trescaleReason = \"Current number of replicas below Spec.MinReplicas\"\n\t\tdesiredReplicas = *hpa.Spec.MinReplicas\n\t} else if currentReplicas == 0 {\n\t\trescaleReason = \"Current number of replicas must be greater than 0\"\n\t\tdesiredReplicas = 1\n\t} else {\n\t\tmetricDesiredReplicas, metricName, metricStatuses, metricTimestamp, err = a.computeReplicasForMetrics(hpa, scale, hpa.Spec.Metrics)\n\t\tif err != nil {\n\t\t\ta.setCurrentReplicasInStatus(hpa, currentReplicas)\n\t\t\tif err := a.updateStatusIfNeeded(hpaStatusOriginal, hpa); err != nil {\n\t\t\t\tutilruntime.HandleError(err)\n\t\t\t}\n\t\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedComputeMetricsReplicas\", err.Error())\n\t\t\treturn fmt.Errorf(\"failed to compute desired number of replicas based on listed metrics for %s: %v\", reference, err)\n\t\t}\n\n\t\tglog.V(4).Infof(\"proposing %v desired replicas (based on %s from %s) for %s\", metricDesiredReplicas, metricName, timestamp, reference)\n\n\t\trescaleMetric := \"\"\n\t\tif metricDesiredReplicas > desiredReplicas {\n\t\t\tdesiredReplicas = metricDesiredReplicas\n\t\t\ttimestamp = metricTimestamp\n\t\t\trescaleMetric = metricName\n\t\t}\n\t\tif desiredReplicas > currentReplicas {\n\t\t\trescaleReason = fmt.Sprintf(\"%s above target\", rescaleMetric)\n\t\t}\n\t\tif desiredReplicas < currentReplicas {\n\t\t\trescaleReason = \"All metrics below target\"\n\t\t}\n\n\t\tdesiredReplicas = a.normalizeDesiredReplicas(hpa, currentReplicas, desiredReplicas)\n\n\t\trescale = a.shouldScale(hpa, currentReplicas, desiredReplicas, timestamp)\n\t\tbackoffDown := false\n\t\tbackoffUp := false\n\t\tif hpa.Status.LastScaleTime != nil {\n\t\t\tif !hpa.Status.LastScaleTime.Add(a.downscaleForbiddenWindow).Before(timestamp) {\n\t\t\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"BackoffDownscale\", \"the time since the previous scale is still within the downscale forbidden window\")\n\t\t\t\tbackoffDown = true\n\t\t\t}\n\n\t\t\tif !hpa.Status.LastScaleTime.Add(a.upscaleForbiddenWindow).Before(timestamp) {\n\t\t\t\tbackoffUp = true\n\t\t\t\tif backoffDown {\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"BackoffBoth\", \"the time since the previous scale is still within both the downscale and upscale forbidden windows\")\n\t\t\t\t} else {\n\t\t\t\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"BackoffUpscale\", \"the time since the previous scale is still within the upscale forbidden window\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif !backoffDown && !backoffUp {\n\t\t\t// mark that we're not backing off\n\t\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionTrue, \"ReadyForNewScale\", \"the last scale time was sufficiently old as to warrant a new scale\")\n\t\t}\n\n\t}\n\n\tif rescale {\n\t\tscale.Spec.Replicas = desiredReplicas\n\t\t_, err = a.scaleNamespacer.Scales(hpa.Namespace).Update(targetGR, scale)\n\t\tif err != nil {\n\t\t\ta.eventRecorder.Eventf(hpa, v1.EventTypeWarning, \"FailedRescale\", \"New size: %d; reason: %s; error: %v\", desiredReplicas, rescaleReason, err.Error())\n\t\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionFalse, \"FailedUpdateScale\", \"the HPA controller was unable to update the target scale: %v\", err)\n\t\t\ta.setCurrentReplicasInStatus(hpa, currentReplicas)\n\t\t\tif err := a.updateStatusIfNeeded(hpaStatusOriginal, hpa); err != nil {\n\t\t\t\tutilruntime.HandleError(err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to rescale %s: %v\", reference, err)\n\t\t}\n\t\tsetCondition(hpa, autoscalingv2.AbleToScale, v1.ConditionTrue, \"SucceededRescale\", \"the HPA controller was able to update the target scale to %d\", desiredReplicas)\n\t\ta.eventRecorder.Eventf(hpa, v1.EventTypeNormal, \"SuccessfulRescale\", \"New size: %d; reason: %s\", desiredReplicas, rescaleReason)\n\t\tglog.Infof(\"Successful rescale of %s, old size: %d, new size: %d, reason: %s\",\n\t\t\thpa.Name, currentReplicas, desiredReplicas, rescaleReason)\n\t} else {\n\t\tglog.V(4).Infof(\"decided not to scale %s to %v (last scale time was %s)\", reference, desiredReplicas, hpa.Status.LastScaleTime)\n\t\tdesiredReplicas = currentReplicas\n\t}\n\n\ta.setStatus(hpa, currentReplicas, desiredReplicas, metricStatuses, rescale)\n\treturn a.updateStatusIfNeeded(hpaStatusOriginal, hpa)\n}\n\n// normalizeDesiredReplicas takes the metrics desired replicas value and normalizes it based on the appropriate conditions (i.e. < maxReplicas, >\n// minReplicas, etc...)\nfunc (a *HorizontalController) normalizeDesiredReplicas(hpa *autoscalingv2.HorizontalPodAutoscaler, currentReplicas int32, prenormalizedDesiredReplicas int32) int32 {\n\tvar minReplicas int32\n\tif hpa.Spec.MinReplicas != nil {\n\t\tminReplicas = *hpa.Spec.MinReplicas\n\t} else {\n\t\tminReplicas = 0\n\t}\n\n\tdesiredReplicas, condition, reason := convertDesiredReplicasWithRules(currentReplicas, prenormalizedDesiredReplicas, minReplicas, hpa.Spec.MaxReplicas)\n\n\tif desiredReplicas == prenormalizedDesiredReplicas {\n\t\tsetCondition(hpa, autoscalingv2.ScalingLimited, v1.ConditionFalse, condition, reason)\n\t} else {\n\t\tsetCondition(hpa, autoscalingv2.ScalingLimited, v1.ConditionTrue, condition, reason)\n\t}\n\n\treturn desiredReplicas\n}\n\n// convertDesiredReplicas performs the actual normalization, without depending on `HorizontalController` or `HorizontalPodAutoscaler`\nfunc convertDesiredReplicasWithRules(currentReplicas, desiredReplicas, hpaMinReplicas, hpaMaxReplicas int32) (int32, string, string) {\n\n\tvar minimumAllowedReplicas int32\n\tvar maximumAllowedReplicas int32\n\n\tvar possibleLimitingCondition string\n\tvar possibleLimitingReason string\n\n\tif hpaMinReplicas == 0 {\n\t\tminimumAllowedReplicas = 1\n\t\tpossibleLimitingReason = \"the desired replica count is zero\"\n\t} else {\n\t\tminimumAllowedReplicas = hpaMinReplicas\n\t\tpossibleLimitingReason = \"the desired replica count is less than the minimum replica count\"\n\t}\n\n\t// Do not upscale too much to prevent incorrect rapid increase of the number of master replicas caused by\n\t// bogus CPU usage report from heapster/kubelet (like in issue #32304).\n\tscaleUpLimit := calculateScaleUpLimit(currentReplicas)\n\n\tif hpaMaxReplicas > scaleUpLimit {\n\t\tmaximumAllowedReplicas = scaleUpLimit\n\n\t\tpossibleLimitingCondition = \"ScaleUpLimit\"\n\t\tpossibleLimitingReason = \"the desired replica count is increasing faster than the maximum scale rate\"\n\t} else {\n\t\tmaximumAllowedReplicas = hpaMaxReplicas\n\n\t\tpossibleLimitingCondition = \"TooManyReplicas\"\n\t\tpossibleLimitingReason = \"the desired replica count is more than the maximum replica count\"\n\t}\n\n\tif desiredReplicas < minimumAllowedReplicas {\n\t\tpossibleLimitingCondition = \"TooFewReplicas\"\n\n\t\treturn minimumAllowedReplicas, possibleLimitingCondition, possibleLimitingReason\n\t} else if desiredReplicas > maximumAllowedReplicas {\n\t\treturn maximumAllowedReplicas, possibleLimitingCondition, possibleLimitingReason\n\t}\n\n\treturn desiredReplicas, \"DesiredWithinRange\", \"the desired count is within the acceptable range\"\n}\n\nfunc calculateScaleUpLimit(currentReplicas int32) int32 {\n\treturn int32(math.Max(scaleUpLimitFactor*float64(currentReplicas), scaleUpLimitMinimum))\n}\n\nfunc (a *HorizontalController) shouldScale(hpa *autoscalingv2.HorizontalPodAutoscaler, currentReplicas, desiredReplicas int32, timestamp time.Time) bool {\n\tif desiredReplicas == currentReplicas {\n\t\treturn false\n\t}\n\n\tif hpa.Status.LastScaleTime == nil {\n\t\treturn true\n\t}\n\n\t// Going down only if the usageRatio dropped significantly below the target\n\t// and there was no rescaling in the last downscaleForbiddenWindow.\n\tif desiredReplicas < currentReplicas && hpa.Status.LastScaleTime.Add(a.downscaleForbiddenWindow).Before(timestamp) {\n\t\treturn true\n\t}\n\n\t// Going up only if the usage ratio increased significantly above the target\n\t// and there was no rescaling in the last upscaleForbiddenWindow.\n\tif desiredReplicas > currentReplicas && hpa.Status.LastScaleTime.Add(a.upscaleForbiddenWindow).Before(timestamp) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n// scaleForResourceMappings attempts to fetch the scale for the\n// resource with the given name and namespace, trying each RESTMapping\n// in turn until a working one is found. If none work, the first error\n// is returned. It returns both the scale, as well as the group-resource from\n// the working mapping.\nfunc (a *HorizontalController) scaleForResourceMappings(namespace, name string, mappings []*apimeta.RESTMapping) (*autoscalingv1.Scale, schema.GroupResource, error) {\n\tvar firstErr error\n\tfor i, mapping := range mappings {\n\t\ttargetGR := mapping.Resource.GroupResource()\n\t\tscale, err := a.scaleNamespacer.Scales(namespace).Get(targetGR, name)\n\t\tif err == nil {\n\t\t\treturn scale, targetGR, nil\n\t\t}\n\n\t\t// if this is the first error, remember it,\n\t\t// then go on and try other mappings until we find a good one\n\t\tif i == 0 {\n\t\t\tfirstErr = err\n\t\t}\n\t}\n\n\t// make sure we handle an empty set of mappings\n\tif firstErr == nil {\n\t\tfirstErr = fmt.Errorf(\"unrecognized resource\")\n\t}\n\n\treturn nil, schema.GroupResource{}, firstErr\n}\n\n// setCurrentReplicasInStatus sets the current replica count in the status of the HPA.\nfunc (a *HorizontalController) setCurrentReplicasInStatus(hpa *autoscalingv2.HorizontalPodAutoscaler, currentReplicas int32) {\n\ta.setStatus(hpa, currentReplicas, hpa.Status.DesiredReplicas, hpa.Status.CurrentMetrics, false)\n}\n\n// setStatus recreates the status of the given HPA, updating the current and\n// desired replicas, as well as the metric statuses\nfunc (a *HorizontalController) setStatus(hpa *autoscalingv2.HorizontalPodAutoscaler, currentReplicas, desiredReplicas int32, metricStatuses []autoscalingv2.MetricStatus, rescale bool) {\n\thpa.Status = autoscalingv2.HorizontalPodAutoscalerStatus{\n\t\tCurrentReplicas: currentReplicas,\n\t\tDesiredReplicas: desiredReplicas,\n\t\tLastScaleTime: hpa.Status.LastScaleTime,\n\t\tCurrentMetrics: metricStatuses,\n\t\tConditions: hpa.Status.Conditions,\n\t}\n\n\tif rescale {\n\t\tnow := metav1.NewTime(time.Now())\n\t\thpa.Status.LastScaleTime = &now\n\t}\n}\n\n// updateStatusIfNeeded calls updateStatus only if the status of the new HPA is not the same as the old status\nfunc (a *HorizontalController) updateStatusIfNeeded(oldStatus *autoscalingv2.HorizontalPodAutoscalerStatus, newHPA *autoscalingv2.HorizontalPodAutoscaler) error {\n\t// skip a write if we wouldn't need to update\n\tif apiequality.Semantic.DeepEqual(oldStatus, &newHPA.Status) {\n\t\treturn nil\n\t}\n\treturn a.updateStatus(newHPA)\n}\n\n// updateStatus actually does the update request for the status of the given HPA\nfunc (a *HorizontalController) updateStatus(hpa *autoscalingv2.HorizontalPodAutoscaler) error {\n\t// convert back to autoscalingv1\n\thpaRaw, err := unsafeConvertToVersionVia(hpa, autoscalingv1.SchemeGroupVersion)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedConvertHPA\", err.Error())\n\t\treturn fmt.Errorf(\"failed to convert the given HPA to %s: %v\", autoscalingv2.SchemeGroupVersion.String(), err)\n\t}\n\thpav1 := hpaRaw.(*autoscalingv1.HorizontalPodAutoscaler)\n\n\t_, err = a.hpaNamespacer.HorizontalPodAutoscalers(hpav1.Namespace).UpdateStatus(hpav1)\n\tif err != nil {\n\t\ta.eventRecorder.Event(hpa, v1.EventTypeWarning, \"FailedUpdateStatus\", err.Error())\n\t\treturn fmt.Errorf(\"failed to update status for %s: %v\", hpa.Name, err)\n\t}\n\tglog.V(2).Infof(\"Successfully updated status for %s\", hpa.Name)\n\treturn nil\n}\n\n// unsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first.\n// We use it since working with v2alpha1 is convenient here, but we want to use the v1 client (and\n// can't just use the internal version). Note that conversion mutates the object, so you need to deepcopy\n// *before* you call this if the input object came out of a shared cache.\nfunc unsafeConvertToVersionVia(obj runtime.Object, externalVersion schema.GroupVersion) (runtime.Object, error) {\n\tobjInt, err := legacyscheme.Scheme.UnsafeConvertToVersion(obj, schema.GroupVersion{Group: externalVersion.Group, Version: runtime.APIVersionInternal})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to convert the given object to the internal version: %v\", err)\n\t}\n\n\tobjExt, err := legacyscheme.Scheme.UnsafeConvertToVersion(objInt, externalVersion)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to convert the given object back to the external version: %v\", err)\n\t}\n\n\treturn objExt, err\n}\n\n// setCondition sets the specific condition type on the given HPA to the specified value with the given reason\n// and message. The message and args are treated like a format string. The condition will be added if it is\n// not present.\nfunc setCondition(hpa *autoscalingv2.HorizontalPodAutoscaler, conditionType autoscalingv2.HorizontalPodAutoscalerConditionType, status v1.ConditionStatus, reason, message string, args ...interface{}) {\n\thpa.Status.Conditions = setConditionInList(hpa.Status.Conditions, conditionType, status, reason, message, args...)\n}\n\n// setConditionInList sets the specific condition type on the given HPA to the specified value with the given\n// reason and message. The message and args are treated like a format string. The condition will be added if\n// it is not present. The new list will be returned.\nfunc setConditionInList(inputList []autoscalingv2.HorizontalPodAutoscalerCondition, conditionType autoscalingv2.HorizontalPodAutoscalerConditionType, status v1.ConditionStatus, reason, message string, args ...interface{}) []autoscalingv2.HorizontalPodAutoscalerCondition {\n\tresList := inputList\n\tvar existingCond *autoscalingv2.HorizontalPodAutoscalerCondition\n\tfor i, condition := range resList {\n\t\tif condition.Type == conditionType {\n\t\t\t// can't take a pointer to an iteration variable\n\t\t\texistingCond = &resList[i]\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif existingCond == nil {\n\t\tresList = append(resList, autoscalingv2.HorizontalPodAutoscalerCondition{\n\t\t\tType: conditionType,\n\t\t})\n\t\texistingCond = &resList[len(resList)-1]\n\t}\n\n\tif existingCond.Status != status {\n\t\texistingCond.LastTransitionTime = metav1.Now()\n\t}\n\n\texistingCond.Status = status\n\texistingCond.Reason = reason\n\texistingCond.Message = fmt.Sprintf(message, args...)\n\n\treturn resList\n}\n"},"repo_name":{"kind":"string","value":"victorgp/kubernetes"},"path":{"kind":"string","value":"pkg/controller/podautoscaler/horizontal.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":33818,"string":"33,818"}}},{"rowIdx":61538428,"cells":{"code":{"kind":"string","value":"// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#include \"chrome/browser/ui/global_error/global_error_service.h\"\n\n#include \n\n#include \"base/stl_util.h\"\n#include \"chrome/browser/chrome_notification_types.h\"\n#include \"chrome/browser/profiles/profile.h\"\n#include \"chrome/browser/ui/global_error/global_error.h\"\n#include \"chrome/browser/ui/global_error/global_error_bubble_view_base.h\"\n#include \"content/public/browser/notification_service.h\"\n\nGlobalErrorService::GlobalErrorService(Profile* profile) : profile_(profile) {\n}\n\nGlobalErrorService::~GlobalErrorService() {\n STLDeleteElements(&errors_);\n}\n\nvoid GlobalErrorService::AddGlobalError(GlobalError* error) {\n errors_.push_back(error);\n NotifyErrorsChanged(error);\n}\n\nvoid GlobalErrorService::RemoveGlobalError(GlobalError* error) {\n errors_.erase(std::find(errors_.begin(), errors_.end(), error));\n GlobalErrorBubbleViewBase* bubble = error->GetBubbleView();\n if (bubble)\n bubble->CloseBubbleView();\n NotifyErrorsChanged(error);\n}\n\nGlobalError* GlobalErrorService::GetGlobalErrorByMenuItemCommandID(\n int command_id) const {\n for (GlobalErrorList::const_iterator\n it = errors_.begin(); it != errors_.end(); ++it) {\n GlobalError* error = *it;\n if (error->HasMenuItem() && command_id == error->MenuItemCommandID())\n return error;\n }\n return NULL;\n}\n\nGlobalError*\nGlobalErrorService::GetHighestSeverityGlobalErrorWithWrenchMenuItem() const {\n GlobalError::Severity highest_severity = GlobalError::SEVERITY_LOW;\n GlobalError* highest_severity_error = NULL;\n\n for (GlobalErrorList::const_iterator\n it = errors_.begin(); it != errors_.end(); ++it) {\n GlobalError* error = *it;\n if (error->HasMenuItem()) {\n if (!highest_severity_error || error->GetSeverity() > highest_severity) {\n highest_severity = error->GetSeverity();\n highest_severity_error = error;\n }\n }\n }\n\n return highest_severity_error;\n}\n\nGlobalError* GlobalErrorService::GetFirstGlobalErrorWithBubbleView() const {\n for (GlobalErrorList::const_iterator\n it = errors_.begin(); it != errors_.end(); ++it) {\n GlobalError* error = *it;\n if (error->HasBubbleView() && !error->HasShownBubbleView())\n return error;\n }\n return NULL;\n}\n\nvoid GlobalErrorService::NotifyErrorsChanged(GlobalError* error) {\n // GlobalErrorService is bound only to original profile so we need to send\n // notifications to both it and its off-the-record profile to update\n // incognito windows as well.\n std::vector profiles_to_notify;\n if (profile_ != NULL) {\n profiles_to_notify.push_back(profile_);\n if (profile_->IsOffTheRecord())\n profiles_to_notify.push_back(profile_->GetOriginalProfile());\n else if (profile_->HasOffTheRecordProfile())\n profiles_to_notify.push_back(profile_->GetOffTheRecordProfile());\n for (size_t i = 0; i < profiles_to_notify.size(); ++i) {\n content::NotificationService::current()->Notify(\n chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,\n content::Source(profiles_to_notify[i]),\n content::Details(error));\n }\n }\n}\n"},"repo_name":{"kind":"string","value":"aospx-kitkat/platform_external_chromium_org"},"path":{"kind":"string","value":"chrome/browser/ui/global_error/global_error_service.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":3238,"string":"3,238"}}},{"rowIdx":61538429,"cells":{"code":{"kind":"string","value":"// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#include \"google_apis/gaia/gaia_oauth_client.h\"\n\n#include \"base/json/json_reader.h\"\n#include \"base/logging.h\"\n#include \"base/memory/scoped_ptr.h\"\n#include \"base/strings/string_util.h\"\n#include \"base/values.h\"\n#include \"google_apis/gaia/gaia_urls.h\"\n#include \"net/base/escape.h\"\n#include \"net/base/load_flags.h\"\n#include \"net/http/http_status_code.h\"\n#include \"net/url_request/url_fetcher.h\"\n#include \"net/url_request/url_fetcher_delegate.h\"\n#include \"net/url_request/url_request_context_getter.h\"\n#include \"url/gurl.h\"\n\nnamespace {\nconst char kAccessTokenValue[] = \"access_token\";\nconst char kRefreshTokenValue[] = \"refresh_token\";\nconst char kExpiresInValue[] = \"expires_in\";\n}\n\nnamespace gaia {\n\n// Use a non-zero number, so unit tests can differentiate the URLFetcher used by\n// this class from other fetchers (most other code just hardcodes the ID to 0).\nconst int GaiaOAuthClient::kUrlFetcherId = 17109006;\n\nclass GaiaOAuthClient::Core\n : public base::RefCountedThreadSafe,\n public net::URLFetcherDelegate {\n public:\n Core(net::URLRequestContextGetter* request_context_getter)\n : num_retries_(0),\n request_context_getter_(request_context_getter),\n delegate_(NULL),\n request_type_(NO_PENDING_REQUEST) {\n }\n\n void GetTokensFromAuthCode(const OAuthClientInfo& oauth_client_info,\n const std::string& auth_code,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate);\n void RefreshToken(const OAuthClientInfo& oauth_client_info,\n const std::string& refresh_token,\n const std::vector& scopes,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate);\n void GetUserEmail(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate);\n void GetUserId(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate);\n void GetTokenInfo(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate);\n\n // net::URLFetcherDelegate implementation.\n virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;\n\n private:\n friend class base::RefCountedThreadSafe;\n\n enum RequestType {\n NO_PENDING_REQUEST,\n TOKENS_FROM_AUTH_CODE,\n REFRESH_TOKEN,\n TOKEN_INFO,\n USER_EMAIL,\n USER_ID,\n };\n\n virtual ~Core() {}\n\n void GetUserInfo(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate);\n void MakeGaiaRequest(const GURL& url,\n const std::string& post_body,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate);\n void HandleResponse(const net::URLFetcher* source,\n bool* should_retry_request);\n\n int num_retries_;\n scoped_refptr request_context_getter_;\n GaiaOAuthClient::Delegate* delegate_;\n scoped_ptr request_;\n RequestType request_type_;\n};\n\nvoid GaiaOAuthClient::Core::GetTokensFromAuthCode(\n const OAuthClientInfo& oauth_client_info,\n const std::string& auth_code,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate) {\n DCHECK_EQ(request_type_, NO_PENDING_REQUEST);\n request_type_ = TOKENS_FROM_AUTH_CODE;\n std::string post_body =\n \"code=\" + net::EscapeUrlEncodedData(auth_code, true) +\n \"&client_id=\" + net::EscapeUrlEncodedData(oauth_client_info.client_id,\n true) +\n \"&client_secret=\" +\n net::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +\n \"&redirect_uri=\" +\n net::EscapeUrlEncodedData(oauth_client_info.redirect_uri, true) +\n \"&grant_type=authorization_code\";\n MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()),\n post_body, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::Core::RefreshToken(\n const OAuthClientInfo& oauth_client_info,\n const std::string& refresh_token,\n const std::vector& scopes,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate) {\n DCHECK_EQ(request_type_, NO_PENDING_REQUEST);\n request_type_ = REFRESH_TOKEN;\n std::string post_body =\n \"refresh_token=\" + net::EscapeUrlEncodedData(refresh_token, true) +\n \"&client_id=\" + net::EscapeUrlEncodedData(oauth_client_info.client_id,\n true) +\n \"&client_secret=\" +\n net::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +\n \"&grant_type=refresh_token\";\n\n if (!scopes.empty()) {\n std::string scopes_string = JoinString(scopes, ' ');\n post_body += \"&scope=\" + net::EscapeUrlEncodedData(scopes_string, true);\n }\n\n MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_url()),\n post_body, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::Core::GetUserEmail(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate) {\n DCHECK_EQ(request_type_, NO_PENDING_REQUEST);\n DCHECK(!request_.get());\n request_type_ = USER_EMAIL;\n GetUserInfo(oauth_access_token, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::Core::GetUserId(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate) {\n DCHECK_EQ(request_type_, NO_PENDING_REQUEST);\n DCHECK(!request_.get());\n request_type_ = USER_ID;\n GetUserInfo(oauth_access_token, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::Core::GetUserInfo(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate) {\n delegate_ = delegate;\n num_retries_ = 0;\n request_.reset(net::URLFetcher::Create(\n kUrlFetcherId, GURL(GaiaUrls::GetInstance()->oauth_user_info_url()),\n net::URLFetcher::GET, this));\n request_->SetRequestContext(request_context_getter_.get());\n request_->AddExtraRequestHeader(\"Authorization: OAuth \" + oauth_access_token);\n request_->SetMaxRetriesOn5xx(max_retries);\n request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |\n net::LOAD_DO_NOT_SAVE_COOKIES);\n\n // Fetchers are sometimes cancelled because a network change was detected,\n // especially at startup and after sign-in on ChromeOS. Retrying once should\n // be enough in those cases; let the fetcher retry up to 3 times just in case.\n // http://crbug.com/163710\n request_->SetAutomaticallyRetryOnNetworkChanges(3);\n request_->Start();\n}\n\nvoid GaiaOAuthClient::Core::GetTokenInfo(const std::string& oauth_access_token,\n int max_retries,\n Delegate* delegate) {\n DCHECK_EQ(request_type_, NO_PENDING_REQUEST);\n DCHECK(!request_.get());\n request_type_ = TOKEN_INFO;\n std::string post_body =\n \"access_token=\" + net::EscapeUrlEncodedData(oauth_access_token, true);\n MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()),\n post_body,\n max_retries,\n delegate);\n}\n\nvoid GaiaOAuthClient::Core::MakeGaiaRequest(\n const GURL& url,\n const std::string& post_body,\n int max_retries,\n GaiaOAuthClient::Delegate* delegate) {\n DCHECK(!request_.get()) << \"Tried to fetch two things at once!\";\n delegate_ = delegate;\n num_retries_ = 0;\n request_.reset(net::URLFetcher::Create(\n kUrlFetcherId, url, net::URLFetcher::POST, this));\n request_->SetRequestContext(request_context_getter_.get());\n request_->SetUploadData(\"application/x-www-form-urlencoded\", post_body);\n request_->SetMaxRetriesOn5xx(max_retries);\n request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |\n net::LOAD_DO_NOT_SAVE_COOKIES);\n // See comment on SetAutomaticallyRetryOnNetworkChanges() above.\n request_->SetAutomaticallyRetryOnNetworkChanges(3);\n request_->Start();\n}\n\n// URLFetcher::Delegate implementation.\nvoid GaiaOAuthClient::Core::OnURLFetchComplete(\n const net::URLFetcher* source) {\n bool should_retry = false;\n HandleResponse(source, &should_retry);\n if (should_retry) {\n // Explicitly call ReceivedContentWasMalformed() to ensure the current\n // request gets counted as a failure for calculation of the back-off\n // period. If it was already a failure by status code, this call will\n // be ignored.\n request_->ReceivedContentWasMalformed();\n num_retries_++;\n // We must set our request_context_getter_ again because\n // URLFetcher::Core::RetryOrCompleteUrlFetch resets it to NULL...\n request_->SetRequestContext(request_context_getter_.get());\n request_->Start();\n }\n}\n\nvoid GaiaOAuthClient::Core::HandleResponse(\n const net::URLFetcher* source,\n bool* should_retry_request) {\n // Move ownership of the request fetcher into a local scoped_ptr which\n // will be nuked when we're done handling the request, unless we need\n // to retry, in which case ownership will be returned to request_.\n scoped_ptr old_request = request_.Pass();\n DCHECK_EQ(source, old_request.get());\n\n // RC_BAD_REQUEST means the arguments are invalid. No point retrying. We are\n // done here.\n if (source->GetResponseCode() == net::HTTP_BAD_REQUEST) {\n delegate_->OnOAuthError();\n return;\n }\n\n scoped_ptr response_dict;\n if (source->GetResponseCode() == net::HTTP_OK) {\n std::string data;\n source->GetResponseAsString(&data);\n scoped_ptr message_value(base::JSONReader::Read(data));\n if (message_value.get() &&\n message_value->IsType(base::Value::TYPE_DICTIONARY)) {\n response_dict.reset(\n static_cast(message_value.release()));\n }\n }\n\n if (!response_dict.get()) {\n // If we don't have an access token yet and the the error was not\n // RC_BAD_REQUEST, we may need to retry.\n if ((source->GetMaxRetriesOn5xx() != -1) &&\n (num_retries_ >= source->GetMaxRetriesOn5xx())) {\n // Retry limit reached. Give up.\n delegate_->OnNetworkError(source->GetResponseCode());\n } else {\n request_ = old_request.Pass();\n *should_retry_request = true;\n }\n return;\n }\n\n RequestType type = request_type_;\n request_type_ = NO_PENDING_REQUEST;\n\n switch (type) {\n case USER_EMAIL: {\n std::string email;\n response_dict->GetString(\"email\", &email);\n delegate_->OnGetUserEmailResponse(email);\n break;\n }\n\n case USER_ID: {\n std::string id;\n response_dict->GetString(\"id\", &id);\n delegate_->OnGetUserIdResponse(id);\n break;\n }\n\n case TOKEN_INFO: {\n delegate_->OnGetTokenInfoResponse(response_dict.Pass());\n break;\n }\n\n case TOKENS_FROM_AUTH_CODE:\n case REFRESH_TOKEN: {\n std::string access_token;\n std::string refresh_token;\n int expires_in_seconds = 0;\n response_dict->GetString(kAccessTokenValue, &access_token);\n response_dict->GetString(kRefreshTokenValue, &refresh_token);\n response_dict->GetInteger(kExpiresInValue, &expires_in_seconds);\n\n if (access_token.empty()) {\n delegate_->OnOAuthError();\n return;\n }\n\n if (type == REFRESH_TOKEN) {\n delegate_->OnRefreshTokenResponse(access_token, expires_in_seconds);\n } else {\n delegate_->OnGetTokensResponse(refresh_token,\n access_token,\n expires_in_seconds);\n }\n break;\n }\n\n default:\n NOTREACHED();\n }\n}\n\nGaiaOAuthClient::GaiaOAuthClient(net::URLRequestContextGetter* context_getter) {\n core_ = new Core(context_getter);\n}\n\nGaiaOAuthClient::~GaiaOAuthClient() {\n}\n\nvoid GaiaOAuthClient::GetTokensFromAuthCode(\n const OAuthClientInfo& oauth_client_info,\n const std::string& auth_code,\n int max_retries,\n Delegate* delegate) {\n return core_->GetTokensFromAuthCode(oauth_client_info,\n auth_code,\n max_retries,\n delegate);\n}\n\nvoid GaiaOAuthClient::RefreshToken(\n const OAuthClientInfo& oauth_client_info,\n const std::string& refresh_token,\n const std::vector& scopes,\n int max_retries,\n Delegate* delegate) {\n return core_->RefreshToken(oauth_client_info,\n refresh_token,\n scopes,\n max_retries,\n delegate);\n}\n\nvoid GaiaOAuthClient::GetUserEmail(const std::string& access_token,\n int max_retries,\n Delegate* delegate) {\n return core_->GetUserEmail(access_token, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::GetUserId(const std::string& access_token,\n int max_retries,\n Delegate* delegate) {\n return core_->GetUserId(access_token, max_retries, delegate);\n}\n\nvoid GaiaOAuthClient::GetTokenInfo(const std::string& access_token,\n int max_retries,\n Delegate* delegate) {\n return core_->GetTokenInfo(access_token, max_retries, delegate);\n}\n\n} // namespace gaia\n"},"repo_name":{"kind":"string","value":"Gateworks/platform-external-chromium_org"},"path":{"kind":"string","value":"google_apis/gaia/gaia_oauth_client.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":13657,"string":"13,657"}}},{"rowIdx":61538430,"cells":{"code":{"kind":"string","value":"// Copyright 2015 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#include \"chrome/browser/usb/usb_chooser_context_factory.h\"\n\n#include \"chrome/browser/content_settings/host_content_settings_map_factory.h\"\n#include \"chrome/browser/profiles/incognito_helpers.h\"\n#include \"chrome/browser/profiles/profile.h\"\n#include \"chrome/browser/usb/usb_chooser_context.h\"\n#include \"components/keyed_service/content/browser_context_dependency_manager.h\"\n\nUsbChooserContextFactory::UsbChooserContextFactory()\n : BrowserContextKeyedServiceFactory(\n \"UsbChooserContext\",\n BrowserContextDependencyManager::GetInstance()) {\n DependsOn(HostContentSettingsMapFactory::GetInstance());\n}\n\nUsbChooserContextFactory::~UsbChooserContextFactory() {}\n\nKeyedService* UsbChooserContextFactory::BuildServiceInstanceFor(\n content::BrowserContext* context) const {\n return new UsbChooserContext(Profile::FromBrowserContext(context));\n}\n\n// static\nUsbChooserContextFactory* UsbChooserContextFactory::GetInstance() {\n return base::Singleton::get();\n}\n\n// static\nUsbChooserContext* UsbChooserContextFactory::GetForProfile(Profile* profile) {\n return static_cast(\n GetInstance()->GetServiceForBrowserContext(profile, true));\n}\n\ncontent::BrowserContext* UsbChooserContextFactory::GetBrowserContextToUse(\n content::BrowserContext* context) const {\n return chrome::GetBrowserContextOwnInstanceInIncognito(context);\n}\n"},"repo_name":{"kind":"string","value":"endlessm/chromium-browser"},"path":{"kind":"string","value":"chrome/browser/usb/usb_chooser_context_factory.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":1559,"string":"1,559"}}},{"rowIdx":61538431,"cells":{"code":{"kind":"string","value":"// Code generated by protoc-gen-gogo.\n// source: combos/both/one.proto\n// DO NOT EDIT!\n\n/*\n\tPackage one is a generated protocol buffer package.\n\n\tIt is generated from these files:\n\t\tcombos/both/one.proto\n\n\tIt has these top-level messages:\n\t\tSubby\n\t\tSampleOneOf\n*/\npackage one\n\nimport proto \"github.com/gogo/protobuf/proto\"\nimport fmt \"fmt\"\nimport math \"math\"\nimport _ \"github.com/gogo/protobuf/gogoproto\"\n\nimport github_com_gogo_protobuf_protoc_gen_gogo_descriptor \"github.com/gogo/protobuf/protoc-gen-gogo/descriptor\"\nimport github_com_gogo_protobuf_proto \"github.com/gogo/protobuf/proto\"\nimport compress_gzip \"compress/gzip\"\nimport bytes \"bytes\"\nimport io_ioutil \"io/ioutil\"\n\nimport strings \"strings\"\nimport reflect \"reflect\"\n\nimport io \"io\"\n\n// Reference imports to suppress errors if they are not otherwise used.\nvar _ = proto.Marshal\nvar _ = fmt.Errorf\nvar _ = math.Inf\n\n// This is a compile-time assertion to ensure that this generated file\n// is compatible with the proto package it is being compiled against.\n// A compilation error at this line likely means your copy of the\n// proto package needs to be updated.\nconst _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package\n\ntype Subby struct {\n\tSub string `protobuf:\"bytes,1,opt,name=sub,proto3\" json:\"sub,omitempty\"`\n}\n\nfunc (m *Subby) Reset() { *m = Subby{} }\nfunc (*Subby) ProtoMessage() {}\nfunc (*Subby) Descriptor() ([]byte, []int) { return fileDescriptorOne, []int{0} }\n\ntype SampleOneOf struct {\n\t// Types that are valid to be assigned to TestOneof:\n\t//\t*SampleOneOf_Field1\n\t//\t*SampleOneOf_Field2\n\t//\t*SampleOneOf_Field3\n\t//\t*SampleOneOf_Field4\n\t//\t*SampleOneOf_Field5\n\t//\t*SampleOneOf_Field6\n\t//\t*SampleOneOf_Field7\n\t//\t*SampleOneOf_Field8\n\t//\t*SampleOneOf_Field9\n\t//\t*SampleOneOf_Field10\n\t//\t*SampleOneOf_Field11\n\t//\t*SampleOneOf_Field12\n\t//\t*SampleOneOf_Field13\n\t//\t*SampleOneOf_Field14\n\t//\t*SampleOneOf_Field15\n\t//\t*SampleOneOf_SubMessage\n\tTestOneof isSampleOneOf_TestOneof `protobuf_oneof:\"test_oneof\"`\n}\n\nfunc (m *SampleOneOf) Reset() { *m = SampleOneOf{} }\nfunc (*SampleOneOf) ProtoMessage() {}\nfunc (*SampleOneOf) Descriptor() ([]byte, []int) { return fileDescriptorOne, []int{1} }\n\ntype isSampleOneOf_TestOneof interface {\n\tisSampleOneOf_TestOneof()\n\tEqual(interface{}) bool\n\tVerboseEqual(interface{}) error\n\tMarshalTo([]byte) (int, error)\n\tSize() int\n}\n\ntype SampleOneOf_Field1 struct {\n\tField1 float64 `protobuf:\"fixed64,1,opt,name=Field1,proto3,oneof\"`\n}\ntype SampleOneOf_Field2 struct {\n\tField2 float32 `protobuf:\"fixed32,2,opt,name=Field2,proto3,oneof\"`\n}\ntype SampleOneOf_Field3 struct {\n\tField3 int32 `protobuf:\"varint,3,opt,name=Field3,proto3,oneof\"`\n}\ntype SampleOneOf_Field4 struct {\n\tField4 int64 `protobuf:\"varint,4,opt,name=Field4,proto3,oneof\"`\n}\ntype SampleOneOf_Field5 struct {\n\tField5 uint32 `protobuf:\"varint,5,opt,name=Field5,proto3,oneof\"`\n}\ntype SampleOneOf_Field6 struct {\n\tField6 uint64 `protobuf:\"varint,6,opt,name=Field6,proto3,oneof\"`\n}\ntype SampleOneOf_Field7 struct {\n\tField7 int32 `protobuf:\"zigzag32,7,opt,name=Field7,proto3,oneof\"`\n}\ntype SampleOneOf_Field8 struct {\n\tField8 int64 `protobuf:\"zigzag64,8,opt,name=Field8,proto3,oneof\"`\n}\ntype SampleOneOf_Field9 struct {\n\tField9 uint32 `protobuf:\"fixed32,9,opt,name=Field9,proto3,oneof\"`\n}\ntype SampleOneOf_Field10 struct {\n\tField10 int32 `protobuf:\"fixed32,10,opt,name=Field10,proto3,oneof\"`\n}\ntype SampleOneOf_Field11 struct {\n\tField11 uint64 `protobuf:\"fixed64,11,opt,name=Field11,proto3,oneof\"`\n}\ntype SampleOneOf_Field12 struct {\n\tField12 int64 `protobuf:\"fixed64,12,opt,name=Field12,proto3,oneof\"`\n}\ntype SampleOneOf_Field13 struct {\n\tField13 bool `protobuf:\"varint,13,opt,name=Field13,proto3,oneof\"`\n}\ntype SampleOneOf_Field14 struct {\n\tField14 string `protobuf:\"bytes,14,opt,name=Field14,proto3,oneof\"`\n}\ntype SampleOneOf_Field15 struct {\n\tField15 []byte `protobuf:\"bytes,15,opt,name=Field15,proto3,oneof\"`\n}\ntype SampleOneOf_SubMessage struct {\n\tSubMessage *Subby `protobuf:\"bytes,16,opt,name=sub_message,json=subMessage,oneof\"`\n}\n\nfunc (*SampleOneOf_Field1) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field2) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field3) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field4) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field5) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field6) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field7) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field8) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field9) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field10) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field11) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field12) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field13) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field14) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_Field15) isSampleOneOf_TestOneof() {}\nfunc (*SampleOneOf_SubMessage) isSampleOneOf_TestOneof() {}\n\nfunc (m *SampleOneOf) GetTestOneof() isSampleOneOf_TestOneof {\n\tif m != nil {\n\t\treturn m.TestOneof\n\t}\n\treturn nil\n}\n\nfunc (m *SampleOneOf) GetField1() float64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field1); ok {\n\t\treturn x.Field1\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField2() float32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field2); ok {\n\t\treturn x.Field2\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField3() int32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field3); ok {\n\t\treturn x.Field3\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField4() int64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field4); ok {\n\t\treturn x.Field4\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField5() uint32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field5); ok {\n\t\treturn x.Field5\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField6() uint64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field6); ok {\n\t\treturn x.Field6\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField7() int32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field7); ok {\n\t\treturn x.Field7\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField8() int64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field8); ok {\n\t\treturn x.Field8\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField9() uint32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field9); ok {\n\t\treturn x.Field9\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField10() int32 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field10); ok {\n\t\treturn x.Field10\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField11() uint64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field11); ok {\n\t\treturn x.Field11\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField12() int64 {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field12); ok {\n\t\treturn x.Field12\n\t}\n\treturn 0\n}\n\nfunc (m *SampleOneOf) GetField13() bool {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field13); ok {\n\t\treturn x.Field13\n\t}\n\treturn false\n}\n\nfunc (m *SampleOneOf) GetField14() string {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field14); ok {\n\t\treturn x.Field14\n\t}\n\treturn \"\"\n}\n\nfunc (m *SampleOneOf) GetField15() []byte {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_Field15); ok {\n\t\treturn x.Field15\n\t}\n\treturn nil\n}\n\nfunc (m *SampleOneOf) GetSubMessage() *Subby {\n\tif x, ok := m.GetTestOneof().(*SampleOneOf_SubMessage); ok {\n\t\treturn x.SubMessage\n\t}\n\treturn nil\n}\n\n// XXX_OneofFuncs is for the internal use of the proto package.\nfunc (*SampleOneOf) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {\n\treturn _SampleOneOf_OneofMarshaler, _SampleOneOf_OneofUnmarshaler, _SampleOneOf_OneofSizer, []interface{}{\n\t\t(*SampleOneOf_Field1)(nil),\n\t\t(*SampleOneOf_Field2)(nil),\n\t\t(*SampleOneOf_Field3)(nil),\n\t\t(*SampleOneOf_Field4)(nil),\n\t\t(*SampleOneOf_Field5)(nil),\n\t\t(*SampleOneOf_Field6)(nil),\n\t\t(*SampleOneOf_Field7)(nil),\n\t\t(*SampleOneOf_Field8)(nil),\n\t\t(*SampleOneOf_Field9)(nil),\n\t\t(*SampleOneOf_Field10)(nil),\n\t\t(*SampleOneOf_Field11)(nil),\n\t\t(*SampleOneOf_Field12)(nil),\n\t\t(*SampleOneOf_Field13)(nil),\n\t\t(*SampleOneOf_Field14)(nil),\n\t\t(*SampleOneOf_Field15)(nil),\n\t\t(*SampleOneOf_SubMessage)(nil),\n\t}\n}\n\nfunc _SampleOneOf_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {\n\tm := msg.(*SampleOneOf)\n\t// test_oneof\n\tswitch x := m.TestOneof.(type) {\n\tcase *SampleOneOf_Field1:\n\t\t_ = b.EncodeVarint(1<<3 | proto.WireFixed64)\n\t\t_ = b.EncodeFixed64(math.Float64bits(x.Field1))\n\tcase *SampleOneOf_Field2:\n\t\t_ = b.EncodeVarint(2<<3 | proto.WireFixed32)\n\t\t_ = b.EncodeFixed32(uint64(math.Float32bits(x.Field2)))\n\tcase *SampleOneOf_Field3:\n\t\t_ = b.EncodeVarint(3<<3 | proto.WireVarint)\n\t\t_ = b.EncodeVarint(uint64(x.Field3))\n\tcase *SampleOneOf_Field4:\n\t\t_ = b.EncodeVarint(4<<3 | proto.WireVarint)\n\t\t_ = b.EncodeVarint(uint64(x.Field4))\n\tcase *SampleOneOf_Field5:\n\t\t_ = b.EncodeVarint(5<<3 | proto.WireVarint)\n\t\t_ = b.EncodeVarint(uint64(x.Field5))\n\tcase *SampleOneOf_Field6:\n\t\t_ = b.EncodeVarint(6<<3 | proto.WireVarint)\n\t\t_ = b.EncodeVarint(uint64(x.Field6))\n\tcase *SampleOneOf_Field7:\n\t\t_ = b.EncodeVarint(7<<3 | proto.WireVarint)\n\t\t_ = b.EncodeZigzag32(uint64(x.Field7))\n\tcase *SampleOneOf_Field8:\n\t\t_ = b.EncodeVarint(8<<3 | proto.WireVarint)\n\t\t_ = b.EncodeZigzag64(uint64(x.Field8))\n\tcase *SampleOneOf_Field9:\n\t\t_ = b.EncodeVarint(9<<3 | proto.WireFixed32)\n\t\t_ = b.EncodeFixed32(uint64(x.Field9))\n\tcase *SampleOneOf_Field10:\n\t\t_ = b.EncodeVarint(10<<3 | proto.WireFixed32)\n\t\t_ = b.EncodeFixed32(uint64(x.Field10))\n\tcase *SampleOneOf_Field11:\n\t\t_ = b.EncodeVarint(11<<3 | proto.WireFixed64)\n\t\t_ = b.EncodeFixed64(uint64(x.Field11))\n\tcase *SampleOneOf_Field12:\n\t\t_ = b.EncodeVarint(12<<3 | proto.WireFixed64)\n\t\t_ = b.EncodeFixed64(uint64(x.Field12))\n\tcase *SampleOneOf_Field13:\n\t\tt := uint64(0)\n\t\tif x.Field13 {\n\t\t\tt = 1\n\t\t}\n\t\t_ = b.EncodeVarint(13<<3 | proto.WireVarint)\n\t\t_ = b.EncodeVarint(t)\n\tcase *SampleOneOf_Field14:\n\t\t_ = b.EncodeVarint(14<<3 | proto.WireBytes)\n\t\t_ = b.EncodeStringBytes(x.Field14)\n\tcase *SampleOneOf_Field15:\n\t\t_ = b.EncodeVarint(15<<3 | proto.WireBytes)\n\t\t_ = b.EncodeRawBytes(x.Field15)\n\tcase *SampleOneOf_SubMessage:\n\t\t_ = b.EncodeVarint(16<<3 | proto.WireBytes)\n\t\tif err := b.EncodeMessage(x.SubMessage); err != nil {\n\t\t\treturn err\n\t\t}\n\tcase nil:\n\tdefault:\n\t\treturn fmt.Errorf(\"SampleOneOf.TestOneof has unexpected type %T\", x)\n\t}\n\treturn nil\n}\n\nfunc _SampleOneOf_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {\n\tm := msg.(*SampleOneOf)\n\tswitch tag {\n\tcase 1: // test_oneof.Field1\n\t\tif wire != proto.WireFixed64 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed64()\n\t\tm.TestOneof = &SampleOneOf_Field1{math.Float64frombits(x)}\n\t\treturn true, err\n\tcase 2: // test_oneof.Field2\n\t\tif wire != proto.WireFixed32 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed32()\n\t\tm.TestOneof = &SampleOneOf_Field2{math.Float32frombits(uint32(x))}\n\t\treturn true, err\n\tcase 3: // test_oneof.Field3\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeVarint()\n\t\tm.TestOneof = &SampleOneOf_Field3{int32(x)}\n\t\treturn true, err\n\tcase 4: // test_oneof.Field4\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeVarint()\n\t\tm.TestOneof = &SampleOneOf_Field4{int64(x)}\n\t\treturn true, err\n\tcase 5: // test_oneof.Field5\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeVarint()\n\t\tm.TestOneof = &SampleOneOf_Field5{uint32(x)}\n\t\treturn true, err\n\tcase 6: // test_oneof.Field6\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeVarint()\n\t\tm.TestOneof = &SampleOneOf_Field6{x}\n\t\treturn true, err\n\tcase 7: // test_oneof.Field7\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeZigzag32()\n\t\tm.TestOneof = &SampleOneOf_Field7{int32(x)}\n\t\treturn true, err\n\tcase 8: // test_oneof.Field8\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeZigzag64()\n\t\tm.TestOneof = &SampleOneOf_Field8{int64(x)}\n\t\treturn true, err\n\tcase 9: // test_oneof.Field9\n\t\tif wire != proto.WireFixed32 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed32()\n\t\tm.TestOneof = &SampleOneOf_Field9{uint32(x)}\n\t\treturn true, err\n\tcase 10: // test_oneof.Field10\n\t\tif wire != proto.WireFixed32 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed32()\n\t\tm.TestOneof = &SampleOneOf_Field10{int32(x)}\n\t\treturn true, err\n\tcase 11: // test_oneof.Field11\n\t\tif wire != proto.WireFixed64 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed64()\n\t\tm.TestOneof = &SampleOneOf_Field11{x}\n\t\treturn true, err\n\tcase 12: // test_oneof.Field12\n\t\tif wire != proto.WireFixed64 {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeFixed64()\n\t\tm.TestOneof = &SampleOneOf_Field12{int64(x)}\n\t\treturn true, err\n\tcase 13: // test_oneof.Field13\n\t\tif wire != proto.WireVarint {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeVarint()\n\t\tm.TestOneof = &SampleOneOf_Field13{x != 0}\n\t\treturn true, err\n\tcase 14: // test_oneof.Field14\n\t\tif wire != proto.WireBytes {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeStringBytes()\n\t\tm.TestOneof = &SampleOneOf_Field14{x}\n\t\treturn true, err\n\tcase 15: // test_oneof.Field15\n\t\tif wire != proto.WireBytes {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tx, err := b.DecodeRawBytes(true)\n\t\tm.TestOneof = &SampleOneOf_Field15{x}\n\t\treturn true, err\n\tcase 16: // test_oneof.sub_message\n\t\tif wire != proto.WireBytes {\n\t\t\treturn true, proto.ErrInternalBadWireType\n\t\t}\n\t\tmsg := new(Subby)\n\t\terr := b.DecodeMessage(msg)\n\t\tm.TestOneof = &SampleOneOf_SubMessage{msg}\n\t\treturn true, err\n\tdefault:\n\t\treturn false, nil\n\t}\n}\n\nfunc _SampleOneOf_OneofSizer(msg proto.Message) (n int) {\n\tm := msg.(*SampleOneOf)\n\t// test_oneof\n\tswitch x := m.TestOneof.(type) {\n\tcase *SampleOneOf_Field1:\n\t\tn += proto.SizeVarint(1<<3 | proto.WireFixed64)\n\t\tn += 8\n\tcase *SampleOneOf_Field2:\n\t\tn += proto.SizeVarint(2<<3 | proto.WireFixed32)\n\t\tn += 4\n\tcase *SampleOneOf_Field3:\n\t\tn += proto.SizeVarint(3<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64(x.Field3))\n\tcase *SampleOneOf_Field4:\n\t\tn += proto.SizeVarint(4<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64(x.Field4))\n\tcase *SampleOneOf_Field5:\n\t\tn += proto.SizeVarint(5<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64(x.Field5))\n\tcase *SampleOneOf_Field6:\n\t\tn += proto.SizeVarint(6<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64(x.Field6))\n\tcase *SampleOneOf_Field7:\n\t\tn += proto.SizeVarint(7<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64((uint32(x.Field7) << 1) ^ uint32((int32(x.Field7) >> 31))))\n\tcase *SampleOneOf_Field8:\n\t\tn += proto.SizeVarint(8<<3 | proto.WireVarint)\n\t\tn += proto.SizeVarint(uint64(uint64(x.Field8<<1) ^ uint64((int64(x.Field8) >> 63))))\n\tcase *SampleOneOf_Field9:\n\t\tn += proto.SizeVarint(9<<3 | proto.WireFixed32)\n\t\tn += 4\n\tcase *SampleOneOf_Field10:\n\t\tn += proto.SizeVarint(10<<3 | proto.WireFixed32)\n\t\tn += 4\n\tcase *SampleOneOf_Field11:\n\t\tn += proto.SizeVarint(11<<3 | proto.WireFixed64)\n\t\tn += 8\n\tcase *SampleOneOf_Field12:\n\t\tn += proto.SizeVarint(12<<3 | proto.WireFixed64)\n\t\tn += 8\n\tcase *SampleOneOf_Field13:\n\t\tn += proto.SizeVarint(13<<3 | proto.WireVarint)\n\t\tn += 1\n\tcase *SampleOneOf_Field14:\n\t\tn += proto.SizeVarint(14<<3 | proto.WireBytes)\n\t\tn += proto.SizeVarint(uint64(len(x.Field14)))\n\t\tn += len(x.Field14)\n\tcase *SampleOneOf_Field15:\n\t\tn += proto.SizeVarint(15<<3 | proto.WireBytes)\n\t\tn += proto.SizeVarint(uint64(len(x.Field15)))\n\t\tn += len(x.Field15)\n\tcase *SampleOneOf_SubMessage:\n\t\ts := proto.Size(x.SubMessage)\n\t\tn += proto.SizeVarint(16<<3 | proto.WireBytes)\n\t\tn += proto.SizeVarint(uint64(s))\n\t\tn += s\n\tcase nil:\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"proto: unexpected type %T in oneof\", x))\n\t}\n\treturn n\n}\n\nfunc init() {\n\tproto.RegisterType((*Subby)(nil), \"one.Subby\")\n\tproto.RegisterType((*SampleOneOf)(nil), \"one.SampleOneOf\")\n}\nfunc (this *Subby) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {\n\treturn OneDescription()\n}\nfunc (this *SampleOneOf) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {\n\treturn OneDescription()\n}\nfunc OneDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) {\n\td := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{}\n\tvar gzipped = []byte{\n\t\t// 3749 bytes of a gzipped FileDescriptorSet\n\t\t0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x5b, 0x6c, 0xe4, 0xe6,\n\t\t0x75, 0x16, 0xe7, 0xa6, 0x99, 0x33, 0xa3, 0x11, 0xf5, 0x4b, 0x5e, 0x73, 0xe5, 0x78, 0x56, 0xab,\n\t\t0xd8, 0xb1, 0x6c, 0xd7, 0x5a, 0x5b, 0x97, 0xbd, 0xcc, 0x36, 0x31, 0x46, 0xd2, 0x58, 0xab, 0x85,\n\t\t0x6e, 0xe1, 0x48, 0x89, 0x9d, 0x3c, 0x10, 0x1c, 0xce, 0x3f, 0x23, 0xee, 0x72, 0xc8, 0x29, 0xc9,\n\t\t0x59, 0x5b, 0x7e, 0xda, 0xc0, 0xbd, 0x20, 0x08, 0x7a, 0x4d, 0x81, 0x26, 0x8e, 0xe3, 0xa6, 0x01,\n\t\t0x5a, 0xa7, 0xe9, 0x2d, 0xe9, 0x25, 0x0d, 0xfa, 0xd4, 0x97, 0xb4, 0x7e, 0x2a, 0x92, 0xb7, 0x3e,\n\t\t0xe4, 0x21, 0xab, 0x1a, 0x68, 0xda, 0xba, 0xad, 0xdb, 0x18, 0x68, 0x80, 0x7d, 0x29, 0xfe, 0x1b,\n\t\t0xc9, 0xb9, 0x68, 0x39, 0x0a, 0x90, 0x38, 0x4f, 0x12, 0xcf, 0x39, 0xdf, 0xc7, 0xc3, 0xf3, 0x9f,\n\t\t0xff, 0x9c, 0xc3, 0x7f, 0x08, 0x9f, 0x59, 0x81, 0xb9, 0x96, 0xe3, 0xb4, 0x2c, 0x7c, 0xa9, 0xe3,\n\t\t0x3a, 0xbe, 0x53, 0xef, 0x36, 0x2f, 0x35, 0xb0, 0x67, 0xb8, 0x66, 0xc7, 0x77, 0xdc, 0x45, 0x2a,\n\t\t0x43, 0x93, 0xcc, 0x62, 0x51, 0x58, 0xcc, 0xef, 0xc0, 0xd4, 0x0b, 0xa6, 0x85, 0x37, 0x02, 0xc3,\n\t\t0x1a, 0xf6, 0xd1, 0x55, 0x48, 0x35, 0x4d, 0x0b, 0x2b, 0xd2, 0x5c, 0x72, 0x21, 0xbf, 0xf4, 0xd8,\n\t\t0x62, 0x1f, 0x68, 0xb1, 0x17, 0xb1, 0x4f, 0xc4, 0x2a, 0x45, 0xcc, 0xbf, 0x93, 0x82, 0xe9, 0x21,\n\t\t0x5a, 0x84, 0x20, 0x65, 0xeb, 0x6d, 0xc2, 0x28, 0x2d, 0xe4, 0x54, 0xfa, 0x3f, 0x52, 0x60, 0xbc,\n\t\t0xa3, 0x1b, 0xb7, 0xf5, 0x16, 0x56, 0x12, 0x54, 0x2c, 0x2e, 0x51, 0x09, 0xa0, 0x81, 0x3b, 0xd8,\n\t\t0x6e, 0x60, 0xdb, 0x38, 0x56, 0x92, 0x73, 0xc9, 0x85, 0x9c, 0x1a, 0x91, 0xa0, 0xa7, 0x61, 0xaa,\n\t\t0xd3, 0xad, 0x5b, 0xa6, 0xa1, 0x45, 0xcc, 0x60, 0x2e, 0xb9, 0x90, 0x56, 0x65, 0xa6, 0xd8, 0x08,\n\t\t0x8d, 0x9f, 0x80, 0xc9, 0x97, 0xb1, 0x7e, 0x3b, 0x6a, 0x9a, 0xa7, 0xa6, 0x45, 0x22, 0x8e, 0x18,\n\t\t0xae, 0x43, 0xa1, 0x8d, 0x3d, 0x4f, 0x6f, 0x61, 0xcd, 0x3f, 0xee, 0x60, 0x25, 0x45, 0x9f, 0x7e,\n\t\t0x6e, 0xe0, 0xe9, 0xfb, 0x9f, 0x3c, 0xcf, 0x51, 0x07, 0xc7, 0x1d, 0x8c, 0x2a, 0x90, 0xc3, 0x76,\n\t\t0xb7, 0xcd, 0x18, 0xd2, 0xa7, 0xc4, 0xaf, 0x6a, 0x77, 0xdb, 0xfd, 0x2c, 0x59, 0x02, 0xe3, 0x14,\n\t\t0xe3, 0x1e, 0x76, 0xef, 0x98, 0x06, 0x56, 0x32, 0x94, 0xe0, 0x89, 0x01, 0x82, 0x1a, 0xd3, 0xf7,\n\t\t0x73, 0x08, 0x1c, 0x5a, 0x87, 0x1c, 0x7e, 0xc5, 0xc7, 0xb6, 0x67, 0x3a, 0xb6, 0x32, 0x4e, 0x49,\n\t\t0x1e, 0x1f, 0xb2, 0x8a, 0xd8, 0x6a, 0xf4, 0x53, 0x84, 0x38, 0x74, 0x19, 0xc6, 0x9d, 0x8e, 0x6f,\n\t\t0x3a, 0xb6, 0xa7, 0x64, 0xe7, 0xa4, 0x85, 0xfc, 0xd2, 0x87, 0x86, 0x26, 0xc2, 0x1e, 0xb3, 0x51,\n\t\t0x85, 0x31, 0xda, 0x02, 0xd9, 0x73, 0xba, 0xae, 0x81, 0x35, 0xc3, 0x69, 0x60, 0xcd, 0xb4, 0x9b,\n\t\t0x8e, 0x92, 0xa3, 0x04, 0x17, 0x06, 0x1f, 0x84, 0x1a, 0xae, 0x3b, 0x0d, 0xbc, 0x65, 0x37, 0x1d,\n\t\t0xb5, 0xe8, 0xf5, 0x5c, 0xa3, 0x73, 0x90, 0xf1, 0x8e, 0x6d, 0x5f, 0x7f, 0x45, 0x29, 0xd0, 0x0c,\n\t\t0xe1, 0x57, 0xf3, 0xff, 0x97, 0x86, 0xc9, 0x51, 0x52, 0xec, 0x3a, 0xa4, 0x9b, 0xe4, 0x29, 0x95,\n\t\t0xc4, 0x59, 0x62, 0xc0, 0x30, 0xbd, 0x41, 0xcc, 0xfc, 0x84, 0x41, 0xac, 0x40, 0xde, 0xc6, 0x9e,\n\t\t0x8f, 0x1b, 0x2c, 0x23, 0x92, 0x23, 0xe6, 0x14, 0x30, 0xd0, 0x60, 0x4a, 0xa5, 0x7e, 0xa2, 0x94,\n\t\t0x7a, 0x11, 0x26, 0x03, 0x97, 0x34, 0x57, 0xb7, 0x5b, 0x22, 0x37, 0x2f, 0xc5, 0x79, 0xb2, 0x58,\n\t\t0x15, 0x38, 0x95, 0xc0, 0xd4, 0x22, 0xee, 0xb9, 0x46, 0x1b, 0x00, 0x8e, 0x8d, 0x9d, 0xa6, 0xd6,\n\t\t0xc0, 0x86, 0xa5, 0x64, 0x4f, 0x89, 0xd2, 0x1e, 0x31, 0x19, 0x88, 0x92, 0xc3, 0xa4, 0x86, 0x85,\n\t\t0xae, 0x85, 0xa9, 0x36, 0x7e, 0x4a, 0xa6, 0xec, 0xb0, 0x4d, 0x36, 0x90, 0x6d, 0x87, 0x50, 0x74,\n\t\t0x31, 0xc9, 0x7b, 0xdc, 0xe0, 0x4f, 0x96, 0xa3, 0x4e, 0x2c, 0xc6, 0x3e, 0x99, 0xca, 0x61, 0xec,\n\t\t0xc1, 0x26, 0xdc, 0xe8, 0x25, 0xfa, 0x30, 0x04, 0x02, 0x8d, 0xa6, 0x15, 0xd0, 0x2a, 0x54, 0x10,\n\t\t0xc2, 0x5d, 0xbd, 0x8d, 0x67, 0xaf, 0x42, 0xb1, 0x37, 0x3c, 0x68, 0x06, 0xd2, 0x9e, 0xaf, 0xbb,\n\t\t0x3e, 0xcd, 0xc2, 0xb4, 0xca, 0x2e, 0x90, 0x0c, 0x49, 0x6c, 0x37, 0x68, 0x95, 0x4b, 0xab, 0xe4,\n\t\t0xdf, 0xd9, 0x2b, 0x30, 0xd1, 0x73, 0xfb, 0x51, 0x81, 0xf3, 0x5f, 0xc8, 0xc0, 0xcc, 0xb0, 0x9c,\n\t\t0x1b, 0x9a, 0xfe, 0xe7, 0x20, 0x63, 0x77, 0xdb, 0x75, 0xec, 0x2a, 0x49, 0xca, 0xc0, 0xaf, 0x50,\n\t\t0x05, 0xd2, 0x96, 0x5e, 0xc7, 0x96, 0x92, 0x9a, 0x93, 0x16, 0x8a, 0x4b, 0x4f, 0x8f, 0x94, 0xd5,\n\t\t0x8b, 0xdb, 0x04, 0xa2, 0x32, 0x24, 0xfa, 0x18, 0xa4, 0x78, 0x89, 0x23, 0x0c, 0x4f, 0x8d, 0xc6,\n\t\t0x40, 0x72, 0x51, 0xa5, 0x38, 0xf4, 0x08, 0xe4, 0xc8, 0x5f, 0x16, 0xdb, 0x0c, 0xf5, 0x39, 0x4b,\n\t\t0x04, 0x24, 0xae, 0x68, 0x16, 0xb2, 0x34, 0xcd, 0x1a, 0x58, 0xb4, 0x86, 0xe0, 0x9a, 0x2c, 0x4c,\n\t\t0x03, 0x37, 0xf5, 0xae, 0xe5, 0x6b, 0x77, 0x74, 0xab, 0x8b, 0x69, 0xc2, 0xe4, 0xd4, 0x02, 0x17,\n\t\t0x7e, 0x82, 0xc8, 0xd0, 0x05, 0xc8, 0xb3, 0xac, 0x34, 0xed, 0x06, 0x7e, 0x85, 0x56, 0x9f, 0xb4,\n\t\t0xca, 0x12, 0x75, 0x8b, 0x48, 0xc8, 0xed, 0x6f, 0x79, 0x8e, 0x2d, 0x96, 0x96, 0xde, 0x82, 0x08,\n\t\t0xe8, 0xed, 0xaf, 0xf4, 0x17, 0xbe, 0x47, 0x87, 0x3f, 0x5e, 0x7f, 0x2e, 0xce, 0x7f, 0x2b, 0x01,\n\t\t0x29, 0xba, 0xdf, 0x26, 0x21, 0x7f, 0xf0, 0xd2, 0x7e, 0x55, 0xdb, 0xd8, 0x3b, 0x5c, 0xdb, 0xae,\n\t\t0xca, 0x12, 0x2a, 0x02, 0x50, 0xc1, 0x0b, 0xdb, 0x7b, 0x95, 0x03, 0x39, 0x11, 0x5c, 0x6f, 0xed,\n\t\t0x1e, 0x5c, 0x5e, 0x91, 0x93, 0x01, 0xe0, 0x90, 0x09, 0x52, 0x51, 0x83, 0xe5, 0x25, 0x39, 0x8d,\n\t\t0x64, 0x28, 0x30, 0x82, 0xad, 0x17, 0xab, 0x1b, 0x97, 0x57, 0xe4, 0x4c, 0xaf, 0x64, 0x79, 0x49,\n\t\t0x1e, 0x47, 0x13, 0x90, 0xa3, 0x92, 0xb5, 0xbd, 0xbd, 0x6d, 0x39, 0x1b, 0x70, 0xd6, 0x0e, 0xd4,\n\t\t0xad, 0xdd, 0x4d, 0x39, 0x17, 0x70, 0x6e, 0xaa, 0x7b, 0x87, 0xfb, 0x32, 0x04, 0x0c, 0x3b, 0xd5,\n\t\t0x5a, 0xad, 0xb2, 0x59, 0x95, 0xf3, 0x81, 0xc5, 0xda, 0x4b, 0x07, 0xd5, 0x9a, 0x5c, 0xe8, 0x71,\n\t\t0x6b, 0x79, 0x49, 0x9e, 0x08, 0x6e, 0x51, 0xdd, 0x3d, 0xdc, 0x91, 0x8b, 0x68, 0x0a, 0x26, 0xd8,\n\t\t0x2d, 0x84, 0x13, 0x93, 0x7d, 0xa2, 0xcb, 0x2b, 0xb2, 0x1c, 0x3a, 0xc2, 0x58, 0xa6, 0x7a, 0x04,\n\t\t0x97, 0x57, 0x64, 0x34, 0xbf, 0x0e, 0x69, 0x9a, 0x5d, 0x08, 0x41, 0x71, 0xbb, 0xb2, 0x56, 0xdd,\n\t\t0xd6, 0xf6, 0xf6, 0x0f, 0xb6, 0xf6, 0x76, 0x2b, 0xdb, 0xb2, 0x14, 0xca, 0xd4, 0xea, 0xc7, 0x0f,\n\t\t0xb7, 0xd4, 0xea, 0x86, 0x9c, 0x88, 0xca, 0xf6, 0xab, 0x95, 0x83, 0xea, 0x86, 0x9c, 0x9c, 0x37,\n\t\t0x60, 0x66, 0x58, 0x9d, 0x19, 0xba, 0x33, 0x22, 0x4b, 0x9c, 0x38, 0x65, 0x89, 0x29, 0xd7, 0xc0,\n\t\t0x12, 0x7f, 0x55, 0x82, 0xe9, 0x21, 0xb5, 0x76, 0xe8, 0x4d, 0x9e, 0x87, 0x34, 0x4b, 0x51, 0xd6,\n\t\t0x7d, 0x9e, 0x1c, 0x5a, 0xb4, 0x69, 0xc2, 0x0e, 0x74, 0x20, 0x8a, 0x8b, 0x76, 0xe0, 0xe4, 0x29,\n\t\t0x1d, 0x98, 0x50, 0x0c, 0x38, 0xf9, 0x9a, 0x04, 0xca, 0x69, 0xdc, 0x31, 0x85, 0x22, 0xd1, 0x53,\n\t\t0x28, 0xae, 0xf7, 0x3b, 0x70, 0xf1, 0xf4, 0x67, 0x18, 0xf0, 0xe2, 0x2d, 0x09, 0xce, 0x0d, 0x1f,\n\t\t0x54, 0x86, 0xfa, 0xf0, 0x31, 0xc8, 0xb4, 0xb1, 0x7f, 0xe4, 0x88, 0x66, 0xfd, 0x91, 0x21, 0x2d,\n\t\t0x80, 0xa8, 0xfb, 0x63, 0xc5, 0x51, 0xd1, 0x1e, 0x92, 0x3c, 0x6d, 0xda, 0x60, 0xde, 0x0c, 0x78,\n\t\t0xfa, 0xd9, 0x04, 0x3c, 0x34, 0x94, 0x7c, 0xa8, 0xa3, 0x8f, 0x02, 0x98, 0x76, 0xa7, 0xeb, 0xb3,\n\t\t0x86, 0xcc, 0xea, 0x53, 0x8e, 0x4a, 0xe8, 0xde, 0x27, 0xb5, 0xa7, 0xeb, 0x07, 0xfa, 0x24, 0xd5,\n\t\t0x03, 0x13, 0x51, 0x83, 0xab, 0xa1, 0xa3, 0x29, 0xea, 0x68, 0xe9, 0x94, 0x27, 0x1d, 0xe8, 0x75,\n\t\t0xcf, 0x82, 0x6c, 0x58, 0x26, 0xb6, 0x7d, 0xcd, 0xf3, 0x5d, 0xac, 0xb7, 0x4d, 0xbb, 0x45, 0x0b,\n\t\t0x70, 0xb6, 0x9c, 0x6e, 0xea, 0x96, 0x87, 0xd5, 0x49, 0xa6, 0xae, 0x09, 0x2d, 0x41, 0xd0, 0x2e,\n\t\t0xe3, 0x46, 0x10, 0x99, 0x1e, 0x04, 0x53, 0x07, 0x88, 0xf9, 0xcf, 0x8d, 0x43, 0x3e, 0x32, 0xd6,\n\t\t0xa1, 0x8b, 0x50, 0xb8, 0xa5, 0xdf, 0xd1, 0x35, 0x31, 0xaa, 0xb3, 0x48, 0xe4, 0x89, 0x6c, 0x9f,\n\t\t0x8f, 0xeb, 0xcf, 0xc2, 0x0c, 0x35, 0x71, 0xba, 0x3e, 0x76, 0x35, 0xc3, 0xd2, 0x3d, 0x8f, 0x06,\n\t\t0x2d, 0x4b, 0x4d, 0x11, 0xd1, 0xed, 0x11, 0xd5, 0xba, 0xd0, 0xa0, 0x55, 0x98, 0xa6, 0x88, 0x76,\n\t\t0xd7, 0xf2, 0xcd, 0x8e, 0x85, 0x35, 0xf2, 0xf2, 0xe0, 0xd1, 0x42, 0x1c, 0x78, 0x36, 0x45, 0x2c,\n\t\t0x76, 0xb8, 0x01, 0xf1, 0xc8, 0x43, 0x9b, 0xf0, 0x28, 0x85, 0xb5, 0xb0, 0x8d, 0x5d, 0xdd, 0xc7,\n\t\t0x1a, 0xfe, 0xa5, 0xae, 0x6e, 0x79, 0x9a, 0x6e, 0x37, 0xb4, 0x23, 0xdd, 0x3b, 0x52, 0x66, 0xa2,\n\t\t0x04, 0xe7, 0x89, 0xed, 0x26, 0x37, 0xad, 0x52, 0xcb, 0x8a, 0xdd, 0xb8, 0xa1, 0x7b, 0x47, 0xa8,\n\t\t0x0c, 0xe7, 0x28, 0x91, 0xe7, 0xbb, 0xa6, 0xdd, 0xd2, 0x8c, 0x23, 0x6c, 0xdc, 0xd6, 0xba, 0x7e,\n\t\t0xf3, 0xaa, 0xf2, 0x48, 0x94, 0x81, 0x3a, 0x59, 0xa3, 0x36, 0xeb, 0xc4, 0xe4, 0xd0, 0x6f, 0x5e,\n\t\t0x45, 0x35, 0x28, 0x90, 0xf5, 0x68, 0x9b, 0xaf, 0x62, 0xad, 0xe9, 0xb8, 0xb4, 0xb9, 0x14, 0x87,\n\t\t0x6c, 0xee, 0x48, 0x10, 0x17, 0xf7, 0x38, 0x60, 0xc7, 0x69, 0xe0, 0x72, 0xba, 0xb6, 0x5f, 0xad,\n\t\t0x6e, 0xa8, 0x79, 0xc1, 0xf2, 0x82, 0xe3, 0x92, 0x9c, 0x6a, 0x39, 0x41, 0x8c, 0xf3, 0x2c, 0xa7,\n\t\t0x5a, 0x8e, 0x88, 0xf0, 0x2a, 0x4c, 0x1b, 0x06, 0x7b, 0x6c, 0xd3, 0xd0, 0xf8, 0x94, 0xef, 0x29,\n\t\t0x72, 0x4f, 0xbc, 0x0c, 0x63, 0x93, 0x19, 0xf0, 0x34, 0xf7, 0xd0, 0x35, 0x78, 0x28, 0x8c, 0x57,\n\t\t0x14, 0x38, 0x35, 0xf0, 0x94, 0xfd, 0xd0, 0x55, 0x98, 0xee, 0x1c, 0x0f, 0x02, 0x51, 0xcf, 0x1d,\n\t\t0x3b, 0xc7, 0xfd, 0xb0, 0xc7, 0xe9, 0x9b, 0x9b, 0x8b, 0x0d, 0xdd, 0xc7, 0x0d, 0xe5, 0xe1, 0xa8,\n\t\t0x75, 0x44, 0x81, 0x2e, 0x81, 0x6c, 0x18, 0x1a, 0xb6, 0xf5, 0xba, 0x85, 0x35, 0xdd, 0xc5, 0xb6,\n\t\t0xee, 0x29, 0x17, 0xa2, 0xc6, 0x45, 0xc3, 0xa8, 0x52, 0x6d, 0x85, 0x2a, 0xd1, 0x53, 0x30, 0xe5,\n\t\t0xd4, 0x6f, 0x19, 0x2c, 0xb9, 0xb4, 0x8e, 0x8b, 0x9b, 0xe6, 0x2b, 0xca, 0x63, 0x34, 0x4c, 0x93,\n\t\t0x44, 0x41, 0x53, 0x6b, 0x9f, 0x8a, 0xd1, 0x93, 0x20, 0x1b, 0xde, 0x91, 0xee, 0x76, 0x68, 0x77,\n\t\t0xf7, 0x3a, 0xba, 0x81, 0x95, 0xc7, 0x99, 0x29, 0x93, 0xef, 0x0a, 0x31, 0x7a, 0x11, 0x66, 0xba,\n\t\t0xb6, 0x69, 0xfb, 0xd8, 0xed, 0xb8, 0x98, 0x0c, 0xe9, 0x6c, 0xa7, 0x29, 0xff, 0x3a, 0x7e, 0xca,\n\t\t0x98, 0x7d, 0x18, 0xb5, 0x66, 0xab, 0xab, 0x4e, 0x77, 0x07, 0x85, 0xf3, 0x65, 0x28, 0x44, 0x17,\n\t\t0x1d, 0xe5, 0x80, 0x2d, 0xbb, 0x2c, 0x91, 0x1e, 0xba, 0xbe, 0xb7, 0x41, 0xba, 0xdf, 0xa7, 0xaa,\n\t\t0x72, 0x82, 0x74, 0xe1, 0xed, 0xad, 0x83, 0xaa, 0xa6, 0x1e, 0xee, 0x1e, 0x6c, 0xed, 0x54, 0xe5,\n\t\t0xe4, 0x53, 0xb9, 0xec, 0x0f, 0xc7, 0xe5, 0xbb, 0x77, 0xef, 0xde, 0x4d, 0xcc, 0x7f, 0x27, 0x01,\n\t\t0xc5, 0xde, 0xc9, 0x17, 0xfd, 0x22, 0x3c, 0x2c, 0x5e, 0x53, 0x3d, 0xec, 0x6b, 0x2f, 0x9b, 0x2e,\n\t\t0xcd, 0xc3, 0xb6, 0xce, 0x66, 0xc7, 0x20, 0x84, 0x33, 0xdc, 0xaa, 0x86, 0xfd, 0x4f, 0x9a, 0x2e,\n\t\t0xc9, 0xb2, 0xb6, 0xee, 0xa3, 0x6d, 0xb8, 0x60, 0x3b, 0x9a, 0xe7, 0xeb, 0x76, 0x43, 0x77, 0x1b,\n\t\t0x5a, 0x78, 0x40, 0xa0, 0xe9, 0x86, 0x81, 0x3d, 0xcf, 0x61, 0x2d, 0x20, 0x60, 0xf9, 0x90, 0xed,\n\t\t0xd4, 0xb8, 0x71, 0x58, 0x1b, 0x2b, 0xdc, 0xb4, 0x6f, 0xb9, 0x93, 0xa7, 0x2d, 0xf7, 0x23, 0x90,\n\t\t0x6b, 0xeb, 0x1d, 0x0d, 0xdb, 0xbe, 0x7b, 0x4c, 0xe7, 0xb5, 0xac, 0x9a, 0x6d, 0xeb, 0x9d, 0x2a,\n\t\t0xb9, 0xfe, 0xe9, 0xad, 0x41, 0x34, 0x8e, 0xdf, 0x4f, 0x42, 0x21, 0x3a, 0xb3, 0x91, 0x11, 0xd8,\n\t\t0xa0, 0xf5, 0x59, 0xa2, 0xdb, 0xf7, 0xc3, 0x0f, 0x9c, 0xf0, 0x16, 0xd7, 0x49, 0xe1, 0x2e, 0x67,\n\t\t0xd8, 0x24, 0xa5, 0x32, 0x24, 0x69, 0x9a, 0x64, 0xc3, 0x62, 0x36, 0x9f, 0x67, 0x55, 0x7e, 0x85,\n\t\t0x36, 0x21, 0x73, 0xcb, 0xa3, 0xdc, 0x19, 0xca, 0xfd, 0xd8, 0x83, 0xb9, 0x6f, 0xd6, 0x28, 0x79,\n\t\t0xee, 0x66, 0x4d, 0xdb, 0xdd, 0x53, 0x77, 0x2a, 0xdb, 0x2a, 0x87, 0xa3, 0xf3, 0x90, 0xb2, 0xf4,\n\t\t0x57, 0x8f, 0x7b, 0x4b, 0x3c, 0x15, 0x8d, 0x1a, 0xf8, 0xf3, 0x90, 0x7a, 0x19, 0xeb, 0xb7, 0x7b,\n\t\t0x0b, 0x2b, 0x15, 0xfd, 0x14, 0x53, 0xff, 0x12, 0xa4, 0x69, 0xbc, 0x10, 0x00, 0x8f, 0x98, 0x3c,\n\t\t0x86, 0xb2, 0x90, 0x5a, 0xdf, 0x53, 0x49, 0xfa, 0xcb, 0x50, 0x60, 0x52, 0x6d, 0x7f, 0xab, 0xba,\n\t\t0x5e, 0x95, 0x13, 0xf3, 0xab, 0x90, 0x61, 0x41, 0x20, 0x5b, 0x23, 0x08, 0x83, 0x3c, 0xc6, 0x2f,\n\t\t0x39, 0x87, 0x24, 0xb4, 0x87, 0x3b, 0x6b, 0x55, 0x55, 0x4e, 0x44, 0x97, 0xd7, 0x83, 0x42, 0x74,\n\t\t0x5c, 0xfb, 0xd9, 0xe4, 0xd4, 0xdf, 0x49, 0x90, 0x8f, 0x8c, 0x5f, 0xa4, 0xf1, 0xeb, 0x96, 0xe5,\n\t\t0xbc, 0xac, 0xe9, 0x96, 0xa9, 0x7b, 0x3c, 0x29, 0x80, 0x8a, 0x2a, 0x44, 0x32, 0xea, 0xa2, 0xfd,\n\t\t0x4c, 0x9c, 0x7f, 0x53, 0x02, 0xb9, 0x7f, 0x74, 0xeb, 0x73, 0x50, 0xfa, 0x40, 0x1d, 0x7c, 0x43,\n\t\t0x82, 0x62, 0xef, 0xbc, 0xd6, 0xe7, 0xde, 0xc5, 0x0f, 0xd4, 0xbd, 0x2f, 0x49, 0x30, 0xd1, 0x33,\n\t\t0xa5, 0xfd, 0x5c, 0x79, 0xf7, 0x7a, 0x12, 0xa6, 0x87, 0xe0, 0x50, 0x85, 0x8f, 0xb3, 0x6c, 0xc2,\n\t\t0x7e, 0x66, 0x94, 0x7b, 0x2d, 0x92, 0x6e, 0xb9, 0xaf, 0xbb, 0x3e, 0x9f, 0x7e, 0x9f, 0x04, 0xd9,\n\t\t0x6c, 0x60, 0xdb, 0x37, 0x9b, 0x26, 0x76, 0xf9, 0x2b, 0x38, 0x9b, 0x71, 0x27, 0x43, 0x39, 0x7b,\n\t\t0x0b, 0xff, 0x05, 0x40, 0x1d, 0xc7, 0x33, 0x7d, 0xf3, 0x0e, 0xd6, 0x4c, 0x5b, 0xbc, 0xaf, 0x93,\n\t\t0x99, 0x37, 0xa5, 0xca, 0x42, 0xb3, 0x65, 0xfb, 0x81, 0xb5, 0x8d, 0x5b, 0x7a, 0x9f, 0x35, 0xa9,\n\t\t0x7d, 0x49, 0x55, 0x16, 0x9a, 0xc0, 0xfa, 0x22, 0x14, 0x1a, 0x4e, 0x97, 0x8c, 0x0f, 0xcc, 0x8e,\n\t\t0x94, 0x5a, 0x49, 0xcd, 0x33, 0x59, 0x60, 0xc2, 0xe7, 0xbb, 0xf0, 0xa0, 0xa0, 0xa0, 0xe6, 0x99,\n\t\t0x8c, 0x99, 0x3c, 0x01, 0x93, 0x7a, 0xab, 0xe5, 0x12, 0x72, 0x41, 0xc4, 0x86, 0xd6, 0x62, 0x20,\n\t\t0xa6, 0x86, 0xb3, 0x37, 0x21, 0x2b, 0xe2, 0x40, 0xba, 0x19, 0x89, 0x84, 0xd6, 0x61, 0xc7, 0x35,\n\t\t0x89, 0x85, 0x9c, 0x9a, 0xb5, 0x85, 0xf2, 0x22, 0x14, 0x4c, 0x4f, 0x0b, 0xcf, 0x0d, 0x13, 0x73,\n\t\t0x89, 0x85, 0xac, 0x9a, 0x37, 0xbd, 0xe0, 0xa0, 0x68, 0xfe, 0xad, 0x04, 0x14, 0x7b, 0xcf, 0x3d,\n\t\t0xd1, 0x06, 0x64, 0x2d, 0xc7, 0xd0, 0x69, 0x22, 0xb0, 0x43, 0xf7, 0x85, 0x98, 0xa3, 0xd2, 0xc5,\n\t\t0x6d, 0x6e, 0xaf, 0x06, 0xc8, 0xd9, 0x7f, 0x92, 0x20, 0x2b, 0xc4, 0xe8, 0x1c, 0xa4, 0x3a, 0xba,\n\t\t0x7f, 0x44, 0xe9, 0xd2, 0x6b, 0x09, 0x59, 0x52, 0xe9, 0x35, 0x91, 0x7b, 0x1d, 0xdd, 0xa6, 0x29,\n\t\t0xc0, 0xe5, 0xe4, 0x9a, 0xac, 0xab, 0x85, 0xf5, 0x06, 0x1d, 0x87, 0x9d, 0x76, 0x1b, 0xdb, 0xbe,\n\t\t0x27, 0xd6, 0x95, 0xcb, 0xd7, 0xb9, 0x18, 0x3d, 0x0d, 0x53, 0xbe, 0xab, 0x9b, 0x56, 0x8f, 0x6d,\n\t\t0x8a, 0xda, 0xca, 0x42, 0x11, 0x18, 0x97, 0xe1, 0xbc, 0xe0, 0x6d, 0x60, 0x5f, 0x37, 0x8e, 0x70,\n\t\t0x23, 0x04, 0x65, 0xe8, 0xa1, 0xda, 0xc3, 0xdc, 0x60, 0x83, 0xeb, 0x05, 0x76, 0xfe, 0x7b, 0x12,\n\t\t0x4c, 0x89, 0x01, 0xbe, 0x11, 0x04, 0x6b, 0x07, 0x40, 0xb7, 0x6d, 0xc7, 0x8f, 0x86, 0x6b, 0x30,\n\t\t0x95, 0x07, 0x70, 0x8b, 0x95, 0x00, 0xa4, 0x46, 0x08, 0x66, 0xdb, 0x00, 0xa1, 0xe6, 0xd4, 0xb0,\n\t\t0x5d, 0x80, 0x3c, 0x3f, 0xd4, 0xa6, 0xbf, 0x8c, 0xb0, 0xb7, 0x3e, 0x60, 0x22, 0x32, 0xe9, 0xa3,\n\t\t0x19, 0x48, 0xd7, 0x71, 0xcb, 0xb4, 0xf9, 0x51, 0x1b, 0xbb, 0x10, 0x07, 0x78, 0xa9, 0xe0, 0x00,\n\t\t0x6f, 0xed, 0xd3, 0x30, 0x6d, 0x38, 0xed, 0x7e, 0x77, 0xd7, 0xe4, 0xbe, 0x37, 0x4f, 0xef, 0x86,\n\t\t0xf4, 0x29, 0x08, 0xa7, 0xb3, 0xaf, 0x48, 0xd2, 0x57, 0x13, 0xc9, 0xcd, 0xfd, 0xb5, 0xaf, 0x27,\n\t\t0x66, 0x37, 0x19, 0x74, 0x5f, 0x3c, 0xa9, 0x8a, 0x9b, 0x16, 0x36, 0x88, 0xf7, 0xf0, 0xa3, 0x8f,\n\t\t0xc0, 0x33, 0x2d, 0xd3, 0x3f, 0xea, 0xd6, 0x17, 0x0d, 0xa7, 0x7d, 0xa9, 0xe5, 0xb4, 0x9c, 0xf0,\n\t\t0xc7, 0x20, 0x72, 0x45, 0x2f, 0xe8, 0x7f, 0xfc, 0x07, 0xa1, 0x5c, 0x20, 0x9d, 0x8d, 0xfd, 0xf5,\n\t\t0xa8, 0xbc, 0x0b, 0xd3, 0xdc, 0x58, 0xa3, 0x27, 0xd2, 0x6c, 0x0e, 0x47, 0x0f, 0x3c, 0x95, 0x50,\n\t\t0xbe, 0xf9, 0x0e, 0xed, 0x74, 0xea, 0x14, 0x87, 0x12, 0x1d, 0x9b, 0xd4, 0xcb, 0x2a, 0x3c, 0xd4,\n\t\t0xc3, 0xc7, 0xb6, 0x26, 0x76, 0x63, 0x18, 0xbf, 0xc3, 0x19, 0xa7, 0x23, 0x8c, 0x35, 0x0e, 0x2d,\n\t\t0xaf, 0xc3, 0xc4, 0x59, 0xb8, 0xfe, 0x81, 0x73, 0x15, 0x70, 0x94, 0x64, 0x13, 0x26, 0x29, 0x89,\n\t\t0xd1, 0xf5, 0x7c, 0xa7, 0x4d, 0xeb, 0xde, 0x83, 0x69, 0xfe, 0xf1, 0x1d, 0xb6, 0x57, 0x8a, 0x04,\n\t\t0xb6, 0x1e, 0xa0, 0xca, 0x65, 0xa0, 0x87, 0xf0, 0x0d, 0x6c, 0x58, 0x31, 0x0c, 0x6f, 0x73, 0x47,\n\t\t0x02, 0xfb, 0xf2, 0x27, 0x60, 0x86, 0xfc, 0x4f, 0xcb, 0x52, 0xd4, 0x93, 0xf8, 0x33, 0x18, 0xe5,\n\t\t0x7b, 0xaf, 0xb1, 0xed, 0x38, 0x1d, 0x10, 0x44, 0x7c, 0x8a, 0xac, 0x62, 0x0b, 0xfb, 0x3e, 0x76,\n\t\t0x3d, 0x4d, 0xb7, 0x86, 0xb9, 0x17, 0x79, 0x83, 0x55, 0xbe, 0xf8, 0x6e, 0xef, 0x2a, 0x6e, 0x32,\n\t\t0x64, 0xc5, 0xb2, 0xca, 0x87, 0xf0, 0xf0, 0x90, 0xac, 0x18, 0x81, 0xf3, 0x75, 0xce, 0x39, 0x33,\n\t\t0x90, 0x19, 0x84, 0x76, 0x1f, 0x84, 0x3c, 0x58, 0xcb, 0x11, 0x38, 0xbf, 0xc4, 0x39, 0x11, 0xc7,\n\t\t0x8a, 0x25, 0x25, 0x8c, 0x37, 0x61, 0xea, 0x0e, 0x76, 0xeb, 0x8e, 0xc7, 0x0f, 0x0e, 0x46, 0xa0,\n\t\t0x7b, 0x83, 0xd3, 0x4d, 0x72, 0x20, 0x3d, 0x46, 0x20, 0x5c, 0xd7, 0x20, 0xdb, 0xd4, 0x0d, 0x3c,\n\t\t0x02, 0xc5, 0x97, 0x39, 0xc5, 0x38, 0xb1, 0x27, 0xd0, 0x0a, 0x14, 0x5a, 0x0e, 0xef, 0x4c, 0xf1,\n\t\t0xf0, 0x37, 0x39, 0x3c, 0x2f, 0x30, 0x9c, 0xa2, 0xe3, 0x74, 0xba, 0x16, 0x69, 0x5b, 0xf1, 0x14,\n\t\t0xbf, 0x2f, 0x28, 0x04, 0x86, 0x53, 0x9c, 0x21, 0xac, 0x5f, 0x11, 0x14, 0x5e, 0x24, 0x9e, 0xcf,\n\t\t0x43, 0xde, 0xb1, 0xad, 0x63, 0xc7, 0x1e, 0xc5, 0x89, 0x3f, 0xe0, 0x0c, 0xc0, 0x21, 0x84, 0xe0,\n\t\t0x3a, 0xe4, 0x46, 0x5d, 0x88, 0x3f, 0x7c, 0x57, 0x6c, 0x0f, 0xb1, 0x02, 0x9b, 0x30, 0x29, 0x0a,\n\t\t0x94, 0xe9, 0xd8, 0x23, 0x50, 0xfc, 0x11, 0xa7, 0x28, 0x46, 0x60, 0xfc, 0x31, 0x7c, 0xec, 0xf9,\n\t\t0x2d, 0x3c, 0x0a, 0xc9, 0x5b, 0xe2, 0x31, 0x38, 0x84, 0x87, 0xb2, 0x8e, 0x6d, 0xe3, 0x68, 0x34,\n\t\t0x86, 0xaf, 0x89, 0x50, 0x0a, 0x0c, 0xa1, 0x58, 0x87, 0x89, 0xb6, 0xee, 0x7a, 0x47, 0xba, 0x35,\n\t\t0xd2, 0x72, 0xfc, 0x31, 0xe7, 0x28, 0x04, 0x20, 0x1e, 0x91, 0xae, 0x7d, 0x16, 0x9a, 0xaf, 0x8b,\n\t\t0x88, 0x44, 0x60, 0x7c, 0xeb, 0x79, 0x3e, 0x3d, 0x9b, 0x39, 0x0b, 0xdb, 0x9f, 0x88, 0xad, 0xc7,\n\t\t0xb0, 0x3b, 0x51, 0xc6, 0xeb, 0x90, 0xf3, 0xcc, 0x57, 0x47, 0xa2, 0xf9, 0x53, 0xb1, 0xd2, 0x14,\n\t\t0x40, 0xc0, 0x2f, 0xc1, 0xf9, 0xa1, 0x6d, 0x62, 0x04, 0xb2, 0x3f, 0xe3, 0x64, 0xe7, 0x86, 0xb4,\n\t\t0x0a, 0x5e, 0x12, 0xce, 0x4a, 0xf9, 0xe7, 0xa2, 0x24, 0xe0, 0x3e, 0xae, 0x7d, 0x32, 0xd9, 0x7b,\n\t\t0x7a, 0xf3, 0x6c, 0x51, 0xfb, 0x0b, 0x11, 0x35, 0x86, 0xed, 0x89, 0xda, 0x01, 0x9c, 0xe3, 0x8c,\n\t\t0x67, 0x5b, 0xd7, 0x6f, 0x88, 0xc2, 0xca, 0xd0, 0x87, 0xbd, 0xab, 0xfb, 0x69, 0x98, 0x0d, 0xc2,\n\t\t0x29, 0x86, 0x52, 0x4f, 0x6b, 0xeb, 0x9d, 0x11, 0x98, 0xbf, 0xc9, 0x99, 0x45, 0xc5, 0x0f, 0xa6,\n\t\t0x5a, 0x6f, 0x47, 0xef, 0x10, 0xf2, 0x17, 0x41, 0x11, 0xe4, 0x5d, 0xdb, 0xc5, 0x86, 0xd3, 0xb2,\n\t\t0xcd, 0x57, 0x71, 0x63, 0x04, 0xea, 0xbf, 0xec, 0x5b, 0xaa, 0xc3, 0x08, 0x9c, 0x30, 0x6f, 0x81,\n\t\t0x1c, 0xcc, 0x2a, 0x9a, 0xd9, 0xee, 0x38, 0xae, 0x1f, 0xc3, 0xf8, 0x57, 0x62, 0xa5, 0x02, 0xdc,\n\t\t0x16, 0x85, 0x95, 0xab, 0x50, 0xa4, 0x97, 0xa3, 0xa6, 0xe4, 0x5f, 0x73, 0xa2, 0x89, 0x10, 0xc5,\n\t\t0x0b, 0x87, 0xe1, 0xb4, 0x3b, 0xba, 0x3b, 0x4a, 0xfd, 0xfb, 0x1b, 0x51, 0x38, 0x38, 0x84, 0x17,\n\t\t0x0e, 0xff, 0xb8, 0x83, 0x49, 0xb7, 0x1f, 0x81, 0xe1, 0x5b, 0xa2, 0x70, 0x08, 0x0c, 0xa7, 0x10,\n\t\t0x03, 0xc3, 0x08, 0x14, 0x7f, 0x2b, 0x28, 0x04, 0x86, 0x50, 0x7c, 0x3c, 0x6c, 0xb4, 0x2e, 0x6e,\n\t\t0x99, 0x9e, 0xef, 0xb2, 0x51, 0xf8, 0xc1, 0x54, 0xdf, 0x7e, 0xb7, 0x77, 0x08, 0x53, 0x23, 0xd0,\n\t\t0xf2, 0x4d, 0x98, 0xec, 0x1b, 0x31, 0x50, 0xdc, 0x2f, 0xfa, 0xca, 0x67, 0xde, 0xe7, 0xc5, 0xa8,\n\t\t0x77, 0xc2, 0x28, 0x6f, 0x93, 0x75, 0xef, 0x9d, 0x03, 0xe2, 0xc9, 0x5e, 0x7b, 0x3f, 0x58, 0xfa,\n\t\t0x9e, 0x31, 0xa0, 0xfc, 0x02, 0x4c, 0xf4, 0xcc, 0x00, 0xf1, 0x54, 0xbf, 0xcc, 0xa9, 0x0a, 0xd1,\n\t\t0x11, 0xa0, 0xbc, 0x0a, 0x29, 0xd2, 0xcf, 0xe3, 0xe1, 0xbf, 0xc2, 0xe1, 0xd4, 0xbc, 0xfc, 0x51,\n\t\t0xc8, 0x8a, 0x3e, 0x1e, 0x0f, 0xfd, 0x55, 0x0e, 0x0d, 0x20, 0x04, 0x2e, 0x7a, 0x78, 0x3c, 0xfc,\n\t\t0xd7, 0x04, 0x5c, 0x40, 0x08, 0x7c, 0xf4, 0x10, 0xfe, 0xfd, 0xe7, 0x52, 0xbc, 0x0e, 0x8b, 0xd8,\n\t\t0x5d, 0x87, 0x71, 0xde, 0xbc, 0xe3, 0xd1, 0x9f, 0xe5, 0x37, 0x17, 0x88, 0xf2, 0x15, 0x48, 0x8f,\n\t\t0x18, 0xf0, 0x5f, 0xe7, 0x50, 0x66, 0x5f, 0x5e, 0x87, 0x7c, 0xa4, 0x61, 0xc7, 0xc3, 0x7f, 0x83,\n\t\t0xc3, 0xa3, 0x28, 0xe2, 0x3a, 0x6f, 0xd8, 0xf1, 0x04, 0xbf, 0x29, 0x5c, 0xe7, 0x08, 0x12, 0x36,\n\t\t0xd1, 0xab, 0xe3, 0xd1, 0xbf, 0x25, 0xa2, 0x2e, 0x20, 0xe5, 0xe7, 0x21, 0x17, 0xd4, 0xdf, 0x78,\n\t\t0xfc, 0x6f, 0x73, 0x7c, 0x88, 0x21, 0x11, 0x88, 0xd4, 0xff, 0x78, 0x8a, 0xdf, 0x11, 0x11, 0x88,\n\t\t0xa0, 0xc8, 0x36, 0xea, 0xef, 0xe9, 0xf1, 0x4c, 0x9f, 0x17, 0xdb, 0xa8, 0xaf, 0xa5, 0x93, 0xd5,\n\t\t0xa4, 0x65, 0x30, 0x9e, 0xe2, 0x77, 0xc5, 0x6a, 0x52, 0x7b, 0xe2, 0x46, 0x7f, 0x93, 0x8c, 0xe7,\n\t\t0xf8, 0x3d, 0xe1, 0x46, 0x5f, 0x8f, 0x2c, 0xef, 0x03, 0x1a, 0x6c, 0x90, 0xf1, 0x7c, 0x5f, 0xe0,\n\t\t0x7c, 0x53, 0x03, 0xfd, 0xb1, 0xfc, 0x49, 0x38, 0x37, 0xbc, 0x39, 0xc6, 0xb3, 0x7e, 0xf1, 0xfd,\n\t\t0xbe, 0xd7, 0x99, 0x68, 0x6f, 0x2c, 0x1f, 0x84, 0x55, 0x36, 0xda, 0x18, 0xe3, 0x69, 0x5f, 0x7f,\n\t\t0xbf, 0xb7, 0xd0, 0x46, 0xfb, 0x62, 0xb9, 0x02, 0x10, 0xf6, 0xa4, 0x78, 0xae, 0x37, 0x38, 0x57,\n\t\t0x04, 0x44, 0xb6, 0x06, 0x6f, 0x49, 0xf1, 0xf8, 0x2f, 0x8b, 0xad, 0xc1, 0x11, 0x64, 0x6b, 0x88,\n\t\t0x6e, 0x14, 0x8f, 0x7e, 0x53, 0x6c, 0x0d, 0x01, 0x29, 0x5f, 0x87, 0xac, 0xdd, 0xb5, 0x2c, 0x92,\n\t\t0x5b, 0xe8, 0xc1, 0x1f, 0xd9, 0x28, 0xff, 0x76, 0x9f, 0x83, 0x05, 0xa0, 0xbc, 0x0a, 0x69, 0xdc,\n\t\t0xae, 0xe3, 0x46, 0x1c, 0xf2, 0xdf, 0xef, 0x8b, 0x7a, 0x42, 0xac, 0xcb, 0xcf, 0x03, 0xb0, 0x97,\n\t\t0x69, 0xfa, 0x1b, 0x4b, 0x0c, 0xf6, 0x3f, 0xee, 0xf3, 0xdf, 0xef, 0x43, 0x48, 0x48, 0xc0, 0xbe,\n\t\t0x06, 0x78, 0x30, 0xc1, 0xbb, 0xbd, 0x04, 0xf4, 0x05, 0xfc, 0x1a, 0x8c, 0xdf, 0xf2, 0x1c, 0xdb,\n\t\t0xd7, 0x5b, 0x71, 0xe8, 0xff, 0xe4, 0x68, 0x61, 0x4f, 0x02, 0xd6, 0x76, 0x5c, 0xec, 0xeb, 0x2d,\n\t\t0x2f, 0x0e, 0xfb, 0x5f, 0x1c, 0x1b, 0x00, 0x08, 0xd8, 0xd0, 0x3d, 0x7f, 0x94, 0xe7, 0xfe, 0x6f,\n\t\t0x01, 0x16, 0x00, 0xe2, 0x34, 0xf9, 0xff, 0x36, 0x3e, 0x8e, 0xc3, 0xbe, 0x27, 0x9c, 0xe6, 0xf6,\n\t\t0xe5, 0x8f, 0x42, 0x8e, 0xfc, 0xcb, 0xbe, 0x69, 0x89, 0x01, 0xff, 0x0f, 0x07, 0x87, 0x08, 0x72,\n\t\t0x67, 0xcf, 0x6f, 0xf8, 0x66, 0x7c, 0xb0, 0xff, 0x97, 0xaf, 0xb4, 0xb0, 0x2f, 0x57, 0x20, 0xef,\n\t\t0xf9, 0x8d, 0x46, 0x97, 0x4f, 0x34, 0x31, 0xf0, 0x1f, 0xdd, 0x0f, 0x5e, 0x72, 0x03, 0xcc, 0xda,\n\t\t0xc5, 0xe1, 0xe7, 0x75, 0xb0, 0xe9, 0x6c, 0x3a, 0xec, 0xa4, 0x0e, 0x3e, 0x9f, 0x86, 0x87, 0x0c,\n\t\t0xa7, 0x5d, 0x77, 0xbc, 0x4b, 0x75, 0xc7, 0x3f, 0xba, 0xe4, 0xd8, 0xdc, 0x10, 0x25, 0x1d, 0x1b,\n\t\t0xcf, 0x9e, 0xed, 0x44, 0x6e, 0xfe, 0x3c, 0xa4, 0x6b, 0xdd, 0x7a, 0xfd, 0x18, 0xc9, 0x90, 0xf4,\n\t\t0xba, 0x75, 0xfe, 0xc1, 0x05, 0xf9, 0x77, 0xfe, 0xfb, 0x49, 0xc8, 0xd7, 0xf4, 0x76, 0xc7, 0xc2,\n\t\t0x7b, 0x36, 0xde, 0x6b, 0x22, 0x05, 0x32, 0xf4, 0x01, 0x9e, 0xa3, 0x46, 0xd2, 0x8d, 0x31, 0x95,\n\t\t0x5f, 0x07, 0x9a, 0x25, 0x7a, 0x52, 0x99, 0x08, 0x34, 0x4b, 0x81, 0x66, 0x99, 0x1d, 0x54, 0x06,\n\t\t0x9a, 0xe5, 0x40, 0xb3, 0x42, 0x8f, 0x2b, 0x93, 0x81, 0x66, 0x25, 0xd0, 0xac, 0xd2, 0xe3, 0xf8,\n\t\t0x89, 0x40, 0xb3, 0x1a, 0x68, 0x2e, 0xd3, 0x03, 0xf8, 0x54, 0xa0, 0xb9, 0x1c, 0x68, 0xae, 0xd0,\n\t\t0x73, 0xf7, 0xa9, 0x40, 0x73, 0x25, 0xd0, 0x5c, 0xa5, 0x67, 0xed, 0x28, 0xd0, 0x5c, 0x0d, 0x34,\n\t\t0xd7, 0xe8, 0x47, 0x15, 0xe3, 0x81, 0xe6, 0x1a, 0x9a, 0x85, 0x71, 0xf6, 0x64, 0xcf, 0xd2, 0xdf,\n\t\t0x32, 0x27, 0x6f, 0x8c, 0xa9, 0x42, 0x10, 0xea, 0x9e, 0xa3, 0x1f, 0x4e, 0x64, 0x42, 0xdd, 0x73,\n\t\t0xa1, 0x6e, 0x89, 0x7e, 0x41, 0x2c, 0x87, 0xba, 0xa5, 0x50, 0xb7, 0xac, 0x4c, 0x90, 0x75, 0x0f,\n\t\t0x75, 0xcb, 0xa1, 0x6e, 0x45, 0x29, 0x92, 0xf8, 0x87, 0xba, 0x95, 0x50, 0xb7, 0xaa, 0x4c, 0xce,\n\t\t0x49, 0x0b, 0x85, 0x50, 0xb7, 0x8a, 0x9e, 0x81, 0xbc, 0xd7, 0xad, 0x6b, 0xfc, 0xa7, 0x77, 0xfa,\n\t\t0x81, 0x46, 0x7e, 0x09, 0x16, 0x49, 0x46, 0xd0, 0x45, 0xbd, 0x31, 0xa6, 0x82, 0xd7, 0xad, 0xf3,\n\t\t0xc2, 0xb8, 0x56, 0x00, 0x7a, 0x8e, 0xa0, 0xd1, 0x2f, 0x13, 0xd7, 0x36, 0xde, 0xbe, 0x57, 0x1a,\n\t\t0xfb, 0xee, 0xbd, 0xd2, 0xd8, 0x3f, 0xdf, 0x2b, 0x8d, 0xfd, 0xe0, 0x5e, 0x49, 0x7a, 0xef, 0x5e,\n\t\t0x49, 0xfa, 0xf1, 0xbd, 0x92, 0x74, 0xf7, 0xa4, 0x24, 0x7d, 0xed, 0xa4, 0x24, 0x7d, 0xe3, 0xa4,\n\t\t0x24, 0x7d, 0xfb, 0xa4, 0x24, 0xbd, 0x7d, 0x52, 0x92, 0xbe, 0x7b, 0x52, 0x92, 0x7e, 0x70, 0x52,\n\t\t0x92, 0x7e, 0x78, 0x52, 0x1a, 0x7b, 0xef, 0xa4, 0x24, 0xfd, 0xf8, 0xa4, 0x34, 0x76, 0xf7, 0x5f,\n\t\t0x4a, 0x63, 0xf5, 0x0c, 0x4d, 0xa3, 0xe5, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x34, 0x19, 0xac,\n\t\t0x3a, 0x10, 0x30, 0x00, 0x00,\n\t}\n\tr := bytes.NewReader(gzipped)\n\tgzipr, err := compress_gzip.NewReader(r)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tungzipped, err := io_ioutil.ReadAll(gzipr)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif err := github_com_gogo_protobuf_proto.Unmarshal(ungzipped, d); err != nil {\n\t\tpanic(err)\n\t}\n\treturn d\n}\nfunc (this *Subby) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*Subby)\n\tif !ok {\n\t\tthat2, ok := that.(Subby)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *Subby\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *Subby but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *Subby but is not nil && this == nil\")\n\t}\n\tif this.Sub != that1.Sub {\n\t\treturn fmt.Errorf(\"Sub this(%v) Not Equal that(%v)\", this.Sub, that1.Sub)\n\t}\n\treturn nil\n}\nfunc (this *Subby) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*Subby)\n\tif !ok {\n\t\tthat2, ok := that.(Subby)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Sub != that1.Sub {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf but is not nil && this == nil\")\n\t}\n\tif that1.TestOneof == nil {\n\t\tif this.TestOneof != nil {\n\t\t\treturn fmt.Errorf(\"this.TestOneof != nil && that1.TestOneof == nil\")\n\t\t}\n\t} else if this.TestOneof == nil {\n\t\treturn fmt.Errorf(\"this.TestOneof == nil && that1.TestOneof != nil\")\n\t} else if err := this.TestOneof.VerboseEqual(that1.TestOneof); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field1) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field1)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field1)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field1\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field1 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field1 but is not nil && this == nil\")\n\t}\n\tif this.Field1 != that1.Field1 {\n\t\treturn fmt.Errorf(\"Field1 this(%v) Not Equal that(%v)\", this.Field1, that1.Field1)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field2) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field2)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field2)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field2\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field2 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field2 but is not nil && this == nil\")\n\t}\n\tif this.Field2 != that1.Field2 {\n\t\treturn fmt.Errorf(\"Field2 this(%v) Not Equal that(%v)\", this.Field2, that1.Field2)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field3) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field3)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field3)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field3\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field3 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field3 but is not nil && this == nil\")\n\t}\n\tif this.Field3 != that1.Field3 {\n\t\treturn fmt.Errorf(\"Field3 this(%v) Not Equal that(%v)\", this.Field3, that1.Field3)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field4) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field4)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field4)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field4\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field4 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field4 but is not nil && this == nil\")\n\t}\n\tif this.Field4 != that1.Field4 {\n\t\treturn fmt.Errorf(\"Field4 this(%v) Not Equal that(%v)\", this.Field4, that1.Field4)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field5) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field5)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field5)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field5\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field5 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field5 but is not nil && this == nil\")\n\t}\n\tif this.Field5 != that1.Field5 {\n\t\treturn fmt.Errorf(\"Field5 this(%v) Not Equal that(%v)\", this.Field5, that1.Field5)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field6) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field6)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field6)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field6\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field6 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field6 but is not nil && this == nil\")\n\t}\n\tif this.Field6 != that1.Field6 {\n\t\treturn fmt.Errorf(\"Field6 this(%v) Not Equal that(%v)\", this.Field6, that1.Field6)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field7) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field7)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field7)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field7\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field7 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field7 but is not nil && this == nil\")\n\t}\n\tif this.Field7 != that1.Field7 {\n\t\treturn fmt.Errorf(\"Field7 this(%v) Not Equal that(%v)\", this.Field7, that1.Field7)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field8) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field8)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field8)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field8\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field8 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field8 but is not nil && this == nil\")\n\t}\n\tif this.Field8 != that1.Field8 {\n\t\treturn fmt.Errorf(\"Field8 this(%v) Not Equal that(%v)\", this.Field8, that1.Field8)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field9) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field9)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field9)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field9\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field9 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field9 but is not nil && this == nil\")\n\t}\n\tif this.Field9 != that1.Field9 {\n\t\treturn fmt.Errorf(\"Field9 this(%v) Not Equal that(%v)\", this.Field9, that1.Field9)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field10) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field10)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field10)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field10\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field10 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field10 but is not nil && this == nil\")\n\t}\n\tif this.Field10 != that1.Field10 {\n\t\treturn fmt.Errorf(\"Field10 this(%v) Not Equal that(%v)\", this.Field10, that1.Field10)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field11) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field11)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field11)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field11\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field11 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field11 but is not nil && this == nil\")\n\t}\n\tif this.Field11 != that1.Field11 {\n\t\treturn fmt.Errorf(\"Field11 this(%v) Not Equal that(%v)\", this.Field11, that1.Field11)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field12) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field12)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field12)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field12\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field12 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field12 but is not nil && this == nil\")\n\t}\n\tif this.Field12 != that1.Field12 {\n\t\treturn fmt.Errorf(\"Field12 this(%v) Not Equal that(%v)\", this.Field12, that1.Field12)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field13) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field13)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field13)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field13\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field13 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field13 but is not nil && this == nil\")\n\t}\n\tif this.Field13 != that1.Field13 {\n\t\treturn fmt.Errorf(\"Field13 this(%v) Not Equal that(%v)\", this.Field13, that1.Field13)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field14) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field14)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field14)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field14\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field14 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field14 but is not nil && this == nil\")\n\t}\n\tif this.Field14 != that1.Field14 {\n\t\treturn fmt.Errorf(\"Field14 this(%v) Not Equal that(%v)\", this.Field14, that1.Field14)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_Field15) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field15)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field15)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_Field15\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field15 but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_Field15 but is not nil && this == nil\")\n\t}\n\tif !bytes.Equal(this.Field15, that1.Field15) {\n\t\treturn fmt.Errorf(\"Field15 this(%v) Not Equal that(%v)\", this.Field15, that1.Field15)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf_SubMessage) VerboseEqual(that interface{}) error {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that == nil && this != nil\")\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_SubMessage)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_SubMessage)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"that is not of type *SampleOneOf_SubMessage\")\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_SubMessage but is nil && this != nil\")\n\t} else if this == nil {\n\t\treturn fmt.Errorf(\"that is type *SampleOneOf_SubMessage but is not nil && this == nil\")\n\t}\n\tif !this.SubMessage.Equal(that1.SubMessage) {\n\t\treturn fmt.Errorf(\"SubMessage this(%v) Not Equal that(%v)\", this.SubMessage, that1.SubMessage)\n\t}\n\treturn nil\n}\nfunc (this *SampleOneOf) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif that1.TestOneof == nil {\n\t\tif this.TestOneof != nil {\n\t\t\treturn false\n\t\t}\n\t} else if this.TestOneof == nil {\n\t\treturn false\n\t} else if !this.TestOneof.Equal(that1.TestOneof) {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field1) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field1)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field1)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field1 != that1.Field1 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field2) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field2)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field2)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field2 != that1.Field2 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field3) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field3)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field3)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field3 != that1.Field3 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field4) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field4)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field4)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field4 != that1.Field4 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field5) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field5)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field5)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field5 != that1.Field5 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field6) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field6)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field6)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field6 != that1.Field6 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field7) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field7)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field7)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field7 != that1.Field7 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field8) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field8)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field8)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field8 != that1.Field8 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field9) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field9)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field9)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field9 != that1.Field9 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field10) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field10)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field10)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field10 != that1.Field10 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field11) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field11)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field11)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field11 != that1.Field11 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field12) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field12)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field12)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field12 != that1.Field12 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field13) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field13)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field13)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field13 != that1.Field13 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field14) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field14)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field14)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif this.Field14 != that1.Field14 {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_Field15) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_Field15)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_Field15)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif !bytes.Equal(this.Field15, that1.Field15) {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *SampleOneOf_SubMessage) Equal(that interface{}) bool {\n\tif that == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\tthat1, ok := that.(*SampleOneOf_SubMessage)\n\tif !ok {\n\t\tthat2, ok := that.(SampleOneOf_SubMessage)\n\t\tif ok {\n\t\t\tthat1 = &that2\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t}\n\tif that1 == nil {\n\t\tif this == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t} else if this == nil {\n\t\treturn false\n\t}\n\tif !this.SubMessage.Equal(that1.SubMessage) {\n\t\treturn false\n\t}\n\treturn true\n}\nfunc (this *Subby) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := make([]string, 0, 5)\n\ts = append(s, \"&one.Subby{\")\n\ts = append(s, \"Sub: \"+fmt.Sprintf(\"%#v\", this.Sub)+\",\\n\")\n\ts = append(s, \"}\")\n\treturn strings.Join(s, \"\")\n}\nfunc (this *SampleOneOf) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := make([]string, 0, 20)\n\ts = append(s, \"&one.SampleOneOf{\")\n\tif this.TestOneof != nil {\n\t\ts = append(s, \"TestOneof: \"+fmt.Sprintf(\"%#v\", this.TestOneof)+\",\\n\")\n\t}\n\ts = append(s, \"}\")\n\treturn strings.Join(s, \"\")\n}\nfunc (this *SampleOneOf_Field1) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field1{` +\n\t\t`Field1:` + fmt.Sprintf(\"%#v\", this.Field1) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field2) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field2{` +\n\t\t`Field2:` + fmt.Sprintf(\"%#v\", this.Field2) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field3) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field3{` +\n\t\t`Field3:` + fmt.Sprintf(\"%#v\", this.Field3) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field4) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field4{` +\n\t\t`Field4:` + fmt.Sprintf(\"%#v\", this.Field4) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field5) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field5{` +\n\t\t`Field5:` + fmt.Sprintf(\"%#v\", this.Field5) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field6) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field6{` +\n\t\t`Field6:` + fmt.Sprintf(\"%#v\", this.Field6) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field7) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field7{` +\n\t\t`Field7:` + fmt.Sprintf(\"%#v\", this.Field7) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field8) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field8{` +\n\t\t`Field8:` + fmt.Sprintf(\"%#v\", this.Field8) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field9) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field9{` +\n\t\t`Field9:` + fmt.Sprintf(\"%#v\", this.Field9) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field10) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field10{` +\n\t\t`Field10:` + fmt.Sprintf(\"%#v\", this.Field10) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field11) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field11{` +\n\t\t`Field11:` + fmt.Sprintf(\"%#v\", this.Field11) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field12) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field12{` +\n\t\t`Field12:` + fmt.Sprintf(\"%#v\", this.Field12) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field13) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field13{` +\n\t\t`Field13:` + fmt.Sprintf(\"%#v\", this.Field13) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field14) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field14{` +\n\t\t`Field14:` + fmt.Sprintf(\"%#v\", this.Field14) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_Field15) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_Field15{` +\n\t\t`Field15:` + fmt.Sprintf(\"%#v\", this.Field15) + `}`}, \", \")\n\treturn s\n}\nfunc (this *SampleOneOf_SubMessage) GoString() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&one.SampleOneOf_SubMessage{` +\n\t\t`SubMessage:` + fmt.Sprintf(\"%#v\", this.SubMessage) + `}`}, \", \")\n\treturn s\n}\nfunc valueToGoStringOne(v interface{}, typ string) string {\n\trv := reflect.ValueOf(v)\n\tif rv.IsNil() {\n\t\treturn \"nil\"\n\t}\n\tpv := reflect.Indirect(rv).Interface()\n\treturn fmt.Sprintf(\"func(v %v) *%v { return &v } ( %#v )\", typ, typ, pv)\n}\nfunc (m *Subby) Marshal() (dAtA []byte, err error) {\n\tsize := m.Size()\n\tdAtA = make([]byte, size)\n\tn, err := m.MarshalTo(dAtA)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn dAtA[:n], nil\n}\n\nfunc (m *Subby) MarshalTo(dAtA []byte) (int, error) {\n\tvar i int\n\t_ = i\n\tvar l int\n\t_ = l\n\tif len(m.Sub) > 0 {\n\t\tdAtA[i] = 0xa\n\t\ti++\n\t\ti = encodeVarintOne(dAtA, i, uint64(len(m.Sub)))\n\t\ti += copy(dAtA[i:], m.Sub)\n\t}\n\treturn i, nil\n}\n\nfunc (m *SampleOneOf) Marshal() (dAtA []byte, err error) {\n\tsize := m.Size()\n\tdAtA = make([]byte, size)\n\tn, err := m.MarshalTo(dAtA)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn dAtA[:n], nil\n}\n\nfunc (m *SampleOneOf) MarshalTo(dAtA []byte) (int, error) {\n\tvar i int\n\t_ = i\n\tvar l int\n\t_ = l\n\tif m.TestOneof != nil {\n\t\tnn1, err := m.TestOneof.MarshalTo(dAtA[i:])\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\ti += nn1\n\t}\n\treturn i, nil\n}\n\nfunc (m *SampleOneOf_Field1) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x9\n\ti++\n\ti = encodeFixed64One(dAtA, i, uint64(math.Float64bits(float64(m.Field1))))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field2) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x15\n\ti++\n\ti = encodeFixed32One(dAtA, i, uint32(math.Float32bits(float32(m.Field2))))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field3) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x18\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64(m.Field3))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field4) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x20\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64(m.Field4))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field5) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x28\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64(m.Field5))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field6) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x30\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64(m.Field6))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field7) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x38\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64((uint32(m.Field7)<<1)^uint32((m.Field7>>31))))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field8) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x40\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64((uint64(m.Field8)<<1)^uint64((m.Field8>>63))))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field9) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x4d\n\ti++\n\ti = encodeFixed32One(dAtA, i, uint32(m.Field9))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field10) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x55\n\ti++\n\ti = encodeFixed32One(dAtA, i, uint32(m.Field10))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field11) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x59\n\ti++\n\ti = encodeFixed64One(dAtA, i, uint64(m.Field11))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field12) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x61\n\ti++\n\ti = encodeFixed64One(dAtA, i, uint64(m.Field12))\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field13) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x68\n\ti++\n\tif m.Field13 {\n\t\tdAtA[i] = 1\n\t} else {\n\t\tdAtA[i] = 0\n\t}\n\ti++\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field14) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tdAtA[i] = 0x72\n\ti++\n\ti = encodeVarintOne(dAtA, i, uint64(len(m.Field14)))\n\ti += copy(dAtA[i:], m.Field14)\n\treturn i, nil\n}\nfunc (m *SampleOneOf_Field15) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tif m.Field15 != nil {\n\t\tdAtA[i] = 0x7a\n\t\ti++\n\t\ti = encodeVarintOne(dAtA, i, uint64(len(m.Field15)))\n\t\ti += copy(dAtA[i:], m.Field15)\n\t}\n\treturn i, nil\n}\nfunc (m *SampleOneOf_SubMessage) MarshalTo(dAtA []byte) (int, error) {\n\ti := 0\n\tif m.SubMessage != nil {\n\t\tdAtA[i] = 0x82\n\t\ti++\n\t\tdAtA[i] = 0x1\n\t\ti++\n\t\ti = encodeVarintOne(dAtA, i, uint64(m.SubMessage.Size()))\n\t\tn2, err := m.SubMessage.MarshalTo(dAtA[i:])\n\t\tif err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\ti += n2\n\t}\n\treturn i, nil\n}\nfunc encodeFixed64One(dAtA []byte, offset int, v uint64) int {\n\tdAtA[offset] = uint8(v)\n\tdAtA[offset+1] = uint8(v >> 8)\n\tdAtA[offset+2] = uint8(v >> 16)\n\tdAtA[offset+3] = uint8(v >> 24)\n\tdAtA[offset+4] = uint8(v >> 32)\n\tdAtA[offset+5] = uint8(v >> 40)\n\tdAtA[offset+6] = uint8(v >> 48)\n\tdAtA[offset+7] = uint8(v >> 56)\n\treturn offset + 8\n}\nfunc encodeFixed32One(dAtA []byte, offset int, v uint32) int {\n\tdAtA[offset] = uint8(v)\n\tdAtA[offset+1] = uint8(v >> 8)\n\tdAtA[offset+2] = uint8(v >> 16)\n\tdAtA[offset+3] = uint8(v >> 24)\n\treturn offset + 4\n}\nfunc encodeVarintOne(dAtA []byte, offset int, v uint64) int {\n\tfor v >= 1<<7 {\n\t\tdAtA[offset] = uint8(v&0x7f | 0x80)\n\t\tv >>= 7\n\t\toffset++\n\t}\n\tdAtA[offset] = uint8(v)\n\treturn offset + 1\n}\nfunc NewPopulatedSubby(r randyOne, easy bool) *Subby {\n\tthis := &Subby{}\n\tthis.Sub = string(randStringOne(r))\n\tif !easy && r.Intn(10) != 0 {\n\t}\n\treturn this\n}\n\nfunc NewPopulatedSampleOneOf(r randyOne, easy bool) *SampleOneOf {\n\tthis := &SampleOneOf{}\n\toneofNumber_TestOneof := []int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}[r.Intn(16)]\n\tswitch oneofNumber_TestOneof {\n\tcase 1:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field1(r, easy)\n\tcase 2:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field2(r, easy)\n\tcase 3:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field3(r, easy)\n\tcase 4:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field4(r, easy)\n\tcase 5:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field5(r, easy)\n\tcase 6:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field6(r, easy)\n\tcase 7:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field7(r, easy)\n\tcase 8:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field8(r, easy)\n\tcase 9:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field9(r, easy)\n\tcase 10:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field10(r, easy)\n\tcase 11:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field11(r, easy)\n\tcase 12:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field12(r, easy)\n\tcase 13:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field13(r, easy)\n\tcase 14:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field14(r, easy)\n\tcase 15:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_Field15(r, easy)\n\tcase 16:\n\t\tthis.TestOneof = NewPopulatedSampleOneOf_SubMessage(r, easy)\n\t}\n\tif !easy && r.Intn(10) != 0 {\n\t}\n\treturn this\n}\n\nfunc NewPopulatedSampleOneOf_Field1(r randyOne, easy bool) *SampleOneOf_Field1 {\n\tthis := &SampleOneOf_Field1{}\n\tthis.Field1 = float64(r.Float64())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field1 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field2(r randyOne, easy bool) *SampleOneOf_Field2 {\n\tthis := &SampleOneOf_Field2{}\n\tthis.Field2 = float32(r.Float32())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field2 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field3(r randyOne, easy bool) *SampleOneOf_Field3 {\n\tthis := &SampleOneOf_Field3{}\n\tthis.Field3 = int32(r.Int31())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field3 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field4(r randyOne, easy bool) *SampleOneOf_Field4 {\n\tthis := &SampleOneOf_Field4{}\n\tthis.Field4 = int64(r.Int63())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field4 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field5(r randyOne, easy bool) *SampleOneOf_Field5 {\n\tthis := &SampleOneOf_Field5{}\n\tthis.Field5 = uint32(r.Uint32())\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field6(r randyOne, easy bool) *SampleOneOf_Field6 {\n\tthis := &SampleOneOf_Field6{}\n\tthis.Field6 = uint64(uint64(r.Uint32()))\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field7(r randyOne, easy bool) *SampleOneOf_Field7 {\n\tthis := &SampleOneOf_Field7{}\n\tthis.Field7 = int32(r.Int31())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field7 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field8(r randyOne, easy bool) *SampleOneOf_Field8 {\n\tthis := &SampleOneOf_Field8{}\n\tthis.Field8 = int64(r.Int63())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field8 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field9(r randyOne, easy bool) *SampleOneOf_Field9 {\n\tthis := &SampleOneOf_Field9{}\n\tthis.Field9 = uint32(r.Uint32())\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field10(r randyOne, easy bool) *SampleOneOf_Field10 {\n\tthis := &SampleOneOf_Field10{}\n\tthis.Field10 = int32(r.Int31())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field10 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field11(r randyOne, easy bool) *SampleOneOf_Field11 {\n\tthis := &SampleOneOf_Field11{}\n\tthis.Field11 = uint64(uint64(r.Uint32()))\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field12(r randyOne, easy bool) *SampleOneOf_Field12 {\n\tthis := &SampleOneOf_Field12{}\n\tthis.Field12 = int64(r.Int63())\n\tif r.Intn(2) == 0 {\n\t\tthis.Field12 *= -1\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field13(r randyOne, easy bool) *SampleOneOf_Field13 {\n\tthis := &SampleOneOf_Field13{}\n\tthis.Field13 = bool(bool(r.Intn(2) == 0))\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field14(r randyOne, easy bool) *SampleOneOf_Field14 {\n\tthis := &SampleOneOf_Field14{}\n\tthis.Field14 = string(randStringOne(r))\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_Field15(r randyOne, easy bool) *SampleOneOf_Field15 {\n\tthis := &SampleOneOf_Field15{}\n\tv1 := r.Intn(100)\n\tthis.Field15 = make([]byte, v1)\n\tfor i := 0; i < v1; i++ {\n\t\tthis.Field15[i] = byte(r.Intn(256))\n\t}\n\treturn this\n}\nfunc NewPopulatedSampleOneOf_SubMessage(r randyOne, easy bool) *SampleOneOf_SubMessage {\n\tthis := &SampleOneOf_SubMessage{}\n\tthis.SubMessage = NewPopulatedSubby(r, easy)\n\treturn this\n}\n\ntype randyOne interface {\n\tFloat32() float32\n\tFloat64() float64\n\tInt63() int64\n\tInt31() int32\n\tUint32() uint32\n\tIntn(n int) int\n}\n\nfunc randUTF8RuneOne(r randyOne) rune {\n\tru := r.Intn(62)\n\tif ru < 10 {\n\t\treturn rune(ru + 48)\n\t} else if ru < 36 {\n\t\treturn rune(ru + 55)\n\t}\n\treturn rune(ru + 61)\n}\nfunc randStringOne(r randyOne) string {\n\tv2 := r.Intn(100)\n\ttmps := make([]rune, v2)\n\tfor i := 0; i < v2; i++ {\n\t\ttmps[i] = randUTF8RuneOne(r)\n\t}\n\treturn string(tmps)\n}\nfunc randUnrecognizedOne(r randyOne, maxFieldNumber int) (dAtA []byte) {\n\tl := r.Intn(5)\n\tfor i := 0; i < l; i++ {\n\t\twire := r.Intn(4)\n\t\tif wire == 3 {\n\t\t\twire = 5\n\t\t}\n\t\tfieldNumber := maxFieldNumber + r.Intn(100)\n\t\tdAtA = randFieldOne(dAtA, r, fieldNumber, wire)\n\t}\n\treturn dAtA\n}\nfunc randFieldOne(dAtA []byte, r randyOne, fieldNumber int, wire int) []byte {\n\tkey := uint32(fieldNumber)<<3 | uint32(wire)\n\tswitch wire {\n\tcase 0:\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(key))\n\t\tv3 := r.Int63()\n\t\tif r.Intn(2) == 0 {\n\t\t\tv3 *= -1\n\t\t}\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(v3))\n\tcase 1:\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(key))\n\t\tdAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))\n\tcase 2:\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(key))\n\t\tll := r.Intn(100)\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(ll))\n\t\tfor j := 0; j < ll; j++ {\n\t\t\tdAtA = append(dAtA, byte(r.Intn(256)))\n\t\t}\n\tdefault:\n\t\tdAtA = encodeVarintPopulateOne(dAtA, uint64(key))\n\t\tdAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))\n\t}\n\treturn dAtA\n}\nfunc encodeVarintPopulateOne(dAtA []byte, v uint64) []byte {\n\tfor v >= 1<<7 {\n\t\tdAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))\n\t\tv >>= 7\n\t}\n\tdAtA = append(dAtA, uint8(v))\n\treturn dAtA\n}\nfunc (m *Subby) Size() (n int) {\n\tvar l int\n\t_ = l\n\tl = len(m.Sub)\n\tif l > 0 {\n\t\tn += 1 + l + sovOne(uint64(l))\n\t}\n\treturn n\n}\n\nfunc (m *SampleOneOf) Size() (n int) {\n\tvar l int\n\t_ = l\n\tif m.TestOneof != nil {\n\t\tn += m.TestOneof.Size()\n\t}\n\treturn n\n}\n\nfunc (m *SampleOneOf_Field1) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 9\n\treturn n\n}\nfunc (m *SampleOneOf_Field2) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 5\n\treturn n\n}\nfunc (m *SampleOneOf_Field3) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sovOne(uint64(m.Field3))\n\treturn n\n}\nfunc (m *SampleOneOf_Field4) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sovOne(uint64(m.Field4))\n\treturn n\n}\nfunc (m *SampleOneOf_Field5) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sovOne(uint64(m.Field5))\n\treturn n\n}\nfunc (m *SampleOneOf_Field6) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sovOne(uint64(m.Field6))\n\treturn n\n}\nfunc (m *SampleOneOf_Field7) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sozOne(uint64(m.Field7))\n\treturn n\n}\nfunc (m *SampleOneOf_Field8) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 1 + sozOne(uint64(m.Field8))\n\treturn n\n}\nfunc (m *SampleOneOf_Field9) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 5\n\treturn n\n}\nfunc (m *SampleOneOf_Field10) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 5\n\treturn n\n}\nfunc (m *SampleOneOf_Field11) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 9\n\treturn n\n}\nfunc (m *SampleOneOf_Field12) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 9\n\treturn n\n}\nfunc (m *SampleOneOf_Field13) Size() (n int) {\n\tvar l int\n\t_ = l\n\tn += 2\n\treturn n\n}\nfunc (m *SampleOneOf_Field14) Size() (n int) {\n\tvar l int\n\t_ = l\n\tl = len(m.Field14)\n\tn += 1 + l + sovOne(uint64(l))\n\treturn n\n}\nfunc (m *SampleOneOf_Field15) Size() (n int) {\n\tvar l int\n\t_ = l\n\tif m.Field15 != nil {\n\t\tl = len(m.Field15)\n\t\tn += 1 + l + sovOne(uint64(l))\n\t}\n\treturn n\n}\nfunc (m *SampleOneOf_SubMessage) Size() (n int) {\n\tvar l int\n\t_ = l\n\tif m.SubMessage != nil {\n\t\tl = m.SubMessage.Size()\n\t\tn += 2 + l + sovOne(uint64(l))\n\t}\n\treturn n\n}\n\nfunc sovOne(x uint64) (n int) {\n\tfor {\n\t\tn++\n\t\tx >>= 7\n\t\tif x == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn n\n}\nfunc sozOne(x uint64) (n int) {\n\treturn sovOne(uint64((x << 1) ^ uint64((int64(x) >> 63))))\n}\nfunc (this *Subby) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&Subby{`,\n\t\t`Sub:` + fmt.Sprintf(\"%v\", this.Sub) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf{`,\n\t\t`TestOneof:` + fmt.Sprintf(\"%v\", this.TestOneof) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field1) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field1{`,\n\t\t`Field1:` + fmt.Sprintf(\"%v\", this.Field1) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field2) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field2{`,\n\t\t`Field2:` + fmt.Sprintf(\"%v\", this.Field2) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field3) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field3{`,\n\t\t`Field3:` + fmt.Sprintf(\"%v\", this.Field3) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field4) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field4{`,\n\t\t`Field4:` + fmt.Sprintf(\"%v\", this.Field4) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field5) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field5{`,\n\t\t`Field5:` + fmt.Sprintf(\"%v\", this.Field5) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field6) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field6{`,\n\t\t`Field6:` + fmt.Sprintf(\"%v\", this.Field6) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field7) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field7{`,\n\t\t`Field7:` + fmt.Sprintf(\"%v\", this.Field7) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field8) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field8{`,\n\t\t`Field8:` + fmt.Sprintf(\"%v\", this.Field8) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field9) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field9{`,\n\t\t`Field9:` + fmt.Sprintf(\"%v\", this.Field9) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field10) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field10{`,\n\t\t`Field10:` + fmt.Sprintf(\"%v\", this.Field10) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field11) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field11{`,\n\t\t`Field11:` + fmt.Sprintf(\"%v\", this.Field11) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field12) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field12{`,\n\t\t`Field12:` + fmt.Sprintf(\"%v\", this.Field12) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field13) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field13{`,\n\t\t`Field13:` + fmt.Sprintf(\"%v\", this.Field13) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field14) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field14{`,\n\t\t`Field14:` + fmt.Sprintf(\"%v\", this.Field14) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_Field15) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_Field15{`,\n\t\t`Field15:` + fmt.Sprintf(\"%v\", this.Field15) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc (this *SampleOneOf_SubMessage) String() string {\n\tif this == nil {\n\t\treturn \"nil\"\n\t}\n\ts := strings.Join([]string{`&SampleOneOf_SubMessage{`,\n\t\t`SubMessage:` + strings.Replace(fmt.Sprintf(\"%v\", this.SubMessage), \"Subby\", \"Subby\", 1) + `,`,\n\t\t`}`,\n\t}, \"\")\n\treturn s\n}\nfunc valueToStringOne(v interface{}) string {\n\trv := reflect.ValueOf(v)\n\tif rv.IsNil() {\n\t\treturn \"nil\"\n\t}\n\tpv := reflect.Indirect(rv).Interface()\n\treturn fmt.Sprintf(\"*%v\", pv)\n}\nfunc (m *Subby) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowOne\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= (uint64(b) & 0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: Subby: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: Subby: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Sub\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= (uint64(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.Sub = string(dAtA[iNdEx:postIndex])\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipOne(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}\nfunc (m *SampleOneOf) Unmarshal(dAtA []byte) error {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tpreIndex := iNdEx\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn ErrIntOverflowOne\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= (uint64(b) & 0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfieldNum := int32(wire >> 3)\n\t\twireType := int(wire & 0x7)\n\t\tif wireType == 4 {\n\t\t\treturn fmt.Errorf(\"proto: SampleOneOf: wiretype end group for non-group\")\n\t\t}\n\t\tif fieldNum <= 0 {\n\t\t\treturn fmt.Errorf(\"proto: SampleOneOf: illegal tag %d (wire type %d)\", fieldNum, wire)\n\t\t}\n\t\tswitch fieldNum {\n\t\tcase 1:\n\t\t\tif wireType != 1 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field1\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tif (iNdEx + 8) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 8\n\t\t\tv = uint64(dAtA[iNdEx-8])\n\t\t\tv |= uint64(dAtA[iNdEx-7]) << 8\n\t\t\tv |= uint64(dAtA[iNdEx-6]) << 16\n\t\t\tv |= uint64(dAtA[iNdEx-5]) << 24\n\t\t\tv |= uint64(dAtA[iNdEx-4]) << 32\n\t\t\tv |= uint64(dAtA[iNdEx-3]) << 40\n\t\t\tv |= uint64(dAtA[iNdEx-2]) << 48\n\t\t\tv |= uint64(dAtA[iNdEx-1]) << 56\n\t\t\tm.TestOneof = &SampleOneOf_Field1{float64(math.Float64frombits(v))}\n\t\tcase 2:\n\t\t\tif wireType != 5 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field2\", wireType)\n\t\t\t}\n\t\t\tvar v uint32\n\t\t\tif (iNdEx + 4) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 4\n\t\t\tv = uint32(dAtA[iNdEx-4])\n\t\t\tv |= uint32(dAtA[iNdEx-3]) << 8\n\t\t\tv |= uint32(dAtA[iNdEx-2]) << 16\n\t\t\tv |= uint32(dAtA[iNdEx-1]) << 24\n\t\t\tm.TestOneof = &SampleOneOf_Field2{float32(math.Float32frombits(v))}\n\t\tcase 3:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field3\", wireType)\n\t\t\t}\n\t\t\tvar v int32\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (int32(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_Field3{v}\n\t\tcase 4:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field4\", wireType)\n\t\t\t}\n\t\t\tvar v int64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (int64(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_Field4{v}\n\t\tcase 5:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field5\", wireType)\n\t\t\t}\n\t\t\tvar v uint32\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (uint32(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_Field5{v}\n\t\tcase 6:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field6\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (uint64(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_Field6{v}\n\t\tcase 7:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field7\", wireType)\n\t\t\t}\n\t\t\tvar v int32\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (int32(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tv = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31))\n\t\t\tm.TestOneof = &SampleOneOf_Field7{v}\n\t\tcase 8:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field8\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (uint64(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tv = (v >> 1) ^ uint64((int64(v&1)<<63)>>63)\n\t\t\tm.TestOneof = &SampleOneOf_Field8{int64(v)}\n\t\tcase 9:\n\t\t\tif wireType != 5 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field9\", wireType)\n\t\t\t}\n\t\t\tvar v uint32\n\t\t\tif (iNdEx + 4) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 4\n\t\t\tv = uint32(dAtA[iNdEx-4])\n\t\t\tv |= uint32(dAtA[iNdEx-3]) << 8\n\t\t\tv |= uint32(dAtA[iNdEx-2]) << 16\n\t\t\tv |= uint32(dAtA[iNdEx-1]) << 24\n\t\t\tm.TestOneof = &SampleOneOf_Field9{v}\n\t\tcase 10:\n\t\t\tif wireType != 5 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field10\", wireType)\n\t\t\t}\n\t\t\tvar v int32\n\t\t\tif (iNdEx + 4) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 4\n\t\t\tv = int32(dAtA[iNdEx-4])\n\t\t\tv |= int32(dAtA[iNdEx-3]) << 8\n\t\t\tv |= int32(dAtA[iNdEx-2]) << 16\n\t\t\tv |= int32(dAtA[iNdEx-1]) << 24\n\t\t\tm.TestOneof = &SampleOneOf_Field10{v}\n\t\tcase 11:\n\t\t\tif wireType != 1 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field11\", wireType)\n\t\t\t}\n\t\t\tvar v uint64\n\t\t\tif (iNdEx + 8) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 8\n\t\t\tv = uint64(dAtA[iNdEx-8])\n\t\t\tv |= uint64(dAtA[iNdEx-7]) << 8\n\t\t\tv |= uint64(dAtA[iNdEx-6]) << 16\n\t\t\tv |= uint64(dAtA[iNdEx-5]) << 24\n\t\t\tv |= uint64(dAtA[iNdEx-4]) << 32\n\t\t\tv |= uint64(dAtA[iNdEx-3]) << 40\n\t\t\tv |= uint64(dAtA[iNdEx-2]) << 48\n\t\t\tv |= uint64(dAtA[iNdEx-1]) << 56\n\t\t\tm.TestOneof = &SampleOneOf_Field11{v}\n\t\tcase 12:\n\t\t\tif wireType != 1 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field12\", wireType)\n\t\t\t}\n\t\t\tvar v int64\n\t\t\tif (iNdEx + 8) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += 8\n\t\t\tv = int64(dAtA[iNdEx-8])\n\t\t\tv |= int64(dAtA[iNdEx-7]) << 8\n\t\t\tv |= int64(dAtA[iNdEx-6]) << 16\n\t\t\tv |= int64(dAtA[iNdEx-5]) << 24\n\t\t\tv |= int64(dAtA[iNdEx-4]) << 32\n\t\t\tv |= int64(dAtA[iNdEx-3]) << 40\n\t\t\tv |= int64(dAtA[iNdEx-2]) << 48\n\t\t\tv |= int64(dAtA[iNdEx-1]) << 56\n\t\t\tm.TestOneof = &SampleOneOf_Field12{v}\n\t\tcase 13:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field13\", wireType)\n\t\t\t}\n\t\t\tvar v int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tv |= (int(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tb := bool(v != 0)\n\t\t\tm.TestOneof = &SampleOneOf_Field13{b}\n\t\tcase 14:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field14\", wireType)\n\t\t\t}\n\t\t\tvar stringLen uint64\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tstringLen |= (uint64(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tintStringLen := int(stringLen)\n\t\t\tif intStringLen < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tpostIndex := iNdEx + intStringLen\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_Field14{string(dAtA[iNdEx:postIndex])}\n\t\t\tiNdEx = postIndex\n\t\tcase 15:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field Field15\", wireType)\n\t\t\t}\n\t\t\tvar byteLen int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tbyteLen |= (int(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif byteLen < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tpostIndex := iNdEx + byteLen\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tv := make([]byte, postIndex-iNdEx)\n\t\t\tcopy(v, dAtA[iNdEx:postIndex])\n\t\t\tm.TestOneof = &SampleOneOf_Field15{v}\n\t\t\tiNdEx = postIndex\n\t\tcase 16:\n\t\t\tif wireType != 2 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field SubMessage\", wireType)\n\t\t\t}\n\t\t\tvar msglen int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tmsglen |= (int(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif msglen < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tpostIndex := iNdEx + msglen\n\t\t\tif postIndex > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tv := &Subby{}\n\t\t\tif err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tm.TestOneof = &SampleOneOf_SubMessage{v}\n\t\t\tiNdEx = postIndex\n\t\tdefault:\n\t\t\tiNdEx = preIndex\n\t\t\tskippy, err := skipOne(dAtA[iNdEx:])\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif skippy < 0 {\n\t\t\t\treturn ErrInvalidLengthOne\n\t\t\t}\n\t\t\tif (iNdEx + skippy) > l {\n\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tiNdEx += skippy\n\t\t}\n\t}\n\n\tif iNdEx > l {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\treturn nil\n}\nfunc skipOne(dAtA []byte) (n int, err error) {\n\tl := len(dAtA)\n\tiNdEx := 0\n\tfor iNdEx < l {\n\t\tvar wire uint64\n\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\tif shift >= 64 {\n\t\t\t\treturn 0, ErrIntOverflowOne\n\t\t\t}\n\t\t\tif iNdEx >= l {\n\t\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t\t}\n\t\t\tb := dAtA[iNdEx]\n\t\t\tiNdEx++\n\t\t\twire |= (uint64(b) & 0x7F) << shift\n\t\t\tif b < 0x80 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\twireType := int(wire & 0x7)\n\t\tswitch wireType {\n\t\tcase 0:\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn 0, ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tiNdEx++\n\t\t\t\tif dAtA[iNdEx-1] < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn iNdEx, nil\n\t\tcase 1:\n\t\t\tiNdEx += 8\n\t\t\treturn iNdEx, nil\n\t\tcase 2:\n\t\t\tvar length int\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn 0, ErrIntOverflowOne\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tlength |= (int(b) & 0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tiNdEx += length\n\t\t\tif length < 0 {\n\t\t\t\treturn 0, ErrInvalidLengthOne\n\t\t\t}\n\t\t\treturn iNdEx, nil\n\t\tcase 3:\n\t\t\tfor {\n\t\t\t\tvar innerWire uint64\n\t\t\t\tvar start int = iNdEx\n\t\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\t\tif shift >= 64 {\n\t\t\t\t\t\treturn 0, ErrIntOverflowOne\n\t\t\t\t\t}\n\t\t\t\t\tif iNdEx >= l {\n\t\t\t\t\t\treturn 0, io.ErrUnexpectedEOF\n\t\t\t\t\t}\n\t\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\t\tiNdEx++\n\t\t\t\t\tinnerWire |= (uint64(b) & 0x7F) << shift\n\t\t\t\t\tif b < 0x80 {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tinnerWireType := int(innerWire & 0x7)\n\t\t\t\tif innerWireType == 4 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tnext, err := skipOne(dAtA[start:])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn 0, err\n\t\t\t\t}\n\t\t\t\tiNdEx = start + next\n\t\t\t}\n\t\t\treturn iNdEx, nil\n\t\tcase 4:\n\t\t\treturn iNdEx, nil\n\t\tcase 5:\n\t\t\tiNdEx += 4\n\t\t\treturn iNdEx, nil\n\t\tdefault:\n\t\t\treturn 0, fmt.Errorf(\"proto: illegal wireType %d\", wireType)\n\t\t}\n\t}\n\tpanic(\"unreachable\")\n}\n\nvar (\n\tErrInvalidLengthOne = fmt.Errorf(\"proto: negative length found during unmarshaling\")\n\tErrIntOverflowOne = fmt.Errorf(\"proto: integer overflow\")\n)\n\nfunc init() { proto.RegisterFile(\"combos/both/one.proto\", fileDescriptorOne) }\n\nvar fileDescriptorOne = []byte{\n\t// 404 bytes of a gzipped FileDescriptorProto\n\t0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0xd2, 0xbf, 0x4f, 0x1b, 0x31,\n\t0x14, 0x07, 0x70, 0x3f, 0x8e, 0x24, 0xe0, 0x84, 0x92, 0x9e, 0x54, 0xe9, 0x95, 0xe1, 0xc9, 0x62,\n\t0xf2, 0x42, 0xd2, 0xdc, 0x25, 0xfc, 0x58, 0x51, 0x55, 0x65, 0xa9, 0x90, 0xc2, 0x1f, 0x80, 0x30,\n\t0x75, 0x0e, 0x24, 0xee, 0x8c, 0x7a, 0x77, 0x43, 0x37, 0xfe, 0x9c, 0x8e, 0x1d, 0xfb, 0x27, 0x30,\n\t0x32, 0x76, 0xe8, 0xc0, 0xb9, 0x4b, 0x47, 0x46, 0xc6, 0x2a, 0x97, 0xf2, 0xbc, 0xbd, 0xaf, 0x3f,\n\t0xf6, 0x60, 0xfb, 0x2b, 0xdf, 0x5d, 0xb9, 0xdc, 0xb8, 0x72, 0x6c, 0x5c, 0x75, 0x3d, 0x76, 0x85,\n\t0x1d, 0xdd, 0x7d, 0x75, 0x95, 0x8b, 0x23, 0x57, 0xd8, 0xbd, 0x83, 0xec, 0xa6, 0xba, 0xae, 0xcd,\n\t0xe8, 0xca, 0xe5, 0xe3, 0xcc, 0x65, 0x6e, 0xdc, 0x9a, 0xa9, 0x97, 0x6d, 0x6a, 0x43, 0x3b, 0xad,\n\t0xcf, 0xec, 0xbf, 0x97, 0x9d, 0xf3, 0xda, 0x98, 0x6f, 0xf1, 0x50, 0x46, 0x65, 0x6d, 0x10, 0x14,\n\t0xe8, 0xed, 0xc5, 0x6a, 0xdc, 0xff, 0x1d, 0xc9, 0xfe, 0xf9, 0x65, 0x7e, 0x77, 0x6b, 0xcf, 0x0a,\n\t0x7b, 0xb6, 0x8c, 0x51, 0x76, 0x3f, 0xdd, 0xd8, 0xdb, 0x2f, 0x93, 0x76, 0x13, 0xcc, 0xc5, 0xe2,\n\t0x7f, 0x66, 0x49, 0x70, 0x43, 0x81, 0xde, 0x60, 0x49, 0x58, 0x52, 0x8c, 0x14, 0xe8, 0x0e, 0x4b,\n\t0xca, 0x32, 0xc5, 0x4d, 0x05, 0x3a, 0x62, 0x99, 0xb2, 0xcc, 0xb0, 0xa3, 0x40, 0xef, 0xb0, 0xcc,\n\t0x58, 0x0e, 0xb1, 0xab, 0x40, 0x6f, 0xb2, 0x1c, 0xb2, 0x1c, 0x61, 0x4f, 0x81, 0x7e, 0xcb, 0x72,\n\t0xc4, 0x72, 0x8c, 0x5b, 0x0a, 0x74, 0xcc, 0x72, 0xcc, 0x72, 0x82, 0xdb, 0x0a, 0x74, 0x8f, 0xe5,\n\t0x24, 0xde, 0x93, 0xbd, 0xf5, 0xcd, 0x3e, 0xa0, 0x54, 0xa0, 0x77, 0xe7, 0x62, 0xf1, 0xba, 0x10,\n\t0x6c, 0x82, 0x7d, 0x05, 0xba, 0x1b, 0x6c, 0x12, 0x2c, 0xc1, 0x81, 0x02, 0x3d, 0x0c, 0x96, 0x04,\n\t0x4b, 0x71, 0x47, 0x81, 0xde, 0x0a, 0x96, 0x06, 0x9b, 0xe2, 0x9b, 0xd5, 0xfb, 0x07, 0x9b, 0x06,\n\t0x9b, 0xe1, 0xae, 0x02, 0x3d, 0x08, 0x36, 0x8b, 0x0f, 0x64, 0xbf, 0xac, 0xcd, 0x45, 0x6e, 0xcb,\n\t0xf2, 0x32, 0xb3, 0x38, 0x54, 0xa0, 0xfb, 0x89, 0x1c, 0xad, 0x1a, 0xd1, 0x7e, 0xea, 0x5c, 0x2c,\n\t0x64, 0x59, 0x9b, 0xcf, 0x6b, 0x3f, 0x1d, 0x48, 0x59, 0xd9, 0xb2, 0xba, 0x70, 0x85, 0x75, 0xcb,\n\t0xd3, 0x8f, 0x0f, 0x0d, 0x89, 0xc7, 0x86, 0xc4, 0xaf, 0x86, 0xc4, 0x53, 0x43, 0xf0, 0xdc, 0x10,\n\t0xbc, 0x34, 0x04, 0xf7, 0x9e, 0xe0, 0xbb, 0x27, 0xf8, 0xe1, 0x09, 0x7e, 0x7a, 0x82, 0x07, 0x4f,\n\t0xf0, 0xe8, 0x09, 0x9e, 0x3c, 0xc1, 0x5f, 0x4f, 0xe2, 0xd9, 0x13, 0xbc, 0x78, 0x12, 0xf7, 0x7f,\n\t0x48, 0x98, 0x6e, 0x5b, 0xa3, 0xf4, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x42, 0xd6, 0x88,\n\t0x93, 0x02, 0x00, 0x00,\n}\n"},"repo_name":{"kind":"string","value":"ae6rt/decap"},"path":{"kind":"string","value":"web/vendor/github.com/gogo/protobuf/test/oneof3/combos/both/one.pb.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":99707,"string":"99,707"}}},{"rowIdx":61538432,"cells":{"code":{"kind":"string","value":"/*\n * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.\n * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n *\n * This code is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License version 2 only, as\n * published by the Free Software Foundation.\n *\n * This code is distributed in the hope that it will be useful, but WITHOUT\n * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n * version 2 for more details (a copy is included in the LICENSE file that\n * accompanied this code).\n *\n * You should have received a copy of the GNU General Public License version\n * 2 along with this work; if not, write to the Free Software Foundation,\n * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n * or visit www.oracle.com if you need additional information or have any\n * questions.\n */\n\n/*\n * @test\n * @bug 6350057 7025809\n * @summary Test that parameters on implicit enum methods have the right kind\n * @author Joseph D. Darcy\n * @library /tools/javac/lib\n * @modules java.compiler\n * jdk.compiler\n * @build JavacTestingAbstractProcessor T6350057\n * @compile -processor T6350057 -proc:only TestEnum.java\n */\n\nimport java.util.Set;\nimport javax.annotation.processing.AbstractProcessor;\nimport javax.annotation.processing.RoundEnvironment;\nimport javax.annotation.processing.SupportedAnnotationTypes;\nimport javax.lang.model.element.*;\nimport javax.lang.model.util.*;\nimport static javax.tools.Diagnostic.Kind.*;\n\npublic class T6350057 extends JavacTestingAbstractProcessor {\n static class LocalVarAllergy extends ElementKindVisitor {\n @Override\n public Boolean visitTypeAsEnum(TypeElement e, Void v) {\n System.out.println(\"visitTypeAsEnum: \" + e.getSimpleName().toString());\n for(Element el: e.getEnclosedElements() )\n this.visit(el);\n return true;\n }\n\n @Override\n public Boolean visitVariableAsLocalVariable(VariableElement e, Void v){\n throw new IllegalStateException(\"Should not see any local variables!\");\n }\n\n @Override\n public Boolean visitVariableAsParameter(VariableElement e, Void v){\n String senclm=e.getEnclosingElement().getEnclosingElement().getSimpleName().toString();\n String sEncl = senclm+\".\"+e.getEnclosingElement().getSimpleName().toString();\n String stype = e.asType().toString();\n String name = e.getSimpleName().toString();\n System.out.println(\"visitVariableAsParameter: \" +sEncl+\".\" + stype + \" \" + name);\n return true;\n }\n\n @Override\n public Boolean visitExecutableAsMethod(ExecutableElement e, Void v){\n String name=e.getEnclosingElement().getSimpleName().toString();\n name = name + \".\"+e.getSimpleName().toString();\n System.out.println(\"visitExecutableAsMethod: \" + name);\n for (VariableElement ve: e.getParameters())\n this.visit(ve);\n return true;\n }\n }\n\n public boolean process(Set annotations,\n RoundEnvironment roundEnvironment) {\n if (!roundEnvironment.processingOver())\n for(Element element : roundEnvironment.getRootElements())\n element.accept(new LocalVarAllergy(), null);\n return true;\n }\n}\n"},"repo_name":{"kind":"string","value":"FauxFaux/jdk9-langtools"},"path":{"kind":"string","value":"test/tools/javac/enum/6350057/T6350057.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":3605,"string":"3,605"}}},{"rowIdx":61538433,"cells":{"code":{"kind":"string","value":"backupServer = $_SERVER;\n\t\t$_SERVER['HTTP_HOST'] = 'example.com';\n\t\t$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0';\n\t\t$_SERVER['REQUEST_URI'] = '/index.php';\n\t\t$_SERVER['SCRIPT_NAME'] = '/index.php';\n\n\t\t$key = \"app_key\";\n\t\t$secret = \"app_secret\";\n\t\t$my_url = \"http://127.0.0.1/gsoc/joomla-platform/linkedin_test.php\";\n\n\t\t$this->options = new JRegistry;\n\t\t$this->input = new JInput;\n\t\t$this->client = $this->getMockBuilder('JHttp')->setMethods(array('get', 'post', 'delete', 'put'))->getMock();\n\t\t$this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input);\n\t\t$this->oauth->setToken(array('key' => $key, 'secret' => $secret));\n\n\t\t$this->object = new JLinkedinPeople($this->options, $this->client, $this->oauth);\n\n\t\t$this->options->set('consumer_key', $key);\n\t\t$this->options->set('consumer_secret', $secret);\n\t\t$this->options->set('callback', $my_url);\n\t}\n\n\t/**\n\t * Tears down the fixture, for example, closes a network connection.\n\t * This method is called after a test is executed.\n\t *\n\t * @return void\n\t *\n\t * @see \\PHPUnit\\Framework\\TestCase::tearDown()\n\t * @since 3.6\n\t */\n\tprotected function tearDown()\n\t{\n\t\t$_SERVER = $this->backupServer;\n\t\tunset($this->backupServer, $this->options, $this->input, $this->client, $this->oauth, $this->object);\n\t\tparent::tearDown();\n\t}\n\n\t/**\n\t* Provides test data for request format detection.\n\t*\n\t* @return array\n\t*\n\t* @since 3.2.0\n\t*/\n\tpublic function seedIdUrl()\n\t{\n\t\t// Member ID or url\n\t\treturn array(\n\t\t\tarray('lcnIwDU0S6', null),\n\t\t\tarray(null, 'http://www.linkedin.com/in/dianaprajescu'),\n\t\t\tarray(null, null)\n\t\t\t);\n\t}\n\n\t/**\n\t * Tests the getProfile method\n\t *\n\t * @param string $id Member id of the profile you want.\n\t * @param string $url The public profile URL.\n\t *\n\t * @return void\n\t *\n\t * @dataProvider seedIdUrl\n\t * @since 3.2.0\n\t */\n\tpublic function testGetProfile($id, $url)\n\t{\n\t\t$fields = '(id,first-name,last-name)';\n\t\t$language = 'en-US';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\n\t\t$path = '/v1/people/';\n\n\t\tif ($url)\n\t\t{\n\t\t\t$path .= 'url=' . $this->oauth->safeEncode($url) . ':public';\n\t\t\t$type = 'public';\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$type = 'standard';\n\t\t}\n\n\t\tif ($id)\n\t\t{\n\t\t\t$path .= 'id=' . $id;\n\t\t}\n\t\telseif (!$url)\n\t\t{\n\t\t\t$path .= '~';\n\t\t}\n\n\t\t$path .= ':' . $fields;\n\t\t$header = array('Accept-Language' => $language);\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 200;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('get', $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->assertThat(\n\t\t\t$this->object->getProfile($id, $url, $fields, $type, $language),\n\t\t\t$this->equalTo(json_decode($this->sampleString))\n\t\t);\n\t}\n\n\t/**\n\t * Tests the getProfile method - failure\n\t *\n\t * @param string $id Member id of the profile you want.\n\t * @param string $url The public profile URL.\n\t *\n\t * @return void\n\t *\n\t * @dataProvider seedIdUrl\n\t * @since 3.2.0\n\t * @expectedException DomainException\n\t */\n\tpublic function testGetProfileFailure($id, $url)\n\t{\n\t\t$fields = '(id,first-name,last-name)';\n\t\t$language = 'en-US';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\n\t\t$path = '/v1/people/';\n\n\t\tif ($url)\n\t\t{\n\t\t\t$path .= 'url=' . $this->oauth->safeEncode($url) . ':public';\n\t\t\t$type = 'public';\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$type = 'standard';\n\t\t}\n\n\t\tif ($id)\n\t\t{\n\t\t\t$path .= 'id=' . $id;\n\t\t}\n\t\telseif (!$url)\n\t\t{\n\t\t\t$path .= '~';\n\t\t}\n\n\t\t$path .= ':' . $fields;\n\t\t$header = array('Accept-Language' => $language);\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 401;\n\t\t$returnData->body = $this->errorString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('get', $header)\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->getProfile($id, $url, $fields, $type, $language);\n\t}\n\n\t/**\n\t * Tests the getConnections method\n\t *\n\t * @return void\n\t *\n\t * @since 3.2.0\n\t */\n\tpublic function testGetConnections()\n\t{\n\t\t$fields = '(id,first-name,last-name)';\n\t\t$start = 1;\n\t\t$count = 50;\n\t\t$modified = 'new';\n\t\t$modified_since = '1267401600000';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\t\t$data['start'] = $start;\n\t\t$data['count'] = $count;\n\t\t$data['modified'] = $modified;\n\t\t$data['modified-since'] = $modified_since;\n\n\t\t$path = '/v1/people/~/connections';\n\n\t\t$path .= ':' . $fields;\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 200;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('get')\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->assertThat(\n\t\t\t$this->object->getConnections($fields, $start, $count, $modified, $modified_since),\n\t\t\t$this->equalTo(json_decode($this->sampleString))\n\t\t);\n\t}\n\n\t/**\n\t * Tests the getConnections method - failure\n\t *\n\t * @return void\n\t *\n\t * @since 3.2.0\n\t * @expectedException DomainException\n\t */\n\tpublic function testGetConnectionsFailure()\n\t{\n\t\t$fields = '(id,first-name,last-name)';\n\t\t$start = 1;\n\t\t$count = 50;\n\t\t$modified = 'new';\n\t\t$modified_since = '1267401600000';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\t\t$data['start'] = $start;\n\t\t$data['count'] = $count;\n\t\t$data['modified'] = $modified;\n\t\t$data['modified-since'] = $modified_since;\n\n\t\t$path = '/v1/people/~/connections';\n\n\t\t$path .= ':' . $fields;\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 401;\n\t\t$returnData->body = $this->errorString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('get')\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->getConnections($fields, $start, $count, $modified, $modified_since);\n\t}\n\n\t/**\n\t* Provides test data for request format detection.\n\t*\n\t* @return array\n\t*\n\t* @since 3.2.0\n\t*/\n\tpublic function seedFields()\n\t{\n\t\t// Fields\n\t\treturn array(\n\t\t\tarray('(people:(id,first-name,last-name,api-standard-profile-request))'),\n\t\t\tarray('(people:(id,first-name,last-name))')\n\t\t\t);\n\t}\n\n\t/**\n\t * Tests the search method\n\t *\n\t * @param string $fields Request fields beyond the default ones. provide 'api-standard-profile-request' field for out of network profiles.\n\t *\n\t * @return void\n\t *\n\t * @dataProvider seedFields\n\t * @since 3.2.0\n\t */\n\tpublic function testSearch($fields)\n\t{\n\t\t$keywords = 'Princess';\n\t\t$first_name = 'Clair';\n\t\t$last_name = 'Standish';\n\t\t$company_name = 'Smth';\n\t\t$current_company = true;\n\t\t$title = 'developer';\n\t\t$current_title = true;\n\t\t$school_name = 'Shermer High School';\n\t\t$current_school = true;\n\t\t$country_code = 'us';\n\t\t$postal_code = 12345;\n\t\t$distance = 500;\n\t\t$facets = 'location,industry,network,language,current-company,past-company,school';\n\t\t$facet = array('us-84', 47, 'F', 'en', 1006, 1028, 2345);\n\t\t$start = 1;\n\t\t$count = 50;\n\t\t$sort = 'distance';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\t\t$data['keywords'] = $keywords;\n\t\t$data['first-name'] = $first_name;\n\t\t$data['last-name'] = $last_name;\n\t\t$data['company-name'] = $company_name;\n\t\t$data['current-company'] = $current_company;\n\t\t$data['title'] = $title;\n\t\t$data['current-title'] = $current_title;\n\t\t$data['school-name'] = $school_name;\n\t\t$data['current-school'] = $current_school;\n\t\t$data['country-code'] = $country_code;\n\t\t$data['postal-code'] = $postal_code;\n\t\t$data['distance'] = $distance;\n\t\t$data['facets'] = $facets;\n\t\t$data['facet'] = array();\n\t\t$data['facet'][] = 'location,' . $facet[0];\n\t\t$data['facet'][] = 'industry,' . $facet[1];\n\t\t$data['facet'][] = 'network,' . $facet[2];\n\t\t$data['facet'][] = 'language,' . $facet[3];\n\t\t$data['facet'][] = 'current-company,' . $facet[4];\n\t\t$data['facet'][] = 'past-company,' . $facet[5];\n\t\t$data['facet'][] = 'school,' . $facet[6];\n\n\t\t$data['start'] = $start;\n\t\t$data['count'] = $count;\n\t\t$data['sort'] = $sort;\n\n\t\t$path = '/v1/people-search';\n\n\t\t$path .= ':' . $fields;\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 200;\n\t\t$returnData->body = $this->sampleString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\tif (strpos($fields, 'api-standard-profile-request') === false)\n\t\t{\n\t\t\t$this->client->expects($this->once())\n\t\t\t\t->method('get')\n\t\t\t\t->with($path)\n\t\t\t\t->will($this->returnValue($returnData));\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$returnData = new stdClass;\n\t\t\t$returnData->code = 200;\n\t\t\t$returnData->body = $this->outString;\n\n\t\t\t$this->client->expects($this->at(0))\n\t\t\t\t->method('get')\n\t\t\t\t->with($path)\n\t\t\t\t->will($this->returnValue($returnData));\n\n\t\t\t$returnData = new stdClass;\n\t\t\t$returnData->code = 200;\n\t\t\t$returnData->body = $this->sampleString;\n\n\t\t\t$path = '/v1/people/oAFz-3CZyv';\n\t\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t\t$name = 'x-li-auth-token';\n\t\t\t$value = 'NAME_SEARCH:-Ogn';\n\t\t\t$header[$name] = $value;\n\n\t\t\t$this->client->expects($this->at(1))\n\t\t\t\t->method('get', $header)\n\t\t\t\t->with($path)\n\t\t\t\t->will($this->returnValue($returnData));\n\t\t}\n\n\t\t$this->assertThat(\n\t\t\t$this->object->search(\n\t\t\t\t$fields, $keywords, $first_name, $last_name, $company_name,\n\t\t\t\t$current_company, $title, $current_title, $school_name, $current_school, $country_code,\n\t\t\t\t$postal_code, $distance, $facets, $facet, $start, $count, $sort\n\t\t\t\t),\n\t\t\t$this->equalTo(json_decode($this->sampleString))\n\t\t);\n\t}\n\n\t/**\n\t * Tests the search method - failure\n\t *\n\t * @return void\n\t *\n\t * @since 3.2.0\n\t * @expectedException DomainException\n\t */\n\tpublic function testSearchFailure()\n\t{\n\t\t$fields = '(id,first-name,last-name)';\n\t\t$keywords = 'Princess';\n\t\t$first_name = 'Clair';\n\t\t$last_name = 'Standish';\n\t\t$company_name = 'Smth';\n\t\t$current_company = true;\n\t\t$title = 'developer';\n\t\t$current_title = true;\n\t\t$school_name = 'Shermer High School';\n\t\t$current_school = true;\n\t\t$country_code = 'us';\n\t\t$postal_code = 12345;\n\t\t$distance = 500;\n\t\t$facets = 'location,industry,network,language,current-company,past-company,school';\n\t\t$facet = array('us-84', 47, 'F', 'en', 1006, 1028, 2345);\n\t\t$start = 1;\n\t\t$count = 50;\n\t\t$sort = 'distance';\n\n\t\t// Set request parameters.\n\t\t$data['format'] = 'json';\n\t\t$data['keywords'] = $keywords;\n\t\t$data['first-name'] = $first_name;\n\t\t$data['last-name'] = $last_name;\n\t\t$data['company-name'] = $company_name;\n\t\t$data['current-company'] = $current_company;\n\t\t$data['title'] = $title;\n\t\t$data['current-title'] = $current_title;\n\t\t$data['school-name'] = $school_name;\n\t\t$data['current-school'] = $current_school;\n\t\t$data['country-code'] = $country_code;\n\t\t$data['postal-code'] = $postal_code;\n\t\t$data['distance'] = $distance;\n\t\t$data['facets'] = $facets;\n\t\t$data['facet'] = array();\n\t\t$data['facet'][] = 'location,' . $facet[0];\n\t\t$data['facet'][] = 'industry,' . $facet[1];\n\t\t$data['facet'][] = 'network,' . $facet[2];\n\t\t$data['facet'][] = 'language,' . $facet[3];\n\t\t$data['facet'][] = 'current-company,' . $facet[4];\n\t\t$data['facet'][] = 'past-company,' . $facet[5];\n\t\t$data['facet'][] = 'school,' . $facet[6];\n\n\t\t$data['start'] = $start;\n\t\t$data['count'] = $count;\n\t\t$data['sort'] = $sort;\n\n\t\t$path = '/v1/people-search';\n\n\t\t$path .= ':' . $fields;\n\n\t\t$returnData = new stdClass;\n\t\t$returnData->code = 401;\n\t\t$returnData->body = $this->errorString;\n\n\t\t$path = $this->oauth->toUrl($path, $data);\n\n\t\t$this->client->expects($this->once())\n\t\t\t->method('get')\n\t\t\t->with($path)\n\t\t\t->will($this->returnValue($returnData));\n\n\t\t$this->object->search(\n\t\t\t$fields, $keywords, $first_name, $last_name, $company_name,\n\t\t\t$current_company, $title, $current_title, $school_name, $current_school, $country_code,\n\t\t\t$postal_code, $distance, $facets, $facet, $start, $count, $sort\n\t\t\t);\n\t}\n}\n"},"repo_name":{"kind":"string","value":"810/joomla-cms"},"path":{"kind":"string","value":"tests/unit/suites/libraries/joomla/linkedin/JLinkedinPeopleTest.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":13369,"string":"13,369"}}},{"rowIdx":61538434,"cells":{"code":{"kind":"string","value":"\n * Copyright (C) 2015 Frederic France \n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n * or see http://www.gnu.org/\n */\n\n/**\n * \\file htdocs/core/actions_fetchobject.inc.php\n * \\brief Code for actions on fetching object page\n */\n\n\n// $action must be defined\n// $object must be defined (object is loaded in this file with fetch)\n// $cancel must be defined\n// $id or $ref must be defined (object is loaded in this file with fetch)\n\nif (($id > 0 || (! empty($ref) && ! in_array($action, array('create','createtask')))) && empty($cancel))\n{\n $ret = $object->fetch($id,$ref);\n if ($ret > 0)\n {\n $object->fetch_thirdparty();\n $id = $object->id;\n }\n else\n {\n setEventMessages($object->error, $object->errors, 'errors');\n $action='';\n }\n}\n"},"repo_name":{"kind":"string","value":"atm-robin/dolibarr"},"path":{"kind":"string","value":"htdocs/core/actions_fetchobject.inc.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-3.0"},"size":{"kind":"number","value":1522,"string":"1,522"}}},{"rowIdx":61538435,"cells":{"code":{"kind":"string","value":"// Inspired from https://github.com/tsi/inlineDisqussions\n(function () {\n \n 'use strict';\n \n var website = openerp.website,\n qweb = openerp.qweb;\n\n website.blog_discussion = openerp.Class.extend({\n init: function(options) {\n var self = this ;\n self.discus_identifier;\n var defaults = {\n position: 'right',\n post_id: $('#blog_post_name').attr('data-blog-id'),\n content : false,\n public_user: false,\n };\n self.settings = $.extend({}, defaults, options);\n\n // TODO: bundlify qweb templates\n website.add_template_file('/website_blog/static/src/xml/website_blog.inline.discussion.xml').then(function () {\n self.do_render(self);\n });\n },\n do_render: function(data) {\n var self = this;\n if ($('#discussions_wrapper').length === 0 && self.settings.content.length > 0) {\n $('
    ').insertAfter($('#blog_content'));\n }\n // Attach a discussion to each paragraph.\n self.discussions_handler(self.settings.content);\n\n // Hide the discussion.\n $('html').click(function(event) {\n if($(event.target).parents('#discussions_wrapper, .main-discussion-link-wrp').length === 0) {\n self.hide_discussion();\n }\n if(!$(event.target).hasClass('discussion-link') && !$(event.target).parents('.popover').length){\n if($('.move_discuss').length){\n $('[enable_chatter_discuss=True]').removeClass('move_discuss');\n $('[enable_chatter_discuss=True]').animate({\n 'marginLeft': \"+=40%\"\n });\n $('#discussions_wrapper').animate({\n 'marginLeft': \"+=250px\"\n });\n }\n }\n });\n },\n prepare_data : function(identifier, comment_count) {\n var self = this;\n return openerp.jsonRpc(\"/blogpost/get_discussion/\", 'call', {\n 'post_id': self.settings.post_id,\n 'path': identifier,\n 'count': comment_count, //if true only get length of total comment, display on discussion thread.\n })\n },\n prepare_multi_data : function(identifiers, comment_count) {\n var self = this;\n return openerp.jsonRpc(\"/blogpost/get_discussions/\", 'call', {\n 'post_id': self.settings.post_id,\n 'paths': identifiers,\n 'count': comment_count, //if true only get length of total comment, display on discussion thread.\n })\n },\n discussions_handler: function() {\n var self = this;\n var node_by_id = {};\n $(self.settings.content).each(function(i) {\n var node = $(this);\n var identifier = node.attr('data-chatter-id');\n if (identifier) {\n node_by_id[identifier] = node;\n }\n });\n self.prepare_multi_data(_.keys(node_by_id), true).then( function (multi_data) {\n _.forEach(multi_data, function(data) {\n self.prepare_discuss_link(data.val, data.path, node_by_id[data.path]);\n });\n });\n },\n prepare_discuss_link : function(data, identifier, node) {\n var self = this;\n var cls = data > 0 ? 'discussion-link has-comments' : 'discussion-link';\n var a = $('')\n .attr('data-discus-identifier', identifier)\n .attr('data-discus-position', self.settings.position)\n .text(data > 0 ? data : '+')\n .attr('data-contentwrapper', '.mycontent')\n .wrap('
    ')\n .parent()\n .appendTo('#discussions_wrapper');\n a.css({\n 'top': node.offset().top,\n 'left': self.settings.position == 'right' ? node.outerWidth() + node.offset().left: node.offset().left - a.outerWidth()\n });\n // node.attr('data-discus-identifier', identifier)\n node.mouseover(function() {\n a.addClass(\"hovered\");\n }).mouseout(function() {\n a.removeClass(\"hovered\");\n });\n\n a.delegate('a.discussion-link', \"click\", function(e) {\n e.preventDefault();\n if(!$('.move_discuss').length){\n $('[enable_chatter_discuss=True]').addClass('move_discuss');\n $('[enable_chatter_discuss=True]').animate({\n 'marginLeft': \"-=40%\"\n });\n $('#discussions_wrapper').animate({\n 'marginLeft': \"-=250px\"\n });\n }\n if ($(this).is('.active')) {\n e.stopPropagation();\n self.hide_discussion();\n }\n else {\n self.get_discussion($(this), function(source) {});\n }\n });\n },\n get_discussion : function(source, callback) {\n var self = this;\n var identifier = source.attr('data-discus-identifier');\n self.hide_discussion();\n self.discus_identifier = identifier;\n var elt = $('a[data-discus-identifier=\"'+identifier+'\"]');\n elt.append(qweb.render(\"website.blog_discussion.popover\", {'identifier': identifier , 'options': self.settings}));\n var comment = '';\n self.prepare_data(identifier,false).then(function(data){\n _.each(data, function(res){\n comment += qweb.render(\"website.blog_discussion.comment\", {'res': res});\n });\n $('.discussion_history').html('
      '+comment+'
    ');\n self.create_popover(elt, identifier); \n // Add 'active' class.\n $('a.discussion-link, a.main-discussion-link').removeClass('active').filter(source).addClass('active');\n elt.popover('hide').filter(source).popover('show');\n callback(source);\n });\n },\n create_popover : function(elt, identifier) {\n var self = this;\n elt.popover({\n placement:'right',\n trigger:'manual',\n html:true, content:function(){\n return $($(this).data('contentwrapper')).html();\n }\n }).parent().delegate(self).on('click','button#comment_post',function(e) {\n e.stopImmediatePropagation();\n self.post_discussion(identifier);\n });\n },\n validate : function(public_user){\n var comment = $(\".popover textarea#inline_comment\").val();\n if (public_user){\n var author_name = $('.popover input#author_name').val();\n var author_email = $('.popover input#author_email').val();\n if(!comment || !author_name || !author_email){\n if (!author_name) \n $('div#author_name').addClass('has-error');\n else \n $('div#author_name').removeClass('has-error');\n if (!author_email)\n $('div#author_email').addClass('has-error');\n else\n $('div#author_email').removeClass('has-error');\n if(!comment)\n $('div#inline_comment').addClass('has-error');\n else\n $('div#inline_comment').removeClass('has-error');\n return false\n }\n }\n else if(!comment) {\n $('div#inline_comment').addClass('has-error');\n return false\n }\n $(\"div#inline_comment\").removeClass('has-error');\n $('div#author_name').removeClass('has-error');\n $('div#author_email').removeClass('has-error');\n $(\".popover textarea#inline_comment\").val('');\n $('.popover input#author_name').val('');\n $('.popover input#author_email').val('');\n return [comment, author_name, author_email]\n },\n post_discussion : function(identifier) {\n var self = this;\n var val = self.validate(self.settings.public_user)\n if(!val) return\n openerp.jsonRpc(\"/blogpost/post_discussion\", 'call', {\n 'blog_post_id': self.settings.post_id,\n 'path': self.discus_identifier,\n 'comment': val[0],\n 'name' : val[1],\n 'email': val[2],\n }).then(function(res){\n $(\".popover ul.media-list\").prepend(qweb.render(\"website.blog_discussion.comment\", {'res': res[0]}))\n var ele = $('a[data-discus-identifier=\"'+ self.discus_identifier +'\"]');\n ele.text(_.isNaN(parseInt(ele.text())) ? 1 : parseInt(ele.text())+1)\n ele.addClass('has-comments');\n });\n },\n hide_discussion : function() {\n var self = this;\n $('a[data-discus-identifier=\"'+ self.discus_identifier+'\"]').popover('destroy');\n $('a.discussion-link').removeClass('active');\n }\n \n });\n\n})();\n"},"repo_name":{"kind":"string","value":"jjscarafia/odoo"},"path":{"kind":"string","value":"addons/website_blog/static/src/js/website_blog.inline.discussion.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"agpl-3.0"},"size":{"kind":"number","value":9713,"string":"9,713"}}},{"rowIdx":61538436,"cells":{"code":{"kind":"string","value":"/*\n * Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n *\n * WSO2 Inc. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n *\n */\npackage org.wso2.carbon.event.ws.internal.builders.exceptions;\n\npublic class InvalidExpirationTimeException extends Exception {\n\n public InvalidExpirationTimeException(String message) {\n super(message);\n }\n\n public InvalidExpirationTimeException(String message, Throwable cause) {\n super(message, cause);\n }\n}"},"repo_name":{"kind":"string","value":"madhawa-gunasekara/carbon-commons"},"path":{"kind":"string","value":"components/event/org.wso2.carbon.event.ws/src/main/java/org/wso2/carbon/event/ws/internal/builders/exceptions/InvalidExpirationTimeException.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":1026,"string":"1,026"}}},{"rowIdx":61538437,"cells":{"code":{"kind":"string","value":"require \"cmd/missing\"\nrequire \"formula\"\nrequire \"keg\"\nrequire \"language/python\"\nrequire \"version\"\n\nclass Volumes\n def initialize\n @volumes = get_mounts\n end\n\n def which path\n vols = get_mounts path\n\n # no volume found\n if vols.empty?\n return -1\n end\n\n vol_index = @volumes.index(vols[0])\n # volume not found in volume list\n if vol_index.nil?\n return -1\n end\n return vol_index\n end\n\n def get_mounts path=nil\n vols = []\n # get the volume of path, if path is nil returns all volumes\n\n args = %w[/bin/df -P]\n args << path if path\n\n Utils.popen_read(*args) do |io|\n io.each_line do |line|\n case line.chomp\n # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% /\n when /^.+\\s+[0-9]+\\s+[0-9]+\\s+[0-9]+\\s+[0-9]{1,3}%\\s+(.+)/\n vols << $1\n end\n end\n end\n return vols\n end\nend\n\n\nclass Checks\n\n############# HELPERS\n # Finds files in HOMEBREW_PREFIX *and* /usr/local.\n # Specify paths relative to a prefix eg. \"include/foo.h\".\n # Sets @found for your convenience.\n def find_relative_paths *relative_paths\n @found = %W[#{HOMEBREW_PREFIX} /usr/local].uniq.inject([]) do |found, prefix|\n found + relative_paths.map{|f| File.join(prefix, f) }.select{|f| File.exist? f }\n end\n end\n\n def inject_file_list(list, str)\n list.inject(str) { |s, f| s << \" #{f}\\n\" }\n end\n\n # Git will always be on PATH because of the wrapper script in\n # Library/ENV/scm, so we check if there is a *real*\n # git here to avoid multiple warnings.\n def git?\n return @git if instance_variable_defined?(:@git)\n @git = system \"git --version >/dev/null 2>&1\"\n end\n############# END HELPERS\n\n# Sorry for the lack of an indent here, the diff would have been unreadable.\n# See https://github.com/Homebrew/homebrew/pull/9986\ndef check_path_for_trailing_slashes\n bad_paths = ENV['PATH'].split(File::PATH_SEPARATOR).select { |p| p[-1..-1] == '/' }\n return if bad_paths.empty?\n s = <<-EOS.undent\n Some directories in your path end in a slash.\n Directories in your path should not end in a slash. This can break other\n doctor checks. The following directories should be edited:\n EOS\n bad_paths.each{|p| s << \" #{p}\"}\n s\nend\n\n# Installing MacGPG2 interferes with Homebrew in a big way\n# https://github.com/GPGTools/MacGPG2\ndef check_for_macgpg2\n return if File.exist? '/usr/local/MacGPG2/share/gnupg/VERSION'\n\n suspects = %w{\n /Applications/start-gpg-agent.app\n /Library/Receipts/libiconv1.pkg\n /usr/local/MacGPG2\n }\n\n if suspects.any? { |f| File.exist? f } then <<-EOS.undent\n You may have installed MacGPG2 via the package installer.\n Several other checks in this script will turn up problems, such as stray\n dylibs in /usr/local and permissions issues with share and man in /usr/local/.\n EOS\n end\nend\n\ndef __check_stray_files(dir, pattern, white_list, message)\n return unless File.directory?(dir)\n\n files = Dir.chdir(dir) {\n Dir[pattern].select { |f| File.file?(f) && !File.symlink?(f) } - Dir.glob(white_list)\n }.map { |file| File.join(dir, file) }\n\n inject_file_list(files, message) unless files.empty?\nend\n\ndef check_for_stray_dylibs\n # Dylibs which are generally OK should be added to this list,\n # with a short description of the software they come with.\n white_list = [\n \"libfuse.2.dylib\", # MacFuse\n \"libfuse_ino64.2.dylib\", # MacFuse\n \"libmacfuse_i32.2.dylib\", # OSXFuse MacFuse compatibility layer\n \"libmacfuse_i64.2.dylib\", # OSXFuse MacFuse compatibility layer\n \"libosxfuse_i32.2.dylib\", # OSXFuse\n \"libosxfuse_i64.2.dylib\", # OSXFuse\n \"libTrAPI.dylib\", # TrAPI / Endpoint Security VPN\n \"libntfs-3g.*.dylib\", # NTFS-3G\n \"libntfs.*.dylib\", # NTFS-3G\n \"libublio.*.dylib\", # NTFS-3G\n ]\n\n __check_stray_files \"/usr/local/lib\", \"*.dylib\", white_list, <<-EOS.undent\n Unbrewed dylibs were found in /usr/local/lib.\n If you didn't put them there on purpose they could cause problems when\n building Homebrew formulae, and may need to be deleted.\n\n Unexpected dylibs:\n EOS\nend\n\ndef check_for_stray_static_libs\n # Static libs which are generally OK should be added to this list,\n # with a short description of the software they come with.\n white_list = [\n \"libsecurity_agent_client.a\", # OS X 10.8.2 Supplemental Update\n \"libsecurity_agent_server.a\", # OS X 10.8.2 Supplemental Update\n \"libntfs-3g.a\", # NTFS-3G\n \"libntfs.a\", # NTFS-3G\n \"libublio.a\", # NTFS-3G\n ]\n\n __check_stray_files \"/usr/local/lib\", \"*.a\", white_list, <<-EOS.undent\n Unbrewed static libraries were found in /usr/local/lib.\n If you didn't put them there on purpose they could cause problems when\n building Homebrew formulae, and may need to be deleted.\n\n Unexpected static libraries:\n EOS\nend\n\ndef check_for_stray_pcs\n # Package-config files which are generally OK should be added to this list,\n # with a short description of the software they come with.\n white_list = [\n \"fuse.pc\", # OSXFuse/MacFuse\n \"macfuse.pc\", # OSXFuse MacFuse compatibility layer\n \"osxfuse.pc\", # OSXFuse\n \"libntfs-3g.pc\", # NTFS-3G\n \"libublio.pc\",# NTFS-3G\n ]\n\n __check_stray_files \"/usr/local/lib/pkgconfig\", \"*.pc\", white_list, <<-EOS.undent\n Unbrewed .pc files were found in /usr/local/lib/pkgconfig.\n If you didn't put them there on purpose they could cause problems when\n building Homebrew formulae, and may need to be deleted.\n\n Unexpected .pc files:\n EOS\nend\n\ndef check_for_stray_las\n white_list = [\n \"libfuse.la\", # MacFuse\n \"libfuse_ino64.la\", # MacFuse\n \"libosxfuse_i32.la\", # OSXFuse\n \"libosxfuse_i64.la\", # OSXFuse\n \"libntfs-3g.la\", # NTFS-3G\n \"libntfs.la\", # NTFS-3G\n \"libublio.la\", # NTFS-3G\n ]\n\n __check_stray_files \"/usr/local/lib\", \"*.la\", white_list, <<-EOS.undent\n Unbrewed .la files were found in /usr/local/lib.\n If you didn't put them there on purpose they could cause problems when\n building Homebrew formulae, and may need to be deleted.\n\n Unexpected .la files:\n EOS\nend\n\ndef check_for_stray_headers\n white_list = [\n \"fuse.h\", # MacFuse\n \"fuse/**/*.h\", # MacFuse\n \"macfuse/**/*.h\", # OSXFuse MacFuse compatibility layer\n \"osxfuse/**/*.h\", # OSXFuse\n \"ntfs/**/*.h\", # NTFS-3G\n \"ntfs-3g/**/*.h\", # NTFS-3G\n ]\n\n __check_stray_files \"/usr/local/include\", \"**/*.h\", white_list, <<-EOS.undent\n Unbrewed header files were found in /usr/local/include.\n If you didn't put them there on purpose they could cause problems when\n building Homebrew formulae, and may need to be deleted.\n\n Unexpected header files:\n EOS\nend\n\ndef check_for_other_package_managers\n ponk = MacOS.macports_or_fink\n unless ponk.empty?\n <<-EOS.undent\n You have MacPorts or Fink installed:\n #{ponk.join(\", \")}\n\n This can cause trouble. You don't have to uninstall them, but you may want to\n temporarily move them out of the way, e.g.\n\n sudo mv /opt/local ~/macports\n EOS\n end\nend\n\ndef check_for_broken_symlinks\n broken_symlinks = []\n\n Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |d|\n d.find do |path|\n if path.symlink? && !path.resolved_path_exists?\n broken_symlinks << path\n end\n end\n end\n unless broken_symlinks.empty? then <<-EOS.undent\n Broken symlinks were found. Remove them with `brew prune`:\n #{broken_symlinks * \"\\n \"}\n EOS\n end\nend\n\ndef check_for_unsupported_osx\n if MacOS.version >= \"10.11\" then <<-EOS.undent\n You are using OS X #{MacOS.version}.\n We do not provide support for this pre-release version.\n You may encounter build failures or other breakage.\n EOS\n end\nend\n\nif MacOS.version >= \"10.9\"\n def check_for_installed_developer_tools\n unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent\n No developer tools installed.\n Install the Command Line Tools:\n xcode-select --install\n EOS\n end\n end\n\n def check_xcode_up_to_date\n if MacOS::Xcode.installed? && MacOS::Xcode.outdated?\n <<-EOS.undent\n Your Xcode (#{MacOS::Xcode.version}) is outdated\n Please update to Xcode #{MacOS::Xcode.latest_version}.\n Xcode can be updated from the App Store.\n EOS\n end\n end\n\n def check_clt_up_to_date\n if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent\n A newer Command Line Tools release is available.\n Update them from Software Update in the App Store.\n EOS\n end\n end\nelsif MacOS.version == \"10.8\" || MacOS.version == \"10.7\"\n def check_for_installed_developer_tools\n unless MacOS::Xcode.installed? || MacOS::CLT.installed? then <<-EOS.undent\n No developer tools installed.\n You should install the Command Line Tools.\n The standalone package can be obtained from\n https://developer.apple.com/downloads\n or it can be installed via Xcode's preferences.\n EOS\n end\n end\n\n def check_xcode_up_to_date\n if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent\n Your Xcode (#{MacOS::Xcode.version}) is outdated\n Please update to Xcode #{MacOS::Xcode.latest_version}.\n Xcode can be updated from\n https://developer.apple.com/downloads\n EOS\n end\n end\n\n def check_clt_up_to_date\n if MacOS::CLT.installed? && MacOS::CLT.outdated? then <<-EOS.undent\n A newer Command Line Tools release is available.\n The standalone package can be obtained from\n https://developer.apple.com/downloads\n or it can be installed via Xcode's preferences.\n EOS\n end\n end\nelse\n def check_for_installed_developer_tools\n unless MacOS::Xcode.installed? then <<-EOS.undent\n Xcode is not installed. Most formulae need Xcode to build.\n It can be installed from\n https://developer.apple.com/downloads\n EOS\n end\n end\n\n def check_xcode_up_to_date\n if MacOS::Xcode.installed? && MacOS::Xcode.outdated? then <<-EOS.undent\n Your Xcode (#{MacOS::Xcode.version}) is outdated\n Please update to Xcode #{MacOS::Xcode.latest_version}.\n Xcode can be updated from\n https://developer.apple.com/downloads\n EOS\n end\n end\nend\n\ndef check_for_osx_gcc_installer\n if (MacOS.version < \"10.7\" || MacOS::Xcode.version > \"4.1\") && \\\n MacOS.clang_version == \"2.1\"\n message = <<-EOS.undent\n You seem to have osx-gcc-installer installed.\n Homebrew doesn't support osx-gcc-installer. It causes many builds to fail and\n is an unlicensed distribution of really old Xcode files.\n EOS\n if MacOS.version >= :mavericks\n message += <<-EOS.undent\n Please run `xcode-select --install` to install the CLT.\n EOS\n elsif MacOS.version >= :lion\n message += <<-EOS.undent\n Please install the CLT or Xcode #{MacOS::Xcode.latest_version}.\n EOS\n else\n message += <<-EOS.undent\n Please install Xcode #{MacOS::Xcode.latest_version}.\n EOS\n end\n end\nend\n\ndef check_for_stray_developer_directory\n # if the uninstaller script isn't there, it's a good guess neither are\n # any troublesome leftover Xcode files\n uninstaller = Pathname.new(\"/Developer/Library/uninstall-developer-folder\")\n if MacOS::Xcode.version >= \"4.3\" && uninstaller.exist? then <<-EOS.undent\n You have leftover files from an older version of Xcode.\n You should delete them using:\n #{uninstaller}\n EOS\n end\nend\n\ndef check_for_bad_install_name_tool\n return if MacOS.version < \"10.9\"\n\n libs = Pathname.new(\"/usr/bin/install_name_tool\").dynamically_linked_libraries\n\n # otool may not work, for example if the Xcode license hasn't been accepted yet\n return if libs.empty?\n\n unless libs.include? \"/usr/lib/libxcselect.dylib\" then <<-EOS.undent\n You have an outdated version of /usr/bin/install_name_tool installed.\n This will cause binary package installations to fail.\n This can happen if you install osx-gcc-installer or RailsInstaller.\n To restore it, you must reinstall OS X or restore the binary from\n the OS packages.\n EOS\n end\nend\n\ndef __check_subdir_access base\n target = HOMEBREW_PREFIX+base\n return unless target.exist?\n\n cant_read = []\n\n target.find do |d|\n next unless d.directory?\n cant_read << d unless d.writable_real?\n end\n\n cant_read.sort!\n if cant_read.length > 0 then\n s = <<-EOS.undent\n Some directories in #{target} aren't writable.\n This can happen if you \"sudo make install\" software that isn't managed\n by Homebrew. If a brew tries to add locale information to one of these\n directories, then the install will fail during the link step.\n You should probably `chown` them:\n\n EOS\n cant_read.each{ |f| s << \" #{f}\\n\" }\n s\n end\nend\n\ndef check_access_share_locale\n __check_subdir_access 'share/locale'\nend\n\ndef check_access_share_man\n __check_subdir_access 'share/man'\nend\n\ndef check_access_usr_local\n return unless HOMEBREW_PREFIX.to_s == '/usr/local'\n\n unless File.writable_real?(\"/usr/local\") then <<-EOS.undent\n The /usr/local directory is not writable.\n Even if this directory was writable when you installed Homebrew, other\n software may change permissions on this directory. Some versions of the\n \"InstantOn\" component of Airfoil are known to do this.\n\n You should probably change the ownership and permissions of /usr/local\n back to your user account.\n EOS\n end\nend\n\ndef check_tmpdir_sticky_bit\n world_writable = HOMEBREW_TEMP.stat.mode & 0777 == 0777\n if world_writable && !HOMEBREW_TEMP.sticky? then <<-EOS.undent\n #{HOMEBREW_TEMP} is world-writable but does not have the sticky bit set.\n Please run \"Repair Disk Permissions\" in Disk Utility.\n EOS\n end\nend\n\n\n(Keg::TOP_LEVEL_DIRECTORIES + [\"lib/pkgconfig\"]).each do |d|\n define_method(\"check_access_#{d.sub(\"/\", \"_\")}\") do\n dir = HOMEBREW_PREFIX.join(d)\n if dir.exist? && !dir.writable_real? then <<-EOS.undent\n #{dir} isn't writable.\n\n This can happen if you \"sudo make install\" software that isn't managed by\n by Homebrew. If a formula tries to write a file to this directory, the\n install will fail during the link step.\n\n You should probably `chown` #{dir}\n EOS\n end\n end\nend\n\ndef check_access_site_packages\n if Language::Python.homebrew_site_packages.exist? && !Language::Python.homebrew_site_packages.writable_real?\n <<-EOS.undent\n #{Language::Python.homebrew_site_packages} isn't writable.\n This can happen if you \"sudo pip install\" software that isn't managed\n by Homebrew. If you install a formula with Python modules, the install\n will fail during the link step.\n\n You should probably `chown` #{Language::Python.homebrew_site_packages}\n EOS\n end\nend\n\ndef check_access_logs\n if HOMEBREW_LOGS.exist? and not HOMEBREW_LOGS.writable_real?\n <<-EOS.undent\n #{HOMEBREW_LOGS} isn't writable.\n Homebrew writes debugging logs to this location.\n You should probably `chown` #{HOMEBREW_LOGS}\n EOS\n end\nend\n\ndef check_access_cache\n if HOMEBREW_CACHE.exist? && !HOMEBREW_CACHE.writable_real?\n <<-EOS.undent\n #{HOMEBREW_CACHE} isn't writable.\n This can happen if you run `brew install` or `brew fetch` as another user.\n Homebrew caches downloaded files to this location.\n You should probably `chown` #{HOMEBREW_CACHE}\n EOS\n end\nend\n\ndef check_access_cellar\n if HOMEBREW_CELLAR.exist? && !HOMEBREW_CELLAR.writable_real?\n <<-EOS.undent\n #{HOMEBREW_CELLAR} isn't writable.\n You should `chown` #{HOMEBREW_CELLAR}\n EOS\n end\nend\n\ndef check_access_prefix_opt\n opt = HOMEBREW_PREFIX.join(\"opt\")\n if opt.exist? && !opt.writable_real?\n <<-EOS.undent\n #{opt} isn't writable.\n You should `chown` #{opt}\n EOS\n end\nend\n\ndef check_ruby_version\n ruby_version = MacOS.version >= \"10.9\" ? \"2.0\" : \"1.8\"\n if RUBY_VERSION[/\\d\\.\\d/] != ruby_version then <<-EOS.undent\n Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew\n is developed and tested on Ruby #{ruby_version}, and may not work correctly\n on other Rubies. Patches are accepted as long as they don't cause breakage\n on supported Rubies.\n EOS\n end\nend\n\ndef check_homebrew_prefix\n unless HOMEBREW_PREFIX.to_s == '/usr/local'\n <<-EOS.undent\n Your Homebrew is not installed to /usr/local\n You can install Homebrew anywhere you want, but some brews may only build\n correctly if you install in /usr/local. Sorry!\n EOS\n end\nend\n\ndef check_xcode_prefix\n prefix = MacOS::Xcode.prefix\n return if prefix.nil?\n if prefix.to_s.match(' ')\n <<-EOS.undent\n Xcode is installed to a directory with a space in the name.\n This will cause some formulae to fail to build.\n EOS\n end\nend\n\ndef check_xcode_prefix_exists\n prefix = MacOS::Xcode.prefix\n return if prefix.nil?\n unless prefix.exist?\n <<-EOS.undent\n The directory Xcode is reportedly installed to doesn't exist:\n #{prefix}\n You may need to `xcode-select` the proper path if you have moved Xcode.\n EOS\n end\nend\n\ndef check_xcode_select_path\n if not MacOS::CLT.installed? and not File.file? \"#{MacOS.active_developer_dir}/usr/bin/xcodebuild\"\n path = MacOS::Xcode.bundle_path\n path = '/Developer' if path.nil? or not path.directory?\n <<-EOS.undent\n Your Xcode is configured with an invalid path.\n You should change it to the correct path:\n sudo xcode-select -switch #{path}\n EOS\n end\nend\n\ndef check_user_path_1\n $seen_prefix_bin = false\n $seen_prefix_sbin = false\n\n out = nil\n\n paths.each do |p|\n case p\n when '/usr/bin'\n unless $seen_prefix_bin\n # only show the doctor message if there are any conflicts\n # rationale: a default install should not trigger any brew doctor messages\n conflicts = Dir[\"#{HOMEBREW_PREFIX}/bin/*\"].\n map{ |fn| File.basename fn }.\n select{ |bn| File.exist? \"/usr/bin/#{bn}\" }\n\n if conflicts.size > 0\n out = <<-EOS.undent\n /usr/bin occurs before #{HOMEBREW_PREFIX}/bin\n This means that system-provided programs will be used instead of those\n provided by Homebrew. The following tools exist at both paths:\n\n #{conflicts * \"\\n \"}\n\n Consider setting your PATH so that #{HOMEBREW_PREFIX}/bin\n occurs before /usr/bin. Here is a one-liner:\n echo 'export PATH=\"#{HOMEBREW_PREFIX}/bin:$PATH\"' >> #{shell_profile}\n EOS\n end\n end\n when \"#{HOMEBREW_PREFIX}/bin\"\n $seen_prefix_bin = true\n when \"#{HOMEBREW_PREFIX}/sbin\"\n $seen_prefix_sbin = true\n end\n end\n out\nend\n\ndef check_user_path_2\n unless $seen_prefix_bin\n <<-EOS.undent\n Homebrew's bin was not found in your PATH.\n Consider setting the PATH for example like so\n echo 'export PATH=\"#{HOMEBREW_PREFIX}/bin:$PATH\"' >> #{shell_profile}\n EOS\n end\nend\n\ndef check_user_path_3\n # Don't complain about sbin not being in the path if it doesn't exist\n sbin = (HOMEBREW_PREFIX+'sbin')\n if sbin.directory? and sbin.children.length > 0\n unless $seen_prefix_sbin\n <<-EOS.undent\n Homebrew's sbin was not found in your PATH but you have installed\n formulae that put executables in #{HOMEBREW_PREFIX}/sbin.\n Consider setting the PATH for example like so\n echo 'export PATH=\"#{HOMEBREW_PREFIX}/sbin:$PATH\"' >> #{shell_profile}\n EOS\n end\n end\nend\n\ndef check_user_curlrc\n if %w[CURL_HOME HOME].any?{|key| ENV[key] and File.exist? \"#{ENV[key]}/.curlrc\" } then <<-EOS.undent\n You have a curlrc file\n If you have trouble downloading packages with Homebrew, then maybe this\n is the problem? If the following command doesn't work, then try removing\n your curlrc:\n curl http://github.com\n EOS\n end\nend\n\ndef check_which_pkg_config\n binary = which 'pkg-config'\n return if binary.nil?\n\n mono_config = Pathname.new(\"/usr/bin/pkg-config\")\n if mono_config.exist? && mono_config.realpath.to_s.include?(\"Mono.framework\") then <<-EOS.undent\n You have a non-Homebrew 'pkg-config' in your PATH:\n /usr/bin/pkg-config => #{mono_config.realpath}\n\n This was most likely created by the Mono installer. `./configure` may\n have problems finding brew-installed packages using this other pkg-config.\n\n Mono no longer installs this file as of 3.0.4. You should\n `sudo rm /usr/bin/pkg-config` and upgrade to the latest version of Mono.\n EOS\n elsif binary.to_s != \"#{HOMEBREW_PREFIX}/bin/pkg-config\" then <<-EOS.undent\n You have a non-Homebrew 'pkg-config' in your PATH:\n #{binary}\n\n `./configure` may have problems finding brew-installed packages using\n this other pkg-config.\n EOS\n end\nend\n\ndef check_for_gettext\n find_relative_paths(\"lib/libgettextlib.dylib\",\n \"lib/libintl.dylib\",\n \"include/libintl.h\")\n\n return if @found.empty?\n\n # Our gettext formula will be caught by check_linked_keg_only_brews\n f = Formulary.factory(\"gettext\") rescue nil\n return if f and f.linked_keg.directory? and @found.all? do |path|\n Pathname.new(path).realpath.to_s.start_with? \"#{HOMEBREW_CELLAR}/gettext\"\n end\n\n s = <<-EOS.undent_________________________________________________________72\n gettext files detected at a system prefix\n These files can cause compilation and link failures, especially if they\n are compiled with improper architectures. Consider removing these files:\n EOS\n inject_file_list(@found, s)\nend\n\ndef check_for_iconv\n unless find_relative_paths(\"lib/libiconv.dylib\", \"include/iconv.h\").empty?\n if (f = Formulary.factory(\"libiconv\") rescue nil) and f.linked_keg.directory?\n if not f.keg_only? then <<-EOS.undent\n A libiconv formula is installed and linked\n This will break stuff. For serious. Unlink it.\n EOS\n else\n # NOOP because: check_for_linked_keg_only_brews\n end\n else\n s = <<-EOS.undent_________________________________________________________72\n libiconv files detected at a system prefix other than /usr\n Homebrew doesn't provide a libiconv formula, and expects to link against\n the system version in /usr. libiconv in other prefixes can cause\n compile or link failure, especially if compiled with improper\n architectures. OS X itself never installs anything to /usr/local so\n it was either installed by a user or some other third party software.\n\n tl;dr: delete these files:\n EOS\n inject_file_list(@found, s)\n end\n end\nend\n\ndef check_for_config_scripts\n return unless HOMEBREW_CELLAR.exist?\n real_cellar = HOMEBREW_CELLAR.realpath\n\n scripts = []\n\n whitelist = %W[\n /usr/bin /usr/sbin\n /usr/X11/bin /usr/X11R6/bin /opt/X11/bin\n #{HOMEBREW_PREFIX}/bin #{HOMEBREW_PREFIX}/sbin\n /Applications/Server.app/Contents/ServerRoot/usr/bin\n /Applications/Server.app/Contents/ServerRoot/usr/sbin\n ].map(&:downcase)\n\n paths.each do |p|\n next if whitelist.include?(p.downcase) || !File.directory?(p)\n\n realpath = Pathname.new(p).realpath.to_s\n next if realpath.start_with?(real_cellar.to_s, HOMEBREW_CELLAR.to_s)\n\n scripts += Dir.chdir(p) { Dir[\"*-config\"] }.map { |c| File.join(p, c) }\n end\n\n unless scripts.empty?\n s = <<-EOS.undent\n \"config\" scripts exist outside your system or Homebrew directories.\n `./configure` scripts often look for *-config scripts to determine if\n software packages are installed, and what additional flags to use when\n compiling and linking.\n\n Having additional scripts in your path can confuse software installed via\n Homebrew if the config script overrides a system or Homebrew provided\n script of the same name. We found the following \"config\" scripts:\n\n EOS\n\n s << scripts.map { |f| \" #{f}\" }.join(\"\\n\")\n end\nend\n\ndef check_DYLD_vars\n found = ENV.keys.grep(/^DYLD_/)\n unless found.empty?\n s = <<-EOS.undent\n Setting DYLD_* vars can break dynamic linking.\n Set variables:\n EOS\n s << found.map { |e| \" #{e}: #{ENV.fetch(e)}\\n\" }.join\n if found.include? 'DYLD_INSERT_LIBRARIES'\n s += <<-EOS.undent\n\n Setting DYLD_INSERT_LIBRARIES can cause Go builds to fail.\n Having this set is common if you use this software:\n http://asepsis.binaryage.com/\n EOS\n end\n s\n end\nend\n\ndef check_for_symlinked_cellar\n return unless HOMEBREW_CELLAR.exist?\n if HOMEBREW_CELLAR.symlink?\n <<-EOS.undent\n Symlinked Cellars can cause problems.\n Your Homebrew Cellar is a symlink: #{HOMEBREW_CELLAR}\n which resolves to: #{HOMEBREW_CELLAR.realpath}\n\n The recommended Homebrew installations are either:\n (A) Have Cellar be a real directory inside of your HOMEBREW_PREFIX\n (B) Symlink \"bin/brew\" into your prefix, but don't symlink \"Cellar\".\n\n Older installations of Homebrew may have created a symlinked Cellar, but this can\n cause problems when two formula install to locations that are mapped on top of each\n other during the linking step.\n EOS\n end\nend\n\ndef check_for_multiple_volumes\n return unless HOMEBREW_CELLAR.exist?\n volumes = Volumes.new\n\n # Find the volumes for the TMP folder & HOMEBREW_CELLAR\n real_cellar = HOMEBREW_CELLAR.realpath\n\n tmp = Pathname.new(Dir.mktmpdir(\"doctor\", HOMEBREW_TEMP))\n real_temp = tmp.realpath.parent\n\n where_cellar = volumes.which real_cellar\n where_temp = volumes.which real_temp\n\n Dir.delete tmp\n\n unless where_cellar == where_temp then <<-EOS.undent\n Your Cellar and TEMP directories are on different volumes.\n OS X won't move relative symlinks across volumes unless the target file already\n exists. Brews known to be affected by this are Git and Narwhal.\n\n You should set the \"HOMEBREW_TEMP\" environmental variable to a suitable\n directory on the same volume as your Cellar.\n EOS\n end\nend\n\ndef check_filesystem_case_sensitive\n volumes = Volumes.new\n case_sensitive_vols = [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY, HOMEBREW_CELLAR, HOMEBREW_TEMP].select do |dir|\n # We select the dir as being case-sensitive if either the UPCASED or the\n # downcased variant is missing.\n # Of course, on a case-insensitive fs, both exist because the os reports so.\n # In the rare situation when the user has indeed a downcased and an upcased\n # dir (e.g. /TMP and /tmp) this check falsely thinks it is case-insensitive\n # but we don't care beacuse: 1. there is more than one dir checked, 2. the\n # check is not vital and 3. we would have to touch files otherwise.\n upcased = Pathname.new(dir.to_s.upcase)\n downcased = Pathname.new(dir.to_s.downcase)\n dir.exist? && !(upcased.exist? && downcased.exist?)\n end.map { |case_sensitive_dir| volumes.get_mounts(case_sensitive_dir) }.uniq\n return if case_sensitive_vols.empty?\n <<-EOS.undent\n The filesystem on #{case_sensitive_vols.join(\",\")} appears to be case-sensitive.\n The default OS X filesystem is case-insensitive. Please report any apparent problems.\n EOS\nend\n\ndef __check_git_version\n # https://help.github.com/articles/https-cloning-errors\n `git --version`.chomp =~ /git version ((?:\\d+\\.?)+)/\n\n if $1 and Version.new($1) < Version.new(\"1.7.10\") then <<-EOS.undent\n An outdated version of Git was detected in your PATH.\n Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.\n Please upgrade: brew upgrade git\n EOS\n end\nend\n\ndef check_for_git\n if git?\n __check_git_version\n else <<-EOS.undent\n Git could not be found in your PATH.\n Homebrew uses Git for several internal functions, and some formulae use Git\n checkouts instead of stable tarballs. You may want to install Git:\n brew install git\n EOS\n end\nend\n\ndef check_git_newline_settings\n return unless git?\n\n autocrlf = `git config --get core.autocrlf`.chomp\n\n if autocrlf == 'true' then <<-EOS.undent\n Suspicious Git newline settings found.\n\n The detected Git newline settings will cause checkout problems:\n core.autocrlf = #{autocrlf}\n\n If you are not routinely dealing with Windows-based projects,\n consider removing these by running:\n `git config --global core.autocrlf input`\n EOS\n end\nend\n\ndef check_git_origin\n return unless git? && (HOMEBREW_REPOSITORY/'.git').exist?\n\n HOMEBREW_REPOSITORY.cd do\n origin = `git config --get remote.origin.url`.strip\n\n if origin.empty? then <<-EOS.undent\n Missing git origin remote.\n\n Without a correctly configured origin, Homebrew won't update\n properly. You can solve this by adding the Homebrew remote:\n cd #{HOMEBREW_REPOSITORY}\n git remote add origin https://github.com/Homebrew/homebrew.git\n EOS\n elsif origin !~ /(mxcl|Homebrew)\\/homebrew(\\.git)?$/ then <<-EOS.undent\n Suspicious git origin remote found.\n\n With a non-standard origin, Homebrew won't pull updates from\n the main repository. The current git origin is:\n #{origin}\n\n Unless you have compelling reasons, consider setting the\n origin remote to point at the main repository, located at:\n https://github.com/Homebrew/homebrew.git\n EOS\n end\n end\nend\n\ndef check_for_autoconf\n return unless MacOS::Xcode.provides_autotools?\n\n autoconf = which('autoconf')\n safe_autoconfs = %w[/usr/bin/autoconf /Developer/usr/bin/autoconf]\n unless autoconf.nil? or safe_autoconfs.include? autoconf.to_s then <<-EOS.undent\n An \"autoconf\" in your path blocks the Xcode-provided version at:\n #{autoconf}\n\n This custom autoconf may cause some Homebrew formulae to fail to compile.\n EOS\n end\nend\n\ndef __check_linked_brew f\n f.rack.subdirs.each do |prefix|\n prefix.find do |src|\n next if src == prefix\n dst = HOMEBREW_PREFIX + src.relative_path_from(prefix)\n return true if dst.symlink? && src == dst.resolved_path\n end\n end\n\n false\nend\n\ndef check_for_linked_keg_only_brews\n return unless HOMEBREW_CELLAR.exist?\n\n linked = Formula.installed.select { |f|\n f.keg_only? && __check_linked_brew(f)\n }\n\n unless linked.empty?\n s = <<-EOS.undent\n Some keg-only formula are linked into the Cellar.\n Linking a keg-only formula, such as gettext, into the cellar with\n `brew link ` will cause other formulae to detect them during\n the `./configure` step. This may cause problems when compiling those\n other formulae.\n\n Binaries provided by keg-only formulae may override system binaries\n with other strange results.\n\n You may wish to `brew unlink` these brews:\n\n EOS\n linked.each { |f| s << \" #{f.full_name}\\n\" }\n s\n end\nend\n\ndef check_for_other_frameworks\n # Other frameworks that are known to cause problems when present\n %w{expat.framework libexpat.framework libcurl.framework}.\n map{ |frmwrk| \"/Library/Frameworks/#{frmwrk}\" }.\n select{ |frmwrk| File.exist? frmwrk }.\n map do |frmwrk| <<-EOS.undent\n #{frmwrk} detected\n This can be picked up by CMake's build system and likely cause the build to\n fail. You may need to move this file out of the way to compile CMake.\n EOS\n end.join\nend\n\ndef check_tmpdir\n tmpdir = ENV['TMPDIR']\n \"TMPDIR #{tmpdir.inspect} doesn't exist.\" unless tmpdir.nil? or File.directory? tmpdir\nend\n\ndef check_missing_deps\n return unless HOMEBREW_CELLAR.exist?\n missing = Set.new\n Homebrew.missing_deps(Formula.installed).each_value do |deps|\n missing.merge(deps)\n end\n\n if missing.any? then <<-EOS.undent\n Some installed formula are missing dependencies.\n You should `brew install` the missing dependencies:\n\n brew install #{missing.sort_by(&:full_name) * \" \"}\n\n Run `brew missing` for more details.\n EOS\n end\nend\n\ndef check_git_status\n return unless git?\n HOMEBREW_REPOSITORY.cd do\n unless `git status --untracked-files=all --porcelain -- Library/Homebrew/ 2>/dev/null`.chomp.empty?\n <<-EOS.undent_________________________________________________________72\n You have uncommitted modifications to Homebrew\n If this a surprise to you, then you should stash these modifications.\n Stashing returns Homebrew to a pristine state but can be undone\n should you later need to do so for some reason.\n cd #{HOMEBREW_LIBRARY} && git stash && git clean -d -f\n EOS\n end\n end\nend\n\ndef check_for_enthought_python\n if which \"enpkg\" then <<-EOS.undent\n Enthought Python was found in your PATH.\n This can cause build problems, as this software installs its own\n copies of iconv and libxml2 into directories that are picked up by\n other build systems.\n EOS\n end\nend\n\ndef check_for_library_python\n if File.exist?(\"/Library/Frameworks/Python.framework\") then <<-EOS.undent\n Python is installed at /Library/Frameworks/Python.framework\n\n Homebrew only supports building against the System-provided Python or a\n brewed Python. In particular, Pythons installed to /Library can interfere\n with other software installs.\n EOS\n end\nend\n\ndef check_for_old_homebrew_share_python_in_path\n s = ''\n ['', '3'].map do |suffix|\n if paths.include?((HOMEBREW_PREFIX/\"share/python#{suffix}\").to_s)\n s += \"#{HOMEBREW_PREFIX}/share/python#{suffix} is not needed in PATH.\\n\"\n end\n end\n unless s.empty?\n s += <<-EOS.undent\n Formerly homebrew put Python scripts you installed via `pip` or `pip3`\n (or `easy_install`) into that directory above but now it can be removed\n from your PATH variable.\n Python scripts will now install into #{HOMEBREW_PREFIX}/bin.\n You can delete anything, except 'Extras', from the #{HOMEBREW_PREFIX}/share/python\n (and #{HOMEBREW_PREFIX}/share/python3) dir and install affected Python packages\n anew with `pip install --upgrade`.\n EOS\n end\nend\n\ndef check_for_bad_python_symlink\n return unless which \"python\"\n `python -V 2>&1` =~ /Python (\\d+)\\./\n # This won't be the right warning if we matched nothing at all\n return if $1.nil?\n unless $1 == \"2\" then <<-EOS.undent\n python is symlinked to python#$1\n This will confuse build scripts and in general lead to subtle breakage.\n EOS\n end\nend\n\ndef check_for_non_prefixed_coreutils\n gnubin = \"#{Formulary.factory('coreutils').prefix}/libexec/gnubin\"\n if paths.include? gnubin then <<-EOS.undent\n Putting non-prefixed coreutils in your path can cause gmp builds to fail.\n EOS\n end\nend\n\ndef check_for_non_prefixed_findutils\n default_names = Tab.for_name('findutils').with? \"default-names\"\n if default_names then <<-EOS.undent\n Putting non-prefixed findutils in your path can cause python builds to fail.\n EOS\n end\nend\n\ndef check_for_pydistutils_cfg_in_home\n if File.exist? \"#{ENV['HOME']}/.pydistutils.cfg\" then <<-EOS.undent\n A .pydistutils.cfg file was found in $HOME, which may cause Python\n builds to fail. See:\n https://bugs.python.org/issue6138\n https://bugs.python.org/issue4655\n EOS\n end\nend\n\ndef check_for_outdated_homebrew\n return unless git?\n HOMEBREW_REPOSITORY.cd do\n if File.directory? \".git\"\n local = `git rev-parse -q --verify refs/remotes/origin/master`.chomp\n remote = /^([a-f0-9]{40})/.match(`git ls-remote origin refs/heads/master 2>/dev/null`)\n if remote.nil? || local == remote[0]\n return\n end\n end\n\n timestamp = if File.directory? \".git\"\n `git log -1 --format=\"%ct\" HEAD`.to_i\n else\n HOMEBREW_LIBRARY.mtime.to_i\n end\n\n if Time.now.to_i - timestamp > 60 * 60 * 24 then <<-EOS.undent\n Your Homebrew is outdated.\n You haven't updated for at least 24 hours. This is a long time in brewland!\n To update Homebrew, run `brew update`.\n EOS\n end\n end\nend\n\ndef check_for_unlinked_but_not_keg_only\n return unless HOMEBREW_CELLAR.exist?\n unlinked = HOMEBREW_CELLAR.children.reject do |rack|\n if not rack.directory?\n true\n elsif not (HOMEBREW_REPOSITORY/\"Library/LinkedKegs\"/rack.basename).directory?\n begin\n Formulary.from_rack(rack).keg_only?\n rescue FormulaUnavailableError, TapFormulaAmbiguityError\n false\n end\n else\n true\n end\n end.map{ |pn| pn.basename }\n\n if not unlinked.empty? then <<-EOS.undent\n You have unlinked kegs in your Cellar\n Leaving kegs unlinked can lead to build-trouble and cause brews that depend on\n those kegs to fail to run properly once built. Run `brew link` on these:\n\n #{unlinked * \"\\n \"}\n EOS\n end\nend\n\n def check_xcode_license_approved\n # If the user installs Xcode-only, they have to approve the\n # license or no \"xc*\" tool will work.\n if `/usr/bin/xcrun clang 2>&1` =~ /license/ and not $?.success? then <<-EOS.undent\n You have not agreed to the Xcode license.\n Builds will fail! Agree to the license by opening Xcode.app or running:\n sudo xcodebuild -license\n EOS\n end\n end\n\n def check_for_latest_xquartz\n return unless MacOS::XQuartz.version\n return if MacOS::XQuartz.provided_by_apple?\n\n installed_version = Version.new(MacOS::XQuartz.version)\n latest_version = Version.new(MacOS::XQuartz.latest_version)\n\n return if installed_version >= latest_version\n\n <<-EOS.undent\n Your XQuartz (#{installed_version}) is outdated\n Please install XQuartz #{latest_version}:\n https://xquartz.macosforge.org\n EOS\n end\n\n def check_for_old_env_vars\n if ENV[\"HOMEBREW_KEEP_INFO\"]\n <<-EOS.undent\n `HOMEBREW_KEEP_INFO` is no longer used\n info files are no longer deleted by default; you may\n remove this environment variable.\n EOS\n end\n end\n\n def check_for_pth_support\n homebrew_site_packages = Language::Python.homebrew_site_packages\n return unless homebrew_site_packages.directory?\n return if Language::Python.reads_brewed_pth_files?(\"python\") != false\n return unless Language::Python.in_sys_path?(\"python\", homebrew_site_packages)\n user_site_packages = Language::Python.user_site_packages \"python\"\n <<-EOS.undent\n Your default Python does not recognize the Homebrew site-packages\n directory as a special site-packages directory, which means that .pth\n files will not be followed. This means you will not be able to import\n some modules after installing them with Homebrew, like wxpython. To fix\n this for the current user, you can run:\n\n mkdir -p #{user_site_packages}\n echo 'import site; site.addsitedir(\"#{homebrew_site_packages}\")' >> #{user_site_packages}/homebrew.pth\n EOS\n end\n\n def check_for_external_cmd_name_conflict\n cmds = paths.map { |p| Dir[\"#{p}/brew-*\"] }.flatten.uniq\n cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) }\n cmd_map = {}\n cmds.each do |cmd|\n cmd_name = File.basename(cmd, \".rb\")\n cmd_map[cmd_name] ||= []\n cmd_map[cmd_name] << cmd\n end\n cmd_map.reject! { |cmd_name, cmd_paths| cmd_paths.size == 1 }\n return if cmd_map.empty?\n s = \"You have external commands with conflicting names.\"\n cmd_map.each do |cmd_name, cmd_paths|\n s += \"\\n\\nFound command `#{cmd_name}` in following places:\\n\"\n s += cmd_paths.map { |f| \" #{f}\" }.join(\"\\n\")\n end\n s\n end\n\n def all\n methods.map(&:to_s).grep(/^check_/)\n end\nend # end class Checks\n\nmodule Homebrew\n def doctor\n checks = Checks.new\n\n if ARGV.include? '--list-checks'\n puts checks.all.sort\n exit\n end\n\n inject_dump_stats(checks) if ARGV.switch? 'D'\n\n if ARGV.named.empty?\n methods = checks.all.sort\n methods << \"check_for_linked_keg_only_brews\" << \"check_for_outdated_homebrew\"\n methods = methods.reverse.uniq.reverse\n else\n methods = ARGV.named\n end\n\n first_warning = true\n methods.each do |method|\n begin\n out = checks.send(method)\n rescue NoMethodError\n Homebrew.failed = true\n puts \"No check available by the name: #{method}\"\n next\n end\n unless out.nil? or out.empty?\n if first_warning\n puts <<-EOS.undent\n #{Tty.white}Please note that these warnings are just used to help the Homebrew maintainers\n with debugging if you file an issue. If everything you use Homebrew for is\n working fine: please don't worry and just ignore them. Thanks!#{Tty.reset}\n EOS\n end\n\n puts\n opoo out\n Homebrew.failed = true\n first_warning = false\n end\n end\n\n puts \"Your system is ready to brew.\" unless Homebrew.failed?\n end\n\n def inject_dump_stats checks\n checks.extend Module.new {\n def send(method, *)\n time = Time.now\n super\n ensure\n $times[method] = Time.now - time\n end\n }\n $times = {}\n at_exit {\n puts $times.sort_by{|k, v| v }.map{|k, v| \"#{k}: #{v}\"}\n }\n end\nend\n"},"repo_name":{"kind":"string","value":"wolfd/homebrew"},"path":{"kind":"string","value":"Library/Homebrew/cmd/doctor.rb"},"language":{"kind":"string","value":"Ruby"},"license":{"kind":"string","value":"bsd-2-clause"},"size":{"kind":"number","value":40730,"string":"40,730"}}},{"rowIdx":61538438,"cells":{"code":{"kind":"string","value":"// Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n#include \"ui/views/corewm/window_animations.h\"\n\n#include \n\n#include \n#include \n\n#include \"base/command_line.h\"\n#include \"base/compiler_specific.h\"\n#include \"base/logging.h\"\n#include \"base/message_loop/message_loop.h\"\n#include \"base/stl_util.h\"\n#include \"base/time/time.h\"\n#include \"ui/aura/client/animation_host.h\"\n#include \"ui/aura/client/aura_constants.h\"\n#include \"ui/aura/window.h\"\n#include \"ui/aura/window_delegate.h\"\n#include \"ui/aura/window_observer.h\"\n#include \"ui/aura/window_property.h\"\n#include \"ui/compositor/compositor_observer.h\"\n#include \"ui/compositor/layer.h\"\n#include \"ui/compositor/layer_animation_observer.h\"\n#include \"ui/compositor/layer_animation_sequence.h\"\n#include \"ui/compositor/layer_animator.h\"\n#include \"ui/compositor/scoped_layer_animation_settings.h\"\n#include \"ui/gfx/interpolated_transform.h\"\n#include \"ui/gfx/rect_conversions.h\"\n#include \"ui/gfx/screen.h\"\n#include \"ui/gfx/vector2d.h\"\n#include \"ui/gfx/vector3d_f.h\"\n#include \"ui/views/corewm/corewm_switches.h\"\n#include \"ui/views/corewm/window_util.h\"\n#include \"ui/views/view.h\"\n#include \"ui/views/widget/widget.h\"\n\nDECLARE_WINDOW_PROPERTY_TYPE(int)\nDECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationType)\nDECLARE_WINDOW_PROPERTY_TYPE(views::corewm::WindowVisibilityAnimationTransition)\nDECLARE_WINDOW_PROPERTY_TYPE(float)\nDECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, bool)\n\nusing aura::Window;\nusing base::TimeDelta;\nusing ui::Layer;\n\nnamespace views {\nnamespace corewm {\nnamespace {\nconst float kWindowAnimation_Vertical_TranslateY = 15.f;\n} // namespace\n\nDEFINE_WINDOW_PROPERTY_KEY(int,\n kWindowVisibilityAnimationTypeKey,\n WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);\nDEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);\nDEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,\n kWindowVisibilityAnimationTransitionKey,\n ANIMATE_BOTH);\nDEFINE_WINDOW_PROPERTY_KEY(float,\n kWindowVisibilityAnimationVerticalPositionKey,\n kWindowAnimation_Vertical_TranslateY);\n\nnamespace {\n\nconst int kDefaultAnimationDurationForMenuMS = 150;\n\nconst float kWindowAnimation_HideOpacity = 0.f;\nconst float kWindowAnimation_ShowOpacity = 1.f;\nconst float kWindowAnimation_TranslateFactor = 0.5f;\nconst float kWindowAnimation_ScaleFactor = .95f;\n\nconst int kWindowAnimation_Rotate_DurationMS = 180;\nconst int kWindowAnimation_Rotate_OpacityDurationPercent = 90;\nconst float kWindowAnimation_Rotate_TranslateY = -20.f;\nconst float kWindowAnimation_Rotate_PerspectiveDepth = 500.f;\nconst float kWindowAnimation_Rotate_DegreesX = 5.f;\nconst float kWindowAnimation_Rotate_ScaleFactor = .99f;\n\nconst float kWindowAnimation_Bounce_Scale = 1.02f;\nconst int kWindowAnimation_Bounce_DurationMS = 180;\nconst int kWindowAnimation_Bounce_GrowShrinkDurationPercent = 40;\n\nbase::TimeDelta GetWindowVisibilityAnimationDuration(aura::Window* window) {\n int duration =\n window->GetProperty(kWindowVisibilityAnimationDurationKey);\n if (duration == 0 && window->type() == aura::client::WINDOW_TYPE_MENU) {\n return base::TimeDelta::FromMilliseconds(\n kDefaultAnimationDurationForMenuMS);\n }\n return TimeDelta::FromInternalValue(duration);\n}\n\n// Gets/sets the WindowVisibilityAnimationType associated with a window.\n// TODO(beng): redundant/fold into method on public api?\nint GetWindowVisibilityAnimationType(aura::Window* window) {\n int type = window->GetProperty(kWindowVisibilityAnimationTypeKey);\n if (type == WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT) {\n return (window->type() == aura::client::WINDOW_TYPE_MENU ||\n window->type() == aura::client::WINDOW_TYPE_TOOLTIP) ?\n WINDOW_VISIBILITY_ANIMATION_TYPE_FADE :\n WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;\n }\n return type;\n}\n\n// Observes a hide animation.\n// A window can be hidden for a variety of reasons. Sometimes, Hide() will be\n// called and life is simple. Sometimes, the window is actually bound to a\n// views::Widget and that Widget is closed, and life is a little more\n// complicated. When a Widget is closed the aura::Window* is actually not\n// destroyed immediately - it is actually just immediately hidden and then\n// destroyed when the stack unwinds. To handle this case, we start the hide\n// animation immediately when the window is hidden, then when the window is\n// subsequently destroyed this object acquires ownership of the window's layer,\n// so that it can continue animating it until the animation completes.\n// Regardless of whether or not the window is destroyed, this object deletes\n// itself when the animation completes.\nclass HidingWindowAnimationObserver : public ui::ImplicitAnimationObserver,\n public aura::WindowObserver {\n public:\n explicit HidingWindowAnimationObserver(aura::Window* window)\n : window_(window) {\n window_->AddObserver(this);\n }\n virtual ~HidingWindowAnimationObserver() {\n STLDeleteElements(&layers_);\n }\n\n private:\n // Overridden from ui::ImplicitAnimationObserver:\n virtual void OnImplicitAnimationsCompleted() OVERRIDE {\n // Window may have been destroyed by this point.\n if (window_) {\n aura::client::AnimationHost* animation_host =\n aura::client::GetAnimationHost(window_);\n if (animation_host)\n animation_host->OnWindowHidingAnimationCompleted();\n window_->RemoveObserver(this);\n }\n delete this;\n }\n\n // Overridden from aura::WindowObserver:\n virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {\n DCHECK_EQ(window, window_);\n DCHECK(layers_.empty());\n AcquireAllLayers(window_);\n\n // If the Widget has views with layers, then it is necessary to take\n // ownership of those layers too.\n views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window_);\n const views::Widget* const_widget = widget;\n if (widget && const_widget->GetRootView() && widget->GetContentsView())\n AcquireAllViewLayers(widget->GetContentsView());\n window_->RemoveObserver(this);\n window_ = NULL;\n }\n\n void AcquireAllLayers(aura::Window* window) {\n ui::Layer* layer = window->AcquireLayer();\n DCHECK(layer);\n layers_.push_back(layer);\n for (aura::Window::Windows::const_iterator it = window->children().begin();\n it != window->children().end();\n ++it)\n AcquireAllLayers(*it);\n }\n\n void AcquireAllViewLayers(views::View* view) {\n for (int i = 0; i < view->child_count(); ++i)\n AcquireAllViewLayers(view->child_at(i));\n if (view->layer()) {\n ui::Layer* layer = view->RecreateLayer();\n if (layer) {\n layer->SuppressPaint();\n layers_.push_back(layer);\n }\n }\n }\n\n aura::Window* window_;\n std::vector layers_;\n\n DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserver);\n};\n\nvoid GetTransformRelativeToRoot(ui::Layer* layer, gfx::Transform* transform) {\n const Layer* root = layer;\n while (root->parent())\n root = root->parent();\n layer->GetTargetTransformRelativeTo(root, transform);\n}\n\ngfx::Rect GetLayerWorldBoundsAfterTransform(ui::Layer* layer,\n const gfx::Transform& transform) {\n gfx::Transform in_world = transform;\n GetTransformRelativeToRoot(layer, &in_world);\n\n gfx::RectF transformed = layer->bounds();\n in_world.TransformRect(&transformed);\n\n return gfx::ToEnclosingRect(transformed);\n}\n\n// Augment the host window so that the enclosing bounds of the full\n// animation will fit inside of it.\nvoid AugmentWindowSize(aura::Window* window,\n const gfx::Transform& end_transform) {\n aura::client::AnimationHost* animation_host =\n aura::client::GetAnimationHost(window);\n if (!animation_host)\n return;\n\n const gfx::Rect& world_at_start = window->bounds();\n gfx::Rect world_at_end =\n GetLayerWorldBoundsAfterTransform(window->layer(), end_transform);\n gfx::Rect union_in_window_space =\n gfx::UnionRects(world_at_start, world_at_end);\n\n // Calculate the top left and bottom right deltas to be added to the window\n // bounds.\n gfx::Vector2d top_left_delta(world_at_start.x() - union_in_window_space.x(),\n world_at_start.y() - union_in_window_space.y());\n\n gfx::Vector2d bottom_right_delta(\n union_in_window_space.x() + union_in_window_space.width() -\n (world_at_start.x() + world_at_start.width()),\n union_in_window_space.y() + union_in_window_space.height() -\n (world_at_start.y() + world_at_start.height()));\n\n DCHECK(top_left_delta.x() >= 0 && top_left_delta.y() >= 0 &&\n bottom_right_delta.x() >= 0 && bottom_right_delta.y() >= 0);\n\n animation_host->SetHostTransitionOffsets(top_left_delta, bottom_right_delta);\n}\n\n// Shows a window using an animation, animating its opacity from 0.f to 1.f,\n// its visibility to true, and its transform from |start_transform| to\n// |end_transform|.\nvoid AnimateShowWindowCommon(aura::Window* window,\n const gfx::Transform& start_transform,\n const gfx::Transform& end_transform) {\n window->layer()->set_delegate(window);\n\n AugmentWindowSize(window, end_transform);\n\n window->layer()->SetOpacity(kWindowAnimation_HideOpacity);\n window->layer()->SetTransform(start_transform);\n window->layer()->SetVisible(true);\n\n {\n // Property sets within this scope will be implicitly animated.\n ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());\n base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);\n if (duration.ToInternalValue() > 0)\n settings.SetTransitionDuration(duration);\n\n window->layer()->SetTransform(end_transform);\n window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);\n }\n}\n\n// Hides a window using an animation, animating its opacity from 1.f to 0.f,\n// its visibility to false, and its transform to |end_transform|.\nvoid AnimateHideWindowCommon(aura::Window* window,\n const gfx::Transform& end_transform) {\n AugmentWindowSize(window, end_transform);\n window->layer()->set_delegate(NULL);\n\n // Property sets within this scope will be implicitly animated.\n ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());\n settings.AddObserver(new HidingWindowAnimationObserver(window));\n\n base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);\n if (duration.ToInternalValue() > 0)\n settings.SetTransitionDuration(duration);\n\n window->layer()->SetOpacity(kWindowAnimation_HideOpacity);\n window->layer()->SetTransform(end_transform);\n window->layer()->SetVisible(false);\n}\n\nstatic gfx::Transform GetScaleForWindow(aura::Window* window) {\n gfx::Rect bounds = window->bounds();\n gfx::Transform scale = gfx::GetScaleTransform(\n gfx::Point(kWindowAnimation_TranslateFactor * bounds.width(),\n kWindowAnimation_TranslateFactor * bounds.height()),\n kWindowAnimation_ScaleFactor);\n return scale;\n}\n\n// Show/Hide windows using a shrink animation.\nvoid AnimateShowWindow_Drop(aura::Window* window) {\n AnimateShowWindowCommon(window, GetScaleForWindow(window), gfx::Transform());\n}\n\nvoid AnimateHideWindow_Drop(aura::Window* window) {\n AnimateHideWindowCommon(window, GetScaleForWindow(window));\n}\n\n// Show/Hide windows using a vertical Glenimation.\nvoid AnimateShowWindow_Vertical(aura::Window* window) {\n gfx::Transform transform;\n transform.Translate(0, window->GetProperty(\n kWindowVisibilityAnimationVerticalPositionKey));\n AnimateShowWindowCommon(window, transform, gfx::Transform());\n}\n\nvoid AnimateHideWindow_Vertical(aura::Window* window) {\n gfx::Transform transform;\n transform.Translate(0, window->GetProperty(\n kWindowVisibilityAnimationVerticalPositionKey));\n AnimateHideWindowCommon(window, transform);\n}\n\n// Show/Hide windows using a fade.\nvoid AnimateShowWindow_Fade(aura::Window* window) {\n AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform());\n}\n\nvoid AnimateHideWindow_Fade(aura::Window* window) {\n AnimateHideWindowCommon(window, gfx::Transform());\n}\n\nui::LayerAnimationElement* CreateGrowShrinkElement(\n aura::Window* window, bool grow) {\n scoped_ptr scale(new ui::InterpolatedScale(\n gfx::Point3F(kWindowAnimation_Bounce_Scale,\n kWindowAnimation_Bounce_Scale,\n 1),\n gfx::Point3F(1, 1, 1)));\n scoped_ptr scale_about_pivot(\n new ui::InterpolatedTransformAboutPivot(\n gfx::Point(window->bounds().width() * 0.5,\n window->bounds().height() * 0.5),\n scale.release()));\n scale_about_pivot->SetReversed(grow);\n scoped_ptr transition(\n ui::LayerAnimationElement::CreateInterpolatedTransformElement(\n scale_about_pivot.release(),\n base::TimeDelta::FromMilliseconds(\n kWindowAnimation_Bounce_DurationMS *\n kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100)));\n transition->set_tween_type(grow ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN);\n return transition.release();\n}\n\nvoid AnimateBounce(aura::Window* window) {\n ui::ScopedLayerAnimationSettings scoped_settings(\n window->layer()->GetAnimator());\n scoped_settings.SetPreemptionStrategy(\n ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);\n window->layer()->set_delegate(window);\n scoped_ptr sequence(\n new ui::LayerAnimationSequence);\n sequence->AddElement(CreateGrowShrinkElement(window, true));\n ui::LayerAnimationElement::AnimatableProperties paused_properties;\n paused_properties.insert(ui::LayerAnimationElement::BOUNDS);\n sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(\n paused_properties,\n base::TimeDelta::FromMilliseconds(\n kWindowAnimation_Bounce_DurationMS *\n (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) /\n 100)));\n sequence->AddElement(CreateGrowShrinkElement(window, false));\n window->layer()->GetAnimator()->StartAnimation(sequence.release());\n}\n\nvoid AddLayerAnimationsForRotate(aura::Window* window, bool show) {\n window->layer()->set_delegate(window);\n if (show)\n window->layer()->SetOpacity(kWindowAnimation_HideOpacity);\n\n base::TimeDelta duration = base::TimeDelta::FromMilliseconds(\n kWindowAnimation_Rotate_DurationMS);\n\n if (!show) {\n new HidingWindowAnimationObserver(window);\n window->layer()->GetAnimator()->SchedulePauseForProperties(\n duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100,\n ui::LayerAnimationElement::OPACITY,\n -1);\n }\n scoped_ptr opacity(\n ui::LayerAnimationElement::CreateOpacityElement(\n show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity,\n duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100));\n opacity->set_tween_type(gfx::Tween::EASE_IN_OUT);\n window->layer()->GetAnimator()->ScheduleAnimation(\n new ui::LayerAnimationSequence(opacity.release()));\n\n float xcenter = window->bounds().width() * 0.5;\n\n gfx::Transform transform;\n transform.Translate(xcenter, 0);\n transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth);\n transform.Translate(-xcenter, 0);\n scoped_ptr perspective(\n new ui::InterpolatedConstantTransform(transform));\n\n scoped_ptr scale(\n new ui::InterpolatedScale(1, kWindowAnimation_Rotate_ScaleFactor));\n scoped_ptr scale_about_pivot(\n new ui::InterpolatedTransformAboutPivot(\n gfx::Point(xcenter, kWindowAnimation_Rotate_TranslateY),\n scale.release()));\n\n scoped_ptr translation(\n new ui::InterpolatedTranslation(gfx::Point(), gfx::Point(\n 0, kWindowAnimation_Rotate_TranslateY)));\n\n scoped_ptr rotation(\n new ui::InterpolatedAxisAngleRotation(\n gfx::Vector3dF(1, 0, 0), 0, kWindowAnimation_Rotate_DegreesX));\n\n scale_about_pivot->SetChild(perspective.release());\n translation->SetChild(scale_about_pivot.release());\n rotation->SetChild(translation.release());\n rotation->SetReversed(show);\n\n scoped_ptr transition(\n ui::LayerAnimationElement::CreateInterpolatedTransformElement(\n rotation.release(), duration));\n\n window->layer()->GetAnimator()->ScheduleAnimation(\n new ui::LayerAnimationSequence(transition.release()));\n}\n\nvoid AnimateShowWindow_Rotate(aura::Window* window) {\n AddLayerAnimationsForRotate(window, true);\n}\n\nvoid AnimateHideWindow_Rotate(aura::Window* window) {\n AddLayerAnimationsForRotate(window, false);\n}\n\nbool AnimateShowWindow(aura::Window* window) {\n if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW)) {\n if (HasWindowVisibilityAnimationTransition(window, ANIMATE_HIDE)) {\n // Since hide animation may have changed opacity and transform,\n // reset them to show the window.\n window->layer()->set_delegate(window);\n window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);\n window->layer()->SetTransform(gfx::Transform());\n }\n return false;\n }\n\n switch (GetWindowVisibilityAnimationType(window)) {\n case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:\n AnimateShowWindow_Drop(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:\n AnimateShowWindow_Vertical(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:\n AnimateShowWindow_Fade(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE:\n AnimateShowWindow_Rotate(window);\n return true;\n default:\n return false;\n }\n}\n\nbool AnimateHideWindow(aura::Window* window) {\n if (!HasWindowVisibilityAnimationTransition(window, ANIMATE_HIDE)) {\n if (HasWindowVisibilityAnimationTransition(window, ANIMATE_SHOW)) {\n // Since show animation may have changed opacity and transform,\n // reset them, though the change should be hidden.\n window->layer()->set_delegate(NULL);\n window->layer()->SetOpacity(kWindowAnimation_HideOpacity);\n window->layer()->SetTransform(gfx::Transform());\n }\n return false;\n }\n\n switch (GetWindowVisibilityAnimationType(window)) {\n case WINDOW_VISIBILITY_ANIMATION_TYPE_DROP:\n AnimateHideWindow_Drop(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL:\n AnimateHideWindow_Vertical(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_FADE:\n AnimateHideWindow_Fade(window);\n return true;\n case WINDOW_VISIBILITY_ANIMATION_TYPE_ROTATE:\n AnimateHideWindow_Rotate(window);\n return true;\n default:\n return false;\n }\n}\n\n} // namespace\n\n////////////////////////////////////////////////////////////////////////////////\n// External interface\n\nvoid SetWindowVisibilityAnimationType(aura::Window* window, int type) {\n window->SetProperty(kWindowVisibilityAnimationTypeKey, type);\n}\n\nint GetWindowVisibilityAnimationType(aura::Window* window) {\n return window->GetProperty(kWindowVisibilityAnimationTypeKey);\n}\n\nvoid SetWindowVisibilityAnimationTransition(\n aura::Window* window,\n WindowVisibilityAnimationTransition transition) {\n window->SetProperty(kWindowVisibilityAnimationTransitionKey, transition);\n}\n\nbool HasWindowVisibilityAnimationTransition(\n aura::Window* window,\n WindowVisibilityAnimationTransition transition) {\n WindowVisibilityAnimationTransition prop = window->GetProperty(\n kWindowVisibilityAnimationTransitionKey);\n return (prop & transition) != 0;\n}\n\nvoid SetWindowVisibilityAnimationDuration(aura::Window* window,\n const TimeDelta& duration) {\n window->SetProperty(kWindowVisibilityAnimationDurationKey,\n static_cast(duration.ToInternalValue()));\n}\n\nvoid SetWindowVisibilityAnimationVerticalPosition(aura::Window* window,\n float position) {\n window->SetProperty(kWindowVisibilityAnimationVerticalPositionKey, position);\n}\n\nui::ImplicitAnimationObserver* CreateHidingWindowAnimationObserver(\n aura::Window* window) {\n return new HidingWindowAnimationObserver(window);\n}\n\nbool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {\n if (WindowAnimationsDisabled(window))\n return false;\n if (visible)\n return AnimateShowWindow(window);\n // Don't start hiding the window again if it's already being hidden.\n return window->layer()->GetTargetOpacity() != 0.0f &&\n AnimateHideWindow(window);\n}\n\nbool AnimateWindow(aura::Window* window, WindowAnimationType type) {\n switch (type) {\n case WINDOW_ANIMATION_TYPE_BOUNCE:\n AnimateBounce(window);\n return true;\n default:\n NOTREACHED();\n return false;\n }\n}\n\nbool WindowAnimationsDisabled(aura::Window* window) {\n return (window &&\n window->GetProperty(aura::client::kAnimationsDisabledKey)) ||\n CommandLine::ForCurrentProcess()->HasSwitch(\n switches::kWindowAnimationsDisabled);\n}\n\n} // namespace corewm\n} // namespace views\n"},"repo_name":{"kind":"string","value":"DirtyUnicorns/android_external_chromium-org"},"path":{"kind":"string","value":"ui/views/corewm/window_animations.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":21476,"string":"21,476"}}},{"rowIdx":61538439,"cells":{"code":{"kind":"string","value":"/* @flow */\n\nfunction a(x: {[key: string]: ?string}, y: string): string {\n if (x[y]) {\n return x[y];\n }\n return \"\";\n}\n\nfunction b(x: {y: {[key: string]: ?string}}, z: string): string {\n if (x.y[z]) {\n return x.y[z];\n }\n return \"\";\n}\n\nfunction c(x: {[key: string]: ?string}, y: {z: string}): string {\n if (x[y.z]) {\n return x[y.z];\n }\n return \"\";\n}\n\nfunction d(x: {y: {[key: string]: ?string}}, a: {b: string}): string {\n if (x.y[a.b]) {\n return x.y[a.b];\n }\n return \"\";\n}\n\nfunction a_array(x: Array, y: number): string {\n if (x[y]) {\n return x[y];\n }\n return \"\";\n}\n\nfunction b_array(x: {y: Array}, z: number): string {\n if (x.y[z]) {\n return x.y[z];\n }\n return \"\";\n}\n\nfunction c_array(x: Array, y: {z: number}): string {\n if (x[y.z]) {\n return x[y.z];\n }\n return \"\";\n}\n\nfunction d_array(x: {y: Array}, a: {b: number}): string {\n if (x.y[a.b]) {\n return x.y[a.b];\n }\n return \"\";\n}\n\n// --- name-sensitive havoc ---\n\nfunction c2(x: {[key: string]: ?string}, y: {z: string}): string {\n if (x[y.z]) {\n y.z = \"HEY\";\n return x[y.z]; // error\n }\n return \"\";\n}\n\nfunction c3(x: {[key: string]: ?string}, y: {z: string, a: string}): string {\n if (x[y.z]) {\n y.a = \"HEY\";\n return x[y.z]; // ok\n }\n return \"\";\n}\n"},"repo_name":{"kind":"string","value":"JohnyDays/flow"},"path":{"kind":"string","value":"tests/refinements/property.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":1303,"string":"1,303"}}},{"rowIdx":61538440,"cells":{"code":{"kind":"string","value":"// Copyright 2012-2015 Oliver Eilhard. All rights reserved.\n// Use of this source code is governed by a MIT-license.\n// See http://olivere.mit-license.org/license.txt for details.\n\npackage elastic\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"net/url\"\n\t\"strings\"\n\n\t\"github.com/olivere/elastic/uritemplates\"\n)\n\nvar (\n\t_ = fmt.Print\n\t_ = log.Print\n\t_ = strings.Index\n\t_ = uritemplates.Expand\n\t_ = url.Parse\n)\n\n// PutMappingService allows to register specific mapping definition\n// for a specific type.\n// See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-put-mapping.html.\ntype PutMappingService struct {\n\tclient *Client\n\tpretty bool\n\ttyp string\n\tindex []string\n\tmasterTimeout string\n\tignoreUnavailable *bool\n\tallowNoIndices *bool\n\texpandWildcards string\n\tignoreConflicts *bool\n\ttimeout string\n\tbodyJson map[string]interface{}\n\tbodyString string\n}\n\n// NewPutMappingService creates a new PutMappingService.\nfunc NewPutMappingService(client *Client) *PutMappingService {\n\treturn &PutMappingService{\n\t\tclient: client,\n\t\tindex: make([]string, 0),\n\t}\n}\n\n// Index is a list of index names the mapping should be added to\n// (supports wildcards); use `_all` or omit to add the mapping on all indices.\nfunc (s *PutMappingService) Index(index ...string) *PutMappingService {\n\ts.index = append(s.index, index...)\n\treturn s\n}\n\n// Type is the name of the document type.\nfunc (s *PutMappingService) Type(typ string) *PutMappingService {\n\ts.typ = typ\n\treturn s\n}\n\n// Timeout is an explicit operation timeout.\nfunc (s *PutMappingService) Timeout(timeout string) *PutMappingService {\n\ts.timeout = timeout\n\treturn s\n}\n\n// MasterTimeout specifies the timeout for connection to master.\nfunc (s *PutMappingService) MasterTimeout(masterTimeout string) *PutMappingService {\n\ts.masterTimeout = masterTimeout\n\treturn s\n}\n\n// IgnoreUnavailable indicates whether specified concrete indices should be\n// ignored when unavailable (missing or closed).\nfunc (s *PutMappingService) IgnoreUnavailable(ignoreUnavailable bool) *PutMappingService {\n\ts.ignoreUnavailable = &ignoreUnavailable\n\treturn s\n}\n\n// AllowNoIndices indicates whether to ignore if a wildcard indices\n// expression resolves into no concrete indices.\n// This includes `_all` string or when no indices have been specified.\nfunc (s *PutMappingService) AllowNoIndices(allowNoIndices bool) *PutMappingService {\n\ts.allowNoIndices = &allowNoIndices\n\treturn s\n}\n\n// ExpandWildcards indicates whether to expand wildcard expression to\n// concrete indices that are open, closed or both.\nfunc (s *PutMappingService) ExpandWildcards(expandWildcards string) *PutMappingService {\n\ts.expandWildcards = expandWildcards\n\treturn s\n}\n\n// IgnoreConflicts specifies whether to ignore conflicts while updating\n// the mapping (default: false).\nfunc (s *PutMappingService) IgnoreConflicts(ignoreConflicts bool) *PutMappingService {\n\ts.ignoreConflicts = &ignoreConflicts\n\treturn s\n}\n\n// Pretty indicates that the JSON response be indented and human readable.\nfunc (s *PutMappingService) Pretty(pretty bool) *PutMappingService {\n\ts.pretty = pretty\n\treturn s\n}\n\n// BodyJson contains the mapping definition.\nfunc (s *PutMappingService) BodyJson(mapping map[string]interface{}) *PutMappingService {\n\ts.bodyJson = mapping\n\treturn s\n}\n\n// BodyString is the mapping definition serialized as a string.\nfunc (s *PutMappingService) BodyString(mapping string) *PutMappingService {\n\ts.bodyString = mapping\n\treturn s\n}\n\n// buildURL builds the URL for the operation.\nfunc (s *PutMappingService) buildURL() (string, url.Values, error) {\n\tvar err error\n\tvar path string\n\n\t// Build URL: Typ MUST be specified and is verified in Validate.\n\tif len(s.index) > 0 {\n\t\tpath, err = uritemplates.Expand(\"/{index}/_mapping/{type}\", map[string]string{\n\t\t\t\"index\": strings.Join(s.index, \",\"),\n\t\t\t\"type\": s.typ,\n\t\t})\n\t} else {\n\t\tpath, err = uritemplates.Expand(\"/_mapping/{type}\", map[string]string{\n\t\t\t\"type\": s.typ,\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn \"\", url.Values{}, err\n\t}\n\n\t// Add query string parameters\n\tparams := url.Values{}\n\tif s.pretty {\n\t\tparams.Set(\"pretty\", \"1\")\n\t}\n\tif s.ignoreUnavailable != nil {\n\t\tparams.Set(\"ignore_unavailable\", fmt.Sprintf(\"%v\", *s.ignoreUnavailable))\n\t}\n\tif s.allowNoIndices != nil {\n\t\tparams.Set(\"allow_no_indices\", fmt.Sprintf(\"%v\", *s.allowNoIndices))\n\t}\n\tif s.expandWildcards != \"\" {\n\t\tparams.Set(\"expand_wildcards\", s.expandWildcards)\n\t}\n\tif s.ignoreConflicts != nil {\n\t\tparams.Set(\"ignore_conflicts\", fmt.Sprintf(\"%v\", *s.ignoreConflicts))\n\t}\n\tif s.timeout != \"\" {\n\t\tparams.Set(\"timeout\", s.timeout)\n\t}\n\tif s.masterTimeout != \"\" {\n\t\tparams.Set(\"master_timeout\", s.masterTimeout)\n\t}\n\treturn path, params, nil\n}\n\n// Validate checks if the operation is valid.\nfunc (s *PutMappingService) Validate() error {\n\tvar invalid []string\n\tif s.typ == \"\" {\n\t\tinvalid = append(invalid, \"Type\")\n\t}\n\tif s.bodyString == \"\" && s.bodyJson == nil {\n\t\tinvalid = append(invalid, \"BodyJson\")\n\t}\n\tif len(invalid) > 0 {\n\t\treturn fmt.Errorf(\"missing required fields: %v\", invalid)\n\t}\n\treturn nil\n}\n\n// Do executes the operation.\nfunc (s *PutMappingService) Do() (*PutMappingResponse, error) {\n\t// Check pre-conditions\n\tif err := s.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Get URL for request\n\tpath, params, err := s.buildURL()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Setup HTTP request body\n\tvar body interface{}\n\tif s.bodyJson != nil {\n\t\tbody = s.bodyJson\n\t} else {\n\t\tbody = s.bodyString\n\t}\n\n\t// Get HTTP response\n\tres, err := s.client.PerformRequest(\"PUT\", path, params, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Return operation response\n\tret := new(PutMappingResponse)\n\tif err := json.Unmarshal(res.Body, ret); err != nil {\n\t\treturn nil, err\n\t}\n\treturn ret, nil\n}\n\n// PutMappingResponse is the response of PutMappingService.Do.\ntype PutMappingResponse struct {\n\tAcknowledged bool `json:\"acknowledged\"`\n}\n"},"repo_name":{"kind":"string","value":"seekingalpha/bosun"},"path":{"kind":"string","value":"vendor/github.com/olivere/elastic/put_mapping.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":5940,"string":"5,940"}}},{"rowIdx":61538441,"cells":{"code":{"kind":"string","value":"using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Data;\nusing System.Linq;\nusing System.Text;\nusing System.Windows.Forms;\n\nusing UICore;\n\nnamespace SlimTuneUI.CoreVis\n{\n\t[DisplayName(\"Hotspots\")]\n\tpublic partial class HotSpots : UserControl, IVisualizer\n\t{\n\t\tProfilerWindowBase m_mainWindow;\n\t\tConnection m_connection;\n\t\tSnapshot m_snapshot;\n\n\t\t//drawing stuff\n\t\tFont m_functionFont = new Font(SystemFonts.DefaultFont.FontFamily, 12, FontStyle.Bold);\n\t\tFont m_objectFont = new Font(SystemFonts.DefaultFont.FontFamily, 9, FontStyle.Regular);\n\n\t\tclass ListTag\n\t\t{\n\t\t\tpublic ListBox Right;\n\t\t\tpublic double TotalTime;\n\t\t}\n\n\t\tpublic event EventHandler Refreshed;\n\n\t\tpublic string DisplayName\n\t\t{\n\t\t\tget { return \"Hotspots\"; }\n\t\t}\n\n\t\tpublic UserControl Control\n\t\t{\n\t\t\tget { return this; }\n\t\t}\n\n\t\tpublic Snapshot Snapshot\n\t\t{\n\t\t\tget { return m_snapshot; }\n\t\t}\n\n\t\tpublic bool SupportsRefresh\n\t\t{\n\t\t\tget { return true; }\n\t\t}\n\n\t\tpublic HotSpots()\n\t\t{\n\t\t\tInitializeComponent();\n\t\t\tHotspotsList.Tag = new ListTag();\n\t\t}\n\n\t\tpublic bool Initialize(ProfilerWindowBase mainWindow, Connection connection, Snapshot snapshot)\n\t\t{\n\t\t\tif(mainWindow == null)\n\t\t\t\tthrow new ArgumentNullException(\"mainWindow\");\n\t\t\tif(connection == null)\n\t\t\t\tthrow new ArgumentNullException(\"connection\");\n\n\t\t\tm_mainWindow = mainWindow;\n\t\t\tm_connection = connection;\n\t\t\tm_snapshot = snapshot;\n\n\t\t\tUpdateHotspots();\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic void OnClose()\n\t\t{\n\t\t}\n\n\t\tpublic void RefreshView()\n\t\t{\n\t\t\tvar rightTag = HotspotsList.Tag as ListTag;\n\t\t\tif(rightTag != null)\n\t\t\t\tRemoveList(rightTag.Right);\n\n\t\t\tUpdateHotspots();\n\t\t\tUtilities.FireEvent(this, Refreshed);\n\t\t}\n\n\t\tprivate void UpdateHotspots()\n\t\t{\n\t\t\tHotspotsList.Items.Clear();\n\t\t\tusing(var session = m_connection.DataEngine.OpenSession(m_snapshot.Id))\n\t\t\tusing(var tx = session.BeginTransaction())\n\t\t\t{\n\t\t\t\t//find the total time consumed\n\t\t\t\tvar totalQuery = session.CreateQuery(\"select sum(call.Time) from Call call where call.ChildId = 0\");\n\t\t\t\tvar totalTimeFuture = totalQuery.FutureValue();\n\n\t\t\t\t//find the functions that consumed the most time-exclusive. These are hotspots.\n\t\t\t\tvar query = session.CreateQuery(\"from Call c inner join fetch c.Parent where c.ChildId = 0 order by c.Time desc\");\n\t\t\t\tquery.SetMaxResults(20);\n\t\t\t\tvar hotspots = query.Future();\n\n\t\t\t\tvar totalTime = totalTimeFuture.Value;\n\t\t\t\t(HotspotsList.Tag as ListTag).TotalTime = totalTime;\n\t\t\t\tforeach(var call in hotspots)\n\t\t\t\t{\n\t\t\t\t\tif(call.Time / totalTime < 0.01f)\n\t\t\t\t\t{\n\t\t\t\t\t\t//less than 1% is not a hotspot, and since we're ordered by Time we can exit\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tHotspotsList.Items.Add(call);\n\t\t\t\t}\n\n\t\t\t\ttx.Commit();\n\t\t\t}\n\t\t}\n\n\t\tprivate bool UpdateParents(Call child, ListBox box)\n\t\t{\n\t\t\tusing(var session = m_connection.DataEngine.OpenSession(m_snapshot.Id))\n\t\t\tusing(var tx = session.BeginTransaction())\n\t\t\t{\n\t\t\t\tvar query = session.CreateQuery(\"from Call c inner join fetch c.Parent where c.ChildId = :funcId order by c.Time desc\")\n\t\t\t\t\t.SetInt32(\"funcId\", child.Parent.Id);\n\t\t\t\tvar parents = query.List();\n\t\t\t\tdouble totalTime = 0;\n\t\t\t\tforeach(var call in parents)\n\t\t\t\t{\n\t\t\t\t\tif(call.ParentId == 0)\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\ttotalTime += call.Time;\n\t\t\t\t\tbox.Items.Add(call);\n\t\t\t\t}\n\t\t\t\t(box.Tag as ListTag).TotalTime = totalTime;\n\n\t\t\t\ttx.Commit();\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\tprivate void RefreshTimer_Tick(object sender, EventArgs e)\n\t\t{\n\t\t\t//UpdateHotspots();\n\t\t}\n\n\t\tprivate void RemoveList(ListBox list)\n\t\t{\n\t\t\tif(list == null)\n\t\t\t\treturn;\n\n\t\t\tRemoveList((list.Tag as ListTag).Right);\n\t\t\tScrollPanel.Controls.Remove(list);\n\t\t}\n\n\t\tprivate void CallList_SelectedIndexChanged(object sender, EventArgs e)\n\t\t{\n\t\t\tListBox list = sender as ListBox;\n\t\t\tRemoveList((list.Tag as ListTag).Right);\n\n\t\t\t//create a new listbox to the right\n\t\t\tListBox lb = new ListBox();\n\t\t\tlb.Size = list.Size;\n\t\t\tlb.Location = new Point(list.Right + 4, 4);\n\t\t\tlb.IntegralHeight = false;\n\t\t\tlb.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;\n\t\t\tlb.FormattingEnabled = true;\n\t\t\tlb.DrawMode = DrawMode.OwnerDrawFixed;\n\t\t\tlb.ItemHeight = HotspotsList.ItemHeight;\n\t\t\tlb.Tag = new ListTag();\n\t\t\tlb.Format += new ListControlConvertEventHandler(CallList_Format);\n\t\t\tlb.SelectedIndexChanged += new EventHandler(CallList_SelectedIndexChanged);\n\t\t\tlb.DrawItem += new DrawItemEventHandler(CallList_DrawItem);\n\n\t\t\tif(UpdateParents(list.SelectedItem as Call, lb))\n\t\t\t{\n\t\t\t\tScrollPanel.Controls.Add(lb);\n\t\t\t\tScrollPanel.ScrollControlIntoView(lb);\n\t\t\t\t(list.Tag as ListTag).Right = lb;\n\t\t\t}\n\t\t}\n\n\t\tprivate void CallList_Format(object sender, ListControlConvertEventArgs e)\n\t\t{\n\t\t\tCall call = e.ListItem as Call;\n\t\t\te.Value = call.Parent.Name;\n\t\t}\n\n\t\tprivate void CallList_DrawItem(object sender, DrawItemEventArgs e)\n\t\t{\n\t\t\tListBox list = sender as ListBox;\n\t\t\tCall item = list.Items[e.Index] as Call;\n\n\t\t\tint splitIndex = item.Parent.Name.LastIndexOf('.');\n\t\t\tstring functionName = item.Parent.Name.Substring(splitIndex + 1);\n\t\t\tstring objectName = \"- \" + item.Parent.Name.Substring(0, splitIndex);\n\t\t\tdouble percent = 100 * item.Time / (list.Tag as ListTag).TotalTime;\n\t\t\tstring functionString = string.Format(\"{0:0.##}%: {1}\", percent, functionName);\n\n\t\t\tBrush brush = Brushes.Black;\n\t\t\tif((e.State & DrawItemState.Selected) == DrawItemState.Selected)\n\t\t\t\tbrush = Brushes.White;\n\n\t\t\te.DrawBackground();\n\t\t\te.Graphics.DrawString(functionString, m_functionFont, brush, new PointF(e.Bounds.X, e.Bounds.Y));\n\t\t\te.Graphics.DrawString(objectName, m_objectFont, brush, new PointF(e.Bounds.X + 4, e.Bounds.Y + 18));\n\t\t\te.DrawFocusRectangle();\n\t\t}\n\t}\n}\n"},"repo_name":{"kind":"string","value":"mohdmasd/slimtune"},"path":{"kind":"string","value":"CoreVis/HotSpots.cs"},"language":{"kind":"string","value":"C#"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":5633,"string":"5,633"}}},{"rowIdx":61538442,"cells":{"code":{"kind":"string","value":"\n */\nclass UserReloaderSpec extends ObjectBehavior\n{\n function let(ObjectManager $objectManager)\n {\n $this->beConstructedWith($objectManager);\n }\n\n function it_is_initializable()\n {\n $this->shouldHaveType('Sylius\\Bundle\\UserBundle\\Reloader\\UserReloader');\n }\n\n function it_implements_user_reloader_interface()\n {\n $this->shouldImplement('Sylius\\Bundle\\UserBundle\\Reloader\\UserReloaderInterface');\n }\n\n function it_reloads_user($objectManager, UserInterface $user)\n {\n $objectManager->refresh($user)->shouldBeCalled();\n\n $this->reloadUser($user);\n }\n}\n"},"repo_name":{"kind":"string","value":"wwojcik/Sylius"},"path":{"kind":"string","value":"src/Sylius/Bundle/UserBundle/spec/Reloader/UserReloaderSpec.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":1079,"string":"1,079"}}},{"rowIdx":61538443,"cells":{"code":{"kind":"string","value":"/*\n* Power BI Visualizations\n*\n* Copyright (c) Microsoft Corporation\n* All rights reserved. \n* MIT License\n*\n* Permission is hereby granted, free of charge, to any person obtaining a copy\n* of this software and associated documentation files (the \"\"Software\"\"), to deal\n* in the Software without restriction, including without limitation the rights\n* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n* copies of the Software, and to permit persons to whom the Software is\n* furnished to do so, subject to the following conditions:\n* \n* The above copyright notice and this permission notice shall be included in \n* all copies or substantial portions of the Software.\n* \n* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \n* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \n* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE \n* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \n* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n* THE SOFTWARE.\n*/\n\n/// \n\nmodule powerbi.visuals.sampleDataViews {\n import DataViewTransform = powerbi.data.DataViewTransform;\n\n export class SalesByCountryData extends SampleDataViews implements ISampleDataViewsMethods {\n\n public name: string = \"SalesByCountryData\";\n public displayName: string = \"Sales By Country\";\n\n public visuals: string[] = ['default'];\n\n private sampleData = [\n [742731.43, 162066.43, 283085.78, 300263.49, 376074.57, 814724.34],\n [123455.43, 40566.43, 200457.78, 5000.49, 320000.57, 450000.34]\n ];\n \n private sampleMin: number = 30000;\n private sampleMax: number = 1000000;\n\n private sampleSingleData: number = 55943.67;\n\n public getDataViews(): DataView[] {\n\n var fieldExpr = powerbi.data.SQExprBuilder.fieldDef({ schema: 's', entity: \"table1\", column: \"country\" });\n\n var categoryValues = [\"Australia\", \"Canada\", \"France\", \"Germany\", \"United Kingdom\", \"United States\"];\n var categoryIdentities = categoryValues.map(function (value) {\n var expr = powerbi.data.SQExprBuilder.equal(fieldExpr, powerbi.data.SQExprBuilder.text(value));\n return powerbi.data.createDataViewScopeIdentity(expr);\n });\n \n // Metadata, describes the data columns, and provides the visual with hints\n // so it can decide how to best represent the data\n var dataViewMetadata: powerbi.DataViewMetadata = {\n columns: [\n {\n displayName: 'Country',\n queryName: 'Country',\n type: powerbi.ValueType.fromDescriptor({ text: true })\n },\n {\n displayName: 'Sales Amount (2014)',\n isMeasure: true,\n format: \"$0,000.00\",\n queryName: 'sales1',\n type: powerbi.ValueType.fromDescriptor({ numeric: true }),\n objects: { dataPoint: { fill: { solid: { color: 'purple' } } } },\n },\n {\n displayName: 'Sales Amount (2015)',\n isMeasure: true,\n format: \"$0,000.00\",\n queryName: 'sales2',\n type: powerbi.ValueType.fromDescriptor({ numeric: true })\n }\n ]\n };\n\n var columns = [\n {\n source: dataViewMetadata.columns[1],\n // Sales Amount for 2014\n values: this.sampleData[0],\n },\n {\n source: dataViewMetadata.columns[2],\n // Sales Amount for 2015\n values: this.sampleData[1],\n }\n ];\n\n var dataValues: DataViewValueColumns = DataViewTransform.createValueColumns(columns);\n var tableDataValues = categoryValues.map(function (countryName, idx) {\n return [countryName, columns[0].values[idx], columns[1].values[idx]];\n });\n\n return [{\n metadata: dataViewMetadata,\n categorical: {\n categories: [{\n source: dataViewMetadata.columns[0],\n values: categoryValues,\n identity: categoryIdentities,\n }],\n values: dataValues\n },\n table: {\n rows: tableDataValues,\n columns: dataViewMetadata.columns,\n },\n single: { value: this.sampleSingleData }\n }];\n }\n\n \n public randomize(): void {\n\n this.sampleData = this.sampleData.map((item) => {\n return item.map(() => this.getRandomValue(this.sampleMin, this.sampleMax));\n });\n\n this.sampleSingleData = this.getRandomValue(this.sampleMin, this.sampleMax);\n }\n \n }\n}"},"repo_name":{"kind":"string","value":"yduit/PowerBI-visuals"},"path":{"kind":"string","value":"src/Clients/PowerBIVisualsPlayground/sampleDataViews/SalesByCountryData.ts"},"language":{"kind":"string","value":"TypeScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":5374,"string":"5,374"}}},{"rowIdx":61538444,"cells":{"code":{"kind":"string","value":"def('prepare_content', 1))\n{\n\tJPluginHelper::importPlugin('content');\n\t$module->content = JHtml::_('content.prepare', $module->content, '', 'mod_custom.content');\n}\n\n$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');\n\nrequire JModuleHelper::getLayoutPath('mod_custom', $params->get('layout', 'default'));\n"},"repo_name":{"kind":"string","value":"810/joomla-cms"},"path":{"kind":"string","value":"modules/mod_custom/mod_custom.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":626,"string":"626"}}},{"rowIdx":61538445,"cells":{"code":{"kind":"string","value":"// license:BSD-3-Clause\n// copyright-holders:Ryan Holtz\n//============================================================\n//\n// clearreader.cpp - BGFX clear state JSON reader\n//\n//============================================================\n\n#include \n\n#include \"clearreader.h\"\n\n#include \"clear.h\"\n\nclear_state* clear_reader::read_from_value(const Value& value, std::string prefix)\n{\n\tif (!validate_parameters(value, prefix))\n\t{\n\t\treturn nullptr;\n\t}\n\n\tuint64_t clear_flags = 0;\n\tuint32_t clear_color = 0;\n\tfloat clear_depth = 1.0f;\n\tuint8_t clear_stencil = 0;\n\n\tif (value.HasMember(\"clearcolor\"))\n\t{\n\t\tconst Value& colors = value[\"clearcolor\"];\n\t\tfor (int i = 0; i < colors.Size(); i++)\n\t\t{\n\t\t\tif (!READER_CHECK(colors[i].IsNumber(), (prefix + \"clearcolor[\" + std::to_string(i) + \"] must be a numeric value\\n\").c_str())) return nullptr;\n\t\t\tauto val = int32_t(float(colors[i].GetDouble()) * 255.0f);\n\t\t\tif (val > 255) val = 255;\n\t\t\tif (val < 0) val = 0;\n\t\t\tclear_color |= val << (24 - (i * 3));\n\t\t}\n\t\tclear_flags |= BGFX_CLEAR_COLOR;\n\t}\n\n\tif (value.HasMember(\"cleardepth\"))\n\t{\n\t\tget_float(value, \"cleardepth\", &clear_depth, &clear_depth);\n\t\tclear_flags |= BGFX_CLEAR_DEPTH;\n\t}\n\n\tif (value.HasMember(\"clearstencil\"))\n\t{\n\t\tclear_stencil = uint8_t(get_int(value, \"clearstencil\", clear_stencil));\n\t\tclear_flags |= BGFX_CLEAR_STENCIL;\n\t}\n\n\treturn new clear_state(clear_flags, clear_color, clear_depth, clear_stencil);\n}\n\nbool clear_reader::validate_parameters(const Value& value, std::string prefix)\n{\n\tif (!READER_CHECK(!value.HasMember(\"clearcolor\") || (value[\"clearcolor\"].IsArray() && value[\"clearcolor\"].GetArray().Size() == 4), (prefix + \"'clearcolor' must be an array of four numeric RGBA values representing the color to which to clear the color buffer\\n\").c_str())) return false;\n\tif (!READER_CHECK(!value.HasMember(\"cleardepth\") || value[\"cleardepth\"].IsNumber(), (prefix + \"'cleardepth' must be a numeric value representing the depth to which to clear the depth buffer\\n\").c_str())) return false;\n\tif (!READER_CHECK(!value.HasMember(\"clearstencil\") || value[\"clearstencil\"].IsNumber(), (prefix + \"'clearstencil' must be a numeric value representing the stencil value to which to clear the stencil buffer\\n\").c_str())) return false;\n\treturn true;\n}\n"},"repo_name":{"kind":"string","value":"johnparker007/mame"},"path":{"kind":"string","value":"src/osd/modules/render/bgfx/clearreader.cpp"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":2264,"string":"2,264"}}},{"rowIdx":61538446,"cells":{"code":{"kind":"string","value":"/*\nCopyright 2017 The Kubernetes Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n// This file was automatically generated by informer-gen\n\npackage v1alpha1\n\nimport (\n\tinternalinterfaces \"k8s.io/sample-apiserver/pkg/client/informers/externalversions/internalinterfaces\"\n)\n\n// Interface provides access to all the informers in this group version.\ntype Interface interface {\n\t// Fischers returns a FischerInformer.\n\tFischers() FischerInformer\n\t// Flunders returns a FlunderInformer.\n\tFlunders() FlunderInformer\n}\n\ntype version struct {\n\tinternalinterfaces.SharedInformerFactory\n}\n\n// New returns a new Interface.\nfunc New(f internalinterfaces.SharedInformerFactory) Interface {\n\treturn &version{f}\n}\n\n// Fischers returns a FischerInformer.\nfunc (v *version) Fischers() FischerInformer {\n\treturn &fischerInformer{factory: v.SharedInformerFactory}\n}\n\n// Flunders returns a FlunderInformer.\nfunc (v *version) Flunders() FlunderInformer {\n\treturn &flunderInformer{factory: v.SharedInformerFactory}\n}\n"},"repo_name":{"kind":"string","value":"shakamunyi/kubernetes"},"path":{"kind":"string","value":"vendor/k8s.io/sample-apiserver/pkg/client/informers/externalversions/wardle/v1alpha1/interface.go"},"language":{"kind":"string","value":"GO"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":1483,"string":"1,483"}}},{"rowIdx":61538447,"cells":{"code":{"kind":"string","value":"/*\n * Copyright 2012-2019 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage org.springframework.boot.test.autoconfigure.web.servlet;\n\nimport java.lang.annotation.Documented;\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Inherited;\nimport java.lang.annotation.Retention;\nimport java.lang.annotation.RetentionPolicy;\nimport java.lang.annotation.Target;\n\nimport com.gargoylesoftware.htmlunit.WebClient;\nimport org.openqa.selenium.WebDriver;\n\nimport org.springframework.boot.autoconfigure.ImportAutoConfiguration;\nimport org.springframework.boot.test.autoconfigure.properties.PropertyMapping;\nimport org.springframework.boot.test.autoconfigure.properties.SkipPropertyMapping;\nimport org.springframework.test.web.servlet.MockMvc;\nimport org.springframework.test.web.servlet.MvcResult;\n\n/**\n * Annotation that can be applied to a test class to enable and configure\n * auto-configuration of {@link MockMvc}.\n *\n * @author Phillip Webb\n * @since 1.4.0\n * @see MockMvcAutoConfiguration\n * @see SpringBootMockMvcBuilderCustomizer\n */\n@Target({ ElementType.TYPE, ElementType.METHOD })\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\n@Inherited\n@ImportAutoConfiguration\n@PropertyMapping(\"spring.test.mockmvc\")\npublic @interface AutoConfigureMockMvc {\n\n\t/**\n\t * If filters from the application context should be registered with MockMVC. Defaults\n\t * to {@code true}.\n\t * @return if filters should be added\n\t */\n\tboolean addFilters() default true;\n\n\t/**\n\t * How {@link MvcResult} information should be printed after each MockMVC invocation.\n\t * @return how information is printed\n\t */\n\t@PropertyMapping(skip = SkipPropertyMapping.ON_DEFAULT_VALUE)\n\tMockMvcPrint print() default MockMvcPrint.DEFAULT;\n\n\t/**\n\t * If {@link MvcResult} information should be printed only if the test fails.\n\t * @return {@code true} if printing only occurs on failure\n\t */\n\tboolean printOnlyOnFailure() default true;\n\n\t/**\n\t * If a {@link WebClient} should be auto-configured when HtmlUnit is on the classpath.\n\t * Defaults to {@code true}.\n\t * @return if a {@link WebClient} is auto-configured\n\t */\n\t@PropertyMapping(\"webclient.enabled\")\n\tboolean webClientEnabled() default true;\n\n\t/**\n\t * If a {@link WebDriver} should be auto-configured when Selenium is on the classpath.\n\t * Defaults to {@code true}.\n\t * @return if a {@link WebDriver} is auto-configured\n\t */\n\t@PropertyMapping(\"webdriver.enabled\")\n\tboolean webDriverEnabled() default true;\n\n}\n"},"repo_name":{"kind":"string","value":"tiarebalbi/spring-boot"},"path":{"kind":"string","value":"spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/AutoConfigureMockMvc.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":2989,"string":"2,989"}}},{"rowIdx":61538448,"cells":{"code":{"kind":"string","value":"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n# Copyright: (c) 2017, Ansible Project\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n__metaclass__ = type\n\nANSIBLE_METADATA = {'metadata_version': '1.1',\n 'status': ['stableinterface'],\n 'supported_by': 'core'}\n\n\nDOCUMENTATION = '''\n---\nmodule: acl\nversion_added: \"1.4\"\nshort_description: Sets and retrieves file ACL information.\ndescription:\n - Sets and retrieves file ACL information.\noptions:\n path:\n required: true\n default: null\n description:\n - The full path of the file or object.\n aliases: ['name']\n\n state:\n required: false\n default: query\n choices: [ 'query', 'present', 'absent' ]\n description:\n - defines whether the ACL should be present or not. The C(query) state gets the current acl without changing it, for use in 'register' operations.\n\n follow:\n required: false\n default: yes\n choices: [ 'yes', 'no' ]\n description:\n - whether to follow symlinks on the path if a symlink is encountered.\n\n default:\n version_added: \"1.5\"\n required: false\n default: no\n choices: [ 'yes', 'no' ]\n description:\n - if the target is a directory, setting this to yes will make it the default acl for entities created inside the directory. It causes an error if\n path is a file.\n\n entity:\n version_added: \"1.5\"\n required: false\n description:\n - actual user or group that the ACL applies to when matching entity types user or group are selected.\n\n etype:\n version_added: \"1.5\"\n required: false\n default: null\n choices: [ 'user', 'group', 'mask', 'other' ]\n description:\n - the entity type of the ACL to apply, see setfacl documentation for more info.\n\n permissions:\n version_added: \"1.5\"\n required: false\n default: null\n description:\n - Permissions to apply/remove can be any combination of r, w and x (read, write and execute respectively)\n\n entry:\n required: false\n default: null\n description:\n - DEPRECATED. The acl to set or remove. This must always be quoted in the form of '::'. The qualifier may be empty for\n some types, but the type and perms are always required. '-' can be used as placeholder when you do not care about permissions. This is now\n superseded by entity, type and permissions fields.\n\n recursive:\n version_added: \"2.0\"\n required: false\n default: no\n choices: [ 'yes', 'no' ]\n description:\n - Recursively sets the specified ACL (added in Ansible 2.0). Incompatible with C(state=query).\nauthor:\n - \"Brian Coca (@bcoca)\"\n - \"Jérémie Astori (@astorije)\"\nnotes:\n - The \"acl\" module requires that acls are enabled on the target filesystem and that the setfacl and getfacl binaries are installed.\n - As of Ansible 2.0, this module only supports Linux distributions.\n - As of Ansible 2.3, the I(name) option has been changed to I(path) as default, but I(name) still works as well.\n'''\n\nEXAMPLES = '''\n# Grant user Joe read access to a file\n- acl:\n path: /etc/foo.conf\n entity: joe\n etype: user\n permissions: r\n state: present\n\n# Removes the acl for Joe on a specific file\n- acl:\n path: /etc/foo.conf\n entity: joe\n etype: user\n state: absent\n\n# Sets default acl for joe on foo.d\n- acl:\n path: /etc/foo.d\n entity: joe\n etype: user\n permissions: rw\n default: yes\n state: present\n\n# Same as previous but using entry shorthand\n- acl:\n path: /etc/foo.d\n entry: \"default:user:joe:rw-\"\n state: present\n\n# Obtain the acl for a specific file\n- acl:\n path: /etc/foo.conf\n register: acl_info\n'''\n\nRETURN = '''\nacl:\n description: Current acl on provided path (after changes, if any)\n returned: success\n type: list\n sample: [ \"user::rwx\", \"group::rwx\", \"other::rwx\" ]\n'''\n\nimport os\nfrom ansible.module_utils.basic import AnsibleModule, get_platform\nfrom ansible.module_utils.pycompat24 import get_exception\n\n\ndef split_entry(entry):\n ''' splits entry and ensures normalized return'''\n\n a = entry.split(':')\n\n d = None\n if entry.lower().startswith(\"d\"):\n d = True\n a.pop(0)\n\n if len(a) == 2:\n a.append(None)\n\n t, e, p = a\n t = t.lower()\n\n if t.startswith(\"u\"):\n t = \"user\"\n elif t.startswith(\"g\"):\n t = \"group\"\n elif t.startswith(\"m\"):\n t = \"mask\"\n elif t.startswith(\"o\"):\n t = \"other\"\n else:\n t = None\n\n return [d, t, e, p]\n\n\ndef build_entry(etype, entity, permissions=None, use_nfsv4_acls=False):\n '''Builds and returns an entry string. Does not include the permissions bit if they are not provided.'''\n if use_nfsv4_acls:\n return ':'.join([etype, entity, permissions, 'allow'])\n if permissions:\n return etype + ':' + entity + ':' + permissions\n else:\n return etype + ':' + entity\n\n\ndef build_command(module, mode, path, follow, default, recursive, entry=''):\n '''Builds and returns a getfacl/setfacl command.'''\n if mode == 'set':\n cmd = [module.get_bin_path('setfacl', True)]\n cmd.append('-m \"%s\"' % entry)\n elif mode == 'rm':\n cmd = [module.get_bin_path('setfacl', True)]\n cmd.append('-x \"%s\"' % entry)\n else: # mode == 'get'\n cmd = [module.get_bin_path('getfacl', True)]\n # prevents absolute path warnings and removes headers\n if get_platform().lower() == 'linux':\n cmd.append('--omit-header')\n cmd.append('--absolute-names')\n\n if recursive:\n cmd.append('--recursive')\n\n if not follow:\n if get_platform().lower() == 'linux':\n cmd.append('--physical')\n elif get_platform().lower() == 'freebsd':\n cmd.append('-h')\n\n if default:\n if mode == 'rm':\n cmd.insert(1, '-k')\n else: # mode == 'set' or mode == 'get'\n cmd.insert(1, '-d')\n\n cmd.append(path)\n return cmd\n\n\ndef acl_changed(module, cmd):\n '''Returns true if the provided command affects the existing ACLs, false otherwise.'''\n # FreeBSD do not have a --test flag, so by default, it is safer to always say \"true\"\n if get_platform().lower() == 'freebsd':\n return True\n\n cmd = cmd[:] # lists are mutables so cmd would be overwritten without this\n cmd.insert(1, '--test')\n lines = run_acl(module, cmd)\n\n for line in lines:\n if not line.endswith('*,*'):\n return True\n return False\n\n\ndef run_acl(module, cmd, check_rc=True):\n\n try:\n (rc, out, err) = module.run_command(' '.join(cmd), check_rc=check_rc)\n except Exception:\n e = get_exception()\n module.fail_json(msg=e.strerror)\n\n lines = []\n for l in out.splitlines():\n if not l.startswith('#'):\n lines.append(l.strip())\n\n if lines and not lines[-1].split():\n # trim last line only when it is empty\n return lines[:-1]\n else:\n return lines\n\n\ndef main():\n module = AnsibleModule(\n argument_spec=dict(\n path=dict(required=True, aliases=['name'], type='path'),\n entry=dict(required=False, type='str'),\n entity=dict(required=False, type='str', default=''),\n etype=dict(\n required=False,\n choices=['other', 'user', 'group', 'mask'],\n type='str'\n ),\n permissions=dict(required=False, type='str'),\n state=dict(\n required=False,\n default='query',\n choices=['query', 'present', 'absent'],\n type='str'\n ),\n follow=dict(required=False, type='bool', default=True),\n default=dict(required=False, type='bool', default=False),\n recursive=dict(required=False, type='bool', default=False),\n use_nfsv4_acls=dict(required=False, type='bool', default=False)\n ),\n supports_check_mode=True,\n )\n\n if get_platform().lower() not in ['linux', 'freebsd']:\n module.fail_json(msg=\"The acl module is not available on this system.\")\n\n path = module.params.get('path')\n entry = module.params.get('entry')\n entity = module.params.get('entity')\n etype = module.params.get('etype')\n permissions = module.params.get('permissions')\n state = module.params.get('state')\n follow = module.params.get('follow')\n default = module.params.get('default')\n recursive = module.params.get('recursive')\n use_nfsv4_acls = module.params.get('use_nfsv4_acls')\n\n if not os.path.exists(path):\n module.fail_json(msg=\"Path not found or not accessible.\")\n\n if state == 'query' and recursive:\n module.fail_json(msg=\"'recursive' MUST NOT be set when 'state=query'.\")\n\n if not entry:\n if state == 'absent' and permissions:\n module.fail_json(msg=\"'permissions' MUST NOT be set when 'state=absent'.\")\n\n if state == 'absent' and not entity:\n module.fail_json(msg=\"'entity' MUST be set when 'state=absent'.\")\n\n if state in ['present', 'absent'] and not etype:\n module.fail_json(msg=\"'etype' MUST be set when 'state=%s'.\" % state)\n\n if entry:\n if etype or entity or permissions:\n module.fail_json(msg=\"'entry' MUST NOT be set when 'entity', 'etype' or 'permissions' are set.\")\n\n if state == 'present' and not entry.count(\":\") in [2, 3]:\n module.fail_json(msg=\"'entry' MUST have 3 or 4 sections divided by ':' when 'state=present'.\")\n\n if state == 'absent' and not entry.count(\":\") in [1, 2]:\n module.fail_json(msg=\"'entry' MUST have 2 or 3 sections divided by ':' when 'state=absent'.\")\n\n if state == 'query':\n module.fail_json(msg=\"'entry' MUST NOT be set when 'state=query'.\")\n\n default_flag, etype, entity, permissions = split_entry(entry)\n if default_flag is not None:\n default = default_flag\n\n if get_platform().lower() == 'freebsd':\n if recursive:\n module.fail_json(msg=\"recursive is not supported on that platform.\")\n\n changed = False\n msg = \"\"\n\n if state == 'present':\n entry = build_entry(etype, entity, permissions, use_nfsv4_acls)\n command = build_command(\n module, 'set', path, follow,\n default, recursive, entry\n )\n changed = acl_changed(module, command)\n\n if changed and not module.check_mode:\n run_acl(module, command)\n msg = \"%s is present\" % entry\n\n elif state == 'absent':\n entry = build_entry(etype, entity, use_nfsv4_acls)\n command = build_command(\n module, 'rm', path, follow,\n default, recursive, entry\n )\n changed = acl_changed(module, command)\n\n if changed and not module.check_mode:\n run_acl(module, command, False)\n msg = \"%s is absent\" % entry\n\n elif state == 'query':\n msg = \"current acl\"\n\n acl = run_acl(\n module,\n build_command(module, 'get', path, follow, default, recursive)\n )\n\n module.exit_json(changed=changed, msg=msg, acl=acl)\n\nif __name__ == '__main__':\n main()\n"},"repo_name":{"kind":"string","value":"e-gob/plataforma-kioscos-autoatencion"},"path":{"kind":"string","value":"scripts/ansible-play/.venv/lib/python2.7/site-packages/ansible/modules/files/acl.py"},"language":{"kind":"string","value":"Python"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":11261,"string":"11,261"}}},{"rowIdx":61538449,"cells":{"code":{"kind":"string","value":"\n* @license GNU General Public License, version 2 (GPL-2.0)\n*\n* For full copyright and license information, please see\n* the docs/CREDITS.txt file.\n*\n*/\n\nnamespace phpbb\\template;\n\ninterface template\n{\n\n\t/**\n\t* Clear the cache\n\t*\n\t* @return \\phpbb\\template\\template\n\t*/\n\tpublic function clear_cache();\n\n\t/**\n\t* Sets the template filenames for handles.\n\t*\n\t* @param array $filename_array Should be a hash of handle => filename pairs.\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function set_filenames(array $filename_array);\n\n\t/**\n\t* Get the style tree of the style preferred by the current user\n\t*\n\t* @return array Style tree, most specific first\n\t*/\n\tpublic function get_user_style();\n\n\t/**\n\t* Set style location based on (current) user's chosen style.\n\t*\n\t* @param array $style_directories The directories to add style paths for\n\t* \tE.g. array('ext/foo/bar/styles', 'styles')\n\t* \tDefault: array('styles') (phpBB's style directory)\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function set_style($style_directories = array('styles'));\n\n\t/**\n\t* Set custom style location (able to use directory outside of phpBB).\n\t*\n\t* Note: Templates are still compiled to phpBB's cache directory.\n\t*\n\t* @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions.\n\t* @param string|array or string $paths Array of style paths, relative to current root directory\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function set_custom_style($names, $paths);\n\n\t/**\n\t* Clears all variables and blocks assigned to this template.\n\t*\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function destroy();\n\n\t/**\n\t* Reset/empty complete block\n\t*\n\t* @param string $blockname Name of block to destroy\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function destroy_block_vars($blockname);\n\n\t/**\n\t* Display a template for provided handle.\n\t*\n\t* The template will be loaded and compiled, if necessary, first.\n\t*\n\t* This function calls hooks.\n\t*\n\t* @param string $handle Handle to display\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function display($handle);\n\n\t/**\n\t* Display the handle and assign the output to a template variable\n\t* or return the compiled result.\n\t*\n\t* @param string $handle Handle to operate on\n\t* @param string $template_var Template variable to assign compiled handle to\n\t* @param bool $return_content If true return compiled handle, otherwise assign to $template_var\n\t* @return \\phpbb\\template\\template|string if $return_content is true return string of the compiled handle, otherwise return $this\n\t*/\n\tpublic function assign_display($handle, $template_var = '', $return_content = true);\n\n\t/**\n\t* Assign key variable pairs from an array\n\t*\n\t* @param array $vararray A hash of variable name => value pairs\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function assign_vars(array $vararray);\n\n\t/**\n\t* Assign a single scalar value to a single key.\n\t*\n\t* Value can be a string, an integer or a boolean.\n\t*\n\t* @param string $varname Variable name\n\t* @param string $varval Value to assign to variable\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function assign_var($varname, $varval);\n\n\t/**\n\t* Append text to the string value stored in a key.\n\t*\n\t* Text is appended using the string concatenation operator (.).\n\t*\n\t* @param string $varname Variable name\n\t* @param string $varval Value to append to variable\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function append_var($varname, $varval);\n\n\t/**\n\t* Assign key variable pairs from an array to a specified block\n\t* @param string $blockname Name of block to assign $vararray to\n\t* @param array $vararray A hash of variable name => value pairs\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function assign_block_vars($blockname, array $vararray);\n\n\t/**\n\t* Assign key variable pairs from an array to a whole specified block loop\n\t* @param string $blockname Name of block to assign $block_vars_array to\n\t* @param array $block_vars_array An array of hashes of variable name => value pairs\n\t* @return \\phpbb\\template\\template $this\n\t*/\n\tpublic function assign_block_vars_array($blockname, array $block_vars_array);\n\n\t/**\n\t* Change already assigned key variable pair (one-dimensional - single loop entry)\n\t*\n\t* An example of how to use this function:\n\t* {@example alter_block_array.php}\n\t*\n\t* @param\tstring\t$blockname\tthe blockname, for example 'loop'\n\t* @param\tarray\t$vararray\tthe var array to insert/add or merge\n\t* @param\tmixed\t$key\t\tKey to search for\n\t*\n\t* array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]\n\t*\n\t* int: Position [the position to change or insert at directly given]\n\t*\n\t* If key is false the position is set to 0\n\t* If key is true the position is set to the last entry\n\t*\n\t* @param\tstring\t$mode\t\tMode to execute (valid modes are 'insert' and 'change')\n\t*\n\t*\tIf insert, the vararray is inserted at the given position (position counting from zero).\n\t*\tIf change, the current block gets merged with the vararray (resulting in new \\key/value pairs be added and existing keys be replaced by the new \\value).\n\t*\n\t* Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)\n\t* and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)\n\t*\n\t* @return bool false on error, true on success\n\t*/\n\tpublic function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert');\n\n\t/**\n\t* Get path to template for handle (required for BBCode parser)\n\t*\n\t* @param string $handle Handle to retrieve the source file\n\t* @return string\n\t*/\n\tpublic function get_source_file_for_handle($handle);\n}\n"},"repo_name":{"kind":"string","value":"kivi8/ars-poetica"},"path":{"kind":"string","value":"www/forum/phpbb/template/template.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":5881,"string":"5,881"}}},{"rowIdx":61538450,"cells":{"code":{"kind":"string","value":"//##################################################################################################################\n// #TOOLBAR#\n/* global CMS */\n\n(function ($) {\n 'use strict';\n // CMS.$ will be passed for $\n $(document).ready(function () {\n /*!\n * Toolbar\n * Handles all features related to the toolbar\n */\n CMS.Toolbar = new CMS.Class({\n\n implement: [CMS.API.Helpers],\n\n options: {\n preventSwitch: false,\n preventSwitchMessage: 'Switching is disabled.',\n messageDelay: 2000\n },\n\n initialize: function (options) {\n this.container = $('#cms-toolbar');\n this.options = $.extend(true, {}, this.options, options);\n this.config = CMS.config;\n this.settings = CMS.settings;\n\n // elements\n this.body = $('html');\n this.toolbar = this.container.find('.cms-toolbar').hide();\n this.toolbarTrigger = this.container.find('.cms-toolbar-trigger');\n this.navigations = this.container.find('.cms-toolbar-item-navigation');\n this.buttons = this.container.find('.cms-toolbar-item-buttons');\n this.switcher = this.container.find('.cms-toolbar-item-switch');\n this.messages = this.container.find('.cms-messages');\n this.screenBlock = this.container.find('.cms-screenblock');\n\n // states\n this.click = 'click.cms';\n this.timer = function () {};\n this.lockToolbar = false;\n\n // setup initial stuff\n this._setup();\n\n // setup events\n this._events();\n },\n\n // initial methods\n _setup: function () {\n // setup toolbar visibility, we need to reverse the options to set the correct state\n (this.settings.toolbar === 'expanded') ? this._showToolbar(0, true) : this._hideToolbar(0, true);\n\n // hide publish button\n var publishBtn = $('.cms-btn-publish').parent();\n publishBtn.hide();\n\n if ($('.cms-btn-publish-active').length) {\n publishBtn.show();\n }\n\n // check if debug is true\n if (CMS.config.debug) {\n this._debug();\n }\n\n // check if there are messages and display them\n if (CMS.config.messages) {\n this.openMessage(CMS.config.messages);\n }\n\n // check if there are error messages and display them\n if (CMS.config.error) {\n this.showError(CMS.config.error);\n }\n\n // enforce open state if user is not logged in but requests the toolbar\n if (!CMS.config.auth || CMS.config.settings.version !== this.settings.version) {\n this.toggleToolbar(true);\n this.settings = this.setSettings(CMS.config.settings);\n }\n\n // should switcher indicate that there is an unpublished page?\n if (CMS.config.publisher) {\n this.openMessage(CMS.config.publisher, 'right');\n setInterval(function () {\n CMS.$('.cms-toolbar-item-switch').toggleClass('cms-toolbar-item-switch-highlight');\n }, this.options.messageDelay);\n }\n\n // open sideframe if it was previously opened\n if (this.settings.sideframe.url) {\n var sideframe = new CMS.Sideframe();\n sideframe.open(this.settings.sideframe.url, false);\n }\n\n // if there is a screenblock, do some resize magic\n if (this.screenBlock.length) {\n this._screenBlock();\n }\n\n // add toolbar ready class to body and fire event\n this.body.addClass('cms-ready');\n $(document).trigger('cms-ready');\n },\n\n _events: function () {\n var that = this;\n\n // attach event to the trigger handler\n this.toolbarTrigger.bind(this.click, function (e) {\n e.preventDefault();\n that.toggleToolbar();\n });\n\n // attach event to the navigation elements\n this.navigations.each(function () {\n var item = $(this);\n var lists = item.find('li');\n var root = 'cms-toolbar-item-navigation';\n var hover = 'cms-toolbar-item-navigation-hover';\n var disabled = 'cms-toolbar-item-navigation-disabled';\n var children = 'cms-toolbar-item-navigation-children';\n\n // remove events from first level\n item.find('a').bind(that.click, function (e) {\n e.preventDefault();\n if ($(this).attr('href') !== '' &&\n $(this).attr('href') !== '#' &&\n !$(this).parent().hasClass(disabled) &&\n !$(this).parent().hasClass(disabled)) {\n that._delegate($(this));\n reset();\n return false;\n }\n });\n\n // handle click states\n lists.bind(that.click, function (e) {\n e.stopPropagation();\n var el = $(this);\n\n // close if el is first item\n if (el.parent().hasClass(root) && el.hasClass(hover) || el.hasClass(disabled)) {\n reset();\n return false;\n } else {\n reset();\n el.addClass(hover);\n }\n\n // activate hover selection\n item.find('> li').bind('mouseenter', function () {\n // cancel if item is already active\n if ($(this).hasClass(hover)) {\n return false;\n }\n $(this).trigger(that.click);\n });\n\n // create the document event\n $(document).bind(that.click, reset);\n });\n\n // attach hover\n lists.find('li').bind('mouseenter mouseleave', function () {\n var el = $(this);\n var parent = el.closest('.cms-toolbar-item-navigation-children')\n .add(el.parents('.cms-toolbar-item-navigation-children'));\n var hasChildren = el.hasClass(children) || parent.length;\n\n // do not attach hover effect if disabled\n // cancel event if element has already hover class\n if (el.hasClass(disabled) || el.hasClass(hover)) {\n return false;\n }\n\n // reset\n lists.find('li').removeClass(hover);\n\n // add hover effect\n el.addClass(hover);\n\n // handle children elements\n if (hasChildren) {\n el.find('> ul').show();\n // add parent class\n parent.addClass(hover);\n } else {\n lists.find('ul ul').hide();\n }\n\n // Remove stale submenus\n el.siblings().find('> ul').hide();\n });\n\n // fix leave event\n lists.find('> ul').bind('mouseleave', function () {\n lists.find('li').removeClass(hover);\n });\n\n // removes classes and events\n function reset() {\n lists.removeClass(hover);\n lists.find('ul ul').hide();\n item.find('> li').unbind('mouseenter');\n $(document).unbind(that.click);\n }\n });\n\n // attach event to the switcher elements\n this.switcher.each(function () {\n $(this).bind(that.click, function (e) {\n e.preventDefault();\n that._setSwitcher($(e.currentTarget));\n });\n });\n\n // attach event for first page publish\n this.buttons.each(function () {\n var btn = $(this);\n\n // in case the button has a data-rel attribute\n if (btn.find('a').attr('data-rel')) {\n btn.on('click', function (e) {\n e.preventDefault();\n that._delegate($(this).find('a'));\n });\n }\n\n // in case of the publish button\n btn.find('.cms-publish-page').bind(that.click, function (e) {\n if (!confirm(that.config.lang.publish)) {\n e.preventDefault();\n }\n });\n\n btn.find('.cms-btn-publish').bind(that.click, function (e) {\n e.preventDefault();\n // send post request to prevent xss attacks\n $.ajax({\n 'type': 'post',\n 'url': $(this).prop('href'),\n 'data': {\n 'csrfmiddlewaretoken': CMS.config.csrf\n },\n 'success': function () {\n CMS.API.Helpers.reloadBrowser();\n },\n 'error': function (request) {\n throw new Error(request);\n }\n });\n });\n });\n },\n\n // public methods\n toggleToolbar: function (show) {\n // overwrite state when provided\n if (show) {\n this.settings.toolbar = 'collapsed';\n }\n // toggle bar\n (this.settings.toolbar === 'collapsed') ? this._showToolbar(200) : this._hideToolbar(200);\n },\n\n openMessage: function (msg, dir, delay, error) {\n // set toolbar freeze\n this._lock(true);\n\n // add content to element\n this.messages.find('.cms-messages-inner').html(msg);\n\n // clear timeout\n clearTimeout(this.timer);\n\n // determine width\n var that = this;\n var width = 320;\n var height = this.messages.outerHeight(true);\n var top = this.toolbar.outerHeight(true);\n var close = this.messages.find('.cms-messages-close');\n close.hide();\n close.bind(this.click, function () {\n that.closeMessage();\n });\n\n // set top to 0 if toolbar is collapsed\n if (this.settings.toolbar === 'collapsed') {\n top = 0;\n }\n\n // do we need to add debug styles?\n if (this.config.debug) {\n top = top + 5;\n }\n\n // set correct position and show\n this.messages.css('top', -height).show();\n\n // error handling\n this.messages.removeClass('cms-messages-error');\n if (error) {\n this.messages.addClass('cms-messages-error');\n }\n\n // dir should be left, center, right\n dir = dir || 'center';\n // set correct direction and animation\n switch (dir) {\n case 'left':\n this.messages.css({\n 'top': top,\n 'left': -width,\n 'right': 'auto',\n 'margin-left': 0\n });\n this.messages.animate({ 'left': 0 });\n break;\n case 'right':\n this.messages.css({\n 'top': top,\n 'right': -width,\n 'left': 'auto',\n 'margin-left': 0\n });\n this.messages.animate({ 'right': 0 });\n break;\n default:\n this.messages.css({\n 'left': '50%',\n 'right': 'auto',\n 'margin-left': -(width / 2)\n });\n this.messages.animate({ 'top': top });\n }\n\n // cancel autohide if delay is 0\n if (delay === 0) {\n close.show();\n return false;\n }\n // add delay to hide\n this.timer = setTimeout(function () {\n that.closeMessage();\n }, delay || this.options.messageDelay);\n },\n\n closeMessage: function () {\n this.messages.fadeOut(300);\n // unlock toolbar\n this._lock(false);\n },\n\n openAjax: function (url, post, text, callback, onSuccess) {\n var that = this;\n\n // check if we have a confirmation text\n var question = (text) ? confirm(text) : true;\n // cancel if question has been denied\n if (!question) {\n return false;\n }\n\n // set loader\n this._loader(true);\n\n $.ajax({\n 'type': 'POST',\n 'url': url,\n 'data': (post) ? JSON.parse(post) : {},\n 'success': function (response) {\n CMS.API.locked = false;\n\n if (callback) {\n callback(that, response);\n that._loader(false);\n } else if (onSuccess) {\n CMS.API.Helpers.reloadBrowser(onSuccess, false, true);\n } else {\n // reload\n CMS.API.Helpers.reloadBrowser(false, false, true);\n }\n },\n 'error': function (jqXHR) {\n CMS.API.locked = false;\n that.showError(jqXHR.response + ' | ' + jqXHR.status + ' ' + jqXHR.statusText);\n }\n });\n },\n\n showError: function (msg, reload) {\n this.openMessage(msg, 'center', 0, true);\n // force reload if param is passed\n if (reload) {\n CMS.API.Helpers.reloadBrowser(false, this.options.messageDelay);\n }\n },\n\n // private methods\n _showToolbar: function (speed, init) {\n this.toolbarTrigger.addClass('cms-toolbar-trigger-expanded');\n this.toolbar.slideDown(speed);\n // animate html\n this.body.animate({ 'margin-top': (this.config.debug) ? 35 : 30 }, (init) ? 0 : speed, function () {\n $(this).addClass('cms-toolbar-expanded');\n });\n // set messages top to toolbar height\n this.messages.css('top', 31);\n // set new settings\n this.settings.toolbar = 'expanded';\n if (!init) {\n this.settings = this.setSettings(this.settings);\n }\n },\n\n _hideToolbar: function (speed, init) {\n // cancel if sideframe is active\n if (this.lockToolbar) {\n return false;\n }\n\n this.toolbarTrigger.removeClass('cms-toolbar-trigger-expanded');\n this.toolbar.slideUp(speed);\n // animate html\n this.body.removeClass('cms-toolbar-expanded')\n .animate({ 'margin-top': (this.config.debug) ? 5 : 0 }, speed);\n // set messages top to 0\n this.messages.css('top', 0);\n // set new settings\n this.settings.toolbar = 'collapsed';\n if (!init) {\n this.settings = this.setSettings(this.settings);\n }\n },\n\n _setSwitcher: function (el) {\n // save local vars\n var active = el.hasClass('cms-toolbar-item-switch-active');\n var anchor = el.find('a');\n var knob = el.find('.cms-toolbar-item-switch-knob');\n var duration = 300;\n\n // prevent if switchopstion is passed\n if (this.options.preventSwitch) {\n this.openMessage(this.options.preventSwitchMessage, 'right');\n return false;\n }\n\n // determin what to trigger\n if (active) {\n knob.animate({\n 'right': anchor.outerWidth(true) - (knob.outerWidth(true) + 2)\n }, duration);\n // move anchor behind the knob\n anchor.css('z-index', 1).animate({\n 'padding-top': 6,\n 'padding-right': 14,\n 'padding-bottom': 4,\n 'padding-left': 28\n }, duration);\n } else {\n knob.animate({\n 'left': anchor.outerWidth(true) - (knob.outerWidth(true) + 2)\n }, duration);\n // move anchor behind the knob\n anchor.css('z-index', 1).animate({\n 'padding-top': 6,\n 'padding-right': 28,\n 'padding-bottom': 4,\n 'padding-left': 14\n }, duration);\n }\n\n // reload\n setTimeout(function () {\n window.location.href = anchor.attr('href');\n }, duration);\n },\n\n _delegate: function (el) {\n // save local vars\n var target = el.data('rel');\n\n switch (target) {\n case 'modal':\n var modal = new CMS.Modal({'onClose': el.data('on-close')});\n modal.open(el.attr('href'), el.data('name'));\n break;\n case 'message':\n this.openMessage(el.data('text'));\n break;\n case 'sideframe':\n var sideframe = new CMS.Sideframe({'onClose': el.data('on-close')});\n sideframe.open(el.attr('href'), true);\n break;\n case 'ajax':\n this.openAjax(el.attr('href'), JSON.stringify(\n el.data('post')), el.data('text'), null, el.data('on-success')\n );\n break;\n default:\n window.location.href = el.attr('href');\n }\n },\n\n _lock: function (lock) {\n if (lock) {\n this.lockToolbar = true;\n // make button look disabled\n this.toolbarTrigger.css('opacity', 0.2);\n } else {\n this.lockToolbar = false;\n // make button look disabled\n this.toolbarTrigger.css('opacity', 1);\n }\n },\n\n _loader: function (loader) {\n if (loader) {\n this.toolbarTrigger.addClass('cms-toolbar-loader');\n } else {\n this.toolbarTrigger.removeClass('cms-toolbar-loader');\n }\n },\n\n _debug: function () {\n var that = this;\n var timeout = 1000;\n var timer = function () {};\n\n // bind message event\n var debug = this.container.find('.cms-debug-bar');\n debug.bind('mouseenter mouseleave', function (e) {\n clearTimeout(timer);\n\n if (e.type === 'mouseenter') {\n timer = setTimeout(function () {\n that.openMessage(that.config.lang.debug);\n }, timeout);\n }\n });\n },\n\n _screenBlock: function () {\n var interval = 20;\n var blocker = this.screenBlock;\n var sideframe = $('.cms-sideframe');\n\n // automatically resize screenblock window according to given attributes\n $(window).on('resize.cms.screenblock', function () {\n var width = $(this).width() - sideframe.width();\n\n blocker.css({\n 'width': width,\n 'height': $(window).height()\n });\n }).trigger('resize');\n\n // set update interval\n setInterval(function () {\n $(window).trigger('resize.cms.screenblock');\n }, interval);\n }\n\n });\n });\n})(CMS.$);\n"},"repo_name":{"kind":"string","value":"josjevv/django-cms"},"path":{"kind":"string","value":"cms/static/cms/js/modules/cms.toolbar.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":22476,"string":"22,476"}}},{"rowIdx":61538451,"cells":{"code":{"kind":"string","value":"from __future__ import absolute_import\n\nimport psycopg2 as Database\n\n# Some of these imports are unused, but they are inherited from other engines\n# and should be available as part of the backend ``base.py`` namespace.\nfrom django.db.backends.postgresql_psycopg2.base import ( # NOQA\n DatabaseWrapper, DatabaseFeatures, DatabaseOperations, DatabaseClient,\n DatabaseCreation, DatabaseIntrospection\n)\n\nfrom .decorators import (\n capture_transaction_exceptions, auto_reconnect_cursor,\n auto_reconnect_connection, less_shitty_error_messages\n)\n\n\n__all__ = ('DatabaseWrapper', 'DatabaseFeatures', 'DatabaseOperations',\n 'DatabaseOperations', 'DatabaseClient', 'DatabaseCreation',\n 'DatabaseIntrospection')\n\n\nclass CursorWrapper(object):\n \"\"\"\n A wrapper around the postgresql_psycopg2 backend which handles various events\n from cursors, such as auto reconnects and lazy time zone evaluation.\n \"\"\"\n\n def __init__(self, db, cursor):\n self.db = db\n self.cursor = cursor\n\n def __getattr__(self, attr):\n return getattr(self.cursor, attr)\n\n def __iter__(self):\n return iter(self.cursor)\n\n @capture_transaction_exceptions\n @auto_reconnect_cursor\n @less_shitty_error_messages\n def execute(self, sql, params=None):\n if params is not None:\n return self.cursor.execute(sql, params)\n return self.cursor.execute(sql)\n\n @capture_transaction_exceptions\n @auto_reconnect_cursor\n @less_shitty_error_messages\n def executemany(self, sql, paramlist=()):\n return self.cursor.executemany(sql, paramlist)\n\n\nclass DatabaseWrapper(DatabaseWrapper):\n @auto_reconnect_connection\n def _set_isolation_level(self, level):\n return super(DatabaseWrapper, self)._set_isolation_level(level)\n\n @auto_reconnect_connection\n def _cursor(self, *args, **kwargs):\n cursor = super(DatabaseWrapper, self)._cursor()\n return CursorWrapper(self, cursor)\n\n def close(self, reconnect=False):\n \"\"\"\n This ensures we dont error if the connection has already been closed.\n \"\"\"\n if self.connection is not None:\n if not self.connection.closed:\n try:\n self.connection.close()\n except Database.InterfaceError:\n # connection was already closed by something\n # like pgbouncer idle timeout.\n pass\n self.connection = None\n\n\nclass DatabaseFeatures(DatabaseFeatures):\n can_return_id_from_insert = True\n\n def __init__(self, connection):\n self.connection = connection\n"},"repo_name":{"kind":"string","value":"Kryz/sentry"},"path":{"kind":"string","value":"src/sentry/db/postgres/base.py"},"language":{"kind":"string","value":"Python"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":2640,"string":"2,640"}}},{"rowIdx":61538452,"cells":{"code":{"kind":"string","value":"import foo from \"foo\";\nimport {default as foo2} from \"foo\";\n"},"repo_name":{"kind":"string","value":"hawkrives/6to5"},"path":{"kind":"string","value":"test/fixtures/transformation/es6-modules-umd/imports-default/actual.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":60,"string":"60"}}},{"rowIdx":61538453,"cells":{"code":{"kind":"string","value":"(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"react-onclickoutside\"), require(\"moment\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"react-onclickoutside\", \"moment\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"DatePicker\"] = factory(require(\"react\"), require(\"react-onclickoutside\"), require(\"moment\"));\n\telse\n\t\troot[\"DatePicker\"] = factory(root[\"React\"], root[\"onClickOutside\"], root[\"moment\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_11__, __WEBPACK_EXTERNAL_MODULE_13__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n\n\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _calendar = __webpack_require__(1);\n\n\tvar _calendar2 = _interopRequireDefault(_calendar);\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _popper_component = __webpack_require__(21);\n\n\tvar _popper_component2 = _interopRequireDefault(_popper_component);\n\n\tvar _classnames2 = __webpack_require__(10);\n\n\tvar _classnames3 = _interopRequireDefault(_classnames2);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tvar _reactOnclickoutside = __webpack_require__(11);\n\n\tvar _reactOnclickoutside2 = _interopRequireDefault(_reactOnclickoutside);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar outsideClickIgnoreClass = 'react-datepicker-ignore-onclickoutside';\n\tvar WrappedCalendar = (0, _reactOnclickoutside2.default)(_calendar2.default);\n\n\t/**\n\t * General datepicker component.\n\t */\n\n\tvar DatePicker = function (_React$Component) {\n\t _inherits(DatePicker, _React$Component);\n\n\t _createClass(DatePicker, null, [{\n\t key: 'defaultProps',\n\t get: function get() {\n\t return {\n\t allowSameDay: false,\n\t dateFormat: 'L',\n\t dateFormatCalendar: 'MMMM YYYY',\n\t onChange: function onChange() {},\n\n\t disabled: false,\n\t disabledKeyboardNavigation: false,\n\t dropdownMode: 'scroll',\n\t onFocus: function onFocus() {},\n\t onBlur: function onBlur() {},\n\t onKeyDown: function onKeyDown() {},\n\t onSelect: function onSelect() {},\n\t onClickOutside: function onClickOutside() {},\n\t onMonthChange: function onMonthChange() {},\n\n\t monthsShown: 1,\n\t withPortal: false,\n\t shouldCloseOnSelect: true,\n\t showTimeSelect: false,\n\t timeIntervals: 30\n\t };\n\t }\n\t }]);\n\n\t function DatePicker(props) {\n\t _classCallCheck(this, DatePicker);\n\n\t var _this = _possibleConstructorReturn(this, (DatePicker.__proto__ || Object.getPrototypeOf(DatePicker)).call(this, props));\n\n\t _this.getPreSelection = function () {\n\t return _this.props.openToDate ? (0, _date_utils.newDate)(_this.props.openToDate) : _this.props.selectsEnd && _this.props.startDate ? (0, _date_utils.newDate)(_this.props.startDate) : _this.props.selectsStart && _this.props.endDate ? (0, _date_utils.newDate)(_this.props.endDate) : (0, _date_utils.now)(_this.props.utcOffset);\n\t };\n\n\t _this.calcInitialState = function () {\n\t var defaultPreSelection = _this.getPreSelection();\n\t var minDate = (0, _date_utils.getEffectiveMinDate)(_this.props);\n\t var maxDate = (0, _date_utils.getEffectiveMaxDate)(_this.props);\n\t var boundedPreSelection = minDate && (0, _date_utils.isBefore)(defaultPreSelection, minDate) ? minDate : maxDate && (0, _date_utils.isAfter)(defaultPreSelection, maxDate) ? maxDate : defaultPreSelection;\n\n\t return {\n\t open: _this.props.startOpen || false,\n\t preventFocus: false,\n\t preSelection: _this.props.selected ? (0, _date_utils.newDate)(_this.props.selected) : boundedPreSelection\n\t };\n\t };\n\n\t _this.clearPreventFocusTimeout = function () {\n\t if (_this.preventFocusTimeout) {\n\t clearTimeout(_this.preventFocusTimeout);\n\t }\n\t };\n\n\t _this.setFocus = function () {\n\t _this.input.focus();\n\t };\n\n\t _this.setOpen = function (open) {\n\t _this.setState({\n\t open: open,\n\t preSelection: open && _this.state.open ? _this.state.preSelection : _this.calcInitialState().preSelection\n\t });\n\t };\n\n\t _this.handleFocus = function (event) {\n\t if (!_this.state.preventFocus) {\n\t _this.props.onFocus(event);\n\t _this.setOpen(true);\n\t }\n\t };\n\n\t _this.cancelFocusInput = function () {\n\t clearTimeout(_this.inputFocusTimeout);\n\t _this.inputFocusTimeout = null;\n\t };\n\n\t _this.deferFocusInput = function () {\n\t _this.cancelFocusInput();\n\t _this.inputFocusTimeout = setTimeout(function () {\n\t return _this.setFocus();\n\t }, 1);\n\t };\n\n\t _this.handleDropdownFocus = function () {\n\t _this.cancelFocusInput();\n\t };\n\n\t _this.handleBlur = function (event) {\n\t if (_this.state.open) {\n\t _this.deferFocusInput();\n\t } else {\n\t _this.props.onBlur(event);\n\t }\n\t };\n\n\t _this.handleCalendarClickOutside = function (event) {\n\t if (!_this.props.inline) {\n\t _this.setOpen(false);\n\t }\n\t _this.props.onClickOutside(event);\n\t if (_this.props.withPortal) {\n\t event.preventDefault();\n\t }\n\t };\n\n\t _this.handleChange = function (event) {\n\t if (_this.props.onChangeRaw) {\n\t _this.props.onChangeRaw(event);\n\t if (event.isDefaultPrevented()) {\n\t return;\n\t }\n\t }\n\t _this.setState({ inputValue: event.target.value });\n\t var date = (0, _date_utils.parseDate)(event.target.value, _this.props);\n\t if (date || !event.target.value) {\n\t _this.setSelected(date, event, true);\n\t }\n\t };\n\n\t _this.handleSelect = function (date, event) {\n\t // Preventing onFocus event to fix issue\n\t // https://github.com/Hacker0x01/react-datepicker/issues/628\n\t _this.setState({ preventFocus: true }, function () {\n\t _this.preventFocusTimeout = setTimeout(function () {\n\t return _this.setState({ preventFocus: false });\n\t }, 50);\n\t return _this.preventFocusTimeout;\n\t });\n\t _this.setSelected(date, event);\n\t if (!_this.props.shouldCloseOnSelect) {\n\t _this.setPreSelection(date);\n\t } else if (!_this.props.inline) {\n\t _this.setOpen(false);\n\t }\n\t };\n\n\t _this.setSelected = function (date, event, keepInput) {\n\t var changedDate = date;\n\n\t if (changedDate !== null && (0, _date_utils.isDayDisabled)(changedDate, _this.props)) {\n\t return;\n\t }\n\n\t if (!(0, _date_utils.isSameDay)(_this.props.selected, changedDate) || _this.props.allowSameDay) {\n\t if (changedDate !== null) {\n\t if (_this.props.selected) {\n\t changedDate = (0, _date_utils.setTime)((0, _date_utils.newDate)(changedDate), {\n\t hour: (0, _date_utils.getHour)(_this.props.selected),\n\t minute: (0, _date_utils.getMinute)(_this.props.selected),\n\t second: (0, _date_utils.getSecond)(_this.props.selected)\n\t });\n\t }\n\t _this.setState({\n\t preSelection: changedDate\n\t });\n\t }\n\t _this.props.onChange(changedDate, event);\n\t }\n\n\t _this.props.onSelect(changedDate, event);\n\n\t if (!keepInput) {\n\t _this.setState({ inputValue: null });\n\t }\n\t };\n\n\t _this.setPreSelection = function (date) {\n\t var isDateRangePresent = typeof _this.props.minDate !== 'undefined' && typeof _this.props.maxDate !== 'undefined';\n\t var isValidDateSelection = isDateRangePresent && date ? (0, _date_utils.isDayInRange)(date, _this.props.minDate, _this.props.maxDate) : true;\n\t if (isValidDateSelection) {\n\t _this.setState({\n\t preSelection: date\n\t });\n\t }\n\t };\n\n\t _this.handleTimeChange = function (time) {\n\t var selected = _this.props.selected ? _this.props.selected : _this.getPreSelection();\n\t var changedDate = (0, _date_utils.setTime)((0, _date_utils.cloneDate)(selected), {\n\t hour: (0, _date_utils.getHour)(time),\n\t minute: (0, _date_utils.getMinute)(time)\n\t });\n\n\t _this.setState({\n\t preSelection: changedDate\n\t });\n\n\t _this.props.onChange(changedDate);\n\t };\n\n\t _this.onInputClick = function () {\n\t if (!_this.props.disabled) {\n\t _this.setOpen(true);\n\t }\n\t };\n\n\t _this.onInputKeyDown = function (event) {\n\t _this.props.onKeyDown(event);\n\t var eventKey = event.key;\n\t if (!_this.state.open && !_this.props.inline) {\n\t if (eventKey !== 'Enter' && eventKey !== 'Escape' && eventKey !== 'Tab') {\n\t _this.onInputClick();\n\t }\n\t return;\n\t }\n\t var copy = (0, _date_utils.newDate)(_this.state.preSelection);\n\t if (eventKey === 'Enter') {\n\t event.preventDefault();\n\t if ((0, _date_utils.isMoment)(_this.state.preSelection) || (0, _date_utils.isDate)(_this.state.preSelection)) {\n\t _this.handleSelect(copy, event);\n\t !_this.props.shouldCloseOnSelect && _this.setPreSelection(copy);\n\t } else {\n\t _this.setOpen(false);\n\t }\n\t } else if (eventKey === 'Escape') {\n\t event.preventDefault();\n\t _this.setOpen(false);\n\t } else if (eventKey === 'Tab') {\n\t _this.setOpen(false);\n\t } else if (!_this.props.disabledKeyboardNavigation) {\n\t var newSelection = void 0;\n\t switch (eventKey) {\n\t case 'ArrowLeft':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.subtractDays)(copy, 1);\n\t break;\n\t case 'ArrowRight':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.addDays)(copy, 1);\n\t break;\n\t case 'ArrowUp':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.subtractWeeks)(copy, 1);\n\t break;\n\t case 'ArrowDown':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.addWeeks)(copy, 1);\n\t break;\n\t case 'PageUp':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.subtractMonths)(copy, 1);\n\t break;\n\t case 'PageDown':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.addMonths)(copy, 1);\n\t break;\n\t case 'Home':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.subtractYears)(copy, 1);\n\t break;\n\t case 'End':\n\t event.preventDefault();\n\t newSelection = (0, _date_utils.addYears)(copy, 1);\n\t break;\n\t }\n\t _this.setPreSelection(newSelection);\n\t }\n\t };\n\n\t _this.onClearClick = function (event) {\n\t event.preventDefault();\n\t _this.props.onChange(null, event);\n\t _this.setState({ inputValue: null });\n\t };\n\n\t _this.renderCalendar = function () {\n\t if (!_this.props.inline && (!_this.state.open || _this.props.disabled)) {\n\t return null;\n\t }\n\t return _react2.default.createElement(\n\t WrappedCalendar,\n\t {\n\t ref: function ref(elem) {\n\t _this.calendar = elem;\n\t },\n\t locale: _this.props.locale,\n\t dateFormat: _this.props.dateFormatCalendar,\n\t useWeekdaysShort: _this.props.useWeekdaysShort,\n\t dropdownMode: _this.props.dropdownMode,\n\t selected: _this.props.selected,\n\t preSelection: _this.state.preSelection,\n\t onSelect: _this.handleSelect,\n\t onWeekSelect: _this.props.onWeekSelect,\n\t openToDate: _this.props.openToDate,\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t selectsStart: _this.props.selectsStart,\n\t selectsEnd: _this.props.selectsEnd,\n\t startDate: _this.props.startDate,\n\t endDate: _this.props.endDate,\n\t excludeDates: _this.props.excludeDates,\n\t filterDate: _this.props.filterDate,\n\t onClickOutside: _this.handleCalendarClickOutside,\n\t formatWeekNumber: _this.props.formatWeekNumber,\n\t highlightDates: _this.props.highlightDates,\n\t includeDates: _this.props.includeDates,\n\t inline: _this.props.inline,\n\t peekNextMonth: _this.props.peekNextMonth,\n\t showMonthDropdown: _this.props.showMonthDropdown,\n\t showWeekNumbers: _this.props.showWeekNumbers,\n\t showYearDropdown: _this.props.showYearDropdown,\n\t withPortal: _this.props.withPortal,\n\t forceShowMonthNavigation: _this.props.forceShowMonthNavigation,\n\t scrollableYearDropdown: _this.props.scrollableYearDropdown,\n\t todayButton: _this.props.todayButton,\n\t weekLabel: _this.props.weekLabel,\n\t utcOffset: _this.props.utcOffset,\n\t outsideClickIgnoreClass: outsideClickIgnoreClass,\n\t fixedHeight: _this.props.fixedHeight,\n\t monthsShown: _this.props.monthsShown,\n\t onDropdownFocus: _this.handleDropdownFocus,\n\t onMonthChange: _this.props.onMonthChange,\n\t dayClassName: _this.props.dayClassName,\n\t showTimeSelect: _this.props.showTimeSelect,\n\t onTimeChange: _this.handleTimeChange,\n\t timeFormat: _this.props.timeFormat,\n\t timeIntervals: _this.props.timeIntervals,\n\t minTime: _this.props.minTime,\n\t maxTime: _this.props.maxTime,\n\t excludeTimes: _this.props.excludeTimes,\n\t className: _this.props.calendarClassName,\n\t yearDropdownItemNumber: _this.props.yearDropdownItemNumber },\n\t _this.props.children\n\t );\n\t };\n\n\t _this.renderDateInput = function () {\n\t var className = (0, _classnames3.default)(_this.props.className, _defineProperty({}, outsideClickIgnoreClass, _this.state.open));\n\n\t var customInput = _this.props.customInput || _react2.default.createElement('input', { type: 'text' });\n\t var inputValue = typeof _this.props.value === 'string' ? _this.props.value : typeof _this.state.inputValue === 'string' ? _this.state.inputValue : (0, _date_utils.safeDateFormat)(_this.props.selected, _this.props);\n\n\t return _react2.default.cloneElement(customInput, {\n\t ref: function ref(input) {\n\t _this.input = input;\n\t },\n\t value: inputValue,\n\t onBlur: _this.handleBlur,\n\t onChange: _this.handleChange,\n\t onClick: _this.onInputClick,\n\t onFocus: _this.handleFocus,\n\t onKeyDown: _this.onInputKeyDown,\n\t id: _this.props.id,\n\t name: _this.props.name,\n\t autoFocus: _this.props.autoFocus,\n\t placeholder: _this.props.placeholderText,\n\t disabled: _this.props.disabled,\n\t autoComplete: _this.props.autoComplete,\n\t className: className,\n\t title: _this.props.title,\n\t readOnly: _this.props.readOnly,\n\t required: _this.props.required,\n\t tabIndex: _this.props.tabIndex\n\t });\n\t };\n\n\t _this.renderClearButton = function () {\n\t if (_this.props.isClearable && _this.props.selected != null) {\n\t return _react2.default.createElement('a', { className: 'react-datepicker__close-icon', href: '#', onClick: _this.onClearClick });\n\t } else {\n\t return null;\n\t }\n\t };\n\n\t _this.state = _this.calcInitialState();\n\t return _this;\n\t }\n\n\t _createClass(DatePicker, [{\n\t key: 'componentWillReceiveProps',\n\t value: function componentWillReceiveProps(nextProps) {\n\t var currentMonth = this.props.selected && (0, _date_utils.getMonth)(this.props.selected);\n\t var nextMonth = nextProps.selected && (0, _date_utils.getMonth)(nextProps.selected);\n\t if (this.props.inline && currentMonth !== nextMonth) {\n\t this.setPreSelection(nextProps.selected);\n\t }\n\t }\n\t }, {\n\t key: 'componentWillUnmount',\n\t value: function componentWillUnmount() {\n\t this.clearPreventFocusTimeout();\n\t }\n\t }, {\n\t key: 'render',\n\t value: function render() {\n\t var calendar = this.renderCalendar();\n\n\t if (this.props.inline && !this.props.withPortal) {\n\t return calendar;\n\t }\n\n\t if (this.props.withPortal) {\n\t return _react2.default.createElement(\n\t 'div',\n\t null,\n\t !this.props.inline ? _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__input-container' },\n\t this.renderDateInput(),\n\t this.renderClearButton()\n\t ) : null,\n\t this.state.open || this.props.inline ? _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__portal' },\n\t calendar\n\t ) : null\n\t );\n\t }\n\n\t return _react2.default.createElement(_popper_component2.default, {\n\t className: this.props.popperClassName,\n\t hidePopper: !this.state.open || this.props.disabled,\n\t popperModifiers: this.props.popperModifiers,\n\t targetComponent: _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__input-container' },\n\t this.renderDateInput(),\n\t this.renderClearButton()\n\t ),\n\t popperContainer: this.props.popperContainer,\n\t popperComponent: calendar,\n\t popperPlacement: this.props.popperPlacement });\n\t }\n\t }]);\n\n\t return DatePicker;\n\t}(_react2.default.Component);\n\n\tDatePicker.propTypes = {\n\t allowSameDay: _propTypes2.default.bool,\n\t autoComplete: _propTypes2.default.string,\n\t autoFocus: _propTypes2.default.bool,\n\t calendarClassName: _propTypes2.default.string,\n\t children: _propTypes2.default.node,\n\t className: _propTypes2.default.string,\n\t customInput: _propTypes2.default.element,\n\t dateFormat: _propTypes2.default.oneOfType([// eslint-disable-line react/no-unused-prop-types\n\t _propTypes2.default.string, _propTypes2.default.array]),\n\t dateFormatCalendar: _propTypes2.default.string,\n\t dayClassName: _propTypes2.default.func,\n\t disabled: _propTypes2.default.bool,\n\t disabledKeyboardNavigation: _propTypes2.default.bool,\n\t dropdownMode: _propTypes2.default.oneOf(['scroll', 'select']).isRequired,\n\t endDate: _propTypes2.default.object,\n\t excludeDates: _propTypes2.default.array,\n\t filterDate: _propTypes2.default.func,\n\t fixedHeight: _propTypes2.default.bool,\n\t formatWeekNumber: _propTypes2.default.func,\n\t highlightDates: _propTypes2.default.array,\n\t id: _propTypes2.default.string,\n\t includeDates: _propTypes2.default.array,\n\t inline: _propTypes2.default.bool,\n\t isClearable: _propTypes2.default.bool,\n\t locale: _propTypes2.default.string,\n\t maxDate: _propTypes2.default.object,\n\t minDate: _propTypes2.default.object,\n\t monthsShown: _propTypes2.default.number,\n\t name: _propTypes2.default.string,\n\t onBlur: _propTypes2.default.func,\n\t onChange: _propTypes2.default.func.isRequired,\n\t onSelect: _propTypes2.default.func,\n\t onWeekSelect: _propTypes2.default.func,\n\t onClickOutside: _propTypes2.default.func,\n\t onChangeRaw: _propTypes2.default.func,\n\t onFocus: _propTypes2.default.func,\n\t onKeyDown: _propTypes2.default.func,\n\t onMonthChange: _propTypes2.default.func,\n\t openToDate: _propTypes2.default.object,\n\t peekNextMonth: _propTypes2.default.bool,\n\t placeholderText: _propTypes2.default.string,\n\t popperContainer: _propTypes2.default.func,\n\t popperClassName: _propTypes2.default.string, // props\n\t popperModifiers: _propTypes2.default.object, // props\n\t popperPlacement: _propTypes2.default.oneOf(_popper_component.popperPlacementPositions), // props\n\t readOnly: _propTypes2.default.bool,\n\t required: _propTypes2.default.bool,\n\t scrollableYearDropdown: _propTypes2.default.bool,\n\t selected: _propTypes2.default.object,\n\t selectsEnd: _propTypes2.default.bool,\n\t selectsStart: _propTypes2.default.bool,\n\t showMonthDropdown: _propTypes2.default.bool,\n\t showWeekNumbers: _propTypes2.default.bool,\n\t showYearDropdown: _propTypes2.default.bool,\n\t forceShowMonthNavigation: _propTypes2.default.bool,\n\t startDate: _propTypes2.default.object,\n\t startOpen: _propTypes2.default.bool,\n\t tabIndex: _propTypes2.default.number,\n\t title: _propTypes2.default.string,\n\t todayButton: _propTypes2.default.string,\n\t useWeekdaysShort: _propTypes2.default.bool,\n\t utcOffset: _propTypes2.default.number,\n\t value: _propTypes2.default.string,\n\t weekLabel: _propTypes2.default.string,\n\t withPortal: _propTypes2.default.bool,\n\t yearDropdownItemNumber: _propTypes2.default.number,\n\t shouldCloseOnSelect: _propTypes2.default.bool,\n\t showTimeSelect: _propTypes2.default.bool,\n\t timeFormat: _propTypes2.default.string,\n\t timeIntervals: _propTypes2.default.number,\n\t minTime: _propTypes2.default.object,\n\t maxTime: _propTypes2.default.object,\n\t excludeTimes: _propTypes2.default.array\n\t};\n\texports.default = DatePicker;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _year_dropdown = __webpack_require__(2);\n\n\tvar _year_dropdown2 = _interopRequireDefault(_year_dropdown);\n\n\tvar _month_dropdown = __webpack_require__(14);\n\n\tvar _month_dropdown2 = _interopRequireDefault(_month_dropdown);\n\n\tvar _month = __webpack_require__(16);\n\n\tvar _month2 = _interopRequireDefault(_month);\n\n\tvar _time = __webpack_require__(20);\n\n\tvar _time2 = _interopRequireDefault(_time);\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar DROPDOWN_FOCUS_CLASSNAMES = ['react-datepicker__year-select', 'react-datepicker__month-select'];\n\n\tvar isDropdownSelect = function isDropdownSelect() {\n\t var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n\t var classNames = (element.className || '').split(/\\s+/);\n\t return DROPDOWN_FOCUS_CLASSNAMES.some(function (testClassname) {\n\t return classNames.indexOf(testClassname) >= 0;\n\t });\n\t};\n\n\tvar Calendar = function (_React$Component) {\n\t _inherits(Calendar, _React$Component);\n\n\t _createClass(Calendar, null, [{\n\t key: 'defaultProps',\n\t get: function get() {\n\t return {\n\t onDropdownFocus: function onDropdownFocus() {},\n\t monthsShown: 1,\n\t forceShowMonthNavigation: false\n\t };\n\t }\n\t }]);\n\n\t function Calendar(props) {\n\t _classCallCheck(this, Calendar);\n\n\t var _this = _possibleConstructorReturn(this, (Calendar.__proto__ || Object.getPrototypeOf(Calendar)).call(this, props));\n\n\t _this.handleClickOutside = function (event) {\n\t _this.props.onClickOutside(event);\n\t };\n\n\t _this.handleDropdownFocus = function (event) {\n\t if (isDropdownSelect(event.target)) {\n\t _this.props.onDropdownFocus();\n\t }\n\t };\n\n\t _this.getDateInView = function () {\n\t var _this$props = _this.props,\n\t preSelection = _this$props.preSelection,\n\t selected = _this$props.selected,\n\t openToDate = _this$props.openToDate,\n\t utcOffset = _this$props.utcOffset;\n\n\t var minDate = (0, _date_utils.getEffectiveMinDate)(_this.props);\n\t var maxDate = (0, _date_utils.getEffectiveMaxDate)(_this.props);\n\t var current = (0, _date_utils.now)(utcOffset);\n\t var initialDate = openToDate || selected || preSelection;\n\t if (initialDate) {\n\t return initialDate;\n\t } else {\n\t if (minDate && (0, _date_utils.isBefore)(current, minDate)) {\n\t return minDate;\n\t } else if (maxDate && (0, _date_utils.isAfter)(current, maxDate)) {\n\t return maxDate;\n\t }\n\t }\n\t return current;\n\t };\n\n\t _this.localizeDate = function (date) {\n\t return (0, _date_utils.localizeDate)(date, _this.props.locale);\n\t };\n\n\t _this.increaseMonth = function () {\n\t _this.setState({\n\t date: (0, _date_utils.addMonths)((0, _date_utils.cloneDate)(_this.state.date), 1)\n\t }, function () {\n\t return _this.handleMonthChange(_this.state.date);\n\t });\n\t };\n\n\t _this.decreaseMonth = function () {\n\t _this.setState({\n\t date: (0, _date_utils.subtractMonths)((0, _date_utils.cloneDate)(_this.state.date), 1)\n\t }, function () {\n\t return _this.handleMonthChange(_this.state.date);\n\t });\n\t };\n\n\t _this.handleDayClick = function (day, event) {\n\t return _this.props.onSelect(day, event);\n\t };\n\n\t _this.handleDayMouseEnter = function (day) {\n\t return _this.setState({ selectingDate: day });\n\t };\n\n\t _this.handleMonthMouseLeave = function () {\n\t return _this.setState({ selectingDate: null });\n\t };\n\n\t _this.handleMonthChange = function (date) {\n\t if (_this.props.onMonthChange) {\n\t _this.props.onMonthChange(date);\n\t }\n\t };\n\n\t _this.changeYear = function (year) {\n\t _this.setState({\n\t date: (0, _date_utils.setYear)((0, _date_utils.cloneDate)(_this.state.date), year)\n\t });\n\t };\n\n\t _this.changeMonth = function (month) {\n\t _this.setState({\n\t date: (0, _date_utils.setMonth)((0, _date_utils.cloneDate)(_this.state.date), month)\n\t }, function () {\n\t return _this.handleMonthChange(_this.state.date);\n\t });\n\t };\n\n\t _this.header = function () {\n\t var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.date;\n\n\t var startOfWeek = (0, _date_utils.getStartOfWeek)((0, _date_utils.cloneDate)(date));\n\t var dayNames = [];\n\t if (_this.props.showWeekNumbers) {\n\t dayNames.push(_react2.default.createElement(\n\t 'div',\n\t { key: 'W', className: 'react-datepicker__day-name' },\n\t _this.props.weekLabel || '#'\n\t ));\n\t }\n\t return dayNames.concat([0, 1, 2, 3, 4, 5, 6].map(function (offset) {\n\t var day = (0, _date_utils.addDays)((0, _date_utils.cloneDate)(startOfWeek), offset);\n\t var localeData = (0, _date_utils.getLocaleData)(day);\n\t var weekDayName = _this.props.useWeekdaysShort ? (0, _date_utils.getWeekdayShortInLocale)(localeData, day) : (0, _date_utils.getWeekdayMinInLocale)(localeData, day);\n\t return _react2.default.createElement(\n\t 'div',\n\t { key: offset, className: 'react-datepicker__day-name' },\n\t weekDayName\n\t );\n\t }));\n\t };\n\n\t _this.renderPreviousMonthButton = function () {\n\t if (!_this.props.forceShowMonthNavigation && (0, _date_utils.allDaysDisabledBefore)(_this.state.date, 'month', _this.props)) {\n\t return;\n\t }\n\t return _react2.default.createElement('a', {\n\t className: 'react-datepicker__navigation react-datepicker__navigation--previous',\n\t onClick: _this.decreaseMonth });\n\t };\n\n\t _this.renderNextMonthButton = function () {\n\t if (!_this.props.forceShowMonthNavigation && (0, _date_utils.allDaysDisabledAfter)(_this.state.date, 'month', _this.props)) {\n\t return;\n\t }\n\n\t var classes = ['react-datepicker__navigation', 'react-datepicker__navigation--next'];\n\t if (_this.props.showTimeSelect) {\n\t classes.push('react-datepicker__navigation--next--with-time');\n\t }\n\t if (_this.props.todayButton) {\n\t classes.push('react-datepicker__navigation--next--with-today-button');\n\t }\n\n\t return _react2.default.createElement('a', {\n\t className: classes.join(' '),\n\t onClick: _this.increaseMonth });\n\t };\n\n\t _this.renderCurrentMonth = function () {\n\t var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.state.date;\n\n\t var classes = ['react-datepicker__current-month'];\n\n\t if (_this.props.showYearDropdown) {\n\t classes.push('react-datepicker__current-month--hasYearDropdown');\n\t }\n\t if (_this.props.showMonthDropdown) {\n\t classes.push('react-datepicker__current-month--hasMonthDropdown');\n\t }\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: classes.join(' ') },\n\t (0, _date_utils.formatDate)(date, _this.props.dateFormat)\n\t );\n\t };\n\n\t _this.renderYearDropdown = function () {\n\t var overrideHide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n\t if (!_this.props.showYearDropdown || overrideHide) {\n\t return;\n\t }\n\t return _react2.default.createElement(_year_dropdown2.default, {\n\t dropdownMode: _this.props.dropdownMode,\n\t onChange: _this.changeYear,\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t year: (0, _date_utils.getYear)(_this.state.date),\n\t scrollableYearDropdown: _this.props.scrollableYearDropdown,\n\t yearDropdownItemNumber: _this.props.yearDropdownItemNumber });\n\t };\n\n\t _this.renderMonthDropdown = function () {\n\t var overrideHide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n\n\t if (!_this.props.showMonthDropdown) {\n\t return;\n\t }\n\t return _react2.default.createElement(_month_dropdown2.default, {\n\t dropdownMode: _this.props.dropdownMode,\n\t locale: _this.props.locale,\n\t dateFormat: _this.props.dateFormat,\n\t onChange: _this.changeMonth,\n\t month: (0, _date_utils.getMonth)(_this.state.date) });\n\t };\n\n\t _this.renderTodayButton = function () {\n\t if (!_this.props.todayButton) {\n\t return;\n\t }\n\t return _react2.default.createElement(\n\t 'div',\n\t {\n\t className: 'react-datepicker__today-button',\n\t onClick: function onClick(e) {\n\t return _this.props.onSelect((0, _date_utils.getStartOfDate)((0, _date_utils.now)(_this.props.utcOffset)), e);\n\t } },\n\t _this.props.todayButton\n\t );\n\t };\n\n\t _this.renderMonths = function () {\n\t var monthList = [];\n\t for (var i = 0; i < _this.props.monthsShown; ++i) {\n\t var monthDate = (0, _date_utils.addMonths)((0, _date_utils.cloneDate)(_this.state.date), i);\n\t var monthKey = 'month-' + i;\n\t monthList.push(_react2.default.createElement(\n\t 'div',\n\t { key: monthKey, ref: function ref(div) {\n\t _this.monthContainer = div;\n\t }, className: 'react-datepicker__month-container' },\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__header' },\n\t _this.renderCurrentMonth(monthDate),\n\t _react2.default.createElement(\n\t 'div',\n\t {\n\t className: 'react-datepicker__header__dropdown react-datepicker__header__dropdown--' + _this.props.dropdownMode,\n\t onFocus: _this.handleDropdownFocus },\n\t _this.renderMonthDropdown(i !== 0),\n\t _this.renderYearDropdown(i !== 0)\n\t ),\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__day-names' },\n\t _this.header(monthDate)\n\t )\n\t ),\n\t _react2.default.createElement(_month2.default, {\n\t day: monthDate,\n\t dayClassName: _this.props.dayClassName,\n\t onDayClick: _this.handleDayClick,\n\t onDayMouseEnter: _this.handleDayMouseEnter,\n\t onMouseLeave: _this.handleMonthMouseLeave,\n\t onWeekSelect: _this.props.onWeekSelect,\n\t formatWeekNumber: _this.props.formatWeekNumber,\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t excludeDates: _this.props.excludeDates,\n\t highlightDates: _this.props.highlightDates,\n\t selectingDate: _this.state.selectingDate,\n\t includeDates: _this.props.includeDates,\n\t inline: _this.props.inline,\n\t fixedHeight: _this.props.fixedHeight,\n\t filterDate: _this.props.filterDate,\n\t preSelection: _this.props.preSelection,\n\t selected: _this.props.selected,\n\t selectsStart: _this.props.selectsStart,\n\t selectsEnd: _this.props.selectsEnd,\n\t showWeekNumbers: _this.props.showWeekNumbers,\n\t startDate: _this.props.startDate,\n\t endDate: _this.props.endDate,\n\t peekNextMonth: _this.props.peekNextMonth,\n\t utcOffset: _this.props.utcOffset })\n\t ));\n\t }\n\t return monthList;\n\t };\n\n\t _this.renderTimeSection = function () {\n\t if (_this.props.showTimeSelect) {\n\t return _react2.default.createElement(_time2.default, {\n\t selected: _this.props.selected,\n\t onChange: _this.props.onTimeChange,\n\t format: _this.props.timeFormat,\n\t intervals: _this.props.timeIntervals,\n\t minTime: _this.props.minTime,\n\t maxTime: _this.props.maxTime,\n\t excludeTimes: _this.props.excludeTimes,\n\t todayButton: _this.props.todayButton,\n\t showMonthDropdown: _this.props.showMonthDropdown,\n\t showYearDropdown: _this.props.showYearDropdown,\n\t withPortal: _this.props.withPortal,\n\t monthRef: _this.state.monthContainer });\n\t } else {\n\t return;\n\t }\n\t };\n\n\t _this.state = {\n\t date: _this.localizeDate(_this.getDateInView()),\n\t selectingDate: null,\n\t monthContainer: _this.monthContainer\n\t };\n\t return _this;\n\t }\n\n\t _createClass(Calendar, [{\n\t key: 'componentDidMount',\n\t value: function componentDidMount() {\n\t var _this2 = this;\n\n\t /* monthContainer height is needed in time component to determine the height for the ul in the time component. setState here so height is given after final component layout is rendered */\n\t if (this.props.showTimeSelect) {\n\t this.assignMonthContainer = function () {\n\t _this2.setState({ monthContainer: _this2.monthContainer });\n\t }();\n\t }\n\t }\n\t }, {\n\t key: 'componentWillReceiveProps',\n\t value: function componentWillReceiveProps(nextProps) {\n\t if (nextProps.preSelection && !(0, _date_utils.isSameDay)(nextProps.preSelection, this.props.preSelection)) {\n\t this.setState({\n\t date: this.localizeDate(nextProps.preSelection)\n\t });\n\t } else if (nextProps.openToDate && !(0, _date_utils.isSameDay)(nextProps.openToDate, this.props.openToDate)) {\n\t this.setState({\n\t date: this.localizeDate(nextProps.openToDate)\n\t });\n\t }\n\t }\n\t }, {\n\t key: 'render',\n\t value: function render() {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: (0, _classnames2.default)('react-datepicker', this.props.className) },\n\t _react2.default.createElement('div', { className: 'react-datepicker__triangle' }),\n\t this.renderPreviousMonthButton(),\n\t this.renderNextMonthButton(),\n\t this.renderMonths(),\n\t this.renderTodayButton(),\n\t this.renderTimeSection(),\n\t this.props.children\n\t );\n\t }\n\t }]);\n\n\t return Calendar;\n\t}(_react2.default.Component);\n\n\tCalendar.propTypes = {\n\t className: _propTypes2.default.string,\n\t children: _propTypes2.default.node,\n\t dateFormat: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array]).isRequired,\n\t dayClassName: _propTypes2.default.func,\n\t dropdownMode: _propTypes2.default.oneOf(['scroll', 'select']).isRequired,\n\t endDate: _propTypes2.default.object,\n\t excludeDates: _propTypes2.default.array,\n\t filterDate: _propTypes2.default.func,\n\t fixedHeight: _propTypes2.default.bool,\n\t formatWeekNumber: _propTypes2.default.func,\n\t highlightDates: _propTypes2.default.array,\n\t includeDates: _propTypes2.default.array,\n\t inline: _propTypes2.default.bool,\n\t locale: _propTypes2.default.string,\n\t maxDate: _propTypes2.default.object,\n\t minDate: _propTypes2.default.object,\n\t monthsShown: _propTypes2.default.number,\n\t onClickOutside: _propTypes2.default.func.isRequired,\n\t onMonthChange: _propTypes2.default.func,\n\t forceShowMonthNavigation: _propTypes2.default.bool,\n\t onDropdownFocus: _propTypes2.default.func,\n\t onSelect: _propTypes2.default.func.isRequired,\n\t onWeekSelect: _propTypes2.default.func,\n\t showTimeSelect: _propTypes2.default.bool,\n\t timeFormat: _propTypes2.default.string,\n\t timeIntervals: _propTypes2.default.number,\n\t onTimeChange: _propTypes2.default.func,\n\t minTime: _propTypes2.default.object,\n\t maxTime: _propTypes2.default.object,\n\t excludeTimes: _propTypes2.default.array,\n\t openToDate: _propTypes2.default.object,\n\t peekNextMonth: _propTypes2.default.bool,\n\t scrollableYearDropdown: _propTypes2.default.bool,\n\t preSelection: _propTypes2.default.object,\n\t selected: _propTypes2.default.object,\n\t selectsEnd: _propTypes2.default.bool,\n\t selectsStart: _propTypes2.default.bool,\n\t showMonthDropdown: _propTypes2.default.bool,\n\t showWeekNumbers: _propTypes2.default.bool,\n\t showYearDropdown: _propTypes2.default.bool,\n\t startDate: _propTypes2.default.object,\n\t todayButton: _propTypes2.default.string,\n\t useWeekdaysShort: _propTypes2.default.bool,\n\t withPortal: _propTypes2.default.bool,\n\t utcOffset: _propTypes2.default.number,\n\t weekLabel: _propTypes2.default.string,\n\t yearDropdownItemNumber: _propTypes2.default.number\n\t};\n\texports.default = Calendar;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _year_dropdown_options = __webpack_require__(9);\n\n\tvar _year_dropdown_options2 = _interopRequireDefault(_year_dropdown_options);\n\n\tvar _reactOnclickoutside = __webpack_require__(11);\n\n\tvar _reactOnclickoutside2 = _interopRequireDefault(_reactOnclickoutside);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar WrappedYearDropdownOptions = (0, _reactOnclickoutside2.default)(_year_dropdown_options2.default);\n\n\tvar YearDropdown = function (_React$Component) {\n\t _inherits(YearDropdown, _React$Component);\n\n\t function YearDropdown() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, YearDropdown);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = YearDropdown.__proto__ || Object.getPrototypeOf(YearDropdown)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n\t dropdownVisible: false\n\t }, _this.renderSelectOptions = function () {\n\t var minYear = _this.props.minDate ? (0, _date_utils.getYear)(_this.props.minDate) : 1900;\n\t var maxYear = _this.props.maxDate ? (0, _date_utils.getYear)(_this.props.maxDate) : 2100;\n\n\t var options = [];\n\t for (var i = minYear; i <= maxYear; i++) {\n\t options.push(_react2.default.createElement(\n\t 'option',\n\t { key: i, value: i },\n\t i\n\t ));\n\t }\n\t return options;\n\t }, _this.onSelectChange = function (e) {\n\t _this.onChange(e.target.value);\n\t }, _this.renderSelectMode = function () {\n\t return _react2.default.createElement(\n\t 'select',\n\t {\n\t value: _this.props.year,\n\t className: 'react-datepicker__year-select',\n\t onChange: _this.onSelectChange },\n\t _this.renderSelectOptions()\n\t );\n\t }, _this.renderReadView = function (visible) {\n\t return _react2.default.createElement(\n\t 'div',\n\t { key: 'read', style: { visibility: visible ? 'visible' : 'hidden' }, className: 'react-datepicker__year-read-view', onClick: _this.toggleDropdown },\n\t _react2.default.createElement('span', { className: 'react-datepicker__year-read-view--down-arrow' }),\n\t _react2.default.createElement(\n\t 'span',\n\t { className: 'react-datepicker__year-read-view--selected-year' },\n\t _this.props.year\n\t )\n\t );\n\t }, _this.renderDropdown = function () {\n\t return _react2.default.createElement(WrappedYearDropdownOptions, {\n\t key: 'dropdown',\n\t ref: 'options',\n\t year: _this.props.year,\n\t onChange: _this.onChange,\n\t onCancel: _this.toggleDropdown,\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t scrollableYearDropdown: _this.props.scrollableYearDropdown,\n\t yearDropdownItemNumber: _this.props.yearDropdownItemNumber });\n\t }, _this.renderScrollMode = function () {\n\t var dropdownVisible = _this.state.dropdownVisible;\n\n\t var result = [_this.renderReadView(!dropdownVisible)];\n\t if (dropdownVisible) {\n\t result.unshift(_this.renderDropdown());\n\t }\n\t return result;\n\t }, _this.onChange = function (year) {\n\t _this.toggleDropdown();\n\t if (year === _this.props.year) return;\n\t _this.props.onChange(year);\n\t }, _this.toggleDropdown = function () {\n\t _this.setState({\n\t dropdownVisible: !_this.state.dropdownVisible\n\t });\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(YearDropdown, [{\n\t key: 'render',\n\t value: function render() {\n\t var renderedDropdown = void 0;\n\t switch (this.props.dropdownMode) {\n\t case 'scroll':\n\t renderedDropdown = this.renderScrollMode();\n\t break;\n\t case 'select':\n\t renderedDropdown = this.renderSelectMode();\n\t break;\n\t }\n\n\t return _react2.default.createElement(\n\t 'div',\n\t {\n\t className: 'react-datepicker__year-dropdown-container react-datepicker__year-dropdown-container--' + this.props.dropdownMode },\n\t renderedDropdown\n\t );\n\t }\n\t }]);\n\n\t return YearDropdown;\n\t}(_react2.default.Component);\n\n\tYearDropdown.propTypes = {\n\t dropdownMode: _propTypes2.default.oneOf(['scroll', 'select']).isRequired,\n\t maxDate: _propTypes2.default.object,\n\t minDate: _propTypes2.default.object,\n\t onChange: _propTypes2.default.func.isRequired,\n\t scrollableYearDropdown: _propTypes2.default.bool,\n\t year: _propTypes2.default.number.isRequired,\n\t yearDropdownItemNumber: _propTypes2.default.number\n\t};\n\texports.default = YearDropdown;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_3__;\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/**\n\t * Copyright 2013-present, Facebook, Inc.\n\t * All rights reserved.\n\t *\n\t * This source code is licensed under the BSD-style license found in the\n\t * LICENSE file in the root directory of this source tree. An additional grant\n\t * of patent rights can be found in the PATENTS file in the same directory.\n\t */\n\n\tif (false) {\n\t var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&\n\t Symbol.for &&\n\t Symbol.for('react.element')) ||\n\t 0xeac7;\n\n\t var isValidElement = function(object) {\n\t return typeof object === 'object' &&\n\t object !== null &&\n\t object.$$typeof === REACT_ELEMENT_TYPE;\n\t };\n\n\t // By explicitly using `prop-types` you are opting into new development behavior.\n\t // http://fb.me/prop-types-in-prod\n\t var throwOnDirectAccess = true;\n\t module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);\n\t} else {\n\t // By explicitly using `prop-types` you are opting into new production behavior.\n\t // http://fb.me/prop-types-in-prod\n\t module.exports = __webpack_require__(5)();\n\t}\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/**\n\t * Copyright 2013-present, Facebook, Inc.\n\t * All rights reserved.\n\t *\n\t * This source code is licensed under the BSD-style license found in the\n\t * LICENSE file in the root directory of this source tree. An additional grant\n\t * of patent rights can be found in the PATENTS file in the same directory.\n\t */\n\n\t'use strict';\n\n\tvar emptyFunction = __webpack_require__(6);\n\tvar invariant = __webpack_require__(7);\n\tvar ReactPropTypesSecret = __webpack_require__(8);\n\n\tmodule.exports = function() {\n\t function shim(props, propName, componentName, location, propFullName, secret) {\n\t if (secret === ReactPropTypesSecret) {\n\t // It is still safe when called from React.\n\t return;\n\t }\n\t invariant(\n\t false,\n\t 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n\t 'Use PropTypes.checkPropTypes() to call them. ' +\n\t 'Read more at http://fb.me/use-check-prop-types'\n\t );\n\t };\n\t shim.isRequired = shim;\n\t function getShim() {\n\t return shim;\n\t };\n\t // Important!\n\t // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n\t var ReactPropTypes = {\n\t array: shim,\n\t bool: shim,\n\t func: shim,\n\t number: shim,\n\t object: shim,\n\t string: shim,\n\t symbol: shim,\n\n\t any: shim,\n\t arrayOf: getShim,\n\t element: shim,\n\t instanceOf: getShim,\n\t node: shim,\n\t objectOf: getShim,\n\t oneOf: getShim,\n\t oneOfType: getShim,\n\t shape: getShim\n\t };\n\n\t ReactPropTypes.checkPropTypes = emptyFunction;\n\t ReactPropTypes.PropTypes = ReactPropTypes;\n\n\t return ReactPropTypes;\n\t};\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n\t\"use strict\";\n\n\t/**\n\t * Copyright (c) 2013-present, Facebook, Inc.\n\t * All rights reserved.\n\t *\n\t * This source code is licensed under the BSD-style license found in the\n\t * LICENSE file in the root directory of this source tree. An additional grant\n\t * of patent rights can be found in the PATENTS file in the same directory.\n\t *\n\t * \n\t */\n\n\tfunction makeEmptyFunction(arg) {\n\t return function () {\n\t return arg;\n\t };\n\t}\n\n\t/**\n\t * This function accepts and discards inputs; it has no side effects. This is\n\t * primarily useful idiomatically for overridable function endpoints which\n\t * always need to be callable, since JS lacks a null-call idiom ala Cocoa.\n\t */\n\tvar emptyFunction = function emptyFunction() {};\n\n\temptyFunction.thatReturns = makeEmptyFunction;\n\temptyFunction.thatReturnsFalse = makeEmptyFunction(false);\n\temptyFunction.thatReturnsTrue = makeEmptyFunction(true);\n\temptyFunction.thatReturnsNull = makeEmptyFunction(null);\n\temptyFunction.thatReturnsThis = function () {\n\t return this;\n\t};\n\temptyFunction.thatReturnsArgument = function (arg) {\n\t return arg;\n\t};\n\n\tmodule.exports = emptyFunction;\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/**\n\t * Copyright (c) 2013-present, Facebook, Inc.\n\t * All rights reserved.\n\t *\n\t * This source code is licensed under the BSD-style license found in the\n\t * LICENSE file in the root directory of this source tree. An additional grant\n\t * of patent rights can be found in the PATENTS file in the same directory.\n\t *\n\t */\n\n\t'use strict';\n\n\t/**\n\t * Use invariant() to assert state which your program assumes to be true.\n\t *\n\t * Provide sprintf-style format (only %s is supported) and arguments\n\t * to provide information about what broke and what you were\n\t * expecting.\n\t *\n\t * The invariant message will be stripped in production, but the invariant\n\t * will remain to ensure logic does not differ in production.\n\t */\n\n\tvar validateFormat = function validateFormat(format) {};\n\n\tif (false) {\n\t validateFormat = function validateFormat(format) {\n\t if (format === undefined) {\n\t throw new Error('invariant requires an error message argument');\n\t }\n\t };\n\t}\n\n\tfunction invariant(condition, format, a, b, c, d, e, f) {\n\t validateFormat(format);\n\n\t if (!condition) {\n\t var error;\n\t if (format === undefined) {\n\t error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');\n\t } else {\n\t var args = [a, b, c, d, e, f];\n\t var argIndex = 0;\n\t error = new Error(format.replace(/%s/g, function () {\n\t return args[argIndex++];\n\t }));\n\t error.name = 'Invariant Violation';\n\t }\n\n\t error.framesToPop = 1; // we don't care about invariant's own frame\n\t throw error;\n\t }\n\t}\n\n\tmodule.exports = invariant;\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports) {\n\n\t/**\n\t * Copyright 2013-present, Facebook, Inc.\n\t * All rights reserved.\n\t *\n\t * This source code is licensed under the BSD-style license found in the\n\t * LICENSE file in the root directory of this source tree. An additional grant\n\t * of patent rights can be found in the PATENTS file in the same directory.\n\t */\n\n\t'use strict';\n\n\tvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\n\tmodule.exports = ReactPropTypesSecret;\n\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tfunction generateYears(year, noOfYear, minDate, maxDate) {\n\t var list = [];\n\t for (var i = 0; i < 2 * noOfYear + 1; i++) {\n\t var newYear = year + noOfYear - i;\n\t var isInRange = true;\n\n\t if (minDate) {\n\t isInRange = minDate.year() <= newYear;\n\t }\n\n\t if (maxDate && isInRange) {\n\t isInRange = maxDate.year() >= newYear;\n\t }\n\n\t if (isInRange) {\n\t list.push(newYear);\n\t }\n\t }\n\n\t return list;\n\t}\n\n\tvar YearDropdownOptions = function (_React$Component) {\n\t _inherits(YearDropdownOptions, _React$Component);\n\n\t function YearDropdownOptions(props) {\n\t _classCallCheck(this, YearDropdownOptions);\n\n\t var _this = _possibleConstructorReturn(this, (YearDropdownOptions.__proto__ || Object.getPrototypeOf(YearDropdownOptions)).call(this, props));\n\n\t _this.renderOptions = function () {\n\t var selectedYear = _this.props.year;\n\t var options = _this.state.yearsList.map(function (year) {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__year-option',\n\t key: year,\n\t ref: year,\n\t onClick: _this.onChange.bind(_this, year) },\n\t selectedYear === year ? _react2.default.createElement(\n\t 'span',\n\t { className: 'react-datepicker__year-option--selected' },\n\t '\\u2713'\n\t ) : '',\n\t year\n\t );\n\t });\n\n\t var minYear = _this.props.minDate ? _this.props.minDate.year() : null;\n\t var maxYear = _this.props.maxDate ? _this.props.maxDate.year() : null;\n\n\t if (!maxYear || !_this.state.yearsList.find(function (year) {\n\t return year === maxYear;\n\t })) {\n\t options.unshift(_react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__year-option',\n\t ref: 'upcoming',\n\t key: 'upcoming',\n\t onClick: _this.incrementYears },\n\t _react2.default.createElement('a', { className: 'react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-upcoming' })\n\t ));\n\t }\n\n\t if (!minYear || !_this.state.yearsList.find(function (year) {\n\t return year === minYear;\n\t })) {\n\t options.push(_react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__year-option',\n\t ref: 'previous',\n\t key: 'previous',\n\t onClick: _this.decrementYears },\n\t _react2.default.createElement('a', { className: 'react-datepicker__navigation react-datepicker__navigation--years react-datepicker__navigation--years-previous' })\n\t ));\n\t }\n\n\t return options;\n\t };\n\n\t _this.onChange = function (year) {\n\t _this.props.onChange(year);\n\t };\n\n\t _this.handleClickOutside = function () {\n\t _this.props.onCancel();\n\t };\n\n\t _this.shiftYears = function (amount) {\n\t var years = _this.state.yearsList.map(function (year) {\n\t return year + amount;\n\t });\n\n\t _this.setState({\n\t yearsList: years\n\t });\n\t };\n\n\t _this.incrementYears = function () {\n\t return _this.shiftYears(1);\n\t };\n\n\t _this.decrementYears = function () {\n\t return _this.shiftYears(-1);\n\t };\n\n\t var yearDropdownItemNumber = props.yearDropdownItemNumber,\n\t scrollableYearDropdown = props.scrollableYearDropdown;\n\n\t var noOfYear = yearDropdownItemNumber || (scrollableYearDropdown ? 10 : 5);\n\n\t _this.state = {\n\t yearsList: generateYears(_this.props.year, noOfYear, _this.props.minDate, _this.props.maxDate)\n\t };\n\t return _this;\n\t }\n\n\t _createClass(YearDropdownOptions, [{\n\t key: 'render',\n\t value: function render() {\n\t var dropdownClass = (0, _classnames2.default)({\n\t 'react-datepicker__year-dropdown': true,\n\t 'react-datepicker__year-dropdown--scrollable': this.props.scrollableYearDropdown\n\t });\n\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: dropdownClass },\n\t this.renderOptions()\n\t );\n\t }\n\t }]);\n\n\t return YearDropdownOptions;\n\t}(_react2.default.Component);\n\n\tYearDropdownOptions.propTypes = {\n\t minDate: _propTypes2.default.object,\n\t maxDate: _propTypes2.default.object,\n\t onCancel: _propTypes2.default.func.isRequired,\n\t onChange: _propTypes2.default.func.isRequired,\n\t scrollableYearDropdown: _propTypes2.default.bool,\n\t year: _propTypes2.default.number.isRequired,\n\t yearDropdownItemNumber: _propTypes2.default.number\n\t};\n\texports.default = YearDropdownOptions;\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!\n\t Copyright (c) 2016 Jed Watson.\n\t Licensed under the MIT License (MIT), see\n\t http://jedwatson.github.io/classnames\n\t*/\n\t/* global define */\n\n\t(function () {\n\t\t'use strict';\n\n\t\tvar hasOwn = {}.hasOwnProperty;\n\n\t\tfunction classNames () {\n\t\t\tvar classes = [];\n\n\t\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\t\tvar arg = arguments[i];\n\t\t\t\tif (!arg) continue;\n\n\t\t\t\tvar argType = typeof arg;\n\n\t\t\t\tif (argType === 'string' || argType === 'number') {\n\t\t\t\t\tclasses.push(arg);\n\t\t\t\t} else if (Array.isArray(arg)) {\n\t\t\t\t\tclasses.push(classNames.apply(null, arg));\n\t\t\t\t} else if (argType === 'object') {\n\t\t\t\t\tfor (var key in arg) {\n\t\t\t\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\t\t\t\tclasses.push(key);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn classes.join(' ');\n\t\t}\n\n\t\tif (typeof module !== 'undefined' && module.exports) {\n\t\t\tmodule.exports = classNames;\n\t\t} else if (true) {\n\t\t\t// register as 'classnames', consistent with npm package name\n\t\t\t!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {\n\t\t\t\treturn classNames;\n\t\t\t}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n\t\t} else {\n\t\t\twindow.classNames = classNames;\n\t\t}\n\t}());\n\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_11__;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.newDate = newDate;\n\texports.newDateWithOffset = newDateWithOffset;\n\texports.now = now;\n\texports.cloneDate = cloneDate;\n\texports.parseDate = parseDate;\n\texports.isMoment = isMoment;\n\texports.isDate = isDate;\n\texports.formatDate = formatDate;\n\texports.safeDateFormat = safeDateFormat;\n\texports.setTime = setTime;\n\texports.setMonth = setMonth;\n\texports.setYear = setYear;\n\texports.setUTCOffset = setUTCOffset;\n\texports.getSecond = getSecond;\n\texports.getMinute = getMinute;\n\texports.getHour = getHour;\n\texports.getDay = getDay;\n\texports.getWeek = getWeek;\n\texports.getMonth = getMonth;\n\texports.getYear = getYear;\n\texports.getDate = getDate;\n\texports.getUTCOffset = getUTCOffset;\n\texports.getDayOfWeekCode = getDayOfWeekCode;\n\texports.getStartOfDay = getStartOfDay;\n\texports.getStartOfWeek = getStartOfWeek;\n\texports.getStartOfMonth = getStartOfMonth;\n\texports.getStartOfDate = getStartOfDate;\n\texports.getEndOfWeek = getEndOfWeek;\n\texports.getEndOfMonth = getEndOfMonth;\n\texports.addMinutes = addMinutes;\n\texports.addDays = addDays;\n\texports.addWeeks = addWeeks;\n\texports.addMonths = addMonths;\n\texports.addYears = addYears;\n\texports.subtractDays = subtractDays;\n\texports.subtractWeeks = subtractWeeks;\n\texports.subtractMonths = subtractMonths;\n\texports.subtractYears = subtractYears;\n\texports.isBefore = isBefore;\n\texports.isAfter = isAfter;\n\texports.equals = equals;\n\texports.isSameMonth = isSameMonth;\n\texports.isSameDay = isSameDay;\n\texports.isSameUtcOffset = isSameUtcOffset;\n\texports.isDayInRange = isDayInRange;\n\texports.getDaysDiff = getDaysDiff;\n\texports.localizeDate = localizeDate;\n\texports.getDefaultLocale = getDefaultLocale;\n\texports.getDefaultLocaleData = getDefaultLocaleData;\n\texports.registerLocale = registerLocale;\n\texports.getLocaleData = getLocaleData;\n\texports.getLocaleDataForLocale = getLocaleDataForLocale;\n\texports.getWeekdayMinInLocale = getWeekdayMinInLocale;\n\texports.getWeekdayShortInLocale = getWeekdayShortInLocale;\n\texports.getMonthInLocale = getMonthInLocale;\n\texports.isDayDisabled = isDayDisabled;\n\texports.isTimeDisabled = isTimeDisabled;\n\texports.isTimeInDisabledRange = isTimeInDisabledRange;\n\texports.allDaysDisabledBefore = allDaysDisabledBefore;\n\texports.allDaysDisabledAfter = allDaysDisabledAfter;\n\texports.getEffectiveMinDate = getEffectiveMinDate;\n\texports.getEffectiveMaxDate = getEffectiveMaxDate;\n\n\tvar _moment = __webpack_require__(13);\n\n\tvar _moment2 = _interopRequireDefault(_moment);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tvar dayOfWeekCodes = {\n\t 1: 'mon',\n\t 2: 'tue',\n\t 3: 'wed',\n\t 4: 'thu',\n\t 5: 'fri',\n\t 6: 'sat',\n\t 7: 'sun'\n\n\t // These functions are not exported so\n\t // that we avoid magic strings like 'days'\n\t};function set(date, unit, to) {\n\t return date.set(unit, to);\n\t}\n\n\tfunction add(date, amount, unit) {\n\t return date.add(amount, unit);\n\t}\n\n\tfunction subtract(date, amount, unit) {\n\t return date.subtract(amount, unit);\n\t}\n\n\tfunction get(date, unit) {\n\t return date.get(unit);\n\t}\n\n\tfunction getStartOf(date, unit) {\n\t return date.startOf(unit);\n\t}\n\n\tfunction getEndOf(date, unit) {\n\t return date.endOf(unit);\n\t}\n\n\tfunction getDiff(date1, date2, unit) {\n\t return date1.diff(date2, unit);\n\t}\n\n\tfunction isSame(date1, date2, unit) {\n\t return date1.isSame(date2, unit);\n\t}\n\n\t// ** Date Constructors **\n\n\tfunction newDate(point) {\n\t return (0, _moment2.default)(point);\n\t}\n\n\tfunction newDateWithOffset(utcOffset) {\n\t return (0, _moment2.default)().utc().utcOffset(utcOffset);\n\t}\n\n\tfunction now(maybeFixedUtcOffset) {\n\t if (maybeFixedUtcOffset == null) {\n\t return newDate();\n\t }\n\t return newDateWithOffset(maybeFixedUtcOffset);\n\t}\n\n\tfunction cloneDate(date) {\n\t return date.clone();\n\t}\n\n\tfunction parseDate(value, _ref) {\n\t var dateFormat = _ref.dateFormat,\n\t locale = _ref.locale;\n\n\t var m = (0, _moment2.default)(value, dateFormat, locale || _moment2.default.locale(), true);\n\t return m.isValid() ? m : null;\n\t}\n\n\t// ** Date \"Reflection\" **\n\n\tfunction isMoment(date) {\n\t return _moment2.default.isMoment(date);\n\t}\n\n\tfunction isDate(date) {\n\t return _moment2.default.isDate(date);\n\t}\n\n\t// ** Date Formatting **\n\n\tfunction formatDate(date, format) {\n\t return date.format(format);\n\t}\n\n\tfunction safeDateFormat(date, _ref2) {\n\t var dateFormat = _ref2.dateFormat,\n\t locale = _ref2.locale;\n\n\t return date && date.clone().locale(locale || _moment2.default.locale()).format(Array.isArray(dateFormat) ? dateFormat[0] : dateFormat) || '';\n\t}\n\n\t// ** Date Setters **\n\n\tfunction setTime(date, _ref3) {\n\t var hour = _ref3.hour,\n\t minute = _ref3.minute,\n\t second = _ref3.second;\n\n\t date.set({ hour: hour, minute: minute, second: second });\n\t return date;\n\t}\n\n\tfunction setMonth(date, month) {\n\t return set(date, 'month', month);\n\t}\n\n\tfunction setYear(date, year) {\n\t return set(date, 'year', year);\n\t}\n\n\tfunction setUTCOffset(date, offset) {\n\t return date.utcOffset(offset);\n\t}\n\n\t// ** Date Getters **\n\n\tfunction getSecond(date) {\n\t return get(date, 'second');\n\t}\n\n\tfunction getMinute(date) {\n\t return get(date, 'minute');\n\t}\n\n\tfunction getHour(date) {\n\t return get(date, 'hour');\n\t}\n\n\t// Returns day of week\n\tfunction getDay(date) {\n\t return get(date, 'day');\n\t}\n\n\tfunction getWeek(date) {\n\t return get(date, 'week');\n\t}\n\n\tfunction getMonth(date) {\n\t return get(date, 'month');\n\t}\n\n\tfunction getYear(date) {\n\t return get(date, 'year');\n\t}\n\n\t// Returns day of month\n\tfunction getDate(date) {\n\t return get(date, 'date');\n\t}\n\n\tfunction getUTCOffset() {\n\t return (0, _moment2.default)().utcOffset();\n\t}\n\n\tfunction getDayOfWeekCode(day) {\n\t return dayOfWeekCodes[day.isoWeekday()];\n\t}\n\n\t// *** Start of ***\n\n\tfunction getStartOfDay(date) {\n\t return getStartOf(date, 'day');\n\t}\n\n\tfunction getStartOfWeek(date) {\n\t return getStartOf(date, 'week');\n\t}\n\tfunction getStartOfMonth(date) {\n\t return getStartOf(date, 'month');\n\t}\n\n\tfunction getStartOfDate(date) {\n\t return getStartOf(date, 'date');\n\t}\n\n\t// *** End of ***\n\n\tfunction getEndOfWeek(date) {\n\t return getEndOf(date, 'week');\n\t}\n\n\tfunction getEndOfMonth(date) {\n\t return getEndOf(date, 'month');\n\t}\n\n\t// ** Date Math **\n\n\t// *** Addition ***\n\n\tfunction addMinutes(date, amount) {\n\t return add(date, amount, 'minutes');\n\t}\n\n\tfunction addDays(date, amount) {\n\t return add(date, amount, 'days');\n\t}\n\n\tfunction addWeeks(date, amount) {\n\t return add(date, amount, 'weeks');\n\t}\n\n\tfunction addMonths(date, amount) {\n\t return add(date, amount, 'months');\n\t}\n\n\tfunction addYears(date, amount) {\n\t return add(date, amount, 'years');\n\t}\n\n\t// *** Subtraction ***\n\tfunction subtractDays(date, amount) {\n\t return subtract(date, amount, 'days');\n\t}\n\n\tfunction subtractWeeks(date, amount) {\n\t return subtract(date, amount, 'weeks');\n\t}\n\n\tfunction subtractMonths(date, amount) {\n\t return subtract(date, amount, 'months');\n\t}\n\n\tfunction subtractYears(date, amount) {\n\t return subtract(date, amount, 'years');\n\t}\n\n\t// ** Date Comparison **\n\n\tfunction isBefore(date1, date2) {\n\t return date1.isBefore(date2);\n\t}\n\n\tfunction isAfter(date1, date2) {\n\t return date1.isAfter(date2);\n\t}\n\n\tfunction equals(date1, date2) {\n\t return date1.isSame(date2);\n\t}\n\n\tfunction isSameMonth(date1, date2) {\n\t return isSame(date1, date2, 'month');\n\t}\n\n\tfunction isSameDay(moment1, moment2) {\n\t if (moment1 && moment2) {\n\t return moment1.isSame(moment2, 'day');\n\t } else {\n\t return !moment1 && !moment2;\n\t }\n\t}\n\n\tfunction isSameUtcOffset(moment1, moment2) {\n\t if (moment1 && moment2) {\n\t return moment1.utcOffset() === moment2.utcOffset();\n\t } else {\n\t return !moment1 && !moment2;\n\t }\n\t}\n\n\tfunction isDayInRange(day, startDate, endDate) {\n\t var before = startDate.clone().startOf('day').subtract(1, 'seconds');\n\t var after = endDate.clone().startOf('day').add(1, 'seconds');\n\t return day.clone().startOf('day').isBetween(before, after);\n\t}\n\n\t// *** Diffing ***\n\n\tfunction getDaysDiff(date1, date2) {\n\t return getDiff(date1, date2, 'days');\n\t}\n\n\t// ** Date Localization **\n\n\tfunction localizeDate(date, locale) {\n\t return date.clone().locale(locale || _moment2.default.locale());\n\t}\n\n\tfunction getDefaultLocale() {\n\t return _moment2.default.locale();\n\t}\n\n\tfunction getDefaultLocaleData() {\n\t return _moment2.default.localeData();\n\t}\n\n\tfunction registerLocale(localeName, localeData) {\n\t _moment2.default.defineLocale(localeName, localeData);\n\t}\n\n\tfunction getLocaleData(date) {\n\t return date.localeData();\n\t}\n\n\tfunction getLocaleDataForLocale(locale) {\n\t return _moment2.default.localeData(locale);\n\t}\n\n\tfunction getWeekdayMinInLocale(locale, date) {\n\t return locale.weekdaysMin(date);\n\t}\n\n\tfunction getWeekdayShortInLocale(locale, date) {\n\t return locale.weekdaysShort(date);\n\t}\n\n\t// TODO what is this format exactly?\n\tfunction getMonthInLocale(locale, date, format) {\n\t return locale.months(date, format);\n\t}\n\n\t// ** Utils for some components **\n\n\tfunction isDayDisabled(day) {\n\t var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n\t minDate = _ref4.minDate,\n\t maxDate = _ref4.maxDate,\n\t excludeDates = _ref4.excludeDates,\n\t includeDates = _ref4.includeDates,\n\t filterDate = _ref4.filterDate;\n\n\t return minDate && day.isBefore(minDate, 'day') || maxDate && day.isAfter(maxDate, 'day') || excludeDates && excludeDates.some(function (excludeDate) {\n\t return isSameDay(day, excludeDate);\n\t }) || includeDates && !includeDates.some(function (includeDate) {\n\t return isSameDay(day, includeDate);\n\t }) || filterDate && !filterDate(day.clone()) || false;\n\t}\n\n\tfunction isTimeDisabled(time, disabledTimes) {\n\t var l = disabledTimes.length;\n\t for (var i = 0; i < l; i++) {\n\t if (disabledTimes[i].get('hours') === time.get('hours') && disabledTimes[i].get('minutes') === time.get('minutes')) {\n\t return true;\n\t }\n\t }\n\n\t return false;\n\t}\n\n\tfunction isTimeInDisabledRange(time, _ref5) {\n\t var minTime = _ref5.minTime,\n\t maxTime = _ref5.maxTime;\n\n\t if (!minTime || !maxTime) {\n\t throw new Error('Both minTime and maxTime props required');\n\t }\n\n\t var base = (0, _moment2.default)().hours(0).minutes(0).seconds(0);\n\t var baseTime = base.clone().hours(time.get('hours')).minutes(time.get('minutes'));\n\t var min = base.clone().hours(minTime.get('hours')).minutes(minTime.get('minutes'));\n\t var max = base.clone().hours(maxTime.get('hours')).minutes(maxTime.get('minutes'));\n\n\t return !(baseTime.isSameOrAfter(min) && baseTime.isSameOrBefore(max));\n\t}\n\n\tfunction allDaysDisabledBefore(day, unit) {\n\t var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},\n\t minDate = _ref6.minDate,\n\t includeDates = _ref6.includeDates;\n\n\t var dateBefore = day.clone().subtract(1, unit);\n\t return minDate && dateBefore.isBefore(minDate, unit) || includeDates && includeDates.every(function (includeDate) {\n\t return dateBefore.isBefore(includeDate, unit);\n\t }) || false;\n\t}\n\n\tfunction allDaysDisabledAfter(day, unit) {\n\t var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},\n\t maxDate = _ref7.maxDate,\n\t includeDates = _ref7.includeDates;\n\n\t var dateAfter = day.clone().add(1, unit);\n\t return maxDate && dateAfter.isAfter(maxDate, unit) || includeDates && includeDates.every(function (includeDate) {\n\t return dateAfter.isAfter(includeDate, unit);\n\t }) || false;\n\t}\n\n\tfunction getEffectiveMinDate(_ref8) {\n\t var minDate = _ref8.minDate,\n\t includeDates = _ref8.includeDates;\n\n\t if (includeDates && minDate) {\n\t return _moment2.default.min(includeDates.filter(function (includeDate) {\n\t return minDate.isSameOrBefore(includeDate, 'day');\n\t }));\n\t } else if (includeDates) {\n\t return _moment2.default.min(includeDates);\n\t } else {\n\t return minDate;\n\t }\n\t}\n\n\tfunction getEffectiveMaxDate(_ref9) {\n\t var maxDate = _ref9.maxDate,\n\t includeDates = _ref9.includeDates;\n\n\t if (includeDates && maxDate) {\n\t return _moment2.default.max(includeDates.filter(function (includeDate) {\n\t return maxDate.isSameOrAfter(includeDate, 'day');\n\t }));\n\t } else if (includeDates) {\n\t return _moment2.default.max(includeDates);\n\t } else {\n\t return maxDate;\n\t }\n\t}\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_13__;\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _month_dropdown_options = __webpack_require__(15);\n\n\tvar _month_dropdown_options2 = _interopRequireDefault(_month_dropdown_options);\n\n\tvar _reactOnclickoutside = __webpack_require__(11);\n\n\tvar _reactOnclickoutside2 = _interopRequireDefault(_reactOnclickoutside);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tvar utils = _interopRequireWildcard(_date_utils);\n\n\tfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar WrappedMonthDropdownOptions = (0, _reactOnclickoutside2.default)(_month_dropdown_options2.default);\n\n\tvar MonthDropdown = function (_React$Component) {\n\t _inherits(MonthDropdown, _React$Component);\n\n\t function MonthDropdown() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, MonthDropdown);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = MonthDropdown.__proto__ || Object.getPrototypeOf(MonthDropdown)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n\t dropdownVisible: false\n\t }, _this.renderSelectOptions = function (monthNames) {\n\t return monthNames.map(function (M, i) {\n\t return _react2.default.createElement(\n\t 'option',\n\t { key: i, value: i },\n\t M\n\t );\n\t });\n\t }, _this.renderSelectMode = function (monthNames) {\n\t return _react2.default.createElement(\n\t 'select',\n\t { value: _this.props.month, className: 'react-datepicker__month-select', onChange: function onChange(e) {\n\t return _this.onChange(e.target.value);\n\t } },\n\t _this.renderSelectOptions(monthNames)\n\t );\n\t }, _this.renderReadView = function (visible, monthNames) {\n\t return _react2.default.createElement(\n\t 'div',\n\t { key: 'read', style: { visibility: visible ? 'visible' : 'hidden' }, className: 'react-datepicker__month-read-view', onClick: _this.toggleDropdown },\n\t _react2.default.createElement(\n\t 'span',\n\t { className: 'react-datepicker__month-read-view--selected-month' },\n\t monthNames[_this.props.month]\n\t ),\n\t _react2.default.createElement('span', { className: 'react-datepicker__month-read-view--down-arrow' })\n\t );\n\t }, _this.renderDropdown = function (monthNames) {\n\t return _react2.default.createElement(WrappedMonthDropdownOptions, {\n\t key: 'dropdown',\n\t ref: 'options',\n\t month: _this.props.month,\n\t monthNames: monthNames,\n\t onChange: _this.onChange,\n\t onCancel: _this.toggleDropdown });\n\t }, _this.renderScrollMode = function (monthNames) {\n\t var dropdownVisible = _this.state.dropdownVisible;\n\n\t var result = [_this.renderReadView(!dropdownVisible, monthNames)];\n\t if (dropdownVisible) {\n\t result.unshift(_this.renderDropdown(monthNames));\n\t }\n\t return result;\n\t }, _this.onChange = function (month) {\n\t _this.toggleDropdown();\n\t if (month !== _this.props.month) {\n\t _this.props.onChange(month);\n\t }\n\t }, _this.toggleDropdown = function () {\n\t return _this.setState({\n\t dropdownVisible: !_this.state.dropdownVisible\n\t });\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(MonthDropdown, [{\n\t key: 'render',\n\t value: function render() {\n\t var _this2 = this;\n\n\t var localeData = utils.getLocaleDataForLocale(this.props.locale);\n\t var monthNames = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(function (M) {\n\t return utils.getMonthInLocale(localeData, utils.newDate({ M: M }), _this2.props.dateFormat);\n\t });\n\n\t var renderedDropdown = void 0;\n\t switch (this.props.dropdownMode) {\n\t case 'scroll':\n\t renderedDropdown = this.renderScrollMode(monthNames);\n\t break;\n\t case 'select':\n\t renderedDropdown = this.renderSelectMode(monthNames);\n\t break;\n\t }\n\n\t return _react2.default.createElement(\n\t 'div',\n\t {\n\t className: 'react-datepicker__month-dropdown-container react-datepicker__month-dropdown-container--' + this.props.dropdownMode },\n\t renderedDropdown\n\t );\n\t }\n\t }]);\n\n\t return MonthDropdown;\n\t}(_react2.default.Component);\n\n\tMonthDropdown.propTypes = {\n\t dropdownMode: _propTypes2.default.oneOf(['scroll', 'select']).isRequired,\n\t locale: _propTypes2.default.string,\n\t dateFormat: _propTypes2.default.string.isRequired,\n\t month: _propTypes2.default.number.isRequired,\n\t onChange: _propTypes2.default.func.isRequired\n\t};\n\texports.default = MonthDropdown;\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar MonthDropdownOptions = function (_React$Component) {\n\t _inherits(MonthDropdownOptions, _React$Component);\n\n\t function MonthDropdownOptions() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, MonthDropdownOptions);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = MonthDropdownOptions.__proto__ || Object.getPrototypeOf(MonthDropdownOptions)).call.apply(_ref, [this].concat(args))), _this), _this.renderOptions = function () {\n\t return _this.props.monthNames.map(function (month, i) {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__month-option',\n\t key: month,\n\t ref: month,\n\t onClick: _this.onChange.bind(_this, i) },\n\t _this.props.month === i ? _react2.default.createElement(\n\t 'span',\n\t { className: 'react-datepicker__month-option--selected' },\n\t '\\u2713'\n\t ) : '',\n\t month\n\t );\n\t });\n\t }, _this.onChange = function (month) {\n\t return _this.props.onChange(month);\n\t }, _this.handleClickOutside = function () {\n\t return _this.props.onCancel();\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(MonthDropdownOptions, [{\n\t key: 'render',\n\t value: function render() {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__month-dropdown' },\n\t this.renderOptions()\n\t );\n\t }\n\t }]);\n\n\t return MonthDropdownOptions;\n\t}(_react2.default.Component);\n\n\tMonthDropdownOptions.propTypes = {\n\t onCancel: _propTypes2.default.func.isRequired,\n\t onChange: _propTypes2.default.func.isRequired,\n\t month: _propTypes2.default.number.isRequired,\n\t monthNames: _propTypes2.default.arrayOf(_propTypes2.default.string.isRequired).isRequired\n\t};\n\texports.default = MonthDropdownOptions;\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tvar _week = __webpack_require__(17);\n\n\tvar _week2 = _interopRequireDefault(_week);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tvar utils = _interopRequireWildcard(_date_utils);\n\n\tfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar FIXED_HEIGHT_STANDARD_WEEK_COUNT = 6;\n\n\tvar Month = function (_React$Component) {\n\t _inherits(Month, _React$Component);\n\n\t function Month() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Month);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Month.__proto__ || Object.getPrototypeOf(Month)).call.apply(_ref, [this].concat(args))), _this), _this.handleDayClick = function (day, event) {\n\t if (_this.props.onDayClick) {\n\t _this.props.onDayClick(day, event);\n\t }\n\t }, _this.handleDayMouseEnter = function (day) {\n\t if (_this.props.onDayMouseEnter) {\n\t _this.props.onDayMouseEnter(day);\n\t }\n\t }, _this.handleMouseLeave = function () {\n\t if (_this.props.onMouseLeave) {\n\t _this.props.onMouseLeave();\n\t }\n\t }, _this.isWeekInMonth = function (startOfWeek) {\n\t var day = _this.props.day;\n\t var endOfWeek = utils.addDays(utils.cloneDate(startOfWeek), 6);\n\t return utils.isSameMonth(startOfWeek, day) || utils.isSameMonth(endOfWeek, day);\n\t }, _this.renderWeeks = function () {\n\t var weeks = [];\n\t var isFixedHeight = _this.props.fixedHeight;\n\t var currentWeekStart = utils.getStartOfWeek(utils.getStartOfMonth(utils.cloneDate(_this.props.day)));\n\t var i = 0;\n\t var breakAfterNextPush = false;\n\n\t while (true) {\n\t weeks.push(_react2.default.createElement(_week2.default, {\n\t key: i,\n\t day: currentWeekStart,\n\t month: utils.getMonth(_this.props.day),\n\t onDayClick: _this.handleDayClick,\n\t onDayMouseEnter: _this.handleDayMouseEnter,\n\t onWeekSelect: _this.props.onWeekSelect,\n\t formatWeekNumber: _this.props.formatWeekNumber,\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t excludeDates: _this.props.excludeDates,\n\t includeDates: _this.props.includeDates,\n\t inline: _this.props.inline,\n\t highlightDates: _this.props.highlightDates,\n\t selectingDate: _this.props.selectingDate,\n\t filterDate: _this.props.filterDate,\n\t preSelection: _this.props.preSelection,\n\t selected: _this.props.selected,\n\t selectsStart: _this.props.selectsStart,\n\t selectsEnd: _this.props.selectsEnd,\n\t showWeekNumber: _this.props.showWeekNumbers,\n\t startDate: _this.props.startDate,\n\t endDate: _this.props.endDate,\n\t dayClassName: _this.props.dayClassName,\n\t utcOffset: _this.props.utcOffset }));\n\n\t if (breakAfterNextPush) break;\n\n\t i++;\n\t currentWeekStart = utils.addWeeks(utils.cloneDate(currentWeekStart), 1);\n\n\t // If one of these conditions is true, we will either break on this week\n\t // or break on the next week\n\t var isFixedAndFinalWeek = isFixedHeight && i >= FIXED_HEIGHT_STANDARD_WEEK_COUNT;\n\t var isNonFixedAndOutOfMonth = !isFixedHeight && !_this.isWeekInMonth(currentWeekStart);\n\n\t if (isFixedAndFinalWeek || isNonFixedAndOutOfMonth) {\n\t if (_this.props.peekNextMonth) {\n\t breakAfterNextPush = true;\n\t } else {\n\t break;\n\t }\n\t }\n\t }\n\n\t return weeks;\n\t }, _this.getClassNames = function () {\n\t var _this$props = _this.props,\n\t selectingDate = _this$props.selectingDate,\n\t selectsStart = _this$props.selectsStart,\n\t selectsEnd = _this$props.selectsEnd;\n\n\t return (0, _classnames2.default)('react-datepicker__month', {\n\t 'react-datepicker__month--selecting-range': selectingDate && (selectsStart || selectsEnd)\n\t });\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Month, [{\n\t key: 'render',\n\t value: function render() {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: this.getClassNames(), onMouseLeave: this.handleMouseLeave, role: 'listbox' },\n\t this.renderWeeks()\n\t );\n\t }\n\t }]);\n\n\t return Month;\n\t}(_react2.default.Component);\n\n\tMonth.propTypes = {\n\t day: _propTypes2.default.object.isRequired,\n\t dayClassName: _propTypes2.default.func,\n\t endDate: _propTypes2.default.object,\n\t excludeDates: _propTypes2.default.array,\n\t filterDate: _propTypes2.default.func,\n\t fixedHeight: _propTypes2.default.bool,\n\t formatWeekNumber: _propTypes2.default.func,\n\t highlightDates: _propTypes2.default.array,\n\t includeDates: _propTypes2.default.array,\n\t inline: _propTypes2.default.bool,\n\t maxDate: _propTypes2.default.object,\n\t minDate: _propTypes2.default.object,\n\t onDayClick: _propTypes2.default.func,\n\t onDayMouseEnter: _propTypes2.default.func,\n\t onMouseLeave: _propTypes2.default.func,\n\t onWeekSelect: _propTypes2.default.func,\n\t peekNextMonth: _propTypes2.default.bool,\n\t preSelection: _propTypes2.default.object,\n\t selected: _propTypes2.default.object,\n\t selectingDate: _propTypes2.default.object,\n\t selectsEnd: _propTypes2.default.bool,\n\t selectsStart: _propTypes2.default.bool,\n\t showWeekNumbers: _propTypes2.default.bool,\n\t startDate: _propTypes2.default.object,\n\t utcOffset: _propTypes2.default.number\n\t};\n\texports.default = Month;\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _day = __webpack_require__(18);\n\n\tvar _day2 = _interopRequireDefault(_day);\n\n\tvar _week_number = __webpack_require__(19);\n\n\tvar _week_number2 = _interopRequireDefault(_week_number);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tvar utils = _interopRequireWildcard(_date_utils);\n\n\tfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar Week = function (_React$Component) {\n\t _inherits(Week, _React$Component);\n\n\t function Week() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Week);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Week.__proto__ || Object.getPrototypeOf(Week)).call.apply(_ref, [this].concat(args))), _this), _this.handleDayClick = function (day, event) {\n\t if (_this.props.onDayClick) {\n\t _this.props.onDayClick(day, event);\n\t }\n\t }, _this.handleDayMouseEnter = function (day) {\n\t if (_this.props.onDayMouseEnter) {\n\t _this.props.onDayMouseEnter(day);\n\t }\n\t }, _this.handleWeekClick = function (day, weekNumber, event) {\n\t if (typeof _this.props.onWeekSelect === 'function') {\n\t _this.props.onWeekSelect(day, weekNumber, event);\n\t }\n\t }, _this.formatWeekNumber = function (startOfWeek) {\n\t if (_this.props.formatWeekNumber) {\n\t return _this.props.formatWeekNumber(startOfWeek);\n\t }\n\t return utils.getWeek(startOfWeek);\n\t }, _this.renderDays = function () {\n\t var startOfWeek = utils.getStartOfWeek(utils.cloneDate(_this.props.day));\n\t var days = [];\n\t var weekNumber = _this.formatWeekNumber(startOfWeek);\n\t if (_this.props.showWeekNumber) {\n\t var onClickAction = _this.props.onWeekSelect ? _this.handleWeekClick.bind(_this, startOfWeek, weekNumber) : undefined;\n\t days.push(_react2.default.createElement(_week_number2.default, { key: 'W', weekNumber: weekNumber, onClick: onClickAction }));\n\t }\n\t return days.concat([0, 1, 2, 3, 4, 5, 6].map(function (offset) {\n\t var day = utils.addDays(utils.cloneDate(startOfWeek), offset);\n\t return _react2.default.createElement(_day2.default, {\n\t key: offset,\n\t day: day,\n\t month: _this.props.month,\n\t onClick: _this.handleDayClick.bind(_this, day),\n\t onMouseEnter: _this.handleDayMouseEnter.bind(_this, day),\n\t minDate: _this.props.minDate,\n\t maxDate: _this.props.maxDate,\n\t excludeDates: _this.props.excludeDates,\n\t includeDates: _this.props.includeDates,\n\t inline: _this.props.inline,\n\t highlightDates: _this.props.highlightDates,\n\t selectingDate: _this.props.selectingDate,\n\t filterDate: _this.props.filterDate,\n\t preSelection: _this.props.preSelection,\n\t selected: _this.props.selected,\n\t selectsStart: _this.props.selectsStart,\n\t selectsEnd: _this.props.selectsEnd,\n\t startDate: _this.props.startDate,\n\t endDate: _this.props.endDate,\n\t dayClassName: _this.props.dayClassName,\n\t utcOffset: _this.props.utcOffset });\n\t }));\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Week, [{\n\t key: 'render',\n\t value: function render() {\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__week' },\n\t this.renderDays()\n\t );\n\t }\n\t }]);\n\n\t return Week;\n\t}(_react2.default.Component);\n\n\tWeek.propTypes = {\n\t day: _propTypes2.default.object.isRequired,\n\t dayClassName: _propTypes2.default.func,\n\t endDate: _propTypes2.default.object,\n\t excludeDates: _propTypes2.default.array,\n\t filterDate: _propTypes2.default.func,\n\t formatWeekNumber: _propTypes2.default.func,\n\t highlightDates: _propTypes2.default.array,\n\t includeDates: _propTypes2.default.array,\n\t inline: _propTypes2.default.bool,\n\t maxDate: _propTypes2.default.object,\n\t minDate: _propTypes2.default.object,\n\t month: _propTypes2.default.number,\n\t onDayClick: _propTypes2.default.func,\n\t onDayMouseEnter: _propTypes2.default.func,\n\t onWeekSelect: _propTypes2.default.func,\n\t preSelection: _propTypes2.default.object,\n\t selected: _propTypes2.default.object,\n\t selectingDate: _propTypes2.default.object,\n\t selectsEnd: _propTypes2.default.bool,\n\t selectsStart: _propTypes2.default.bool,\n\t showWeekNumber: _propTypes2.default.bool,\n\t startDate: _propTypes2.default.object,\n\t utcOffset: _propTypes2.default.number\n\t};\n\texports.default = Week;\n\n/***/ }),\n/* 18 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar Day = function (_React$Component) {\n\t _inherits(Day, _React$Component);\n\n\t function Day() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Day);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Day.__proto__ || Object.getPrototypeOf(Day)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) {\n\t if (!_this.isDisabled() && _this.props.onClick) {\n\t _this.props.onClick(event);\n\t }\n\t }, _this.handleMouseEnter = function (event) {\n\t if (!_this.isDisabled() && _this.props.onMouseEnter) {\n\t _this.props.onMouseEnter(event);\n\t }\n\t }, _this.isSameDay = function (other) {\n\t return (0, _date_utils.isSameDay)(_this.props.day, other);\n\t }, _this.isKeyboardSelected = function () {\n\t return !_this.props.inline && !_this.isSameDay(_this.props.selected) && _this.isSameDay(_this.props.preSelection);\n\t }, _this.isDisabled = function () {\n\t return (0, _date_utils.isDayDisabled)(_this.props.day, _this.props);\n\t }, _this.getHighLightedClass = function (defaultClassName) {\n\t var _this$props = _this.props,\n\t day = _this$props.day,\n\t highlightDates = _this$props.highlightDates;\n\n\n\t if (!highlightDates) {\n\t return _defineProperty({}, defaultClassName, false);\n\t }\n\n\t var classNames = {};\n\t for (var i = 0, len = highlightDates.length; i < len; i++) {\n\t var obj = highlightDates[i];\n\t if ((0, _date_utils.isMoment)(obj)) {\n\t if ((0, _date_utils.isSameDay)(day, obj)) {\n\t classNames[defaultClassName] = true;\n\t }\n\t } else if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object') {\n\t var keys = Object.keys(obj);\n\t var arr = obj[keys[0]];\n\t if (typeof keys[0] === 'string' && arr.constructor === Array) {\n\t for (var k = 0, _len2 = arr.length; k < _len2; k++) {\n\t if ((0, _date_utils.isSameDay)(day, arr[k])) {\n\t classNames[keys[0]] = true;\n\t }\n\t }\n\t }\n\t }\n\t }\n\n\t return classNames;\n\t }, _this.isInRange = function () {\n\t var _this$props2 = _this.props,\n\t day = _this$props2.day,\n\t startDate = _this$props2.startDate,\n\t endDate = _this$props2.endDate;\n\n\t if (!startDate || !endDate) {\n\t return false;\n\t }\n\t return (0, _date_utils.isDayInRange)(day, startDate, endDate);\n\t }, _this.isInSelectingRange = function () {\n\t var _this$props3 = _this.props,\n\t day = _this$props3.day,\n\t selectsStart = _this$props3.selectsStart,\n\t selectsEnd = _this$props3.selectsEnd,\n\t selectingDate = _this$props3.selectingDate,\n\t startDate = _this$props3.startDate,\n\t endDate = _this$props3.endDate;\n\n\n\t if (!(selectsStart || selectsEnd) || !selectingDate || _this.isDisabled()) {\n\t return false;\n\t }\n\n\t if (selectsStart && endDate && selectingDate.isSameOrBefore(endDate)) {\n\t return (0, _date_utils.isDayInRange)(day, selectingDate, endDate);\n\t }\n\n\t if (selectsEnd && startDate && selectingDate.isSameOrAfter(startDate)) {\n\t return (0, _date_utils.isDayInRange)(day, startDate, selectingDate);\n\t }\n\n\t return false;\n\t }, _this.isSelectingRangeStart = function () {\n\t if (!_this.isInSelectingRange()) {\n\t return false;\n\t }\n\n\t var _this$props4 = _this.props,\n\t day = _this$props4.day,\n\t selectingDate = _this$props4.selectingDate,\n\t startDate = _this$props4.startDate,\n\t selectsStart = _this$props4.selectsStart;\n\n\n\t if (selectsStart) {\n\t return (0, _date_utils.isSameDay)(day, selectingDate);\n\t } else {\n\t return (0, _date_utils.isSameDay)(day, startDate);\n\t }\n\t }, _this.isSelectingRangeEnd = function () {\n\t if (!_this.isInSelectingRange()) {\n\t return false;\n\t }\n\n\t var _this$props5 = _this.props,\n\t day = _this$props5.day,\n\t selectingDate = _this$props5.selectingDate,\n\t endDate = _this$props5.endDate,\n\t selectsEnd = _this$props5.selectsEnd;\n\n\n\t if (selectsEnd) {\n\t return (0, _date_utils.isSameDay)(day, selectingDate);\n\t } else {\n\t return (0, _date_utils.isSameDay)(day, endDate);\n\t }\n\t }, _this.isRangeStart = function () {\n\t var _this$props6 = _this.props,\n\t day = _this$props6.day,\n\t startDate = _this$props6.startDate,\n\t endDate = _this$props6.endDate;\n\n\t if (!startDate || !endDate) {\n\t return false;\n\t }\n\t return (0, _date_utils.isSameDay)(startDate, day);\n\t }, _this.isRangeEnd = function () {\n\t var _this$props7 = _this.props,\n\t day = _this$props7.day,\n\t startDate = _this$props7.startDate,\n\t endDate = _this$props7.endDate;\n\n\t if (!startDate || !endDate) {\n\t return false;\n\t }\n\t return (0, _date_utils.isSameDay)(endDate, day);\n\t }, _this.isWeekend = function () {\n\t var weekday = (0, _date_utils.getDay)(_this.props.day);\n\t return weekday === 0 || weekday === 6;\n\t }, _this.isOutsideMonth = function () {\n\t return _this.props.month !== undefined && _this.props.month !== (0, _date_utils.getMonth)(_this.props.day);\n\t }, _this.getClassNames = function (date) {\n\t var dayClassName = _this.props.dayClassName ? _this.props.dayClassName(date) : undefined;\n\t return (0, _classnames2.default)('react-datepicker__day', dayClassName, 'react-datepicker__day--' + (0, _date_utils.getDayOfWeekCode)(_this.props.day), {\n\t 'react-datepicker__day--disabled': _this.isDisabled(),\n\t 'react-datepicker__day--selected': _this.isSameDay(_this.props.selected),\n\t 'react-datepicker__day--keyboard-selected': _this.isKeyboardSelected(),\n\t 'react-datepicker__day--range-start': _this.isRangeStart(),\n\t 'react-datepicker__day--range-end': _this.isRangeEnd(),\n\t 'react-datepicker__day--in-range': _this.isInRange(),\n\t 'react-datepicker__day--in-selecting-range': _this.isInSelectingRange(),\n\t 'react-datepicker__day--selecting-range-start': _this.isSelectingRangeStart(),\n\t 'react-datepicker__day--selecting-range-end': _this.isSelectingRangeEnd(),\n\t 'react-datepicker__day--today': _this.isSameDay((0, _date_utils.now)(_this.props.utcOffset)),\n\t 'react-datepicker__day--weekend': _this.isWeekend(),\n\t 'react-datepicker__day--outside-month': _this.isOutsideMonth()\n\t }, _this.getHighLightedClass('react-datepicker__day--highlighted'));\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Day, [{\n\t key: 'render',\n\t value: function render() {\n\t return _react2.default.createElement(\n\t 'div',\n\t {\n\t className: this.getClassNames(this.props.day),\n\t onClick: this.handleClick,\n\t onMouseEnter: this.handleMouseEnter,\n\t 'aria-label': 'day-' + (0, _date_utils.getDate)(this.props.day),\n\t role: 'option' },\n\t (0, _date_utils.getDate)(this.props.day)\n\t );\n\t }\n\t }]);\n\n\t return Day;\n\t}(_react2.default.Component);\n\n\tDay.propTypes = {\n\t day: _propTypes2.default.object.isRequired,\n\t dayClassName: _propTypes2.default.func,\n\t endDate: _propTypes2.default.object,\n\t highlightDates: _propTypes2.default.array,\n\t inline: _propTypes2.default.bool,\n\t month: _propTypes2.default.number,\n\t onClick: _propTypes2.default.func,\n\t onMouseEnter: _propTypes2.default.func,\n\t preSelection: _propTypes2.default.object,\n\t selected: _propTypes2.default.object,\n\t selectingDate: _propTypes2.default.object,\n\t selectsEnd: _propTypes2.default.bool,\n\t selectsStart: _propTypes2.default.bool,\n\t startDate: _propTypes2.default.object,\n\t utcOffset: _propTypes2.default.number\n\t};\n\texports.default = Day;\n\n/***/ }),\n/* 19 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar WeekNumber = function (_React$Component) {\n\t _inherits(WeekNumber, _React$Component);\n\n\t function WeekNumber() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, WeekNumber);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = WeekNumber.__proto__ || Object.getPrototypeOf(WeekNumber)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (event) {\n\t if (_this.props.onClick) {\n\t _this.props.onClick(event);\n\t }\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(WeekNumber, [{\n\t key: 'render',\n\t value: function render() {\n\t var weekNumberClasses = {\n\t 'react-datepicker__week-number': true,\n\t 'react-datepicker__week-number--clickable': !!this.props.onClick\n\t };\n\t return _react2.default.createElement(\n\t 'div',\n\t {\n\t className: (0, _classnames2.default)(weekNumberClasses),\n\t 'aria-label': 'week-' + this.props.weekNumber,\n\t onClick: this.handleClick },\n\t this.props.weekNumber\n\t );\n\t }\n\t }]);\n\n\t return WeekNumber;\n\t}(_react2.default.Component);\n\n\tWeekNumber.propTypes = {\n\t weekNumber: _propTypes2.default.number.isRequired,\n\t onClick: _propTypes2.default.func\n\t};\n\texports.default = WeekNumber;\n\n/***/ }),\n/* 20 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _date_utils = __webpack_require__(12);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar Time = function (_React$Component) {\n\t _inherits(Time, _React$Component);\n\n\t function Time() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Time);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Time.__proto__ || Object.getPrototypeOf(Time)).call.apply(_ref, [this].concat(args))), _this), _this.handleClick = function (time) {\n\t if ((_this.props.minTime || _this.props.maxTime) && (0, _date_utils.isTimeInDisabledRange)(time, _this.props) || _this.props.excludeTimes && (0, _date_utils.isTimeDisabled)(time, _this.props.excludeTimes)) {\n\t return;\n\t }\n\n\t _this.props.onChange(time);\n\t }, _this.liClasses = function (time, currH, currM) {\n\t var classes = ['react-datepicker__time-list-item'];\n\n\t if (currH === (0, _date_utils.getHour)(time) && currM === (0, _date_utils.getMinute)(time)) {\n\t classes.push('react-datepicker__time-list-item--selected');\n\t }\n\t if ((_this.props.minTime || _this.props.maxTime) && (0, _date_utils.isTimeInDisabledRange)(time, _this.props) || _this.props.excludeTimes && (0, _date_utils.isTimeDisabled)(time, _this.props.excludeTimes)) {\n\t classes.push('react-datepicker__time-list-item--disabled');\n\t }\n\n\t return classes.join(' ');\n\t }, _this.renderTimes = function () {\n\t var times = [];\n\t var format = _this.props.format ? _this.props.format : 'hh:mm A';\n\t var intervals = _this.props.intervals;\n\t var activeTime = _this.props.selected ? _this.props.selected : (0, _date_utils.newDate)();\n\t var currH = (0, _date_utils.getHour)(activeTime);\n\t var currM = (0, _date_utils.getMinute)(activeTime);\n\t var base = (0, _date_utils.getStartOfDay)((0, _date_utils.newDate)());\n\t var multiplier = 1440 / intervals;\n\t for (var i = 0; i < multiplier; i++) {\n\t times.push((0, _date_utils.addMinutes)((0, _date_utils.cloneDate)(base), i * intervals));\n\t }\n\n\t return times.map(function (time, i) {\n\t return _react2.default.createElement(\n\t 'li',\n\t { key: i, onClick: _this.handleClick.bind(_this, time), className: _this.liClasses(time, currH, currM) },\n\t (0, _date_utils.formatDate)(time, format)\n\t );\n\t });\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Time, [{\n\t key: 'componentDidMount',\n\t value: function componentDidMount() {\n\t // code to ensure selected time will always be in focus within time window when it first appears\n\t var multiplier = 60 / this.props.intervals;\n\t var currH = this.props.selected ? (0, _date_utils.getHour)(this.props.selected) : (0, _date_utils.getHour)((0, _date_utils.newDate)());\n\t this.list.scrollTop = 30 * (multiplier * currH);\n\t }\n\t }, {\n\t key: 'render',\n\t value: function render() {\n\t var _this2 = this;\n\n\t var height = null;\n\t if (this.props.monthRef) {\n\t height = this.props.monthRef.clientHeight - 39;\n\t }\n\n\t return _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__time-container ' + (this.props.todayButton ? 'react-datepicker__time-container--with-today-button' : '') },\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__header react-datepicker__header--time' },\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker-time__header' },\n\t 'Time'\n\t )\n\t ),\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__time' },\n\t _react2.default.createElement(\n\t 'div',\n\t { className: 'react-datepicker__time-box' },\n\t _react2.default.createElement(\n\t 'ul',\n\t { className: 'react-datepicker__time-list', ref: function ref(list) {\n\t _this2.list = list;\n\t }, style: height ? { height: height } : {} },\n\t this.renderTimes.bind(this)()\n\t )\n\t )\n\t )\n\t );\n\t }\n\t }], [{\n\t key: 'defaultProps',\n\t get: function get() {\n\t return {\n\t intervals: 30,\n\t onTimeChange: function onTimeChange() {},\n\t todayButton: null\n\t };\n\t }\n\t }]);\n\n\t return Time;\n\t}(_react2.default.Component);\n\n\tTime.propTypes = {\n\t format: _propTypes2.default.string,\n\t intervals: _propTypes2.default.number,\n\t selected: _propTypes2.default.object,\n\t onChange: _propTypes2.default.func,\n\t todayButton: _propTypes2.default.string,\n\t minTime: _propTypes2.default.object,\n\t maxTime: _propTypes2.default.object,\n\t excludeTimes: _propTypes2.default.array,\n\t monthRef: _propTypes2.default.object\n\t};\n\texports.default = Time;\n\n/***/ }),\n/* 21 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.popperPlacementPositions = undefined;\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _classnames = __webpack_require__(10);\n\n\tvar _classnames2 = _interopRequireDefault(_classnames);\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _reactPopper = __webpack_require__(22);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar popperPlacementPositions = exports.popperPlacementPositions = ['auto', 'auto-left', 'auto-right', 'bottom', 'bottom-end', 'bottom-start', 'left', 'left-end', 'left-start', 'right', 'right-end', 'right-start', 'top', 'top-end', 'top-start'];\n\n\tvar PopperComponent = function (_React$Component) {\n\t _inherits(PopperComponent, _React$Component);\n\n\t function PopperComponent() {\n\t _classCallCheck(this, PopperComponent);\n\n\t return _possibleConstructorReturn(this, (PopperComponent.__proto__ || Object.getPrototypeOf(PopperComponent)).apply(this, arguments));\n\t }\n\n\t _createClass(PopperComponent, [{\n\t key: 'render',\n\t value: function render() {\n\t var _props = this.props,\n\t className = _props.className,\n\t hidePopper = _props.hidePopper,\n\t popperComponent = _props.popperComponent,\n\t popperModifiers = _props.popperModifiers,\n\t popperPlacement = _props.popperPlacement,\n\t targetComponent = _props.targetComponent;\n\n\n\t var popper = void 0;\n\n\t if (!hidePopper) {\n\t var classes = (0, _classnames2.default)('react-datepicker-popper', className);\n\t popper = _react2.default.createElement(\n\t _reactPopper.Popper,\n\t {\n\t className: classes,\n\t modifiers: popperModifiers,\n\t placement: popperPlacement },\n\t popperComponent\n\t );\n\t }\n\n\t if (this.props.popperContainer) {\n\t popper = _react2.default.createElement(this.props.popperContainer, {}, popper);\n\t }\n\n\t return _react2.default.createElement(\n\t _reactPopper.Manager,\n\t null,\n\t _react2.default.createElement(\n\t _reactPopper.Target,\n\t { className: 'react-datepicker-wrapper' },\n\t targetComponent\n\t ),\n\t popper\n\t );\n\t }\n\t }], [{\n\t key: 'defaultProps',\n\t get: function get() {\n\t return {\n\t hidePopper: true,\n\t popperModifiers: {\n\t preventOverflow: {\n\t enabled: true,\n\t escapeWithReference: true,\n\t boundariesElement: 'viewport'\n\t }\n\t },\n\t popperPlacement: 'bottom-start'\n\t };\n\t }\n\t }]);\n\n\t return PopperComponent;\n\t}(_react2.default.Component);\n\n\tPopperComponent.propTypes = {\n\t className: _propTypes2.default.string,\n\t hidePopper: _propTypes2.default.bool,\n\t popperComponent: _propTypes2.default.element,\n\t popperModifiers: _propTypes2.default.object, // props\n\t popperPlacement: _propTypes2.default.oneOf(popperPlacementPositions), // props\n\t popperContainer: _propTypes2.default.func,\n\t targetComponent: _propTypes2.default.element\n\t};\n\texports.default = PopperComponent;\n\n/***/ }),\n/* 22 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.Arrow = exports.Popper = exports.Target = exports.Manager = undefined;\n\n\tvar _Manager2 = __webpack_require__(23);\n\n\tvar _Manager3 = _interopRequireDefault(_Manager2);\n\n\tvar _Target2 = __webpack_require__(24);\n\n\tvar _Target3 = _interopRequireDefault(_Target2);\n\n\tvar _Popper2 = __webpack_require__(25);\n\n\tvar _Popper3 = _interopRequireDefault(_Popper2);\n\n\tvar _Arrow2 = __webpack_require__(27);\n\n\tvar _Arrow3 = _interopRequireDefault(_Arrow2);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\texports.Manager = _Manager3.default;\n\texports.Target = _Target3.default;\n\texports.Popper = _Popper3.default;\n\texports.Arrow = _Arrow3.default;\n\n/***/ }),\n/* 23 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar Manager = function (_Component) {\n\t _inherits(Manager, _Component);\n\n\t function Manager() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Manager);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Manager.__proto__ || Object.getPrototypeOf(Manager)).call.apply(_ref, [this].concat(args))), _this), _this._setTargetNode = function (node) {\n\t _this._targetNode = node;\n\t }, _this._getTargetNode = function () {\n\t return _this._targetNode;\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Manager, [{\n\t key: 'getChildContext',\n\t value: function getChildContext() {\n\t return {\n\t popperManager: {\n\t setTargetNode: this._setTargetNode,\n\t getTargetNode: this._getTargetNode\n\t }\n\t };\n\t }\n\t }, {\n\t key: 'render',\n\t value: function render() {\n\t var _props = this.props,\n\t tag = _props.tag,\n\t children = _props.children,\n\t restProps = _objectWithoutProperties(_props, ['tag', 'children']);\n\n\t if (tag !== false) {\n\t return (0, _react.createElement)(tag, restProps, children);\n\t } else {\n\t return children;\n\t }\n\t }\n\t }]);\n\n\t return Manager;\n\t}(_react.Component);\n\n\tManager.childContextTypes = {\n\t popperManager: _propTypes2.default.object.isRequired\n\t};\n\tManager.propTypes = {\n\t tag: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.bool])\n\t};\n\tManager.defaultProps = {\n\t tag: 'div'\n\t};\n\texports.default = Manager;\n\n/***/ }),\n/* 24 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\n\tvar Target = function Target(props, context) {\n\t var _props$component = props.component,\n\t component = _props$component === undefined ? 'div' : _props$component,\n\t innerRef = props.innerRef,\n\t children = props.children,\n\t restProps = _objectWithoutProperties(props, ['component', 'innerRef', 'children']);\n\n\t var popperManager = context.popperManager;\n\n\t var targetRef = function targetRef(node) {\n\t popperManager.setTargetNode(node);\n\t if (typeof innerRef === 'function') {\n\t innerRef(node);\n\t }\n\t };\n\n\t if (typeof children === 'function') {\n\t var targetProps = { ref: targetRef };\n\t return children({ targetProps: targetProps, restProps: restProps });\n\t }\n\n\t var componentProps = _extends({}, restProps);\n\n\t if (typeof component === 'string') {\n\t componentProps.ref = targetRef;\n\t } else {\n\t componentProps.innerRef = targetRef;\n\t }\n\n\t return (0, _react.createElement)(component, componentProps, children);\n\t};\n\n\tTarget.contextTypes = {\n\t popperManager: _propTypes2.default.object.isRequired\n\t};\n\n\tTarget.propTypes = {\n\t component: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func]),\n\t innerRef: _propTypes2.default.func,\n\t children: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func])\n\t};\n\n\texports.default = Target;\n\n/***/ }),\n/* 25 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tvar _popper = __webpack_require__(26);\n\n\tvar _popper2 = _interopRequireDefault(_popper);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\tfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\tvar noop = function noop() {\n\t return null;\n\t};\n\n\tvar Popper = function (_Component) {\n\t _inherits(Popper, _Component);\n\n\t function Popper() {\n\t var _ref;\n\n\t var _temp, _this, _ret;\n\n\t _classCallCheck(this, Popper);\n\n\t for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n\t args[_key] = arguments[_key];\n\t }\n\n\t return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Popper.__proto__ || Object.getPrototypeOf(Popper)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this._setArrowNode = function (node) {\n\t _this._arrowNode = node;\n\t }, _this._getTargetNode = function () {\n\t return _this.context.popperManager.getTargetNode();\n\t }, _this._getOffsets = function (data) {\n\t return Object.keys(data.offsets).map(function (key) {\n\t return data.offsets[key];\n\t });\n\t }, _this._isDataDirty = function (data) {\n\t if (_this.state.data) {\n\t return JSON.stringify(_this._getOffsets(_this.state.data)) !== JSON.stringify(_this._getOffsets(data));\n\t } else {\n\t return true;\n\t }\n\t }, _this._updateStateModifier = {\n\t enabled: true,\n\t order: 900,\n\t fn: function fn(data) {\n\t if (_this._isDataDirty(data)) {\n\t _this.setState({ data: data });\n\t }\n\t return data;\n\t }\n\t }, _this._getPopperStyle = function () {\n\t var data = _this.state.data;\n\n\t // If Popper isn't instantiated, hide the popperElement\n\t // to avoid flash of unstyled content\n\n\t if (!_this._popper || !data) {\n\t return {\n\t position: 'absolute',\n\t pointerEvents: 'none',\n\t opacity: 0\n\t };\n\t }\n\n\t var _data$offsets$popper = data.offsets.popper,\n\t top = _data$offsets$popper.top,\n\t left = _data$offsets$popper.left,\n\t position = _data$offsets$popper.position;\n\n\n\t return _extends({\n\t position: position\n\t }, data.styles);\n\t }, _this._getPopperPlacement = function () {\n\t return !!_this.state.data ? _this.state.data.placement : undefined;\n\t }, _this._getPopperHide = function () {\n\t return !!_this.state.data && _this.state.data.hide ? '' : undefined;\n\t }, _this._getArrowStyle = function () {\n\t if (!_this.state.data || !_this.state.data.offsets.arrow) {\n\t return {};\n\t } else {\n\t var _this$state$data$offs = _this.state.data.offsets.arrow,\n\t top = _this$state$data$offs.top,\n\t left = _this$state$data$offs.left;\n\n\t return { top: top, left: left };\n\t }\n\t }, _temp), _possibleConstructorReturn(_this, _ret);\n\t }\n\n\t _createClass(Popper, [{\n\t key: 'getChildContext',\n\t value: function getChildContext() {\n\t return {\n\t popper: {\n\t setArrowNode: this._setArrowNode,\n\t getArrowStyle: this._getArrowStyle\n\t }\n\t };\n\t }\n\t }, {\n\t key: 'componentDidMount',\n\t value: function componentDidMount() {\n\t this._updatePopper();\n\t }\n\t }, {\n\t key: 'componentDidUpdate',\n\t value: function componentDidUpdate(lastProps) {\n\t if (lastProps.placement !== this.props.placement || lastProps.eventsEnabled !== this.props.eventsEnabled) {\n\t this._updatePopper();\n\t }\n\n\t if (this._popper && lastProps.children !== this.props.children) {\n\t this._popper.scheduleUpdate();\n\t }\n\t }\n\t }, {\n\t key: 'componentWillUnmount',\n\t value: function componentWillUnmount() {\n\t this._destroyPopper();\n\t }\n\t }, {\n\t key: '_updatePopper',\n\t value: function _updatePopper() {\n\t this._destroyPopper();\n\t if (this._node) {\n\t this._createPopper();\n\t }\n\t }\n\t }, {\n\t key: '_createPopper',\n\t value: function _createPopper() {\n\t var _props = this.props,\n\t placement = _props.placement,\n\t eventsEnabled = _props.eventsEnabled;\n\n\t var modifiers = _extends({}, this.props.modifiers, {\n\t applyStyle: { enabled: false },\n\t updateState: this._updateStateModifier\n\t });\n\n\t if (this._arrowNode) {\n\t modifiers.arrow = {\n\t element: this._arrowNode\n\t };\n\t }\n\n\t this._popper = new _popper2.default(this._getTargetNode(), this._node, {\n\t placement: placement,\n\t eventsEnabled: eventsEnabled,\n\t modifiers: modifiers\n\t });\n\n\t // schedule an update to make sure everything gets positioned correct\n\t // after being instantiated\n\t this._popper.scheduleUpdate();\n\t }\n\t }, {\n\t key: '_destroyPopper',\n\t value: function _destroyPopper() {\n\t if (this._popper) {\n\t this._popper.destroy();\n\t }\n\t }\n\t }, {\n\t key: 'render',\n\t value: function render() {\n\t var _this2 = this;\n\n\t var _props2 = this.props,\n\t component = _props2.component,\n\t innerRef = _props2.innerRef,\n\t placement = _props2.placement,\n\t eventsEnabled = _props2.eventsEnabled,\n\t modifiers = _props2.modifiers,\n\t children = _props2.children,\n\t restProps = _objectWithoutProperties(_props2, ['component', 'innerRef', 'placement', 'eventsEnabled', 'modifiers', 'children']);\n\n\t var popperRef = function popperRef(node) {\n\t _this2._node = node;\n\t if (typeof innerRef === 'function') {\n\t innerRef(node);\n\t }\n\t };\n\t var popperStyle = this._getPopperStyle();\n\t var popperPlacement = this._getPopperPlacement();\n\t var popperHide = this._getPopperHide();\n\n\t if (typeof children === 'function') {\n\t var _popperProps;\n\n\t var popperProps = (_popperProps = {\n\t ref: popperRef,\n\t style: popperStyle\n\t }, _defineProperty(_popperProps, 'data-placement', popperPlacement), _defineProperty(_popperProps, 'data-x-out-of-boundaries', popperHide), _popperProps);\n\t return children({\n\t popperProps: popperProps,\n\t restProps: restProps,\n\t scheduleUpdate: this._popper && this._popper.scheduleUpdate\n\t });\n\t }\n\n\t var componentProps = _extends({}, restProps, {\n\t style: _extends({}, restProps.style, popperStyle),\n\t 'data-placement': popperPlacement,\n\t 'data-x-out-of-boundaries': popperHide\n\t });\n\n\t if (typeof component === 'string') {\n\t componentProps.ref = popperRef;\n\t } else {\n\t componentProps.innerRef = popperRef;\n\t }\n\n\t return (0, _react.createElement)(component, componentProps, children);\n\t }\n\t }]);\n\n\t return Popper;\n\t}(_react.Component);\n\n\tPopper.contextTypes = {\n\t popperManager: _propTypes2.default.object.isRequired\n\t};\n\tPopper.childContextTypes = {\n\t popper: _propTypes2.default.object.isRequired\n\t};\n\tPopper.propTypes = {\n\t component: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func]),\n\t innerRef: _propTypes2.default.func,\n\t placement: _propTypes2.default.oneOf(_popper2.default.placements),\n\t eventsEnabled: _propTypes2.default.bool,\n\t modifiers: _propTypes2.default.object,\n\t children: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func])\n\t};\n\tPopper.defaultProps = {\n\t component: 'div',\n\t placement: 'bottom',\n\t eventsEnabled: true,\n\t modifiers: {}\n\t};\n\texports.default = Popper;\n\n/***/ }),\n/* 26 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(global) {/**!\n\t * @fileOverview Kickass library to create and place poppers near their reference elements.\n\t * @version 1.12.6\n\t * @license\n\t * Copyright (c) 2016 Federico Zivolo and contributors\n\t *\n\t * Permission is hereby granted, free of charge, to any person obtaining a copy\n\t * of this software and associated documentation files (the \"Software\"), to deal\n\t * in the Software without restriction, including without limitation the rights\n\t * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\t * copies of the Software, and to permit persons to whom the Software is\n\t * furnished to do so, subject to the following conditions:\n\t *\n\t * The above copyright notice and this permission notice shall be included in all\n\t * copies or substantial portions of the Software.\n\t *\n\t * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\t * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\t * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\t * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\t * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\t * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n\t * SOFTWARE.\n\t */\n\t(function (global, factory) {\n\t\t true ? module.exports = factory() :\n\t\ttypeof define === 'function' && define.amd ? define(factory) :\n\t\t(global.Popper = factory());\n\t}(this, (function () { 'use strict';\n\n\tvar isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\tvar longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];\n\tvar timeoutDuration = 0;\n\tfor (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {\n\t if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {\n\t timeoutDuration = 1;\n\t break;\n\t }\n\t}\n\n\tfunction microtaskDebounce(fn) {\n\t var called = false;\n\t return function () {\n\t if (called) {\n\t return;\n\t }\n\t called = true;\n\t Promise.resolve().then(function () {\n\t called = false;\n\t fn();\n\t });\n\t };\n\t}\n\n\tfunction taskDebounce(fn) {\n\t var scheduled = false;\n\t return function () {\n\t if (!scheduled) {\n\t scheduled = true;\n\t setTimeout(function () {\n\t scheduled = false;\n\t fn();\n\t }, timeoutDuration);\n\t }\n\t };\n\t}\n\n\tvar supportsMicroTasks = isBrowser && window.Promise;\n\n\t/**\n\t* Create a debounced version of a method, that's asynchronously deferred\n\t* but called in the minimum time possible.\n\t*\n\t* @method\n\t* @memberof Popper.Utils\n\t* @argument {Function} fn\n\t* @returns {Function}\n\t*/\n\tvar debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;\n\n\t/**\n\t * Check if the given variable is a function\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Any} functionToCheck - variable to check\n\t * @returns {Boolean} answer to: is a function?\n\t */\n\tfunction isFunction(functionToCheck) {\n\t var getType = {};\n\t return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';\n\t}\n\n\t/**\n\t * Get CSS computed property of the given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Eement} element\n\t * @argument {String} property\n\t */\n\tfunction getStyleComputedProperty(element, property) {\n\t if (element.nodeType !== 1) {\n\t return [];\n\t }\n\t // NOTE: 1 DOM access here\n\t var css = window.getComputedStyle(element, null);\n\t return property ? css[property] : css;\n\t}\n\n\t/**\n\t * Returns the parentNode or the host of the element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @returns {Element} parent\n\t */\n\tfunction getParentNode(element) {\n\t if (element.nodeName === 'HTML') {\n\t return element;\n\t }\n\t return element.parentNode || element.host;\n\t}\n\n\t/**\n\t * Returns the scrolling parent of the given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @returns {Element} scroll parent\n\t */\n\tfunction getScrollParent(element) {\n\t // Return body, `getScroll` will take care to get the correct `scrollTop` from it\n\t if (!element) {\n\t return window.document.body;\n\t }\n\n\t switch (element.nodeName) {\n\t case 'HTML':\n\t case 'BODY':\n\t return element.ownerDocument.body;\n\t case '#document':\n\t return element.body;\n\t }\n\n\t // Firefox want us to check `-x` and `-y` variations as well\n\n\t var _getStyleComputedProp = getStyleComputedProperty(element),\n\t overflow = _getStyleComputedProp.overflow,\n\t overflowX = _getStyleComputedProp.overflowX,\n\t overflowY = _getStyleComputedProp.overflowY;\n\n\t if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {\n\t return element;\n\t }\n\n\t return getScrollParent(getParentNode(element));\n\t}\n\n\t/**\n\t * Returns the offset parent of the given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @returns {Element} offset parent\n\t */\n\tfunction getOffsetParent(element) {\n\t // NOTE: 1 DOM access here\n\t var offsetParent = element && element.offsetParent;\n\t var nodeName = offsetParent && offsetParent.nodeName;\n\n\t if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {\n\t if (element) {\n\t return element.ownerDocument.documentElement;\n\t }\n\n\t return window.document.documentElement;\n\t }\n\n\t // .offsetParent will return the closest TD or TABLE in case\n\t // no offsetParent is present, I hate this job...\n\t if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {\n\t return getOffsetParent(offsetParent);\n\t }\n\n\t return offsetParent;\n\t}\n\n\tfunction isOffsetContainer(element) {\n\t var nodeName = element.nodeName;\n\n\t if (nodeName === 'BODY') {\n\t return false;\n\t }\n\t return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;\n\t}\n\n\t/**\n\t * Finds the root node (document, shadowDOM root) of the given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} node\n\t * @returns {Element} root node\n\t */\n\tfunction getRoot(node) {\n\t if (node.parentNode !== null) {\n\t return getRoot(node.parentNode);\n\t }\n\n\t return node;\n\t}\n\n\t/**\n\t * Finds the offset parent common to the two provided nodes\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element1\n\t * @argument {Element} element2\n\t * @returns {Element} common offset parent\n\t */\n\tfunction findCommonOffsetParent(element1, element2) {\n\t // This check is needed to avoid errors in case one of the elements isn't defined for any reason\n\t if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {\n\t return window.document.documentElement;\n\t }\n\n\t // Here we make sure to give as \"start\" the element that comes first in the DOM\n\t var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;\n\t var start = order ? element1 : element2;\n\t var end = order ? element2 : element1;\n\n\t // Get common ancestor container\n\t var range = document.createRange();\n\t range.setStart(start, 0);\n\t range.setEnd(end, 0);\n\t var commonAncestorContainer = range.commonAncestorContainer;\n\n\t // Both nodes are inside #document\n\n\t if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {\n\t if (isOffsetContainer(commonAncestorContainer)) {\n\t return commonAncestorContainer;\n\t }\n\n\t return getOffsetParent(commonAncestorContainer);\n\t }\n\n\t // one of the nodes is inside shadowDOM, find which one\n\t var element1root = getRoot(element1);\n\t if (element1root.host) {\n\t return findCommonOffsetParent(element1root.host, element2);\n\t } else {\n\t return findCommonOffsetParent(element1, getRoot(element2).host);\n\t }\n\t}\n\n\t/**\n\t * Gets the scroll value of the given element in the given side (top and left)\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @argument {String} side `top` or `left`\n\t * @returns {number} amount of scrolled pixels\n\t */\n\tfunction getScroll(element) {\n\t var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';\n\n\t var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';\n\t var nodeName = element.nodeName;\n\n\t if (nodeName === 'BODY' || nodeName === 'HTML') {\n\t var html = element.ownerDocument.documentElement;\n\t var scrollingElement = element.ownerDocument.scrollingElement || html;\n\t return scrollingElement[upperSide];\n\t }\n\n\t return element[upperSide];\n\t}\n\n\t/*\n\t * Sum or subtract the element scroll values (left and top) from a given rect object\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {Object} rect - Rect object you want to change\n\t * @param {HTMLElement} element - The element from the function reads the scroll values\n\t * @param {Boolean} subtract - set to true if you want to subtract the scroll values\n\t * @return {Object} rect - The modifier rect object\n\t */\n\tfunction includeScroll(rect, element) {\n\t var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n\n\t var scrollTop = getScroll(element, 'top');\n\t var scrollLeft = getScroll(element, 'left');\n\t var modifier = subtract ? -1 : 1;\n\t rect.top += scrollTop * modifier;\n\t rect.bottom += scrollTop * modifier;\n\t rect.left += scrollLeft * modifier;\n\t rect.right += scrollLeft * modifier;\n\t return rect;\n\t}\n\n\t/*\n\t * Helper to detect borders of a given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {CSSStyleDeclaration} styles\n\t * Result of `getStyleComputedProperty` on the given element\n\t * @param {String} axis - `x` or `y`\n\t * @return {number} borders - The borders size of the given axis\n\t */\n\n\tfunction getBordersSize(styles, axis) {\n\t var sideA = axis === 'x' ? 'Left' : 'Top';\n\t var sideB = sideA === 'Left' ? 'Right' : 'Bottom';\n\n\t return +styles['border' + sideA + 'Width'].split('px')[0] + +styles['border' + sideB + 'Width'].split('px')[0];\n\t}\n\n\t/**\n\t * Tells if you are running Internet Explorer 10\n\t * @method\n\t * @memberof Popper.Utils\n\t * @returns {Boolean} isIE10\n\t */\n\tvar isIE10 = undefined;\n\n\tvar isIE10$1 = function () {\n\t if (isIE10 === undefined) {\n\t isIE10 = navigator.appVersion.indexOf('MSIE 10') !== -1;\n\t }\n\t return isIE10;\n\t};\n\n\tfunction getSize(axis, body, html, computedStyle) {\n\t return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE10$1() ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);\n\t}\n\n\tfunction getWindowSizes() {\n\t var body = window.document.body;\n\t var html = window.document.documentElement;\n\t var computedStyle = isIE10$1() && window.getComputedStyle(html);\n\n\t return {\n\t height: getSize('Height', body, html, computedStyle),\n\t width: getSize('Width', body, html, computedStyle)\n\t };\n\t}\n\n\tvar classCallCheck = function (instance, Constructor) {\n\t if (!(instance instanceof Constructor)) {\n\t throw new TypeError(\"Cannot call a class as a function\");\n\t }\n\t};\n\n\tvar createClass = function () {\n\t function defineProperties(target, props) {\n\t for (var i = 0; i < props.length; i++) {\n\t var descriptor = props[i];\n\t descriptor.enumerable = descriptor.enumerable || false;\n\t descriptor.configurable = true;\n\t if (\"value\" in descriptor) descriptor.writable = true;\n\t Object.defineProperty(target, descriptor.key, descriptor);\n\t }\n\t }\n\n\t return function (Constructor, protoProps, staticProps) {\n\t if (protoProps) defineProperties(Constructor.prototype, protoProps);\n\t if (staticProps) defineProperties(Constructor, staticProps);\n\t return Constructor;\n\t };\n\t}();\n\n\n\n\n\n\tvar defineProperty = function (obj, key, value) {\n\t if (key in obj) {\n\t Object.defineProperty(obj, key, {\n\t value: value,\n\t enumerable: true,\n\t configurable: true,\n\t writable: true\n\t });\n\t } else {\n\t obj[key] = value;\n\t }\n\n\t return obj;\n\t};\n\n\tvar _extends = Object.assign || function (target) {\n\t for (var i = 1; i < arguments.length; i++) {\n\t var source = arguments[i];\n\n\t for (var key in source) {\n\t if (Object.prototype.hasOwnProperty.call(source, key)) {\n\t target[key] = source[key];\n\t }\n\t }\n\t }\n\n\t return target;\n\t};\n\n\t/**\n\t * Given element offsets, generate an output similar to getBoundingClientRect\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Object} offsets\n\t * @returns {Object} ClientRect like output\n\t */\n\tfunction getClientRect(offsets) {\n\t return _extends({}, offsets, {\n\t right: offsets.left + offsets.width,\n\t bottom: offsets.top + offsets.height\n\t });\n\t}\n\n\t/**\n\t * Get bounding client rect of given element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {HTMLElement} element\n\t * @return {Object} client rect\n\t */\n\tfunction getBoundingClientRect(element) {\n\t var rect = {};\n\n\t // IE10 10 FIX: Please, don't ask, the element isn't\n\t // considered in DOM in some circumstances...\n\t // This isn't reproducible in IE10 compatibility mode of IE11\n\t if (isIE10$1()) {\n\t try {\n\t rect = element.getBoundingClientRect();\n\t var scrollTop = getScroll(element, 'top');\n\t var scrollLeft = getScroll(element, 'left');\n\t rect.top += scrollTop;\n\t rect.left += scrollLeft;\n\t rect.bottom += scrollTop;\n\t rect.right += scrollLeft;\n\t } catch (err) {}\n\t } else {\n\t rect = element.getBoundingClientRect();\n\t }\n\n\t var result = {\n\t left: rect.left,\n\t top: rect.top,\n\t width: rect.right - rect.left,\n\t height: rect.bottom - rect.top\n\t };\n\n\t // subtract scrollbar size from sizes\n\t var sizes = element.nodeName === 'HTML' ? getWindowSizes() : {};\n\t var width = sizes.width || element.clientWidth || result.right - result.left;\n\t var height = sizes.height || element.clientHeight || result.bottom - result.top;\n\n\t var horizScrollbar = element.offsetWidth - width;\n\t var vertScrollbar = element.offsetHeight - height;\n\n\t // if an hypothetical scrollbar is detected, we must be sure it's not a `border`\n\t // we make this check conditional for performance reasons\n\t if (horizScrollbar || vertScrollbar) {\n\t var styles = getStyleComputedProperty(element);\n\t horizScrollbar -= getBordersSize(styles, 'x');\n\t vertScrollbar -= getBordersSize(styles, 'y');\n\n\t result.width -= horizScrollbar;\n\t result.height -= vertScrollbar;\n\t }\n\n\t return getClientRect(result);\n\t}\n\n\tfunction getOffsetRectRelativeToArbitraryNode(children, parent) {\n\t var isIE10 = isIE10$1();\n\t var isHTML = parent.nodeName === 'HTML';\n\t var childrenRect = getBoundingClientRect(children);\n\t var parentRect = getBoundingClientRect(parent);\n\t var scrollParent = getScrollParent(children);\n\n\t var styles = getStyleComputedProperty(parent);\n\t var borderTopWidth = +styles.borderTopWidth.split('px')[0];\n\t var borderLeftWidth = +styles.borderLeftWidth.split('px')[0];\n\n\t var offsets = getClientRect({\n\t top: childrenRect.top - parentRect.top - borderTopWidth,\n\t left: childrenRect.left - parentRect.left - borderLeftWidth,\n\t width: childrenRect.width,\n\t height: childrenRect.height\n\t });\n\t offsets.marginTop = 0;\n\t offsets.marginLeft = 0;\n\n\t // Subtract margins of documentElement in case it's being used as parent\n\t // we do this only on HTML because it's the only element that behaves\n\t // differently when margins are applied to it. The margins are included in\n\t // the box of the documentElement, in the other cases not.\n\t if (!isIE10 && isHTML) {\n\t var marginTop = +styles.marginTop.split('px')[0];\n\t var marginLeft = +styles.marginLeft.split('px')[0];\n\n\t offsets.top -= borderTopWidth - marginTop;\n\t offsets.bottom -= borderTopWidth - marginTop;\n\t offsets.left -= borderLeftWidth - marginLeft;\n\t offsets.right -= borderLeftWidth - marginLeft;\n\n\t // Attach marginTop and marginLeft because in some circumstances we may need them\n\t offsets.marginTop = marginTop;\n\t offsets.marginLeft = marginLeft;\n\t }\n\n\t if (isIE10 ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {\n\t offsets = includeScroll(offsets, parent);\n\t }\n\n\t return offsets;\n\t}\n\n\tfunction getViewportOffsetRectRelativeToArtbitraryNode(element) {\n\t var html = element.ownerDocument.documentElement;\n\t var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);\n\t var width = Math.max(html.clientWidth, window.innerWidth || 0);\n\t var height = Math.max(html.clientHeight, window.innerHeight || 0);\n\n\t var scrollTop = getScroll(html);\n\t var scrollLeft = getScroll(html, 'left');\n\n\t var offset = {\n\t top: scrollTop - relativeOffset.top + relativeOffset.marginTop,\n\t left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,\n\t width: width,\n\t height: height\n\t };\n\n\t return getClientRect(offset);\n\t}\n\n\t/**\n\t * Check if the given element is fixed or is inside a fixed parent\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @argument {Element} customContainer\n\t * @returns {Boolean} answer to \"isFixed?\"\n\t */\n\tfunction isFixed(element) {\n\t var nodeName = element.nodeName;\n\t if (nodeName === 'BODY' || nodeName === 'HTML') {\n\t return false;\n\t }\n\t if (getStyleComputedProperty(element, 'position') === 'fixed') {\n\t return true;\n\t }\n\t return isFixed(getParentNode(element));\n\t}\n\n\t/**\n\t * Computed the boundaries limits and return them\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {HTMLElement} popper\n\t * @param {HTMLElement} reference\n\t * @param {number} padding\n\t * @param {HTMLElement} boundariesElement - Element used to define the boundaries\n\t * @returns {Object} Coordinates of the boundaries\n\t */\n\tfunction getBoundaries(popper, reference, padding, boundariesElement) {\n\t // NOTE: 1 DOM access here\n\t var boundaries = { top: 0, left: 0 };\n\t var offsetParent = findCommonOffsetParent(popper, reference);\n\n\t // Handle viewport case\n\t if (boundariesElement === 'viewport') {\n\t boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent);\n\t } else {\n\t // Handle other cases based on DOM element used as boundaries\n\t var boundariesNode = void 0;\n\t if (boundariesElement === 'scrollParent') {\n\t boundariesNode = getScrollParent(getParentNode(popper));\n\t if (boundariesNode.nodeName === 'BODY') {\n\t boundariesNode = popper.ownerDocument.documentElement;\n\t }\n\t } else if (boundariesElement === 'window') {\n\t boundariesNode = popper.ownerDocument.documentElement;\n\t } else {\n\t boundariesNode = boundariesElement;\n\t }\n\n\t var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent);\n\n\t // In case of HTML, we need a different computation\n\t if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {\n\t var _getWindowSizes = getWindowSizes(),\n\t height = _getWindowSizes.height,\n\t width = _getWindowSizes.width;\n\n\t boundaries.top += offsets.top - offsets.marginTop;\n\t boundaries.bottom = height + offsets.top;\n\t boundaries.left += offsets.left - offsets.marginLeft;\n\t boundaries.right = width + offsets.left;\n\t } else {\n\t // for all the other DOM elements, this one is good\n\t boundaries = offsets;\n\t }\n\t }\n\n\t // Add paddings\n\t boundaries.left += padding;\n\t boundaries.top += padding;\n\t boundaries.right -= padding;\n\t boundaries.bottom -= padding;\n\n\t return boundaries;\n\t}\n\n\tfunction getArea(_ref) {\n\t var width = _ref.width,\n\t height = _ref.height;\n\n\t return width * height;\n\t}\n\n\t/**\n\t * Utility used to transform the `auto` placement to the placement with more\n\t * available space.\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {\n\t var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;\n\n\t if (placement.indexOf('auto') === -1) {\n\t return placement;\n\t }\n\n\t var boundaries = getBoundaries(popper, reference, padding, boundariesElement);\n\n\t var rects = {\n\t top: {\n\t width: boundaries.width,\n\t height: refRect.top - boundaries.top\n\t },\n\t right: {\n\t width: boundaries.right - refRect.right,\n\t height: boundaries.height\n\t },\n\t bottom: {\n\t width: boundaries.width,\n\t height: boundaries.bottom - refRect.bottom\n\t },\n\t left: {\n\t width: refRect.left - boundaries.left,\n\t height: boundaries.height\n\t }\n\t };\n\n\t var sortedAreas = Object.keys(rects).map(function (key) {\n\t return _extends({\n\t key: key\n\t }, rects[key], {\n\t area: getArea(rects[key])\n\t });\n\t }).sort(function (a, b) {\n\t return b.area - a.area;\n\t });\n\n\t var filteredAreas = sortedAreas.filter(function (_ref2) {\n\t var width = _ref2.width,\n\t height = _ref2.height;\n\t return width >= popper.clientWidth && height >= popper.clientHeight;\n\t });\n\n\t var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;\n\n\t var variation = placement.split('-')[1];\n\n\t return computedPlacement + (variation ? '-' + variation : '');\n\t}\n\n\t/**\n\t * Get offsets to the reference element\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {Object} state\n\t * @param {Element} popper - the popper element\n\t * @param {Element} reference - the reference element (the popper will be relative to this)\n\t * @returns {Object} An object containing the offsets which will be applied to the popper\n\t */\n\tfunction getReferenceOffsets(state, popper, reference) {\n\t var commonOffsetParent = findCommonOffsetParent(popper, reference);\n\t return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent);\n\t}\n\n\t/**\n\t * Get the outer sizes of the given element (offset size + margins)\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element\n\t * @returns {Object} object containing width and height properties\n\t */\n\tfunction getOuterSizes(element) {\n\t var styles = window.getComputedStyle(element);\n\t var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);\n\t var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);\n\t var result = {\n\t width: element.offsetWidth + y,\n\t height: element.offsetHeight + x\n\t };\n\t return result;\n\t}\n\n\t/**\n\t * Get the opposite placement of the given one\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {String} placement\n\t * @returns {String} flipped placement\n\t */\n\tfunction getOppositePlacement(placement) {\n\t var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };\n\t return placement.replace(/left|right|bottom|top/g, function (matched) {\n\t return hash[matched];\n\t });\n\t}\n\n\t/**\n\t * Get offsets to the popper\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {Object} position - CSS position the Popper will get applied\n\t * @param {HTMLElement} popper - the popper element\n\t * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)\n\t * @param {String} placement - one of the valid placement options\n\t * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper\n\t */\n\tfunction getPopperOffsets(popper, referenceOffsets, placement) {\n\t placement = placement.split('-')[0];\n\n\t // Get popper node sizes\n\t var popperRect = getOuterSizes(popper);\n\n\t // Add position, width and height to our offsets object\n\t var popperOffsets = {\n\t width: popperRect.width,\n\t height: popperRect.height\n\t };\n\n\t // depending by the popper placement we have to compute its offsets slightly differently\n\t var isHoriz = ['right', 'left'].indexOf(placement) !== -1;\n\t var mainSide = isHoriz ? 'top' : 'left';\n\t var secondarySide = isHoriz ? 'left' : 'top';\n\t var measurement = isHoriz ? 'height' : 'width';\n\t var secondaryMeasurement = !isHoriz ? 'height' : 'width';\n\n\t popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;\n\t if (placement === secondarySide) {\n\t popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];\n\t } else {\n\t popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];\n\t }\n\n\t return popperOffsets;\n\t}\n\n\t/**\n\t * Mimics the `find` method of Array\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Array} arr\n\t * @argument prop\n\t * @argument value\n\t * @returns index or -1\n\t */\n\tfunction find(arr, check) {\n\t // use native find if supported\n\t if (Array.prototype.find) {\n\t return arr.find(check);\n\t }\n\n\t // use `filter` to obtain the same behavior of `find`\n\t return arr.filter(check)[0];\n\t}\n\n\t/**\n\t * Return the index of the matching object\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Array} arr\n\t * @argument prop\n\t * @argument value\n\t * @returns index or -1\n\t */\n\tfunction findIndex(arr, prop, value) {\n\t // use native findIndex if supported\n\t if (Array.prototype.findIndex) {\n\t return arr.findIndex(function (cur) {\n\t return cur[prop] === value;\n\t });\n\t }\n\n\t // use `find` + `indexOf` if `findIndex` isn't supported\n\t var match = find(arr, function (obj) {\n\t return obj[prop] === value;\n\t });\n\t return arr.indexOf(match);\n\t}\n\n\t/**\n\t * Loop trough the list of modifiers and run them in order,\n\t * each of them will then edit the data object.\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {dataObject} data\n\t * @param {Array} modifiers\n\t * @param {String} ends - Optional modifier name used as stopper\n\t * @returns {dataObject}\n\t */\n\tfunction runModifiers(modifiers, data, ends) {\n\t var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));\n\n\t modifiersToRun.forEach(function (modifier) {\n\t if (modifier['function']) {\n\t // eslint-disable-line dot-notation\n\t console.warn('`modifier.function` is deprecated, use `modifier.fn`!');\n\t }\n\t var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation\n\t if (modifier.enabled && isFunction(fn)) {\n\t // Add properties to offsets to make them a complete clientRect object\n\t // we do this before each modifier to make sure the previous one doesn't\n\t // mess with these values\n\t data.offsets.popper = getClientRect(data.offsets.popper);\n\t data.offsets.reference = getClientRect(data.offsets.reference);\n\n\t data = fn(data, modifier);\n\t }\n\t });\n\n\t return data;\n\t}\n\n\t/**\n\t * Updates the position of the popper, computing the new offsets and applying\n\t * the new style.
    \n\t * Prefer `scheduleUpdate` over `update` because of performance reasons.\n\t * @method\n\t * @memberof Popper\n\t */\n\tfunction update() {\n\t // if popper is destroyed, don't perform any further update\n\t if (this.state.isDestroyed) {\n\t return;\n\t }\n\n\t var data = {\n\t instance: this,\n\t styles: {},\n\t arrowStyles: {},\n\t attributes: {},\n\t flipped: false,\n\t offsets: {}\n\t };\n\n\t // compute reference element offsets\n\t data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference);\n\n\t // compute auto placement, store placement inside the data object,\n\t // modifiers will be able to edit `placement` if needed\n\t // and refer to originalPlacement to know the original value\n\t data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);\n\n\t // store the computed placement inside `originalPlacement`\n\t data.originalPlacement = data.placement;\n\n\t // compute the popper offsets\n\t data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);\n\t data.offsets.popper.position = 'absolute';\n\n\t // run the modifiers\n\t data = runModifiers(this.modifiers, data);\n\n\t // the first `update` will call `onCreate` callback\n\t // the other ones will call `onUpdate` callback\n\t if (!this.state.isCreated) {\n\t this.state.isCreated = true;\n\t this.options.onCreate(data);\n\t } else {\n\t this.options.onUpdate(data);\n\t }\n\t}\n\n\t/**\n\t * Helper used to know if the given modifier is enabled.\n\t * @method\n\t * @memberof Popper.Utils\n\t * @returns {Boolean}\n\t */\n\tfunction isModifierEnabled(modifiers, modifierName) {\n\t return modifiers.some(function (_ref) {\n\t var name = _ref.name,\n\t enabled = _ref.enabled;\n\t return enabled && name === modifierName;\n\t });\n\t}\n\n\t/**\n\t * Get the prefixed supported property name\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {String} property (camelCase)\n\t * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)\n\t */\n\tfunction getSupportedPropertyName(property) {\n\t var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];\n\t var upperProp = property.charAt(0).toUpperCase() + property.slice(1);\n\n\t for (var i = 0; i < prefixes.length - 1; i++) {\n\t var prefix = prefixes[i];\n\t var toCheck = prefix ? '' + prefix + upperProp : property;\n\t if (typeof window.document.body.style[toCheck] !== 'undefined') {\n\t return toCheck;\n\t }\n\t }\n\t return null;\n\t}\n\n\t/**\n\t * Destroy the popper\n\t * @method\n\t * @memberof Popper\n\t */\n\tfunction destroy() {\n\t this.state.isDestroyed = true;\n\n\t // touch DOM only if `applyStyle` modifier is enabled\n\t if (isModifierEnabled(this.modifiers, 'applyStyle')) {\n\t this.popper.removeAttribute('x-placement');\n\t this.popper.style.left = '';\n\t this.popper.style.position = '';\n\t this.popper.style.top = '';\n\t this.popper.style[getSupportedPropertyName('transform')] = '';\n\t }\n\n\t this.disableEventListeners();\n\n\t // remove the popper if user explicity asked for the deletion on destroy\n\t // do not use `remove` because IE11 doesn't support it\n\t if (this.options.removeOnDestroy) {\n\t this.popper.parentNode.removeChild(this.popper);\n\t }\n\t return this;\n\t}\n\n\t/**\n\t * Get the window associated with the element\n\t * @argument {Element} element\n\t * @returns {Window}\n\t */\n\tfunction getWindow(element) {\n\t var ownerDocument = element.ownerDocument;\n\t return ownerDocument ? ownerDocument.defaultView : window;\n\t}\n\n\tfunction attachToScrollParents(scrollParent, event, callback, scrollParents) {\n\t var isBody = scrollParent.nodeName === 'BODY';\n\t var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;\n\t target.addEventListener(event, callback, { passive: true });\n\n\t if (!isBody) {\n\t attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);\n\t }\n\t scrollParents.push(target);\n\t}\n\n\t/**\n\t * Setup needed event listeners used to update the popper position\n\t * @method\n\t * @memberof Popper.Utils\n\t * @private\n\t */\n\tfunction setupEventListeners(reference, options, state, updateBound) {\n\t // Resize event listener on window\n\t state.updateBound = updateBound;\n\t getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });\n\n\t // Scroll event listener on scroll parents\n\t var scrollElement = getScrollParent(reference);\n\t attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);\n\t state.scrollElement = scrollElement;\n\t state.eventsEnabled = true;\n\n\t return state;\n\t}\n\n\t/**\n\t * It will add resize/scroll events and start recalculating\n\t * position of the popper element when they are triggered.\n\t * @method\n\t * @memberof Popper\n\t */\n\tfunction enableEventListeners() {\n\t if (!this.state.eventsEnabled) {\n\t this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);\n\t }\n\t}\n\n\t/**\n\t * Remove event listeners used to update the popper position\n\t * @method\n\t * @memberof Popper.Utils\n\t * @private\n\t */\n\tfunction removeEventListeners(reference, state) {\n\t // Remove resize event listener on window\n\t getWindow(reference).removeEventListener('resize', state.updateBound);\n\n\t // Remove scroll event listener on scroll parents\n\t state.scrollParents.forEach(function (target) {\n\t target.removeEventListener('scroll', state.updateBound);\n\t });\n\n\t // Reset state\n\t state.updateBound = null;\n\t state.scrollParents = [];\n\t state.scrollElement = null;\n\t state.eventsEnabled = false;\n\t return state;\n\t}\n\n\t/**\n\t * It will remove resize/scroll events and won't recalculate popper position\n\t * when they are triggered. It also won't trigger onUpdate callback anymore,\n\t * unless you call `update` method manually.\n\t * @method\n\t * @memberof Popper\n\t */\n\tfunction disableEventListeners() {\n\t if (this.state.eventsEnabled) {\n\t window.cancelAnimationFrame(this.scheduleUpdate);\n\t this.state = removeEventListeners(this.reference, this.state);\n\t }\n\t}\n\n\t/**\n\t * Tells if a given input is a number\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {*} input to check\n\t * @return {Boolean}\n\t */\n\tfunction isNumeric(n) {\n\t return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);\n\t}\n\n\t/**\n\t * Set the style to the given popper\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element - Element to apply the style to\n\t * @argument {Object} styles\n\t * Object with a list of properties and values which will be applied to the element\n\t */\n\tfunction setStyles(element, styles) {\n\t Object.keys(styles).forEach(function (prop) {\n\t var unit = '';\n\t // add unit if the value is numeric and is one of the following\n\t if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {\n\t unit = 'px';\n\t }\n\t element.style[prop] = styles[prop] + unit;\n\t });\n\t}\n\n\t/**\n\t * Set the attributes to the given popper\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {Element} element - Element to apply the attributes to\n\t * @argument {Object} styles\n\t * Object with a list of properties and values which will be applied to the element\n\t */\n\tfunction setAttributes(element, attributes) {\n\t Object.keys(attributes).forEach(function (prop) {\n\t var value = attributes[prop];\n\t if (value !== false) {\n\t element.setAttribute(prop, attributes[prop]);\n\t } else {\n\t element.removeAttribute(prop);\n\t }\n\t });\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by `update` method\n\t * @argument {Object} data.styles - List of style properties - values to apply to popper element\n\t * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The same data object\n\t */\n\tfunction applyStyle(data) {\n\t // any property present in `data.styles` will be applied to the popper,\n\t // in this way we can make the 3rd party modifiers add custom styles to it\n\t // Be aware, modifiers could override the properties defined in the previous\n\t // lines of this modifier!\n\t setStyles(data.instance.popper, data.styles);\n\n\t // any property present in `data.attributes` will be applied to the popper,\n\t // they will be set as HTML attributes of the element\n\t setAttributes(data.instance.popper, data.attributes);\n\n\t // if arrowElement is defined and arrowStyles has some properties\n\t if (data.arrowElement && Object.keys(data.arrowStyles).length) {\n\t setStyles(data.arrowElement, data.arrowStyles);\n\t }\n\n\t return data;\n\t}\n\n\t/**\n\t * Set the x-placement attribute before everything else because it could be used\n\t * to add margins to the popper margins needs to be calculated to get the\n\t * correct popper offsets.\n\t * @method\n\t * @memberof Popper.modifiers\n\t * @param {HTMLElement} reference - The reference element used to position the popper\n\t * @param {HTMLElement} popper - The HTML element used as popper.\n\t * @param {Object} options - Popper.js options\n\t */\n\tfunction applyStyleOnLoad(reference, popper, options, modifierOptions, state) {\n\t // compute reference element offsets\n\t var referenceOffsets = getReferenceOffsets(state, popper, reference);\n\n\t // compute auto placement, store placement inside the data object,\n\t // modifiers will be able to edit `placement` if needed\n\t // and refer to originalPlacement to know the original value\n\t var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);\n\n\t popper.setAttribute('x-placement', placement);\n\n\t // Apply `position` to popper before anything else because\n\t // without the position applied we can't guarantee correct computations\n\t setStyles(popper, { position: 'absolute' });\n\n\t return options;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by `update` method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction computeStyle(data, options) {\n\t var x = options.x,\n\t y = options.y;\n\t var popper = data.offsets.popper;\n\n\t // Remove this legacy support in Popper.js v2\n\n\t var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {\n\t return modifier.name === 'applyStyle';\n\t }).gpuAcceleration;\n\t if (legacyGpuAccelerationOption !== undefined) {\n\t console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');\n\t }\n\t var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;\n\n\t var offsetParent = getOffsetParent(data.instance.popper);\n\t var offsetParentRect = getBoundingClientRect(offsetParent);\n\n\t // Styles\n\t var styles = {\n\t position: popper.position\n\t };\n\n\t // floor sides to avoid blurry text\n\t var offsets = {\n\t left: Math.floor(popper.left),\n\t top: Math.floor(popper.top),\n\t bottom: Math.floor(popper.bottom),\n\t right: Math.floor(popper.right)\n\t };\n\n\t var sideA = x === 'bottom' ? 'top' : 'bottom';\n\t var sideB = y === 'right' ? 'left' : 'right';\n\n\t // if gpuAcceleration is set to `true` and transform is supported,\n\t // we use `translate3d` to apply the position to the popper we\n\t // automatically use the supported prefixed version if needed\n\t var prefixedProperty = getSupportedPropertyName('transform');\n\n\t // now, let's make a step back and look at this code closely (wtf?)\n\t // If the content of the popper grows once it's been positioned, it\n\t // may happen that the popper gets misplaced because of the new content\n\t // overflowing its reference element\n\t // To avoid this problem, we provide two options (x and y), which allow\n\t // the consumer to define the offset origin.\n\t // If we position a popper on top of a reference element, we can set\n\t // `x` to `top` to make the popper grow towards its top instead of\n\t // its bottom.\n\t var left = void 0,\n\t top = void 0;\n\t if (sideA === 'bottom') {\n\t top = -offsetParentRect.height + offsets.bottom;\n\t } else {\n\t top = offsets.top;\n\t }\n\t if (sideB === 'right') {\n\t left = -offsetParentRect.width + offsets.right;\n\t } else {\n\t left = offsets.left;\n\t }\n\t if (gpuAcceleration && prefixedProperty) {\n\t styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';\n\t styles[sideA] = 0;\n\t styles[sideB] = 0;\n\t styles.willChange = 'transform';\n\t } else {\n\t // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties\n\t var invertTop = sideA === 'bottom' ? -1 : 1;\n\t var invertLeft = sideB === 'right' ? -1 : 1;\n\t styles[sideA] = top * invertTop;\n\t styles[sideB] = left * invertLeft;\n\t styles.willChange = sideA + ', ' + sideB;\n\t }\n\n\t // Attributes\n\t var attributes = {\n\t 'x-placement': data.placement\n\t };\n\n\t // Update `data` attributes, styles and arrowStyles\n\t data.attributes = _extends({}, attributes, data.attributes);\n\t data.styles = _extends({}, styles, data.styles);\n\t data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);\n\n\t return data;\n\t}\n\n\t/**\n\t * Helper used to know if the given modifier depends from another one.
    \n\t * It checks if the needed modifier is listed and enabled.\n\t * @method\n\t * @memberof Popper.Utils\n\t * @param {Array} modifiers - list of modifiers\n\t * @param {String} requestingName - name of requesting modifier\n\t * @param {String} requestedName - name of requested modifier\n\t * @returns {Boolean}\n\t */\n\tfunction isModifierRequired(modifiers, requestingName, requestedName) {\n\t var requesting = find(modifiers, function (_ref) {\n\t var name = _ref.name;\n\t return name === requestingName;\n\t });\n\n\t var isRequired = !!requesting && modifiers.some(function (modifier) {\n\t return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;\n\t });\n\n\t if (!isRequired) {\n\t var _requesting = '`' + requestingName + '`';\n\t var requested = '`' + requestedName + '`';\n\t console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');\n\t }\n\t return isRequired;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction arrow(data, options) {\n\t // arrow depends on keepTogether in order to work\n\t if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {\n\t return data;\n\t }\n\n\t var arrowElement = options.element;\n\n\t // if arrowElement is a string, suppose it's a CSS selector\n\t if (typeof arrowElement === 'string') {\n\t arrowElement = data.instance.popper.querySelector(arrowElement);\n\n\t // if arrowElement is not found, don't run the modifier\n\t if (!arrowElement) {\n\t return data;\n\t }\n\t } else {\n\t // if the arrowElement isn't a query selector we must check that the\n\t // provided DOM node is child of its popper node\n\t if (!data.instance.popper.contains(arrowElement)) {\n\t console.warn('WARNING: `arrow.element` must be child of its popper element!');\n\t return data;\n\t }\n\t }\n\n\t var placement = data.placement.split('-')[0];\n\t var _data$offsets = data.offsets,\n\t popper = _data$offsets.popper,\n\t reference = _data$offsets.reference;\n\n\t var isVertical = ['left', 'right'].indexOf(placement) !== -1;\n\n\t var len = isVertical ? 'height' : 'width';\n\t var sideCapitalized = isVertical ? 'Top' : 'Left';\n\t var side = sideCapitalized.toLowerCase();\n\t var altSide = isVertical ? 'left' : 'top';\n\t var opSide = isVertical ? 'bottom' : 'right';\n\t var arrowElementSize = getOuterSizes(arrowElement)[len];\n\n\t //\n\t // extends keepTogether behavior making sure the popper and its\n\t // reference have enough pixels in conjuction\n\t //\n\n\t // top/left side\n\t if (reference[opSide] - arrowElementSize < popper[side]) {\n\t data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);\n\t }\n\t // bottom/right side\n\t if (reference[side] + arrowElementSize > popper[opSide]) {\n\t data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];\n\t }\n\n\t // compute center of the popper\n\t var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;\n\n\t // Compute the sideValue using the updated popper offsets\n\t // take popper margin in account because we don't have this info available\n\t var popperMarginSide = getStyleComputedProperty(data.instance.popper, 'margin' + sideCapitalized).replace('px', '');\n\t var sideValue = center - getClientRect(data.offsets.popper)[side] - popperMarginSide;\n\n\t // prevent arrowElement from being placed not contiguously to its popper\n\t sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);\n\n\t data.arrowElement = arrowElement;\n\t data.offsets.arrow = {};\n\t data.offsets.arrow[side] = Math.round(sideValue);\n\t data.offsets.arrow[altSide] = ''; // make sure to unset any eventual altSide value from the DOM node\n\n\t return data;\n\t}\n\n\t/**\n\t * Get the opposite placement variation of the given one\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {String} placement variation\n\t * @returns {String} flipped placement variation\n\t */\n\tfunction getOppositeVariation(variation) {\n\t if (variation === 'end') {\n\t return 'start';\n\t } else if (variation === 'start') {\n\t return 'end';\n\t }\n\t return variation;\n\t}\n\n\t/**\n\t * List of accepted placements to use as values of the `placement` option.
    \n\t * Valid placements are:\n\t * - `auto`\n\t * - `top`\n\t * - `right`\n\t * - `bottom`\n\t * - `left`\n\t *\n\t * Each placement can have a variation from this list:\n\t * - `-start`\n\t * - `-end`\n\t *\n\t * Variations are interpreted easily if you think of them as the left to right\n\t * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`\n\t * is right.
    \n\t * Vertically (`left` and `right`), `start` is top and `end` is bottom.\n\t *\n\t * Some valid examples are:\n\t * - `top-end` (on top of reference, right aligned)\n\t * - `right-start` (on right of reference, top aligned)\n\t * - `bottom` (on bottom, centered)\n\t * - `auto-right` (on the side with more space available, alignment depends by placement)\n\t *\n\t * @static\n\t * @type {Array}\n\t * @enum {String}\n\t * @readonly\n\t * @method placements\n\t * @memberof Popper\n\t */\n\tvar placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start'];\n\n\t// Get rid of `auto` `auto-start` and `auto-end`\n\tvar validPlacements = placements.slice(3);\n\n\t/**\n\t * Given an initial placement, returns all the subsequent placements\n\t * clockwise (or counter-clockwise).\n\t *\n\t * @method\n\t * @memberof Popper.Utils\n\t * @argument {String} placement - A valid placement (it accepts variations)\n\t * @argument {Boolean} counter - Set to true to walk the placements counterclockwise\n\t * @returns {Array} placements including their variations\n\t */\n\tfunction clockwise(placement) {\n\t var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n\t var index = validPlacements.indexOf(placement);\n\t var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));\n\t return counter ? arr.reverse() : arr;\n\t}\n\n\tvar BEHAVIORS = {\n\t FLIP: 'flip',\n\t CLOCKWISE: 'clockwise',\n\t COUNTERCLOCKWISE: 'counterclockwise'\n\t};\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction flip(data, options) {\n\t // if `inner` modifier is enabled, we can't use the `flip` modifier\n\t if (isModifierEnabled(data.instance.modifiers, 'inner')) {\n\t return data;\n\t }\n\n\t if (data.flipped && data.placement === data.originalPlacement) {\n\t // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides\n\t return data;\n\t }\n\n\t var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement);\n\n\t var placement = data.placement.split('-')[0];\n\t var placementOpposite = getOppositePlacement(placement);\n\t var variation = data.placement.split('-')[1] || '';\n\n\t var flipOrder = [];\n\n\t switch (options.behavior) {\n\t case BEHAVIORS.FLIP:\n\t flipOrder = [placement, placementOpposite];\n\t break;\n\t case BEHAVIORS.CLOCKWISE:\n\t flipOrder = clockwise(placement);\n\t break;\n\t case BEHAVIORS.COUNTERCLOCKWISE:\n\t flipOrder = clockwise(placement, true);\n\t break;\n\t default:\n\t flipOrder = options.behavior;\n\t }\n\n\t flipOrder.forEach(function (step, index) {\n\t if (placement !== step || flipOrder.length === index + 1) {\n\t return data;\n\t }\n\n\t placement = data.placement.split('-')[0];\n\t placementOpposite = getOppositePlacement(placement);\n\n\t var popperOffsets = data.offsets.popper;\n\t var refOffsets = data.offsets.reference;\n\n\t // using floor because the reference offsets may contain decimals we are not going to consider here\n\t var floor = Math.floor;\n\t var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom);\n\n\t var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);\n\t var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);\n\t var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);\n\t var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);\n\n\t var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;\n\n\t // flip the variation if required\n\t var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;\n\t var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);\n\n\t if (overlapsRef || overflowsBoundaries || flippedVariation) {\n\t // this boolean to detect any flip loop\n\t data.flipped = true;\n\n\t if (overlapsRef || overflowsBoundaries) {\n\t placement = flipOrder[index + 1];\n\t }\n\n\t if (flippedVariation) {\n\t variation = getOppositeVariation(variation);\n\t }\n\n\t data.placement = placement + (variation ? '-' + variation : '');\n\n\t // this object contains `position`, we want to preserve it along with\n\t // any additional property we may add in the future\n\t data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));\n\n\t data = runModifiers(data.instance.modifiers, data, 'flip');\n\t }\n\t });\n\t return data;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction keepTogether(data) {\n\t var _data$offsets = data.offsets,\n\t popper = _data$offsets.popper,\n\t reference = _data$offsets.reference;\n\n\t var placement = data.placement.split('-')[0];\n\t var floor = Math.floor;\n\t var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;\n\t var side = isVertical ? 'right' : 'bottom';\n\t var opSide = isVertical ? 'left' : 'top';\n\t var measurement = isVertical ? 'width' : 'height';\n\n\t if (popper[side] < floor(reference[opSide])) {\n\t data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];\n\t }\n\t if (popper[opSide] > floor(reference[side])) {\n\t data.offsets.popper[opSide] = floor(reference[side]);\n\t }\n\n\t return data;\n\t}\n\n\t/**\n\t * Converts a string containing value + unit into a px value number\n\t * @function\n\t * @memberof {modifiers~offset}\n\t * @private\n\t * @argument {String} str - Value + unit string\n\t * @argument {String} measurement - `height` or `width`\n\t * @argument {Object} popperOffsets\n\t * @argument {Object} referenceOffsets\n\t * @returns {Number|String}\n\t * Value in pixels, or original string if no values were extracted\n\t */\n\tfunction toValue(str, measurement, popperOffsets, referenceOffsets) {\n\t // separate value from unit\n\t var split = str.match(/((?:\\-|\\+)?\\d*\\.?\\d*)(.*)/);\n\t var value = +split[1];\n\t var unit = split[2];\n\n\t // If it's not a number it's an operator, I guess\n\t if (!value) {\n\t return str;\n\t }\n\n\t if (unit.indexOf('%') === 0) {\n\t var element = void 0;\n\t switch (unit) {\n\t case '%p':\n\t element = popperOffsets;\n\t break;\n\t case '%':\n\t case '%r':\n\t default:\n\t element = referenceOffsets;\n\t }\n\n\t var rect = getClientRect(element);\n\t return rect[measurement] / 100 * value;\n\t } else if (unit === 'vh' || unit === 'vw') {\n\t // if is a vh or vw, we calculate the size based on the viewport\n\t var size = void 0;\n\t if (unit === 'vh') {\n\t size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);\n\t } else {\n\t size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);\n\t }\n\t return size / 100 * value;\n\t } else {\n\t // if is an explicit pixel unit, we get rid of the unit and keep the value\n\t // if is an implicit unit, it's px, and we return just the value\n\t return value;\n\t }\n\t}\n\n\t/**\n\t * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.\n\t * @function\n\t * @memberof {modifiers~offset}\n\t * @private\n\t * @argument {String} offset\n\t * @argument {Object} popperOffsets\n\t * @argument {Object} referenceOffsets\n\t * @argument {String} basePlacement\n\t * @returns {Array} a two cells array with x and y offsets in numbers\n\t */\n\tfunction parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {\n\t var offsets = [0, 0];\n\n\t // Use height if placement is left or right and index is 0 otherwise use width\n\t // in this way the first offset will use an axis and the second one\n\t // will use the other one\n\t var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;\n\n\t // Split the offset string to obtain a list of values and operands\n\t // The regex addresses values with the plus or minus sign in front (+10, -20, etc)\n\t var fragments = offset.split(/(\\+|\\-)/).map(function (frag) {\n\t return frag.trim();\n\t });\n\n\t // Detect if the offset string contains a pair of values or a single one\n\t // they could be separated by comma or space\n\t var divider = fragments.indexOf(find(fragments, function (frag) {\n\t return frag.search(/,|\\s/) !== -1;\n\t }));\n\n\t if (fragments[divider] && fragments[divider].indexOf(',') === -1) {\n\t console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');\n\t }\n\n\t // If divider is found, we divide the list of values and operands to divide\n\t // them by ofset X and Y.\n\t var splitRegex = /\\s*,\\s*|\\s+/;\n\t var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments];\n\n\t // Convert the values with units to absolute pixels to allow our computations\n\t ops = ops.map(function (op, index) {\n\t // Most of the units rely on the orientation of the popper\n\t var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';\n\t var mergeWithPrevious = false;\n\t return op\n\t // This aggregates any `+` or `-` sign that aren't considered operators\n\t // e.g.: 10 + +5 => [10, +, +5]\n\t .reduce(function (a, b) {\n\t if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {\n\t a[a.length - 1] = b;\n\t mergeWithPrevious = true;\n\t return a;\n\t } else if (mergeWithPrevious) {\n\t a[a.length - 1] += b;\n\t mergeWithPrevious = false;\n\t return a;\n\t } else {\n\t return a.concat(b);\n\t }\n\t }, [])\n\t // Here we convert the string values into number values (in px)\n\t .map(function (str) {\n\t return toValue(str, measurement, popperOffsets, referenceOffsets);\n\t });\n\t });\n\n\t // Loop trough the offsets arrays and execute the operations\n\t ops.forEach(function (op, index) {\n\t op.forEach(function (frag, index2) {\n\t if (isNumeric(frag)) {\n\t offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);\n\t }\n\t });\n\t });\n\t return offsets;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @argument {Number|String} options.offset=0\n\t * The offset value as described in the modifier description\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction offset(data, _ref) {\n\t var offset = _ref.offset;\n\t var placement = data.placement,\n\t _data$offsets = data.offsets,\n\t popper = _data$offsets.popper,\n\t reference = _data$offsets.reference;\n\n\t var basePlacement = placement.split('-')[0];\n\n\t var offsets = void 0;\n\t if (isNumeric(+offset)) {\n\t offsets = [+offset, 0];\n\t } else {\n\t offsets = parseOffset(offset, popper, reference, basePlacement);\n\t }\n\n\t if (basePlacement === 'left') {\n\t popper.top += offsets[0];\n\t popper.left -= offsets[1];\n\t } else if (basePlacement === 'right') {\n\t popper.top += offsets[0];\n\t popper.left += offsets[1];\n\t } else if (basePlacement === 'top') {\n\t popper.left += offsets[0];\n\t popper.top -= offsets[1];\n\t } else if (basePlacement === 'bottom') {\n\t popper.left += offsets[0];\n\t popper.top += offsets[1];\n\t }\n\n\t data.popper = popper;\n\t return data;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by `update` method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction preventOverflow(data, options) {\n\t var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);\n\n\t // If offsetParent is the reference element, we really want to\n\t // go one step up and use the next offsetParent as reference to\n\t // avoid to make this modifier completely useless and look like broken\n\t if (data.instance.reference === boundariesElement) {\n\t boundariesElement = getOffsetParent(boundariesElement);\n\t }\n\n\t var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement);\n\t options.boundaries = boundaries;\n\n\t var order = options.priority;\n\t var popper = data.offsets.popper;\n\n\t var check = {\n\t primary: function primary(placement) {\n\t var value = popper[placement];\n\t if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {\n\t value = Math.max(popper[placement], boundaries[placement]);\n\t }\n\t return defineProperty({}, placement, value);\n\t },\n\t secondary: function secondary(placement) {\n\t var mainSide = placement === 'right' ? 'left' : 'top';\n\t var value = popper[mainSide];\n\t if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {\n\t value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));\n\t }\n\t return defineProperty({}, mainSide, value);\n\t }\n\t };\n\n\t order.forEach(function (placement) {\n\t var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';\n\t popper = _extends({}, popper, check[side](placement));\n\t });\n\n\t data.offsets.popper = popper;\n\n\t return data;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by `update` method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction shift(data) {\n\t var placement = data.placement;\n\t var basePlacement = placement.split('-')[0];\n\t var shiftvariation = placement.split('-')[1];\n\n\t // if shift shiftvariation is specified, run the modifier\n\t if (shiftvariation) {\n\t var _data$offsets = data.offsets,\n\t reference = _data$offsets.reference,\n\t popper = _data$offsets.popper;\n\n\t var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;\n\t var side = isVertical ? 'left' : 'top';\n\t var measurement = isVertical ? 'width' : 'height';\n\n\t var shiftOffsets = {\n\t start: defineProperty({}, side, reference[side]),\n\t end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])\n\t };\n\n\t data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);\n\t }\n\n\t return data;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by update method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction hide(data) {\n\t if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {\n\t return data;\n\t }\n\n\t var refRect = data.offsets.reference;\n\t var bound = find(data.instance.modifiers, function (modifier) {\n\t return modifier.name === 'preventOverflow';\n\t }).boundaries;\n\n\t if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {\n\t // Avoid unnecessary DOM access if visibility hasn't changed\n\t if (data.hide === true) {\n\t return data;\n\t }\n\n\t data.hide = true;\n\t data.attributes['x-out-of-boundaries'] = '';\n\t } else {\n\t // Avoid unnecessary DOM access if visibility hasn't changed\n\t if (data.hide === false) {\n\t return data;\n\t }\n\n\t data.hide = false;\n\t data.attributes['x-out-of-boundaries'] = false;\n\t }\n\n\t return data;\n\t}\n\n\t/**\n\t * @function\n\t * @memberof Modifiers\n\t * @argument {Object} data - The data object generated by `update` method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {Object} The data object, properly modified\n\t */\n\tfunction inner(data) {\n\t var placement = data.placement;\n\t var basePlacement = placement.split('-')[0];\n\t var _data$offsets = data.offsets,\n\t popper = _data$offsets.popper,\n\t reference = _data$offsets.reference;\n\n\t var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;\n\n\t var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;\n\n\t popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);\n\n\t data.placement = getOppositePlacement(placement);\n\t data.offsets.popper = getClientRect(popper);\n\n\t return data;\n\t}\n\n\t/**\n\t * Modifier function, each modifier can have a function of this type assigned\n\t * to its `fn` property.
    \n\t * These functions will be called on each update, this means that you must\n\t * make sure they are performant enough to avoid performance bottlenecks.\n\t *\n\t * @function ModifierFn\n\t * @argument {dataObject} data - The data object generated by `update` method\n\t * @argument {Object} options - Modifiers configuration and options\n\t * @returns {dataObject} The data object, properly modified\n\t */\n\n\t/**\n\t * Modifiers are plugins used to alter the behavior of your poppers.
    \n\t * Popper.js uses a set of 9 modifiers to provide all the basic functionalities\n\t * needed by the library.\n\t *\n\t * Usually you don't want to override the `order`, `fn` and `onLoad` props.\n\t * All the other properties are configurations that could be tweaked.\n\t * @namespace modifiers\n\t */\n\tvar modifiers = {\n\t /**\n\t * Modifier used to shift the popper on the start or end of its reference\n\t * element.
    \n\t * It will read the variation of the `placement` property.
    \n\t * It can be one either `-end` or `-start`.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t shift: {\n\t /** @prop {number} order=100 - Index used to define the order of execution */\n\t order: 100,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: shift\n\t },\n\n\t /**\n\t * The `offset` modifier can shift your popper on both its axis.\n\t *\n\t * It accepts the following units:\n\t * - `px` or unitless, interpreted as pixels\n\t * - `%` or `%r`, percentage relative to the length of the reference element\n\t * - `%p`, percentage relative to the length of the popper element\n\t * - `vw`, CSS viewport width unit\n\t * - `vh`, CSS viewport height unit\n\t *\n\t * For length is intended the main axis relative to the placement of the popper.
    \n\t * This means that if the placement is `top` or `bottom`, the length will be the\n\t * `width`. In case of `left` or `right`, it will be the height.\n\t *\n\t * You can provide a single value (as `Number` or `String`), or a pair of values\n\t * as `String` divided by a comma or one (or more) white spaces.
    \n\t * The latter is a deprecated method because it leads to confusion and will be\n\t * removed in v2.
    \n\t * Additionally, it accepts additions and subtractions between different units.\n\t * Note that multiplications and divisions aren't supported.\n\t *\n\t * Valid examples are:\n\t * ```\n\t * 10\n\t * '10%'\n\t * '10, 10'\n\t * '10%, 10'\n\t * '10 + 10%'\n\t * '10 - 5vh + 3%'\n\t * '-10px + 5vh, 5px - 6%'\n\t * ```\n\t * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap\n\t * > with their reference element, unfortunately, you will have to disable the `flip` modifier.\n\t * > More on this [reading this issue](https://github.com/FezVrasta/popper.js/issues/373)\n\t *\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t offset: {\n\t /** @prop {number} order=200 - Index used to define the order of execution */\n\t order: 200,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: offset,\n\t /** @prop {Number|String} offset=0\n\t * The offset value as described in the modifier description\n\t */\n\t offset: 0\n\t },\n\n\t /**\n\t * Modifier used to prevent the popper from being positioned outside the boundary.\n\t *\n\t * An scenario exists where the reference itself is not within the boundaries.
    \n\t * We can say it has \"escaped the boundaries\" — or just \"escaped\".
    \n\t * In this case we need to decide whether the popper should either:\n\t *\n\t * - detach from the reference and remain \"trapped\" in the boundaries, or\n\t * - if it should ignore the boundary and \"escape with its reference\"\n\t *\n\t * When `escapeWithReference` is set to`true` and reference is completely\n\t * outside its boundaries, the popper will overflow (or completely leave)\n\t * the boundaries in order to remain attached to the edge of the reference.\n\t *\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t preventOverflow: {\n\t /** @prop {number} order=300 - Index used to define the order of execution */\n\t order: 300,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: preventOverflow,\n\t /**\n\t * @prop {Array} [priority=['left','right','top','bottom']]\n\t * Popper will try to prevent overflow following these priorities by default,\n\t * then, it could overflow on the left and on top of the `boundariesElement`\n\t */\n\t priority: ['left', 'right', 'top', 'bottom'],\n\t /**\n\t * @prop {number} padding=5\n\t * Amount of pixel used to define a minimum distance between the boundaries\n\t * and the popper this makes sure the popper has always a little padding\n\t * between the edges of its container\n\t */\n\t padding: 5,\n\t /**\n\t * @prop {String|HTMLElement} boundariesElement='scrollParent'\n\t * Boundaries used by the modifier, can be `scrollParent`, `window`,\n\t * `viewport` or any DOM element.\n\t */\n\t boundariesElement: 'scrollParent'\n\t },\n\n\t /**\n\t * Modifier used to make sure the reference and its popper stay near eachothers\n\t * without leaving any gap between the two. Expecially useful when the arrow is\n\t * enabled and you want to assure it to point to its reference element.\n\t * It cares only about the first axis, you can still have poppers with margin\n\t * between the popper and its reference element.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t keepTogether: {\n\t /** @prop {number} order=400 - Index used to define the order of execution */\n\t order: 400,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: keepTogether\n\t },\n\n\t /**\n\t * This modifier is used to move the `arrowElement` of the popper to make\n\t * sure it is positioned between the reference element and its popper element.\n\t * It will read the outer size of the `arrowElement` node to detect how many\n\t * pixels of conjuction are needed.\n\t *\n\t * It has no effect if no `arrowElement` is provided.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t arrow: {\n\t /** @prop {number} order=500 - Index used to define the order of execution */\n\t order: 500,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: arrow,\n\t /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */\n\t element: '[x-arrow]'\n\t },\n\n\t /**\n\t * Modifier used to flip the popper's placement when it starts to overlap its\n\t * reference element.\n\t *\n\t * Requires the `preventOverflow` modifier before it in order to work.\n\t *\n\t * **NOTE:** this modifier will interrupt the current update cycle and will\n\t * restart it if it detects the need to flip the placement.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t flip: {\n\t /** @prop {number} order=600 - Index used to define the order of execution */\n\t order: 600,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: flip,\n\t /**\n\t * @prop {String|Array} behavior='flip'\n\t * The behavior used to change the popper's placement. It can be one of\n\t * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid\n\t * placements (with optional variations).\n\t */\n\t behavior: 'flip',\n\t /**\n\t * @prop {number} padding=5\n\t * The popper will flip if it hits the edges of the `boundariesElement`\n\t */\n\t padding: 5,\n\t /**\n\t * @prop {String|HTMLElement} boundariesElement='viewport'\n\t * The element which will define the boundaries of the popper position,\n\t * the popper will never be placed outside of the defined boundaries\n\t * (except if keepTogether is enabled)\n\t */\n\t boundariesElement: 'viewport'\n\t },\n\n\t /**\n\t * Modifier used to make the popper flow toward the inner of the reference element.\n\t * By default, when this modifier is disabled, the popper will be placed outside\n\t * the reference element.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t inner: {\n\t /** @prop {number} order=700 - Index used to define the order of execution */\n\t order: 700,\n\t /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */\n\t enabled: false,\n\t /** @prop {ModifierFn} */\n\t fn: inner\n\t },\n\n\t /**\n\t * Modifier used to hide the popper when its reference element is outside of the\n\t * popper boundaries. It will set a `x-out-of-boundaries` attribute which can\n\t * be used to hide with a CSS selector the popper when its reference is\n\t * out of boundaries.\n\t *\n\t * Requires the `preventOverflow` modifier before it in order to work.\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t hide: {\n\t /** @prop {number} order=800 - Index used to define the order of execution */\n\t order: 800,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: hide\n\t },\n\n\t /**\n\t * Computes the style that will be applied to the popper element to gets\n\t * properly positioned.\n\t *\n\t * Note that this modifier will not touch the DOM, it just prepares the styles\n\t * so that `applyStyle` modifier can apply it. This separation is useful\n\t * in case you need to replace `applyStyle` with a custom implementation.\n\t *\n\t * This modifier has `850` as `order` value to maintain backward compatibility\n\t * with previous versions of Popper.js. Expect the modifiers ordering method\n\t * to change in future major versions of the library.\n\t *\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t computeStyle: {\n\t /** @prop {number} order=850 - Index used to define the order of execution */\n\t order: 850,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: computeStyle,\n\t /**\n\t * @prop {Boolean} gpuAcceleration=true\n\t * If true, it uses the CSS 3d transformation to position the popper.\n\t * Otherwise, it will use the `top` and `left` properties.\n\t */\n\t gpuAcceleration: true,\n\t /**\n\t * @prop {string} [x='bottom']\n\t * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.\n\t * Change this if your popper should grow in a direction different from `bottom`\n\t */\n\t x: 'bottom',\n\t /**\n\t * @prop {string} [x='left']\n\t * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.\n\t * Change this if your popper should grow in a direction different from `right`\n\t */\n\t y: 'right'\n\t },\n\n\t /**\n\t * Applies the computed styles to the popper element.\n\t *\n\t * All the DOM manipulations are limited to this modifier. This is useful in case\n\t * you want to integrate Popper.js inside a framework or view library and you\n\t * want to delegate all the DOM manipulations to it.\n\t *\n\t * Note that if you disable this modifier, you must make sure the popper element\n\t * has its position set to `absolute` before Popper.js can do its work!\n\t *\n\t * Just disable this modifier and define you own to achieve the desired effect.\n\t *\n\t * @memberof modifiers\n\t * @inner\n\t */\n\t applyStyle: {\n\t /** @prop {number} order=900 - Index used to define the order of execution */\n\t order: 900,\n\t /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */\n\t enabled: true,\n\t /** @prop {ModifierFn} */\n\t fn: applyStyle,\n\t /** @prop {Function} */\n\t onLoad: applyStyleOnLoad,\n\t /**\n\t * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier\n\t * @prop {Boolean} gpuAcceleration=true\n\t * If true, it uses the CSS 3d transformation to position the popper.\n\t * Otherwise, it will use the `top` and `left` properties.\n\t */\n\t gpuAcceleration: undefined\n\t }\n\t};\n\n\t/**\n\t * The `dataObject` is an object containing all the informations used by Popper.js\n\t * this object get passed to modifiers and to the `onCreate` and `onUpdate` callbacks.\n\t * @name dataObject\n\t * @property {Object} data.instance The Popper.js instance\n\t * @property {String} data.placement Placement applied to popper\n\t * @property {String} data.originalPlacement Placement originally defined on init\n\t * @property {Boolean} data.flipped True if popper has been flipped by flip modifier\n\t * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper.\n\t * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier\n\t * @property {Object} data.styles Any CSS property defined here will be applied to the popper, it expects the JavaScript nomenclature (eg. `marginBottom`)\n\t * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow, it expects the JavaScript nomenclature (eg. `marginBottom`)\n\t * @property {Object} data.boundaries Offsets of the popper boundaries\n\t * @property {Object} data.offsets The measurements of popper, reference and arrow elements.\n\t * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values\n\t * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values\n\t * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0\n\t */\n\n\t/**\n\t * Default options provided to Popper.js constructor.
    \n\t * These can be overriden using the `options` argument of Popper.js.
    \n\t * To override an option, simply pass as 3rd argument an object with the same\n\t * structure of this object, example:\n\t * ```\n\t * new Popper(ref, pop, {\n\t * modifiers: {\n\t * preventOverflow: { enabled: false }\n\t * }\n\t * })\n\t * ```\n\t * @type {Object}\n\t * @static\n\t * @memberof Popper\n\t */\n\tvar Defaults = {\n\t /**\n\t * Popper's placement\n\t * @prop {Popper.placements} placement='bottom'\n\t */\n\t placement: 'bottom',\n\n\t /**\n\t * Whether events (resize, scroll) are initially enabled\n\t * @prop {Boolean} eventsEnabled=true\n\t */\n\t eventsEnabled: true,\n\n\t /**\n\t * Set to true if you want to automatically remove the popper when\n\t * you call the `destroy` method.\n\t * @prop {Boolean} removeOnDestroy=false\n\t */\n\t removeOnDestroy: false,\n\n\t /**\n\t * Callback called when the popper is created.
    \n\t * By default, is set to no-op.
    \n\t * Access Popper.js instance with `data.instance`.\n\t * @prop {onCreate}\n\t */\n\t onCreate: function onCreate() {},\n\n\t /**\n\t * Callback called when the popper is updated, this callback is not called\n\t * on the initialization/creation of the popper, but only on subsequent\n\t * updates.
    \n\t * By default, is set to no-op.
    \n\t * Access Popper.js instance with `data.instance`.\n\t * @prop {onUpdate}\n\t */\n\t onUpdate: function onUpdate() {},\n\n\t /**\n\t * List of modifiers used to modify the offsets before they are applied to the popper.\n\t * They provide most of the functionalities of Popper.js\n\t * @prop {modifiers}\n\t */\n\t modifiers: modifiers\n\t};\n\n\t/**\n\t * @callback onCreate\n\t * @param {dataObject} data\n\t */\n\n\t/**\n\t * @callback onUpdate\n\t * @param {dataObject} data\n\t */\n\n\t// Utils\n\t// Methods\n\tvar Popper = function () {\n\t /**\n\t * Create a new Popper.js instance\n\t * @class Popper\n\t * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper\n\t * @param {HTMLElement} popper - The HTML element used as popper.\n\t * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)\n\t * @return {Object} instance - The generated Popper.js instance\n\t */\n\t function Popper(reference, popper) {\n\t var _this = this;\n\n\t var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n\t classCallCheck(this, Popper);\n\n\t this.scheduleUpdate = function () {\n\t return requestAnimationFrame(_this.update);\n\t };\n\n\t // make update() debounced, so that it only runs at most once-per-tick\n\t this.update = debounce(this.update.bind(this));\n\n\t // with {} we create a new object with the options inside it\n\t this.options = _extends({}, Popper.Defaults, options);\n\n\t // init state\n\t this.state = {\n\t isDestroyed: false,\n\t isCreated: false,\n\t scrollParents: []\n\t };\n\n\t // get reference and popper elements (allow jQuery wrappers)\n\t this.reference = reference && reference.jquery ? reference[0] : reference;\n\t this.popper = popper && popper.jquery ? popper[0] : popper;\n\n\t // Deep merge modifiers options\n\t this.options.modifiers = {};\n\t Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {\n\t _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});\n\t });\n\n\t // Refactoring modifiers' list (Object => Array)\n\t this.modifiers = Object.keys(this.options.modifiers).map(function (name) {\n\t return _extends({\n\t name: name\n\t }, _this.options.modifiers[name]);\n\t })\n\t // sort the modifiers by order\n\t .sort(function (a, b) {\n\t return a.order - b.order;\n\t });\n\n\t // modifiers have the ability to execute arbitrary code when Popper.js get inited\n\t // such code is executed in the same order of its modifier\n\t // they could add new properties to their options configuration\n\t // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!\n\t this.modifiers.forEach(function (modifierOptions) {\n\t if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {\n\t modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);\n\t }\n\t });\n\n\t // fire the first update to position the popper in the right place\n\t this.update();\n\n\t var eventsEnabled = this.options.eventsEnabled;\n\t if (eventsEnabled) {\n\t // setup event listeners, they will take care of update the position in specific situations\n\t this.enableEventListeners();\n\t }\n\n\t this.state.eventsEnabled = eventsEnabled;\n\t }\n\n\t // We can't use class properties because they don't get listed in the\n\t // class prototype and break stuff like Sinon stubs\n\n\n\t createClass(Popper, [{\n\t key: 'update',\n\t value: function update$$1() {\n\t return update.call(this);\n\t }\n\t }, {\n\t key: 'destroy',\n\t value: function destroy$$1() {\n\t return destroy.call(this);\n\t }\n\t }, {\n\t key: 'enableEventListeners',\n\t value: function enableEventListeners$$1() {\n\t return enableEventListeners.call(this);\n\t }\n\t }, {\n\t key: 'disableEventListeners',\n\t value: function disableEventListeners$$1() {\n\t return disableEventListeners.call(this);\n\t }\n\n\t /**\n\t * Schedule an update, it will run on the next UI update available\n\t * @method scheduleUpdate\n\t * @memberof Popper\n\t */\n\n\n\t /**\n\t * Collection of utilities useful when writing custom modifiers.\n\t * Starting from version 1.7, this method is available only if you\n\t * include `popper-utils.js` before `popper.js`.\n\t *\n\t * **DEPRECATION**: This way to access PopperUtils is deprecated\n\t * and will be removed in v2! Use the PopperUtils module directly instead.\n\t * Due to the high instability of the methods contained in Utils, we can't\n\t * guarantee them to follow semver. Use them at your own risk!\n\t * @static\n\t * @private\n\t * @type {Object}\n\t * @deprecated since version 1.8\n\t * @member Utils\n\t * @memberof Popper\n\t */\n\n\t }]);\n\t return Popper;\n\t}();\n\n\t/**\n\t * The `referenceObject` is an object that provides an interface compatible with Popper.js\n\t * and lets you use it as replacement of a real DOM node.
    \n\t * You can use this method to position a popper relatively to a set of coordinates\n\t * in case you don't have a DOM node to use as reference.\n\t *\n\t * ```\n\t * new Popper(referenceObject, popperNode);\n\t * ```\n\t *\n\t * NB: This feature isn't supported in Internet Explorer 10\n\t * @name referenceObject\n\t * @property {Function} data.getBoundingClientRect\n\t * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.\n\t * @property {number} data.clientWidth\n\t * An ES6 getter that will return the width of the virtual reference element.\n\t * @property {number} data.clientHeight\n\t * An ES6 getter that will return the height of the virtual reference element.\n\t */\n\n\n\tPopper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;\n\tPopper.placements = placements;\n\tPopper.Defaults = Defaults;\n\n\treturn Popper;\n\n\t})));\n\t//# sourceMappingURL=popper.js.map\n\n\t/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/***/ }),\n/* 27 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\n\tvar _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\n\tvar _react = __webpack_require__(3);\n\n\tvar _react2 = _interopRequireDefault(_react);\n\n\tvar _propTypes = __webpack_require__(4);\n\n\tvar _propTypes2 = _interopRequireDefault(_propTypes);\n\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n\tfunction _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }\n\n\tvar Arrow = function Arrow(props, context) {\n\t var _props$component = props.component,\n\t component = _props$component === undefined ? 'span' : _props$component,\n\t innerRef = props.innerRef,\n\t children = props.children,\n\t restProps = _objectWithoutProperties(props, ['component', 'innerRef', 'children']);\n\n\t var popper = context.popper;\n\n\t var arrowRef = function arrowRef(node) {\n\t popper.setArrowNode(node);\n\t if (typeof innerRef === 'function') {\n\t innerRef(node);\n\t }\n\t };\n\t var arrowStyle = popper.getArrowStyle();\n\n\t if (typeof children === 'function') {\n\t var arrowProps = {\n\t ref: arrowRef,\n\t style: arrowStyle\n\t };\n\t return children({ arrowProps: arrowProps, restProps: restProps });\n\t }\n\n\t var componentProps = _extends({}, restProps, {\n\t style: _extends({}, arrowStyle, restProps.style)\n\t });\n\n\t if (typeof component === 'string') {\n\t componentProps.ref = arrowRef;\n\t } else {\n\t componentProps.innerRef = arrowRef;\n\t }\n\n\t return (0, _react.createElement)(component, componentProps, children);\n\t};\n\n\tArrow.contextTypes = {\n\t popper: _propTypes2.default.object.isRequired\n\t};\n\n\tArrow.propTypes = {\n\t component: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func]),\n\t innerRef: _propTypes2.default.func,\n\t children: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.func])\n\t};\n\n\texports.default = Arrow;\n\n/***/ })\n/******/ ])\n});\n;"},"repo_name":{"kind":"string","value":"tholu/cdnjs"},"path":{"kind":"string","value":"ajax/libs/react-datepicker/0.59.0/react-datepicker.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"mit"},"size":{"kind":"number","value":229566,"string":"229,566"}}},{"rowIdx":61538454,"cells":{"code":{"kind":"string","value":"// { dg-options \"-std=gnu++0x\" }\n// { dg-do compile }\n\n// Copyright (C) 2007-2013 Free Software Foundation, Inc.\n//\n// This file is part of the GNU ISO C++ Library. This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 3, or (at your option)\n// any later version.\n//\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this library; see the file COPYING3. If not see\n// .\n\n#include \n\nusing namespace std;\ntemplate class unordered_multiset, equal_to, allocator>;\n"},"repo_name":{"kind":"string","value":"Xilinx/gcc"},"path":{"kind":"string","value":"libstdc++-v3/testsuite/23_containers/unordered_multiset/requirements/explicit_instantiation/3.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":953,"string":"953"}}},{"rowIdx":61538455,"cells":{"code":{"kind":"string","value":"{$field_name})) {\n // If the entity belongs to a bundle that was deleted, return early.\n continue;\n }\n $id = $wrapper->getIdentifier();\n $items[$id] = array();\n $gids = og_get_entity_groups($entity_type, $entity, array(OG_STATE_ACTIVE), $field_name);\n\n if (empty($gids[$target_type])) {\n continue;\n }\n\n foreach ($gids[$target_type] as $gid) {\n $items[$id][] = array(\n 'target_id' => $gid,\n );\n }\n }\n }\n\n /**\n * Implements EntityReference_BehaviorHandler_Abstract::insert().\n */\n public function insert($entity_type, $entity, $field, $instance, $langcode, &$items) {\n if (!empty($entity->skip_og_membership)) {\n return;\n }\n $this->OgMembershipCrud($entity_type, $entity, $field, $instance, $langcode, $items);\n $items = array();\n }\n\n /**\n * Implements EntityReference_BehaviorHandler_Abstract::access().\n */\n public function update($entity_type, $entity, $field, $instance, $langcode, &$items) {\n if (!empty($entity->skip_og_membership)) {\n return;\n }\n $this->OgMembershipCrud($entity_type, $entity, $field, $instance, $langcode, $items);\n $items = array();\n }\n\n /**\n * Implements EntityReference_BehaviorHandler_Abstract::Delete()\n *\n * CRUD memberships from field, or if entity is marked for deleteing,\n * delete all the OG membership related to it.\n *\n * @see og_entity_delete().\n */\n public function delete($entity_type, $entity, $field, $instance, $langcode, &$items) {\n if (!empty($entity->skip_og_membership)) {\n return;\n }\n if (!empty($entity->delete_og_membership)) {\n // Delete all OG memberships related to this entity.\n $og_memberships = array();\n foreach (og_get_entity_groups($entity_type, $entity) as $group_type => $ids) {\n $og_memberships = array_merge($og_memberships, array_keys($ids));\n }\n if ($og_memberships) {\n og_membership_delete_multiple($og_memberships);\n }\n\n }\n else {\n $this->OgMembershipCrud($entity_type, $entity, $field, $instance, $langcode, $items);\n }\n }\n\n /**\n * Create, update or delete OG membership based on field values.\n */\n public function OgMembershipCrud($entity_type, $entity, $field, $instance, $langcode, &$items) {\n if (!user_access('administer group') && !field_access('edit', $field, $entity_type, $entity)) {\n // User has no access to field.\n return;\n }\n if (!$diff = $this->groupAudiencegetDiff($entity_type, $entity, $field, $instance, $langcode, $items)) {\n return;\n }\n\n $field_name = $field['field_name'];\n $group_type = $field['settings']['target_type'];\n\n $diff += array('insert' => array(), 'delete' => array());\n\n // Delete first, so we don't trigger cardinality errors.\n if ($diff['delete']) {\n og_membership_delete_multiple($diff['delete']);\n }\n\n if (!$diff['insert']) {\n return;\n }\n\n // Prepare an array with the membership state, if it was provided in the widget.\n $states = array();\n foreach ($items as $item) {\n $gid = $item['target_id'];\n if (empty($item['state']) || !in_array($gid, $diff['insert'])) {\n // State isn't provided, or not an \"insert\" operation.\n continue;\n }\n $states[$gid] = $item['state'];\n }\n\n foreach ($diff['insert'] as $gid) {\n $values = array(\n 'entity_type' => $entity_type,\n 'entity' => $entity,\n 'field_name' => $field_name,\n );\n\n if (!empty($states[$gid])) {\n $values['state'] = $states[$gid];\n }\n\n og_group($group_type, $gid, $values);\n }\n }\n\n /**\n * Get the difference in group audience for a saved field.\n *\n * @return\n * Array with all the differences, or an empty array if none found.\n */\n public function groupAudiencegetDiff($entity_type, $entity, $field, $instance, $langcode, $items) {\n $return = FALSE;\n\n $field_name = $field['field_name'];\n $wrapper = entity_metadata_wrapper($entity_type, $entity);\n $og_memberships = $wrapper->{$field_name . '__og_membership'}->value();\n\n $new_memberships = array();\n foreach ($items as $item) {\n $new_memberships[$item['target_id']] = TRUE;\n }\n\n foreach ($og_memberships as $og_membership) {\n $gid = $og_membership->gid;\n if (empty($new_memberships[$gid])) {\n // Membership was deleted.\n if ($og_membership->entity_type == 'user') {\n // Make sure this is not the group manager, if exists.\n $group = entity_load_single($og_membership->group_type, $og_membership->gid);\n if (!empty($group->uid) && $group->uid == $og_membership->etid) {\n continue;\n }\n }\n\n $return['delete'][] = $og_membership->id;\n unset($new_memberships[$gid]);\n }\n else {\n // Existing membership.\n unset($new_memberships[$gid]);\n }\n }\n if ($new_memberships) {\n // New memberships.\n $return['insert'] = array_keys($new_memberships);\n }\n\n return $return;\n }\n\n /**\n * Implements EntityReference_BehaviorHandler_Abstract::views_data_alter().\n */\n public function views_data_alter(&$data, $field) {\n // We need to override the default EntityReference table settings when OG\n // behavior is being used.\n if (og_is_group_audience_field($field['field_name'])) {\n $entity_types = array_keys($field['bundles']);\n // We need to join the base table for the entities\n // that this field is attached to.\n foreach ($entity_types as $entity_type) {\n $entity_info = entity_get_info($entity_type);\n $data['og_membership'] = array(\n 'table' => array(\n 'join' => array(\n $entity_info['base table'] => array(\n // Join entity base table on its id field with left_field.\n 'left_field' => $entity_info['entity keys']['id'],\n 'field' => 'etid',\n 'extra' => array(\n 0 => array(\n 'field' => 'entity_type',\n 'value' => $entity_type,\n ),\n ),\n ),\n ),\n ),\n // Copy the original config from the table definition.\n $field['field_name'] => $data['field_data_' . $field['field_name']][$field['field_name']],\n $field['field_name'] . '_target_id' => $data['field_data_' . $field['field_name']][$field['field_name'] . '_target_id'],\n );\n\n // Change config with settings from og_membership table.\n foreach (array('filter', 'argument', 'sort') as $op) {\n $data['og_membership'][$field['field_name'] . '_target_id'][$op]['field'] = 'gid';\n $data['og_membership'][$field['field_name'] . '_target_id'][$op]['table'] = 'og_membership';\n unset($data['og_membership'][$field['field_name'] . '_target_id'][$op]['additional fields']);\n }\n }\n\n // Get rid of the original table configs.\n unset($data['field_data_' . $field['field_name']]);\n unset($data['field_revision_' . $field['field_name']]);\n }\n }\n\n /**\n * Implements EntityReference_BehaviorHandler_Abstract::validate().\n *\n * Re-build $errors array to be keyed correctly by \"default\" and \"admin\" field\n * modes.\n *\n * @todo: Try to get the correct delta so we can highlight the invalid\n * reference.\n *\n * @see entityreference_field_validate().\n */\n public function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {\n $new_errors = array();\n $values = array('default' => array(), 'admin' => array());\n // If the widget type name starts with 'og_' we suppose it is separated\n // into an admin and default part.\n if (strpos($instance['widget']['type'], 'og_') === 0) {\n foreach ($items as $item) {\n $values[$item['field_mode']][] = $item['target_id'];\n }\n }\n else {\n foreach ($items as $item) {\n $values['default'][] = $item['target_id'];\n }\n }\n\n $field_name = $field['field_name'];\n\n foreach ($values as $field_mode => $ids) {\n if (!$ids) {\n continue;\n }\n\n if ($field_mode == 'admin' && !user_access('administer group')) {\n // No need to validate the admin, as the user has no access to it.\n continue;\n }\n\n $instance['field_mode'] = $field_mode;\n $valid_ids = entityreference_get_selection_handler($field, $instance, $entity_type, $entity)->validateReferencableEntities($ids);\n\n if ($invalid_entities = array_diff($ids, $valid_ids)) {\n foreach ($invalid_entities as $id) {\n $new_errors[$field_mode][] = array(\n 'error' => 'og_invalid_entity',\n 'message' => t('The referenced group (@type: @id) is invalid.', array('@type' => $field['settings']['target_type'], '@id' => $id)),\n );\n }\n }\n }\n\n if ($new_errors) {\n og_field_widget_register_errors($field_name, $new_errors);\n }\n\n // Errors for this field now handled, removing from the referenced array.\n unset($errors[$field_name]);\n }\n}\n"},"repo_name":{"kind":"string","value":"johnlaine1/installer"},"path":{"kind":"string","value":"sites/all/modules/og/plugins/entityreference/behavior/OgBehaviorHandler.class.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":9888,"string":"9,888"}}},{"rowIdx":61538456,"cells":{"code":{"kind":"string","value":"// 2005-12-20 Paolo Carlini \n\n// Copyright (C) 2005-2013 Free Software Foundation, Inc.\n//\n// This file is part of the GNU ISO C++ Library. This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 3, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License along\n// with this library; see the file COPYING3. If not see\n// .\n\n// 23.2.1.3 deque::swap\n\n#include \n#include \n#include \n\n// uneq_allocator as a non-empty allocator.\nvoid\ntest01()\n{\n bool test __attribute__((unused)) = true;\n using namespace std;\n\n typedef __gnu_test::uneq_allocator my_alloc;\n typedef deque my_deque;\n\n const char title01[] = \"Rivers of sand\";\n const char title02[] = \"Concret PH\";\n const char title03[] = \"Sonatas and Interludes for Prepared Piano\";\n const char title04[] = \"never as tired as when i'm waking up\";\n\n const size_t N1 = sizeof(title01);\n const size_t N2 = sizeof(title02);\n const size_t N3 = sizeof(title03);\n const size_t N4 = sizeof(title04);\n\n my_deque::size_type size01, size02;\n\n my_alloc alloc01(1);\n\n my_deque deq01(alloc01);\n size01 = deq01.size();\n my_deque deq02(alloc01);\n size02 = deq02.size();\n \n deq01.swap(deq02);\n VERIFY( deq01.size() == size02 );\n VERIFY( deq01.empty() );\n VERIFY( deq02.size() == size01 );\n VERIFY( deq02.empty() );\n\n my_deque deq03(alloc01);\n size01 = deq03.size();\n my_deque deq04(title02, title02 + N2, alloc01);\n size02 = deq04.size();\n \n deq03.swap(deq04);\n VERIFY( deq03.size() == size02 );\n VERIFY( equal(deq03.begin(), deq03.end(), title02) );\n VERIFY( deq04.size() == size01 );\n VERIFY( deq04.empty() );\n \n my_deque deq05(title01, title01 + N1, alloc01);\n size01 = deq05.size();\n my_deque deq06(title02, title02 + N2, alloc01);\n size02 = deq06.size();\n \n deq05.swap(deq06);\n VERIFY( deq05.size() == size02 );\n VERIFY( equal(deq05.begin(), deq05.end(), title02) );\n VERIFY( deq06.size() == size01 );\n VERIFY( equal(deq06.begin(), deq06.end(), title01) );\n\n my_deque deq07(title01, title01 + N1, alloc01);\n size01 = deq07.size();\n my_deque deq08(title03, title03 + N3, alloc01);\n size02 = deq08.size();\n\n deq07.swap(deq08);\n VERIFY( deq07.size() == size02 );\n VERIFY( equal(deq07.begin(), deq07.end(), title03) );\n VERIFY( deq08.size() == size01 );\n VERIFY( equal(deq08.begin(), deq08.end(), title01) );\n\n my_deque deq09(title03, title03 + N3, alloc01);\n size01 = deq09.size();\n my_deque deq10(title04, title04 + N4, alloc01);\n size02 = deq10.size();\n\n deq09.swap(deq10);\n VERIFY( deq09.size() == size02 );\n VERIFY( equal(deq09.begin(), deq09.end(), title04) );\n VERIFY( deq10.size() == size01 );\n VERIFY( equal(deq10.begin(), deq10.end(), title03) );\n\n my_deque deq11(title04, title04 + N4, alloc01);\n size01 = deq11.size();\n my_deque deq12(title01, title01 + N1, alloc01);\n size02 = deq12.size();\n\n deq11.swap(deq12);\n VERIFY( deq11.size() == size02 );\n VERIFY( equal(deq11.begin(), deq11.end(), title01) );\n VERIFY( deq12.size() == size01 );\n VERIFY( equal(deq12.begin(), deq12.end(), title04) );\n\n my_deque deq13(title03, title03 + N3, alloc01);\n size01 = deq13.size();\n my_deque deq14(title03, title03 + N3, alloc01);\n size02 = deq14.size();\n\n deq13.swap(deq14);\n VERIFY( deq13.size() == size02 );\n VERIFY( equal(deq13.begin(), deq13.end(), title03) );\n VERIFY( deq14.size() == size01 );\n VERIFY( equal(deq14.begin(), deq14.end(), title03) );\n}\n\nint main()\n{ \n test01();\n return 0;\n}\n"},"repo_name":{"kind":"string","value":"skristiansson/eco32-gcc"},"path":{"kind":"string","value":"libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/2.cc"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"gpl-2.0"},"size":{"kind":"number","value":3966,"string":"3,966"}}},{"rowIdx":61538457,"cells":{"code":{"kind":"string","value":"libdir.'/simpletest/testportfoliolib.php');\nrequire_once($CFG->dirroot.'/portfolio/download/lib.php');\n\n/*\n * TODO: The portfolio unit tests were obselete and did not work.\n * They have been commented out so that they do not break the\n * unit tests in Moodle 2.\n *\n * At some point:\n * 1. These tests should be audited to see which ones were valuable.\n * 2. The useful ones should be rewritten using the current standards\n * for writing test cases.\n *\n * This might be left until Moodle 2.1 when the test case framework\n * is due to change.\n\nMock::generate('boxclient', 'mock_boxclient');\nMock::generatePartial('portfolio_plugin_download', 'mock_downloadplugin', array('ensure_ticket', 'ensure_account_tree'));\n*/\n\nclass testPortfolioPluginDownload extends portfoliolib_test {\n public static $includecoverage = array('lib/portfoliolib.php', 'portfolio/download/lib.php');\n public function setUp() {\n parent::setUp();\n// $this->plugin = new mock_boxnetplugin($this);\n// $this->plugin->boxclient = new mock_boxclient();\n }\n\n public function tearDown() {\n parent::tearDown();\n }\n\n}\n\n"},"repo_name":{"kind":"string","value":"dhamma-dev/SEA"},"path":{"kind":"string","value":"web/portfolio/download/simpletest/testportfolioplugindownload.php"},"language":{"kind":"string","value":"PHP"},"license":{"kind":"string","value":"gpl-3.0"},"size":{"kind":"number","value":1151,"string":"1,151"}}},{"rowIdx":61538458,"cells":{"code":{"kind":"string","value":"/**********\nThis library is free software; you can redistribute it and/or modify it under\nthe terms of the GNU Lesser General Public License as published by the\nFree Software Foundation; either version 2.1 of the License, or (at your\noption) any later version. (See .)\n\nThis library is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\nFOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for\nmore details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this library; if not, write to the Free Software Foundation, Inc.,\n51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n**********/\n// \"liveMedia\"\n// Copyright (c) 1996-2012 Live Networks, Inc. All rights reserved.\n// RTP sink for VP8 video\n// C++ header\n\n#ifndef _VP8_VIDEO_RTP_SINK_HH\n#define _VP8_VIDEO_RTP_SINK_HH\n\n#ifndef _VIDEO_RTP_SINK_HH\n#include \"VideoRTPSink.hh\"\n#endif\n\nclass VP8VideoRTPSink: public VideoRTPSink {\npublic:\n static VP8VideoRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);\n\nprotected:\n VP8VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);\n\t// called only by createNew()\n\n virtual ~VP8VideoRTPSink();\n\nprivate: // redefined virtual functions:\n virtual void doSpecialFrameHandling(unsigned fragmentationOffset,\n unsigned char* frameStart,\n unsigned numBytesInFrame,\n struct timeval framePresentationTime,\n unsigned numRemainingBytes);\n virtual\n Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,\n\t\t\t\t\t unsigned numBytesInFrame) const;\n virtual unsigned specialHeaderSize() const;\n};\n\n#endif\n"},"repo_name":{"kind":"string","value":"hungld87/live555-for-win32"},"path":{"kind":"string","value":"liveMedia/include/VP8VideoRTPSink.hh"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"lgpl-2.1"},"size":{"kind":"number","value":1917,"string":"1,917"}}},{"rowIdx":61538459,"cells":{"code":{"kind":"string","value":"/*\n * Copyright 2013 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.apps.dashclock.phone;\n\nimport com.google.android.apps.dashclock.LogUtils;\nimport com.google.android.apps.dashclock.api.DashClockExtension;\nimport com.google.android.apps.dashclock.api.ExtensionData;\n\nimport net.nurik.roman.dashclock.R;\n\nimport android.annotation.TargetApi;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.database.Cursor;\nimport android.net.Uri;\nimport android.os.Build;\nimport android.provider.ContactsContract;\nimport android.provider.Telephony;\nimport android.text.TextUtils;\n\nimport java.util.HashSet;\nimport java.util.Set;\n\nimport static com.google.android.apps.dashclock.LogUtils.LOGD;\nimport static com.google.android.apps.dashclock.LogUtils.LOGE;\nimport static com.google.android.apps.dashclock.LogUtils.LOGW;\n\n/**\n * Unread SMS and MMS's extension.\n */\npublic class SmsExtension extends DashClockExtension {\n private static final String TAG = LogUtils.makeLogTag(SmsExtension.class);\n\n @Override\n protected void onInitialize(boolean isReconnect) {\n super.onInitialize(isReconnect);\n if (!isReconnect) {\n addWatchContentUris(new String[]{\n TelephonyProviderConstants.MmsSms.CONTENT_URI.toString(),\n });\n }\n }\n\n @Override\n protected void onUpdateData(int reason) {\n long lastUnreadThreadId = 0;\n Set unreadThreadIds = new HashSet();\n Set unreadThreadParticipantNames = new HashSet();\n boolean showingAllConversationParticipants = false;\n\n Cursor cursor = tryOpenSimpleThreadsCursor();\n if (cursor != null) {\n while (cursor.moveToNext()) {\n if (cursor.getInt(SimpleThreadsQuery.READ) == 0) {\n long threadId = cursor.getLong(SimpleThreadsQuery._ID);\n unreadThreadIds.add(threadId);\n lastUnreadThreadId = threadId;\n\n // Some devices will fail on tryOpenMmsSmsCursor below, so\n // store a list of participants on unread threads as a fallback.\n String recipientIdsStr = cursor.getString(SimpleThreadsQuery.RECIPIENT_IDS);\n if (!TextUtils.isEmpty(recipientIdsStr)) {\n String[] recipientIds = TextUtils.split(recipientIdsStr, \" \");\n for (String recipientId : recipientIds) {\n Cursor canonAddrCursor = tryOpenCanonicalAddressCursorById(\n Long.parseLong(recipientId));\n if (canonAddrCursor == null) {\n continue;\n }\n if (canonAddrCursor.moveToFirst()) {\n String address = canonAddrCursor.getString(\n CanonicalAddressQuery.ADDRESS);\n String displayName = getDisplayNameForContact(0, address);\n if (!TextUtils.isEmpty(displayName)) {\n unreadThreadParticipantNames.add(displayName);\n }\n }\n canonAddrCursor.close();\n }\n }\n }\n }\n cursor.close();\n\n LOGD(TAG, \"Unread thread IDs: [\" + TextUtils.join(\", \", unreadThreadIds) + \"]\");\n }\n\n int unreadConversations = 0;\n StringBuilder names = new StringBuilder();\n cursor = tryOpenMmsSmsCursor();\n if (cursor != null) {\n // Most devices will hit this code path.\n while (cursor.moveToNext()) {\n // Get display name. SMS's are easy; MMS's not so much.\n long id = cursor.getLong(MmsSmsQuery._ID);\n long contactId = cursor.getLong(MmsSmsQuery.PERSON);\n String address = cursor.getString(MmsSmsQuery.ADDRESS);\n long threadId = cursor.getLong(MmsSmsQuery.THREAD_ID);\n if (unreadThreadIds != null && !unreadThreadIds.contains(threadId)) {\n // We have the list of all thread IDs (same as what the messaging app uses), and\n // this supposedly unread message's thread isn't in the list. This message is\n // likely an orphaned message whose thread was deleted. Not skipping it is\n // likely the cause of http://code.google.com/p/dashclock/issues/detail?id=8\n LOGD(TAG, \"Skipping probably orphaned message \" + id + \" with thread ID \"\n + threadId);\n continue;\n }\n\n ++unreadConversations;\n lastUnreadThreadId = threadId;\n\n if (contactId == 0 && TextUtils.isEmpty(address) && id != 0) {\n // Try MMS addr query\n Cursor addrCursor = tryOpenMmsAddrCursor(id);\n if (addrCursor != null) {\n if (addrCursor.moveToFirst()) {\n contactId = addrCursor.getLong(MmsAddrQuery.CONTACT_ID);\n address = addrCursor.getString(MmsAddrQuery.ADDRESS);\n }\n addrCursor.close();\n }\n }\n\n String displayName = getDisplayNameForContact(contactId, address);\n\n if (names.length() > 0) {\n names.append(\", \");\n }\n names.append(displayName);\n }\n cursor.close();\n\n } else {\n // In case the cursor is null (some Samsung devices like the Galaxy S4), use the\n // fall back on the list of participants in unread threads.\n unreadConversations = unreadThreadIds.size();\n names.append(TextUtils.join(\", \", unreadThreadParticipantNames));\n showingAllConversationParticipants = true;\n }\n\n PackageManager pm = getPackageManager();\n Intent clickIntent = null;\n if (unreadConversations == 1 && lastUnreadThreadId > 0) {\n clickIntent = new Intent(Intent.ACTION_VIEW,\n TelephonyProviderConstants.MmsSms.CONTENT_CONVERSATIONS_URI.buildUpon()\n .appendPath(Long.toString(lastUnreadThreadId)).build());\n }\n\n // If the default SMS app doesn't support ACTION_VIEW on the conversation URI,\n // or if there are multiple unread conversations, try opening the app landing screen\n // by implicit intent.\n if (clickIntent == null || pm.resolveActivity(clickIntent, 0) == null) {\n clickIntent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN,\n Intent.CATEGORY_APP_MESSAGING);\n\n // If the default SMS app doesn't support CATEGORY_APP_MESSAGING, try KitKat's\n // new API to get the default package (if the API is available).\n if (pm.resolveActivity(clickIntent, 0) == null) {\n clickIntent = tryGetKitKatDefaultSmsActivity();\n }\n }\n\n publishUpdate(new ExtensionData()\n .visible(unreadConversations > 0)\n .icon(R.drawable.ic_extension_sms)\n .status(Integer.toString(unreadConversations))\n .expandedTitle(\n getResources().getQuantityString(\n R.plurals.sms_title_template, unreadConversations,\n unreadConversations))\n .expandedBody(getString(showingAllConversationParticipants\n ? R.string.sms_body_all_participants_template\n : R.string.sms_body_template,\n names.toString()))\n .clickIntent(clickIntent));\n }\n\n @TargetApi(Build.VERSION_CODES.KITKAT)\n private Intent tryGetKitKatDefaultSmsActivity() {\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {\n String smsPackage = Telephony.Sms.getDefaultSmsPackage(this);\n if (TextUtils.isEmpty(smsPackage)) {\n return null;\n }\n\n return new Intent()\n .setAction(Intent.ACTION_MAIN)\n .addCategory(Intent.CATEGORY_LAUNCHER)\n .setPackage(smsPackage);\n }\n return null;\n }\n\n /**\n * Returns the display name for the contact with the given ID and/or the given address\n * (phone number). One or both parameters should be provided.\n */\n private String getDisplayNameForContact(long contactId, String address) {\n String displayName = address;\n\n if (contactId > 0) {\n Cursor contactCursor = tryOpenContactsCursorById(contactId);\n if (contactCursor != null) {\n if (contactCursor.moveToFirst()) {\n displayName = contactCursor.getString(RawContactsQuery.DISPLAY_NAME);\n } else {\n contactId = 0;\n }\n contactCursor.close();\n }\n }\n\n if (contactId <= 0) {\n Cursor contactCursor = tryOpenContactsCursorByAddress(address);\n if (contactCursor != null) {\n if (contactCursor.moveToFirst()) {\n displayName = contactCursor.getString(ContactsQuery.DISPLAY_NAME);\n }\n contactCursor.close();\n }\n }\n\n return displayName;\n }\n\n private Cursor tryOpenMmsSmsCursor() {\n try {\n return getContentResolver().query(\n TelephonyProviderConstants.MmsSms.CONTENT_CONVERSATIONS_URI,\n MmsSmsQuery.PROJECTION,\n TelephonyProviderConstants.Mms.READ + \"=0 AND \"\n + TelephonyProviderConstants.Mms.THREAD_ID + \"!=0 AND (\"\n + TelephonyProviderConstants.Mms.MESSAGE_BOX + \"=\"\n + TelephonyProviderConstants.Mms.MESSAGE_BOX_INBOX + \" OR \"\n + TelephonyProviderConstants.Sms.TYPE + \"=\"\n + TelephonyProviderConstants.Sms.MESSAGE_TYPE_INBOX + \")\",\n null,\n null);\n\n } catch (Exception e) {\n // Catch all exceptions because the SMS provider is crashy\n // From developer console: \"SQLiteException: table spam_filter already exists\"\n LOGE(TAG, \"Error accessing conversations cursor in SMS/MMS provider\", e);\n return null;\n }\n }\n\n private Cursor tryOpenSimpleThreadsCursor() {\n try {\n return getContentResolver().query(\n TelephonyProviderConstants.Threads.CONTENT_URI\n .buildUpon()\n .appendQueryParameter(\"simple\", \"true\")\n .build(),\n SimpleThreadsQuery.PROJECTION,\n null,\n null,\n null);\n\n } catch (Exception e) {\n LOGW(TAG, \"Error accessing simple SMS threads cursor\", e);\n return null;\n }\n }\n\n private Cursor tryOpenCanonicalAddressCursorById(long id) {\n try {\n return getContentResolver().query(\n TelephonyProviderConstants.CanonicalAddresses.CONTENT_URI.buildUpon()\n .build(),\n CanonicalAddressQuery.PROJECTION,\n TelephonyProviderConstants.CanonicalAddresses._ID + \"=?\",\n new String[]{Long.toString(id)},\n null);\n\n } catch (Exception e) {\n LOGE(TAG, \"Error accessing canonical addresses cursor\", e);\n return null;\n }\n }\n\n private Cursor tryOpenMmsAddrCursor(long mmsMsgId) {\n try {\n return getContentResolver().query(\n TelephonyProviderConstants.Mms.CONTENT_URI.buildUpon()\n .appendPath(Long.toString(mmsMsgId))\n .appendPath(\"addr\")\n .build(),\n MmsAddrQuery.PROJECTION,\n TelephonyProviderConstants.Mms.Addr.MSG_ID + \"=?\",\n new String[]{Long.toString(mmsMsgId)},\n null);\n\n } catch (Exception e) {\n // Catch all exceptions because the SMS provider is crashy\n // From developer console: \"SQLiteException: table spam_filter already exists\"\n LOGE(TAG, \"Error accessing MMS addresses cursor\", e);\n return null;\n }\n }\n\n private Cursor tryOpenContactsCursorById(long contactId) {\n try {\n return getContentResolver().query(\n ContactsContract.RawContacts.CONTENT_URI.buildUpon()\n .appendPath(Long.toString(contactId))\n .build(),\n RawContactsQuery.PROJECTION,\n null,\n null,\n null);\n\n } catch (Exception e) {\n LOGE(TAG, \"Error accessing contacts provider\", e);\n return null;\n }\n }\n\n private Cursor tryOpenContactsCursorByAddress(String phoneNumber) {\n try {\n return getContentResolver().query(\n ContactsContract.PhoneLookup.CONTENT_FILTER_URI.buildUpon()\n .appendPath(Uri.encode(phoneNumber)).build(),\n ContactsQuery.PROJECTION,\n null,\n null,\n null);\n\n } catch (Exception e) {\n // Can be called by the content provider (from Google Play crash/ANR console)\n // java.lang.IllegalArgumentException: URI: content://com.android.contacts/phone_lookup/\n LOGW(TAG, \"Error looking up contact name\", e);\n return null;\n }\n }\n\n private interface SimpleThreadsQuery {\n String[] PROJECTION = {\n TelephonyProviderConstants.Threads._ID,\n TelephonyProviderConstants.Threads.READ,\n TelephonyProviderConstants.Threads.RECIPIENT_IDS,\n };\n\n int _ID = 0;\n int READ = 1;\n int RECIPIENT_IDS = 2;\n }\n\n private interface CanonicalAddressQuery {\n String[] PROJECTION = {\n TelephonyProviderConstants.CanonicalAddresses._ID,\n TelephonyProviderConstants.CanonicalAddresses.ADDRESS,\n };\n\n int _ID = 0;\n int ADDRESS = 1;\n }\n\n private interface MmsSmsQuery {\n String[] PROJECTION = {\n TelephonyProviderConstants.Sms._ID,\n TelephonyProviderConstants.Sms.ADDRESS,\n TelephonyProviderConstants.Sms.PERSON,\n TelephonyProviderConstants.Sms.THREAD_ID,\n };\n\n int _ID = 0;\n int ADDRESS = 1;\n int PERSON = 2;\n int THREAD_ID = 3;\n }\n\n private interface MmsAddrQuery {\n String[] PROJECTION = {\n TelephonyProviderConstants.Mms.Addr.ADDRESS,\n TelephonyProviderConstants.Mms.Addr.CONTACT_ID,\n };\n\n int ADDRESS = 0;\n int CONTACT_ID = 1;\n }\n\n private interface RawContactsQuery {\n String[] PROJECTION = {\n ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY,\n };\n\n int DISPLAY_NAME = 0;\n }\n\n private interface ContactsQuery {\n String[] PROJECTION = {\n ContactsContract.Contacts.DISPLAY_NAME,\n };\n\n int DISPLAY_NAME = 0;\n }\n}\n"},"repo_name":{"kind":"string","value":"ITVlab/neodash"},"path":{"kind":"string","value":"module-dashclock/src/main/java/com/google/android/apps/dashclock/phone/SmsExtension.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":16299,"string":"16,299"}}},{"rowIdx":61538460,"cells":{"code":{"kind":"string","value":"/*\n * Copyright 2014-present Facebook, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n * not use this file except in compliance with the License. You may obtain\n * a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the License.\n */\n\npackage com.facebook.buck.util;\n\nimport com.facebook.buck.log.Logger;\n\nimport java.io.IOException;\nimport java.io.InputStream;\n\npublic class ThriftWatcher {\n\n private static final Logger LOG = Logger.get(ThriftWatcher.class);\n\n private ThriftWatcher() {\n }\n\n /**\n * @return true if \"thrift --version\" can be executed successfully\n */\n public static boolean isThriftAvailable() throws InterruptedException {\n try {\n LOG.debug(\"Checking if Thrift is available..\");\n InputStream output = new ProcessBuilder(\"thrift\", \"-version\").start().getInputStream();\n byte[] bytes = new byte[7];\n output.read(bytes);\n boolean available = (new String(bytes)).equals(\"Thrift \");\n LOG.debug(\"Thrift available: %s\", available);\n return available;\n } catch (IOException e) {\n return false; // Could not execute thrift.\n }\n }\n}\n"},"repo_name":{"kind":"string","value":"mread/buck"},"path":{"kind":"string","value":"src/com/facebook/buck/util/ThriftWatcher.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":1473,"string":"1,473"}}},{"rowIdx":61538461,"cells":{"code":{"kind":"string","value":"/**\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage org.apache.camel.component.netty4.http;\n\nimport java.util.Map;\n\nimport io.netty.channel.ChannelHandlerContext;\nimport io.netty.handler.codec.http.FullHttpRequest;\nimport org.apache.camel.AsyncEndpoint;\nimport org.apache.camel.Consumer;\nimport org.apache.camel.Exchange;\nimport org.apache.camel.Message;\nimport org.apache.camel.PollingConsumer;\nimport org.apache.camel.Processor;\nimport org.apache.camel.Producer;\nimport org.apache.camel.component.netty4.NettyConfiguration;\nimport org.apache.camel.component.netty4.NettyEndpoint;\nimport org.apache.camel.http.common.cookie.CookieHandler;\nimport org.apache.camel.impl.SynchronousDelegateProducer;\nimport org.apache.camel.spi.HeaderFilterStrategy;\nimport org.apache.camel.spi.HeaderFilterStrategyAware;\nimport org.apache.camel.spi.UriEndpoint;\nimport org.apache.camel.spi.UriParam;\nimport org.apache.camel.util.ObjectHelper;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\n/**\n * Netty HTTP server and client using the Netty 4.x library.\n */\n@UriEndpoint(firstVersion = \"2.14.0\", scheme = \"netty4-http\", extendsScheme = \"netty4\", title = \"Netty4 HTTP\",\n syntax = \"netty4-http:protocol:host:port/path\", consumerClass = NettyHttpConsumer.class, label = \"http\", lenientProperties = true,\n excludeProperties = \"textline,delimiter,autoAppendDelimiter,decoderMaxLineLength,encoding,allowDefaultCodec,udpConnectionlessSending,networkInterface\"\n + \",clientMode,reconnect,reconnectInterval,useByteBuf,udpByteArrayCodec,broadcast\")\npublic class NettyHttpEndpoint extends NettyEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware {\n\n private static final Logger LOG = LoggerFactory.getLogger(NettyHttpEndpoint.class);\n @UriParam\n private NettyHttpConfiguration configuration;\n @UriParam(label = \"advanced\", name = \"configuration\", javaType = \"org.apache.camel.component.netty4.http.NettyHttpConfiguration\",\n description = \"To use a custom configured NettyHttpConfiguration for configuring this endpoint.\")\n private Object httpConfiguration; // to include in component docs as NettyHttpConfiguration is a @UriParams class\n @UriParam(label = \"advanced\")\n private NettyHttpBinding nettyHttpBinding;\n @UriParam(label = \"advanced\")\n private HeaderFilterStrategy headerFilterStrategy;\n @UriParam(label = \"consumer,advanced\")\n private boolean traceEnabled;\n @UriParam(label = \"consumer,advanced\")\n private String httpMethodRestrict;\n @UriParam(label = \"consumer,advanced\")\n private NettySharedHttpServer nettySharedHttpServer;\n @UriParam(label = \"consumer,security\")\n private NettyHttpSecurityConfiguration securityConfiguration;\n @UriParam(label = \"consumer,security\", prefix = \"securityConfiguration.\", multiValue = true)\n private Map securityOptions; // to include in component docs\n @UriParam(label = \"producer\")\n private CookieHandler cookieHandler;\n\n public NettyHttpEndpoint(String endpointUri, NettyHttpComponent component, NettyConfiguration configuration) {\n super(endpointUri, component, configuration);\n }\n\n @Override\n public NettyHttpComponent getComponent() {\n return (NettyHttpComponent) super.getComponent();\n }\n\n @Override\n public Consumer createConsumer(Processor processor) throws Exception {\n NettyHttpConsumer answer = new NettyHttpConsumer(this, processor, getConfiguration());\n configureConsumer(answer);\n\n if (nettySharedHttpServer != null) {\n answer.setNettyServerBootstrapFactory(nettySharedHttpServer.getServerBootstrapFactory());\n LOG.info(\"NettyHttpConsumer: {} is using NettySharedHttpServer on port: {}\", answer, nettySharedHttpServer.getPort());\n } else {\n // reuse pipeline factory for the same address\n HttpServerBootstrapFactory factory = getComponent().getOrCreateHttpNettyServerBootstrapFactory(answer);\n // force using our server bootstrap factory\n answer.setNettyServerBootstrapFactory(factory);\n LOG.debug(\"Created NettyHttpConsumer: {} using HttpServerBootstrapFactory: {}\", answer, factory);\n }\n return answer;\n }\n\n @Override\n public Producer createProducer() throws Exception {\n Producer answer = new NettyHttpProducer(this, getConfiguration());\n if (isSynchronous()) {\n return new SynchronousDelegateProducer(answer);\n } else {\n return answer;\n }\n }\n\n @Override\n public PollingConsumer createPollingConsumer() throws Exception {\n throw new UnsupportedOperationException(\"This component does not support polling consumer\");\n }\n\n @Override\n public Exchange createExchange(ChannelHandlerContext ctx, Object message) throws Exception {\n Exchange exchange = createExchange();\n \n FullHttpRequest request = (FullHttpRequest) message;\n Message in = getNettyHttpBinding().toCamelMessage(request, exchange, getConfiguration());\n exchange.setIn(in);\n \n // setup the common message headers \n updateMessageHeader(in, ctx);\n\n // honor the character encoding\n String contentType = in.getHeader(Exchange.CONTENT_TYPE, String.class);\n String charset = NettyHttpHelper.getCharsetFromContentType(contentType);\n if (charset != null) {\n exchange.setProperty(Exchange.CHARSET_NAME, charset);\n in.setHeader(Exchange.HTTP_CHARACTER_ENCODING, charset);\n }\n\n return exchange;\n }\n\n @Override\n public boolean isLenientProperties() {\n // true to allow dynamic URI options to be configured and passed to external system for eg. the HttpProducer\n return true;\n }\n\n @Override\n public void setConfiguration(NettyConfiguration configuration) {\n super.setConfiguration(configuration);\n this.configuration = (NettyHttpConfiguration) configuration;\n }\n\n @Override\n public NettyHttpConfiguration getConfiguration() {\n return (NettyHttpConfiguration) super.getConfiguration();\n }\n\n public NettyHttpBinding getNettyHttpBinding() {\n return nettyHttpBinding;\n }\n\n /**\n * To use a custom org.apache.camel.component.netty4.http.NettyHttpBinding for binding to/from Netty and Camel Message API.\n */\n public void setNettyHttpBinding(NettyHttpBinding nettyHttpBinding) {\n this.nettyHttpBinding = nettyHttpBinding;\n }\n\n public HeaderFilterStrategy getHeaderFilterStrategy() {\n return headerFilterStrategy;\n }\n\n /**\n * To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers.\n */\n public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) {\n this.headerFilterStrategy = headerFilterStrategy;\n getNettyHttpBinding().setHeaderFilterStrategy(headerFilterStrategy);\n }\n\n public boolean isTraceEnabled() {\n return traceEnabled;\n }\n\n /**\n * Specifies whether to enable HTTP TRACE for this Netty HTTP consumer. By default TRACE is turned off.\n */\n public void setTraceEnabled(boolean traceEnabled) {\n this.traceEnabled = traceEnabled;\n }\n\n public String getHttpMethodRestrict() {\n return httpMethodRestrict;\n }\n\n /**\n * To disable HTTP methods on the Netty HTTP consumer. You can specify multiple separated by comma.\n */\n public void setHttpMethodRestrict(String httpMethodRestrict) {\n this.httpMethodRestrict = httpMethodRestrict;\n }\n\n public NettySharedHttpServer getNettySharedHttpServer() {\n return nettySharedHttpServer;\n }\n\n /**\n * To use a shared Netty HTTP server. See Netty HTTP Server Example for more details.\n */\n public void setNettySharedHttpServer(NettySharedHttpServer nettySharedHttpServer) {\n this.nettySharedHttpServer = nettySharedHttpServer;\n }\n\n public NettyHttpSecurityConfiguration getSecurityConfiguration() {\n return securityConfiguration;\n }\n\n /**\n * Refers to a org.apache.camel.component.netty4.http.NettyHttpSecurityConfiguration for configuring secure web resources.\n */\n public void setSecurityConfiguration(NettyHttpSecurityConfiguration securityConfiguration) {\n this.securityConfiguration = securityConfiguration;\n }\n\n public Map getSecurityOptions() {\n return securityOptions;\n }\n\n /**\n * To configure NettyHttpSecurityConfiguration using key/value pairs from the map\n */\n public void setSecurityOptions(Map securityOptions) {\n this.securityOptions = securityOptions;\n }\n\n public CookieHandler getCookieHandler() {\n return cookieHandler;\n }\n\n /**\n * Configure a cookie handler to maintain a HTTP session\n */\n public void setCookieHandler(CookieHandler cookieHandler) {\n this.cookieHandler = cookieHandler;\n }\n\n @Override\n protected void doStart() throws Exception {\n super.doStart();\n\n ObjectHelper.notNull(nettyHttpBinding, \"nettyHttpBinding\", this);\n ObjectHelper.notNull(headerFilterStrategy, \"headerFilterStrategy\", this);\n\n if (securityConfiguration != null) {\n ObjectHelper.notEmpty(securityConfiguration.getRealm(), \"realm\", securityConfiguration);\n ObjectHelper.notEmpty(securityConfiguration.getConstraint(), \"restricted\", securityConfiguration);\n\n if (securityConfiguration.getSecurityAuthenticator() == null) {\n // setup default JAAS authenticator if none was configured\n JAASSecurityAuthenticator jaas = new JAASSecurityAuthenticator();\n jaas.setName(securityConfiguration.getRealm());\n LOG.info(\"No SecurityAuthenticator configured, using JAASSecurityAuthenticator as authenticator: {}\", jaas);\n securityConfiguration.setSecurityAuthenticator(jaas);\n }\n }\n }\n}\n"},"repo_name":{"kind":"string","value":"curso007/camel"},"path":{"kind":"string","value":"components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpEndpoint.java"},"language":{"kind":"string","value":"Java"},"license":{"kind":"string","value":"apache-2.0"},"size":{"kind":"number","value":10739,"string":"10,739"}}},{"rowIdx":61538462,"cells":{"code":{"kind":"string","value":"function getElements(className) {\n return Array.from(document.getElementsByClassName(className));\n}\nwindow.onload = function() {\n // Force a reflow before any changes.\n document.body.clientWidth;\n\n getElements('remove').forEach(function(e) {\n e.remove();\n });\n getElements('remove-after').forEach(function(e) {\n e.parentNode.removeChild(e.nextSibling);\n });\n};\n"},"repo_name":{"kind":"string","value":"nwjs/chromium.src"},"path":{"kind":"string","value":"third_party/blink/web_tests/external/wpt/css/css-ruby/support/ruby-dynamic-removal.js"},"language":{"kind":"string","value":"JavaScript"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":374,"string":"374"}}},{"rowIdx":61538463,"cells":{"code":{"kind":"string","value":"// { dg-do assemble { target fpic } }\n// { dg-options \"-O0 -fpic\" }\n// Origin: Jakub Jelinek \n\nstruct bar {\n bar() {}\n double x[3];\n};\n\nstatic bar y[4];\n\nvoid foo(int z)\n{\n bar w;\n y[z] = w;\n}\n"},"repo_name":{"kind":"string","value":"shaotuanchen/sunflower_exp"},"path":{"kind":"string","value":"tools/source/gcc-4.2.4/gcc/testsuite/g++.old-deja/g++.other/local-alloc1.C"},"language":{"kind":"string","value":"C++"},"license":{"kind":"string","value":"bsd-3-clause"},"size":{"kind":"number","value":215,"string":"215"}}},{"rowIdx":61538464,"cells":{"code":{"kind":"string","value":"/**\n * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or http://ckeditor.com/license\n */\n\n'use strict';\n\n( function() {\n\n\tvar template = '\"\"',\n\t\ttemplateBlock = new CKEDITOR.template(\n\t\t\t'
    ' +\n\t\t\t\ttemplate +\n\t\t\t\t'
    {captionPlaceholder}
    ' +\n\t\t\t'
    ' ),\n\t\talignmentsObj = { left: 0, center: 1, right: 2 },\n\t\tregexPercent = /^\\s*(\\d+\\%)\\s*$/i;\n\n\tCKEDITOR.plugins.add( 'image2', {\n\t\t// jscs:disable maximumLineLength\n\t\tlang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%\n\t\t// jscs:enable maximumLineLength\n\t\trequires: 'widget,dialog',\n\t\ticons: 'image',\n\t\thidpi: true,\n\n\t\tonLoad: function() {\n\t\t\tCKEDITOR.addCss(\n\t\t\t'.cke_image_nocaption{' +\n\t\t\t\t// This is to remove unwanted space so resize\n\t\t\t\t// wrapper is displayed property.\n\t\t\t\t'line-height:0' +\n\t\t\t'}' +\n\t\t\t'.cke_editable.cke_image_sw, .cke_editable.cke_image_sw *{cursor:sw-resize !important}' +\n\t\t\t'.cke_editable.cke_image_se, .cke_editable.cke_image_se *{cursor:se-resize !important}' +\n\t\t\t'.cke_image_resizer{' +\n\t\t\t\t'display:none;' +\n\t\t\t\t'position:absolute;' +\n\t\t\t\t'width:10px;' +\n\t\t\t\t'height:10px;' +\n\t\t\t\t'bottom:-5px;' +\n\t\t\t\t'right:-5px;' +\n\t\t\t\t'background:#000;' +\n\t\t\t\t'outline:1px solid #fff;' +\n\t\t\t\t// Prevent drag handler from being misplaced (#11207).\n\t\t\t\t'line-height:0;' +\n\t\t\t\t'cursor:se-resize;' +\n\t\t\t'}' +\n\t\t\t'.cke_image_resizer_wrapper{' +\n\t\t\t\t'position:relative;' +\n\t\t\t\t'display:inline-block;' +\n\t\t\t\t'line-height:0;' +\n\t\t\t'}' +\n\t\t\t// Bottom-left corner style of the resizer.\n\t\t\t'.cke_image_resizer.cke_image_resizer_left{' +\n\t\t\t\t'right:auto;' +\n\t\t\t\t'left:-5px;' +\n\t\t\t\t'cursor:sw-resize;' +\n\t\t\t'}' +\n\t\t\t'.cke_widget_wrapper:hover .cke_image_resizer,' +\n\t\t\t'.cke_image_resizer.cke_image_resizing{' +\n\t\t\t\t'display:block' +\n\t\t\t'}' +\n\t\t\t// Expand widget wrapper when linked inline image.\n\t\t\t'.cke_widget_wrapper>a{' +\n\t\t\t\t'display:inline-block' +\n\t\t\t'}' );\n\t\t},\n\n\t\tinit: function( editor ) {\n\t\t\t// Adapts configuration from original image plugin. Should be removed\n\t\t\t// when we'll rename image2 to image.\n\t\t\tvar config = editor.config,\n\t\t\t\tlang = editor.lang.image2,\n\t\t\t\timage = widgetDef( editor );\n\n\t\t\t// Since filebrowser plugin discovers config properties by dialog (plugin?)\n\t\t\t// names (sic!), this hack will be necessary as long as Image2 is not named\n\t\t\t// Image. And since Image2 will never be Image, for sure some filebrowser logic\n\t\t\t// got to be refined.\n\t\t\tconfig.filebrowserImage2BrowseUrl = config.filebrowserImageBrowseUrl;\n\t\t\tconfig.filebrowserImage2UploadUrl = config.filebrowserImageUploadUrl;\n\n\t\t\t// Add custom elementspath names to widget definition.\n\t\t\timage.pathName = lang.pathName;\n\t\t\timage.editables.caption.pathName = lang.pathNameCaption;\n\n\t\t\t// Register the widget.\n\t\t\teditor.widgets.add( 'image', image );\n\n\t\t\t// Add toolbar button for this plugin.\n\t\t\teditor.ui.addButton && editor.ui.addButton( 'Image', {\n\t\t\t\tlabel: editor.lang.common.image,\n\t\t\t\tcommand: 'image',\n\t\t\t\ttoolbar: 'insert,10'\n\t\t\t} );\n\n\t\t\t// Register context menu option for editing widget.\n\t\t\tif ( editor.contextMenu ) {\n\t\t\t\teditor.addMenuGroup( 'image', 10 );\n\n\t\t\t\teditor.addMenuItem( 'image', {\n\t\t\t\t\tlabel: lang.menu,\n\t\t\t\t\tcommand: 'image',\n\t\t\t\t\tgroup: 'image'\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tCKEDITOR.dialog.add( 'image2', this.path + 'dialogs/image2.js' );\n\t\t},\n\n\t\tafterInit: function( editor ) {\n\t\t\t// Integrate with align commands (justify plugin).\n\t\t\tvar align = { left: 1, right: 1, center: 1, block: 1 },\n\t\t\t\tintegrate = alignCommandIntegrator( editor );\n\n\t\t\tfor ( var value in align )\n\t\t\t\tintegrate( value );\n\n\t\t\t// Integrate with link commands (link plugin).\n\t\t\tlinkCommandIntegrator( editor );\n\t\t}\n\t} );\n\n\t// Wiget states (forms) depending on alignment and configuration.\n\t//\n\t// Non-captioned widget (inline styles)\n\t// \t\t┌──────┬───────────────────────────────┬─────────────────────────────┐\n\t// \t\t│Align │Internal form │Data │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│none │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│left │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│center│

    │\n\t// \t\t│ │

    │\n\t// \t\t│ │

    │\n\t// \t\t│ │

    │ │\n\t// \t\t│ │
    │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│right │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t└──────┴───────────────────────────────┴─────────────────────────────┘\n\t//\n\t// Non-captioned widget (config.image2_alignClasses defined)\n\t// \t\t┌──────┬───────────────────────────────┬─────────────────────────────┐\n\t// \t\t│Align │Internal form │Data │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│none │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│left │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│center│

    │\n\t// \t\t│ │

    │\n\t// \t\t│ │

    │\n\t// \t\t│ │

    │ │\n\t// \t\t│ │
    │ │\n\t// \t\t├──────┼───────────────────────────────┼─────────────────────────────┤\n\t// \t\t│right │ │\n\t// \t\t│ │ │ │\n\t// \t\t│ │ │ │\n\t// \t\t└──────┴───────────────────────────────┴─────────────────────────────┘\n\t//\n\t// Captioned widget (inline styles)\n\t// \t\t┌──────┬────────────────────────────────────────┬────────────────────────────────────────┐\n\t// \t\t│Align │Internal form │Data │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│none │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│left │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│center│
    │\n\t// \t\t│ │
    │\n\t// \t\t│ │ │

    │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│right │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t└──────┴────────────────────────────────────────┴────────────────────────────────────────┘\n\t//\n\t// Captioned widget (config.image2_alignClasses defined)\n\t// \t\t┌──────┬────────────────────────────────────────┬────────────────────────────────────────┐\n\t// \t\t│Align │Internal form │Data │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│none │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│left │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│center│
    │\n\t// \t\t│ │
    │\n\t// \t\t│ │ │

    │\n\t// \t\t├──────┼────────────────────────────────────────┼────────────────────────────────────────┤\n\t// \t\t│right │
    │\n\t// \t\t│ │
    │ │\n\t// \t\t│ │ │ │\n\t// \t\t└──────┴────────────────────────────────────────┴────────────────────────────────────────┘\n\t//\n\t// @param {CKEDITOR.editor}\n\t// @returns {Object}\n\tfunction widgetDef( editor ) {\n\t\tvar alignClasses = editor.config.image2_alignClasses,\n\t\t\tcaptionedClass = editor.config.image2_captionedClass;\n\n\t\tfunction deflate() {\n\t\t\tif ( this.deflated )\n\t\t\t\treturn;\n\n\t\t\t// Remember whether widget was focused before destroyed.\n\t\t\tif ( editor.widgets.focused == this.widget )\n\t\t\t\tthis.focused = true;\n\n\t\t\teditor.widgets.destroy( this.widget );\n\n\t\t\t// Mark widget was destroyed.\n\t\t\tthis.deflated = true;\n\t\t}\n\n\t\tfunction inflate() {\n\t\t\tvar editable = editor.editable(),\n\t\t\tdoc = editor.document;\n\n\t\t\t// Create a new widget. This widget will be either captioned\n\t\t\t// non-captioned, block or inline according to what is the\n\t\t\t// new state of the widget.\n\t\t\tif ( this.deflated ) {\n\t\t\t\tthis.widget = editor.widgets.initOn( this.element, 'image', this.widget.data );\n\n\t\t\t\t// Once widget was re-created, it may become an inline element without\n\t\t\t\t// block wrapper (i.e. when unaligned, end not captioned). Let's do some\n\t\t\t\t// sort of autoparagraphing here (#10853).\n\t\t\t\tif ( this.widget.inline && !( new CKEDITOR.dom.elementPath( this.widget.wrapper, editable ).block ) ) {\n\t\t\t\t\tvar block = doc.createElement( editor.activeEnterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\n\t\t\t\t\tblock.replace( this.widget.wrapper );\n\t\t\t\t\tthis.widget.wrapper.move( block );\n\t\t\t\t}\n\n\t\t\t\t// The focus must be transferred from the old one (destroyed)\n\t\t\t\t// to the new one (just created).\n\t\t\t\tif ( this.focused ) {\n\t\t\t\t\tthis.widget.focus();\n\t\t\t\t\tdelete this.focused;\n\t\t\t\t}\n\n\t\t\t\tdelete this.deflated;\n\t\t\t}\n\n\t\t\t// If now widget was destroyed just update wrapper's alignment.\n\t\t\t// According to the new state.\n\t\t\telse {\n\t\t\t\tsetWrapperAlign( this.widget, alignClasses );\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tallowedContent: getWidgetAllowedContent( editor ),\n\n\t\t\trequiredContent: 'img[src,alt]',\n\n\t\t\tfeatures: getWidgetFeatures( editor ),\n\n\t\t\tstyleableElements: 'img figure',\n\n\t\t\t// This widget converts style-driven dimensions to attributes.\n\t\t\tcontentTransformations: [\n\t\t\t\t[ 'img[width]: sizeToAttribute' ]\n\t\t\t],\n\n\t\t\t// This widget has an editable caption.\n\t\t\teditables: {\n\t\t\t\tcaption: {\n\t\t\t\t\tselector: 'figcaption',\n\t\t\t\t\tallowedContent: 'br em strong sub sup u s; a[!href]'\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tparts: {\n\t\t\t\timage: 'img',\n\t\t\t\tcaption: 'figcaption'\n\t\t\t\t// parts#link defined in widget#init\n\t\t\t},\n\n\t\t\t// The name of this widget's dialog.\n\t\t\tdialog: 'image2',\n\n\t\t\t// Template of the widget: plain image.\n\t\t\ttemplate: template,\n\n\t\t\tdata: function() {\n\t\t\t\tvar features = this.features;\n\n\t\t\t\t// Image can't be captioned when figcaption is disallowed (#11004).\n\t\t\t\tif ( this.data.hasCaption && !editor.filter.checkFeature( features.caption ) )\n\t\t\t\t\tthis.data.hasCaption = false;\n\n\t\t\t\t// Image can't be aligned when floating is disallowed (#11004).\n\t\t\t\tif ( this.data.align != 'none' && !editor.filter.checkFeature( features.align ) )\n\t\t\t\t\tthis.data.align = 'none';\n\n\t\t\t\t// Convert the internal form of the widget from the old state to the new one.\n\t\t\t\tthis.shiftState( {\n\t\t\t\t\twidget: this,\n\t\t\t\t\telement: this.element,\n\t\t\t\t\toldData: this.oldData,\n\t\t\t\t\tnewData: this.data,\n\t\t\t\t\tdeflate: deflate,\n\t\t\t\t\tinflate: inflate\n\t\t\t\t} );\n\n\t\t\t\t// Update widget.parts.link since it will not auto-update unless widget\n\t\t\t\t// is destroyed and re-inited.\n\t\t\t\tif ( !this.data.link ) {\n\t\t\t\t\tif ( this.parts.link )\n\t\t\t\t\t\tdelete this.parts.link;\n\t\t\t\t} else {\n\t\t\t\t\tif ( !this.parts.link )\n\t\t\t\t\t\tthis.parts.link = this.parts.image.getParent();\n\t\t\t\t}\n\n\t\t\t\tthis.parts.image.setAttributes( {\n\t\t\t\t\tsrc: this.data.src,\n\n\t\t\t\t\t// This internal is required by the editor.\n\t\t\t\t\t'data-cke-saved-src': this.data.src,\n\n\t\t\t\t\talt: this.data.alt\n\t\t\t\t} );\n\n\t\t\t\t// If shifting non-captioned -> captioned, remove classes\n\t\t\t\t// related to styles from .\n\t\t\t\tif ( this.oldData && !this.oldData.hasCaption && this.data.hasCaption ) {\n\t\t\t\t\tfor ( var c in this.data.classes )\n\t\t\t\t\t\tthis.parts.image.removeClass( c );\n\t\t\t\t}\n\n\t\t\t\t// Set dimensions of the image according to gathered data.\n\t\t\t\t// Do it only when the attributes are allowed (#11004).\n\t\t\t\tif ( editor.filter.checkFeature( features.dimension ) )\n\t\t\t\t\tsetDimensions( this );\n\n\t\t\t\t// Cache current data.\n\t\t\t\tthis.oldData = CKEDITOR.tools.extend( {}, this.data );\n\t\t\t},\n\n\t\t\tinit: function() {\n\t\t\t\tvar helpers = CKEDITOR.plugins.image2,\n\t\t\t\t\timage = this.parts.image,\n\t\t\t\t\tdata = {\n\t\t\t\t\t\thasCaption: !!this.parts.caption,\n\t\t\t\t\t\tsrc: image.getAttribute( 'src' ),\n\t\t\t\t\t\talt: image.getAttribute( 'alt' ) || '',\n\t\t\t\t\t\twidth: image.getAttribute( 'width' ) || '',\n\t\t\t\t\t\theight: image.getAttribute( 'height' ) || '',\n\n\t\t\t\t\t\t// Lock ratio is on by default (#10833).\n\t\t\t\t\t\tlock: this.ready ? helpers.checkHasNaturalRatio( image ) : true\n\t\t\t\t\t};\n\n\t\t\t\t// If we used 'a' in widget#parts definition, it could happen that\n\t\t\t\t// selected element is a child of widget.parts#caption. Since there's no clever\n\t\t\t\t// way to solve it with CSS selectors, it's done like that. (#11783).\n\t\t\t\tvar link = image.getAscendant( 'a' );\n\n\t\t\t\tif ( link && this.wrapper.contains( link ) )\n\t\t\t\t\tthis.parts.link = link;\n\n\t\t\t\t// Depending on configuration, read style/class from element and\n\t\t\t\t// then remove it. Removed style/class will be set on wrapper in #data listener.\n\t\t\t\t// Note: Center alignment is detected during upcast, so only left/right cases\n\t\t\t\t// are checked below.\n\t\t\t\tif ( !data.align ) {\n\t\t\t\t\tvar alignElement = data.hasCaption ? this.element : image;\n\n\t\t\t\t\t// Read the initial left/right alignment from the class set on element.\n\t\t\t\t\tif ( alignClasses ) {\n\t\t\t\t\t\tif ( alignElement.hasClass( alignClasses[ 0 ] ) ) {\n\t\t\t\t\t\t\tdata.align = 'left';\n\t\t\t\t\t\t} else if ( alignElement.hasClass( alignClasses[ 2 ] ) ) {\n\t\t\t\t\t\t\tdata.align = 'right';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( data.align ) {\n\t\t\t\t\t\t\talignElement.removeClass( alignClasses[ alignmentsObj[ data.align ] ] );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdata.align = 'none';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Read initial float style from figure/image and then remove it.\n\t\t\t\t\telse {\n\t\t\t\t\t\tdata.align = alignElement.getStyle( 'float' ) || 'none';\n\t\t\t\t\t\talignElement.removeStyle( 'float' );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Update data.link object with attributes if the link has been discovered.\n\t\t\t\tif ( editor.plugins.link && this.parts.link ) {\n\t\t\t\t\tdata.link = CKEDITOR.plugins.link.parseLinkAttributes( editor, this.parts.link );\n\n\t\t\t\t\t// Get rid of cke_widget_* classes in data. Otherwise\n\t\t\t\t\t// they might appear in link dialog.\n\t\t\t\t\tvar advanced = data.link.advanced;\n\t\t\t\t\tif ( advanced && advanced.advCSSClasses ) {\n\t\t\t\t\t\tadvanced.advCSSClasses = CKEDITOR.tools.trim( advanced.advCSSClasses.replace( /cke_\\S+/, '' ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Get rid of extra vertical space when there's no caption.\n\t\t\t\t// It will improve the look of the resizer.\n\t\t\t\tthis.wrapper[ ( data.hasCaption ? 'remove' : 'add' ) + 'Class' ]( 'cke_image_nocaption' );\n\n\t\t\t\tthis.setData( data );\n\n\t\t\t\t// Setup dynamic image resizing with mouse.\n\t\t\t\t// Don't initialize resizer when dimensions are disallowed (#11004).\n\t\t\t\tif ( editor.filter.checkFeature( this.features.dimension ) && editor.config.image2_disableResizer !== true )\n\t\t\t\t\tsetupResizer( this );\n\n\t\t\t\tthis.shiftState = helpers.stateShifter( this.editor );\n\n\t\t\t\t// Add widget editing option to its context menu.\n\t\t\t\tthis.on( 'contextMenu', function( evt ) {\n\t\t\t\t\tevt.data.image = CKEDITOR.TRISTATE_OFF;\n\n\t\t\t\t\t// Integrate context menu items for link.\n\t\t\t\t\t// Note that widget may be wrapped in a link, which\n\t\t\t\t\t// does not belong to that widget (#11814).\n\t\t\t\t\tif ( this.parts.link || this.wrapper.getAscendant( 'a' ) )\n\t\t\t\t\t\tevt.data.link = evt.data.unlink = CKEDITOR.TRISTATE_OFF;\n\t\t\t\t} );\n\n\t\t\t\t// Pass the reference to this widget to the dialog.\n\t\t\t\tthis.on( 'dialog', function( evt ) {\n\t\t\t\t\tevt.data.widget = this;\n\t\t\t\t}, this );\n\t\t\t},\n\n\t\t\t// Overrides default method to handle internal mutability of Image2.\n\t\t\t// @see CKEDITOR.plugins.widget#addClass\n\t\t\taddClass: function( className ) {\n\t\t\t\tgetStyleableElement( this ).addClass( className );\n\t\t\t},\n\n\t\t\t// Overrides default method to handle internal mutability of Image2.\n\t\t\t// @see CKEDITOR.plugins.widget#hasClass\n\t\t\thasClass: function( className ) {\n\t\t\t\treturn getStyleableElement( this ).hasClass( className );\n\t\t\t},\n\n\t\t\t// Overrides default method to handle internal mutability of Image2.\n\t\t\t// @see CKEDITOR.plugins.widget#removeClass\n\t\t\tremoveClass: function( className ) {\n\t\t\t\tgetStyleableElement( this ).removeClass( className );\n\t\t\t},\n\n\t\t\t// Overrides default method to handle internal mutability of Image2.\n\t\t\t// @see CKEDITOR.plugins.widget#getClasses\n\t\t\tgetClasses: ( function() {\n\t\t\t\tvar classRegex = new RegExp( '^(' + [].concat( captionedClass, alignClasses ).join( '|' ) + ')$' );\n\n\t\t\t\treturn function() {\n\t\t\t\t\tvar classes = this.repository.parseElementClasses( getStyleableElement( this ).getAttribute( 'class' ) );\n\n\t\t\t\t\t// Neither config.image2_captionedClass nor config.image2_alignClasses\n\t\t\t\t\t// do not belong to style classes.\n\t\t\t\t\tfor ( var c in classes ) {\n\t\t\t\t\t\tif ( classRegex.test( c ) )\n\t\t\t\t\t\t\tdelete classes[ c ];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn classes;\n\t\t\t\t};\n\t\t\t} )(),\n\n\t\t\tupcast: upcastWidgetElement( editor ),\n\t\t\tdowncast: downcastWidgetElement( editor )\n\t\t};\n\t}\n\n\tCKEDITOR.plugins.image2 = {\n\t\tstateShifter: function( editor ) {\n\t\t\t// Tag name used for centering non-captioned widgets.\n\t\t\tvar doc = editor.document,\n\t\t\t\talignClasses = editor.config.image2_alignClasses,\n\t\t\t\tcaptionedClass = editor.config.image2_captionedClass,\n\t\t\t\teditable = editor.editable(),\n\n\t\t\t\t// The order that stateActions get executed. It matters!\n\t\t\t\tshiftables = [ 'hasCaption', 'align', 'link' ];\n\n\t\t\t// Atomic procedures, one per state variable.\n\t\t\tvar stateActions = {\n\t\t\t\talign: function( shift, oldValue, newValue ) {\n\t\t\t\t\tvar el = shift.element;\n\n\t\t\t\t\t// Alignment changed.\n\t\t\t\t\tif ( shift.changed.align ) {\n\t\t\t\t\t\t// No caption in the new state.\n\t\t\t\t\t\tif ( !shift.newData.hasCaption ) {\n\t\t\t\t\t\t\t// Changed to \"center\" (non-captioned).\n\t\t\t\t\t\t\tif ( newValue == 'center' ) {\n\t\t\t\t\t\t\t\tshift.deflate();\n\t\t\t\t\t\t\t\tshift.element = wrapInCentering( editor, el );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Changed to \"non-center\" from \"center\" while caption removed.\n\t\t\t\t\t\t\tif ( !shift.changed.hasCaption && oldValue == 'center' && newValue != 'center' ) {\n\t\t\t\t\t\t\t\tshift.deflate();\n\t\t\t\t\t\t\t\tshift.element = unwrapFromCentering( el );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Alignment remains and \"center\" removed caption.\n\t\t\t\t\telse if ( newValue == 'center' && shift.changed.hasCaption && !shift.newData.hasCaption ) {\n\t\t\t\t\t\tshift.deflate();\n\t\t\t\t\t\tshift.element = wrapInCentering( editor, el );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Finally set display for figure.\n\t\t\t\t\tif ( !alignClasses && el.is( 'figure' ) ) {\n\t\t\t\t\t\tif ( newValue == 'center' )\n\t\t\t\t\t\t\tel.setStyle( 'display', 'inline-block' );\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tel.removeStyle( 'display' );\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\thasCaption:\tfunction( shift, oldValue, newValue ) {\n\t\t\t\t\t// This action is for real state change only.\n\t\t\t\t\tif ( !shift.changed.hasCaption )\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t// Get or from widget. Note that widget element might itself\n\t\t\t\t\t// be what we're looking for. Also element can be

    ...

    .\n\t\t\t\t\tvar imageOrLink;\n\t\t\t\t\tif ( shift.element.is( { img: 1, a: 1 } ) )\n\t\t\t\t\t\timageOrLink = shift.element;\n\t\t\t\t\telse\n\t\t\t\t\t\timageOrLink = shift.element.findOne( 'a,img' );\n\n\t\t\t\t\t// Switching hasCaption always destroys the widget.\n\t\t\t\t\tshift.deflate();\n\n\t\t\t\t\t// There was no caption, but the caption is to be added.\n\t\t\t\t\tif ( newValue ) {\n\t\t\t\t\t\t// Create new
    from widget template.\n\t\t\t\t\t\tvar figure = CKEDITOR.dom.element.createFromHtml( templateBlock.output( {\n\t\t\t\t\t\t\tcaptionedClass: captionedClass,\n\t\t\t\t\t\t\tcaptionPlaceholder: editor.lang.image2.captionPlaceholder\n\t\t\t\t\t\t} ), doc );\n\n\t\t\t\t\t\t// Replace element with
    .\n\t\t\t\t\t\treplaceSafely( figure, shift.element );\n\n\t\t\t\t\t\t// Use old or instead of the one from the template,\n\t\t\t\t\t\t// so we won't lose additional attributes.\n\t\t\t\t\t\timageOrLink.replace( figure.findOne( 'img' ) );\n\n\t\t\t\t\t\t// Update widget's element.\n\t\t\t\t\t\tshift.element = figure;\n\t\t\t\t\t}\n\n\t\t\t\t\t// The caption was present, but now it's to be removed.\n\t\t\t\t\telse {\n\t\t\t\t\t\t// Unwrap or from figure.\n\t\t\t\t\t\timageOrLink.replace( shift.element );\n\n\t\t\t\t\t\t// Update widget's element.\n\t\t\t\t\t\tshift.element = imageOrLink;\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tlink: function( shift, oldValue, newValue ) {\n\t\t\t\t\tif ( shift.changed.link ) {\n\t\t\t\t\t\tvar img = shift.element.is( 'img' ) ?\n\t\t\t\t\t\t\t\tshift.element : shift.element.findOne( 'img' ),\n\t\t\t\t\t\t\tlink = shift.element.is( 'a' ) ?\n\t\t\t\t\t\t\t\tshift.element : shift.element.findOne( 'a' ),\n\t\t\t\t\t\t\t// Why deflate:\n\t\t\t\t\t\t\t// If element is , it will be wrapped into ,\n\t\t\t\t\t\t\t// which becomes a new widget.element.\n\t\t\t\t\t\t\t// If element is , it will be unlinked\n\t\t\t\t\t\t\t// so becomes a new widget.element.\n\t\t\t\t\t\t\tneedsDeflate = ( shift.element.is( 'a' ) && !newValue ) || ( shift.element.is( 'img' ) && newValue ),\n\t\t\t\t\t\t\tnewEl;\n\n\t\t\t\t\t\tif ( needsDeflate )\n\t\t\t\t\t\t\tshift.deflate();\n\n\t\t\t\t\t\t// If unlinked the image, returned element is .\n\t\t\t\t\t\tif ( !newValue )\n\t\t\t\t\t\t\tnewEl = unwrapFromLink( link );\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t// If linked the image, returned element is .\n\t\t\t\t\t\t\tif ( !oldValue )\n\t\t\t\t\t\t\t\tnewEl = wrapInLink( img, shift.newData.link );\n\n\t\t\t\t\t\t\t// Set and remove all attributes associated with this state.\n\t\t\t\t\t\t\tvar attributes = CKEDITOR.plugins.link.getLinkAttributes( editor, newValue );\n\n\t\t\t\t\t\t\tif ( !CKEDITOR.tools.isEmpty( attributes.set ) )\n\t\t\t\t\t\t\t\t( newEl || link ).setAttributes( attributes.set );\n\n\t\t\t\t\t\t\tif ( attributes.removed.length )\n\t\t\t\t\t\t\t\t( newEl || link ).removeAttributes( attributes.removed );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( needsDeflate )\n\t\t\t\t\t\t\tshift.element = newEl;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfunction wrapInCentering( editor, element ) {\n\t\t\t\tvar attribsAndStyles = {};\n\n\t\t\t\tif ( alignClasses )\n\t\t\t\t\tattribsAndStyles.attributes = { 'class': alignClasses[ 1 ] };\n\t\t\t\telse\n\t\t\t\t\tattribsAndStyles.styles = { 'text-align': 'center' };\n\n\t\t\t\t// There's no gentle way to center inline element with CSS, so create p/div\n\t\t\t\t// that wraps widget contents and does the trick either with style or class.\n\t\t\t\tvar center = doc.createElement(\n\t\t\t\t\teditor.activeEnterMode == CKEDITOR.ENTER_P ? 'p' : 'div', attribsAndStyles );\n\n\t\t\t\t// Replace element with centering wrapper.\n\t\t\t\treplaceSafely( center, element );\n\t\t\t\telement.move( center );\n\n\t\t\t\treturn center;\n\t\t\t}\n\n\t\t\tfunction unwrapFromCentering( element ) {\n\t\t\t\tvar imageOrLink = element.findOne( 'a,img' );\n\n\t\t\t\timageOrLink.replace( element );\n\n\t\t\t\treturn imageOrLink;\n\t\t\t}\n\n\t\t\t// Wraps -> .\n\t\t\t// Returns reference to .\n\t\t\t//\n\t\t\t// @param {CKEDITOR.dom.element} img\n\t\t\t// @param {Object} linkData\n\t\t\t// @returns {CKEDITOR.dom.element}\n\t\t\tfunction wrapInLink( img, linkData ) {\n\t\t\t\tvar link = doc.createElement( 'a', {\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\thref: linkData.url\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\tlink.replace( img );\n\t\t\t\timg.move( link );\n\n\t\t\t\treturn link;\n\t\t\t}\n\n\t\t\t// De-wraps -> .\n\t\t\t// Returns the reference to \n\t\t\t//\n\t\t\t// @param {CKEDITOR.dom.element} link\n\t\t\t// @returns {CKEDITOR.dom.element}\n\t\t\tfunction unwrapFromLink( link ) {\n\t\t\t\tvar img = link.findOne( 'img' );\n\n\t\t\t\timg.replace( link );\n\n\t\t\t\treturn img;\n\t\t\t}\n\n\t\t\tfunction replaceSafely( replacing, replaced ) {\n\t\t\t\tif ( replaced.getParent() ) {\n\t\t\t\t\tvar range = editor.createRange();\n\n\t\t\t\t\trange.moveToPosition( replaced, CKEDITOR.POSITION_BEFORE_START );\n\n\t\t\t\t\t// Remove old element. Do it before insertion to avoid a case when\n\t\t\t\t\t// element is moved from 'replaced' element before it, what creates\n\t\t\t\t\t// a tricky case which insertElementIntorRange does not handle.\n\t\t\t\t\treplaced.remove();\n\n\t\t\t\t\teditable.insertElementIntoRange( replacing, range );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treplacing.replace( replaced );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn function( shift ) {\n\t\t\t\tvar name, i;\n\n\t\t\t\tshift.changed = {};\n\n\t\t\t\tfor ( i = 0; i < shiftables.length; i++ ) {\n\t\t\t\t\tname = shiftables[ i ];\n\n\t\t\t\t\tshift.changed[ name ] = shift.oldData ?\n\t\t\t\t\t\tshift.oldData[ name ] !== shift.newData[ name ] : false;\n\t\t\t\t}\n\n\t\t\t\t// Iterate over possible state variables.\n\t\t\t\tfor ( i = 0; i < shiftables.length; i++ ) {\n\t\t\t\t\tname = shiftables[ i ];\n\n\t\t\t\t\tstateActions[ name ]( shift,\n\t\t\t\t\t\tshift.oldData ? shift.oldData[ name ] : null,\n\t\t\t\t\t\tshift.newData[ name ] );\n\t\t\t\t}\n\n\t\t\t\tshift.inflate();\n\t\t\t};\n\t\t},\n\n\t\t// Checks whether current ratio of the image match the natural one.\n\t\t// by comparing dimensions.\n\t\t// @param {CKEDITOR.dom.element} image\n\t\t// @returns {Boolean}\n\t\tcheckHasNaturalRatio: function( image ) {\n\t\t\tvar $ = image.$,\n\t\t\t\tnatural = this.getNatural( image );\n\n\t\t\t// The reason for two alternative comparisons is that the rounding can come from\n\t\t\t// both dimensions, e.g. there are two cases:\n\t\t\t// \t1. height is computed as a rounded relation of the real height and the value of width,\n\t\t\t//\t2. width is computed as a rounded relation of the real width and the value of heigh.\n\t\t\treturn Math.round( $.clientWidth / natural.width * natural.height ) == $.clientHeight ||\n\t\t\t\tMath.round( $.clientHeight / natural.height * natural.width ) == $.clientWidth;\n\t\t},\n\n\t\t// Returns natural dimensions of the image. For modern browsers\n\t\t// it uses natural(Width|Height) for old ones (IE8), creates\n\t\t// a new image and reads dimensions.\n\t\t// @param {CKEDITOR.dom.element} image\n\t\t// @returns {Object}\n\t\tgetNatural: function( image ) {\n\t\t\tvar dimensions;\n\n\t\t\tif ( image.$.naturalWidth ) {\n\t\t\t\tdimensions = {\n\t\t\t\t\twidth: image.$.naturalWidth,\n\t\t\t\t\theight: image.$.naturalHeight\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tvar img = new Image();\n\t\t\t\timg.src = image.getAttribute( 'src' );\n\n\t\t\t\tdimensions = {\n\t\t\t\t\twidth: img.width,\n\t\t\t\t\theight: img.height\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn dimensions;\n\t\t}\n\t};\n\n\tfunction setWrapperAlign( widget, alignClasses ) {\n\t\tvar wrapper = widget.wrapper,\n\t\t\talign = widget.data.align,\n\t\t\thasCaption = widget.data.hasCaption;\n\n\t\tif ( alignClasses ) {\n\t\t\t// Remove all align classes first.\n\t\t\tfor ( var i = 3; i--; )\n\t\t\t\twrapper.removeClass( alignClasses[ i ] );\n\n\t\t\tif ( align == 'center' ) {\n\t\t\t\t// Avoid touching non-captioned, centered widgets because\n\t\t\t\t// they have the class set on the element instead of wrapper:\n\t\t\t\t//\n\t\t\t\t// \t
    \n\t\t\t\t// \t\t

    \n\t\t\t\t// \t\t\t\n\t\t\t\t// \t\t

    \n\t\t\t\t// \t
    \n\t\t\t\tif ( hasCaption ) {\n\t\t\t\t\twrapper.addClass( alignClasses[ 1 ] );\n\t\t\t\t}\n\t\t\t} else if ( align != 'none' ) {\n\t\t\t\twrapper.addClass( alignClasses[ alignmentsObj[ align ] ] );\n\t\t\t}\n\t\t} else {\n\t\t\tif ( align == 'center' ) {\n\t\t\t\tif ( hasCaption )\n\t\t\t\t\twrapper.setStyle( 'text-align', 'center' );\n\t\t\t\telse\n\t\t\t\t\twrapper.removeStyle( 'text-align' );\n\n\t\t\t\twrapper.removeStyle( 'float' );\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif ( align == 'none' )\n\t\t\t\t\twrapper.removeStyle( 'float' );\n\t\t\t\telse\n\t\t\t\t\twrapper.setStyle( 'float', align );\n\n\t\t\t\twrapper.removeStyle( 'text-align' );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Returns a function that creates widgets from all and\n\t//
    elements.\n\t//\n\t// @param {CKEDITOR.editor} editor\n\t// @returns {Function}\n\tfunction upcastWidgetElement( editor ) {\n\t\tvar isCenterWrapper = centerWrapperChecker( editor ),\n\t\t\tcaptionedClass = editor.config.image2_captionedClass;\n\n\t\t// @param {CKEDITOR.htmlParser.element} el\n\t\t// @param {Object} data\n\t\treturn function( el, data ) {\n\t\t\tvar dimensions = { width: 1, height: 1 },\n\t\t\t\tname = el.name,\n\t\t\t\timage;\n\n\t\t\t// #11110 Don't initialize on pasted fake objects.\n\t\t\tif ( el.attributes[ 'data-cke-realelement' ] )\n\t\t\t\treturn;\n\n\t\t\t// If a center wrapper is found, there are 3 possible cases:\n\t\t\t//\n\t\t\t// 1.
    ...
    .\n\t\t\t// In this case centering is done with a class set on widget.wrapper.\n\t\t\t// Simply replace centering wrapper with figure (it's no longer necessary).\n\t\t\t//\n\t\t\t// 2.

    .\n\t\t\t// Nothing to do here:

    remains for styling purposes.\n\t\t\t//\n\t\t\t// 3.

    .\n\t\t\t// Nothing to do here (2.) but that case is only possible in enterMode different\n\t\t\t// than ENTER_P.\n\t\t\tif ( isCenterWrapper( el ) ) {\n\t\t\t\tif ( name == 'div' ) {\n\t\t\t\t\tvar figure = el.getFirst( 'figure' );\n\n\t\t\t\t\t// Case #1.\n\t\t\t\t\tif ( figure ) {\n\t\t\t\t\t\tel.replaceWith( figure );\n\t\t\t\t\t\tel = figure;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Cases #2 and #3 (handled transparently)\n\n\t\t\t\t// If there's a centering wrapper, save it in data.\n\t\t\t\tdata.align = 'center';\n\n\t\t\t\t// Image can be wrapped in link .\n\t\t\t\timage = el.getFirst( 'img' ) || el.getFirst( 'a' ).getFirst( 'img' );\n\t\t\t}\n\n\t\t\t// No center wrapper has been found.\n\t\t\telse if ( name == 'figure' && el.hasClass( captionedClass ) ) {\n\t\t\t\timage = el.getFirst( 'img' ) || el.getFirst( 'a' ).getFirst( 'img' );\n\n\t\t\t\t// Upcast linked image like .\n\t\t\t} else if ( isLinkedOrStandaloneImage( el ) ) {\n\t\t\t\timage = el.name == 'a' ? el.children[ 0 ] : el;\n\t\t\t}\n\n\t\t\tif ( !image )\n\t\t\t\treturn;\n\n\t\t\t// If there's an image, then cool, we got a widget.\n\t\t\t// Now just remove dimension attributes expressed with %.\n\t\t\tfor ( var d in dimensions ) {\n\t\t\t\tvar dimension = image.attributes[ d ];\n\n\t\t\t\tif ( dimension && dimension.match( regexPercent ) )\n\t\t\t\t\tdelete image.attributes[ d ];\n\t\t\t}\n\n\t\t\treturn el;\n\t\t};\n\t}\n\n\t// Returns a function which transforms the widget to the external format\n\t// according to the current configuration.\n\t//\n\t// @param {CKEDITOR.editor}\n\tfunction downcastWidgetElement( editor ) {\n\t\tvar alignClasses = editor.config.image2_alignClasses;\n\n\t\t// @param {CKEDITOR.htmlParser.element} el\n\t\treturn function( el ) {\n\t\t\t// In case of , is the element to hold\n\t\t\t// inline styles or classes (image2_alignClasses).\n\t\t\tvar attrsHolder = el.name == 'a' ? el.getFirst() : el,\n\t\t\t\tattrs = attrsHolder.attributes,\n\t\t\t\talign = this.data.align;\n\n\t\t\t// De-wrap the image from resize handle wrapper.\n\t\t\t// Only block widgets have one.\n\t\t\tif ( !this.inline ) {\n\t\t\t\tvar resizeWrapper = el.getFirst( 'span' );\n\n\t\t\t\tif ( resizeWrapper )\n\t\t\t\t\tresizeWrapper.replaceWith( resizeWrapper.getFirst( { img: 1, a: 1 } ) );\n\t\t\t}\n\n\t\t\tif ( align && align != 'none' ) {\n\t\t\t\tvar styles = CKEDITOR.tools.parseCssText( attrs.style || '' );\n\n\t\t\t\t// When the widget is captioned (
    ) and internally centering is done\n\t\t\t\t// with widget's wrapper style/class, in the external data representation,\n\t\t\t\t//
    must be wrapped with an element holding an style/class:\n\t\t\t\t//\n\t\t\t\t// \t
    \n\t\t\t\t// \t\t
    ...
    \n\t\t\t\t// \t
    \n\t\t\t\t// or\n\t\t\t\t// \t
    \n\t\t\t\t// \t\t
    ...
    \n\t\t\t\t// \t
    \n\t\t\t\t//\n\t\t\t\tif ( align == 'center' && el.name == 'figure' ) {\n\t\t\t\t\tel = el.wrapWith( new CKEDITOR.htmlParser.element( 'div',\n\t\t\t\t\t\talignClasses ? { 'class': alignClasses[ 1 ] } : { style: 'text-align:center' } ) );\n\t\t\t\t}\n\n\t\t\t\t// If left/right, add float style to the downcasted element.\n\t\t\t\telse if ( align in { left: 1, right: 1 } ) {\n\t\t\t\t\tif ( alignClasses )\n\t\t\t\t\t\tattrsHolder.addClass( alignClasses[ alignmentsObj[ align ] ] );\n\t\t\t\t\telse\n\t\t\t\t\t\tstyles[ 'float' ] = align;\n\t\t\t\t}\n\n\t\t\t\t// Update element styles.\n\t\t\t\tif ( !alignClasses && !CKEDITOR.tools.isEmpty( styles ) )\n\t\t\t\t\tattrs.style = CKEDITOR.tools.writeCssText( styles );\n\t\t\t}\n\n\t\t\treturn el;\n\t\t};\n\t}\n\n\t// Returns a function that checks if an element is a centering wrapper.\n\t//\n\t// @param {CKEDITOR.editor} editor\n\t// @returns {Function}\n\tfunction centerWrapperChecker( editor ) {\n\t\tvar captionedClass = editor.config.image2_captionedClass,\n\t\t\talignClasses = editor.config.image2_alignClasses,\n\t\t\tvalidChildren = { figure: 1, a: 1, img: 1 };\n\n\t\treturn function( el ) {\n\t\t\t// Wrapper must be either
    or

    .\n\t\t\tif ( !( el.name in { div: 1, p: 1 } ) )\n\t\t\t\treturn false;\n\n\t\t\tvar children = el.children;\n\n\t\t\t// Centering wrapper can have only one child.\n\t\t\tif ( children.length !== 1 )\n\t\t\t\treturn false;\n\n\t\t\tvar child = children[ 0 ];\n\n\t\t\t// Only

    or can be first (only) child of centering wrapper,\n\t\t\t// regardless of its type.\n\t\t\tif ( !( child.name in validChildren ) )\n\t\t\t\treturn false;\n\n\t\t\t// If centering wrapper is

    , only can be the child.\n\t\t\t//

    \n\t\t\tif ( el.name == 'p' ) {\n\t\t\t\tif ( !isLinkedOrStandaloneImage( child ) )\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t// Centering
    can hold or
    , depending on enterMode.\n\t\t\telse {\n\t\t\t\t// If a
    is the first (only) child, it must have a class.\n\t\t\t\t//
    ...
    \n\t\t\t\tif ( child.name == 'figure' ) {\n\t\t\t\t\tif ( !child.hasClass( captionedClass ) )\n\t\t\t\t\t\treturn false;\n\t\t\t\t} else {\n\t\t\t\t\t// Centering
    can hold or only when enterMode\n\t\t\t\t\t// is ENTER_(BR|DIV).\n\t\t\t\t\t//
    \n\t\t\t\t\t//
    \n\t\t\t\t\tif ( editor.enterMode == CKEDITOR.ENTER_P )\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t// Regardless of enterMode, a child which is not
    must be\n\t\t\t\t\t// either or .\n\t\t\t\t\tif ( !isLinkedOrStandaloneImage( child ) )\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Centering wrapper got to be... centering. If image2_alignClasses are defined,\n\t\t\t// check for centering class. Otherwise, check the style.\n\t\t\tif ( alignClasses ? el.hasClass( alignClasses[ 1 ] ) :\n\t\t\t\t\tCKEDITOR.tools.parseCssText( el.attributes.style || '', true )[ 'text-align' ] == 'center' )\n\t\t\t\treturn true;\n\n\t\t\treturn false;\n\t\t};\n\t}\n\n\t// Checks whether element is or .\n\t//\n\t// @param {CKEDITOR.htmlParser.element}\n\tfunction isLinkedOrStandaloneImage( el ) {\n\t\tif ( el.name == 'img' )\n\t\t\treturn true;\n\t\telse if ( el.name == 'a' )\n\t\t\treturn el.children.length == 1 && el.getFirst( 'img' );\n\n\t\treturn false;\n\t}\n\n\t// Sets width and height of the widget image according to current widget data.\n\t//\n\t// @param {CKEDITOR.plugins.widget} widget\n\tfunction setDimensions( widget ) {\n\t\tvar data = widget.data,\n\t\t\tdimensions = { width: data.width, height: data.height },\n\t\t\timage = widget.parts.image;\n\n\t\tfor ( var d in dimensions ) {\n\t\t\tif ( dimensions[ d ] )\n\t\t\t\timage.setAttribute( d, dimensions[ d ] );\n\t\t\telse\n\t\t\t\timage.removeAttribute( d );\n\t\t}\n\t}\n\n\t// Defines all features related to drag-driven image resizing.\n\t//\n\t// @param {CKEDITOR.plugins.widget} widget\n\tfunction setupResizer( widget ) {\n\t\tvar editor = widget.editor,\n\t\t\teditable = editor.editable(),\n\t\t\tdoc = editor.document,\n\n\t\t\t// Store the resizer in a widget for testing (#11004).\n\t\t\tresizer = widget.resizer = doc.createElement( 'span' );\n\n\t\tresizer.addClass( 'cke_image_resizer' );\n\t\tresizer.setAttribute( 'title', editor.lang.image2.resizer );\n\t\tresizer.append( new CKEDITOR.dom.text( '\\u200b', doc ) );\n\n\t\t// Inline widgets don't need a resizer wrapper as an image spans the entire widget.\n\t\tif ( !widget.inline ) {\n\t\t\tvar imageOrLink = widget.parts.link || widget.parts.image,\n\t\t\t\toldResizeWrapper = imageOrLink.getParent(),\n\t\t\t\tresizeWrapper = doc.createElement( 'span' );\n\n\t\t\tresizeWrapper.addClass( 'cke_image_resizer_wrapper' );\n\t\t\tresizeWrapper.append( imageOrLink );\n\t\t\tresizeWrapper.append( resizer );\n\t\t\twidget.element.append( resizeWrapper, true );\n\n\t\t\t// Remove the old wrapper which could came from e.g. pasted HTML\n\t\t\t// and which could be corrupted (e.g. resizer span has been lost).\n\t\t\tif ( oldResizeWrapper.is( 'span' ) )\n\t\t\t\toldResizeWrapper.remove();\n\t\t} else {\n\t\t\twidget.wrapper.append( resizer );\n\t\t}\n\n\t\t// Calculate values of size variables and mouse offsets.\n\t\tresizer.on( 'mousedown', function( evt ) {\n\t\t\tvar image = widget.parts.image,\n\n\t\t\t\t// \"factor\" can be either 1 or -1. I.e.: For right-aligned images, we need to\n\t\t\t\t// subtract the difference to get proper width, etc. Without \"factor\",\n\t\t\t\t// resizer starts working the opposite way.\n\t\t\t\tfactor = widget.data.align == 'right' ? -1 : 1,\n\n\t\t\t\t// The x-coordinate of the mouse relative to the screen\n\t\t\t\t// when button gets pressed.\n\t\t\t\tstartX = evt.data.$.screenX,\n\t\t\t\tstartY = evt.data.$.screenY,\n\n\t\t\t\t// The initial dimensions and aspect ratio of the image.\n\t\t\t\tstartWidth = image.$.clientWidth,\n\t\t\t\tstartHeight = image.$.clientHeight,\n\t\t\t\tratio = startWidth / startHeight,\n\n\t\t\t\tlisteners = [],\n\n\t\t\t\t// A class applied to editable during resizing.\n\t\t\t\tcursorClass = 'cke_image_s' + ( !~factor ? 'w' : 'e' ),\n\n\t\t\t\tnativeEvt, newWidth, newHeight, updateData,\n\t\t\t\tmoveDiffX, moveDiffY, moveRatio;\n\n\t\t\t// Save the undo snapshot first: before resizing.\n\t\t\teditor.fire( 'saveSnapshot' );\n\n\t\t\t// Mousemove listeners are removed on mouseup.\n\t\t\tattachToDocuments( 'mousemove', onMouseMove, listeners );\n\n\t\t\t// Clean up the mousemove listener. Update widget data if valid.\n\t\t\tattachToDocuments( 'mouseup', onMouseUp, listeners );\n\n\t\t\t// The entire editable will have the special cursor while resizing goes on.\n\t\t\teditable.addClass( cursorClass );\n\n\t\t\t// This is to always keep the resizer element visible while resizing.\n\t\t\tresizer.addClass( 'cke_image_resizing' );\n\n\t\t\t// Attaches an event to a global document if inline editor.\n\t\t\t// Additionally, if classic (`iframe`-based) editor, also attaches the same event to `iframe`'s document.\n\t\t\tfunction attachToDocuments( name, callback, collection ) {\n\t\t\t\tvar globalDoc = CKEDITOR.document,\n\t\t\t\t\tlisteners = [];\n\n\t\t\t\tif ( !doc.equals( globalDoc ) )\n\t\t\t\t\tlisteners.push( globalDoc.on( name, callback ) );\n\n\t\t\t\tlisteners.push( doc.on( name, callback ) );\n\n\t\t\t\tif ( collection ) {\n\t\t\t\t\tfor ( var i = listeners.length; i--; )\n\t\t\t\t\t\tcollection.push( listeners.pop() );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Calculate with first, and then adjust height, preserving ratio.\n\t\t\tfunction adjustToX() {\n\t\t\t\tnewWidth = startWidth + factor * moveDiffX;\n\t\t\t\tnewHeight = Math.round( newWidth / ratio );\n\t\t\t}\n\n\t\t\t// Calculate height first, and then adjust width, preserving ratio.\n\t\t\tfunction adjustToY() {\n\t\t\t\tnewHeight = startHeight - moveDiffY;\n\t\t\t\tnewWidth = Math.round( newHeight * ratio );\n\t\t\t}\n\n\t\t\t// This is how variables refer to the geometry.\n\t\t\t// Note: x corresponds to moveOffset, this is the position of mouse\n\t\t\t// Note: o corresponds to [startX, startY].\n\t\t\t//\n\t\t\t// \t+--------------+--------------+\n\t\t\t// \t| | |\n\t\t\t// \t| I | II |\n\t\t\t// \t| | |\n\t\t\t// \t+------------- o -------------+ _ _ _\n\t\t\t// \t| | | ^\n\t\t\t// \t| VI | III | | moveDiffY\n\t\t\t// \t| | x _ _ _ _ _ v\n\t\t\t// \t+--------------+---------|----+\n\t\t\t// \t | |\n\t\t\t// \t <------->\n\t\t\t// \t moveDiffX\n\t\t\tfunction onMouseMove( evt ) {\n\t\t\t\tnativeEvt = evt.data.$;\n\n\t\t\t\t// This is how far the mouse is from the point the button was pressed.\n\t\t\t\tmoveDiffX = nativeEvt.screenX - startX;\n\t\t\t\tmoveDiffY = startY - nativeEvt.screenY;\n\n\t\t\t\t// This is the aspect ratio of the move difference.\n\t\t\t\tmoveRatio = Math.abs( moveDiffX / moveDiffY );\n\n\t\t\t\t// Left, center or none-aligned widget.\n\t\t\t\tif ( factor == 1 ) {\n\t\t\t\t\tif ( moveDiffX <= 0 ) {\n\t\t\t\t\t\t// Case: IV.\n\t\t\t\t\t\tif ( moveDiffY <= 0 )\n\t\t\t\t\t\t\tadjustToX();\n\n\t\t\t\t\t\t// Case: I.\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif ( moveRatio >= ratio )\n\t\t\t\t\t\t\t\tadjustToX();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Case: III.\n\t\t\t\t\t\tif ( moveDiffY <= 0 ) {\n\t\t\t\t\t\t\tif ( moveRatio >= ratio )\n\t\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tadjustToX();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Case: II.\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Right-aligned widget. It mirrors behaviours, so I becomes II,\n\t\t\t\t// IV becomes III and vice-versa.\n\t\t\t\telse {\n\t\t\t\t\tif ( moveDiffX <= 0 ) {\n\t\t\t\t\t\t// Case: IV.\n\t\t\t\t\t\tif ( moveDiffY <= 0 ) {\n\t\t\t\t\t\t\tif ( moveRatio >= ratio )\n\t\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tadjustToX();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Case: I.\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Case: III.\n\t\t\t\t\t\tif ( moveDiffY <= 0 )\n\t\t\t\t\t\t\tadjustToX();\n\n\t\t\t\t\t\t// Case: II.\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif ( moveRatio >= ratio ) {\n\t\t\t\t\t\t\t\tadjustToX();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tadjustToY();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Don't update attributes if less than 10.\n\t\t\t\t// This is to prevent images to visually disappear.\n\t\t\t\tif ( newWidth >= 15 && newHeight >= 15 ) {\n\t\t\t\t\timage.setAttributes( { width: newWidth, height: newHeight } );\n\t\t\t\t\tupdateData = true;\n\t\t\t\t} else {\n\t\t\t\t\tupdateData = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onMouseUp() {\n\t\t\t\tvar l;\n\n\t\t\t\twhile ( ( l = listeners.pop() ) )\n\t\t\t\t\tl.removeListener();\n\n\t\t\t\t// Restore default cursor by removing special class.\n\t\t\t\teditable.removeClass( cursorClass );\n\n\t\t\t\t// This is to bring back the regular behaviour of the resizer.\n\t\t\t\tresizer.removeClass( 'cke_image_resizing' );\n\n\t\t\t\tif ( updateData ) {\n\t\t\t\t\twidget.setData( { width: newWidth, height: newHeight } );\n\n\t\t\t\t\t// Save another undo snapshot: after resizing.\n\t\t\t\t\teditor.fire( 'saveSnapshot' );\n\t\t\t\t}\n\n\t\t\t\t// Don't update data twice or more.\n\t\t\t\tupdateData = false;\n\t\t\t}\n\t\t} );\n\n\t\t// Change the position of the widget resizer when data changes.\n\t\twidget.on( 'data', function() {\n\t\t\tresizer[ widget.data.align == 'right' ? 'addClass' : 'removeClass' ]( 'cke_image_resizer_left' );\n\t\t} );\n\t}\n\n\t// Integrates widget alignment setting with justify\n\t// plugin's commands (execution and refreshment).\n\t// @param {CKEDITOR.editor} editor\n\t// @param {String} value 'left', 'right', 'center' or 'block'\n\tfunction alignCommandIntegrator( editor ) {\n\t\tvar execCallbacks = [],\n\t\t\tenabled;\n\n\t\treturn function( value ) {\n\t\t\tvar command = editor.getCommand( 'justify' + value );\n\n\t\t\t// Most likely, the justify plugin isn't loaded.\n\t\t\tif ( !command )\n\t\t\t\treturn;\n\n\t\t\t// This command will be manually refreshed along with\n\t\t\t// other commands after exec.\n\t\t\texecCallbacks.push( function() {\n\t\t\t\tcommand.refresh( editor, editor.elementPath() );\n\t\t\t} );\n\n\t\t\tif ( value in { right: 1, left: 1, center: 1 } ) {\n\t\t\t\tcommand.on( 'exec', function( evt ) {\n\t\t\t\t\tvar widget = getFocusedWidget( editor );\n\n\t\t\t\t\tif ( widget ) {\n\t\t\t\t\t\twidget.setData( 'align', value );\n\n\t\t\t\t\t\t// Once the widget changed its align, all the align commands\n\t\t\t\t\t\t// must be refreshed: the event is to be cancelled.\n\t\t\t\t\t\tfor ( var i = execCallbacks.length; i--; )\n\t\t\t\t\t\t\texecCallbacks[ i ]();\n\n\t\t\t\t\t\tevt.cancel();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcommand.on( 'refresh', function( evt ) {\n\t\t\t\tvar widget = getFocusedWidget( editor ),\n\t\t\t\t\tallowed = { right: 1, left: 1, center: 1 };\n\n\t\t\t\tif ( !widget )\n\t\t\t\t\treturn;\n\n\t\t\t\t// Cache \"enabled\" on first use. This is because filter#checkFeature may\n\t\t\t\t// not be available during plugin's afterInit in the future — a moment when\n\t\t\t\t// alignCommandIntegrator is called.\n\t\t\t\tif ( enabled === undefined )\n\t\t\t\t\tenabled = editor.filter.checkFeature( editor.widgets.registered.image.features.align );\n\n\t\t\t\t// Don't allow justify commands when widget alignment is disabled (#11004).\n\t\t\t\tif ( !enabled )\n\t\t\t\t\tthis.setState( CKEDITOR.TRISTATE_DISABLED );\n\t\t\t\telse {\n\t\t\t\t\tthis.setState(\n\t\t\t\t\t\t( widget.data.align == value ) ? (\n\t\t\t\t\t\t\tCKEDITOR.TRISTATE_ON\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t( value in allowed ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tevt.cancel();\n\t\t\t} );\n\t\t};\n\t}\n\n\tfunction linkCommandIntegrator( editor ) {\n\t\t// Nothing to integrate with if link is not loaded.\n\t\tif ( !editor.plugins.link )\n\t\t\treturn;\n\n\t\tCKEDITOR.on( 'dialogDefinition', function( evt ) {\n\t\t\tvar dialog = evt.data;\n\n\t\t\tif ( dialog.name == 'link' ) {\n\t\t\t\tvar def = dialog.definition;\n\n\t\t\t\tvar onShow = def.onShow,\n\t\t\t\t\tonOk = def.onOk;\n\n\t\t\t\tdef.onShow = function() {\n\t\t\t\t\tvar widget = getFocusedWidget( editor );\n\n\t\t\t\t\t// Widget cannot be enclosed in a link, i.e.\n\t\t\t\t\t//\t\tfoobar\n\t\t\t\t\tif ( widget && ( widget.inline ? !widget.wrapper.getAscendant( 'a' ) : 1 ) )\n\t\t\t\t\t\tthis.setupContent( widget.data.link || {} );\n\t\t\t\t\telse\n\t\t\t\t\t\tonShow.apply( this, arguments );\n\t\t\t\t};\n\n\t\t\t\t// Set widget data if linking the widget using\n\t\t\t\t// link dialog (instead of default action).\n\t\t\t\t// State shifter handles data change and takes\n\t\t\t\t// care of internal DOM structure of linked widget.\n\t\t\t\tdef.onOk = function() {\n\t\t\t\t\tvar widget = getFocusedWidget( editor );\n\n\t\t\t\t\t// Widget cannot be enclosed in a link, i.e.\n\t\t\t\t\t//\t\tfoobar\n\t\t\t\t\tif ( widget && ( widget.inline ? !widget.wrapper.getAscendant( 'a' ) : 1 ) ) {\n\t\t\t\t\t\tvar data = {};\n\n\t\t\t\t\t\t// Collect data from fields.\n\t\t\t\t\t\tthis.commitContent( data );\n\n\t\t\t\t\t\t// Set collected data to widget.\n\t\t\t\t\t\twidget.setData( 'link', data );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonOk.apply( this, arguments );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// Overwrite default behaviour of unlink command.\n\t\teditor.getCommand( 'unlink' ).on( 'exec', function( evt ) {\n\t\t\tvar widget = getFocusedWidget( editor );\n\n\t\t\t// Override unlink only when link truly belongs to the widget.\n\t\t\t// If wrapped inline widget in a link, let default unlink work (#11814).\n\t\t\tif ( !widget || !widget.parts.link )\n\t\t\t\treturn;\n\n\t\t\twidget.setData( 'link', null );\n\n\t\t\t// Selection (which is fake) may not change if unlinked image in focused widget,\n\t\t\t// i.e. if captioned image. Let's refresh command state manually here.\n\t\t\tthis.refresh( editor, editor.elementPath() );\n\n\t\t\tevt.cancel();\n\t\t} );\n\n\t\t// Overwrite default refresh of unlink command.\n\t\teditor.getCommand( 'unlink' ).on( 'refresh', function( evt ) {\n\t\t\tvar widget = getFocusedWidget( editor );\n\n\t\t\tif ( !widget )\n\t\t\t\treturn;\n\n\t\t\t// Note that widget may be wrapped in a link, which\n\t\t\t// does not belong to that widget (#11814).\n\t\t\tthis.setState( widget.data.link || widget.wrapper.getAscendant( 'a' ) ?\n\t\t\t\tCKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );\n\n\t\t\tevt.cancel();\n\t\t} );\n\t}\n\n\t// Returns the focused widget, if of the type specific for this plugin.\n\t// If no widget is focused, `null` is returned.\n\t//\n\t// @param {CKEDITOR.editor}\n\t// @returns {CKEDITOR.plugins.widget}\n\tfunction getFocusedWidget( editor ) {\n\t\tvar widget = editor.widgets.focused;\n\n\t\tif ( widget && widget.name == 'image' )\n\t\t\treturn widget;\n\n\t\treturn null;\n\t}\n\n\t// Returns a set of widget allowedContent rules, depending\n\t// on configurations like config#image2_alignClasses or\n\t// config#image2_captionedClass.\n\t//\n\t// @param {CKEDITOR.editor}\n\t// @returns {Object}\n\tfunction getWidgetAllowedContent( editor ) {\n\t\tvar alignClasses = editor.config.image2_alignClasses,\n\t\t\trules = {\n\t\t\t\t// Widget may need
    or

    centering wrapper.\n\t\t\t\tdiv: {\n\t\t\t\t\tmatch: centerWrapperChecker( editor )\n\t\t\t\t},\n\t\t\t\tp: {\n\t\t\t\t\tmatch: centerWrapperChecker( editor )\n\t\t\t\t},\n\t\t\t\timg: {\n\t\t\t\t\tattributes: '!src,alt,width,height'\n\t\t\t\t},\n\t\t\t\tfigure: {\n\t\t\t\t\tclasses: '!' + editor.config.image2_captionedClass\n\t\t\t\t},\n\t\t\t\tfigcaption: true\n\t\t\t};\n\n\t\tif ( alignClasses ) {\n\t\t\t// Centering class from the config.\n\t\t\trules.div.classes = alignClasses[ 1 ];\n\t\t\trules.p.classes = rules.div.classes;\n\n\t\t\t// Left/right classes from the config.\n\t\t\trules.img.classes = alignClasses[ 0 ] + ',' + alignClasses[ 2 ];\n\t\t\trules.figure.classes += ',' + rules.img.classes;\n\t\t} else {\n\t\t\t// Centering with text-align.\n\t\t\trules.div.styles = 'text-align';\n\t\t\trules.p.styles = 'text-align';\n\n\t\t\trules.img.styles = 'float';\n\t\t\trules.figure.styles = 'float,display';\n\t\t}\n\n\t\treturn rules;\n\t}\n\n\t// Returns a set of widget feature rules, depending\n\t// on editor configuration. Note that the following may not cover\n\t// all the possible cases since requiredContent supports a single\n\t// tag only.\n\t//\n\t// @param {CKEDITOR.editor}\n\t// @returns {Object}\n\tfunction getWidgetFeatures( editor ) {\n\t\tvar alignClasses = editor.config.image2_alignClasses,\n\t\t\tfeatures = {\n\t\t\t\tdimension: {\n\t\t\t\t\trequiredContent: 'img[width,height]'\n\t\t\t\t},\n\t\t\t\talign: {\n\t\t\t\t\trequiredContent: 'img' +\n\t\t\t\t\t\t( alignClasses ? '(' + alignClasses[ 0 ] + ')' : '{float}' )\n\t\t\t\t},\n\t\t\t\tcaption: {\n\t\t\t\t\trequiredContent: 'figcaption'\n\t\t\t\t}\n\t\t\t};\n\n\t\treturn features;\n\t}\n\n\t// Returns element which is styled, considering current\n\t// state of the widget.\n\t//\n\t// @see CKEDITOR.plugins.widget#applyStyle\n\t// @param {CKEDITOR.plugins.widget} widget\n\t// @returns {CKEDITOR.dom.element}\n\tfunction getStyleableElement( widget ) {\n\t\treturn widget.data.hasCaption ? widget.element : widget.parts.image;\n\t}\n} )();\n\n/**\n * A CSS class applied to the `

    ` element of a captioned image.\n *\n *\t\t// Changes the class to \"captionedImage\".\n *\t\tconfig.image2_captionedClass = 'captionedImage';\n *\n * @cfg {String} [image2_captionedClass='image']\n * @member CKEDITOR.config\n */\nCKEDITOR.config.image2_captionedClass = 'image';\n\n/**\n * Determines whether dimension inputs should be automatically filled when the image URL changes in the Enhanced Image\n * plugin dialog window.\n *\n *\t\tconfig.image2_prefillDimensions = false;\n *\n * @since 4.5\n * @cfg {Boolean} [image2_prefillDimensions=true]\n * @member CKEDITOR.config\n */\n\n/**\n * Disables the image resizer. By default the resizer is enabled.\n *\n *\t\tconfig.image2_disableResizer = true;\n *\n * @since 4.5\n * @cfg {Boolean} [image2_disableResizer=false]\n * @member CKEDITOR.config\n */\n\n/**\n * CSS classes applied to aligned images. Useful to take control over the way\n * the images are aligned, i.e. to customize output HTML and integrate external stylesheets.\n *\n * Classes should be defined in an array of three elements, containing left, center, and right\n * alignment classes, respectively. For example:\n *\n *\t\tconfig.image2_alignClasses = [ 'align-left', 'align-center', 'align-right' ];\n *\n * **Note**: Once this configuration option is set, the plugin will no longer produce inline\n * styles for alignment. It means that e.g. the following HTML will be produced:\n *\n *\t\t\"My\n *\n * instead of:\n *\n *\t\t\"My\n *\n * **Note**: Once this configuration option is set, corresponding style definitions\n * must be supplied to the editor:\n *\n * * For [classic editor](#!/guide/dev_framed) it can be done by defining additional\n * styles in the {@link CKEDITOR.config#contentsCss stylesheets loaded by the editor}. The same\n * styles must be provided on the target page where the content will be loaded.\n * * For [inline editor](#!/guide/dev_inline) the styles can be defined directly\n * with `