algoliasearch - Version 1.4.1

Version Notes

- NEW: Add analytics tags
- UPDATED: Customer group implementation (to lower the number of records)
- FIX: Amazon like suggestion
- FIX: special price in case of partial updates
- FIX: No results page (facets)

Download this release

Release Info

Developer Algolia Team
Extension algoliasearch
Version 1.4.1
Comparing to
See all releases


Code changes from version 1.4.0 to 1.4.1

app/code/community/Algolia/Algoliasearch/Block/System/Config/Form/Field/Facets.php CHANGED
@@ -32,7 +32,6 @@ class Algolia_Algoliasearch_Block_System_Config_Form_Field_Facets extends Mage_A
32
  'conjunctive' => 'Conjunctive',
33
  'disjunctive' => 'Disjunctive',
34
  'slider' => 'Slider',
35
- 'hierarchical' => 'Hierarchical (for categories only)',
36
  'other' => 'Other ->'
37
  );
38
 
32
  'conjunctive' => 'Conjunctive',
33
  'disjunctive' => 'Disjunctive',
34
  'slider' => 'Slider',
 
35
  'other' => 'Other ->'
36
  );
37
 
app/code/community/Algolia/Algoliasearch/Helper/Config.php CHANGED
@@ -200,16 +200,21 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
200
 
201
  $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
202
 
203
- $suffix_index_name = '';
204
-
205
- if ($this->isCustomerGroupsEnabled($storeId))
206
  {
207
- $suffix_index_name = '_group_' . $group_id;
 
 
 
 
 
 
 
 
 
 
208
  }
209
 
210
- foreach ($attrs as &$attr)
211
- $attr['index_name'] = $product_helper->getIndexName($storeId).$suffix_index_name.'_'.$attr['attribute'].'_'.$attr['sort'];
212
-
213
  if (is_array($attrs))
214
  return $attrs;
215
 
200
 
201
  $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
202
 
203
+ foreach ($attrs as &$attr)
 
 
204
  {
205
+ if ($this->isCustomerGroupsEnabled($storeId))
206
+ {
207
+ if (strpos($attr['attribute'], 'price') !== false)
208
+ {
209
+ $suffix_index_name = 'group_' . $group_id;
210
+
211
+ $attr['index_name'] = $product_helper->getIndexName($storeId) . '_' . $suffix_index_name . '_' .$attr['attribute'].'_'.$attr['sort'];
212
+ }
213
+ }
214
+ else
215
+ $attr['index_name'] = $product_helper->getIndexName($storeId) . '_' . 'default' . '_' .$attr['attribute'].'_'.$attr['sort'];
216
  }
217
 
 
 
 
218
  if (is_array($attrs))
219
  return $attrs;
220
 
app/code/community/Algolia/Algoliasearch/Helper/Data.php CHANGED
@@ -23,7 +23,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
23
 
24
  public function __construct()
25
  {
26
- \AlgoliaSearch\Version::$custom_value = " Magento (1.4.0)";
27
 
28
  $this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
29
 
@@ -40,19 +40,6 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
40
  {
41
  $this->algolia_helper->deleteIndex($this->product_helper->getIndexName($storeId));
42
  $this->algolia_helper->deleteIndex($this->category_helper->getIndexName($storeId));
43
-
44
- /**
45
- * Handle deletetion for customer groups
46
- */
47
- if ($this->config->isCustomerGroupsEnabled($storeId))
48
- {
49
- foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
50
- {
51
- $group_id = (int) $group->getData('customer_group_id');
52
-
53
- $this->algolia_helper->deleteIndex($this->product_helper->getIndexName($storeId).'_group_'.$group_id);
54
- }
55
- }
56
  }
57
 
58
  public function saveConfigurationToAlgolia($storeId = null)
@@ -66,20 +53,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
66
  foreach ($this->config->getAutocompleteAdditionnalSections() as $section)
67
  $this->algolia_helper->setSettings($this->additionalsections_helper->getIndexName($storeId).'_'.$section['attribute'], $this->additionalsections_helper->getIndexSettings($storeId));
68
 
69
- $this->algolia_helper->setSettings($this->product_helper->getIndexName($storeId), $this->product_helper->getIndexSettings($storeId));
70
-
71
- /**
72
- * Handle deletetion for customer groups
73
- */
74
- if ($this->config->isCustomerGroupsEnabled($storeId))
75
- {
76
- foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
77
- {
78
- $group_id = (int) $group->getData('customer_group_id');
79
-
80
- $this->algolia_helper->setSettings($this->product_helper->getIndexName($storeId).'_group_'.$group_id, $this->product_helper->getIndexSettings($storeId, $group_id));
81
- }
82
- }
83
  }
84
 
85
  public function getSearchResult($query, $storeId)
@@ -88,22 +62,13 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
88
 
89
  $index_name = $this->product_helper->getIndexName($storeId);
90
 
91
- /**
92
- * Handle customer group
93
- */
94
- if ($this->config->isCustomerGroupsEnabled($storeId))
95
- {
96
- $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
97
-
98
- $index_name = $this->product_helper->getIndexName($storeId).'_group_'.$group_id;
99
- }
100
-
101
  $answer = $this->algolia_helper->query($index_name, $query, array(
102
  'hitsPerPage' => max(5, min($resultsLimit, 1000)), // retrieve all the hits (hard limit is 1000)
103
  'attributesToRetrieve' => 'objectID',
104
  'attributesToHighlight' => '',
105
  'attributesToSnippet' => '',
106
- 'removeWordsIfNoResult'=> $this->config->getRemoveWordsIfNoResult($storeId)
 
107
  ));
108
 
109
  $data = array();
@@ -249,6 +214,11 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
249
  }
250
  }
251
 
 
 
 
 
 
252
  public function rebuildStoreProductIndex($storeId, $productIds)
253
  {
254
  $emulationInfo = $this->startEmulation($storeId);
@@ -288,7 +258,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
288
  $collection->setCurPage($page)->setPageSize($pageSize);
289
  $collection->load();
290
 
291
- $index_name = $this->suggestion_helper->getIndexName($storeId);
292
 
293
  $indexData = array();
294
 
@@ -349,7 +319,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
349
  unset($collection);
350
  }
351
 
352
- private function getProductsRecords($storeId, $collection, $groupId = null)
353
  {
354
  $indexData = array();
355
 
@@ -358,7 +328,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
358
  {
359
  $product->setStoreId($storeId);
360
 
361
- $json = $this->product_helper->getObject($product, $groupId);
362
 
363
  array_push($indexData, $json);
364
  }
@@ -382,30 +352,11 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
382
  /**
383
  * Normal Indexing
384
  */
385
- $indexData = $this->getProductsRecords($storeId, $collection, null);
386
 
387
  if (count($indexData) > 0)
388
  $this->algolia_helper->addObjects($indexData, $index_name);
389
 
390
-
391
- /**
392
- * Group Indexing
393
- */
394
- if ($this->config->isCustomerGroupsEnabled($storeId))
395
- {
396
- foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
397
- {
398
- $group_id = (int) $group->getData('customer_group_id');
399
-
400
- $index_name = $this->product_helper->getIndexName($storeId).'_group_'.$group_id;
401
-
402
- $indexData = $this->getProductsRecords($storeId, $collection, $group_id);
403
-
404
- if (count($indexData) > 0)
405
- $this->algolia_helper->addObjects($indexData, $index_name);
406
- }
407
- }
408
-
409
  unset($indexData);
410
 
411
  $collection->walk('clearInstance');
23
 
24
  public function __construct()
25
  {
26
+ \AlgoliaSearch\Version::$custom_value = " Magento (1.4.1)";
27
 
28
  $this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
29
 
40
  {
41
  $this->algolia_helper->deleteIndex($this->product_helper->getIndexName($storeId));
42
  $this->algolia_helper->deleteIndex($this->category_helper->getIndexName($storeId));
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  public function saveConfigurationToAlgolia($storeId = null)
53
  foreach ($this->config->getAutocompleteAdditionnalSections() as $section)
54
  $this->algolia_helper->setSettings($this->additionalsections_helper->getIndexName($storeId).'_'.$section['attribute'], $this->additionalsections_helper->getIndexSettings($storeId));
55
 
56
+ $this->product_helper->setSettings($storeId);
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  public function getSearchResult($query, $storeId)
62
 
63
  $index_name = $this->product_helper->getIndexName($storeId);
64
 
 
 
 
 
 
 
 
 
 
 
65
  $answer = $this->algolia_helper->query($index_name, $query, array(
66
  'hitsPerPage' => max(5, min($resultsLimit, 1000)), // retrieve all the hits (hard limit is 1000)
67
  'attributesToRetrieve' => 'objectID',
68
  'attributesToHighlight' => '',
69
  'attributesToSnippet' => '',
70
+ 'removeWordsIfNoResult'=> $this->config->getRemoveWordsIfNoResult($storeId),
71
+ 'analyticsTags' => 'backend-search'
72
  ));
73
 
74
  $data = array();
214
  }
215
  }
216
 
217
+ public function moveStoreSuggestionIndex($storeId)
218
+ {
219
+ $this->algolia_helper->moveIndex($this->suggestion_helper->getIndexName($storeId) . '_tmp', $this->suggestion_helper->getIndexName($storeId));
220
+ }
221
+
222
  public function rebuildStoreProductIndex($storeId, $productIds)
223
  {
224
  $emulationInfo = $this->startEmulation($storeId);
258
  $collection->setCurPage($page)->setPageSize($pageSize);
259
  $collection->load();
260
 
261
+ $index_name = $this->suggestion_helper->getIndexName($storeId) . '_tmp';
262
 
263
  $indexData = array();
264
 
319
  unset($collection);
320
  }
321
 
322
+ private function getProductsRecords($storeId, $collection)
323
  {
324
  $indexData = array();
325
 
328
  {
329
  $product->setStoreId($storeId);
330
 
331
+ $json = $this->product_helper->getObject($product);
332
 
333
  array_push($indexData, $json);
334
  }
352
  /**
353
  * Normal Indexing
354
  */
355
+ $indexData = $this->getProductsRecords($storeId, $collection);
356
 
357
  if (count($indexData) > 0)
358
  $this->algolia_helper->addObjects($indexData, $index_name);
359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  unset($indexData);
361
 
362
  $collection->walk('clearInstance');
app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php CHANGED
@@ -35,7 +35,7 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
35
  $productAttributes = array_diff($productAttributes, $excludedAttributes);
36
 
37
  foreach ($productAttributes as $attributeCode)
38
- self::$_productAttributes[$attributeCode] = $config->getAttribute('catalog_category', $attributeCode)->getFrontendLabel();
39
  }
40
 
41
  $attributes = self::$_productAttributes;
@@ -83,9 +83,6 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
83
  ->addAttributeToSelect('special_to_date')
84
  ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
85
 
86
-
87
-
88
-
89
  $additionalAttr = $this->config->getProductAdditionalAttributes($storeId);
90
 
91
  foreach ($additionalAttr as &$attr)
@@ -101,22 +98,12 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
101
  return $products;
102
  }
103
 
104
- public function getIndexSettings($storeId, $group_id = null)
105
  {
106
  $attributesToIndex = array();
107
  $unretrievableAttributes = array();
108
  $attributesForFaceting = array();
109
 
110
- $suffix_index_name = '';
111
-
112
- /**
113
- * Handle grouping
114
- */
115
- if ($group_id !== null)
116
- {
117
- $suffix_index_name = '_group_'.$group_id;
118
- }
119
-
120
  foreach ($this->config->getProductAdditionalAttributes($storeId) as $attribute)
121
  {
122
  if ($attribute['searchable'] == '1')
@@ -157,7 +144,9 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
157
  Mage::dispatchEvent('algolia_index_settings_prepare', array('store_id' => $storeId, 'index_settings' => $transport));
158
  $indexSettings = $transport->getData();
159
 
160
- $mergeSettings = $this->algolia_helper->mergeSettings($this->getIndexName($storeId).$suffix_index_name, $indexSettings);
 
 
161
 
162
  /**
163
  * Handle Slaves
@@ -169,24 +158,105 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
169
  $slaves = array();
170
 
171
  foreach ($sorting_indices as $values)
172
- $slaves[] = $this->getIndexName($storeId).$suffix_index_name.'_'.$values['attribute'].'_'.$values['sort'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
- $this->algolia_helper->setSettings($this->getIndexName($storeId).$suffix_index_name, array('slaves' => $slaves));
175
 
176
  foreach ($sorting_indices as $values)
177
  {
178
- $mergeSettings['ranking'] = array($values['sort'].'('.$values['attribute'].')', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom');
 
 
 
 
 
 
 
 
179
 
180
- $this->algolia_helper->setSettings($this->getIndexName($storeId).$suffix_index_name.'_'.$values['attribute'].'_'.$values['sort'], $mergeSettings);
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
  }
 
 
 
 
 
183
 
184
- unset($mergeSettings['ranking']);
 
185
 
186
- return $mergeSettings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  }
188
 
189
- public function getObject(Mage_Catalog_Model_Product $product, $group_id = null)
190
  {
191
  $defaultData = array();
192
 
@@ -201,45 +271,26 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
201
  $customData = array(
202
  'objectID' => $product->getId(),
203
  'name' => $product->getName(),
204
- 'price' => $product->getPrice(),
205
- 'price_with_tax' => Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false),
206
  'url' => $product->getProductUrl(),
207
  'description' => $product->getDescription()
208
  );
209
 
210
- $special_price = $product->getFinalPrice();
 
 
 
211
 
212
- /**
213
- * Handle group price
214
- */
215
- if ($group_id !== null)
216
- {
217
- $discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
218
- Mage::app()->getLocale()->storeTimeStamp($product->getStoreId()),
219
- Mage::app()->getStore($product->getStoreId())->getWebsiteId(),
220
- $group_id,
221
- $product->getId());
222
-
223
- if ($discounted_price !== false)
224
- $special_price = $discounted_price;
225
- }
226
 
227
-
228
- if ($special_price != $customData['price'])
229
  {
230
- $customData['special_price_from_date'] = strtotime($product->getSpecialFromDate());
231
- $customData['special_price_to_date'] = strtotime($product->getSpecialToDate());
232
-
233
- $customData['special_price'] = $special_price;
234
- $customData['special_price_with_tax'] = Mage::helper('tax')->getPrice($product, $special_price, true, null, null, null, null, false);
235
-
236
- $customData['special_price_formated'] = Mage::helper('core')->formatPrice($customData['special_price'], false);
237
- $customData['special_price_with_tax_formated'] = Mage::helper('core')->formatPrice($customData['special_price_with_tax'], false);
238
  }
239
 
240
- $customData['price_formated'] = Mage::helper('core')->formatPrice($customData['price'], false);
241
- $customData['price_with_tax_formated'] = Mage::helper('core')->formatPrice($customData['price_with_tax'], false);
242
-
243
  $categories = array();
244
  $categories_with_path = array();
245
 
@@ -292,7 +343,7 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
292
 
293
  foreach ($categories_hierarchical as &$level)
294
  {
295
- $level = array_unique($level);
296
  }
297
 
298
  foreach ($categories_with_path as &$category)
35
  $productAttributes = array_diff($productAttributes, $excludedAttributes);
36
 
37
  foreach ($productAttributes as $attributeCode)
38
+ self::$_productAttributes[$attributeCode] = $config->getAttribute('catalog_product', $attributeCode)->getFrontendLabel();
39
  }
40
 
41
  $attributes = self::$_productAttributes;
83
  ->addAttributeToSelect('special_to_date')
84
  ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
85
 
 
 
 
86
  $additionalAttr = $this->config->getProductAdditionalAttributes($storeId);
87
 
88
  foreach ($additionalAttr as &$attr)
98
  return $products;
99
  }
100
 
101
+ public function setSettings($storeId)
102
  {
103
  $attributesToIndex = array();
104
  $unretrievableAttributes = array();
105
  $attributesForFaceting = array();
106
 
 
 
 
 
 
 
 
 
 
 
107
  foreach ($this->config->getProductAdditionalAttributes($storeId) as $attribute)
108
  {
109
  if ($attribute['searchable'] == '1')
144
  Mage::dispatchEvent('algolia_index_settings_prepare', array('store_id' => $storeId, 'index_settings' => $transport));
145
  $indexSettings = $transport->getData();
146
 
147
+ $mergeSettings = $this->algolia_helper->mergeSettings($this->getIndexName($storeId), $indexSettings);
148
+
149
+ $this->algolia_helper->setSettings($this->getIndexName($storeId), $mergeSettings);
150
 
151
  /**
152
  * Handle Slaves
158
  $slaves = array();
159
 
160
  foreach ($sorting_indices as $values)
161
+ {
162
+ if ($this->config->isCustomerGroupsEnabled($storeId))
163
+ {
164
+ if (strpos($values['attribute'], 'price') !== false)
165
+ {
166
+ foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
167
+ {
168
+ $group_id = (int)$group->getData('customer_group_id');
169
+
170
+ $suffix_index_name = 'group_' . $group_id;
171
+
172
+ $slaves[] = $this->getIndexName($storeId) . '_' . $suffix_index_name . '_' .$values['attribute'].'_'.$values['sort'];
173
+ }
174
+ }
175
+ }
176
+ else
177
+ {
178
+ $slaves[] = $this->getIndexName($storeId) . '_' . 'default' . '_' .$values['attribute'].'_'.$values['sort'];
179
+ }
180
+ }
181
 
182
+ $this->algolia_helper->setSettings($this->getIndexName($storeId), array('slaves' => $slaves));
183
 
184
  foreach ($sorting_indices as $values)
185
  {
186
+ if ($this->config->isCustomerGroupsEnabled($storeId))
187
+ {
188
+ if (strpos($values['attribute'], 'price') !== false)
189
+ {
190
+ foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
191
+ {
192
+ $group_id = (int)$group->getData('customer_group_id');
193
+
194
+ $suffix_index_name = '_group_' . $group_id;
195
 
196
+ $mergeSettings['ranking'] = array($values['sort'].'('.$values['attribute'].'.'.$group_id.')', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom');
197
+
198
+ $this->algolia_helper->setSettings($this->getIndexName($storeId).$suffix_index_name.'_'.$values['attribute'].'_'.$values['sort'], $mergeSettings);
199
+ }
200
+ }
201
+ }
202
+ else
203
+ {
204
+ $mergeSettings['ranking'] = array($values['sort'].'('.$values['attribute'].'.'.'default'.')', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom');
205
+
206
+ $this->algolia_helper->setSettings($this->getIndexName($storeId) . '_' . 'default' . '_' .$values['attribute'].'_'.$values['sort'], $mergeSettings);
207
+ }
208
  }
209
  }
210
+ }
211
+
212
+ private function handlePrice(&$product, &$customData, $group_id = null)
213
+ {
214
+ $key = $group_id === null ? 'default' : $group_id;
215
 
216
+ $customData['price'][$key] = (double) $product->getPrice();
217
+ $customData['price_with_tax'][$key] = (double) Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false);
218
 
219
+ $special_price = null;
220
+
221
+ if ($group_id !== null) // If fetch special price for groups
222
+ {
223
+ $discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
224
+ Mage::app()->getLocale()->storeTimeStamp($product->getStoreId()),
225
+ Mage::app()->getStore($product->getStoreId())->getWebsiteId(),
226
+ $group_id,
227
+ $product->getId());
228
+
229
+ if ($discounted_price !== false)
230
+ $special_price = $discounted_price;
231
+ }
232
+ else // If fetch default special price
233
+ $special_price = (double) $product->getFinalPrice();
234
+
235
+ if ($special_price && $special_price !== $customData['price'][$key])
236
+ {
237
+ $customData['special_price_from_date'][$key] = strtotime($product->getSpecialFromDate());
238
+ $customData['special_price_to_date'][$key] = strtotime($product->getSpecialToDate());
239
+
240
+ $customData['special_price'][$key] = (double) $special_price;
241
+ $customData['special_price_with_tax'][$key] = (double) Mage::helper('tax')->getPrice($product, $special_price, true, null, null, null, null, false);
242
+
243
+ $customData['special_price_formated'][$key] = Mage::helper('core')->formatPrice($customData['special_price'][$key], false);
244
+ $customData['special_price_with_tax_formated'][$key] = Mage::helper('core')->formatPrice($customData['special_price_with_tax'][$key], false);
245
+ }
246
+ else
247
+ {
248
+ /**
249
+ * In case of partial updates set back to empty so that it get updated
250
+ */
251
+ $customData['special_price'][$key] = '';
252
+ $customData['special_price_with_tax'][$key] = '';
253
+ }
254
+
255
+ $customData['price_formated'][$key] = Mage::helper('core')->formatPrice($customData['price'][$key], false);
256
+ $customData['price_with_tax_formated'][$key] = Mage::helper('core')->formatPrice($customData['price_with_tax'][$key], false);
257
  }
258
 
259
+ public function getObject(Mage_Catalog_Model_Product $product)
260
  {
261
  $defaultData = array();
262
 
271
  $customData = array(
272
  'objectID' => $product->getId(),
273
  'name' => $product->getName(),
 
 
274
  'url' => $product->getProductUrl(),
275
  'description' => $product->getDescription()
276
  );
277
 
278
+ foreach (array('price', 'price_with_tax', 'special_price_from_date', 'special_price_to_date', 'special_price'
279
+ ,'special_price_with_tax', 'special_price_formated', 'special_price_with_tax_formated'
280
+ ,'price_formated', 'price_with_tax_formated') as $price)
281
+ $customData[$price] = array();
282
 
283
+ $this->handlePrice($product, $customData);
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
+ if ($this->config->isCustomerGroupsEnabled())
 
286
  {
287
+ foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
288
+ {
289
+ $group_id = (int)$group->getData('customer_group_id');
290
+ $this->handlePrice($product, $customData, $group_id);
291
+ }
 
 
 
292
  }
293
 
 
 
 
294
  $categories = array();
295
  $categories_with_path = array();
296
 
343
 
344
  foreach ($categories_hierarchical as &$level)
345
  {
346
+ $level = array_values(array_unique($level));
347
  }
348
 
349
  foreach ($categories_with_path as &$category)
app/code/community/Algolia/Algoliasearch/Model/Indexer/Algolia.php CHANGED
@@ -99,11 +99,11 @@ class Algolia_Algoliasearch_Model_Indexer_Algolia extends Mage_Index_Model_Index
99
  $product = $event->getDataObject();
100
  $delete = FALSE;
101
 
102
- if ($product->dataHasChangedFor('status') && $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
103
  {
104
  $delete = TRUE;
105
  }
106
- elseif ($product->dataHasChangedFor('visibility') && ! in_array($product->getData('visibility'), Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds()))
107
  {
108
  $delete = TRUE;
109
  }
@@ -181,7 +181,7 @@ class Algolia_Algoliasearch_Model_Indexer_Algolia extends Mage_Index_Model_Index
181
  $category = $event->getDataObject();
182
  $productIds = $category->getAffectedProductIds();
183
 
184
- if ($category->dataHasChangedFor('is_active') && ! $category->getData('is_active'))
185
  {
186
  $event->addNewData('catalogsearch_delete_category_id', array_merge(array($category->getId()), $category->getAllChildren(TRUE)));
187
 
99
  $product = $event->getDataObject();
100
  $delete = FALSE;
101
 
102
+ if ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
103
  {
104
  $delete = TRUE;
105
  }
106
+ elseif (! in_array($product->getData('visibility'), Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds()))
107
  {
108
  $delete = TRUE;
109
  }
181
  $category = $event->getDataObject();
182
  $productIds = $category->getAffectedProductIds();
183
 
184
+ if (! $category->getData('is_active'))
185
  {
186
  $event->addNewData('catalogsearch_delete_category_id', array_merge(array($category->getId()), $category->getAllChildren(TRUE)));
187
 
app/code/community/Algolia/Algoliasearch/Model/Observer.php CHANGED
@@ -152,6 +152,13 @@ class Algolia_Algoliasearch_Model_Observer
152
  return $this;
153
  }
154
 
 
 
 
 
 
 
 
155
  public function rebuildCategoryIndex(Varien_Object $event)
156
  {
157
  $storeId = $event->getStoreId();
152
  return $this;
153
  }
154
 
155
+ public function moveStoreSuggestionIndex(Varien_Object $event)
156
+ {
157
+ $storeId = $event->getStoreId();
158
+
159
+ $this->helper->moveStoreSuggestionIndex($storeId);
160
+ }
161
+
162
  public function rebuildCategoryIndex(Varien_Object $event)
163
  {
164
  $storeId = $event->getStoreId();
app/code/community/Algolia/Algoliasearch/Model/Resource/Engine.php CHANGED
@@ -120,8 +120,11 @@ class Algolia_Algoliasearch_Model_Resource_Engine extends Mage_CatalogSearch_Mod
120
  $data = array('store_id' => $store->getId(), 'page_size' => $by_page, 'page' => $i);
121
  $this->addToQueue('algoliasearch/observer', 'rebuildSuggestionIndex', $data, $this->config->getQueueMaxRetries());
122
  }
 
 
123
  }
124
 
 
125
  return $this;
126
  }
127
 
120
  $data = array('store_id' => $store->getId(), 'page_size' => $by_page, 'page' => $i);
121
  $this->addToQueue('algoliasearch/observer', 'rebuildSuggestionIndex', $data, $this->config->getQueueMaxRetries());
122
  }
123
+
124
+ $this->addToQueue('algoliasearch/observer', 'moveStoreSuggestionIndex', array('store_id' => $store->getId()), $this->config->getQueueMaxRetries());
125
  }
126
 
127
+
128
  return $this;
129
  }
130
 
app/code/community/Algolia/Algoliasearch/etc/config.xml CHANGED
@@ -177,7 +177,7 @@
177
  <instant>
178
  <replace_categories>1</replace_categories>
179
  <instant_selector>.main</instant_selector>
180
- <facets>a:2:{s:18:"_1432907948596_596";a:4:{s:9:"attribute";s:14:"price_with_tax";s:4:"type";s:6:"slider";s:10:"other_type";s:0:"";s:5:"label";s:5:"Price";}s:18:"_1432907963376_376";a:4:{s:9:"attribute";s:10:"categories";s:4:"type";s:12:"hierarchical";s:10:"other_type";s:0:"";s:5:"label";s:10:"Categories";}}</facets>
181
  <sorts>a:3:{s:18:"_1432908018844_844";a:3:{s:9:"attribute";s:14:"price_with_tax";s:4:"sort";s:3:"asc";s:5:"label";s:12:"Lowest price";}s:18:"_1432908022539_539";a:3:{s:9:"attribute";s:14:"price_with_tax";s:4:"sort";s:4:"desc";s:5:"label";s:13:"Highest price";}s:18:"_1433768597454_454";a:3:{s:9:"attribute";s:10:"created_at";s:4:"sort";s:4:"desc";s:5:"label";s:12:"Newest first";}}</sorts>
182
  </instant>
183
  <autocomplete>
177
  <instant>
178
  <replace_categories>1</replace_categories>
179
  <instant_selector>.main</instant_selector>
180
+ <facets>a:2:{s:18:"_1432907948596_596";a:4:{s:9:"attribute";s:14:"price_with_tax";s:4:"type";s:6:"slider";s:10:"other_type";s:0:"";s:5:"label";s:5:"Price";}s:18:"_1432907963376_376";a:4:{s:9:"attribute";s:10:"categories";s:4:"type";s:11:"conjunctive";s:10:"other_type";s:0:"";s:5:"label";s:10:"Categories";}}</facets>
181
  <sorts>a:3:{s:18:"_1432908018844_844";a:3:{s:9:"attribute";s:14:"price_with_tax";s:4:"sort";s:3:"asc";s:5:"label";s:12:"Lowest price";}s:18:"_1432908022539_539";a:3:{s:9:"attribute";s:14:"price_with_tax";s:4:"sort";s:4:"desc";s:5:"label";s:13:"Highest price";}s:18:"_1433768597454_454";a:3:{s:9:"attribute";s:10:"created_at";s:4:"sort";s:4:"desc";s:5:"label";s:12:"Newest first";}}</sorts>
182
  </instant>
183
  <autocomplete>
app/code/community/Algolia/Algoliasearch/etc/system.xml CHANGED
@@ -4,7 +4,7 @@
4
  <algoliasearch translate="label" module="algoliasearch">
5
  <label>
6
  <![CDATA[
7
- Algolia Search
8
  <style>
9
  .algoliasearch-admin-menu span {
10
  padding-left: 38px !important;
4
  <algoliasearch translate="label" module="algoliasearch">
5
  <label>
6
  <![CDATA[
7
+ Algolia Search 1.4.1
8
  <style>
9
  .algoliasearch-admin-menu span {
10
  padding-left: 38px !important;
app/design/frontend/base/default/template/algoliasearch/topsearch.phtml CHANGED
@@ -11,14 +11,16 @@ $isSearchPage = false;;
11
  $hash_path = null;
12
 
13
  $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
14
-
15
- $suffix_index_name = '';
16
 
17
  if ($config->isCustomerGroupsEnabled(Mage::app()->getStore()->getStoreId()))
18
  {
19
- $suffix_index_name = '_group_' . $group_id;
20
  }
21
 
 
 
 
22
  /**
23
  * Handle category replacement
24
  */
@@ -26,10 +28,18 @@ if($config->isInstantEnabled() && $config->replaceCategories() && Mage::app()->g
26
  {
27
  $category = Mage::registry('current_category');
28
 
29
- if ($category)
30
  {
31
  $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId());
32
 
 
 
 
 
 
 
 
 
33
  $path = '';
34
 
35
  foreach ($category->getPathIds() as $treeCategoryId) {
@@ -40,7 +50,7 @@ if($config->isInstantEnabled() && $config->replaceCategories() && Mage::app()->g
40
  $path .= $product_helper->getCategoryName($treeCategoryId, Mage::app()->getStore()->getStoreId());
41
  }
42
 
43
- $indexName = $product_helper->getIndexName(Mage::app()->getStore()->getStoreId()).$suffix_index_name;
44
  $category_url = $category->getUrl($category);
45
  $hash_path = '#q=&page=0&refinements=%5B%7B%22categories%22%3A%5B%22'.$path.'%22%5D%7D%5D&numerics_refinements=%7B%7D&index_name=%22'.$indexName.'%22';
46
 
@@ -57,14 +67,14 @@ if ($config->isInstantEnabled())
57
 
58
  if ($pageIdentifier === 'catalogsearch_result_index')
59
  {
60
- $query = Mage::app()->getRequest()->getParam('q');
61
 
62
  if ($query == '__empty__')
63
  $query = '';
64
 
65
  $product_helper = Mage::helper('algoliasearch/entity_producthelper');
66
 
67
- $hash_path = '#q='.$query.'&page=0&refinements=%5B%5D&numerics_refinements=%7B%7D&index_name=%22'.$product_helper->getIndexName().$suffix_index_name.'%22';
68
 
69
  $refinement_key = Mage::app()->getRequest()->getParam('refinement_key');
70
  $refinement_value = Mage::app()->getRequest()->getParam('refinement_value');
@@ -159,18 +169,18 @@ $class = $isSearchPage ? 'search-page' : '';
159
  {{#thumbnail_url}}
160
  <div class="thumb"><img src="{{thumbnail_url}}" /></div>
161
  {{/thumbnail_url}}
162
- {{#price_with_tax}}
163
  <div class="algoliasearch-autocomplete-price">
164
- {{#special_price_with_tax}}
165
  <div class="after_special">
166
- {{special_price_with_tax_formated}}
167
  </div>
168
- {{/special_price_with_tax}}
169
- <div {{#special_price_with_tax}}class="before_special"{{/special_price_with_tax}}>
170
- {{price_with_tax_formated}}
171
  </div>
172
  </div>
173
- {{/price_with_tax}}
174
  <div class="info">
175
  {{{_highlightResult.name.value}}}
176
 
@@ -263,25 +273,33 @@ $class = $isSearchPage ? 'search-page' : '';
263
 
264
  <div class="row">
265
  <div class="col-md-offset-3 col-md-9">
266
- {{#second_bar}}
267
- <div id="instant-search-bar-container">
268
- <div id="instant-search-box">
269
- <label for="instant-search-bar">
270
- <?php echo $this->__('Search :'); ?>
271
- </label>
272
-
273
- <input value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" placeholder="<?php echo $this->__('Search for products'); ?>" id="instant-search-bar" type="text" autocomplete="off" spellcheck="false" autocorrect="off" autocapitalize="off" />
274
-
275
- <svg xmlns="http://www.w3.org/2000/svg" class="magnifying-glass" width="24" height="24" viewBox="0 0 128 128">
276
- <g transform="scale(4)">
277
- <path stroke-width="3" d="M19.5 19.582l9.438 9.438"></path>
278
- <circle stroke-width="3" cx="12" cy="12" r="10.5" fill="none"></circle>
279
- <path d="M23.646 20.354l-3.293 3.293c-.195.195-.195.512 0 .707l7.293 7.293c.195.195.512.195.707 0l3.293-3.293c.195-.195.195-.512 0-.707l-7.293-7.293c-.195-.195-.512-.195-.707 0z"></path>
280
- </g>
281
- </svg>
 
 
 
 
 
 
 
 
282
  </div>
 
283
  </div>
284
- {{/second_bar}}
285
  </div>
286
  </div>
287
 
@@ -349,28 +367,27 @@ $class = $isSearchPage ? 'search-page' : '';
349
  <div class="price">
350
  <div class="algoliasearch-autocomplete-price">
351
  <div>
352
- {{#special_price_with_tax}}
353
  <span class="after_special">
354
- {{special_price_with_tax_formated}}
355
  </span>
356
- {{/special_price_with_tax}}
357
 
358
- {{#special_price_with_tax}}
359
  <span class="before_special">
360
- {{/special_price_with_tax}}
361
 
362
- {{#price_with_tax}}{{price_with_tax_formated}}{{/price_with_tax}}
363
- {{^price_with_tax}}
364
- {{#min_with_tax_formated}}
365
- {{min_with_tax_formated}} - {{max_with_tax_formated}}
366
- {{/min_with_tax_formated}}
367
- {{^min_with_tax_formated}}-{{/min_with_tax_formated}}
368
- {{/price_with_tax}}
369
 
370
- {{#special_price_with_tax}}
371
  </span>
372
- {{/special_price_with_tax}}
373
-
374
 
375
  </div>
376
  </div>
@@ -412,7 +429,7 @@ $class = $isSearchPage ? 'search-page' : '';
412
  <script type="text/template" id="instant-facets-hierarchical-template">
413
  {{#data}}
414
  <div style="padding-left: 10px; padding-right: 0px;" class="hierarchical_facet">
415
- <div data-name="{{attribute}}" data-path="{{path}}" data-type="hierarchical" class="{{#isRefined}}checked {{/isRefined}}sub_facet hierarchical">
416
  <input style="display: none;" data-attribute="{{attribute}}" {{#isRefined}}checked{{/isRefined}} data-name="{{name}}" class="facet_value" type="checkbox" />
417
  {{name}}
418
  {{#count}}<span class="count">{{count}}</span>{{/count}}
@@ -557,7 +574,6 @@ $class = $isSearchPage ? 'search-page' : '';
557
  },
558
  applicationId: '<?php echo $config->getApplicationID() ?>',
559
  indexName: '<?php echo $product_helper->getBaseIndexName(); ?>',
560
- suffixIndexName: '<?php echo $suffix_index_name; ?>',
561
  apiKey: '<?php echo $config->getSearchOnlyAPIKey() ?>',
562
  facets: <?php echo json_encode($config->getFacets()); ?>,
563
  hitsPerPage: <?php echo (int) $config->getNumberOfProductResults() ?>,
@@ -643,20 +659,22 @@ $class = $isSearchPage ? 'search-page' : '';
643
  }
644
  }
645
 
646
- var helper = algoliaBundle.algoliasearchHelper(algolia_client, algoliaConfig.indexName + '_products' + algoliaConfig.suffixIndexName, {
647
  facets: conjunctive_facets,
648
  disjunctiveFacets: disjunctive_facets,
649
  hierarchicalFacets: hierarchical_facets,
650
- hitsPerPage: algoliaConfig.hitsPerPage
 
651
  });
652
 
653
  helper.setQuery('');
654
 
655
- var helper_empty = algoliaBundle.algoliasearchHelper(algolia_client, algoliaConfig.indexName + '_products' + algoliaConfig.suffixIndexName, {
656
  facets: conjunctive_facets,
657
  disjunctiveFacets: disjunctive_facets_empty,
658
  hierarchicalFacets: hierarchical_facets,
659
- hitsPerPage: algoliaConfig.hitsPerPage
 
660
  });
661
 
662
  helper_empty.setQuery('');
@@ -771,6 +789,8 @@ $class = $isSearchPage ? 'search-page' : '';
771
  var numericsRefinements = JSON.parse(decodeURIComponent(params.substring(numericsRefinementsParamOffset + '&numerics_refinements='.length, indexNameOffset)));
772
  var indexName = JSON.parse(decodeURIComponent(params.substring(indexNameOffset + '&index_name='.length)));
773
 
 
 
774
  helper.setQuery(q);
775
 
776
  helper.clearRefinements();
@@ -780,6 +800,7 @@ $class = $isSearchPage ? 'search-page' : '';
780
  for (var refine in refinements[i]) {
781
  for (var j = 0; j < refinements[i][refine].length; j++) {
782
  helper.toggleRefine(refine, refinements[i][refine][j]);
 
783
  }
784
  }
785
  }
@@ -1017,28 +1038,30 @@ $class = $isSearchPage ? 'search-page' : '';
1017
  var hogan_objs = [];
1018
 
1019
  var indices = ['categories', 'products', 'pages'];
1020
- var indices_with_suffix = ['categories', 'products' + algoliaConfig.suffixIndexName, 'pages'];
1021
 
1022
  if (algoliaConfig.autocomplete.hitsPerPage['suggestions'] > 0)
1023
  {
1024
  var suggestions_index = algolia_client.initIndex(algoliaConfig.indexName + "_suggestions");
1025
- var products_index = algolia_client.initIndex(algoliaConfig.indexName + "_products" + algoliaConfig.suffixIndexName);
1026
 
1027
  hogan_objs.push({
1028
  displayKey: 'query',
1029
  source: function (query, cb) {
1030
  suggestions_index.search(query, {
1031
- hitsPerPage: algoliaConfig.autocomplete.hitsPerPage['suggestions']
 
1032
  }, function (err, content) {
1033
  if (err)
1034
  return;
1035
 
1036
  if (content.hits.length > 0) {
1037
  products_index.search(content.hits[0].query, {
1038
- facets: ['categories'],
1039
  hitsPerPage: 0,
1040
  typoTolerance: false,
1041
- maxValuesPerFacet: 3
 
1042
  }, function (err2, content2) {
1043
 
1044
  if (err2)
@@ -1051,14 +1074,14 @@ $class = $isSearchPage ? 'search-page' : '';
1051
 
1052
  var categories = {};
1053
 
1054
- if (content2.facets.categories) {
1055
 
1056
  var obj = $.extend(true, {}, content.hits[0]);
1057
  obj.category = '<?php echo $this->__('All departments') ?>';
1058
  obj.url = '<?php echo $base_url; ?>/catalogsearch/result/?q=' + obj.query;
1059
  hits.push(obj);
1060
 
1061
- for (var key in content2.facets.categories) {
1062
 
1063
  var explode = key.split(' /// ');
1064
  var nameattr = explode[0];
@@ -1070,7 +1093,7 @@ $class = $isSearchPage ? 'search-page' : '';
1070
  {
1071
  var obj = $.extend(true, {}, content.hits[0]);
1072
  obj.category = key;
1073
- obj.url = '<?php echo $base_url; ?>?category=1#q=' + obj.query + '&page=0&refinements=%5B%7B%22categories%22%3A%5B%22' + obj.category + '%22%5D%7D%5D&numerics_refinements=%7B%7D&index_name=%22<?php echo $product_helper->getBaseIndexName(); ?>_products%22';
1074
  hits.push(obj);
1075
  }
1076
  }
@@ -1117,7 +1140,8 @@ $class = $isSearchPage ? 'search-page' : '';
1117
  source: (function (index, i) {
1118
  return function (query, cb) {
1119
  index.search(query, {
1120
- hitsPerPage: algoliaConfig.autocomplete.hitsPerPage[indices[i]]
 
1121
  }, function (err, content) {
1122
  if (err)
1123
  {
@@ -1191,7 +1215,8 @@ $class = $isSearchPage ? 'search-page' : '';
1191
  source: (function (index, i) {
1192
  return function (query, cb) {
1193
  index.search(query, {
1194
- hitsPerPage: algoliaConfig.autocomplete.additionnalSection[i].hitsPerPage
 
1195
  }, function (err, content) {
1196
  if (err)
1197
  {
@@ -1261,7 +1286,7 @@ $class = $isSearchPage ? 'search-page' : '';
1261
  if ($(algoliaConfig.instant.selector).length !== 1)
1262
  throw '[Algolia] Invalid instant-search selector: ' + algoliaConfig.instant.selector;
1263
 
1264
- if ($(algoliaConfig.instant.selector).find(algoliaConfig.autocomplete.selector).length > 0)
1265
  throw '[Algolia] You can\'t have a search input matching "' + algoliaConfig.autocomplete.selector +
1266
  '" inside you instant selector "' + algoliaConfig.instant.selector + '"';
1267
 
@@ -1464,7 +1489,10 @@ $class = $isSearchPage ? 'search-page' : '';
1464
  helper.state.clearRefinements($(this).attr("data-attribute"));
1465
 
1466
  if ($(this).attr("data-name") != "all")
 
1467
  helper.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
 
 
1468
  });
1469
 
1470
  performQueries(true);
@@ -1482,6 +1510,7 @@ $class = $isSearchPage ? 'search-page' : '';
1482
  }
1483
 
1484
  helper.toggleRefine($(this).attr("data-name"), $(this).attr('data-path'));
 
1485
 
1486
  performQueries(true);
1487
  });
@@ -1499,6 +1528,7 @@ $class = $isSearchPage ? 'search-page' : '';
1499
  $(this).prop("checked", !$(this).prop("checked"));
1500
 
1501
  helper.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
 
1502
  });
1503
 
1504
  performQueries(true);
11
  $hash_path = null;
12
 
13
  $group_id = Mage::getSingleton('customer/session')->getCustomerGroupId();
14
+ $price_key = '.default';
 
15
 
16
  if ($config->isCustomerGroupsEnabled(Mage::app()->getStore()->getStoreId()))
17
  {
18
+ $price_key = '.'.$group_id;
19
  }
20
 
21
+ $title = '';
22
+ $content = '';
23
+
24
  /**
25
  * Handle category replacement
26
  */
28
  {
29
  $category = Mage::registry('current_category');
30
 
31
+ if ($category && $category->getDisplayMode() !== 'PAGE')
32
  {
33
  $category->getUrlInstance()->setStore(Mage::app()->getStore()->getStoreId());
34
 
35
+ if ($category->getDisplayMode() == 'PRODUCTS_AND_PAGE')
36
+ {
37
+ $page = $category->getLandingPage();
38
+ $cms_block = Mage::getModel('cms/block')->load($page);
39
+ $title = $cms_block->getTitle();
40
+ $content = $cms_block->getContent();
41
+ }
42
+
43
  $path = '';
44
 
45
  foreach ($category->getPathIds() as $treeCategoryId) {
50
  $path .= $product_helper->getCategoryName($treeCategoryId, Mage::app()->getStore()->getStoreId());
51
  }
52
 
53
+ $indexName = $product_helper->getIndexName(Mage::app()->getStore()->getStoreId());
54
  $category_url = $category->getUrl($category);
55
  $hash_path = '#q=&page=0&refinements=%5B%7B%22categories%22%3A%5B%22'.$path.'%22%5D%7D%5D&numerics_refinements=%7B%7D&index_name=%22'.$indexName.'%22';
56
 
67
 
68
  if ($pageIdentifier === 'catalogsearch_result_index')
69
  {
70
+ $query = $catalogSearchHelper->getEscapedQueryText();
71
 
72
  if ($query == '__empty__')
73
  $query = '';
74
 
75
  $product_helper = Mage::helper('algoliasearch/entity_producthelper');
76
 
77
+ $hash_path = '#q='.htmlentities($query).'&page=0&refinements=%5B%5D&numerics_refinements=%7B%7D&index_name=%22'.$product_helper->getIndexName().'%22';
78
 
79
  $refinement_key = Mage::app()->getRequest()->getParam('refinement_key');
80
  $refinement_value = Mage::app()->getRequest()->getParam('refinement_value');
169
  {{#thumbnail_url}}
170
  <div class="thumb"><img src="{{thumbnail_url}}" /></div>
171
  {{/thumbnail_url}}
172
+ {{#price_with_tax<?php echo $price_key; ?>}}
173
  <div class="algoliasearch-autocomplete-price">
174
+ {{#special_price_with_tax<?php echo $price_key; ?>}}
175
  <div class="after_special">
176
+ {{special_price_with_tax_formated<?php echo $price_key; ?>}}
177
  </div>
178
+ {{/special_price_with_tax<?php echo $price_key; ?>}}
179
+ <div {{#special_price_with_tax<?php echo $price_key; ?>}}class="before_special"{{/special_price_with_tax<?php echo $price_key; ?>}}>
180
+ {{price_with_tax_formated<?php echo $price_key; ?>}}
181
  </div>
182
  </div>
183
+ {{/price_with_tax<?php echo $price_key; ?>}}
184
  <div class="info">
185
  {{{_highlightResult.name.value}}}
186
 
273
 
274
  <div class="row">
275
  <div class="col-md-offset-3 col-md-9">
276
+ <div id="algolia-static-content">
277
+ <div class="page-title category-title">
278
+ <h1><?php echo $title; ?></h1>
279
+ </div>
280
+ <?php echo $content; ?>
281
+ </div>
282
+ <div>
283
+ {{#second_bar}}
284
+ <div id="instant-search-bar-container">
285
+ <div id="instant-search-box">
286
+ <label for="instant-search-bar">
287
+ <?php echo $this->__('Search :'); ?>
288
+ </label>
289
+
290
+ <input value="<?php echo $catalogSearchHelper->getEscapedQueryText() ?>" placeholder="<?php echo $this->__('Search for products'); ?>" id="instant-search-bar" type="text" autocomplete="off" spellcheck="false" autocorrect="off" autocapitalize="off" />
291
+
292
+ <svg xmlns="http://www.w3.org/2000/svg" class="magnifying-glass" width="24" height="24" viewBox="0 0 128 128">
293
+ <g transform="scale(4)">
294
+ <path stroke-width="3" d="M19.5 19.582l9.438 9.438"></path>
295
+ <circle stroke-width="3" cx="12" cy="12" r="10.5" fill="none"></circle>
296
+ <path d="M23.646 20.354l-3.293 3.293c-.195.195-.195.512 0 .707l7.293 7.293c.195.195.512.195.707 0l3.293-3.293c.195-.195.195-.512 0-.707l-7.293-7.293c-.195-.195-.512-.195-.707 0z"></path>
297
+ </g>
298
+ </svg>
299
+ </div>
300
  </div>
301
+ {{/second_bar}}
302
  </div>
 
303
  </div>
304
  </div>
305
 
367
  <div class="price">
368
  <div class="algoliasearch-autocomplete-price">
369
  <div>
370
+ {{#special_price_with_tax<?php echo $price_key; ?>}}
371
  <span class="after_special">
372
+ {{special_price_with_tax_formated<?php echo $price_key; ?>}}
373
  </span>
374
+ {{/special_price_with_tax<?php echo $price_key; ?>}}
375
 
376
+ {{#special_price_with_tax<?php echo $price_key; ?>}}
377
  <span class="before_special">
378
+ {{/special_price_with_tax<?php echo $price_key; ?>}}
379
 
380
+ {{#price_with_tax<?php echo $price_key; ?>}}{{price_with_tax_formated<?php echo $price_key; ?>}}{{/price_with_tax<?php echo $price_key; ?>}}
381
+ {{^price_with_tax<?php echo $price_key; ?>}}
382
+ {{#min_with_tax_formated<?php echo $price_key; ?>}}
383
+ {{min_with_tax_formated<?php echo $price_key; ?>}} - {{max_with_tax_formated<?php echo $price_key; ?>}}
384
+ {{/min_with_tax_formated<?php echo $price_key; ?>}}
385
+ {{^min_with_tax_formated<?php echo $price_key; ?>}}-{{/min_with_tax_formated<?php echo $price_key; ?>}}
386
+ {{/price_with_tax<?php echo $price_key; ?>}}
387
 
388
+ {{#special_price_with_tax<?php echo $price_key; ?>}}
389
  </span>
390
+ {{/special_price_with_tax<?php echo $price_key; ?>}}
 
391
 
392
  </div>
393
  </div>
429
  <script type="text/template" id="instant-facets-hierarchical-template">
430
  {{#data}}
431
  <div style="padding-left: 10px; padding-right: 0px;" class="hierarchical_facet">
432
+ <div data-name="{{attribute}}" data-path="{{path}}" data-type="hierarchical" class="{{#isRefined}}checked {{/isRefined}}sub_facet hierarchical {{#empty}}empty{{/empty}}">
433
  <input style="display: none;" data-attribute="{{attribute}}" {{#isRefined}}checked{{/isRefined}} data-name="{{name}}" class="facet_value" type="checkbox" />
434
  {{name}}
435
  {{#count}}<span class="count">{{count}}</span>{{/count}}
574
  },
575
  applicationId: '<?php echo $config->getApplicationID() ?>',
576
  indexName: '<?php echo $product_helper->getBaseIndexName(); ?>',
 
577
  apiKey: '<?php echo $config->getSearchOnlyAPIKey() ?>',
578
  facets: <?php echo json_encode($config->getFacets()); ?>,
579
  hitsPerPage: <?php echo (int) $config->getNumberOfProductResults() ?>,
659
  }
660
  }
661
 
662
+ var helper = algoliaBundle.algoliasearchHelper(algolia_client, algoliaConfig.indexName + '_products', {
663
  facets: conjunctive_facets,
664
  disjunctiveFacets: disjunctive_facets,
665
  hierarchicalFacets: hierarchical_facets,
666
+ hitsPerPage: algoliaConfig.hitsPerPage,
667
+ analyticsTags: 'instant-search'
668
  });
669
 
670
  helper.setQuery('');
671
 
672
+ var helper_empty = algoliaBundle.algoliasearchHelper(algolia_client, algoliaConfig.indexName + '_products', {
673
  facets: conjunctive_facets,
674
  disjunctiveFacets: disjunctive_facets_empty,
675
  hierarchicalFacets: hierarchical_facets,
676
+ hitsPerPage: algoliaConfig.hitsPerPage,
677
+ analyticsTags: 'instant-search'
678
  });
679
 
680
  helper_empty.setQuery('');
789
  var numericsRefinements = JSON.parse(decodeURIComponent(params.substring(numericsRefinementsParamOffset + '&numerics_refinements='.length, indexNameOffset)));
790
  var indexName = JSON.parse(decodeURIComponent(params.substring(indexNameOffset + '&index_name='.length)));
791
 
792
+ q = $("<div/>").html(q).text();
793
+
794
  helper.setQuery(q);
795
 
796
  helper.clearRefinements();
800
  for (var refine in refinements[i]) {
801
  for (var j = 0; j < refinements[i][refine].length; j++) {
802
  helper.toggleRefine(refine, refinements[i][refine][j]);
803
+ helper_empty.toggleRefine(refine, refinements[i][refine][j]);
804
  }
805
  }
806
  }
1038
  var hogan_objs = [];
1039
 
1040
  var indices = ['categories', 'products', 'pages'];
1041
+ var indices_with_suffix = ['categories', 'products', 'pages'];
1042
 
1043
  if (algoliaConfig.autocomplete.hitsPerPage['suggestions'] > 0)
1044
  {
1045
  var suggestions_index = algolia_client.initIndex(algoliaConfig.indexName + "_suggestions");
1046
+ var products_index = algolia_client.initIndex(algoliaConfig.indexName + "_products");
1047
 
1048
  hogan_objs.push({
1049
  displayKey: 'query',
1050
  source: function (query, cb) {
1051
  suggestions_index.search(query, {
1052
+ hitsPerPage: algoliaConfig.autocomplete.hitsPerPage['suggestions'],
1053
+ analyticsTags: 'autocomplete'
1054
  }, function (err, content) {
1055
  if (err)
1056
  return;
1057
 
1058
  if (content.hits.length > 0) {
1059
  products_index.search(content.hits[0].query, {
1060
+ facets: ['categories.level0'],
1061
  hitsPerPage: 0,
1062
  typoTolerance: false,
1063
+ maxValuesPerFacet: 3,
1064
+ analyticsTags: 'instant-search'
1065
  }, function (err2, content2) {
1066
 
1067
  if (err2)
1074
 
1075
  var categories = {};
1076
 
1077
+ if (content2.facets['categories.level0']) {
1078
 
1079
  var obj = $.extend(true, {}, content.hits[0]);
1080
  obj.category = '<?php echo $this->__('All departments') ?>';
1081
  obj.url = '<?php echo $base_url; ?>/catalogsearch/result/?q=' + obj.query;
1082
  hits.push(obj);
1083
 
1084
+ for (var key in content2.facets['categories.level0']) {
1085
 
1086
  var explode = key.split(' /// ');
1087
  var nameattr = explode[0];
1093
  {
1094
  var obj = $.extend(true, {}, content.hits[0]);
1095
  obj.category = key;
1096
+ obj.url = '<?php echo $base_url; ?>/catalogsearch/result/?q=' + obj.query + '#q=' + obj.query + '&page=0&refinements=%5B%7B%22categories%22%3A%5B%22' + obj.category + '%22%5D%7D%5D&numerics_refinements=%7B%7D&index_name=%22<?php echo $product_helper->getBaseIndexName(); ?>_products%22';
1097
  hits.push(obj);
1098
  }
1099
  }
1140
  source: (function (index, i) {
1141
  return function (query, cb) {
1142
  index.search(query, {
1143
+ hitsPerPage: algoliaConfig.autocomplete.hitsPerPage[indices[i]],
1144
+ analyticsTags: 'autocomplete'
1145
  }, function (err, content) {
1146
  if (err)
1147
  {
1215
  source: (function (index, i) {
1216
  return function (query, cb) {
1217
  index.search(query, {
1218
+ hitsPerPage: algoliaConfig.autocomplete.additionnalSection[i].hitsPerPage,
1219
+ analyticsTags: 'autocomplete'
1220
  }, function (err, content) {
1221
  if (err)
1222
  {
1286
  if ($(algoliaConfig.instant.selector).length !== 1)
1287
  throw '[Algolia] Invalid instant-search selector: ' + algoliaConfig.instant.selector;
1288
 
1289
+ if (algoliaConfig.autocomplete.enabled && $(algoliaConfig.instant.selector).find(algoliaConfig.autocomplete.selector).length > 0)
1290
  throw '[Algolia] You can\'t have a search input matching "' + algoliaConfig.autocomplete.selector +
1291
  '" inside you instant selector "' + algoliaConfig.instant.selector + '"';
1292
 
1489
  helper.state.clearRefinements($(this).attr("data-attribute"));
1490
 
1491
  if ($(this).attr("data-name") != "all")
1492
+ {
1493
  helper.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
1494
+ helper_empty.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
1495
+ }
1496
  });
1497
 
1498
  performQueries(true);
1510
  }
1511
 
1512
  helper.toggleRefine($(this).attr("data-name"), $(this).attr('data-path'));
1513
+ helper_empty.toggleRefine($(this).attr("data-name"), $(this).attr('data-path'));
1514
 
1515
  performQueries(true);
1516
  });
1528
  $(this).prop("checked", !$(this).prop("checked"));
1529
 
1530
  helper.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
1531
+ helper_empty.toggleRefine($(this).attr("data-attribute"), $(this).attr("data-name"));
1532
  });
1533
 
1534
  performQueries(true);
js/algoliasearch/bundle.min.js CHANGED
@@ -1,31409 +1,21 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.algoliaBundle = f()}})(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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- module.exports = {
3
- $: require('jquery'),
4
- Hogan: require('hogan.js'),
5
- algoliasearch: require('algoliasearch'),
6
- algoliasearchHelper: require('algoliasearch-helper')
7
- };
8
 
9
- require('jquery-ui/slider');
10
- require('jquery-ui/sortable');
11
- require('jquery-ui/draggable');
12
- require('jquery-ui/mouse');
13
 
14
- // Some jQuery plugins are not commonJS compatible and thus
15
- // we cannot easily tell them to use our own jQuery instead of the global jQuery
16
- // To solve this, we do a little trick.
17
- var oldJQuery = window.jQuery;
18
- window.jQuery = module.exports.$;
19
- require('jquery-ui-touch-punch');
20
- require('typeahead.js');
21
- window.jQuery = oldJQuery;
22
 
23
- },{"algoliasearch":213,"algoliasearch-helper":2,"hogan.js":228,"jquery":237,"jquery-ui-touch-punch":230,"jquery-ui/draggable":232,"jquery-ui/mouse":233,"jquery-ui/slider":234,"jquery-ui/sortable":235,"typeahead.js":238}],2:[function(require,module,exports){
24
- 'use strict';
25
 
26
- var AlgoliaSearchHelper = require('./src/algoliasearch.helper');
 
27
 
28
- var SearchParameters = require('./src/SearchParameters');
29
- var SearchResults = require('./src/SearchResults');
30
-
31
- /**
32
- * The algoliasearchHelper module contains everything needed to use the Algoliasearch
33
- * Helper. It is a also a function that instanciate the helper.
34
- * To use the helper, you also need the Algolia JS client v3.
35
- * @example
36
- * //using the UMD build
37
- * var client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
38
- * var helper = algoliasearchHelper(client, 'bestbuy', {
39
- * facets: ['shipping'],
40
- * disjunctiveFacets: ['category']
41
- * });
42
- * helper.on('result', function(result) {
43
- * console.log(result);
44
- * });
45
- * helper.toggleRefine('Movies & TV Shows')
46
- * .toggleRefine('Free shipping')
47
- * .search();
48
- * @module algoliasearchHelper
49
- * @param {AlgoliaSearch} client an AlgoliaSearch client
50
- * @param {string} index the index name to query
51
- * @param {SearchParameters|object} opts an object defining the initial config of the search. It doesn't have to be a {SearchParameters}, just an object containing the properties you need from it.
52
- * @return {AlgoliaSearchHelper}
53
- */
54
- function algoliasearchHelper(client, index, opts) {
55
- return new AlgoliaSearchHelper(client, index, opts);
56
- }
57
-
58
- /**
59
- * The version currently used
60
- * @member module:algoliasearchHelper.version
61
- * @type {number}
62
- */
63
- algoliasearchHelper.version = '2.1.2';
64
-
65
- /**
66
- * Constructor for the Helper.
67
- * @member module:algoliasearchHelper.AlgoliaSearchHelper
68
- * @type {AlgoliaSearchHelper}
69
- */
70
- algoliasearchHelper.AlgoliaSearchHelper = AlgoliaSearchHelper;
71
-
72
- /**
73
- * Constructor for the object containing all the parameters of the search.
74
- * @member module:algoliasearchHelper.SearchParameters
75
- * @type {SearchParameters}
76
- */
77
- algoliasearchHelper.SearchParameters = SearchParameters;
78
-
79
- /**
80
- * Constructor for the object containing the results of the search.
81
- * @member module:algoliasearchHelper.SearchResults
82
- * @type {SearchResults}
83
- */
84
- algoliasearchHelper.SearchResults = SearchResults;
85
-
86
- module.exports = algoliasearchHelper;
87
-
88
- },{"./src/SearchParameters":152,"./src/SearchResults":154,"./src/algoliasearch.helper":155}],3:[function(require,module,exports){
89
- /**
90
- * Creates an array with all falsey values removed. The values `false`, `null`,
91
- * `0`, `""`, `undefined`, and `NaN` are falsey.
92
- *
93
- * @static
94
- * @memberOf _
95
- * @category Array
96
- * @param {Array} array The array to compact.
97
- * @returns {Array} Returns the new array of filtered values.
98
- * @example
99
- *
100
- * _.compact([0, 1, false, 2, '', 3]);
101
- * // => [1, 2, 3]
102
- */
103
- function compact(array) {
104
- var index = -1,
105
- length = array ? array.length : 0,
106
- resIndex = -1,
107
- result = [];
108
-
109
- while (++index < length) {
110
- var value = array[index];
111
- if (value) {
112
- result[++resIndex] = value;
113
- }
114
- }
115
- return result;
116
- }
117
-
118
- module.exports = compact;
119
-
120
- },{}],4:[function(require,module,exports){
121
- var createFindIndex = require('../internal/createFindIndex');
122
-
123
- /**
124
- * This method is like `_.find` except that it returns the index of the first
125
- * element `predicate` returns truthy for instead of the element itself.
126
- *
127
- * If a property name is provided for `predicate` the created `_.property`
128
- * style callback returns the property value of the given element.
129
- *
130
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
131
- * style callback returns `true` for elements that have a matching property
132
- * value, else `false`.
133
- *
134
- * If an object is provided for `predicate` the created `_.matches` style
135
- * callback returns `true` for elements that have the properties of the given
136
- * object, else `false`.
137
- *
138
- * @static
139
- * @memberOf _
140
- * @category Array
141
- * @param {Array} array The array to search.
142
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
143
- * per iteration.
144
- * @param {*} [thisArg] The `this` binding of `predicate`.
145
- * @returns {number} Returns the index of the found element, else `-1`.
146
- * @example
147
- *
148
- * var users = [
149
- * { 'user': 'barney', 'active': false },
150
- * { 'user': 'fred', 'active': false },
151
- * { 'user': 'pebbles', 'active': true }
152
- * ];
153
- *
154
- * _.findIndex(users, function(chr) {
155
- * return chr.user == 'barney';
156
- * });
157
- * // => 0
158
- *
159
- * // using the `_.matches` callback shorthand
160
- * _.findIndex(users, { 'user': 'fred', 'active': false });
161
- * // => 1
162
- *
163
- * // using the `_.matchesProperty` callback shorthand
164
- * _.findIndex(users, 'active', false);
165
- * // => 0
166
- *
167
- * // using the `_.property` callback shorthand
168
- * _.findIndex(users, 'active');
169
- * // => 2
170
- */
171
- var findIndex = createFindIndex();
172
-
173
- module.exports = findIndex;
174
-
175
- },{"../internal/createFindIndex":87}],5:[function(require,module,exports){
176
- var baseIndexOf = require('../internal/baseIndexOf'),
177
- binaryIndex = require('../internal/binaryIndex');
178
-
179
- /* Native method references for those with the same name as other `lodash` methods. */
180
- var nativeMax = Math.max;
181
-
182
- /**
183
- * Gets the index at which the first occurrence of `value` is found in `array`
184
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
185
- * for equality comparisons. If `fromIndex` is negative, it is used as the offset
186
- * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
187
- * performs a faster binary search.
188
- *
189
- * @static
190
- * @memberOf _
191
- * @category Array
192
- * @param {Array} array The array to search.
193
- * @param {*} value The value to search for.
194
- * @param {boolean|number} [fromIndex=0] The index to search from or `true`
195
- * to perform a binary search on a sorted array.
196
- * @returns {number} Returns the index of the matched value, else `-1`.
197
- * @example
198
- *
199
- * _.indexOf([1, 2, 1, 2], 2);
200
- * // => 1
201
- *
202
- * // using `fromIndex`
203
- * _.indexOf([1, 2, 1, 2], 2, 2);
204
- * // => 3
205
- *
206
- * // performing a binary search
207
- * _.indexOf([1, 1, 2, 2], 2, true);
208
- * // => 2
209
- */
210
- function indexOf(array, value, fromIndex) {
211
- var length = array ? array.length : 0;
212
- if (!length) {
213
- return -1;
214
- }
215
- if (typeof fromIndex == 'number') {
216
- fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
217
- } else if (fromIndex) {
218
- var index = binaryIndex(array, value);
219
- if (index < length &&
220
- (value === value ? (value === array[index]) : (array[index] !== array[index]))) {
221
- return index;
222
- }
223
- return -1;
224
- }
225
- return baseIndexOf(array, value, fromIndex || 0);
226
- }
227
-
228
- module.exports = indexOf;
229
-
230
- },{"../internal/baseIndexOf":49,"../internal/binaryIndex":69}],6:[function(require,module,exports){
231
- var baseIndexOf = require('../internal/baseIndexOf'),
232
- cacheIndexOf = require('../internal/cacheIndexOf'),
233
- createCache = require('../internal/createCache'),
234
- isArrayLike = require('../internal/isArrayLike'),
235
- restParam = require('../function/restParam');
236
-
237
- /**
238
- * Creates an array of unique values that are included in all of the provided
239
- * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
240
- * for equality comparisons.
241
- *
242
- * @static
243
- * @memberOf _
244
- * @category Array
245
- * @param {...Array} [arrays] The arrays to inspect.
246
- * @returns {Array} Returns the new array of shared values.
247
- * @example
248
- * _.intersection([1, 2], [4, 2], [2, 1]);
249
- * // => [2]
250
- */
251
- var intersection = restParam(function(arrays) {
252
- var othLength = arrays.length,
253
- othIndex = othLength,
254
- caches = Array(length),
255
- indexOf = baseIndexOf,
256
- isCommon = true,
257
- result = [];
258
-
259
- while (othIndex--) {
260
- var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
261
- caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
262
- }
263
- var array = arrays[0],
264
- index = -1,
265
- length = array ? array.length : 0,
266
- seen = caches[0];
267
-
268
- outer:
269
- while (++index < length) {
270
- value = array[index];
271
- if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
272
- var othIndex = othLength;
273
- while (--othIndex) {
274
- var cache = caches[othIndex];
275
- if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
276
- continue outer;
277
- }
278
- }
279
- if (seen) {
280
- seen.push(value);
281
- }
282
- result.push(value);
283
- }
284
- }
285
- return result;
286
- });
287
-
288
- module.exports = intersection;
289
-
290
- },{"../function/restParam":20,"../internal/baseIndexOf":49,"../internal/cacheIndexOf":72,"../internal/createCache":83,"../internal/isArrayLike":102}],7:[function(require,module,exports){
291
- /**
292
- * Gets the last element of `array`.
293
- *
294
- * @static
295
- * @memberOf _
296
- * @category Array
297
- * @param {Array} array The array to query.
298
- * @returns {*} Returns the last element of `array`.
299
- * @example
300
- *
301
- * _.last([1, 2, 3]);
302
- * // => 3
303
- */
304
- function last(array) {
305
- var length = array ? array.length : 0;
306
- return length ? array[length - 1] : undefined;
307
- }
308
-
309
- module.exports = last;
310
-
311
- },{}],8:[function(require,module,exports){
312
- var LazyWrapper = require('../internal/LazyWrapper'),
313
- LodashWrapper = require('../internal/LodashWrapper'),
314
- baseLodash = require('../internal/baseLodash'),
315
- isArray = require('../lang/isArray'),
316
- isObjectLike = require('../internal/isObjectLike'),
317
- wrapperClone = require('../internal/wrapperClone');
318
-
319
- /** Used for native method references. */
320
- var objectProto = Object.prototype;
321
-
322
- /** Used to check objects for own properties. */
323
- var hasOwnProperty = objectProto.hasOwnProperty;
324
-
325
- /**
326
- * Creates a `lodash` object which wraps `value` to enable implicit chaining.
327
- * Methods that operate on and return arrays, collections, and functions can
328
- * be chained together. Methods that retrieve a single value or may return a
329
- * primitive value will automatically end the chain returning the unwrapped
330
- * value. Explicit chaining may be enabled using `_.chain`. The execution of
331
- * chained methods is lazy, that is, execution is deferred until `_#value`
332
- * is implicitly or explicitly called.
333
- *
334
- * Lazy evaluation allows several methods to support shortcut fusion. Shortcut
335
- * fusion is an optimization strategy which merge iteratee calls; this can help
336
- * to avoid the creation of intermediate data structures and greatly reduce the
337
- * number of iteratee executions.
338
- *
339
- * Chaining is supported in custom builds as long as the `_#value` method is
340
- * directly or indirectly included in the build.
341
- *
342
- * In addition to lodash methods, wrappers have `Array` and `String` methods.
343
- *
344
- * The wrapper `Array` methods are:
345
- * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
346
- * `splice`, and `unshift`
347
- *
348
- * The wrapper `String` methods are:
349
- * `replace` and `split`
350
- *
351
- * The wrapper methods that support shortcut fusion are:
352
- * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
353
- * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
354
- * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
355
- * and `where`
356
- *
357
- * The chainable wrapper methods are:
358
- * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
359
- * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
360
- * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`,
361
- * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`,
362
- * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`,
363
- * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
364
- * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
365
- * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`,
366
- * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`,
367
- * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
368
- * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
369
- * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`,
370
- * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`,
371
- * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`,
372
- * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,
373
- * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`,
374
- * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
375
- *
376
- * The wrapper methods that are **not** chainable by default are:
377
- * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`,
378
- * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,
379
- * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`,
380
- * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`,
381
- * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
382
- * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`,
383
- * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,
384
- * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`,
385
- * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`,
386
- * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`,
387
- * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`,
388
- * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`,
389
- * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
390
- * `unescape`, `uniqueId`, `value`, and `words`
391
- *
392
- * The wrapper method `sample` will return a wrapped value when `n` is provided,
393
- * otherwise an unwrapped value is returned.
394
- *
395
- * @name _
396
- * @constructor
397
- * @category Chain
398
- * @param {*} value The value to wrap in a `lodash` instance.
399
- * @returns {Object} Returns the new `lodash` wrapper instance.
400
- * @example
401
- *
402
- * var wrapped = _([1, 2, 3]);
403
- *
404
- * // returns an unwrapped value
405
- * wrapped.reduce(function(total, n) {
406
- * return total + n;
407
- * });
408
- * // => 6
409
- *
410
- * // returns a wrapped value
411
- * var squares = wrapped.map(function(n) {
412
- * return n * n;
413
- * });
414
- *
415
- * _.isArray(squares);
416
- * // => false
417
- *
418
- * _.isArray(squares.value());
419
- * // => true
420
- */
421
- function lodash(value) {
422
- if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
423
- if (value instanceof LodashWrapper) {
424
- return value;
425
- }
426
- if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
427
- return wrapperClone(value);
428
- }
429
- }
430
- return new LodashWrapper(value);
431
- }
432
-
433
- // Ensure wrappers are instances of `baseLodash`.
434
- lodash.prototype = baseLodash.prototype;
435
-
436
- module.exports = lodash;
437
-
438
- },{"../internal/LazyWrapper":21,"../internal/LodashWrapper":22,"../internal/baseLodash":53,"../internal/isObjectLike":108,"../internal/wrapperClone":125,"../lang/isArray":127}],9:[function(require,module,exports){
439
- var arrayFilter = require('../internal/arrayFilter'),
440
- baseCallback = require('../internal/baseCallback'),
441
- baseFilter = require('../internal/baseFilter'),
442
- isArray = require('../lang/isArray');
443
-
444
- /**
445
- * Iterates over elements of `collection`, returning an array of all elements
446
- * `predicate` returns truthy for. The predicate is bound to `thisArg` and
447
- * invoked with three arguments: (value, index|key, collection).
448
- *
449
- * If a property name is provided for `predicate` the created `_.property`
450
- * style callback returns the property value of the given element.
451
- *
452
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
453
- * style callback returns `true` for elements that have a matching property
454
- * value, else `false`.
455
- *
456
- * If an object is provided for `predicate` the created `_.matches` style
457
- * callback returns `true` for elements that have the properties of the given
458
- * object, else `false`.
459
- *
460
- * @static
461
- * @memberOf _
462
- * @alias select
463
- * @category Collection
464
- * @param {Array|Object|string} collection The collection to iterate over.
465
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
466
- * per iteration.
467
- * @param {*} [thisArg] The `this` binding of `predicate`.
468
- * @returns {Array} Returns the new filtered array.
469
- * @example
470
- *
471
- * _.filter([4, 5, 6], function(n) {
472
- * return n % 2 == 0;
473
- * });
474
- * // => [4, 6]
475
- *
476
- * var users = [
477
- * { 'user': 'barney', 'age': 36, 'active': true },
478
- * { 'user': 'fred', 'age': 40, 'active': false }
479
- * ];
480
- *
481
- * // using the `_.matches` callback shorthand
482
- * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
483
- * // => ['barney']
484
- *
485
- * // using the `_.matchesProperty` callback shorthand
486
- * _.pluck(_.filter(users, 'active', false), 'user');
487
- * // => ['fred']
488
- *
489
- * // using the `_.property` callback shorthand
490
- * _.pluck(_.filter(users, 'active'), 'user');
491
- * // => ['barney']
492
- */
493
- function filter(collection, predicate, thisArg) {
494
- var func = isArray(collection) ? arrayFilter : baseFilter;
495
- predicate = baseCallback(predicate, thisArg, 3);
496
- return func(collection, predicate);
497
- }
498
-
499
- module.exports = filter;
500
-
501
- },{"../internal/arrayFilter":26,"../internal/baseCallback":35,"../internal/baseFilter":41,"../lang/isArray":127}],10:[function(require,module,exports){
502
- var baseEach = require('../internal/baseEach'),
503
- createFind = require('../internal/createFind');
504
-
505
- /**
506
- * Iterates over elements of `collection`, returning the first element
507
- * `predicate` returns truthy for. The predicate is bound to `thisArg` and
508
- * invoked with three arguments: (value, index|key, collection).
509
- *
510
- * If a property name is provided for `predicate` the created `_.property`
511
- * style callback returns the property value of the given element.
512
- *
513
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
514
- * style callback returns `true` for elements that have a matching property
515
- * value, else `false`.
516
- *
517
- * If an object is provided for `predicate` the created `_.matches` style
518
- * callback returns `true` for elements that have the properties of the given
519
- * object, else `false`.
520
- *
521
- * @static
522
- * @memberOf _
523
- * @alias detect
524
- * @category Collection
525
- * @param {Array|Object|string} collection The collection to search.
526
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
527
- * per iteration.
528
- * @param {*} [thisArg] The `this` binding of `predicate`.
529
- * @returns {*} Returns the matched element, else `undefined`.
530
- * @example
531
- *
532
- * var users = [
533
- * { 'user': 'barney', 'age': 36, 'active': true },
534
- * { 'user': 'fred', 'age': 40, 'active': false },
535
- * { 'user': 'pebbles', 'age': 1, 'active': true }
536
- * ];
537
- *
538
- * _.result(_.find(users, function(chr) {
539
- * return chr.age < 40;
540
- * }), 'user');
541
- * // => 'barney'
542
- *
543
- * // using the `_.matches` callback shorthand
544
- * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
545
- * // => 'pebbles'
546
- *
547
- * // using the `_.matchesProperty` callback shorthand
548
- * _.result(_.find(users, 'active', false), 'user');
549
- * // => 'fred'
550
- *
551
- * // using the `_.property` callback shorthand
552
- * _.result(_.find(users, 'active'), 'user');
553
- * // => 'barney'
554
- */
555
- var find = createFind(baseEach);
556
-
557
- module.exports = find;
558
-
559
- },{"../internal/baseEach":40,"../internal/createFind":86}],11:[function(require,module,exports){
560
- var arrayEach = require('../internal/arrayEach'),
561
- baseEach = require('../internal/baseEach'),
562
- createForEach = require('../internal/createForEach');
563
-
564
- /**
565
- * Iterates over elements of `collection` invoking `iteratee` for each element.
566
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
567
- * (value, index|key, collection). Iteratee functions may exit iteration early
568
- * by explicitly returning `false`.
569
- *
570
- * **Note:** As with other "Collections" methods, objects with a "length" property
571
- * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
572
- * may be used for object iteration.
573
- *
574
- * @static
575
- * @memberOf _
576
- * @alias each
577
- * @category Collection
578
- * @param {Array|Object|string} collection The collection to iterate over.
579
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
580
- * @param {*} [thisArg] The `this` binding of `iteratee`.
581
- * @returns {Array|Object|string} Returns `collection`.
582
- * @example
583
- *
584
- * _([1, 2]).forEach(function(n) {
585
- * console.log(n);
586
- * }).value();
587
- * // => logs each value from left to right and returns the array
588
- *
589
- * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
590
- * console.log(n, key);
591
- * });
592
- * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
593
- */
594
- var forEach = createForEach(arrayEach, baseEach);
595
-
596
- module.exports = forEach;
597
-
598
- },{"../internal/arrayEach":25,"../internal/baseEach":40,"../internal/createForEach":88}],12:[function(require,module,exports){
599
- var baseIndexOf = require('../internal/baseIndexOf'),
600
- getLength = require('../internal/getLength'),
601
- isArray = require('../lang/isArray'),
602
- isIterateeCall = require('../internal/isIterateeCall'),
603
- isLength = require('../internal/isLength'),
604
- isString = require('../lang/isString'),
605
- values = require('../object/values');
606
-
607
- /* Native method references for those with the same name as other `lodash` methods. */
608
- var nativeMax = Math.max;
609
-
610
- /**
611
- * Checks if `value` is in `collection` using
612
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
613
- * for equality comparisons. If `fromIndex` is negative, it is used as the offset
614
- * from the end of `collection`.
615
- *
616
- * @static
617
- * @memberOf _
618
- * @alias contains, include
619
- * @category Collection
620
- * @param {Array|Object|string} collection The collection to search.
621
- * @param {*} target The value to search for.
622
- * @param {number} [fromIndex=0] The index to search from.
623
- * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
624
- * @returns {boolean} Returns `true` if a matching element is found, else `false`.
625
- * @example
626
- *
627
- * _.includes([1, 2, 3], 1);
628
- * // => true
629
- *
630
- * _.includes([1, 2, 3], 1, 2);
631
- * // => false
632
- *
633
- * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
634
- * // => true
635
- *
636
- * _.includes('pebbles', 'eb');
637
- * // => true
638
- */
639
- function includes(collection, target, fromIndex, guard) {
640
- var length = collection ? getLength(collection) : 0;
641
- if (!isLength(length)) {
642
- collection = values(collection);
643
- length = collection.length;
644
- }
645
- if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
646
- fromIndex = 0;
647
- } else {
648
- fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
649
- }
650
- return (typeof collection == 'string' || !isArray(collection) && isString(collection))
651
- ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
652
- : (!!length && baseIndexOf(collection, target, fromIndex) > -1);
653
- }
654
-
655
- module.exports = includes;
656
-
657
- },{"../internal/baseIndexOf":49,"../internal/getLength":98,"../internal/isIterateeCall":104,"../internal/isLength":107,"../lang/isArray":127,"../lang/isString":133,"../object/values":146}],13:[function(require,module,exports){
658
- var arrayMap = require('../internal/arrayMap'),
659
- baseCallback = require('../internal/baseCallback'),
660
- baseMap = require('../internal/baseMap'),
661
- isArray = require('../lang/isArray');
662
-
663
- /**
664
- * Creates an array of values by running each element in `collection` through
665
- * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
666
- * arguments: (value, index|key, collection).
667
- *
668
- * If a property name is provided for `iteratee` the created `_.property`
669
- * style callback returns the property value of the given element.
670
- *
671
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
672
- * style callback returns `true` for elements that have a matching property
673
- * value, else `false`.
674
- *
675
- * If an object is provided for `iteratee` the created `_.matches` style
676
- * callback returns `true` for elements that have the properties of the given
677
- * object, else `false`.
678
- *
679
- * Many lodash methods are guarded to work as iteratees for methods like
680
- * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
681
- *
682
- * The guarded methods are:
683
- * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
684
- * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
685
- * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
686
- * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
687
- * `sum`, `uniq`, and `words`
688
- *
689
- * @static
690
- * @memberOf _
691
- * @alias collect
692
- * @category Collection
693
- * @param {Array|Object|string} collection The collection to iterate over.
694
- * @param {Function|Object|string} [iteratee=_.identity] The function invoked
695
- * per iteration.
696
- * @param {*} [thisArg] The `this` binding of `iteratee`.
697
- * @returns {Array} Returns the new mapped array.
698
- * @example
699
- *
700
- * function timesThree(n) {
701
- * return n * 3;
702
- * }
703
- *
704
- * _.map([1, 2], timesThree);
705
- * // => [3, 6]
706
- *
707
- * _.map({ 'a': 1, 'b': 2 }, timesThree);
708
- * // => [3, 6] (iteration order is not guaranteed)
709
- *
710
- * var users = [
711
- * { 'user': 'barney' },
712
- * { 'user': 'fred' }
713
- * ];
714
- *
715
- * // using the `_.property` callback shorthand
716
- * _.map(users, 'user');
717
- * // => ['barney', 'fred']
718
- */
719
- function map(collection, iteratee, thisArg) {
720
- var func = isArray(collection) ? arrayMap : baseMap;
721
- iteratee = baseCallback(iteratee, thisArg, 3);
722
- return func(collection, iteratee);
723
- }
724
-
725
- module.exports = map;
726
-
727
- },{"../internal/arrayMap":27,"../internal/baseCallback":35,"../internal/baseMap":54,"../lang/isArray":127}],14:[function(require,module,exports){
728
- var map = require('./map'),
729
- property = require('../utility/property');
730
-
731
- /**
732
- * Gets the property value of `path` from all elements in `collection`.
733
- *
734
- * @static
735
- * @memberOf _
736
- * @category Collection
737
- * @param {Array|Object|string} collection The collection to iterate over.
738
- * @param {Array|string} path The path of the property to pluck.
739
- * @returns {Array} Returns the property values.
740
- * @example
741
- *
742
- * var users = [
743
- * { 'user': 'barney', 'age': 36 },
744
- * { 'user': 'fred', 'age': 40 }
745
- * ];
746
- *
747
- * _.pluck(users, 'user');
748
- * // => ['barney', 'fred']
749
- *
750
- * var userIndex = _.indexBy(users, 'user');
751
- * _.pluck(userIndex, 'age');
752
- * // => [36, 40] (iteration order is not guaranteed)
753
- */
754
- function pluck(collection, path) {
755
- return map(collection, property(path));
756
- }
757
-
758
- module.exports = pluck;
759
-
760
- },{"../utility/property":150,"./map":13}],15:[function(require,module,exports){
761
- var arrayReduce = require('../internal/arrayReduce'),
762
- baseEach = require('../internal/baseEach'),
763
- createReduce = require('../internal/createReduce');
764
-
765
- /**
766
- * Reduces `collection` to a value which is the accumulated result of running
767
- * each element in `collection` through `iteratee`, where each successive
768
- * invocation is supplied the return value of the previous. If `accumulator`
769
- * is not provided the first element of `collection` is used as the initial
770
- * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
771
- * (accumulator, value, index|key, collection).
772
- *
773
- * Many lodash methods are guarded to work as iteratees for methods like
774
- * `_.reduce`, `_.reduceRight`, and `_.transform`.
775
- *
776
- * The guarded methods are:
777
- * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,
778
- * and `sortByOrder`
779
- *
780
- * @static
781
- * @memberOf _
782
- * @alias foldl, inject
783
- * @category Collection
784
- * @param {Array|Object|string} collection The collection to iterate over.
785
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
786
- * @param {*} [accumulator] The initial value.
787
- * @param {*} [thisArg] The `this` binding of `iteratee`.
788
- * @returns {*} Returns the accumulated value.
789
- * @example
790
- *
791
- * _.reduce([1, 2], function(total, n) {
792
- * return total + n;
793
- * });
794
- * // => 3
795
- *
796
- * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
797
- * result[key] = n * 3;
798
- * return result;
799
- * }, {});
800
- * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
801
- */
802
- var reduce = createReduce(arrayReduce, baseEach);
803
-
804
- module.exports = reduce;
805
-
806
- },{"../internal/arrayReduce":29,"../internal/baseEach":40,"../internal/createReduce":91}],16:[function(require,module,exports){
807
- var baseSortByOrder = require('../internal/baseSortByOrder'),
808
- isArray = require('../lang/isArray'),
809
- isIterateeCall = require('../internal/isIterateeCall');
810
-
811
- /**
812
- * This method is like `_.sortByAll` except that it allows specifying the
813
- * sort orders of the iteratees to sort by. If `orders` is unspecified, all
814
- * values are sorted in ascending order. Otherwise, a value is sorted in
815
- * ascending order if its corresponding order is "asc", and descending if "desc".
816
- *
817
- * If a property name is provided for an iteratee the created `_.property`
818
- * style callback returns the property value of the given element.
819
- *
820
- * If an object is provided for an iteratee the created `_.matches` style
821
- * callback returns `true` for elements that have the properties of the given
822
- * object, else `false`.
823
- *
824
- * @static
825
- * @memberOf _
826
- * @category Collection
827
- * @param {Array|Object|string} collection The collection to iterate over.
828
- * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
829
- * @param {boolean[]} [orders] The sort orders of `iteratees`.
830
- * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
831
- * @returns {Array} Returns the new sorted array.
832
- * @example
833
- *
834
- * var users = [
835
- * { 'user': 'fred', 'age': 48 },
836
- * { 'user': 'barney', 'age': 34 },
837
- * { 'user': 'fred', 'age': 42 },
838
- * { 'user': 'barney', 'age': 36 }
839
- * ];
840
- *
841
- * // sort by `user` in ascending order and by `age` in descending order
842
- * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values);
843
- * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
844
- */
845
- function sortByOrder(collection, iteratees, orders, guard) {
846
- if (collection == null) {
847
- return [];
848
- }
849
- if (guard && isIterateeCall(iteratees, orders, guard)) {
850
- orders = undefined;
851
- }
852
- if (!isArray(iteratees)) {
853
- iteratees = iteratees == null ? [] : [iteratees];
854
- }
855
- if (!isArray(orders)) {
856
- orders = orders == null ? [] : [orders];
857
- }
858
- return baseSortByOrder(collection, iteratees, orders);
859
- }
860
-
861
- module.exports = sortByOrder;
862
-
863
- },{"../internal/baseSortByOrder":65,"../internal/isIterateeCall":104,"../lang/isArray":127}],17:[function(require,module,exports){
864
- module.exports = require('../math/sum');
865
-
866
- },{"../math/sum":137}],18:[function(require,module,exports){
867
- var getNative = require('../internal/getNative');
868
-
869
- /* Native method references for those with the same name as other `lodash` methods. */
870
- var nativeNow = getNative(Date, 'now');
871
-
872
- /**
873
- * Gets the number of milliseconds that have elapsed since the Unix epoch
874
- * (1 January 1970 00:00:00 UTC).
875
- *
876
- * @static
877
- * @memberOf _
878
- * @category Date
879
- * @example
880
- *
881
- * _.defer(function(stamp) {
882
- * console.log(_.now() - stamp);
883
- * }, _.now());
884
- * // => logs the number of milliseconds it took for the deferred function to be invoked
885
- */
886
- var now = nativeNow || function() {
887
- return new Date().getTime();
888
- };
889
-
890
- module.exports = now;
891
-
892
- },{"../internal/getNative":100}],19:[function(require,module,exports){
893
- var createWrapper = require('../internal/createWrapper'),
894
- replaceHolders = require('../internal/replaceHolders'),
895
- restParam = require('./restParam');
896
-
897
- /** Used to compose bitmasks for wrapper metadata. */
898
- var BIND_FLAG = 1,
899
- PARTIAL_FLAG = 32;
900
-
901
- /**
902
- * Creates a function that invokes `func` with the `this` binding of `thisArg`
903
- * and prepends any additional `_.bind` arguments to those provided to the
904
- * bound function.
905
- *
906
- * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
907
- * may be used as a placeholder for partially applied arguments.
908
- *
909
- * **Note:** Unlike native `Function#bind` this method does not set the "length"
910
- * property of bound functions.
911
- *
912
- * @static
913
- * @memberOf _
914
- * @category Function
915
- * @param {Function} func The function to bind.
916
- * @param {*} thisArg The `this` binding of `func`.
917
- * @param {...*} [partials] The arguments to be partially applied.
918
- * @returns {Function} Returns the new bound function.
919
- * @example
920
- *
921
- * var greet = function(greeting, punctuation) {
922
- * return greeting + ' ' + this.user + punctuation;
923
- * };
924
- *
925
- * var object = { 'user': 'fred' };
926
- *
927
- * var bound = _.bind(greet, object, 'hi');
928
- * bound('!');
929
- * // => 'hi fred!'
930
- *
931
- * // using placeholders
932
- * var bound = _.bind(greet, object, _, '!');
933
- * bound('hi');
934
- * // => 'hi fred!'
935
- */
936
- var bind = restParam(function(func, thisArg, partials) {
937
- var bitmask = BIND_FLAG;
938
- if (partials.length) {
939
- var holders = replaceHolders(partials, bind.placeholder);
940
- bitmask |= PARTIAL_FLAG;
941
- }
942
- return createWrapper(func, bitmask, thisArg, partials, holders);
943
- });
944
-
945
- // Assign default placeholders.
946
- bind.placeholder = {};
947
-
948
- module.exports = bind;
949
-
950
- },{"../internal/createWrapper":92,"../internal/replaceHolders":117,"./restParam":20}],20:[function(require,module,exports){
951
- /** Used as the `TypeError` message for "Functions" methods. */
952
- var FUNC_ERROR_TEXT = 'Expected a function';
953
-
954
- /* Native method references for those with the same name as other `lodash` methods. */
955
- var nativeMax = Math.max;
956
-
957
- /**
958
- * Creates a function that invokes `func` with the `this` binding of the
959
- * created function and arguments from `start` and beyond provided as an array.
960
- *
961
- * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
962
- *
963
- * @static
964
- * @memberOf _
965
- * @category Function
966
- * @param {Function} func The function to apply a rest parameter to.
967
- * @param {number} [start=func.length-1] The start position of the rest parameter.
968
- * @returns {Function} Returns the new function.
969
- * @example
970
- *
971
- * var say = _.restParam(function(what, names) {
972
- * return what + ' ' + _.initial(names).join(', ') +
973
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
974
- * });
975
- *
976
- * say('hello', 'fred', 'barney', 'pebbles');
977
- * // => 'hello fred, barney, & pebbles'
978
- */
979
- function restParam(func, start) {
980
- if (typeof func != 'function') {
981
- throw new TypeError(FUNC_ERROR_TEXT);
982
- }
983
- start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
984
- return function() {
985
- var args = arguments,
986
- index = -1,
987
- length = nativeMax(args.length - start, 0),
988
- rest = Array(length);
989
-
990
- while (++index < length) {
991
- rest[index] = args[start + index];
992
- }
993
- switch (start) {
994
- case 0: return func.call(this, rest);
995
- case 1: return func.call(this, args[0], rest);
996
- case 2: return func.call(this, args[0], args[1], rest);
997
- }
998
- var otherArgs = Array(start + 1);
999
- index = -1;
1000
- while (++index < start) {
1001
- otherArgs[index] = args[index];
1002
- }
1003
- otherArgs[start] = rest;
1004
- return func.apply(this, otherArgs);
1005
- };
1006
- }
1007
-
1008
- module.exports = restParam;
1009
-
1010
- },{}],21:[function(require,module,exports){
1011
- var baseCreate = require('./baseCreate'),
1012
- baseLodash = require('./baseLodash');
1013
-
1014
- /** Used as references for `-Infinity` and `Infinity`. */
1015
- var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
1016
-
1017
- /**
1018
- * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
1019
- *
1020
- * @private
1021
- * @param {*} value The value to wrap.
1022
- */
1023
- function LazyWrapper(value) {
1024
- this.__wrapped__ = value;
1025
- this.__actions__ = [];
1026
- this.__dir__ = 1;
1027
- this.__filtered__ = false;
1028
- this.__iteratees__ = [];
1029
- this.__takeCount__ = POSITIVE_INFINITY;
1030
- this.__views__ = [];
1031
- }
1032
-
1033
- LazyWrapper.prototype = baseCreate(baseLodash.prototype);
1034
- LazyWrapper.prototype.constructor = LazyWrapper;
1035
-
1036
- module.exports = LazyWrapper;
1037
-
1038
- },{"./baseCreate":38,"./baseLodash":53}],22:[function(require,module,exports){
1039
- var baseCreate = require('./baseCreate'),
1040
- baseLodash = require('./baseLodash');
1041
-
1042
- /**
1043
- * The base constructor for creating `lodash` wrapper objects.
1044
- *
1045
- * @private
1046
- * @param {*} value The value to wrap.
1047
- * @param {boolean} [chainAll] Enable chaining for all wrapper methods.
1048
- * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
1049
- */
1050
- function LodashWrapper(value, chainAll, actions) {
1051
- this.__wrapped__ = value;
1052
- this.__actions__ = actions || [];
1053
- this.__chain__ = !!chainAll;
1054
- }
1055
-
1056
- LodashWrapper.prototype = baseCreate(baseLodash.prototype);
1057
- LodashWrapper.prototype.constructor = LodashWrapper;
1058
-
1059
- module.exports = LodashWrapper;
1060
-
1061
- },{"./baseCreate":38,"./baseLodash":53}],23:[function(require,module,exports){
1062
- (function (global){
1063
- var cachePush = require('./cachePush'),
1064
- getNative = require('./getNative');
1065
-
1066
- /** Native method references. */
1067
- var Set = getNative(global, 'Set');
1068
-
1069
- /* Native method references for those with the same name as other `lodash` methods. */
1070
- var nativeCreate = getNative(Object, 'create');
1071
-
1072
- /**
1073
- *
1074
- * Creates a cache object to store unique values.
1075
- *
1076
- * @private
1077
- * @param {Array} [values] The values to cache.
1078
- */
1079
- function SetCache(values) {
1080
- var length = values ? values.length : 0;
1081
-
1082
- this.data = { 'hash': nativeCreate(null), 'set': new Set };
1083
- while (length--) {
1084
- this.push(values[length]);
1085
- }
1086
- }
1087
-
1088
- // Add functions to the `Set` cache.
1089
- SetCache.prototype.push = cachePush;
1090
-
1091
- module.exports = SetCache;
1092
-
1093
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
1094
- },{"./cachePush":73,"./getNative":100}],24:[function(require,module,exports){
1095
- /**
1096
- * Copies the values of `source` to `array`.
1097
- *
1098
- * @private
1099
- * @param {Array} source The array to copy values from.
1100
- * @param {Array} [array=[]] The array to copy values to.
1101
- * @returns {Array} Returns `array`.
1102
- */
1103
- function arrayCopy(source, array) {
1104
- var index = -1,
1105
- length = source.length;
1106
-
1107
- array || (array = Array(length));
1108
- while (++index < length) {
1109
- array[index] = source[index];
1110
- }
1111
- return array;
1112
- }
1113
-
1114
- module.exports = arrayCopy;
1115
-
1116
- },{}],25:[function(require,module,exports){
1117
- /**
1118
- * A specialized version of `_.forEach` for arrays without support for callback
1119
- * shorthands and `this` binding.
1120
- *
1121
- * @private
1122
- * @param {Array} array The array to iterate over.
1123
- * @param {Function} iteratee The function invoked per iteration.
1124
- * @returns {Array} Returns `array`.
1125
- */
1126
- function arrayEach(array, iteratee) {
1127
- var index = -1,
1128
- length = array.length;
1129
-
1130
- while (++index < length) {
1131
- if (iteratee(array[index], index, array) === false) {
1132
- break;
1133
- }
1134
- }
1135
- return array;
1136
- }
1137
-
1138
- module.exports = arrayEach;
1139
-
1140
- },{}],26:[function(require,module,exports){
1141
- /**
1142
- * A specialized version of `_.filter` for arrays without support for callback
1143
- * shorthands and `this` binding.
1144
- *
1145
- * @private
1146
- * @param {Array} array The array to iterate over.
1147
- * @param {Function} predicate The function invoked per iteration.
1148
- * @returns {Array} Returns the new filtered array.
1149
- */
1150
- function arrayFilter(array, predicate) {
1151
- var index = -1,
1152
- length = array.length,
1153
- resIndex = -1,
1154
- result = [];
1155
-
1156
- while (++index < length) {
1157
- var value = array[index];
1158
- if (predicate(value, index, array)) {
1159
- result[++resIndex] = value;
1160
- }
1161
- }
1162
- return result;
1163
- }
1164
-
1165
- module.exports = arrayFilter;
1166
-
1167
- },{}],27:[function(require,module,exports){
1168
- /**
1169
- * A specialized version of `_.map` for arrays without support for callback
1170
- * shorthands and `this` binding.
1171
- *
1172
- * @private
1173
- * @param {Array} array The array to iterate over.
1174
- * @param {Function} iteratee The function invoked per iteration.
1175
- * @returns {Array} Returns the new mapped array.
1176
- */
1177
- function arrayMap(array, iteratee) {
1178
- var index = -1,
1179
- length = array.length,
1180
- result = Array(length);
1181
-
1182
- while (++index < length) {
1183
- result[index] = iteratee(array[index], index, array);
1184
- }
1185
- return result;
1186
- }
1187
-
1188
- module.exports = arrayMap;
1189
-
1190
- },{}],28:[function(require,module,exports){
1191
- /**
1192
- * Appends the elements of `values` to `array`.
1193
- *
1194
- * @private
1195
- * @param {Array} array The array to modify.
1196
- * @param {Array} values The values to append.
1197
- * @returns {Array} Returns `array`.
1198
- */
1199
- function arrayPush(array, values) {
1200
- var index = -1,
1201
- length = values.length,
1202
- offset = array.length;
1203
-
1204
- while (++index < length) {
1205
- array[offset + index] = values[index];
1206
- }
1207
- return array;
1208
- }
1209
-
1210
- module.exports = arrayPush;
1211
-
1212
- },{}],29:[function(require,module,exports){
1213
- /**
1214
- * A specialized version of `_.reduce` for arrays without support for callback
1215
- * shorthands and `this` binding.
1216
- *
1217
- * @private
1218
- * @param {Array} array The array to iterate over.
1219
- * @param {Function} iteratee The function invoked per iteration.
1220
- * @param {*} [accumulator] The initial value.
1221
- * @param {boolean} [initFromArray] Specify using the first element of `array`
1222
- * as the initial value.
1223
- * @returns {*} Returns the accumulated value.
1224
- */
1225
- function arrayReduce(array, iteratee, accumulator, initFromArray) {
1226
- var index = -1,
1227
- length = array.length;
1228
-
1229
- if (initFromArray && length) {
1230
- accumulator = array[++index];
1231
- }
1232
- while (++index < length) {
1233
- accumulator = iteratee(accumulator, array[index], index, array);
1234
- }
1235
- return accumulator;
1236
- }
1237
-
1238
- module.exports = arrayReduce;
1239
-
1240
- },{}],30:[function(require,module,exports){
1241
- /**
1242
- * A specialized version of `_.some` for arrays without support for callback
1243
- * shorthands and `this` binding.
1244
- *
1245
- * @private
1246
- * @param {Array} array The array to iterate over.
1247
- * @param {Function} predicate The function invoked per iteration.
1248
- * @returns {boolean} Returns `true` if any element passes the predicate check,
1249
- * else `false`.
1250
- */
1251
- function arraySome(array, predicate) {
1252
- var index = -1,
1253
- length = array.length;
1254
-
1255
- while (++index < length) {
1256
- if (predicate(array[index], index, array)) {
1257
- return true;
1258
- }
1259
- }
1260
- return false;
1261
- }
1262
-
1263
- module.exports = arraySome;
1264
-
1265
- },{}],31:[function(require,module,exports){
1266
- /**
1267
- * A specialized version of `_.sum` for arrays without support for callback
1268
- * shorthands and `this` binding..
1269
- *
1270
- * @private
1271
- * @param {Array} array The array to iterate over.
1272
- * @param {Function} iteratee The function invoked per iteration.
1273
- * @returns {number} Returns the sum.
1274
- */
1275
- function arraySum(array, iteratee) {
1276
- var length = array.length,
1277
- result = 0;
1278
-
1279
- while (length--) {
1280
- result += +iteratee(array[length]) || 0;
1281
- }
1282
- return result;
1283
- }
1284
-
1285
- module.exports = arraySum;
1286
-
1287
- },{}],32:[function(require,module,exports){
1288
- /**
1289
- * Used by `_.defaults` to customize its `_.assign` use.
1290
- *
1291
- * @private
1292
- * @param {*} objectValue The destination object property value.
1293
- * @param {*} sourceValue The source object property value.
1294
- * @returns {*} Returns the value to assign to the destination object.
1295
- */
1296
- function assignDefaults(objectValue, sourceValue) {
1297
- return objectValue === undefined ? sourceValue : objectValue;
1298
- }
1299
-
1300
- module.exports = assignDefaults;
1301
-
1302
- },{}],33:[function(require,module,exports){
1303
- var keys = require('../object/keys');
1304
-
1305
- /**
1306
- * A specialized version of `_.assign` for customizing assigned values without
1307
- * support for argument juggling, multiple sources, and `this` binding `customizer`
1308
- * functions.
1309
- *
1310
- * @private
1311
- * @param {Object} object The destination object.
1312
- * @param {Object} source The source object.
1313
- * @param {Function} customizer The function to customize assigned values.
1314
- * @returns {Object} Returns `object`.
1315
- */
1316
- function assignWith(object, source, customizer) {
1317
- var index = -1,
1318
- props = keys(source),
1319
- length = props.length;
1320
-
1321
- while (++index < length) {
1322
- var key = props[index],
1323
- value = object[key],
1324
- result = customizer(value, source[key], key, object, source);
1325
-
1326
- if ((result === result ? (result !== value) : (value === value)) ||
1327
- (value === undefined && !(key in object))) {
1328
- object[key] = result;
1329
- }
1330
- }
1331
- return object;
1332
- }
1333
-
1334
- module.exports = assignWith;
1335
-
1336
- },{"../object/keys":140}],34:[function(require,module,exports){
1337
- var baseCopy = require('./baseCopy'),
1338
- keys = require('../object/keys');
1339
-
1340
- /**
1341
- * The base implementation of `_.assign` without support for argument juggling,
1342
- * multiple sources, and `customizer` functions.
1343
- *
1344
- * @private
1345
- * @param {Object} object The destination object.
1346
- * @param {Object} source The source object.
1347
- * @returns {Object} Returns `object`.
1348
- */
1349
- function baseAssign(object, source) {
1350
- return source == null
1351
- ? object
1352
- : baseCopy(source, keys(source), object);
1353
- }
1354
-
1355
- module.exports = baseAssign;
1356
-
1357
- },{"../object/keys":140,"./baseCopy":37}],35:[function(require,module,exports){
1358
- var baseMatches = require('./baseMatches'),
1359
- baseMatchesProperty = require('./baseMatchesProperty'),
1360
- bindCallback = require('./bindCallback'),
1361
- identity = require('../utility/identity'),
1362
- property = require('../utility/property');
1363
-
1364
- /**
1365
- * The base implementation of `_.callback` which supports specifying the
1366
- * number of arguments to provide to `func`.
1367
- *
1368
- * @private
1369
- * @param {*} [func=_.identity] The value to convert to a callback.
1370
- * @param {*} [thisArg] The `this` binding of `func`.
1371
- * @param {number} [argCount] The number of arguments to provide to `func`.
1372
- * @returns {Function} Returns the callback.
1373
- */
1374
- function baseCallback(func, thisArg, argCount) {
1375
- var type = typeof func;
1376
- if (type == 'function') {
1377
- return thisArg === undefined
1378
- ? func
1379
- : bindCallback(func, thisArg, argCount);
1380
- }
1381
- if (func == null) {
1382
- return identity;
1383
- }
1384
- if (type == 'object') {
1385
- return baseMatches(func);
1386
- }
1387
- return thisArg === undefined
1388
- ? property(func)
1389
- : baseMatchesProperty(func, thisArg);
1390
- }
1391
-
1392
- module.exports = baseCallback;
1393
-
1394
- },{"../utility/identity":148,"../utility/property":150,"./baseMatches":55,"./baseMatchesProperty":56,"./bindCallback":71}],36:[function(require,module,exports){
1395
- /**
1396
- * The base implementation of `compareAscending` which compares values and
1397
- * sorts them in ascending order without guaranteeing a stable sort.
1398
- *
1399
- * @private
1400
- * @param {*} value The value to compare.
1401
- * @param {*} other The other value to compare.
1402
- * @returns {number} Returns the sort order indicator for `value`.
1403
- */
1404
- function baseCompareAscending(value, other) {
1405
- if (value !== other) {
1406
- var valIsNull = value === null,
1407
- valIsUndef = value === undefined,
1408
- valIsReflexive = value === value;
1409
-
1410
- var othIsNull = other === null,
1411
- othIsUndef = other === undefined,
1412
- othIsReflexive = other === other;
1413
-
1414
- if ((value > other && !othIsNull) || !valIsReflexive ||
1415
- (valIsNull && !othIsUndef && othIsReflexive) ||
1416
- (valIsUndef && othIsReflexive)) {
1417
- return 1;
1418
- }
1419
- if ((value < other && !valIsNull) || !othIsReflexive ||
1420
- (othIsNull && !valIsUndef && valIsReflexive) ||
1421
- (othIsUndef && valIsReflexive)) {
1422
- return -1;
1423
- }
1424
- }
1425
- return 0;
1426
- }
1427
-
1428
- module.exports = baseCompareAscending;
1429
-
1430
- },{}],37:[function(require,module,exports){
1431
- /**
1432
- * Copies properties of `source` to `object`.
1433
- *
1434
- * @private
1435
- * @param {Object} source The object to copy properties from.
1436
- * @param {Array} props The property names to copy.
1437
- * @param {Object} [object={}] The object to copy properties to.
1438
- * @returns {Object} Returns `object`.
1439
- */
1440
- function baseCopy(source, props, object) {
1441
- object || (object = {});
1442
-
1443
- var index = -1,
1444
- length = props.length;
1445
-
1446
- while (++index < length) {
1447
- var key = props[index];
1448
- object[key] = source[key];
1449
- }
1450
- return object;
1451
- }
1452
-
1453
- module.exports = baseCopy;
1454
-
1455
- },{}],38:[function(require,module,exports){
1456
- var isObject = require('../lang/isObject');
1457
-
1458
- /**
1459
- * The base implementation of `_.create` without support for assigning
1460
- * properties to the created object.
1461
- *
1462
- * @private
1463
- * @param {Object} prototype The object to inherit from.
1464
- * @returns {Object} Returns the new object.
1465
- */
1466
- var baseCreate = (function() {
1467
- function object() {}
1468
- return function(prototype) {
1469
- if (isObject(prototype)) {
1470
- object.prototype = prototype;
1471
- var result = new object;
1472
- object.prototype = undefined;
1473
- }
1474
- return result || {};
1475
- };
1476
- }());
1477
-
1478
- module.exports = baseCreate;
1479
-
1480
- },{"../lang/isObject":131}],39:[function(require,module,exports){
1481
- var baseIndexOf = require('./baseIndexOf'),
1482
- cacheIndexOf = require('./cacheIndexOf'),
1483
- createCache = require('./createCache');
1484
-
1485
- /** Used as the size to enable large array optimizations. */
1486
- var LARGE_ARRAY_SIZE = 200;
1487
-
1488
- /**
1489
- * The base implementation of `_.difference` which accepts a single array
1490
- * of values to exclude.
1491
- *
1492
- * @private
1493
- * @param {Array} array The array to inspect.
1494
- * @param {Array} values The values to exclude.
1495
- * @returns {Array} Returns the new array of filtered values.
1496
- */
1497
- function baseDifference(array, values) {
1498
- var length = array ? array.length : 0,
1499
- result = [];
1500
-
1501
- if (!length) {
1502
- return result;
1503
- }
1504
- var index = -1,
1505
- indexOf = baseIndexOf,
1506
- isCommon = true,
1507
- cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
1508
- valuesLength = values.length;
1509
-
1510
- if (cache) {
1511
- indexOf = cacheIndexOf;
1512
- isCommon = false;
1513
- values = cache;
1514
- }
1515
- outer:
1516
- while (++index < length) {
1517
- var value = array[index];
1518
-
1519
- if (isCommon && value === value) {
1520
- var valuesIndex = valuesLength;
1521
- while (valuesIndex--) {
1522
- if (values[valuesIndex] === value) {
1523
- continue outer;
1524
- }
1525
- }
1526
- result.push(value);
1527
- }
1528
- else if (indexOf(values, value, 0) < 0) {
1529
- result.push(value);
1530
- }
1531
- }
1532
- return result;
1533
- }
1534
-
1535
- module.exports = baseDifference;
1536
-
1537
- },{"./baseIndexOf":49,"./cacheIndexOf":72,"./createCache":83}],40:[function(require,module,exports){
1538
- var baseForOwn = require('./baseForOwn'),
1539
- createBaseEach = require('./createBaseEach');
1540
-
1541
- /**
1542
- * The base implementation of `_.forEach` without support for callback
1543
- * shorthands and `this` binding.
1544
- *
1545
- * @private
1546
- * @param {Array|Object|string} collection The collection to iterate over.
1547
- * @param {Function} iteratee The function invoked per iteration.
1548
- * @returns {Array|Object|string} Returns `collection`.
1549
- */
1550
- var baseEach = createBaseEach(baseForOwn);
1551
-
1552
- module.exports = baseEach;
1553
-
1554
- },{"./baseForOwn":47,"./createBaseEach":80}],41:[function(require,module,exports){
1555
- var baseEach = require('./baseEach');
1556
-
1557
- /**
1558
- * The base implementation of `_.filter` without support for callback
1559
- * shorthands and `this` binding.
1560
- *
1561
- * @private
1562
- * @param {Array|Object|string} collection The collection to iterate over.
1563
- * @param {Function} predicate The function invoked per iteration.
1564
- * @returns {Array} Returns the new filtered array.
1565
- */
1566
- function baseFilter(collection, predicate) {
1567
- var result = [];
1568
- baseEach(collection, function(value, index, collection) {
1569
- if (predicate(value, index, collection)) {
1570
- result.push(value);
1571
- }
1572
- });
1573
- return result;
1574
- }
1575
-
1576
- module.exports = baseFilter;
1577
-
1578
- },{"./baseEach":40}],42:[function(require,module,exports){
1579
- /**
1580
- * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
1581
- * without support for callback shorthands and `this` binding, which iterates
1582
- * over `collection` using the provided `eachFunc`.
1583
- *
1584
- * @private
1585
- * @param {Array|Object|string} collection The collection to search.
1586
- * @param {Function} predicate The function invoked per iteration.
1587
- * @param {Function} eachFunc The function to iterate over `collection`.
1588
- * @param {boolean} [retKey] Specify returning the key of the found element
1589
- * instead of the element itself.
1590
- * @returns {*} Returns the found element or its key, else `undefined`.
1591
- */
1592
- function baseFind(collection, predicate, eachFunc, retKey) {
1593
- var result;
1594
- eachFunc(collection, function(value, key, collection) {
1595
- if (predicate(value, key, collection)) {
1596
- result = retKey ? key : value;
1597
- return false;
1598
- }
1599
- });
1600
- return result;
1601
- }
1602
-
1603
- module.exports = baseFind;
1604
-
1605
- },{}],43:[function(require,module,exports){
1606
- /**
1607
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
1608
- * support for callback shorthands and `this` binding.
1609
- *
1610
- * @private
1611
- * @param {Array} array The array to search.
1612
- * @param {Function} predicate The function invoked per iteration.
1613
- * @param {boolean} [fromRight] Specify iterating from right to left.
1614
- * @returns {number} Returns the index of the matched value, else `-1`.
1615
- */
1616
- function baseFindIndex(array, predicate, fromRight) {
1617
- var length = array.length,
1618
- index = fromRight ? length : -1;
1619
-
1620
- while ((fromRight ? index-- : ++index < length)) {
1621
- if (predicate(array[index], index, array)) {
1622
- return index;
1623
- }
1624
- }
1625
- return -1;
1626
- }
1627
-
1628
- module.exports = baseFindIndex;
1629
-
1630
- },{}],44:[function(require,module,exports){
1631
- var arrayPush = require('./arrayPush'),
1632
- isArguments = require('../lang/isArguments'),
1633
- isArray = require('../lang/isArray'),
1634
- isArrayLike = require('./isArrayLike'),
1635
- isObjectLike = require('./isObjectLike');
1636
-
1637
- /**
1638
- * The base implementation of `_.flatten` with added support for restricting
1639
- * flattening and specifying the start index.
1640
- *
1641
- * @private
1642
- * @param {Array} array The array to flatten.
1643
- * @param {boolean} [isDeep] Specify a deep flatten.
1644
- * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
1645
- * @param {Array} [result=[]] The initial result value.
1646
- * @returns {Array} Returns the new flattened array.
1647
- */
1648
- function baseFlatten(array, isDeep, isStrict, result) {
1649
- result || (result = []);
1650
-
1651
- var index = -1,
1652
- length = array.length;
1653
-
1654
- while (++index < length) {
1655
- var value = array[index];
1656
- if (isObjectLike(value) && isArrayLike(value) &&
1657
- (isStrict || isArray(value) || isArguments(value))) {
1658
- if (isDeep) {
1659
- // Recursively flatten arrays (susceptible to call stack limits).
1660
- baseFlatten(value, isDeep, isStrict, result);
1661
- } else {
1662
- arrayPush(result, value);
1663
- }
1664
- } else if (!isStrict) {
1665
- result[result.length] = value;
1666
- }
1667
- }
1668
- return result;
1669
- }
1670
-
1671
- module.exports = baseFlatten;
1672
-
1673
- },{"../lang/isArguments":126,"../lang/isArray":127,"./arrayPush":28,"./isArrayLike":102,"./isObjectLike":108}],45:[function(require,module,exports){
1674
- var createBaseFor = require('./createBaseFor');
1675
-
1676
- /**
1677
- * The base implementation of `baseForIn` and `baseForOwn` which iterates
1678
- * over `object` properties returned by `keysFunc` invoking `iteratee` for
1679
- * each property. Iteratee functions may exit iteration early by explicitly
1680
- * returning `false`.
1681
- *
1682
- * @private
1683
- * @param {Object} object The object to iterate over.
1684
- * @param {Function} iteratee The function invoked per iteration.
1685
- * @param {Function} keysFunc The function to get the keys of `object`.
1686
- * @returns {Object} Returns `object`.
1687
- */
1688
- var baseFor = createBaseFor();
1689
-
1690
- module.exports = baseFor;
1691
-
1692
- },{"./createBaseFor":81}],46:[function(require,module,exports){
1693
- var baseFor = require('./baseFor'),
1694
- keysIn = require('../object/keysIn');
1695
-
1696
- /**
1697
- * The base implementation of `_.forIn` without support for callback
1698
- * shorthands and `this` binding.
1699
- *
1700
- * @private
1701
- * @param {Object} object The object to iterate over.
1702
- * @param {Function} iteratee The function invoked per iteration.
1703
- * @returns {Object} Returns `object`.
1704
- */
1705
- function baseForIn(object, iteratee) {
1706
- return baseFor(object, iteratee, keysIn);
1707
- }
1708
-
1709
- module.exports = baseForIn;
1710
-
1711
- },{"../object/keysIn":141,"./baseFor":45}],47:[function(require,module,exports){
1712
- var baseFor = require('./baseFor'),
1713
- keys = require('../object/keys');
1714
-
1715
- /**
1716
- * The base implementation of `_.forOwn` without support for callback
1717
- * shorthands and `this` binding.
1718
- *
1719
- * @private
1720
- * @param {Object} object The object to iterate over.
1721
- * @param {Function} iteratee The function invoked per iteration.
1722
- * @returns {Object} Returns `object`.
1723
- */
1724
- function baseForOwn(object, iteratee) {
1725
- return baseFor(object, iteratee, keys);
1726
- }
1727
-
1728
- module.exports = baseForOwn;
1729
-
1730
- },{"../object/keys":140,"./baseFor":45}],48:[function(require,module,exports){
1731
- var toObject = require('./toObject');
1732
-
1733
- /**
1734
- * The base implementation of `get` without support for string paths
1735
- * and default values.
1736
- *
1737
- * @private
1738
- * @param {Object} object The object to query.
1739
- * @param {Array} path The path of the property to get.
1740
- * @param {string} [pathKey] The key representation of path.
1741
- * @returns {*} Returns the resolved value.
1742
- */
1743
- function baseGet(object, path, pathKey) {
1744
- if (object == null) {
1745
- return;
1746
- }
1747
- if (pathKey !== undefined && pathKey in toObject(object)) {
1748
- path = [pathKey];
1749
- }
1750
- var index = 0,
1751
- length = path.length;
1752
-
1753
- while (object != null && index < length) {
1754
- object = object[path[index++]];
1755
- }
1756
- return (index && index == length) ? object : undefined;
1757
- }
1758
-
1759
- module.exports = baseGet;
1760
-
1761
- },{"./toObject":121}],49:[function(require,module,exports){
1762
- var indexOfNaN = require('./indexOfNaN');
1763
-
1764
- /**
1765
- * The base implementation of `_.indexOf` without support for binary searches.
1766
- *
1767
- * @private
1768
- * @param {Array} array The array to search.
1769
- * @param {*} value The value to search for.
1770
- * @param {number} fromIndex The index to search from.
1771
- * @returns {number} Returns the index of the matched value, else `-1`.
1772
- */
1773
- function baseIndexOf(array, value, fromIndex) {
1774
- if (value !== value) {
1775
- return indexOfNaN(array, fromIndex);
1776
- }
1777
- var index = fromIndex - 1,
1778
- length = array.length;
1779
-
1780
- while (++index < length) {
1781
- if (array[index] === value) {
1782
- return index;
1783
- }
1784
- }
1785
- return -1;
1786
- }
1787
-
1788
- module.exports = baseIndexOf;
1789
-
1790
- },{"./indexOfNaN":101}],50:[function(require,module,exports){
1791
- var baseIsEqualDeep = require('./baseIsEqualDeep'),
1792
- isObject = require('../lang/isObject'),
1793
- isObjectLike = require('./isObjectLike');
1794
-
1795
- /**
1796
- * The base implementation of `_.isEqual` without support for `this` binding
1797
- * `customizer` functions.
1798
- *
1799
- * @private
1800
- * @param {*} value The value to compare.
1801
- * @param {*} other The other value to compare.
1802
- * @param {Function} [customizer] The function to customize comparing values.
1803
- * @param {boolean} [isLoose] Specify performing partial comparisons.
1804
- * @param {Array} [stackA] Tracks traversed `value` objects.
1805
- * @param {Array} [stackB] Tracks traversed `other` objects.
1806
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1807
- */
1808
- function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
1809
- if (value === other) {
1810
- return true;
1811
- }
1812
- if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
1813
- return value !== value && other !== other;
1814
- }
1815
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
1816
- }
1817
-
1818
- module.exports = baseIsEqual;
1819
-
1820
- },{"../lang/isObject":131,"./baseIsEqualDeep":51,"./isObjectLike":108}],51:[function(require,module,exports){
1821
- var equalArrays = require('./equalArrays'),
1822
- equalByTag = require('./equalByTag'),
1823
- equalObjects = require('./equalObjects'),
1824
- isArray = require('../lang/isArray'),
1825
- isTypedArray = require('../lang/isTypedArray');
1826
-
1827
- /** `Object#toString` result references. */
1828
- var argsTag = '[object Arguments]',
1829
- arrayTag = '[object Array]',
1830
- objectTag = '[object Object]';
1831
-
1832
- /** Used for native method references. */
1833
- var objectProto = Object.prototype;
1834
-
1835
- /** Used to check objects for own properties. */
1836
- var hasOwnProperty = objectProto.hasOwnProperty;
1837
-
1838
- /**
1839
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
1840
- * of values.
1841
- */
1842
- var objToString = objectProto.toString;
1843
-
1844
- /**
1845
- * A specialized version of `baseIsEqual` for arrays and objects which performs
1846
- * deep comparisons and tracks traversed objects enabling objects with circular
1847
- * references to be compared.
1848
- *
1849
- * @private
1850
- * @param {Object} object The object to compare.
1851
- * @param {Object} other The other object to compare.
1852
- * @param {Function} equalFunc The function to determine equivalents of values.
1853
- * @param {Function} [customizer] The function to customize comparing objects.
1854
- * @param {boolean} [isLoose] Specify performing partial comparisons.
1855
- * @param {Array} [stackA=[]] Tracks traversed `value` objects.
1856
- * @param {Array} [stackB=[]] Tracks traversed `other` objects.
1857
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1858
- */
1859
- function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
1860
- var objIsArr = isArray(object),
1861
- othIsArr = isArray(other),
1862
- objTag = arrayTag,
1863
- othTag = arrayTag;
1864
-
1865
- if (!objIsArr) {
1866
- objTag = objToString.call(object);
1867
- if (objTag == argsTag) {
1868
- objTag = objectTag;
1869
- } else if (objTag != objectTag) {
1870
- objIsArr = isTypedArray(object);
1871
- }
1872
- }
1873
- if (!othIsArr) {
1874
- othTag = objToString.call(other);
1875
- if (othTag == argsTag) {
1876
- othTag = objectTag;
1877
- } else if (othTag != objectTag) {
1878
- othIsArr = isTypedArray(other);
1879
- }
1880
- }
1881
- var objIsObj = objTag == objectTag,
1882
- othIsObj = othTag == objectTag,
1883
- isSameTag = objTag == othTag;
1884
-
1885
- if (isSameTag && !(objIsArr || objIsObj)) {
1886
- return equalByTag(object, other, objTag);
1887
- }
1888
- if (!isLoose) {
1889
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1890
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1891
-
1892
- if (objIsWrapped || othIsWrapped) {
1893
- return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
1894
- }
1895
- }
1896
- if (!isSameTag) {
1897
- return false;
1898
- }
1899
- // Assume cyclic values are equal.
1900
- // For more information on detecting circular references see https://es5.github.io/#JO.
1901
- stackA || (stackA = []);
1902
- stackB || (stackB = []);
1903
-
1904
- var length = stackA.length;
1905
- while (length--) {
1906
- if (stackA[length] == object) {
1907
- return stackB[length] == other;
1908
- }
1909
- }
1910
- // Add `object` and `other` to the stack of traversed objects.
1911
- stackA.push(object);
1912
- stackB.push(other);
1913
-
1914
- var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
1915
-
1916
- stackA.pop();
1917
- stackB.pop();
1918
-
1919
- return result;
1920
- }
1921
-
1922
- module.exports = baseIsEqualDeep;
1923
-
1924
- },{"../lang/isArray":127,"../lang/isTypedArray":134,"./equalArrays":93,"./equalByTag":94,"./equalObjects":95}],52:[function(require,module,exports){
1925
- var baseIsEqual = require('./baseIsEqual'),
1926
- toObject = require('./toObject');
1927
-
1928
- /**
1929
- * The base implementation of `_.isMatch` without support for callback
1930
- * shorthands and `this` binding.
1931
- *
1932
- * @private
1933
- * @param {Object} object The object to inspect.
1934
- * @param {Array} matchData The propery names, values, and compare flags to match.
1935
- * @param {Function} [customizer] The function to customize comparing objects.
1936
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
1937
- */
1938
- function baseIsMatch(object, matchData, customizer) {
1939
- var index = matchData.length,
1940
- length = index,
1941
- noCustomizer = !customizer;
1942
-
1943
- if (object == null) {
1944
- return !length;
1945
- }
1946
- object = toObject(object);
1947
- while (index--) {
1948
- var data = matchData[index];
1949
- if ((noCustomizer && data[2])
1950
- ? data[1] !== object[data[0]]
1951
- : !(data[0] in object)
1952
- ) {
1953
- return false;
1954
- }
1955
- }
1956
- while (++index < length) {
1957
- data = matchData[index];
1958
- var key = data[0],
1959
- objValue = object[key],
1960
- srcValue = data[1];
1961
-
1962
- if (noCustomizer && data[2]) {
1963
- if (objValue === undefined && !(key in object)) {
1964
- return false;
1965
- }
1966
- } else {
1967
- var result = customizer ? customizer(objValue, srcValue, key) : undefined;
1968
- if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
1969
- return false;
1970
- }
1971
- }
1972
- }
1973
- return true;
1974
- }
1975
-
1976
- module.exports = baseIsMatch;
1977
-
1978
- },{"./baseIsEqual":50,"./toObject":121}],53:[function(require,module,exports){
1979
- /**
1980
- * The function whose prototype all chaining wrappers inherit from.
1981
- *
1982
- * @private
1983
- */
1984
- function baseLodash() {
1985
- // No operation performed.
1986
- }
1987
-
1988
- module.exports = baseLodash;
1989
-
1990
- },{}],54:[function(require,module,exports){
1991
- var baseEach = require('./baseEach'),
1992
- isArrayLike = require('./isArrayLike');
1993
-
1994
- /**
1995
- * The base implementation of `_.map` without support for callback shorthands
1996
- * and `this` binding.
1997
- *
1998
- * @private
1999
- * @param {Array|Object|string} collection The collection to iterate over.
2000
- * @param {Function} iteratee The function invoked per iteration.
2001
- * @returns {Array} Returns the new mapped array.
2002
- */
2003
- function baseMap(collection, iteratee) {
2004
- var index = -1,
2005
- result = isArrayLike(collection) ? Array(collection.length) : [];
2006
-
2007
- baseEach(collection, function(value, key, collection) {
2008
- result[++index] = iteratee(value, key, collection);
2009
- });
2010
- return result;
2011
- }
2012
-
2013
- module.exports = baseMap;
2014
-
2015
- },{"./baseEach":40,"./isArrayLike":102}],55:[function(require,module,exports){
2016
- var baseIsMatch = require('./baseIsMatch'),
2017
- getMatchData = require('./getMatchData'),
2018
- toObject = require('./toObject');
2019
-
2020
- /**
2021
- * The base implementation of `_.matches` which does not clone `source`.
2022
- *
2023
- * @private
2024
- * @param {Object} source The object of property values to match.
2025
- * @returns {Function} Returns the new function.
2026
- */
2027
- function baseMatches(source) {
2028
- var matchData = getMatchData(source);
2029
- if (matchData.length == 1 && matchData[0][2]) {
2030
- var key = matchData[0][0],
2031
- value = matchData[0][1];
2032
-
2033
- return function(object) {
2034
- if (object == null) {
2035
- return false;
2036
- }
2037
- return object[key] === value && (value !== undefined || (key in toObject(object)));
2038
- };
2039
- }
2040
- return function(object) {
2041
- return baseIsMatch(object, matchData);
2042
- };
2043
- }
2044
-
2045
- module.exports = baseMatches;
2046
-
2047
- },{"./baseIsMatch":52,"./getMatchData":99,"./toObject":121}],56:[function(require,module,exports){
2048
- var baseGet = require('./baseGet'),
2049
- baseIsEqual = require('./baseIsEqual'),
2050
- baseSlice = require('./baseSlice'),
2051
- isArray = require('../lang/isArray'),
2052
- isKey = require('./isKey'),
2053
- isStrictComparable = require('./isStrictComparable'),
2054
- last = require('../array/last'),
2055
- toObject = require('./toObject'),
2056
- toPath = require('./toPath');
2057
-
2058
- /**
2059
- * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
2060
- *
2061
- * @private
2062
- * @param {string} path The path of the property to get.
2063
- * @param {*} srcValue The value to compare.
2064
- * @returns {Function} Returns the new function.
2065
- */
2066
- function baseMatchesProperty(path, srcValue) {
2067
- var isArr = isArray(path),
2068
- isCommon = isKey(path) && isStrictComparable(srcValue),
2069
- pathKey = (path + '');
2070
-
2071
- path = toPath(path);
2072
- return function(object) {
2073
- if (object == null) {
2074
- return false;
2075
- }
2076
- var key = pathKey;
2077
- object = toObject(object);
2078
- if ((isArr || !isCommon) && !(key in object)) {
2079
- object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
2080
- if (object == null) {
2081
- return false;
2082
- }
2083
- key = last(path);
2084
- object = toObject(object);
2085
- }
2086
- return object[key] === srcValue
2087
- ? (srcValue !== undefined || (key in object))
2088
- : baseIsEqual(srcValue, object[key], undefined, true);
2089
- };
2090
- }
2091
-
2092
- module.exports = baseMatchesProperty;
2093
-
2094
- },{"../array/last":7,"../lang/isArray":127,"./baseGet":48,"./baseIsEqual":50,"./baseSlice":63,"./isKey":105,"./isStrictComparable":110,"./toObject":121,"./toPath":122}],57:[function(require,module,exports){
2095
- var arrayEach = require('./arrayEach'),
2096
- baseMergeDeep = require('./baseMergeDeep'),
2097
- isArray = require('../lang/isArray'),
2098
- isArrayLike = require('./isArrayLike'),
2099
- isObject = require('../lang/isObject'),
2100
- isObjectLike = require('./isObjectLike'),
2101
- isTypedArray = require('../lang/isTypedArray'),
2102
- keys = require('../object/keys');
2103
-
2104
- /**
2105
- * The base implementation of `_.merge` without support for argument juggling,
2106
- * multiple sources, and `this` binding `customizer` functions.
2107
- *
2108
- * @private
2109
- * @param {Object} object The destination object.
2110
- * @param {Object} source The source object.
2111
- * @param {Function} [customizer] The function to customize merged values.
2112
- * @param {Array} [stackA=[]] Tracks traversed source objects.
2113
- * @param {Array} [stackB=[]] Associates values with source counterparts.
2114
- * @returns {Object} Returns `object`.
2115
- */
2116
- function baseMerge(object, source, customizer, stackA, stackB) {
2117
- if (!isObject(object)) {
2118
- return object;
2119
- }
2120
- var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
2121
- props = isSrcArr ? undefined : keys(source);
2122
-
2123
- arrayEach(props || source, function(srcValue, key) {
2124
- if (props) {
2125
- key = srcValue;
2126
- srcValue = source[key];
2127
- }
2128
- if (isObjectLike(srcValue)) {
2129
- stackA || (stackA = []);
2130
- stackB || (stackB = []);
2131
- baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
2132
- }
2133
- else {
2134
- var value = object[key],
2135
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
2136
- isCommon = result === undefined;
2137
-
2138
- if (isCommon) {
2139
- result = srcValue;
2140
- }
2141
- if ((result !== undefined || (isSrcArr && !(key in object))) &&
2142
- (isCommon || (result === result ? (result !== value) : (value === value)))) {
2143
- object[key] = result;
2144
- }
2145
- }
2146
- });
2147
- return object;
2148
- }
2149
-
2150
- module.exports = baseMerge;
2151
-
2152
- },{"../lang/isArray":127,"../lang/isObject":131,"../lang/isTypedArray":134,"../object/keys":140,"./arrayEach":25,"./baseMergeDeep":58,"./isArrayLike":102,"./isObjectLike":108}],58:[function(require,module,exports){
2153
- var arrayCopy = require('./arrayCopy'),
2154
- isArguments = require('../lang/isArguments'),
2155
- isArray = require('../lang/isArray'),
2156
- isArrayLike = require('./isArrayLike'),
2157
- isPlainObject = require('../lang/isPlainObject'),
2158
- isTypedArray = require('../lang/isTypedArray'),
2159
- toPlainObject = require('../lang/toPlainObject');
2160
-
2161
- /**
2162
- * A specialized version of `baseMerge` for arrays and objects which performs
2163
- * deep merges and tracks traversed objects enabling objects with circular
2164
- * references to be merged.
2165
- *
2166
- * @private
2167
- * @param {Object} object The destination object.
2168
- * @param {Object} source The source object.
2169
- * @param {string} key The key of the value to merge.
2170
- * @param {Function} mergeFunc The function to merge values.
2171
- * @param {Function} [customizer] The function to customize merged values.
2172
- * @param {Array} [stackA=[]] Tracks traversed source objects.
2173
- * @param {Array} [stackB=[]] Associates values with source counterparts.
2174
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2175
- */
2176
- function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
2177
- var length = stackA.length,
2178
- srcValue = source[key];
2179
-
2180
- while (length--) {
2181
- if (stackA[length] == srcValue) {
2182
- object[key] = stackB[length];
2183
- return;
2184
- }
2185
- }
2186
- var value = object[key],
2187
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
2188
- isCommon = result === undefined;
2189
-
2190
- if (isCommon) {
2191
- result = srcValue;
2192
- if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
2193
- result = isArray(value)
2194
- ? value
2195
- : (isArrayLike(value) ? arrayCopy(value) : []);
2196
- }
2197
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2198
- result = isArguments(value)
2199
- ? toPlainObject(value)
2200
- : (isPlainObject(value) ? value : {});
2201
- }
2202
- else {
2203
- isCommon = false;
2204
- }
2205
- }
2206
- // Add the source value to the stack of traversed objects and associate
2207
- // it with its merged value.
2208
- stackA.push(srcValue);
2209
- stackB.push(result);
2210
-
2211
- if (isCommon) {
2212
- // Recursively merge objects and arrays (susceptible to call stack limits).
2213
- object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
2214
- } else if (result === result ? (result !== value) : (value === value)) {
2215
- object[key] = result;
2216
- }
2217
- }
2218
-
2219
- module.exports = baseMergeDeep;
2220
-
2221
- },{"../lang/isArguments":126,"../lang/isArray":127,"../lang/isPlainObject":132,"../lang/isTypedArray":134,"../lang/toPlainObject":136,"./arrayCopy":24,"./isArrayLike":102}],59:[function(require,module,exports){
2222
- /**
2223
- * The base implementation of `_.property` without support for deep paths.
2224
- *
2225
- * @private
2226
- * @param {string} key The key of the property to get.
2227
- * @returns {Function} Returns the new function.
2228
- */
2229
- function baseProperty(key) {
2230
- return function(object) {
2231
- return object == null ? undefined : object[key];
2232
- };
2233
- }
2234
-
2235
- module.exports = baseProperty;
2236
-
2237
- },{}],60:[function(require,module,exports){
2238
- var baseGet = require('./baseGet'),
2239
- toPath = require('./toPath');
2240
-
2241
- /**
2242
- * A specialized version of `baseProperty` which supports deep paths.
2243
- *
2244
- * @private
2245
- * @param {Array|string} path The path of the property to get.
2246
- * @returns {Function} Returns the new function.
2247
- */
2248
- function basePropertyDeep(path) {
2249
- var pathKey = (path + '');
2250
- path = toPath(path);
2251
- return function(object) {
2252
- return baseGet(object, path, pathKey);
2253
- };
2254
- }
2255
-
2256
- module.exports = basePropertyDeep;
2257
-
2258
- },{"./baseGet":48,"./toPath":122}],61:[function(require,module,exports){
2259
- /**
2260
- * The base implementation of `_.reduce` and `_.reduceRight` without support
2261
- * for callback shorthands and `this` binding, which iterates over `collection`
2262
- * using the provided `eachFunc`.
2263
- *
2264
- * @private
2265
- * @param {Array|Object|string} collection The collection to iterate over.
2266
- * @param {Function} iteratee The function invoked per iteration.
2267
- * @param {*} accumulator The initial value.
2268
- * @param {boolean} initFromCollection Specify using the first or last element
2269
- * of `collection` as the initial value.
2270
- * @param {Function} eachFunc The function to iterate over `collection`.
2271
- * @returns {*} Returns the accumulated value.
2272
- */
2273
- function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
2274
- eachFunc(collection, function(value, index, collection) {
2275
- accumulator = initFromCollection
2276
- ? (initFromCollection = false, value)
2277
- : iteratee(accumulator, value, index, collection);
2278
- });
2279
- return accumulator;
2280
- }
2281
-
2282
- module.exports = baseReduce;
2283
-
2284
- },{}],62:[function(require,module,exports){
2285
- var identity = require('../utility/identity'),
2286
- metaMap = require('./metaMap');
2287
-
2288
- /**
2289
- * The base implementation of `setData` without support for hot loop detection.
2290
- *
2291
- * @private
2292
- * @param {Function} func The function to associate metadata with.
2293
- * @param {*} data The metadata.
2294
- * @returns {Function} Returns `func`.
2295
- */
2296
- var baseSetData = !metaMap ? identity : function(func, data) {
2297
- metaMap.set(func, data);
2298
- return func;
2299
- };
2300
-
2301
- module.exports = baseSetData;
2302
-
2303
- },{"../utility/identity":148,"./metaMap":112}],63:[function(require,module,exports){
2304
- /**
2305
- * The base implementation of `_.slice` without an iteratee call guard.
2306
- *
2307
- * @private
2308
- * @param {Array} array The array to slice.
2309
- * @param {number} [start=0] The start position.
2310
- * @param {number} [end=array.length] The end position.
2311
- * @returns {Array} Returns the slice of `array`.
2312
- */
2313
- function baseSlice(array, start, end) {
2314
- var index = -1,
2315
- length = array.length;
2316
-
2317
- start = start == null ? 0 : (+start || 0);
2318
- if (start < 0) {
2319
- start = -start > length ? 0 : (length + start);
2320
- }
2321
- end = (end === undefined || end > length) ? length : (+end || 0);
2322
- if (end < 0) {
2323
- end += length;
2324
- }
2325
- length = start > end ? 0 : ((end - start) >>> 0);
2326
- start >>>= 0;
2327
-
2328
- var result = Array(length);
2329
- while (++index < length) {
2330
- result[index] = array[index + start];
2331
- }
2332
- return result;
2333
- }
2334
-
2335
- module.exports = baseSlice;
2336
-
2337
- },{}],64:[function(require,module,exports){
2338
- /**
2339
- * The base implementation of `_.sortBy` which uses `comparer` to define
2340
- * the sort order of `array` and replaces criteria objects with their
2341
- * corresponding values.
2342
- *
2343
- * @private
2344
- * @param {Array} array The array to sort.
2345
- * @param {Function} comparer The function to define sort order.
2346
- * @returns {Array} Returns `array`.
2347
- */
2348
- function baseSortBy(array, comparer) {
2349
- var length = array.length;
2350
-
2351
- array.sort(comparer);
2352
- while (length--) {
2353
- array[length] = array[length].value;
2354
- }
2355
- return array;
2356
- }
2357
-
2358
- module.exports = baseSortBy;
2359
-
2360
- },{}],65:[function(require,module,exports){
2361
- var arrayMap = require('./arrayMap'),
2362
- baseCallback = require('./baseCallback'),
2363
- baseMap = require('./baseMap'),
2364
- baseSortBy = require('./baseSortBy'),
2365
- compareMultiple = require('./compareMultiple');
2366
-
2367
- /**
2368
- * The base implementation of `_.sortByOrder` without param guards.
2369
- *
2370
- * @private
2371
- * @param {Array|Object|string} collection The collection to iterate over.
2372
- * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
2373
- * @param {boolean[]} orders The sort orders of `iteratees`.
2374
- * @returns {Array} Returns the new sorted array.
2375
- */
2376
- function baseSortByOrder(collection, iteratees, orders) {
2377
- var index = -1;
2378
-
2379
- iteratees = arrayMap(iteratees, function(iteratee) { return baseCallback(iteratee); });
2380
-
2381
- var result = baseMap(collection, function(value) {
2382
- var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); });
2383
- return { 'criteria': criteria, 'index': ++index, 'value': value };
2384
- });
2385
-
2386
- return baseSortBy(result, function(object, other) {
2387
- return compareMultiple(object, other, orders);
2388
- });
2389
- }
2390
-
2391
- module.exports = baseSortByOrder;
2392
-
2393
- },{"./arrayMap":27,"./baseCallback":35,"./baseMap":54,"./baseSortBy":64,"./compareMultiple":76}],66:[function(require,module,exports){
2394
- var baseEach = require('./baseEach');
2395
-
2396
- /**
2397
- * The base implementation of `_.sum` without support for callback shorthands
2398
- * and `this` binding.
2399
- *
2400
- * @private
2401
- * @param {Array|Object|string} collection The collection to iterate over.
2402
- * @param {Function} iteratee The function invoked per iteration.
2403
- * @returns {number} Returns the sum.
2404
- */
2405
- function baseSum(collection, iteratee) {
2406
- var result = 0;
2407
- baseEach(collection, function(value, index, collection) {
2408
- result += +iteratee(value, index, collection) || 0;
2409
- });
2410
- return result;
2411
- }
2412
-
2413
- module.exports = baseSum;
2414
-
2415
- },{"./baseEach":40}],67:[function(require,module,exports){
2416
- /**
2417
- * Converts `value` to a string if it's not one. An empty string is returned
2418
- * for `null` or `undefined` values.
2419
- *
2420
- * @private
2421
- * @param {*} value The value to process.
2422
- * @returns {string} Returns the string.
2423
- */
2424
- function baseToString(value) {
2425
- return value == null ? '' : (value + '');
2426
- }
2427
-
2428
- module.exports = baseToString;
2429
-
2430
- },{}],68:[function(require,module,exports){
2431
- /**
2432
- * The base implementation of `_.values` and `_.valuesIn` which creates an
2433
- * array of `object` property values corresponding to the property names
2434
- * of `props`.
2435
- *
2436
- * @private
2437
- * @param {Object} object The object to query.
2438
- * @param {Array} props The property names to get values for.
2439
- * @returns {Object} Returns the array of property values.
2440
- */
2441
- function baseValues(object, props) {
2442
- var index = -1,
2443
- length = props.length,
2444
- result = Array(length);
2445
-
2446
- while (++index < length) {
2447
- result[index] = object[props[index]];
2448
- }
2449
- return result;
2450
- }
2451
-
2452
- module.exports = baseValues;
2453
-
2454
- },{}],69:[function(require,module,exports){
2455
- var binaryIndexBy = require('./binaryIndexBy'),
2456
- identity = require('../utility/identity');
2457
-
2458
- /** Used as references for the maximum length and index of an array. */
2459
- var MAX_ARRAY_LENGTH = 4294967295,
2460
- HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
2461
-
2462
- /**
2463
- * Performs a binary search of `array` to determine the index at which `value`
2464
- * should be inserted into `array` in order to maintain its sort order.
2465
- *
2466
- * @private
2467
- * @param {Array} array The sorted array to inspect.
2468
- * @param {*} value The value to evaluate.
2469
- * @param {boolean} [retHighest] Specify returning the highest qualified index.
2470
- * @returns {number} Returns the index at which `value` should be inserted
2471
- * into `array`.
2472
- */
2473
- function binaryIndex(array, value, retHighest) {
2474
- var low = 0,
2475
- high = array ? array.length : low;
2476
-
2477
- if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
2478
- while (low < high) {
2479
- var mid = (low + high) >>> 1,
2480
- computed = array[mid];
2481
-
2482
- if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
2483
- low = mid + 1;
2484
- } else {
2485
- high = mid;
2486
- }
2487
- }
2488
- return high;
2489
- }
2490
- return binaryIndexBy(array, value, identity, retHighest);
2491
- }
2492
-
2493
- module.exports = binaryIndex;
2494
-
2495
- },{"../utility/identity":148,"./binaryIndexBy":70}],70:[function(require,module,exports){
2496
- /* Native method references for those with the same name as other `lodash` methods. */
2497
- var nativeFloor = Math.floor,
2498
- nativeMin = Math.min;
2499
-
2500
- /** Used as references for the maximum length and index of an array. */
2501
- var MAX_ARRAY_LENGTH = 4294967295,
2502
- MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
2503
-
2504
- /**
2505
- * This function is like `binaryIndex` except that it invokes `iteratee` for
2506
- * `value` and each element of `array` to compute their sort ranking. The
2507
- * iteratee is invoked with one argument; (value).
2508
- *
2509
- * @private
2510
- * @param {Array} array The sorted array to inspect.
2511
- * @param {*} value The value to evaluate.
2512
- * @param {Function} iteratee The function invoked per iteration.
2513
- * @param {boolean} [retHighest] Specify returning the highest qualified index.
2514
- * @returns {number} Returns the index at which `value` should be inserted
2515
- * into `array`.
2516
- */
2517
- function binaryIndexBy(array, value, iteratee, retHighest) {
2518
- value = iteratee(value);
2519
-
2520
- var low = 0,
2521
- high = array ? array.length : 0,
2522
- valIsNaN = value !== value,
2523
- valIsNull = value === null,
2524
- valIsUndef = value === undefined;
2525
-
2526
- while (low < high) {
2527
- var mid = nativeFloor((low + high) / 2),
2528
- computed = iteratee(array[mid]),
2529
- isDef = computed !== undefined,
2530
- isReflexive = computed === computed;
2531
-
2532
- if (valIsNaN) {
2533
- var setLow = isReflexive || retHighest;
2534
- } else if (valIsNull) {
2535
- setLow = isReflexive && isDef && (retHighest || computed != null);
2536
- } else if (valIsUndef) {
2537
- setLow = isReflexive && (retHighest || isDef);
2538
- } else if (computed == null) {
2539
- setLow = false;
2540
- } else {
2541
- setLow = retHighest ? (computed <= value) : (computed < value);
2542
- }
2543
- if (setLow) {
2544
- low = mid + 1;
2545
- } else {
2546
- high = mid;
2547
- }
2548
- }
2549
- return nativeMin(high, MAX_ARRAY_INDEX);
2550
- }
2551
-
2552
- module.exports = binaryIndexBy;
2553
-
2554
- },{}],71:[function(require,module,exports){
2555
- var identity = require('../utility/identity');
2556
-
2557
- /**
2558
- * A specialized version of `baseCallback` which only supports `this` binding
2559
- * and specifying the number of arguments to provide to `func`.
2560
- *
2561
- * @private
2562
- * @param {Function} func The function to bind.
2563
- * @param {*} thisArg The `this` binding of `func`.
2564
- * @param {number} [argCount] The number of arguments to provide to `func`.
2565
- * @returns {Function} Returns the callback.
2566
- */
2567
- function bindCallback(func, thisArg, argCount) {
2568
- if (typeof func != 'function') {
2569
- return identity;
2570
- }
2571
- if (thisArg === undefined) {
2572
- return func;
2573
- }
2574
- switch (argCount) {
2575
- case 1: return function(value) {
2576
- return func.call(thisArg, value);
2577
- };
2578
- case 3: return function(value, index, collection) {
2579
- return func.call(thisArg, value, index, collection);
2580
- };
2581
- case 4: return function(accumulator, value, index, collection) {
2582
- return func.call(thisArg, accumulator, value, index, collection);
2583
- };
2584
- case 5: return function(value, other, key, object, source) {
2585
- return func.call(thisArg, value, other, key, object, source);
2586
- };
2587
- }
2588
- return function() {
2589
- return func.apply(thisArg, arguments);
2590
- };
2591
- }
2592
-
2593
- module.exports = bindCallback;
2594
-
2595
- },{"../utility/identity":148}],72:[function(require,module,exports){
2596
- var isObject = require('../lang/isObject');
2597
-
2598
- /**
2599
- * Checks if `value` is in `cache` mimicking the return signature of
2600
- * `_.indexOf` by returning `0` if the value is found, else `-1`.
2601
- *
2602
- * @private
2603
- * @param {Object} cache The cache to search.
2604
- * @param {*} value The value to search for.
2605
- * @returns {number} Returns `0` if `value` is found, else `-1`.
2606
- */
2607
- function cacheIndexOf(cache, value) {
2608
- var data = cache.data,
2609
- result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
2610
-
2611
- return result ? 0 : -1;
2612
- }
2613
-
2614
- module.exports = cacheIndexOf;
2615
-
2616
- },{"../lang/isObject":131}],73:[function(require,module,exports){
2617
- var isObject = require('../lang/isObject');
2618
-
2619
- /**
2620
- * Adds `value` to the cache.
2621
- *
2622
- * @private
2623
- * @name push
2624
- * @memberOf SetCache
2625
- * @param {*} value The value to cache.
2626
- */
2627
- function cachePush(value) {
2628
- var data = this.data;
2629
- if (typeof value == 'string' || isObject(value)) {
2630
- data.set.add(value);
2631
- } else {
2632
- data.hash[value] = true;
2633
- }
2634
- }
2635
-
2636
- module.exports = cachePush;
2637
-
2638
- },{"../lang/isObject":131}],74:[function(require,module,exports){
2639
- /**
2640
- * Used by `_.trim` and `_.trimLeft` to get the index of the first character
2641
- * of `string` that is not found in `chars`.
2642
- *
2643
- * @private
2644
- * @param {string} string The string to inspect.
2645
- * @param {string} chars The characters to find.
2646
- * @returns {number} Returns the index of the first character not found in `chars`.
2647
- */
2648
- function charsLeftIndex(string, chars) {
2649
- var index = -1,
2650
- length = string.length;
2651
-
2652
- while (++index < length && chars.indexOf(string.charAt(index)) > -1) {}
2653
- return index;
2654
- }
2655
-
2656
- module.exports = charsLeftIndex;
2657
-
2658
- },{}],75:[function(require,module,exports){
2659
- /**
2660
- * Used by `_.trim` and `_.trimRight` to get the index of the last character
2661
- * of `string` that is not found in `chars`.
2662
- *
2663
- * @private
2664
- * @param {string} string The string to inspect.
2665
- * @param {string} chars The characters to find.
2666
- * @returns {number} Returns the index of the last character not found in `chars`.
2667
- */
2668
- function charsRightIndex(string, chars) {
2669
- var index = string.length;
2670
-
2671
- while (index-- && chars.indexOf(string.charAt(index)) > -1) {}
2672
- return index;
2673
- }
2674
-
2675
- module.exports = charsRightIndex;
2676
-
2677
- },{}],76:[function(require,module,exports){
2678
- var baseCompareAscending = require('./baseCompareAscending');
2679
-
2680
- /**
2681
- * Used by `_.sortByOrder` to compare multiple properties of a value to another
2682
- * and stable sort them.
2683
- *
2684
- * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise,
2685
- * a value is sorted in ascending order if its corresponding order is "asc", and
2686
- * descending if "desc".
2687
- *
2688
- * @private
2689
- * @param {Object} object The object to compare.
2690
- * @param {Object} other The other object to compare.
2691
- * @param {boolean[]} orders The order to sort by for each property.
2692
- * @returns {number} Returns the sort order indicator for `object`.
2693
- */
2694
- function compareMultiple(object, other, orders) {
2695
- var index = -1,
2696
- objCriteria = object.criteria,
2697
- othCriteria = other.criteria,
2698
- length = objCriteria.length,
2699
- ordersLength = orders.length;
2700
-
2701
- while (++index < length) {
2702
- var result = baseCompareAscending(objCriteria[index], othCriteria[index]);
2703
- if (result) {
2704
- if (index >= ordersLength) {
2705
- return result;
2706
- }
2707
- var order = orders[index];
2708
- return result * ((order === 'asc' || order === true) ? 1 : -1);
2709
- }
2710
- }
2711
- // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
2712
- // that causes it, under certain circumstances, to provide the same value for
2713
- // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
2714
- // for more details.
2715
- //
2716
- // This also ensures a stable sort in V8 and other engines.
2717
- // See https://code.google.com/p/v8/issues/detail?id=90 for more details.
2718
- return object.index - other.index;
2719
- }
2720
-
2721
- module.exports = compareMultiple;
2722
-
2723
- },{"./baseCompareAscending":36}],77:[function(require,module,exports){
2724
- /* Native method references for those with the same name as other `lodash` methods. */
2725
- var nativeMax = Math.max;
2726
-
2727
- /**
2728
- * Creates an array that is the composition of partially applied arguments,
2729
- * placeholders, and provided arguments into a single array of arguments.
2730
- *
2731
- * @private
2732
- * @param {Array|Object} args The provided arguments.
2733
- * @param {Array} partials The arguments to prepend to those provided.
2734
- * @param {Array} holders The `partials` placeholder indexes.
2735
- * @returns {Array} Returns the new array of composed arguments.
2736
- */
2737
- function composeArgs(args, partials, holders) {
2738
- var holdersLength = holders.length,
2739
- argsIndex = -1,
2740
- argsLength = nativeMax(args.length - holdersLength, 0),
2741
- leftIndex = -1,
2742
- leftLength = partials.length,
2743
- result = Array(leftLength + argsLength);
2744
-
2745
- while (++leftIndex < leftLength) {
2746
- result[leftIndex] = partials[leftIndex];
2747
- }
2748
- while (++argsIndex < holdersLength) {
2749
- result[holders[argsIndex]] = args[argsIndex];
2750
- }
2751
- while (argsLength--) {
2752
- result[leftIndex++] = args[argsIndex++];
2753
- }
2754
- return result;
2755
- }
2756
-
2757
- module.exports = composeArgs;
2758
-
2759
- },{}],78:[function(require,module,exports){
2760
- /* Native method references for those with the same name as other `lodash` methods. */
2761
- var nativeMax = Math.max;
2762
-
2763
- /**
2764
- * This function is like `composeArgs` except that the arguments composition
2765
- * is tailored for `_.partialRight`.
2766
- *
2767
- * @private
2768
- * @param {Array|Object} args The provided arguments.
2769
- * @param {Array} partials The arguments to append to those provided.
2770
- * @param {Array} holders The `partials` placeholder indexes.
2771
- * @returns {Array} Returns the new array of composed arguments.
2772
- */
2773
- function composeArgsRight(args, partials, holders) {
2774
- var holdersIndex = -1,
2775
- holdersLength = holders.length,
2776
- argsIndex = -1,
2777
- argsLength = nativeMax(args.length - holdersLength, 0),
2778
- rightIndex = -1,
2779
- rightLength = partials.length,
2780
- result = Array(argsLength + rightLength);
2781
-
2782
- while (++argsIndex < argsLength) {
2783
- result[argsIndex] = args[argsIndex];
2784
- }
2785
- var offset = argsIndex;
2786
- while (++rightIndex < rightLength) {
2787
- result[offset + rightIndex] = partials[rightIndex];
2788
- }
2789
- while (++holdersIndex < holdersLength) {
2790
- result[offset + holders[holdersIndex]] = args[argsIndex++];
2791
- }
2792
- return result;
2793
- }
2794
-
2795
- module.exports = composeArgsRight;
2796
-
2797
- },{}],79:[function(require,module,exports){
2798
- var bindCallback = require('./bindCallback'),
2799
- isIterateeCall = require('./isIterateeCall'),
2800
- restParam = require('../function/restParam');
2801
-
2802
- /**
2803
- * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
2804
- *
2805
- * @private
2806
- * @param {Function} assigner The function to assign values.
2807
- * @returns {Function} Returns the new assigner function.
2808
- */
2809
- function createAssigner(assigner) {
2810
- return restParam(function(object, sources) {
2811
- var index = -1,
2812
- length = object == null ? 0 : sources.length,
2813
- customizer = length > 2 ? sources[length - 2] : undefined,
2814
- guard = length > 2 ? sources[2] : undefined,
2815
- thisArg = length > 1 ? sources[length - 1] : undefined;
2816
-
2817
- if (typeof customizer == 'function') {
2818
- customizer = bindCallback(customizer, thisArg, 5);
2819
- length -= 2;
2820
- } else {
2821
- customizer = typeof thisArg == 'function' ? thisArg : undefined;
2822
- length -= (customizer ? 1 : 0);
2823
- }
2824
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
2825
- customizer = length < 3 ? undefined : customizer;
2826
- length = 1;
2827
- }
2828
- while (++index < length) {
2829
- var source = sources[index];
2830
- if (source) {
2831
- assigner(object, source, customizer);
2832
- }
2833
- }
2834
- return object;
2835
- });
2836
- }
2837
-
2838
- module.exports = createAssigner;
2839
-
2840
- },{"../function/restParam":20,"./bindCallback":71,"./isIterateeCall":104}],80:[function(require,module,exports){
2841
- var getLength = require('./getLength'),
2842
- isLength = require('./isLength'),
2843
- toObject = require('./toObject');
2844
-
2845
- /**
2846
- * Creates a `baseEach` or `baseEachRight` function.
2847
- *
2848
- * @private
2849
- * @param {Function} eachFunc The function to iterate over a collection.
2850
- * @param {boolean} [fromRight] Specify iterating from right to left.
2851
- * @returns {Function} Returns the new base function.
2852
- */
2853
- function createBaseEach(eachFunc, fromRight) {
2854
- return function(collection, iteratee) {
2855
- var length = collection ? getLength(collection) : 0;
2856
- if (!isLength(length)) {
2857
- return eachFunc(collection, iteratee);
2858
- }
2859
- var index = fromRight ? length : -1,
2860
- iterable = toObject(collection);
2861
-
2862
- while ((fromRight ? index-- : ++index < length)) {
2863
- if (iteratee(iterable[index], index, iterable) === false) {
2864
- break;
2865
- }
2866
- }
2867
- return collection;
2868
- };
2869
- }
2870
-
2871
- module.exports = createBaseEach;
2872
-
2873
- },{"./getLength":98,"./isLength":107,"./toObject":121}],81:[function(require,module,exports){
2874
- var toObject = require('./toObject');
2875
-
2876
- /**
2877
- * Creates a base function for `_.forIn` or `_.forInRight`.
2878
- *
2879
- * @private
2880
- * @param {boolean} [fromRight] Specify iterating from right to left.
2881
- * @returns {Function} Returns the new base function.
2882
- */
2883
- function createBaseFor(fromRight) {
2884
- return function(object, iteratee, keysFunc) {
2885
- var iterable = toObject(object),
2886
- props = keysFunc(object),
2887
- length = props.length,
2888
- index = fromRight ? length : -1;
2889
-
2890
- while ((fromRight ? index-- : ++index < length)) {
2891
- var key = props[index];
2892
- if (iteratee(iterable[key], key, iterable) === false) {
2893
- break;
2894
- }
2895
- }
2896
- return object;
2897
- };
2898
- }
2899
-
2900
- module.exports = createBaseFor;
2901
-
2902
- },{"./toObject":121}],82:[function(require,module,exports){
2903
- (function (global){
2904
- var createCtorWrapper = require('./createCtorWrapper');
2905
-
2906
- /**
2907
- * Creates a function that wraps `func` and invokes it with the `this`
2908
- * binding of `thisArg`.
2909
- *
2910
- * @private
2911
- * @param {Function} func The function to bind.
2912
- * @param {*} [thisArg] The `this` binding of `func`.
2913
- * @returns {Function} Returns the new bound function.
2914
- */
2915
- function createBindWrapper(func, thisArg) {
2916
- var Ctor = createCtorWrapper(func);
2917
-
2918
- function wrapper() {
2919
- var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
2920
- return fn.apply(thisArg, arguments);
2921
- }
2922
- return wrapper;
2923
- }
2924
-
2925
- module.exports = createBindWrapper;
2926
-
2927
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2928
- },{"./createCtorWrapper":84}],83:[function(require,module,exports){
2929
- (function (global){
2930
- var SetCache = require('./SetCache'),
2931
- getNative = require('./getNative');
2932
-
2933
- /** Native method references. */
2934
- var Set = getNative(global, 'Set');
2935
-
2936
- /* Native method references for those with the same name as other `lodash` methods. */
2937
- var nativeCreate = getNative(Object, 'create');
2938
-
2939
- /**
2940
- * Creates a `Set` cache object to optimize linear searches of large arrays.
2941
- *
2942
- * @private
2943
- * @param {Array} [values] The values to cache.
2944
- * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
2945
- */
2946
- function createCache(values) {
2947
- return (nativeCreate && Set) ? new SetCache(values) : null;
2948
- }
2949
-
2950
- module.exports = createCache;
2951
-
2952
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2953
- },{"./SetCache":23,"./getNative":100}],84:[function(require,module,exports){
2954
- var baseCreate = require('./baseCreate'),
2955
- isObject = require('../lang/isObject');
2956
-
2957
- /**
2958
- * Creates a function that produces an instance of `Ctor` regardless of
2959
- * whether it was invoked as part of a `new` expression or by `call` or `apply`.
2960
- *
2961
- * @private
2962
- * @param {Function} Ctor The constructor to wrap.
2963
- * @returns {Function} Returns the new wrapped function.
2964
- */
2965
- function createCtorWrapper(Ctor) {
2966
- return function() {
2967
- // Use a `switch` statement to work with class constructors.
2968
- // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
2969
- // for more details.
2970
- var args = arguments;
2971
- switch (args.length) {
2972
- case 0: return new Ctor;
2973
- case 1: return new Ctor(args[0]);
2974
- case 2: return new Ctor(args[0], args[1]);
2975
- case 3: return new Ctor(args[0], args[1], args[2]);
2976
- case 4: return new Ctor(args[0], args[1], args[2], args[3]);
2977
- case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
2978
- case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
2979
- case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
2980
- }
2981
- var thisBinding = baseCreate(Ctor.prototype),
2982
- result = Ctor.apply(thisBinding, args);
2983
-
2984
- // Mimic the constructor's `return` behavior.
2985
- // See https://es5.github.io/#x13.2.2 for more details.
2986
- return isObject(result) ? result : thisBinding;
2987
- };
2988
- }
2989
-
2990
- module.exports = createCtorWrapper;
2991
-
2992
- },{"../lang/isObject":131,"./baseCreate":38}],85:[function(require,module,exports){
2993
- var restParam = require('../function/restParam');
2994
-
2995
- /**
2996
- * Creates a `_.defaults` or `_.defaultsDeep` function.
2997
- *
2998
- * @private
2999
- * @param {Function} assigner The function to assign values.
3000
- * @param {Function} customizer The function to customize assigned values.
3001
- * @returns {Function} Returns the new defaults function.
3002
- */
3003
- function createDefaults(assigner, customizer) {
3004
- return restParam(function(args) {
3005
- var object = args[0];
3006
- if (object == null) {
3007
- return object;
3008
- }
3009
- args.push(customizer);
3010
- return assigner.apply(undefined, args);
3011
- });
3012
- }
3013
-
3014
- module.exports = createDefaults;
3015
-
3016
- },{"../function/restParam":20}],86:[function(require,module,exports){
3017
- var baseCallback = require('./baseCallback'),
3018
- baseFind = require('./baseFind'),
3019
- baseFindIndex = require('./baseFindIndex'),
3020
- isArray = require('../lang/isArray');
3021
-
3022
- /**
3023
- * Creates a `_.find` or `_.findLast` function.
3024
- *
3025
- * @private
3026
- * @param {Function} eachFunc The function to iterate over a collection.
3027
- * @param {boolean} [fromRight] Specify iterating from right to left.
3028
- * @returns {Function} Returns the new find function.
3029
- */
3030
- function createFind(eachFunc, fromRight) {
3031
- return function(collection, predicate, thisArg) {
3032
- predicate = baseCallback(predicate, thisArg, 3);
3033
- if (isArray(collection)) {
3034
- var index = baseFindIndex(collection, predicate, fromRight);
3035
- return index > -1 ? collection[index] : undefined;
3036
- }
3037
- return baseFind(collection, predicate, eachFunc);
3038
- };
3039
- }
3040
-
3041
- module.exports = createFind;
3042
-
3043
- },{"../lang/isArray":127,"./baseCallback":35,"./baseFind":42,"./baseFindIndex":43}],87:[function(require,module,exports){
3044
- var baseCallback = require('./baseCallback'),
3045
- baseFindIndex = require('./baseFindIndex');
3046
-
3047
- /**
3048
- * Creates a `_.findIndex` or `_.findLastIndex` function.
3049
- *
3050
- * @private
3051
- * @param {boolean} [fromRight] Specify iterating from right to left.
3052
- * @returns {Function} Returns the new find function.
3053
- */
3054
- function createFindIndex(fromRight) {
3055
- return function(array, predicate, thisArg) {
3056
- if (!(array && array.length)) {
3057
- return -1;
3058
- }
3059
- predicate = baseCallback(predicate, thisArg, 3);
3060
- return baseFindIndex(array, predicate, fromRight);
3061
- };
3062
- }
3063
-
3064
- module.exports = createFindIndex;
3065
-
3066
- },{"./baseCallback":35,"./baseFindIndex":43}],88:[function(require,module,exports){
3067
- var bindCallback = require('./bindCallback'),
3068
- isArray = require('../lang/isArray');
3069
-
3070
- /**
3071
- * Creates a function for `_.forEach` or `_.forEachRight`.
3072
- *
3073
- * @private
3074
- * @param {Function} arrayFunc The function to iterate over an array.
3075
- * @param {Function} eachFunc The function to iterate over a collection.
3076
- * @returns {Function} Returns the new each function.
3077
- */
3078
- function createForEach(arrayFunc, eachFunc) {
3079
- return function(collection, iteratee, thisArg) {
3080
- return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
3081
- ? arrayFunc(collection, iteratee)
3082
- : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
3083
- };
3084
- }
3085
-
3086
- module.exports = createForEach;
3087
-
3088
- },{"../lang/isArray":127,"./bindCallback":71}],89:[function(require,module,exports){
3089
- (function (global){
3090
- var arrayCopy = require('./arrayCopy'),
3091
- composeArgs = require('./composeArgs'),
3092
- composeArgsRight = require('./composeArgsRight'),
3093
- createCtorWrapper = require('./createCtorWrapper'),
3094
- isLaziable = require('./isLaziable'),
3095
- reorder = require('./reorder'),
3096
- replaceHolders = require('./replaceHolders'),
3097
- setData = require('./setData');
3098
-
3099
- /** Used to compose bitmasks for wrapper metadata. */
3100
- var BIND_FLAG = 1,
3101
- BIND_KEY_FLAG = 2,
3102
- CURRY_BOUND_FLAG = 4,
3103
- CURRY_FLAG = 8,
3104
- CURRY_RIGHT_FLAG = 16,
3105
- PARTIAL_FLAG = 32,
3106
- PARTIAL_RIGHT_FLAG = 64,
3107
- ARY_FLAG = 128;
3108
-
3109
- /* Native method references for those with the same name as other `lodash` methods. */
3110
- var nativeMax = Math.max;
3111
-
3112
- /**
3113
- * Creates a function that wraps `func` and invokes it with optional `this`
3114
- * binding of, partial application, and currying.
3115
- *
3116
- * @private
3117
- * @param {Function|string} func The function or method name to reference.
3118
- * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
3119
- * @param {*} [thisArg] The `this` binding of `func`.
3120
- * @param {Array} [partials] The arguments to prepend to those provided to the new function.
3121
- * @param {Array} [holders] The `partials` placeholder indexes.
3122
- * @param {Array} [partialsRight] The arguments to append to those provided to the new function.
3123
- * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
3124
- * @param {Array} [argPos] The argument positions of the new function.
3125
- * @param {number} [ary] The arity cap of `func`.
3126
- * @param {number} [arity] The arity of `func`.
3127
- * @returns {Function} Returns the new wrapped function.
3128
- */
3129
- function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
3130
- var isAry = bitmask & ARY_FLAG,
3131
- isBind = bitmask & BIND_FLAG,
3132
- isBindKey = bitmask & BIND_KEY_FLAG,
3133
- isCurry = bitmask & CURRY_FLAG,
3134
- isCurryBound = bitmask & CURRY_BOUND_FLAG,
3135
- isCurryRight = bitmask & CURRY_RIGHT_FLAG,
3136
- Ctor = isBindKey ? undefined : createCtorWrapper(func);
3137
-
3138
- function wrapper() {
3139
- // Avoid `arguments` object use disqualifying optimizations by
3140
- // converting it to an array before providing it to other functions.
3141
- var length = arguments.length,
3142
- index = length,
3143
- args = Array(length);
3144
-
3145
- while (index--) {
3146
- args[index] = arguments[index];
3147
- }
3148
- if (partials) {
3149
- args = composeArgs(args, partials, holders);
3150
- }
3151
- if (partialsRight) {
3152
- args = composeArgsRight(args, partialsRight, holdersRight);
3153
- }
3154
- if (isCurry || isCurryRight) {
3155
- var placeholder = wrapper.placeholder,
3156
- argsHolders = replaceHolders(args, placeholder);
3157
-
3158
- length -= argsHolders.length;
3159
- if (length < arity) {
3160
- var newArgPos = argPos ? arrayCopy(argPos) : undefined,
3161
- newArity = nativeMax(arity - length, 0),
3162
- newsHolders = isCurry ? argsHolders : undefined,
3163
- newHoldersRight = isCurry ? undefined : argsHolders,
3164
- newPartials = isCurry ? args : undefined,
3165
- newPartialsRight = isCurry ? undefined : args;
3166
-
3167
- bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
3168
- bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
3169
-
3170
- if (!isCurryBound) {
3171
- bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
3172
- }
3173
- var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],
3174
- result = createHybridWrapper.apply(undefined, newData);
3175
-
3176
- if (isLaziable(func)) {
3177
- setData(result, newData);
3178
- }
3179
- result.placeholder = placeholder;
3180
- return result;
3181
- }
3182
- }
3183
- var thisBinding = isBind ? thisArg : this,
3184
- fn = isBindKey ? thisBinding[func] : func;
3185
-
3186
- if (argPos) {
3187
- args = reorder(args, argPos);
3188
- }
3189
- if (isAry && ary < args.length) {
3190
- args.length = ary;
3191
- }
3192
- if (this && this !== global && this instanceof wrapper) {
3193
- fn = Ctor || createCtorWrapper(func);
3194
- }
3195
- return fn.apply(thisBinding, args);
3196
- }
3197
- return wrapper;
3198
- }
3199
-
3200
- module.exports = createHybridWrapper;
3201
-
3202
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3203
- },{"./arrayCopy":24,"./composeArgs":77,"./composeArgsRight":78,"./createCtorWrapper":84,"./isLaziable":106,"./reorder":116,"./replaceHolders":117,"./setData":118}],90:[function(require,module,exports){
3204
- (function (global){
3205
- var createCtorWrapper = require('./createCtorWrapper');
3206
-
3207
- /** Used to compose bitmasks for wrapper metadata. */
3208
- var BIND_FLAG = 1;
3209
-
3210
- /**
3211
- * Creates a function that wraps `func` and invokes it with the optional `this`
3212
- * binding of `thisArg` and the `partials` prepended to those provided to
3213
- * the wrapper.
3214
- *
3215
- * @private
3216
- * @param {Function} func The function to partially apply arguments to.
3217
- * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
3218
- * @param {*} thisArg The `this` binding of `func`.
3219
- * @param {Array} partials The arguments to prepend to those provided to the new function.
3220
- * @returns {Function} Returns the new bound function.
3221
- */
3222
- function createPartialWrapper(func, bitmask, thisArg, partials) {
3223
- var isBind = bitmask & BIND_FLAG,
3224
- Ctor = createCtorWrapper(func);
3225
-
3226
- function wrapper() {
3227
- // Avoid `arguments` object use disqualifying optimizations by
3228
- // converting it to an array before providing it `func`.
3229
- var argsIndex = -1,
3230
- argsLength = arguments.length,
3231
- leftIndex = -1,
3232
- leftLength = partials.length,
3233
- args = Array(leftLength + argsLength);
3234
-
3235
- while (++leftIndex < leftLength) {
3236
- args[leftIndex] = partials[leftIndex];
3237
- }
3238
- while (argsLength--) {
3239
- args[leftIndex++] = arguments[++argsIndex];
3240
- }
3241
- var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
3242
- return fn.apply(isBind ? thisArg : this, args);
3243
- }
3244
- return wrapper;
3245
- }
3246
-
3247
- module.exports = createPartialWrapper;
3248
-
3249
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3250
- },{"./createCtorWrapper":84}],91:[function(require,module,exports){
3251
- var baseCallback = require('./baseCallback'),
3252
- baseReduce = require('./baseReduce'),
3253
- isArray = require('../lang/isArray');
3254
-
3255
- /**
3256
- * Creates a function for `_.reduce` or `_.reduceRight`.
3257
- *
3258
- * @private
3259
- * @param {Function} arrayFunc The function to iterate over an array.
3260
- * @param {Function} eachFunc The function to iterate over a collection.
3261
- * @returns {Function} Returns the new each function.
3262
- */
3263
- function createReduce(arrayFunc, eachFunc) {
3264
- return function(collection, iteratee, accumulator, thisArg) {
3265
- var initFromArray = arguments.length < 3;
3266
- return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
3267
- ? arrayFunc(collection, iteratee, accumulator, initFromArray)
3268
- : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
3269
- };
3270
- }
3271
-
3272
- module.exports = createReduce;
3273
-
3274
- },{"../lang/isArray":127,"./baseCallback":35,"./baseReduce":61}],92:[function(require,module,exports){
3275
- var baseSetData = require('./baseSetData'),
3276
- createBindWrapper = require('./createBindWrapper'),
3277
- createHybridWrapper = require('./createHybridWrapper'),
3278
- createPartialWrapper = require('./createPartialWrapper'),
3279
- getData = require('./getData'),
3280
- mergeData = require('./mergeData'),
3281
- setData = require('./setData');
3282
-
3283
- /** Used to compose bitmasks for wrapper metadata. */
3284
- var BIND_FLAG = 1,
3285
- BIND_KEY_FLAG = 2,
3286
- PARTIAL_FLAG = 32,
3287
- PARTIAL_RIGHT_FLAG = 64;
3288
-
3289
- /** Used as the `TypeError` message for "Functions" methods. */
3290
- var FUNC_ERROR_TEXT = 'Expected a function';
3291
-
3292
- /* Native method references for those with the same name as other `lodash` methods. */
3293
- var nativeMax = Math.max;
3294
-
3295
- /**
3296
- * Creates a function that either curries or invokes `func` with optional
3297
- * `this` binding and partially applied arguments.
3298
- *
3299
- * @private
3300
- * @param {Function|string} func The function or method name to reference.
3301
- * @param {number} bitmask The bitmask of flags.
3302
- * The bitmask may be composed of the following flags:
3303
- * 1 - `_.bind`
3304
- * 2 - `_.bindKey`
3305
- * 4 - `_.curry` or `_.curryRight` of a bound function
3306
- * 8 - `_.curry`
3307
- * 16 - `_.curryRight`
3308
- * 32 - `_.partial`
3309
- * 64 - `_.partialRight`
3310
- * 128 - `_.rearg`
3311
- * 256 - `_.ary`
3312
- * @param {*} [thisArg] The `this` binding of `func`.
3313
- * @param {Array} [partials] The arguments to be partially applied.
3314
- * @param {Array} [holders] The `partials` placeholder indexes.
3315
- * @param {Array} [argPos] The argument positions of the new function.
3316
- * @param {number} [ary] The arity cap of `func`.
3317
- * @param {number} [arity] The arity of `func`.
3318
- * @returns {Function} Returns the new wrapped function.
3319
- */
3320
- function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
3321
- var isBindKey = bitmask & BIND_KEY_FLAG;
3322
- if (!isBindKey && typeof func != 'function') {
3323
- throw new TypeError(FUNC_ERROR_TEXT);
3324
- }
3325
- var length = partials ? partials.length : 0;
3326
- if (!length) {
3327
- bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
3328
- partials = holders = undefined;
3329
- }
3330
- length -= (holders ? holders.length : 0);
3331
- if (bitmask & PARTIAL_RIGHT_FLAG) {
3332
- var partialsRight = partials,
3333
- holdersRight = holders;
3334
-
3335
- partials = holders = undefined;
3336
- }
3337
- var data = isBindKey ? undefined : getData(func),
3338
- newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
3339
-
3340
- if (data) {
3341
- mergeData(newData, data);
3342
- bitmask = newData[1];
3343
- arity = newData[9];
3344
- }
3345
- newData[9] = arity == null
3346
- ? (isBindKey ? 0 : func.length)
3347
- : (nativeMax(arity - length, 0) || 0);
3348
-
3349
- if (bitmask == BIND_FLAG) {
3350
- var result = createBindWrapper(newData[0], newData[2]);
3351
- } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
3352
- result = createPartialWrapper.apply(undefined, newData);
3353
- } else {
3354
- result = createHybridWrapper.apply(undefined, newData);
3355
- }
3356
- var setter = data ? baseSetData : setData;
3357
- return setter(result, newData);
3358
- }
3359
-
3360
- module.exports = createWrapper;
3361
-
3362
- },{"./baseSetData":62,"./createBindWrapper":82,"./createHybridWrapper":89,"./createPartialWrapper":90,"./getData":96,"./mergeData":111,"./setData":118}],93:[function(require,module,exports){
3363
- var arraySome = require('./arraySome');
3364
-
3365
- /**
3366
- * A specialized version of `baseIsEqualDeep` for arrays with support for
3367
- * partial deep comparisons.
3368
- *
3369
- * @private
3370
- * @param {Array} array The array to compare.
3371
- * @param {Array} other The other array to compare.
3372
- * @param {Function} equalFunc The function to determine equivalents of values.
3373
- * @param {Function} [customizer] The function to customize comparing arrays.
3374
- * @param {boolean} [isLoose] Specify performing partial comparisons.
3375
- * @param {Array} [stackA] Tracks traversed `value` objects.
3376
- * @param {Array} [stackB] Tracks traversed `other` objects.
3377
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
3378
- */
3379
- function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
3380
- var index = -1,
3381
- arrLength = array.length,
3382
- othLength = other.length;
3383
-
3384
- if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
3385
- return false;
3386
- }
3387
- // Ignore non-index properties.
3388
- while (++index < arrLength) {
3389
- var arrValue = array[index],
3390
- othValue = other[index],
3391
- result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
3392
-
3393
- if (result !== undefined) {
3394
- if (result) {
3395
- continue;
3396
- }
3397
- return false;
3398
- }
3399
- // Recursively compare arrays (susceptible to call stack limits).
3400
- if (isLoose) {
3401
- if (!arraySome(other, function(othValue) {
3402
- return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
3403
- })) {
3404
- return false;
3405
- }
3406
- } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
3407
- return false;
3408
- }
3409
- }
3410
- return true;
3411
- }
3412
-
3413
- module.exports = equalArrays;
3414
-
3415
- },{"./arraySome":30}],94:[function(require,module,exports){
3416
- /** `Object#toString` result references. */
3417
- var boolTag = '[object Boolean]',
3418
- dateTag = '[object Date]',
3419
- errorTag = '[object Error]',
3420
- numberTag = '[object Number]',
3421
- regexpTag = '[object RegExp]',
3422
- stringTag = '[object String]';
3423
-
3424
- /**
3425
- * A specialized version of `baseIsEqualDeep` for comparing objects of
3426
- * the same `toStringTag`.
3427
- *
3428
- * **Note:** This function only supports comparing values with tags of
3429
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
3430
- *
3431
- * @private
3432
- * @param {Object} object The object to compare.
3433
- * @param {Object} other The other object to compare.
3434
- * @param {string} tag The `toStringTag` of the objects to compare.
3435
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3436
- */
3437
- function equalByTag(object, other, tag) {
3438
- switch (tag) {
3439
- case boolTag:
3440
- case dateTag:
3441
- // Coerce dates and booleans to numbers, dates to milliseconds and booleans
3442
- // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
3443
- return +object == +other;
3444
-
3445
- case errorTag:
3446
- return object.name == other.name && object.message == other.message;
3447
-
3448
- case numberTag:
3449
- // Treat `NaN` vs. `NaN` as equal.
3450
- return (object != +object)
3451
- ? other != +other
3452
- : object == +other;
3453
-
3454
- case regexpTag:
3455
- case stringTag:
3456
- // Coerce regexes to strings and treat strings primitives and string
3457
- // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
3458
- return object == (other + '');
3459
- }
3460
- return false;
3461
- }
3462
-
3463
- module.exports = equalByTag;
3464
-
3465
- },{}],95:[function(require,module,exports){
3466
- var keys = require('../object/keys');
3467
-
3468
- /** Used for native method references. */
3469
- var objectProto = Object.prototype;
3470
-
3471
- /** Used to check objects for own properties. */
3472
- var hasOwnProperty = objectProto.hasOwnProperty;
3473
-
3474
- /**
3475
- * A specialized version of `baseIsEqualDeep` for objects with support for
3476
- * partial deep comparisons.
3477
- *
3478
- * @private
3479
- * @param {Object} object The object to compare.
3480
- * @param {Object} other The other object to compare.
3481
- * @param {Function} equalFunc The function to determine equivalents of values.
3482
- * @param {Function} [customizer] The function to customize comparing values.
3483
- * @param {boolean} [isLoose] Specify performing partial comparisons.
3484
- * @param {Array} [stackA] Tracks traversed `value` objects.
3485
- * @param {Array} [stackB] Tracks traversed `other` objects.
3486
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
3487
- */
3488
- function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
3489
- var objProps = keys(object),
3490
- objLength = objProps.length,
3491
- othProps = keys(other),
3492
- othLength = othProps.length;
3493
-
3494
- if (objLength != othLength && !isLoose) {
3495
- return false;
3496
- }
3497
- var index = objLength;
3498
- while (index--) {
3499
- var key = objProps[index];
3500
- if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
3501
- return false;
3502
- }
3503
- }
3504
- var skipCtor = isLoose;
3505
- while (++index < objLength) {
3506
- key = objProps[index];
3507
- var objValue = object[key],
3508
- othValue = other[key],
3509
- result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
3510
-
3511
- // Recursively compare objects (susceptible to call stack limits).
3512
- if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
3513
- return false;
3514
- }
3515
- skipCtor || (skipCtor = key == 'constructor');
3516
- }
3517
- if (!skipCtor) {
3518
- var objCtor = object.constructor,
3519
- othCtor = other.constructor;
3520
-
3521
- // Non `Object` object instances with different constructors are not equal.
3522
- if (objCtor != othCtor &&
3523
- ('constructor' in object && 'constructor' in other) &&
3524
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
3525
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
3526
- return false;
3527
- }
3528
- }
3529
- return true;
3530
- }
3531
-
3532
- module.exports = equalObjects;
3533
-
3534
- },{"../object/keys":140}],96:[function(require,module,exports){
3535
- var metaMap = require('./metaMap'),
3536
- noop = require('../utility/noop');
3537
-
3538
- /**
3539
- * Gets metadata for `func`.
3540
- *
3541
- * @private
3542
- * @param {Function} func The function to query.
3543
- * @returns {*} Returns the metadata for `func`.
3544
- */
3545
- var getData = !metaMap ? noop : function(func) {
3546
- return metaMap.get(func);
3547
- };
3548
-
3549
- module.exports = getData;
3550
-
3551
- },{"../utility/noop":149,"./metaMap":112}],97:[function(require,module,exports){
3552
- var realNames = require('./realNames');
3553
-
3554
- /**
3555
- * Gets the name of `func`.
3556
- *
3557
- * @private
3558
- * @param {Function} func The function to query.
3559
- * @returns {string} Returns the function name.
3560
- */
3561
- function getFuncName(func) {
3562
- var result = func.name,
3563
- array = realNames[result],
3564
- length = array ? array.length : 0;
3565
-
3566
- while (length--) {
3567
- var data = array[length],
3568
- otherFunc = data.func;
3569
- if (otherFunc == null || otherFunc == func) {
3570
- return data.name;
3571
- }
3572
- }
3573
- return result;
3574
- }
3575
-
3576
- module.exports = getFuncName;
3577
-
3578
- },{"./realNames":115}],98:[function(require,module,exports){
3579
- var baseProperty = require('./baseProperty');
3580
-
3581
- /**
3582
- * Gets the "length" property value of `object`.
3583
- *
3584
- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
3585
- * that affects Safari on at least iOS 8.1-8.3 ARM64.
3586
- *
3587
- * @private
3588
- * @param {Object} object The object to query.
3589
- * @returns {*} Returns the "length" value.
3590
- */
3591
- var getLength = baseProperty('length');
3592
-
3593
- module.exports = getLength;
3594
-
3595
- },{"./baseProperty":59}],99:[function(require,module,exports){
3596
- var isStrictComparable = require('./isStrictComparable'),
3597
- pairs = require('../object/pairs');
3598
-
3599
- /**
3600
- * Gets the propery names, values, and compare flags of `object`.
3601
- *
3602
- * @private
3603
- * @param {Object} object The object to query.
3604
- * @returns {Array} Returns the match data of `object`.
3605
- */
3606
- function getMatchData(object) {
3607
- var result = pairs(object),
3608
- length = result.length;
3609
-
3610
- while (length--) {
3611
- result[length][2] = isStrictComparable(result[length][1]);
3612
- }
3613
- return result;
3614
- }
3615
-
3616
- module.exports = getMatchData;
3617
-
3618
- },{"../object/pairs":144,"./isStrictComparable":110}],100:[function(require,module,exports){
3619
- var isNative = require('../lang/isNative');
3620
-
3621
- /**
3622
- * Gets the native function at `key` of `object`.
3623
- *
3624
- * @private
3625
- * @param {Object} object The object to query.
3626
- * @param {string} key The key of the method to get.
3627
- * @returns {*} Returns the function if it's native, else `undefined`.
3628
- */
3629
- function getNative(object, key) {
3630
- var value = object == null ? undefined : object[key];
3631
- return isNative(value) ? value : undefined;
3632
- }
3633
-
3634
- module.exports = getNative;
3635
-
3636
- },{"../lang/isNative":130}],101:[function(require,module,exports){
3637
- /**
3638
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
3639
- *
3640
- * @private
3641
- * @param {Array} array The array to search.
3642
- * @param {number} fromIndex The index to search from.
3643
- * @param {boolean} [fromRight] Specify iterating from right to left.
3644
- * @returns {number} Returns the index of the matched `NaN`, else `-1`.
3645
- */
3646
- function indexOfNaN(array, fromIndex, fromRight) {
3647
- var length = array.length,
3648
- index = fromIndex + (fromRight ? 0 : -1);
3649
-
3650
- while ((fromRight ? index-- : ++index < length)) {
3651
- var other = array[index];
3652
- if (other !== other) {
3653
- return index;
3654
- }
3655
- }
3656
- return -1;
3657
- }
3658
-
3659
- module.exports = indexOfNaN;
3660
-
3661
- },{}],102:[function(require,module,exports){
3662
- var getLength = require('./getLength'),
3663
- isLength = require('./isLength');
3664
-
3665
- /**
3666
- * Checks if `value` is array-like.
3667
- *
3668
- * @private
3669
- * @param {*} value The value to check.
3670
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3671
- */
3672
- function isArrayLike(value) {
3673
- return value != null && isLength(getLength(value));
3674
- }
3675
-
3676
- module.exports = isArrayLike;
3677
-
3678
- },{"./getLength":98,"./isLength":107}],103:[function(require,module,exports){
3679
- /** Used to detect unsigned integer values. */
3680
- var reIsUint = /^\d+$/;
3681
-
3682
- /**
3683
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
3684
- * of an array-like value.
3685
- */
3686
- var MAX_SAFE_INTEGER = 9007199254740991;
3687
-
3688
- /**
3689
- * Checks if `value` is a valid array-like index.
3690
- *
3691
- * @private
3692
- * @param {*} value The value to check.
3693
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
3694
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
3695
- */
3696
- function isIndex(value, length) {
3697
- value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
3698
- length = length == null ? MAX_SAFE_INTEGER : length;
3699
- return value > -1 && value % 1 == 0 && value < length;
3700
- }
3701
-
3702
- module.exports = isIndex;
3703
-
3704
- },{}],104:[function(require,module,exports){
3705
- var isArrayLike = require('./isArrayLike'),
3706
- isIndex = require('./isIndex'),
3707
- isObject = require('../lang/isObject');
3708
-
3709
- /**
3710
- * Checks if the provided arguments are from an iteratee call.
3711
- *
3712
- * @private
3713
- * @param {*} value The potential iteratee value argument.
3714
- * @param {*} index The potential iteratee index or key argument.
3715
- * @param {*} object The potential iteratee object argument.
3716
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
3717
- */
3718
- function isIterateeCall(value, index, object) {
3719
- if (!isObject(object)) {
3720
- return false;
3721
- }
3722
- var type = typeof index;
3723
- if (type == 'number'
3724
- ? (isArrayLike(object) && isIndex(index, object.length))
3725
- : (type == 'string' && index in object)) {
3726
- var other = object[index];
3727
- return value === value ? (value === other) : (other !== other);
3728
- }
3729
- return false;
3730
- }
3731
-
3732
- module.exports = isIterateeCall;
3733
-
3734
- },{"../lang/isObject":131,"./isArrayLike":102,"./isIndex":103}],105:[function(require,module,exports){
3735
- var isArray = require('../lang/isArray'),
3736
- toObject = require('./toObject');
3737
-
3738
- /** Used to match property names within property paths. */
3739
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
3740
- reIsPlainProp = /^\w*$/;
3741
-
3742
- /**
3743
- * Checks if `value` is a property name and not a property path.
3744
- *
3745
- * @private
3746
- * @param {*} value The value to check.
3747
- * @param {Object} [object] The object to query keys on.
3748
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
3749
- */
3750
- function isKey(value, object) {
3751
- var type = typeof value;
3752
- if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
3753
- return true;
3754
- }
3755
- if (isArray(value)) {
3756
- return false;
3757
- }
3758
- var result = !reIsDeepProp.test(value);
3759
- return result || (object != null && value in toObject(object));
3760
- }
3761
-
3762
- module.exports = isKey;
3763
-
3764
- },{"../lang/isArray":127,"./toObject":121}],106:[function(require,module,exports){
3765
- var LazyWrapper = require('./LazyWrapper'),
3766
- getData = require('./getData'),
3767
- getFuncName = require('./getFuncName'),
3768
- lodash = require('../chain/lodash');
3769
-
3770
- /**
3771
- * Checks if `func` has a lazy counterpart.
3772
- *
3773
- * @private
3774
- * @param {Function} func The function to check.
3775
- * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
3776
- */
3777
- function isLaziable(func) {
3778
- var funcName = getFuncName(func);
3779
- if (!(funcName in LazyWrapper.prototype)) {
3780
- return false;
3781
- }
3782
- var other = lodash[funcName];
3783
- if (func === other) {
3784
- return true;
3785
- }
3786
- var data = getData(other);
3787
- return !!data && func === data[0];
3788
- }
3789
-
3790
- module.exports = isLaziable;
3791
-
3792
- },{"../chain/lodash":8,"./LazyWrapper":21,"./getData":96,"./getFuncName":97}],107:[function(require,module,exports){
3793
- /**
3794
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
3795
- * of an array-like value.
3796
- */
3797
- var MAX_SAFE_INTEGER = 9007199254740991;
3798
-
3799
- /**
3800
- * Checks if `value` is a valid array-like length.
3801
- *
3802
- * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
3803
- *
3804
- * @private
3805
- * @param {*} value The value to check.
3806
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3807
- */
3808
- function isLength(value) {
3809
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3810
- }
3811
-
3812
- module.exports = isLength;
3813
-
3814
- },{}],108:[function(require,module,exports){
3815
- /**
3816
- * Checks if `value` is object-like.
3817
- *
3818
- * @private
3819
- * @param {*} value The value to check.
3820
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3821
- */
3822
- function isObjectLike(value) {
3823
- return !!value && typeof value == 'object';
3824
- }
3825
-
3826
- module.exports = isObjectLike;
3827
-
3828
- },{}],109:[function(require,module,exports){
3829
- /**
3830
- * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a
3831
- * character code is whitespace.
3832
- *
3833
- * @private
3834
- * @param {number} charCode The character code to inspect.
3835
- * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.
3836
- */
3837
- function isSpace(charCode) {
3838
- return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||
3839
- (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));
3840
- }
3841
-
3842
- module.exports = isSpace;
3843
-
3844
- },{}],110:[function(require,module,exports){
3845
- var isObject = require('../lang/isObject');
3846
-
3847
- /**
3848
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
3849
- *
3850
- * @private
3851
- * @param {*} value The value to check.
3852
- * @returns {boolean} Returns `true` if `value` if suitable for strict
3853
- * equality comparisons, else `false`.
3854
- */
3855
- function isStrictComparable(value) {
3856
- return value === value && !isObject(value);
3857
- }
3858
-
3859
- module.exports = isStrictComparable;
3860
-
3861
- },{"../lang/isObject":131}],111:[function(require,module,exports){
3862
- var arrayCopy = require('./arrayCopy'),
3863
- composeArgs = require('./composeArgs'),
3864
- composeArgsRight = require('./composeArgsRight'),
3865
- replaceHolders = require('./replaceHolders');
3866
-
3867
- /** Used to compose bitmasks for wrapper metadata. */
3868
- var BIND_FLAG = 1,
3869
- CURRY_BOUND_FLAG = 4,
3870
- CURRY_FLAG = 8,
3871
- ARY_FLAG = 128,
3872
- REARG_FLAG = 256;
3873
-
3874
- /** Used as the internal argument placeholder. */
3875
- var PLACEHOLDER = '__lodash_placeholder__';
3876
-
3877
- /* Native method references for those with the same name as other `lodash` methods. */
3878
- var nativeMin = Math.min;
3879
-
3880
- /**
3881
- * Merges the function metadata of `source` into `data`.
3882
- *
3883
- * Merging metadata reduces the number of wrappers required to invoke a function.
3884
- * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
3885
- * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`
3886
- * augment function arguments, making the order in which they are executed important,
3887
- * preventing the merging of metadata. However, we make an exception for a safe
3888
- * common case where curried functions have `_.ary` and or `_.rearg` applied.
3889
- *
3890
- * @private
3891
- * @param {Array} data The destination metadata.
3892
- * @param {Array} source The source metadata.
3893
- * @returns {Array} Returns `data`.
3894
- */
3895
- function mergeData(data, source) {
3896
- var bitmask = data[1],
3897
- srcBitmask = source[1],
3898
- newBitmask = bitmask | srcBitmask,
3899
- isCommon = newBitmask < ARY_FLAG;
3900
-
3901
- var isCombo =
3902
- (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||
3903
- (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||
3904
- (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);
3905
-
3906
- // Exit early if metadata can't be merged.
3907
- if (!(isCommon || isCombo)) {
3908
- return data;
3909
- }
3910
- // Use source `thisArg` if available.
3911
- if (srcBitmask & BIND_FLAG) {
3912
- data[2] = source[2];
3913
- // Set when currying a bound function.
3914
- newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
3915
- }
3916
- // Compose partial arguments.
3917
- var value = source[3];
3918
- if (value) {
3919
- var partials = data[3];
3920
- data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);
3921
- data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);
3922
- }
3923
- // Compose partial right arguments.
3924
- value = source[5];
3925
- if (value) {
3926
- partials = data[5];
3927
- data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);
3928
- data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);
3929
- }
3930
- // Use source `argPos` if available.
3931
- value = source[7];
3932
- if (value) {
3933
- data[7] = arrayCopy(value);
3934
- }
3935
- // Use source `ary` if it's smaller.
3936
- if (srcBitmask & ARY_FLAG) {
3937
- data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
3938
- }
3939
- // Use source `arity` if one is not provided.
3940
- if (data[9] == null) {
3941
- data[9] = source[9];
3942
- }
3943
- // Use source `func` and merge bitmasks.
3944
- data[0] = source[0];
3945
- data[1] = newBitmask;
3946
-
3947
- return data;
3948
- }
3949
-
3950
- module.exports = mergeData;
3951
-
3952
- },{"./arrayCopy":24,"./composeArgs":77,"./composeArgsRight":78,"./replaceHolders":117}],112:[function(require,module,exports){
3953
- (function (global){
3954
- var getNative = require('./getNative');
3955
-
3956
- /** Native method references. */
3957
- var WeakMap = getNative(global, 'WeakMap');
3958
-
3959
- /** Used to store function metadata. */
3960
- var metaMap = WeakMap && new WeakMap;
3961
-
3962
- module.exports = metaMap;
3963
-
3964
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3965
- },{"./getNative":100}],113:[function(require,module,exports){
3966
- var toObject = require('./toObject');
3967
-
3968
- /**
3969
- * A specialized version of `_.pick` which picks `object` properties specified
3970
- * by `props`.
3971
- *
3972
- * @private
3973
- * @param {Object} object The source object.
3974
- * @param {string[]} props The property names to pick.
3975
- * @returns {Object} Returns the new object.
3976
- */
3977
- function pickByArray(object, props) {
3978
- object = toObject(object);
3979
-
3980
- var index = -1,
3981
- length = props.length,
3982
- result = {};
3983
-
3984
- while (++index < length) {
3985
- var key = props[index];
3986
- if (key in object) {
3987
- result[key] = object[key];
3988
- }
3989
- }
3990
- return result;
3991
- }
3992
-
3993
- module.exports = pickByArray;
3994
-
3995
- },{"./toObject":121}],114:[function(require,module,exports){
3996
- var baseForIn = require('./baseForIn');
3997
-
3998
- /**
3999
- * A specialized version of `_.pick` which picks `object` properties `predicate`
4000
- * returns truthy for.
4001
- *
4002
- * @private
4003
- * @param {Object} object The source object.
4004
- * @param {Function} predicate The function invoked per iteration.
4005
- * @returns {Object} Returns the new object.
4006
- */
4007
- function pickByCallback(object, predicate) {
4008
- var result = {};
4009
- baseForIn(object, function(value, key, object) {
4010
- if (predicate(value, key, object)) {
4011
- result[key] = value;
4012
- }
4013
- });
4014
- return result;
4015
- }
4016
-
4017
- module.exports = pickByCallback;
4018
-
4019
- },{"./baseForIn":46}],115:[function(require,module,exports){
4020
- /** Used to lookup unminified function names. */
4021
- var realNames = {};
4022
-
4023
- module.exports = realNames;
4024
-
4025
- },{}],116:[function(require,module,exports){
4026
- var arrayCopy = require('./arrayCopy'),
4027
- isIndex = require('./isIndex');
4028
-
4029
- /* Native method references for those with the same name as other `lodash` methods. */
4030
- var nativeMin = Math.min;
4031
-
4032
- /**
4033
- * Reorder `array` according to the specified indexes where the element at
4034
- * the first index is assigned as the first element, the element at
4035
- * the second index is assigned as the second element, and so on.
4036
- *
4037
- * @private
4038
- * @param {Array} array The array to reorder.
4039
- * @param {Array} indexes The arranged array indexes.
4040
- * @returns {Array} Returns `array`.
4041
- */
4042
- function reorder(array, indexes) {
4043
- var arrLength = array.length,
4044
- length = nativeMin(indexes.length, arrLength),
4045
- oldArray = arrayCopy(array);
4046
-
4047
- while (length--) {
4048
- var index = indexes[length];
4049
- array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
4050
- }
4051
- return array;
4052
- }
4053
-
4054
- module.exports = reorder;
4055
-
4056
- },{"./arrayCopy":24,"./isIndex":103}],117:[function(require,module,exports){
4057
- /** Used as the internal argument placeholder. */
4058
- var PLACEHOLDER = '__lodash_placeholder__';
4059
-
4060
- /**
4061
- * Replaces all `placeholder` elements in `array` with an internal placeholder
4062
- * and returns an array of their indexes.
4063
- *
4064
- * @private
4065
- * @param {Array} array The array to modify.
4066
- * @param {*} placeholder The placeholder to replace.
4067
- * @returns {Array} Returns the new array of placeholder indexes.
4068
- */
4069
- function replaceHolders(array, placeholder) {
4070
- var index = -1,
4071
- length = array.length,
4072
- resIndex = -1,
4073
- result = [];
4074
-
4075
- while (++index < length) {
4076
- if (array[index] === placeholder) {
4077
- array[index] = PLACEHOLDER;
4078
- result[++resIndex] = index;
4079
- }
4080
- }
4081
- return result;
4082
- }
4083
-
4084
- module.exports = replaceHolders;
4085
-
4086
- },{}],118:[function(require,module,exports){
4087
- var baseSetData = require('./baseSetData'),
4088
- now = require('../date/now');
4089
-
4090
- /** Used to detect when a function becomes hot. */
4091
- var HOT_COUNT = 150,
4092
- HOT_SPAN = 16;
4093
-
4094
- /**
4095
- * Sets metadata for `func`.
4096
- *
4097
- * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
4098
- * period of time, it will trip its breaker and transition to an identity function
4099
- * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)
4100
- * for more details.
4101
- *
4102
- * @private
4103
- * @param {Function} func The function to associate metadata with.
4104
- * @param {*} data The metadata.
4105
- * @returns {Function} Returns `func`.
4106
- */
4107
- var setData = (function() {
4108
- var count = 0,
4109
- lastCalled = 0;
4110
-
4111
- return function(key, value) {
4112
- var stamp = now(),
4113
- remaining = HOT_SPAN - (stamp - lastCalled);
4114
-
4115
- lastCalled = stamp;
4116
- if (remaining > 0) {
4117
- if (++count >= HOT_COUNT) {
4118
- return key;
4119
- }
4120
- } else {
4121
- count = 0;
4122
- }
4123
- return baseSetData(key, value);
4124
- };
4125
- }());
4126
-
4127
- module.exports = setData;
4128
-
4129
- },{"../date/now":18,"./baseSetData":62}],119:[function(require,module,exports){
4130
- var isArguments = require('../lang/isArguments'),
4131
- isArray = require('../lang/isArray'),
4132
- isIndex = require('./isIndex'),
4133
- isLength = require('./isLength'),
4134
- keysIn = require('../object/keysIn');
4135
-
4136
- /** Used for native method references. */
4137
- var objectProto = Object.prototype;
4138
-
4139
- /** Used to check objects for own properties. */
4140
- var hasOwnProperty = objectProto.hasOwnProperty;
4141
-
4142
- /**
4143
- * A fallback implementation of `Object.keys` which creates an array of the
4144
- * own enumerable property names of `object`.
4145
- *
4146
- * @private
4147
- * @param {Object} object The object to query.
4148
- * @returns {Array} Returns the array of property names.
4149
- */
4150
- function shimKeys(object) {
4151
- var props = keysIn(object),
4152
- propsLength = props.length,
4153
- length = propsLength && object.length;
4154
-
4155
- var allowIndexes = !!length && isLength(length) &&
4156
- (isArray(object) || isArguments(object));
4157
-
4158
- var index = -1,
4159
- result = [];
4160
-
4161
- while (++index < propsLength) {
4162
- var key = props[index];
4163
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
4164
- result.push(key);
4165
- }
4166
- }
4167
- return result;
4168
- }
4169
-
4170
- module.exports = shimKeys;
4171
-
4172
- },{"../lang/isArguments":126,"../lang/isArray":127,"../object/keysIn":141,"./isIndex":103,"./isLength":107}],120:[function(require,module,exports){
4173
- var isArrayLike = require('./isArrayLike'),
4174
- isObject = require('../lang/isObject'),
4175
- values = require('../object/values');
4176
-
4177
- /**
4178
- * Converts `value` to an array-like object if it's not one.
4179
- *
4180
- * @private
4181
- * @param {*} value The value to process.
4182
- * @returns {Array|Object} Returns the array-like object.
4183
- */
4184
- function toIterable(value) {
4185
- if (value == null) {
4186
- return [];
4187
- }
4188
- if (!isArrayLike(value)) {
4189
- return values(value);
4190
- }
4191
- return isObject(value) ? value : Object(value);
4192
- }
4193
-
4194
- module.exports = toIterable;
4195
-
4196
- },{"../lang/isObject":131,"../object/values":146,"./isArrayLike":102}],121:[function(require,module,exports){
4197
- var isObject = require('../lang/isObject');
4198
-
4199
- /**
4200
- * Converts `value` to an object if it's not one.
4201
- *
4202
- * @private
4203
- * @param {*} value The value to process.
4204
- * @returns {Object} Returns the object.
4205
- */
4206
- function toObject(value) {
4207
- return isObject(value) ? value : Object(value);
4208
- }
4209
-
4210
- module.exports = toObject;
4211
-
4212
- },{"../lang/isObject":131}],122:[function(require,module,exports){
4213
- var baseToString = require('./baseToString'),
4214
- isArray = require('../lang/isArray');
4215
-
4216
- /** Used to match property names within property paths. */
4217
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
4218
-
4219
- /** Used to match backslashes in property paths. */
4220
- var reEscapeChar = /\\(\\)?/g;
4221
-
4222
- /**
4223
- * Converts `value` to property path array if it's not one.
4224
- *
4225
- * @private
4226
- * @param {*} value The value to process.
4227
- * @returns {Array} Returns the property path array.
4228
- */
4229
- function toPath(value) {
4230
- if (isArray(value)) {
4231
- return value;
4232
- }
4233
- var result = [];
4234
- baseToString(value).replace(rePropName, function(match, number, quote, string) {
4235
- result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
4236
- });
4237
- return result;
4238
- }
4239
-
4240
- module.exports = toPath;
4241
-
4242
- },{"../lang/isArray":127,"./baseToString":67}],123:[function(require,module,exports){
4243
- var isSpace = require('./isSpace');
4244
-
4245
- /**
4246
- * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
4247
- * character of `string`.
4248
- *
4249
- * @private
4250
- * @param {string} string The string to inspect.
4251
- * @returns {number} Returns the index of the first non-whitespace character.
4252
- */
4253
- function trimmedLeftIndex(string) {
4254
- var index = -1,
4255
- length = string.length;
4256
-
4257
- while (++index < length && isSpace(string.charCodeAt(index))) {}
4258
- return index;
4259
- }
4260
-
4261
- module.exports = trimmedLeftIndex;
4262
-
4263
- },{"./isSpace":109}],124:[function(require,module,exports){
4264
- var isSpace = require('./isSpace');
4265
-
4266
- /**
4267
- * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace
4268
- * character of `string`.
4269
- *
4270
- * @private
4271
- * @param {string} string The string to inspect.
4272
- * @returns {number} Returns the index of the last non-whitespace character.
4273
- */
4274
- function trimmedRightIndex(string) {
4275
- var index = string.length;
4276
-
4277
- while (index-- && isSpace(string.charCodeAt(index))) {}
4278
- return index;
4279
- }
4280
-
4281
- module.exports = trimmedRightIndex;
4282
-
4283
- },{"./isSpace":109}],125:[function(require,module,exports){
4284
- var LazyWrapper = require('./LazyWrapper'),
4285
- LodashWrapper = require('./LodashWrapper'),
4286
- arrayCopy = require('./arrayCopy');
4287
-
4288
- /**
4289
- * Creates a clone of `wrapper`.
4290
- *
4291
- * @private
4292
- * @param {Object} wrapper The wrapper to clone.
4293
- * @returns {Object} Returns the cloned wrapper.
4294
- */
4295
- function wrapperClone(wrapper) {
4296
- return wrapper instanceof LazyWrapper
4297
- ? wrapper.clone()
4298
- : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
4299
- }
4300
-
4301
- module.exports = wrapperClone;
4302
-
4303
- },{"./LazyWrapper":21,"./LodashWrapper":22,"./arrayCopy":24}],126:[function(require,module,exports){
4304
- var isArrayLike = require('../internal/isArrayLike'),
4305
- isObjectLike = require('../internal/isObjectLike');
4306
-
4307
- /** Used for native method references. */
4308
- var objectProto = Object.prototype;
4309
-
4310
- /** Used to check objects for own properties. */
4311
- var hasOwnProperty = objectProto.hasOwnProperty;
4312
-
4313
- /** Native method references. */
4314
- var propertyIsEnumerable = objectProto.propertyIsEnumerable;
4315
-
4316
- /**
4317
- * Checks if `value` is classified as an `arguments` object.
4318
- *
4319
- * @static
4320
- * @memberOf _
4321
- * @category Lang
4322
- * @param {*} value The value to check.
4323
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
4324
- * @example
4325
- *
4326
- * _.isArguments(function() { return arguments; }());
4327
- * // => true
4328
- *
4329
- * _.isArguments([1, 2, 3]);
4330
- * // => false
4331
- */
4332
- function isArguments(value) {
4333
- return isObjectLike(value) && isArrayLike(value) &&
4334
- hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
4335
- }
4336
-
4337
- module.exports = isArguments;
4338
-
4339
- },{"../internal/isArrayLike":102,"../internal/isObjectLike":108}],127:[function(require,module,exports){
4340
- var getNative = require('../internal/getNative'),
4341
- isLength = require('../internal/isLength'),
4342
- isObjectLike = require('../internal/isObjectLike');
4343
-
4344
- /** `Object#toString` result references. */
4345
- var arrayTag = '[object Array]';
4346
-
4347
- /** Used for native method references. */
4348
- var objectProto = Object.prototype;
4349
-
4350
- /**
4351
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
4352
- * of values.
4353
- */
4354
- var objToString = objectProto.toString;
4355
-
4356
- /* Native method references for those with the same name as other `lodash` methods. */
4357
- var nativeIsArray = getNative(Array, 'isArray');
4358
-
4359
- /**
4360
- * Checks if `value` is classified as an `Array` object.
4361
- *
4362
- * @static
4363
- * @memberOf _
4364
- * @category Lang
4365
- * @param {*} value The value to check.
4366
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
4367
- * @example
4368
- *
4369
- * _.isArray([1, 2, 3]);
4370
- * // => true
4371
- *
4372
- * _.isArray(function() { return arguments; }());
4373
- * // => false
4374
- */
4375
- var isArray = nativeIsArray || function(value) {
4376
- return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
4377
- };
4378
-
4379
- module.exports = isArray;
4380
-
4381
- },{"../internal/getNative":100,"../internal/isLength":107,"../internal/isObjectLike":108}],128:[function(require,module,exports){
4382
- var isArguments = require('./isArguments'),
4383
- isArray = require('./isArray'),
4384
- isArrayLike = require('../internal/isArrayLike'),
4385
- isFunction = require('./isFunction'),
4386
- isObjectLike = require('../internal/isObjectLike'),
4387
- isString = require('./isString'),
4388
- keys = require('../object/keys');
4389
-
4390
- /**
4391
- * Checks if `value` is empty. A value is considered empty unless it is an
4392
- * `arguments` object, array, string, or jQuery-like collection with a length
4393
- * greater than `0` or an object with own enumerable properties.
4394
- *
4395
- * @static
4396
- * @memberOf _
4397
- * @category Lang
4398
- * @param {Array|Object|string} value The value to inspect.
4399
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
4400
- * @example
4401
- *
4402
- * _.isEmpty(null);
4403
- * // => true
4404
- *
4405
- * _.isEmpty(true);
4406
- * // => true
4407
- *
4408
- * _.isEmpty(1);
4409
- * // => true
4410
- *
4411
- * _.isEmpty([1, 2, 3]);
4412
- * // => false
4413
- *
4414
- * _.isEmpty({ 'a': 1 });
4415
- * // => false
4416
- */
4417
- function isEmpty(value) {
4418
- if (value == null) {
4419
- return true;
4420
- }
4421
- if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
4422
- (isObjectLike(value) && isFunction(value.splice)))) {
4423
- return !value.length;
4424
- }
4425
- return !keys(value).length;
4426
- }
4427
-
4428
- module.exports = isEmpty;
4429
-
4430
- },{"../internal/isArrayLike":102,"../internal/isObjectLike":108,"../object/keys":140,"./isArguments":126,"./isArray":127,"./isFunction":129,"./isString":133}],129:[function(require,module,exports){
4431
- var isObject = require('./isObject');
4432
-
4433
- /** `Object#toString` result references. */
4434
- var funcTag = '[object Function]';
4435
-
4436
- /** Used for native method references. */
4437
- var objectProto = Object.prototype;
4438
-
4439
- /**
4440
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
4441
- * of values.
4442
- */
4443
- var objToString = objectProto.toString;
4444
-
4445
- /**
4446
- * Checks if `value` is classified as a `Function` object.
4447
- *
4448
- * @static
4449
- * @memberOf _
4450
- * @category Lang
4451
- * @param {*} value The value to check.
4452
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
4453
- * @example
4454
- *
4455
- * _.isFunction(_);
4456
- * // => true
4457
- *
4458
- * _.isFunction(/abc/);
4459
- * // => false
4460
- */
4461
- function isFunction(value) {
4462
- // The use of `Object#toString` avoids issues with the `typeof` operator
4463
- // in older versions of Chrome and Safari which return 'function' for regexes
4464
- // and Safari 8 equivalents which return 'object' for typed array constructors.
4465
- return isObject(value) && objToString.call(value) == funcTag;
4466
- }
4467
-
4468
- module.exports = isFunction;
4469
-
4470
- },{"./isObject":131}],130:[function(require,module,exports){
4471
- var isFunction = require('./isFunction'),
4472
- isObjectLike = require('../internal/isObjectLike');
4473
-
4474
- /** Used to detect host constructors (Safari > 5). */
4475
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
4476
-
4477
- /** Used for native method references. */
4478
- var objectProto = Object.prototype;
4479
-
4480
- /** Used to resolve the decompiled source of functions. */
4481
- var fnToString = Function.prototype.toString;
4482
-
4483
- /** Used to check objects for own properties. */
4484
- var hasOwnProperty = objectProto.hasOwnProperty;
4485
-
4486
- /** Used to detect if a method is native. */
4487
- var reIsNative = RegExp('^' +
4488
- fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
4489
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
4490
- );
4491
-
4492
- /**
4493
- * Checks if `value` is a native function.
4494
- *
4495
- * @static
4496
- * @memberOf _
4497
- * @category Lang
4498
- * @param {*} value The value to check.
4499
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
4500
- * @example
4501
- *
4502
- * _.isNative(Array.prototype.push);
4503
- * // => true
4504
- *
4505
- * _.isNative(_);
4506
- * // => false
4507
- */
4508
- function isNative(value) {
4509
- if (value == null) {
4510
- return false;
4511
- }
4512
- if (isFunction(value)) {
4513
- return reIsNative.test(fnToString.call(value));
4514
- }
4515
- return isObjectLike(value) && reIsHostCtor.test(value);
4516
- }
4517
-
4518
- module.exports = isNative;
4519
-
4520
- },{"../internal/isObjectLike":108,"./isFunction":129}],131:[function(require,module,exports){
4521
- /**
4522
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
4523
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
4524
- *
4525
- * @static
4526
- * @memberOf _
4527
- * @category Lang
4528
- * @param {*} value The value to check.
4529
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
4530
- * @example
4531
- *
4532
- * _.isObject({});
4533
- * // => true
4534
- *
4535
- * _.isObject([1, 2, 3]);
4536
- * // => true
4537
- *
4538
- * _.isObject(1);
4539
- * // => false
4540
- */
4541
- function isObject(value) {
4542
- // Avoid a V8 JIT bug in Chrome 19-20.
4543
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
4544
- var type = typeof value;
4545
- return !!value && (type == 'object' || type == 'function');
4546
- }
4547
-
4548
- module.exports = isObject;
4549
-
4550
- },{}],132:[function(require,module,exports){
4551
- var baseForIn = require('../internal/baseForIn'),
4552
- isArguments = require('./isArguments'),
4553
- isObjectLike = require('../internal/isObjectLike');
4554
-
4555
- /** `Object#toString` result references. */
4556
- var objectTag = '[object Object]';
4557
-
4558
- /** Used for native method references. */
4559
- var objectProto = Object.prototype;
4560
-
4561
- /** Used to check objects for own properties. */
4562
- var hasOwnProperty = objectProto.hasOwnProperty;
4563
-
4564
- /**
4565
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
4566
- * of values.
4567
- */
4568
- var objToString = objectProto.toString;
4569
-
4570
- /**
4571
- * Checks if `value` is a plain object, that is, an object created by the
4572
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
4573
- *
4574
- * **Note:** This method assumes objects created by the `Object` constructor
4575
- * have no inherited enumerable properties.
4576
- *
4577
- * @static
4578
- * @memberOf _
4579
- * @category Lang
4580
- * @param {*} value The value to check.
4581
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
4582
- * @example
4583
- *
4584
- * function Foo() {
4585
- * this.a = 1;
4586
- * }
4587
- *
4588
- * _.isPlainObject(new Foo);
4589
- * // => false
4590
- *
4591
- * _.isPlainObject([1, 2, 3]);
4592
- * // => false
4593
- *
4594
- * _.isPlainObject({ 'x': 0, 'y': 0 });
4595
- * // => true
4596
- *
4597
- * _.isPlainObject(Object.create(null));
4598
- * // => true
4599
- */
4600
- function isPlainObject(value) {
4601
- var Ctor;
4602
-
4603
- // Exit early for non `Object` objects.
4604
- if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
4605
- (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
4606
- return false;
4607
- }
4608
- // IE < 9 iterates inherited properties before own properties. If the first
4609
- // iterated property is an object's own property then there are no inherited
4610
- // enumerable properties.
4611
- var result;
4612
- // In most environments an object's own properties are iterated before
4613
- // its inherited properties. If the last iterated property is an object's
4614
- // own property then there are no inherited enumerable properties.
4615
- baseForIn(value, function(subValue, key) {
4616
- result = key;
4617
- });
4618
- return result === undefined || hasOwnProperty.call(value, result);
4619
- }
4620
-
4621
- module.exports = isPlainObject;
4622
-
4623
- },{"../internal/baseForIn":46,"../internal/isObjectLike":108,"./isArguments":126}],133:[function(require,module,exports){
4624
- var isObjectLike = require('../internal/isObjectLike');
4625
-
4626
- /** `Object#toString` result references. */
4627
- var stringTag = '[object String]';
4628
-
4629
- /** Used for native method references. */
4630
- var objectProto = Object.prototype;
4631
-
4632
- /**
4633
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
4634
- * of values.
4635
- */
4636
- var objToString = objectProto.toString;
4637
-
4638
- /**
4639
- * Checks if `value` is classified as a `String` primitive or object.
4640
- *
4641
- * @static
4642
- * @memberOf _
4643
- * @category Lang
4644
- * @param {*} value The value to check.
4645
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
4646
- * @example
4647
- *
4648
- * _.isString('abc');
4649
- * // => true
4650
- *
4651
- * _.isString(1);
4652
- * // => false
4653
- */
4654
- function isString(value) {
4655
- return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
4656
- }
4657
-
4658
- module.exports = isString;
4659
-
4660
- },{"../internal/isObjectLike":108}],134:[function(require,module,exports){
4661
- var isLength = require('../internal/isLength'),
4662
- isObjectLike = require('../internal/isObjectLike');
4663
-
4664
- /** `Object#toString` result references. */
4665
- var argsTag = '[object Arguments]',
4666
- arrayTag = '[object Array]',
4667
- boolTag = '[object Boolean]',
4668
- dateTag = '[object Date]',
4669
- errorTag = '[object Error]',
4670
- funcTag = '[object Function]',
4671
- mapTag = '[object Map]',
4672
- numberTag = '[object Number]',
4673
- objectTag = '[object Object]',
4674
- regexpTag = '[object RegExp]',
4675
- setTag = '[object Set]',
4676
- stringTag = '[object String]',
4677
- weakMapTag = '[object WeakMap]';
4678
-
4679
- var arrayBufferTag = '[object ArrayBuffer]',
4680
- float32Tag = '[object Float32Array]',
4681
- float64Tag = '[object Float64Array]',
4682
- int8Tag = '[object Int8Array]',
4683
- int16Tag = '[object Int16Array]',
4684
- int32Tag = '[object Int32Array]',
4685
- uint8Tag = '[object Uint8Array]',
4686
- uint8ClampedTag = '[object Uint8ClampedArray]',
4687
- uint16Tag = '[object Uint16Array]',
4688
- uint32Tag = '[object Uint32Array]';
4689
-
4690
- /** Used to identify `toStringTag` values of typed arrays. */
4691
- var typedArrayTags = {};
4692
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
4693
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
4694
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
4695
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
4696
- typedArrayTags[uint32Tag] = true;
4697
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
4698
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
4699
- typedArrayTags[dateTag] = typedArrayTags[errorTag] =
4700
- typedArrayTags[funcTag] = typedArrayTags[mapTag] =
4701
- typedArrayTags[numberTag] = typedArrayTags[objectTag] =
4702
- typedArrayTags[regexpTag] = typedArrayTags[setTag] =
4703
- typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
4704
-
4705
- /** Used for native method references. */
4706
- var objectProto = Object.prototype;
4707
-
4708
- /**
4709
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
4710
- * of values.
4711
- */
4712
- var objToString = objectProto.toString;
4713
-
4714
- /**
4715
- * Checks if `value` is classified as a typed array.
4716
- *
4717
- * @static
4718
- * @memberOf _
4719
- * @category Lang
4720
- * @param {*} value The value to check.
4721
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
4722
- * @example
4723
- *
4724
- * _.isTypedArray(new Uint8Array);
4725
- * // => true
4726
- *
4727
- * _.isTypedArray([]);
4728
- * // => false
4729
- */
4730
- function isTypedArray(value) {
4731
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
4732
- }
4733
-
4734
- module.exports = isTypedArray;
4735
-
4736
- },{"../internal/isLength":107,"../internal/isObjectLike":108}],135:[function(require,module,exports){
4737
- /**
4738
- * Checks if `value` is `undefined`.
4739
- *
4740
- * @static
4741
- * @memberOf _
4742
- * @category Lang
4743
- * @param {*} value The value to check.
4744
- * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
4745
- * @example
4746
- *
4747
- * _.isUndefined(void 0);
4748
- * // => true
4749
- *
4750
- * _.isUndefined(null);
4751
- * // => false
4752
- */
4753
- function isUndefined(value) {
4754
- return value === undefined;
4755
- }
4756
-
4757
- module.exports = isUndefined;
4758
-
4759
- },{}],136:[function(require,module,exports){
4760
- var baseCopy = require('../internal/baseCopy'),
4761
- keysIn = require('../object/keysIn');
4762
-
4763
- /**
4764
- * Converts `value` to a plain object flattening inherited enumerable
4765
- * properties of `value` to own properties of the plain object.
4766
- *
4767
- * @static
4768
- * @memberOf _
4769
- * @category Lang
4770
- * @param {*} value The value to convert.
4771
- * @returns {Object} Returns the converted plain object.
4772
- * @example
4773
- *
4774
- * function Foo() {
4775
- * this.b = 2;
4776
- * }
4777
- *
4778
- * Foo.prototype.c = 3;
4779
- *
4780
- * _.assign({ 'a': 1 }, new Foo);
4781
- * // => { 'a': 1, 'b': 2 }
4782
- *
4783
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
4784
- * // => { 'a': 1, 'b': 2, 'c': 3 }
4785
- */
4786
- function toPlainObject(value) {
4787
- return baseCopy(value, keysIn(value));
4788
- }
4789
-
4790
- module.exports = toPlainObject;
4791
-
4792
- },{"../internal/baseCopy":37,"../object/keysIn":141}],137:[function(require,module,exports){
4793
- var arraySum = require('../internal/arraySum'),
4794
- baseCallback = require('../internal/baseCallback'),
4795
- baseSum = require('../internal/baseSum'),
4796
- isArray = require('../lang/isArray'),
4797
- isIterateeCall = require('../internal/isIterateeCall'),
4798
- toIterable = require('../internal/toIterable');
4799
-
4800
- /**
4801
- * Gets the sum of the values in `collection`.
4802
- *
4803
- * @static
4804
- * @memberOf _
4805
- * @category Math
4806
- * @param {Array|Object|string} collection The collection to iterate over.
4807
- * @param {Function|Object|string} [iteratee] The function invoked per iteration.
4808
- * @param {*} [thisArg] The `this` binding of `iteratee`.
4809
- * @returns {number} Returns the sum.
4810
- * @example
4811
- *
4812
- * _.sum([4, 6]);
4813
- * // => 10
4814
- *
4815
- * _.sum({ 'a': 4, 'b': 6 });
4816
- * // => 10
4817
- *
4818
- * var objects = [
4819
- * { 'n': 4 },
4820
- * { 'n': 6 }
4821
- * ];
4822
- *
4823
- * _.sum(objects, function(object) {
4824
- * return object.n;
4825
- * });
4826
- * // => 10
4827
- *
4828
- * // using the `_.property` callback shorthand
4829
- * _.sum(objects, 'n');
4830
- * // => 10
4831
- */
4832
- function sum(collection, iteratee, thisArg) {
4833
- if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
4834
- iteratee = undefined;
4835
- }
4836
- iteratee = baseCallback(iteratee, thisArg, 3);
4837
- return iteratee.length == 1
4838
- ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)
4839
- : baseSum(collection, iteratee);
4840
- }
4841
-
4842
- module.exports = sum;
4843
-
4844
- },{"../internal/arraySum":31,"../internal/baseCallback":35,"../internal/baseSum":66,"../internal/isIterateeCall":104,"../internal/toIterable":120,"../lang/isArray":127}],138:[function(require,module,exports){
4845
- var assignWith = require('../internal/assignWith'),
4846
- baseAssign = require('../internal/baseAssign'),
4847
- createAssigner = require('../internal/createAssigner');
4848
-
4849
- /**
4850
- * Assigns own enumerable properties of source object(s) to the destination
4851
- * object. Subsequent sources overwrite property assignments of previous sources.
4852
- * If `customizer` is provided it is invoked to produce the assigned values.
4853
- * The `customizer` is bound to `thisArg` and invoked with five arguments:
4854
- * (objectValue, sourceValue, key, object, source).
4855
- *
4856
- * **Note:** This method mutates `object` and is based on
4857
- * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
4858
- *
4859
- * @static
4860
- * @memberOf _
4861
- * @alias extend
4862
- * @category Object
4863
- * @param {Object} object The destination object.
4864
- * @param {...Object} [sources] The source objects.
4865
- * @param {Function} [customizer] The function to customize assigned values.
4866
- * @param {*} [thisArg] The `this` binding of `customizer`.
4867
- * @returns {Object} Returns `object`.
4868
- * @example
4869
- *
4870
- * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
4871
- * // => { 'user': 'fred', 'age': 40 }
4872
- *
4873
- * // using a customizer callback
4874
- * var defaults = _.partialRight(_.assign, function(value, other) {
4875
- * return _.isUndefined(value) ? other : value;
4876
- * });
4877
- *
4878
- * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
4879
- * // => { 'user': 'barney', 'age': 36 }
4880
- */
4881
- var assign = createAssigner(function(object, source, customizer) {
4882
- return customizer
4883
- ? assignWith(object, source, customizer)
4884
- : baseAssign(object, source);
4885
- });
4886
-
4887
- module.exports = assign;
4888
-
4889
- },{"../internal/assignWith":33,"../internal/baseAssign":34,"../internal/createAssigner":79}],139:[function(require,module,exports){
4890
- var assign = require('./assign'),
4891
- assignDefaults = require('../internal/assignDefaults'),
4892
- createDefaults = require('../internal/createDefaults');
4893
-
4894
- /**
4895
- * Assigns own enumerable properties of source object(s) to the destination
4896
- * object for all destination properties that resolve to `undefined`. Once a
4897
- * property is set, additional values of the same property are ignored.
4898
- *
4899
- * **Note:** This method mutates `object`.
4900
- *
4901
- * @static
4902
- * @memberOf _
4903
- * @category Object
4904
- * @param {Object} object The destination object.
4905
- * @param {...Object} [sources] The source objects.
4906
- * @returns {Object} Returns `object`.
4907
- * @example
4908
- *
4909
- * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
4910
- * // => { 'user': 'barney', 'age': 36 }
4911
- */
4912
- var defaults = createDefaults(assign, assignDefaults);
4913
-
4914
- module.exports = defaults;
4915
-
4916
- },{"../internal/assignDefaults":32,"../internal/createDefaults":85,"./assign":138}],140:[function(require,module,exports){
4917
- var getNative = require('../internal/getNative'),
4918
- isArrayLike = require('../internal/isArrayLike'),
4919
- isObject = require('../lang/isObject'),
4920
- shimKeys = require('../internal/shimKeys');
4921
-
4922
- /* Native method references for those with the same name as other `lodash` methods. */
4923
- var nativeKeys = getNative(Object, 'keys');
4924
-
4925
- /**
4926
- * Creates an array of the own enumerable property names of `object`.
4927
- *
4928
- * **Note:** Non-object values are coerced to objects. See the
4929
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
4930
- * for more details.
4931
- *
4932
- * @static
4933
- * @memberOf _
4934
- * @category Object
4935
- * @param {Object} object The object to query.
4936
- * @returns {Array} Returns the array of property names.
4937
- * @example
4938
- *
4939
- * function Foo() {
4940
- * this.a = 1;
4941
- * this.b = 2;
4942
- * }
4943
- *
4944
- * Foo.prototype.c = 3;
4945
- *
4946
- * _.keys(new Foo);
4947
- * // => ['a', 'b'] (iteration order is not guaranteed)
4948
- *
4949
- * _.keys('hi');
4950
- * // => ['0', '1']
4951
- */
4952
- var keys = !nativeKeys ? shimKeys : function(object) {
4953
- var Ctor = object == null ? undefined : object.constructor;
4954
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
4955
- (typeof object != 'function' && isArrayLike(object))) {
4956
- return shimKeys(object);
4957
- }
4958
- return isObject(object) ? nativeKeys(object) : [];
4959
- };
4960
-
4961
- module.exports = keys;
4962
-
4963
- },{"../internal/getNative":100,"../internal/isArrayLike":102,"../internal/shimKeys":119,"../lang/isObject":131}],141:[function(require,module,exports){
4964
- var isArguments = require('../lang/isArguments'),
4965
- isArray = require('../lang/isArray'),
4966
- isIndex = require('../internal/isIndex'),
4967
- isLength = require('../internal/isLength'),
4968
- isObject = require('../lang/isObject');
4969
-
4970
- /** Used for native method references. */
4971
- var objectProto = Object.prototype;
4972
-
4973
- /** Used to check objects for own properties. */
4974
- var hasOwnProperty = objectProto.hasOwnProperty;
4975
-
4976
- /**
4977
- * Creates an array of the own and inherited enumerable property names of `object`.
4978
- *
4979
- * **Note:** Non-object values are coerced to objects.
4980
- *
4981
- * @static
4982
- * @memberOf _
4983
- * @category Object
4984
- * @param {Object} object The object to query.
4985
- * @returns {Array} Returns the array of property names.
4986
- * @example
4987
- *
4988
- * function Foo() {
4989
- * this.a = 1;
4990
- * this.b = 2;
4991
- * }
4992
- *
4993
- * Foo.prototype.c = 3;
4994
- *
4995
- * _.keysIn(new Foo);
4996
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
4997
- */
4998
- function keysIn(object) {
4999
- if (object == null) {
5000
- return [];
5001
- }
5002
- if (!isObject(object)) {
5003
- object = Object(object);
5004
- }
5005
- var length = object.length;
5006
- length = (length && isLength(length) &&
5007
- (isArray(object) || isArguments(object)) && length) || 0;
5008
-
5009
- var Ctor = object.constructor,
5010
- index = -1,
5011
- isProto = typeof Ctor == 'function' && Ctor.prototype === object,
5012
- result = Array(length),
5013
- skipIndexes = length > 0;
5014
-
5015
- while (++index < length) {
5016
- result[index] = (index + '');
5017
- }
5018
- for (var key in object) {
5019
- if (!(skipIndexes && isIndex(key, length)) &&
5020
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
5021
- result.push(key);
5022
- }
5023
- }
5024
- return result;
5025
- }
5026
-
5027
- module.exports = keysIn;
5028
-
5029
- },{"../internal/isIndex":103,"../internal/isLength":107,"../lang/isArguments":126,"../lang/isArray":127,"../lang/isObject":131}],142:[function(require,module,exports){
5030
- var baseMerge = require('../internal/baseMerge'),
5031
- createAssigner = require('../internal/createAssigner');
5032
-
5033
- /**
5034
- * Recursively merges own enumerable properties of the source object(s), that
5035
- * don't resolve to `undefined` into the destination object. Subsequent sources
5036
- * overwrite property assignments of previous sources. If `customizer` is
5037
- * provided it is invoked to produce the merged values of the destination and
5038
- * source properties. If `customizer` returns `undefined` merging is handled
5039
- * by the method instead. The `customizer` is bound to `thisArg` and invoked
5040
- * with five arguments: (objectValue, sourceValue, key, object, source).
5041
- *
5042
- * @static
5043
- * @memberOf _
5044
- * @category Object
5045
- * @param {Object} object The destination object.
5046
- * @param {...Object} [sources] The source objects.
5047
- * @param {Function} [customizer] The function to customize assigned values.
5048
- * @param {*} [thisArg] The `this` binding of `customizer`.
5049
- * @returns {Object} Returns `object`.
5050
- * @example
5051
- *
5052
- * var users = {
5053
- * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
5054
- * };
5055
- *
5056
- * var ages = {
5057
- * 'data': [{ 'age': 36 }, { 'age': 40 }]
5058
- * };
5059
- *
5060
- * _.merge(users, ages);
5061
- * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
5062
- *
5063
- * // using a customizer callback
5064
- * var object = {
5065
- * 'fruits': ['apple'],
5066
- * 'vegetables': ['beet']
5067
- * };
5068
- *
5069
- * var other = {
5070
- * 'fruits': ['banana'],
5071
- * 'vegetables': ['carrot']
5072
- * };
5073
- *
5074
- * _.merge(object, other, function(a, b) {
5075
- * if (_.isArray(a)) {
5076
- * return a.concat(b);
5077
- * }
5078
- * });
5079
- * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
5080
- */
5081
- var merge = createAssigner(baseMerge);
5082
-
5083
- module.exports = merge;
5084
-
5085
- },{"../internal/baseMerge":57,"../internal/createAssigner":79}],143:[function(require,module,exports){
5086
- var arrayMap = require('../internal/arrayMap'),
5087
- baseDifference = require('../internal/baseDifference'),
5088
- baseFlatten = require('../internal/baseFlatten'),
5089
- bindCallback = require('../internal/bindCallback'),
5090
- keysIn = require('./keysIn'),
5091
- pickByArray = require('../internal/pickByArray'),
5092
- pickByCallback = require('../internal/pickByCallback'),
5093
- restParam = require('../function/restParam');
5094
-
5095
- /**
5096
- * The opposite of `_.pick`; this method creates an object composed of the
5097
- * own and inherited enumerable properties of `object` that are not omitted.
5098
- *
5099
- * @static
5100
- * @memberOf _
5101
- * @category Object
5102
- * @param {Object} object The source object.
5103
- * @param {Function|...(string|string[])} [predicate] The function invoked per
5104
- * iteration or property names to omit, specified as individual property
5105
- * names or arrays of property names.
5106
- * @param {*} [thisArg] The `this` binding of `predicate`.
5107
- * @returns {Object} Returns the new object.
5108
- * @example
5109
- *
5110
- * var object = { 'user': 'fred', 'age': 40 };
5111
- *
5112
- * _.omit(object, 'age');
5113
- * // => { 'user': 'fred' }
5114
- *
5115
- * _.omit(object, _.isNumber);
5116
- * // => { 'user': 'fred' }
5117
- */
5118
- var omit = restParam(function(object, props) {
5119
- if (object == null) {
5120
- return {};
5121
- }
5122
- if (typeof props[0] != 'function') {
5123
- var props = arrayMap(baseFlatten(props), String);
5124
- return pickByArray(object, baseDifference(keysIn(object), props));
5125
- }
5126
- var predicate = bindCallback(props[0], props[1], 3);
5127
- return pickByCallback(object, function(value, key, object) {
5128
- return !predicate(value, key, object);
5129
- });
5130
- });
5131
-
5132
- module.exports = omit;
5133
-
5134
- },{"../function/restParam":20,"../internal/arrayMap":27,"../internal/baseDifference":39,"../internal/baseFlatten":44,"../internal/bindCallback":71,"../internal/pickByArray":113,"../internal/pickByCallback":114,"./keysIn":141}],144:[function(require,module,exports){
5135
- var keys = require('./keys'),
5136
- toObject = require('../internal/toObject');
5137
-
5138
- /**
5139
- * Creates a two dimensional array of the key-value pairs for `object`,
5140
- * e.g. `[[key1, value1], [key2, value2]]`.
5141
- *
5142
- * @static
5143
- * @memberOf _
5144
- * @category Object
5145
- * @param {Object} object The object to query.
5146
- * @returns {Array} Returns the new array of key-value pairs.
5147
- * @example
5148
- *
5149
- * _.pairs({ 'barney': 36, 'fred': 40 });
5150
- * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
5151
- */
5152
- function pairs(object) {
5153
- object = toObject(object);
5154
-
5155
- var index = -1,
5156
- props = keys(object),
5157
- length = props.length,
5158
- result = Array(length);
5159
-
5160
- while (++index < length) {
5161
- var key = props[index];
5162
- result[index] = [key, object[key]];
5163
- }
5164
- return result;
5165
- }
5166
-
5167
- module.exports = pairs;
5168
-
5169
- },{"../internal/toObject":121,"./keys":140}],145:[function(require,module,exports){
5170
- var baseFlatten = require('../internal/baseFlatten'),
5171
- bindCallback = require('../internal/bindCallback'),
5172
- pickByArray = require('../internal/pickByArray'),
5173
- pickByCallback = require('../internal/pickByCallback'),
5174
- restParam = require('../function/restParam');
5175
-
5176
- /**
5177
- * Creates an object composed of the picked `object` properties. Property
5178
- * names may be specified as individual arguments or as arrays of property
5179
- * names. If `predicate` is provided it is invoked for each property of `object`
5180
- * picking the properties `predicate` returns truthy for. The predicate is
5181
- * bound to `thisArg` and invoked with three arguments: (value, key, object).
5182
- *
5183
- * @static
5184
- * @memberOf _
5185
- * @category Object
5186
- * @param {Object} object The source object.
5187
- * @param {Function|...(string|string[])} [predicate] The function invoked per
5188
- * iteration or property names to pick, specified as individual property
5189
- * names or arrays of property names.
5190
- * @param {*} [thisArg] The `this` binding of `predicate`.
5191
- * @returns {Object} Returns the new object.
5192
- * @example
5193
- *
5194
- * var object = { 'user': 'fred', 'age': 40 };
5195
- *
5196
- * _.pick(object, 'user');
5197
- * // => { 'user': 'fred' }
5198
- *
5199
- * _.pick(object, _.isString);
5200
- * // => { 'user': 'fred' }
5201
- */
5202
- var pick = restParam(function(object, props) {
5203
- if (object == null) {
5204
- return {};
5205
- }
5206
- return typeof props[0] == 'function'
5207
- ? pickByCallback(object, bindCallback(props[0], props[1], 3))
5208
- : pickByArray(object, baseFlatten(props));
5209
- });
5210
-
5211
- module.exports = pick;
5212
-
5213
- },{"../function/restParam":20,"../internal/baseFlatten":44,"../internal/bindCallback":71,"../internal/pickByArray":113,"../internal/pickByCallback":114}],146:[function(require,module,exports){
5214
- var baseValues = require('../internal/baseValues'),
5215
- keys = require('./keys');
5216
-
5217
- /**
5218
- * Creates an array of the own enumerable property values of `object`.
5219
- *
5220
- * **Note:** Non-object values are coerced to objects.
5221
- *
5222
- * @static
5223
- * @memberOf _
5224
- * @category Object
5225
- * @param {Object} object The object to query.
5226
- * @returns {Array} Returns the array of property values.
5227
- * @example
5228
- *
5229
- * function Foo() {
5230
- * this.a = 1;
5231
- * this.b = 2;
5232
- * }
5233
- *
5234
- * Foo.prototype.c = 3;
5235
- *
5236
- * _.values(new Foo);
5237
- * // => [1, 2] (iteration order is not guaranteed)
5238
- *
5239
- * _.values('hi');
5240
- * // => ['h', 'i']
5241
- */
5242
- function values(object) {
5243
- return baseValues(object, keys(object));
5244
- }
5245
-
5246
- module.exports = values;
5247
-
5248
- },{"../internal/baseValues":68,"./keys":140}],147:[function(require,module,exports){
5249
- var baseToString = require('../internal/baseToString'),
5250
- charsLeftIndex = require('../internal/charsLeftIndex'),
5251
- charsRightIndex = require('../internal/charsRightIndex'),
5252
- isIterateeCall = require('../internal/isIterateeCall'),
5253
- trimmedLeftIndex = require('../internal/trimmedLeftIndex'),
5254
- trimmedRightIndex = require('../internal/trimmedRightIndex');
5255
-
5256
- /**
5257
- * Removes leading and trailing whitespace or specified characters from `string`.
5258
- *
5259
- * @static
5260
- * @memberOf _
5261
- * @category String
5262
- * @param {string} [string=''] The string to trim.
5263
- * @param {string} [chars=whitespace] The characters to trim.
5264
- * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
5265
- * @returns {string} Returns the trimmed string.
5266
- * @example
5267
- *
5268
- * _.trim(' abc ');
5269
- * // => 'abc'
5270
- *
5271
- * _.trim('-_-abc-_-', '_-');
5272
- * // => 'abc'
5273
- *
5274
- * _.map([' foo ', ' bar '], _.trim);
5275
- * // => ['foo', 'bar']
5276
- */
5277
- function trim(string, chars, guard) {
5278
- var value = string;
5279
- string = baseToString(string);
5280
- if (!string) {
5281
- return string;
5282
- }
5283
- if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
5284
- return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
5285
- }
5286
- chars = (chars + '');
5287
- return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
5288
- }
5289
-
5290
- module.exports = trim;
5291
-
5292
- },{"../internal/baseToString":67,"../internal/charsLeftIndex":74,"../internal/charsRightIndex":75,"../internal/isIterateeCall":104,"../internal/trimmedLeftIndex":123,"../internal/trimmedRightIndex":124}],148:[function(require,module,exports){
5293
- /**
5294
- * This method returns the first argument provided to it.
5295
- *
5296
- * @static
5297
- * @memberOf _
5298
- * @category Utility
5299
- * @param {*} value Any value.
5300
- * @returns {*} Returns `value`.
5301
- * @example
5302
- *
5303
- * var object = { 'user': 'fred' };
5304
- *
5305
- * _.identity(object) === object;
5306
- * // => true
5307
- */
5308
- function identity(value) {
5309
- return value;
5310
- }
5311
-
5312
- module.exports = identity;
5313
-
5314
- },{}],149:[function(require,module,exports){
5315
- /**
5316
- * A no-operation function that returns `undefined` regardless of the
5317
- * arguments it receives.
5318
- *
5319
- * @static
5320
- * @memberOf _
5321
- * @category Utility
5322
- * @example
5323
- *
5324
- * var object = { 'user': 'fred' };
5325
- *
5326
- * _.noop(object) === undefined;
5327
- * // => true
5328
- */
5329
- function noop() {
5330
- // No operation performed.
5331
- }
5332
-
5333
- module.exports = noop;
5334
-
5335
- },{}],150:[function(require,module,exports){
5336
- var baseProperty = require('../internal/baseProperty'),
5337
- basePropertyDeep = require('../internal/basePropertyDeep'),
5338
- isKey = require('../internal/isKey');
5339
-
5340
- /**
5341
- * Creates a function that returns the property value at `path` on a
5342
- * given object.
5343
- *
5344
- * @static
5345
- * @memberOf _
5346
- * @category Utility
5347
- * @param {Array|string} path The path of the property to get.
5348
- * @returns {Function} Returns the new function.
5349
- * @example
5350
- *
5351
- * var objects = [
5352
- * { 'a': { 'b': { 'c': 2 } } },
5353
- * { 'a': { 'b': { 'c': 1 } } }
5354
- * ];
5355
- *
5356
- * _.map(objects, _.property('a.b.c'));
5357
- * // => [2, 1]
5358
- *
5359
- * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
5360
- * // => [1, 2]
5361
- */
5362
- function property(path) {
5363
- return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
5364
- }
5365
-
5366
- module.exports = property;
5367
-
5368
- },{"../internal/baseProperty":59,"../internal/basePropertyDeep":60,"../internal/isKey":105}],151:[function(require,module,exports){
5369
- 'use strict';
5370
-
5371
- /**
5372
- * Functions to manipulate refinement lists
5373
- *
5374
- * The RefinementList is not formally defined through a prototype but is based
5375
- * on a specific structure.
5376
- *
5377
- * @module SearchParameters.refinementList
5378
- *
5379
- * @typedef {string[]} SearchParameters.refinementList.Refinements
5380
- * @typedef {Object.<string, SearchParameters.refinementList.Refinements>} SearchParameters.refinementList.RefinementList
5381
- */
5382
-
5383
- var isUndefined = require('lodash/lang/isUndefined');
5384
- var isString = require('lodash/lang/isString');
5385
- var isFunction = require('lodash/lang/isFunction');
5386
- var isEmpty = require('lodash/lang/isEmpty');
5387
- var defaults = require('lodash/object/defaults');
5388
-
5389
- var reduce = require('lodash/collection/reduce');
5390
- var filter = require('lodash/collection/filter');
5391
- var omit = require('lodash/object/omit');
5392
-
5393
- var lib = {
5394
- /**
5395
- * Adds a refinement to a RefinementList
5396
- * @param {RefinementList} refinementList the initial list
5397
- * @param {string} attribute the attribute to refine
5398
- * @param {string} value the value of the refinement, if the value is not a string it will be converted
5399
- * @return {RefinementList} a new and updated prefinement list
5400
- */
5401
- addRefinement: function addRefinement(refinementList, attribute, value) {
5402
- if (lib.isRefined(refinementList, attribute, value)) {
5403
- return refinementList;
5404
- }
5405
-
5406
- var valueAsString = '' + value;
5407
-
5408
- var facetRefinement = !refinementList[attribute] ?
5409
- [valueAsString] :
5410
- refinementList[attribute].concat(valueAsString);
5411
-
5412
- var mod = {};
5413
-
5414
- mod[attribute] = facetRefinement;
5415
-
5416
- return defaults({}, mod, refinementList);
5417
- },
5418
- /**
5419
- * Removes refinement(s) for an attribute:
5420
- * - if the value is specified removes the refinement for the value on the attribute
5421
- * - if no value is specified removes all the refinements for this attribute
5422
- * @param {RefinementList} refinementList the initial list
5423
- * @param {string} attribute the attribute to refine
5424
- * @param {string} [value] the value of the refinement
5425
- * @return {RefinementList} a new and updated refinement lst
5426
- */
5427
- removeRefinement: function removeRefinement(refinementList, attribute, value) {
5428
- if (isUndefined(value)) {
5429
- return lib.clearRefinement(refinementList, attribute);
5430
- }
5431
-
5432
- var valueAsString = '' + value;
5433
-
5434
- return lib.clearRefinement(refinementList, function(v, f) {
5435
- return attribute === f && valueAsString === v;
5436
- });
5437
- },
5438
- /**
5439
- * Toggles the refinement value for an attribute.
5440
- * @param {RefinementList} refinementList the initial list
5441
- * @param {string} attribute the attribute to refine
5442
- * @param {string} value the value of the refinement
5443
- * @return {RefinementList} a new and updated list
5444
- */
5445
- toggleRefinement: function toggleRefinement(refinementList, attribute, value) {
5446
- if (isUndefined(value)) throw new Error('toggleRefinement should be used with a value');
5447
-
5448
- if (lib.isRefined(refinementList, attribute, value)) {
5449
- return lib.removeRefinement(refinementList, attribute, value);
5450
- }
5451
-
5452
- return lib.addRefinement(refinementList, attribute, value);
5453
- },
5454
- /**
5455
- * Clear all or parts of a RefinementList. Depending on the arguments, three
5456
- * behaviors can happen:
5457
- * - if no attribute is provided: clears the whole list
5458
- * - if an attribute is provided as a string: clears the list for the specific attribute
5459
- * - if an attribute is provided as a function: discards the elements for which the function returns true
5460
- * @param {RefinementList} refinementList the initial list
5461
- * @param {string} [attribute] the attribute or function to discard
5462
- * @param {string} [refinementType] optionnal parameter to give more context to the attribute function
5463
- * @return {RefinementList} a new and updated refinement list
5464
- */
5465
- clearRefinement: function clearRefinement(refinementList, attribute, refinementType) {
5466
- if (isUndefined(attribute)) {
5467
- return {};
5468
- } else if (isString(attribute)) {
5469
- return omit(refinementList, attribute);
5470
- } else if (isFunction(attribute)) {
5471
- return reduce(refinementList, function(memo, values, key) {
5472
- var facetList = filter(values, function(value) {
5473
- return !attribute(value, key, refinementType);
5474
- });
5475
-
5476
- if (!isEmpty(facetList)) memo[key] = facetList;
5477
-
5478
- return memo;
5479
- }, {});
5480
- }
5481
- },
5482
- /**
5483
- * Test if the refinement value is used for the attribute. If no refinement value
5484
- * is provided, test if the refinementList contains any refinement for the
5485
- * given attribute.
5486
- * @param {RefinementList} refinementList the list of refinement
5487
- * @param {string} attribute name of the attribute
5488
- * @param {string} refinementValue value of the filter/refinement
5489
- * @return {boolean}
5490
- */
5491
- isRefined: function isRefined(refinementList, attribute, refinementValue) {
5492
- var indexOf = require('lodash/array/indexOf');
5493
-
5494
- var containsRefinements = !!refinementList[attribute] &&
5495
- refinementList[attribute].length > 0;
5496
-
5497
- if (isUndefined(refinementValue) || !containsRefinements) {
5498
- return containsRefinements;
5499
- }
5500
-
5501
- var refinementValueAsString = '' + refinementValue;
5502
-
5503
- return indexOf(refinementList[attribute], refinementValueAsString) !== -1;
5504
- }
5505
- };
5506
-
5507
- module.exports = lib;
5508
-
5509
- },{"lodash/array/indexOf":5,"lodash/collection/filter":9,"lodash/collection/reduce":15,"lodash/lang/isEmpty":128,"lodash/lang/isFunction":129,"lodash/lang/isString":133,"lodash/lang/isUndefined":135,"lodash/object/defaults":139,"lodash/object/omit":143}],152:[function(require,module,exports){
5510
- 'use strict';
5511
-
5512
- var keys = require('lodash/object/keys');
5513
- var intersection = require('lodash/array/intersection');
5514
- var forEach = require('lodash/collection/forEach');
5515
- var reduce = require('lodash/collection/reduce');
5516
- var filter = require('lodash/collection/filter');
5517
- var omit = require('lodash/object/omit');
5518
- var indexOf = require('lodash/array/indexOf');
5519
- var isEmpty = require('lodash/lang/isEmpty');
5520
- var isUndefined = require('lodash/lang/isUndefined');
5521
- var isString = require('lodash/lang/isString');
5522
- var isFunction = require('lodash/lang/isFunction');
5523
- var find = require('lodash/collection/find');
5524
- var pluck = require('lodash/collection/pluck');
5525
-
5526
- var defaults = require('lodash/object/defaults');
5527
- var merge = require('lodash/object/merge');
5528
- var deepFreeze = require('../functions/deepFreeze');
5529
-
5530
- var RefinementList = require('./RefinementList');
5531
-
5532
- /**
5533
- * @typedef {string[]} SearchParameters.FacetList
5534
- */
5535
-
5536
- /**
5537
- * @typedef {Object.<string, number>} SearchParameters.OperatorList
5538
- */
5539
-
5540
- /**
5541
- * SearchParameters is the data structure that contains all the informations
5542
- * usable for making a search to Algolia API. It doesn't do the search itself,
5543
- * nor does it contains logic about the parameters.
5544
- * It is an immutable object, therefore it has been created in a way that each
5545
- * changes does not change the object itself but returns a copy with the
5546
- * modification.
5547
- * This object should probably not be instantiated outside of the helper. It will
5548
- * be provided when needed. This object is documented for reference as you'll
5549
- * get it from events generated by the {@link AlgoliaSearchHelper}.
5550
- * If need be, instanciate the Helper from the factory function {@link SearchParameters.make}
5551
- * @constructor
5552
- * @classdesc contains all the parameters of a search
5553
- * @param {object|SearchParameters} newParameters existing parameters or partial object for the properties of a new SearchParameters
5554
- * @see SearchParameters.make
5555
- * @example <caption>SearchParameters of the first query in <a href="http://demos.algolia.com/instant-search-demo">the instant search demo</a></caption>
5556
- {
5557
- "query": "",
5558
- "disjunctiveFacets": [
5559
- "customerReviewCount",
5560
- "category",
5561
- "salePrice_range",
5562
- "manufacturer"
5563
- ],
5564
- "maxValuesPerFacet": 30,
5565
- "page": 0,
5566
- "hitsPerPage": 10,
5567
- "facets": [
5568
- "type",
5569
- "shipping"
5570
- ]
5571
- }
5572
- */
5573
- function SearchParameters(newParameters) {
5574
- var params = newParameters || {};
5575
-
5576
- // Query
5577
- /**
5578
- * Query string of the instant search. The empty string is a valid query.
5579
- * @member {string}
5580
- * @see https://www.algolia.com/doc#query
5581
- */
5582
- this.query = params.query || '';
5583
-
5584
- // Facets
5585
- /**
5586
- * All the facets that will be requested to the server
5587
- * @member {string[]}
5588
- */
5589
- this.facets = params.facets || [];
5590
- /**
5591
- * All the declared disjunctive facets
5592
- * @member {string[]}
5593
- */
5594
- this.disjunctiveFacets = params.disjunctiveFacets || [];
5595
- /**
5596
- * All the declared hierarchical facets,
5597
- * a hierarchical facet is a disjunctive facet with some specific behavior
5598
- * @member {string[]|object[]}
5599
- */
5600
- this.hierarchicalFacets = params.hierarchicalFacets || [];
5601
-
5602
- // Refinements
5603
- /**
5604
- * @private
5605
- * @member {Object.<string, SearchParameters.FacetList>}
5606
- */
5607
- this.facetsRefinements = params.facetsRefinements || {};
5608
- /**
5609
- * @private
5610
- * @member {Object.<string, SearchParameters.FacetList>}
5611
- */
5612
- this.facetsExcludes = params.facetsExcludes || {};
5613
- /**
5614
- * @private
5615
- * @member {Object.<string, SearchParameters.FacetList>}
5616
- */
5617
- this.disjunctiveFacetsRefinements = params.disjunctiveFacetsRefinements || {};
5618
- /**
5619
- * @private
5620
- * @member {Object.<string, SearchParameters.OperatorList>}
5621
- */
5622
- this.numericRefinements = params.numericRefinements || {};
5623
- /**
5624
- * Contains the tags used to refine the query
5625
- * Associated property in the query: tagFilters
5626
- * @private
5627
- * @member {string[]}
5628
- */
5629
- this.tagRefinements = params.tagRefinements || [];
5630
- /**
5631
- * @private
5632
- * @member {Object.<string, SearchParameters.FacetList>}
5633
- */
5634
- this.hierarchicalFacetsRefinements = params.hierarchicalFacetsRefinements || {};
5635
-
5636
- /**
5637
- * Contains the tag filters in the raw format of the Algolia API. Setting this
5638
- * parameter is not compatible with the of the add/remove/toggle methods of the
5639
- * tag api.
5640
- * @see https://www.algolia.com/doc#tagFilters
5641
- * @member {string}
5642
- */
5643
- this.tagFilters = params.tagFilters;
5644
-
5645
- // Misc. parameters
5646
- /**
5647
- * Number of hits to be returned by the search API
5648
- * @member {number}
5649
- * @see https://www.algolia.com/doc#hitsPerPage
5650
- */
5651
- this.hitsPerPage = params.hitsPerPage;
5652
- /**
5653
- * Number of values for each facetted attribute
5654
- * @member {number}
5655
- * @see https://www.algolia.com/doc#maxValuesPerFacet
5656
- */
5657
- this.maxValuesPerFacet = params.maxValuesPerFacet;
5658
- /**
5659
- * The current page number
5660
- * @member {number}
5661
- * @see https://www.algolia.com/doc#page
5662
- */
5663
- this.page = params.page || 0;
5664
- /**
5665
- * How the query should be treated by the search engine.
5666
- * Possible values: prefixAll, prefixLast, prefixNone
5667
- * @see https://www.algolia.com/doc#queryType
5668
- * @member {string}
5669
- */
5670
- this.queryType = params.queryType;
5671
- /**
5672
- * How the typo tolerance behave in the search engine.
5673
- * Possible values: true, false, min, strict
5674
- * @see https://www.algolia.com/doc#typoTolerance
5675
- * @member {string}
5676
- */
5677
- this.typoTolerance = params.typoTolerance;
5678
-
5679
- /**
5680
- * Number of characters to wait before doing one character replacement.
5681
- * @see https://www.algolia.com/doc#minWordSizefor1Typo
5682
- * @member {number}
5683
- */
5684
- this.minWordSizefor1Typo = params.minWordSizefor1Typo;
5685
- /**
5686
- * Number of characters to wait before doing a second character replacement.
5687
- * @see https://www.algolia.com/doc#minWordSizefor2Typos
5688
- * @member {number}
5689
- */
5690
- this.minWordSizefor2Typos = params.minWordSizefor2Typos;
5691
- /**
5692
- * Should the engine allow typos on numerics.
5693
- * @see https://www.algolia.com/doc#allowTyposOnNumericTokens
5694
- * @member {boolean}
5695
- */
5696
- this.allowTyposOnNumericTokens = params.allowTyposOnNumericTokens;
5697
- /**
5698
- * Should the plurals be ignored
5699
- * @see https://www.algolia.com/doc#ignorePlurals
5700
- * @member {boolean}
5701
- */
5702
- this.ignorePlurals = params.ignorePlurals;
5703
- /**
5704
- * Restrict which attribute is searched.
5705
- * @see https://www.algolia.com/doc#restrictSearchableAttributes
5706
- * @member {string}
5707
- */
5708
- this.restrictSearchableAttributes = params.restrictSearchableAttributes;
5709
- /**
5710
- * Enable the advanced syntax.
5711
- * @see https://www.algolia.com/doc#advancedSyntax
5712
- * @member {boolean}
5713
- */
5714
- this.advancedSyntax = params.advancedSyntax;
5715
- /**
5716
- * Enable the analytics
5717
- * @see https://www.algolia.com/doc#analytics
5718
- * @member {boolean}
5719
- */
5720
- this.analytics = params.analytics;
5721
- /**
5722
- * Tag of the query in the analytics.
5723
- * @see https://www.algolia.com/doc#analyticsTags
5724
- * @member {string}
5725
- */
5726
- this.analyticsTags = params.analyticsTags;
5727
- /**
5728
- * Enable the synonyms
5729
- * @see https://www.algolia.com/doc#synonyms
5730
- * @member {boolean}
5731
- */
5732
- this.synonyms = params.synonyms;
5733
- /**
5734
- * Should the engine replace the synonyms in the highlighted results.
5735
- * @see https://www.algolia.com/doc#replaceSynonymsInHighlight
5736
- * @member {boolean}
5737
- */
5738
- this.replaceSynonymsInHighlight = params.replaceSynonymsInHighlight;
5739
- /**
5740
- * Add some optional words to those defined in the dashboard
5741
- * @see https://www.algolia.com/doc#optionalWords
5742
- * @member {string}
5743
- */
5744
- this.optionalWords = params.optionalWords;
5745
- /**
5746
- * Possible values are "lastWords" "firstWords" "allOptionnal" "none" (default)
5747
- * @see https://www.algolia.com/doc#removeWordsIfNoResults
5748
- * @member {string}
5749
- */
5750
- this.removeWordsIfNoResults = params.removeWordsIfNoResults;
5751
- /**
5752
- * List of attributes to retrieve
5753
- * @see https://www.algolia.com/doc#attributesToRetrieve
5754
- * @member {string}
5755
- */
5756
- this.attributesToRetrieve = params.attributesToRetrieve;
5757
- /**
5758
- * List of attributes to highlight
5759
- * @see https://www.algolia.com/doc#attributesToHighlight
5760
- * @member {string}
5761
- */
5762
- this.attributesToHighlight = params.attributesToHighlight;
5763
- /**
5764
- * Code to be embedded on the left part of the highlighted results
5765
- * @see https://www.algolia.com/doc#highlightPreTag
5766
- * @member {string}
5767
- */
5768
- this.highlightPreTag = params.highlightPreTag;
5769
- /**
5770
- * Code to be embedded on the right part of the highlighted results
5771
- * @see https://www.algolia.com/doc#highlightPostTag
5772
- * @member {string}
5773
- */
5774
- this.highlightPostTag = params.highlightPostTag;
5775
- /**
5776
- * List of attributes to snippet
5777
- * @see https://www.algolia.com/doc#attributesToSnippet
5778
- * @member {string}
5779
- */
5780
- this.attributesToSnippet = params.attributesToSnippet;
5781
- /**
5782
- * Enable the ranking informations in the response
5783
- * @see https://www.algolia.com/doc#getRankingInfo
5784
- * @member {integer}
5785
- */
5786
- this.getRankingInfo = params.getRankingInfo;
5787
- /**
5788
- * Remove duplicates based on the index setting attributeForDistinct
5789
- * @see https://www.algolia.com/doc#distinct
5790
- * @member {boolean}
5791
- */
5792
- this.distinct = params.distinct;
5793
- /**
5794
- * Center of the geo search.
5795
- * @see https://www.algolia.com/doc#aroundLatLng
5796
- * @member {string}
5797
- */
5798
- this.aroundLatLng = params.aroundLatLng;
5799
- /**
5800
- * Center of the search, retrieve from the user IP.
5801
- * @see https://www.algolia.com/doc#aroundLatLngViaIP
5802
- * @member {boolean}
5803
- */
5804
- this.aroundLatLngViaIP = params.aroundLatLngViaIP;
5805
- /**
5806
- * Radius of the geo search.
5807
- * @see https://www.algolia.com/doc#aroundRadius
5808
- * @member {number}
5809
- */
5810
- this.aroundRadius = params.aroundRadius;
5811
- /**
5812
- * Precision of the geo search.
5813
- * @see https://www.algolia.com/doc#aroundPrecision
5814
- * @member {number}
5815
- */
5816
- this.aroundPrecision = params.aroundPrecision;
5817
- /**
5818
- * Geo search inside a box.
5819
- * @see https://www.algolia.com/doc#insideBoundingBox
5820
- * @member {string}
5821
- */
5822
- this.insideBoundingBox = params.insideBoundingBox;
5823
- }
5824
-
5825
- /**
5826
- * Factory for SearchParameters
5827
- * @param {object|SearchParameters} newParameters existing parameters or partial object for the properties of a new SearchParameters
5828
- * @return {SearchParameters} frozen instance of SearchParameters
5829
- */
5830
- SearchParameters.make = function makeSearchParameters(newParameters) {
5831
- var instance = new SearchParameters(newParameters);
5832
-
5833
- return deepFreeze(instance);
5834
- };
5835
-
5836
- /**
5837
- * Validates the new parameters based on the previous state
5838
- * @param {SearchParameters} currentState the current state
5839
- * @param {object|SearchParameters} parameters the new parameters to set
5840
- * @return {Error|null} Error if the modification is invalid, null otherwise
5841
- */
5842
- SearchParameters.validate = function(currentState, parameters) {
5843
- var params = parameters || {};
5844
-
5845
- var ks = keys(params);
5846
- var unknownKeys = filter(ks, function(k) {
5847
- return !currentState.hasOwnProperty(k);
5848
- });
5849
-
5850
- if (unknownKeys.length === 1) return new Error('Property ' + unknownKeys[0] + ' is not defined on SearchParameters (see http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)');
5851
- if (unknownKeys.length > 1) return new Error('Properties ' + unknownKeys.join(' ') + ' are not defined on SearchParameters (see http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)');
5852
-
5853
- if (currentState.tagFilters && params.tagRefinements && params.tagRefinements.length > 0) {
5854
- return new Error("[Tags] Can't switch from the managed tag API to the advanced API. It is probably an error, if it's really what you want, you should first clear the tags with clearTags method.");
5855
- }
5856
-
5857
- if (currentState.tagRefinements.length > 0 && params.tagFilters) {
5858
- return new Error("[Tags] Can't switch from the advanced tag API to the managed API. It is probably an error, if it's not, you should first clear the tags with clearTags method.");
5859
- }
5860
-
5861
- return null;
5862
- };
5863
-
5864
- SearchParameters.prototype = {
5865
- constructor: SearchParameters,
5866
-
5867
- /**
5868
- * Remove all refinements (disjunctive + conjunctive + excludes + numeric filters)
5869
- * @method
5870
- * @param {string|SearchParameters.clearCallback} [attribute] optionnal string or function
5871
- * - If not given, means to clear all the filters.
5872
- * - If `string`, means to clear all refinements for the `attribute` named filter.
5873
- * - If `function`, means to clear all the refinements that return truthy values.
5874
- * @return {SearchParameters}
5875
- */
5876
- clearRefinements: function clearRefinements(attribute) {
5877
- return this.setQueryParameters({
5878
- page: 0,
5879
- numericRefinements: this._clearNumericRefinements(attribute),
5880
- facetsRefinements: RefinementList.clearRefinement(this.facetsRefinements, attribute, 'conjunctiveFacet'),
5881
- facetsExcludes: RefinementList.clearRefinement(this.facetsExcludes, attribute, 'exclude'),
5882
- disjunctiveFacetsRefinements: RefinementList.clearRefinement(this.disjunctiveFacetsRefinements, attribute, 'disjunctiveFacet'),
5883
- hierarchicalFacetsRefinements: RefinementList.clearRefinement(this.hierarchicalFacetsRefinements, attribute, 'hierarchicalFacet')
5884
- });
5885
- },
5886
- /**
5887
- * Remove all the refined tags from the SearchParameters
5888
- * @method
5889
- * @return {SearchParameters}
5890
- */
5891
- clearTags: function clearTags() {
5892
- if (this.tagFilters === undefined && this.tagRefinements.length === 0) return this;
5893
-
5894
- return this.setQueryParameters({
5895
- page: 0,
5896
- tagFilters: undefined,
5897
- tagRefinements: []
5898
- });
5899
- },
5900
- /**
5901
- * Query setter
5902
- * @method
5903
- * @param {string} newQuery value for the new query
5904
- * @return {SearchParameters}
5905
- */
5906
- setQuery: function setQuery(newQuery) {
5907
- if (newQuery === this.query) return this;
5908
-
5909
- return this.setQueryParameters({
5910
- query: newQuery,
5911
- page: 0
5912
- });
5913
- },
5914
- /**
5915
- * Page setter
5916
- * @method
5917
- * @param {number} newPage new page number
5918
- * @return {SearchParameters}
5919
- */
5920
- setPage: function setPage(newPage) {
5921
- if (newPage === this.page) return this;
5922
-
5923
- return this.setQueryParameters({
5924
- page: newPage
5925
- });
5926
- },
5927
- /**
5928
- * Facets setter
5929
- * The facets are the simple facets, used for conjunctive (and) facetting.
5930
- * @method
5931
- * @param {string[]} facets all the attributes of the algolia records used for conjunctive facetting
5932
- * @return {SearchParameters}
5933
- */
5934
- setFacets: function setFacets(facets) {
5935
- return this.setQueryParameters({
5936
- facets: facets
5937
- });
5938
- },
5939
- /**
5940
- * Disjunctive facets setter
5941
- * Change the list of disjunctive (or) facets the helper chan handle.
5942
- * @method
5943
- * @param {string[]} facets all the attributes of the algolia records used for disjunctive facetting
5944
- * @return {SearchParameters}
5945
- */
5946
- setDisjunctiveFacets: function setDisjunctiveFacets(facets) {
5947
- return this.setQueryParameters({
5948
- disjunctiveFacets: facets
5949
- });
5950
- },
5951
- /**
5952
- * HitsPerPage setter
5953
- * Hits per page represents the number of hits retrieved for this query
5954
- * @method
5955
- * @param {number} n number of hits retrieved per page of results
5956
- * @return {SearchParameters}
5957
- */
5958
- setHitsPerPage: function setHitsPerPage(n) {
5959
- if (this.hitsPerPage === n) return this;
5960
-
5961
- return this.setQueryParameters({
5962
- hitsPerPage: n,
5963
- page: 0
5964
- });
5965
- },
5966
- /**
5967
- * typoTolerance setter
5968
- * Set the value of typoTolerance
5969
- * @method
5970
- * @param {string} typoTolerance new value of typoTolerance ("true", "false", "min" or "strict")
5971
- * @return {SearchParameters}
5972
- */
5973
- setTypoTolerance: function setTypoTolerance(typoTolerance) {
5974
- if (this.typoTolerance === typoTolerance) return this;
5975
-
5976
- return this.setQueryParameters({
5977
- typoTolerance: typoTolerance,
5978
- page: 0
5979
- });
5980
- },
5981
- /**
5982
- * Add or update a numeric filter for a given attribute
5983
- * Current limitation of the numeric filters: you can't have more than one value
5984
- * filtered for each (attribute, oprator). It means that you can't have a filter
5985
- * for ("attribute", "=", 3 ) and ("attribute", "=", 8)
5986
- * @method
5987
- * @param {string} attribute attribute to set the filter on
5988
- * @param {string} operator operator of the filter (possible values: =, >, >=, <, <=, !=)
5989
- * @param {number} value value of the filter
5990
- * @return {SearchParameters}
5991
- */
5992
- addNumericRefinement: function(attribute, operator, value) {
5993
- if (this.isNumericRefined(attribute, operator, value)) return this;
5994
-
5995
- var mod = merge({}, this.numericRefinements);
5996
-
5997
- mod[attribute] = merge({}, mod[attribute]);
5998
- mod[attribute][operator] = value;
5999
-
6000
- return this.setQueryParameters({
6001
- page: 0,
6002
- numericRefinements: mod
6003
- });
6004
- },
6005
- /**
6006
- * Get the list of conjunctive refinements for a single facet
6007
- * @param {string} facetName name of the attribute used for facetting
6008
- * @return {string[]} list of refinements
6009
- */
6010
- getConjunctiveRefinements: function(facetName) {
6011
- if (!this.isConjunctiveFacet(facetName)) {
6012
- throw new Error(facetName + ' is not defined in the facets attribute of the helper configuration');
6013
- }
6014
- return this.facetsRefinements[facetName] || [];
6015
- },
6016
- /**
6017
- * Get the list of disjunctive refinements for a single facet
6018
- * @param {string} facetName name of the attribute used for facetting
6019
- * @return {string[]} list of refinements
6020
- */
6021
- getDisjunctiveRefinements: function(facetName) {
6022
- if (!this.isDisjunctiveFacet(facetName)) {
6023
- throw new Error(facetName + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
6024
- }
6025
- return this.disjunctiveFacetsRefinements[facetName] || [];
6026
- },
6027
- /**
6028
- * Get the list of hierarchical refinements for a single facet
6029
- * @param {string} facetName name of the attribute used for facetting
6030
- * @return {string[]} list of refinements
6031
- */
6032
- getHierarchicalRefinement: function(facetName) {
6033
- // we send an array but we currently do not support multiple hierarchicalRefinements for a hierarchicalFacet
6034
- return this.hierarchicalFacetsRefinements[facetName] || [];
6035
- },
6036
- /**
6037
- * Get the list of exclude refinements for a single facet
6038
- * @param {string} facetName name of the attribute used for facetting
6039
- * @return {string[]} list of refinements
6040
- */
6041
- getExcludeRefinements: function(facetName) {
6042
- if (!this.isConjunctiveFacet(facetName)) {
6043
- throw new Error(facetName + ' is not defined in the facets attribute of the helper configuration');
6044
- }
6045
- return this.facetsExcludes[facetName] || [];
6046
- },
6047
- /**
6048
- * Remove a numeric filter
6049
- * @method
6050
- * @param {string} attribute attribute to set the filter on
6051
- * @param {string} operator operator of the filter (possible values: =, >, >=, <, <=, !=)
6052
- * @return {SearchParameters}
6053
- */
6054
- removeNumericRefinement: function(attribute, operator) {
6055
- if (!this.isNumericRefined(attribute, operator)) return this;
6056
-
6057
- return this.setQueryParameters({
6058
- page: 0,
6059
- numericRefinements: this._clearNumericRefinements(function(value, key) {
6060
- return key === attribute && value.op === operator;
6061
- })
6062
- });
6063
- },
6064
- /**
6065
- * Get the list of numeric refinements for a single facet
6066
- * @param {string} facetName name of the attribute used for facetting
6067
- * @return {SearchParameters.OperatorList[]} list of refinements
6068
- */
6069
- getNumericRefinements: function(facetName) {
6070
- return this.numericRefinements[facetName] || [];
6071
- },
6072
- /**
6073
- * Return the current refinement for the (attribute, operator)
6074
- * @param {string} attribute of the record
6075
- * @param {string} operator applied
6076
- * @return {number} value of the refinement
6077
- */
6078
- getNumericRefinement: function(attribute, operator) {
6079
- return this.numericRefinements[attribute] && this.numericRefinements[attribute][operator];
6080
- },
6081
- /**
6082
- * Clear numeric filters.
6083
- * @method
6084
- * @private
6085
- * @param {string|SearchParameters.clearCallback} [attribute] optionnal string or function
6086
- * - If not given, means to clear all the filters.
6087
- * - If `string`, means to clear all refinements for the `attribute` named filter.
6088
- * - If `function`, means to clear all the refinements that return truthy values.
6089
- * @return {Object.<string, OperatorList>}
6090
- */
6091
- _clearNumericRefinements: function _clearNumericRefinements(attribute) {
6092
- if (isUndefined(attribute)) {
6093
- return {};
6094
- } else if (isString(attribute)) {
6095
- return omit(this.numericRefinements, attribute);
6096
- } else if (isFunction(attribute)) {
6097
- return reduce(this.numericRefinements, function(memo, operators, key) {
6098
- var operatorList = omit(operators, function(value, operator) {
6099
- return attribute({val: value, op: operator}, key, 'numeric');
6100
- });
6101
-
6102
- if (!isEmpty(operatorList)) memo[key] = operatorList;
6103
-
6104
- return memo;
6105
- }, {});
6106
- }
6107
- },
6108
- /**
6109
- * Add a refinement on a "normal" facet
6110
- * @method
6111
- * @param {string} facet attribute to apply the facetting on
6112
- * @param {string} value value of the attribute (will be converted to string)
6113
- * @return {SearchParameters}
6114
- */
6115
- addFacetRefinement: function addFacetRefinement(facet, value) {
6116
- if (!this.isConjunctiveFacet(facet)) {
6117
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6118
- }
6119
- if (RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;
6120
-
6121
- return this.setQueryParameters({
6122
- page: 0,
6123
- facetsRefinements: RefinementList.addRefinement(this.facetsRefinements, facet, value)
6124
- });
6125
- },
6126
- /**
6127
- * Exclude a value from a "normal" facet
6128
- * @method
6129
- * @param {string} facet attribute to apply the exclusion on
6130
- * @param {string} value value of the attribute (will be converted to string)
6131
- * @return {SearchParameters}
6132
- */
6133
- addExcludeRefinement: function addExcludeRefinement(facet, value) {
6134
- if (!this.isConjunctiveFacet(facet)) {
6135
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6136
- }
6137
- if (RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;
6138
-
6139
- return this.setQueryParameters({
6140
- page: 0,
6141
- facetsExcludes: RefinementList.addRefinement(this.facetsExcludes, facet, value)
6142
- });
6143
- },
6144
- /**
6145
- * Adds a refinement on a disjunctive facet.
6146
- * @method
6147
- * @param {string} facet attribute to apply the facetting on
6148
- * @param {string} value value of the attribute (will be converted to string)
6149
- * @return {SearchParameters}
6150
- */
6151
- addDisjunctiveFacetRefinement: function addDisjunctiveFacetRefinement(facet, value) {
6152
- if (!this.isDisjunctiveFacet(facet)) {
6153
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
6154
- }
6155
-
6156
- if (RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;
6157
-
6158
- return this.setQueryParameters({
6159
- page: 0,
6160
- disjunctiveFacetsRefinements: RefinementList.addRefinement(this.disjunctiveFacetsRefinements, facet, value)
6161
- });
6162
- },
6163
- /**
6164
- * addTagRefinement adds a tag to the list used to filter the results
6165
- * @param {string} tag tag to be added
6166
- * @return {SearchParameters}
6167
- */
6168
- addTagRefinement: function addTagRefinement(tag) {
6169
- if (this.isTagRefined(tag)) return this;
6170
-
6171
- var modification = {
6172
- page: 0,
6173
- tagRefinements: this.tagRefinements.concat(tag)
6174
- };
6175
-
6176
- return this.setQueryParameters(modification);
6177
- },
6178
- /**
6179
- * Remove a refinement set on facet. If a value is provided, it will clear the
6180
- * refinement for the given value, otherwise it will clear all the refinement
6181
- * values for the facetted attribute.
6182
- * @method
6183
- * @param {string} facet name of the attribute used for facetting
6184
- * @param {string} value value used to filter
6185
- * @return {SearchParameters}
6186
- */
6187
- removeFacetRefinement: function removeFacetRefinement(facet, value) {
6188
- if (!this.isConjunctiveFacet(facet)) {
6189
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6190
- }
6191
- if (!RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;
6192
-
6193
- return this.setQueryParameters({
6194
- page: 0,
6195
- facetsRefinements: RefinementList.removeRefinement(this.facetsRefinements, facet, value)
6196
- });
6197
- },
6198
- /**
6199
- * Remove a negative refinement on a facet
6200
- * @method
6201
- * @param {string} facet name of the attribute used for facetting
6202
- * @param {string} value value used to filter
6203
- * @return {SearchParameters}
6204
- */
6205
- removeExcludeRefinement: function removeExcludeRefinement(facet, value) {
6206
- if (!this.isConjunctiveFacet(facet)) {
6207
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6208
- }
6209
- if (!RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;
6210
-
6211
- return this.setQueryParameters({
6212
- page: 0,
6213
- facetsExcludes: RefinementList.removeRefinement(this.facetsExcludes, facet, value)
6214
- });
6215
- },
6216
- /**
6217
- * Remove a refinement on a disjunctive facet
6218
- * @method
6219
- * @param {string} facet name of the attribute used for facetting
6220
- * @param {string} value value used to filter
6221
- * @return {SearchParameters}
6222
- */
6223
- removeDisjunctiveFacetRefinement: function removeDisjunctiveFacetRefinement(facet, value) {
6224
- if (!this.isDisjunctiveFacet(facet)) {
6225
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
6226
- }
6227
- if (!RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;
6228
-
6229
- return this.setQueryParameters({
6230
- page: 0,
6231
- disjunctiveFacetsRefinements: RefinementList.removeRefinement(this.disjunctiveFacetsRefinements, facet, value)
6232
- });
6233
- },
6234
- /**
6235
- * Remove a tag from the list of tag refinements
6236
- * @method
6237
- * @param {string} tag the tag to remove
6238
- * @return {SearchParameters}
6239
- */
6240
- removeTagRefinement: function removeTagRefinement(tag) {
6241
- if (!this.isTagRefined(tag)) return this;
6242
-
6243
- var modification = {
6244
- page: 0,
6245
- tagRefinements: filter(this.tagRefinements, function(t) { return t !== tag; })
6246
- };
6247
-
6248
- return this.setQueryParameters(modification);
6249
- },
6250
- /**
6251
- * Switch the refinement applied over a facet/value
6252
- * @method
6253
- * @param {string} facet name of the attribute used for facetting
6254
- * @param {value} value value used for filtering
6255
- * @return {SearchParameters}
6256
- */
6257
- toggleFacetRefinement: function toggleFacetRefinement(facet, value) {
6258
- if (!this.isConjunctiveFacet(facet)) {
6259
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6260
- }
6261
-
6262
- return this.setQueryParameters({
6263
- page: 0,
6264
- facetsRefinements: RefinementList.toggleRefinement(this.facetsRefinements, facet, value)
6265
- });
6266
- },
6267
- /**
6268
- * Switch the refinement applied over a facet/value
6269
- * @method
6270
- * @param {string} facet name of the attribute used for facetting
6271
- * @param {value} value value used for filtering
6272
- * @return {SearchParameters}
6273
- */
6274
- toggleExcludeFacetRefinement: function toggleExcludeFacetRefinement(facet, value) {
6275
- if (!this.isConjunctiveFacet(facet)) {
6276
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6277
- }
6278
-
6279
- return this.setQueryParameters({
6280
- page: 0,
6281
- facetsExcludes: RefinementList.toggleRefinement(this.facetsExcludes, facet, value)
6282
- });
6283
- },
6284
- /**
6285
- * Switch the refinement applied over a facet/value
6286
- * @method
6287
- * @param {string} facet name of the attribute used for facetting
6288
- * @param {value} value value used for filtering
6289
- * @return {SearchParameters}
6290
- */
6291
- toggleDisjunctiveFacetRefinement: function toggleDisjunctiveFacetRefinement(facet, value) {
6292
- if (!this.isDisjunctiveFacet(facet)) {
6293
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
6294
- }
6295
-
6296
- return this.setQueryParameters({
6297
- page: 0,
6298
- disjunctiveFacetsRefinements: RefinementList.toggleRefinement(this.disjunctiveFacetsRefinements, facet, value)
6299
- });
6300
- },
6301
- /**
6302
- * Switch the refinement applied over a facet/value
6303
- * @method
6304
- * @param {string} facet name of the attribute used for facetting
6305
- * @param {value} value value used for filtering
6306
- * @return {SearchParameters}
6307
- */
6308
- toggleHierarchicalFacetRefinement: function toggleHierarchicalFacetRefinement(facet, value) {
6309
- if (!this.isHierarchicalFacet(facet)) {
6310
- throw new Error(facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration');
6311
- }
6312
-
6313
- var separator = this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facet));
6314
-
6315
- var mod = {};
6316
-
6317
- var upOneOrMultipleLevel = this.hierarchicalFacetsRefinements[facet] !== undefined &&
6318
- this.hierarchicalFacetsRefinements[facet].length > 0 && (
6319
- // remove current refinement:
6320
- // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`
6321
- this.hierarchicalFacetsRefinements[facet][0] === value ||
6322
- // remove a parent refinement of the current refinement:
6323
- // - refinement was 'beer > IPA > Flying dog'
6324
- // - call is toggleRefine('beer > IPA')
6325
- // - refinement should be `beer`
6326
- this.hierarchicalFacetsRefinements[facet][0].indexOf(value + separator) === 0
6327
- );
6328
-
6329
- if (upOneOrMultipleLevel) {
6330
- if (value.indexOf(separator) === -1) {
6331
- // go back to root level
6332
- mod[facet] = [];
6333
- } else {
6334
- mod[facet] = [value.slice(0, value.lastIndexOf(separator))];
6335
- }
6336
- } else {
6337
- mod[facet] = [value];
6338
- }
6339
-
6340
- return this.setQueryParameters({
6341
- hierarchicalFacetsRefinements: defaults({}, mod, this.hierarchicalFacetsRefinements)
6342
- });
6343
- },
6344
- /**
6345
- * Switch the tag refinement
6346
- * @method
6347
- * @param {string} tag the tag to remove or add
6348
- * @return {SearchParameters}
6349
- */
6350
- toggleTagRefinement: function toggleTagRefinement(tag) {
6351
- if (this.isTagRefined(tag)) {
6352
- return this.removeTagRefinement(tag);
6353
- }
6354
-
6355
- return this.addTagRefinement(tag);
6356
- },
6357
- /**
6358
- * Test if the facet name is from one of the disjunctive facets
6359
- * @method
6360
- * @param {string} facet facet name to test
6361
- * @return {boolean}
6362
- */
6363
- isDisjunctiveFacet: function(facet) {
6364
- return indexOf(this.disjunctiveFacets, facet) > -1;
6365
- },
6366
- /**
6367
- * Test if the facet name is from one of the hierarchical facets
6368
- * @method
6369
- * @param {string} facetName facet name to test
6370
- * @return {boolean}
6371
- */
6372
- isHierarchicalFacet: function(facetName) {
6373
- return this.getHierarchicalFacetByName(facetName) !== undefined;
6374
- },
6375
- /**
6376
- * Test if the facet name is from one of the conjunctive/normal facets
6377
- * @method
6378
- * @param {string} facet facet name to test
6379
- * @return {boolean}
6380
- */
6381
- isConjunctiveFacet: function(facet) {
6382
- return indexOf(this.facets, facet) > -1;
6383
- },
6384
- /**
6385
- * Returns true if the facet is refined, either for a specific value or in
6386
- * general.
6387
- * @method
6388
- * @param {string} facet name of the attribute for used for facetting
6389
- * @param {string} value, optionnal value. If passed will test that this value
6390
- * is filtering the given facet.
6391
- * @return {boolean} returns true if refined
6392
- */
6393
- isFacetRefined: function isFacetRefined(facet, value) {
6394
- if (!this.isConjunctiveFacet(facet)) {
6395
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6396
- }
6397
- return RefinementList.isRefined(this.facetsRefinements, facet, value);
6398
- },
6399
- /**
6400
- * Returns true if the facet contains exclusions or if a specific value is
6401
- * excluded
6402
- * @method
6403
- * @param {string} facet name of the attribute for used for facetting
6404
- * @param {string} value, optionnal value. If passed will test that this value
6405
- * is filtering the given facet.
6406
- * @return {boolean} returns true if refined
6407
- */
6408
- isExcludeRefined: function isExcludeRefined(facet, value) {
6409
- if (!this.isConjunctiveFacet(facet)) {
6410
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
6411
- }
6412
- return RefinementList.isRefined(this.facetsExcludes, facet, value);
6413
- },
6414
- /**
6415
- * Returns true if the facet contains a refinement, or if a value passed is a
6416
- * refinement for the facet.
6417
- * @method
6418
- * @param {string} facet name of the attribute for used for facetting
6419
- * @param {string} value optionnal, will test if the value is used for refinement
6420
- * if there is one, otherwise will test if the facet contains any refinement
6421
- * @return {boolean}
6422
- */
6423
- isDisjunctiveFacetRefined: function isDisjunctiveFacetRefined(facet, value) {
6424
- if (!this.isDisjunctiveFacet(facet)) {
6425
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
6426
- }
6427
- return RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value);
6428
- },
6429
- /**
6430
- * Test if the triple (attribute, operator, value) is already refined.
6431
- * If only the attribute and the operator are provided, it tests if the
6432
- * contains any refinement value.
6433
- * @method
6434
- * @param {string} attribute attribute for which the refinement is applied
6435
- * @param {string} operator operator of the refinement
6436
- * @param {string} [value] value of the refinement
6437
- * @return {boolean} true if it is refined
6438
- */
6439
- isNumericRefined: function isNumericRefined(attribute, operator, value) {
6440
- if (isUndefined(value)) {
6441
- return this.numericRefinements[attribute] &&
6442
- !isUndefined(this.numericRefinements[attribute][operator]);
6443
- }
6444
-
6445
- return this.numericRefinements[attribute] &&
6446
- !isUndefined(this.numericRefinements[attribute][operator]) &&
6447
- this.numericRefinements[attribute][operator] === value;
6448
- },
6449
- /**
6450
- * Returns true if the tag refined, false otherwise
6451
- * @method
6452
- * @param {string} tag the tag to check
6453
- * @return {boolean}
6454
- */
6455
- isTagRefined: function isTagRefined(tag) {
6456
- return indexOf(this.tagRefinements, tag) !== -1;
6457
- },
6458
- /**
6459
- * Returns the list of all disjunctive facets refined
6460
- * @method
6461
- * @param {string} facet name of the attribute used for facetting
6462
- * @param {value} value value used for filtering
6463
- * @return {string[]}
6464
- */
6465
- getRefinedDisjunctiveFacets: function getRefinedDisjunctiveFacets() {
6466
- // attributes used for numeric filter can also be disjunctive
6467
- var disjunctiveNumericRefinedFacets = intersection(
6468
- keys(this.numericRefinements),
6469
- this.disjunctiveFacets
6470
- );
6471
-
6472
- return keys(this.disjunctiveFacetsRefinements)
6473
- .concat(disjunctiveNumericRefinedFacets)
6474
- .concat(this.getRefinedHierarchicalFacets());
6475
- },
6476
- /**
6477
- * Returns the list of all disjunctive facets refined
6478
- * @method
6479
- * @param {string} facet name of the attribute used for facetting
6480
- * @param {value} value value used for filtering
6481
- * @return {string[]}
6482
- */
6483
- getRefinedHierarchicalFacets: function getRefinedHierarchicalFacets() {
6484
- return intersection(
6485
- // enforce the order between the two arrays,
6486
- // so that refinement name index === hierarchical facet index
6487
- pluck(this.hierarchicalFacets, 'name'),
6488
- keys(this.hierarchicalFacetsRefinements)
6489
- );
6490
- },
6491
- /**
6492
- * Returned the list of all disjunctive facets not refined
6493
- * @method
6494
- * @return {string[]}
6495
- */
6496
- getUnrefinedDisjunctiveFacets: function() {
6497
- var refinedFacets = this.getRefinedDisjunctiveFacets();
6498
-
6499
- return filter(this.disjunctiveFacets, function(f) {
6500
- return indexOf(refinedFacets, f) === -1;
6501
- });
6502
- },
6503
-
6504
- managedParameters: [
6505
- 'facets', 'disjunctiveFacets', 'facetsRefinements',
6506
- 'facetsExcludes', 'disjunctiveFacetsRefinements',
6507
- 'numericRefinements', 'tagRefinements', 'hierarchicalFacets', 'hierarchicalFacetsRefinements'
6508
- ],
6509
- getQueryParams: function getQueryParams() {
6510
- var managedParameters = this.managedParameters;
6511
-
6512
- // FIXME with lodash
6513
- return reduce(this, function(memo, value, parameter, parameters) {
6514
- if (indexOf(managedParameters, parameter) === -1 &&
6515
- parameters[parameter] !== undefined) {
6516
- memo[parameter] = value;
6517
- }
6518
-
6519
- return memo;
6520
- }, {});
6521
- },
6522
- /**
6523
- * Let the user retrieve any parameter value from the SearchParameters
6524
- * @param {string} paramName name of the parameter
6525
- * @return {any} the value of the parameter
6526
- */
6527
- getQueryParameter: function getQueryParameter(paramName) {
6528
- if (!this.hasOwnProperty(paramName)) throw new Error("Parameter '" + paramName + "' is not an attribute of SearchParameters (http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)");
6529
-
6530
- return this[paramName];
6531
- },
6532
- /**
6533
- * Let the user set a specific value for a given parameter. Will return the
6534
- * same instance if the parameter is invalid or if the value is the same as the
6535
- * previous one.
6536
- * @method
6537
- * @param {string} parameter the parameter name
6538
- * @param {any} value the value to be set, must be compliant with the definition of the attribute on the object
6539
- * @return {SearchParameters} the updated state
6540
- */
6541
- setQueryParameter: function setParameter(parameter, value) {
6542
- if (this[parameter] === value) return this;
6543
-
6544
- var modification = {};
6545
-
6546
- modification[parameter] = value;
6547
-
6548
- return this.setQueryParameters(modification);
6549
- },
6550
- /**
6551
- * Let the user set any of the parameters with a plain object.
6552
- * It won't let the user define custom properties.
6553
- * @method
6554
- * @param {object} params all the keys and the values to be updated
6555
- * @return {SearchParameters} a new updated instance
6556
- */
6557
- setQueryParameters: function setQueryParameters(params) {
6558
- var error = SearchParameters.validate(this, params);
6559
-
6560
- if (error) {
6561
- throw error;
6562
- }
6563
-
6564
- return this.mutateMe(function mergeWith(newInstance) {
6565
- var ks = keys(params);
6566
-
6567
- forEach(ks, function(k) {
6568
- newInstance[k] = params[k];
6569
- });
6570
-
6571
- return newInstance;
6572
- });
6573
- },
6574
- /**
6575
- * Helper function to make it easier to build new instances from a mutating
6576
- * function
6577
- * @private
6578
- * @param {function} fn newMutableState -> previousState -> () function that will
6579
- * change the value of the newMutable to the desired state
6580
- * @return {SearchParameters} a new instance with the specified modifications applied
6581
- */
6582
- mutateMe: function mutateMe(fn) {
6583
- var newState = new this.constructor(this);
6584
-
6585
- fn(newState, this);
6586
- return deepFreeze(newState);
6587
- },
6588
-
6589
- /**
6590
- * Helper function to get the hierarchicalFacet separator or the default one (`>`)
6591
- * @param {object} hierarchicalFacet
6592
- * @return {string} returns the hierarchicalFacet.separator or `>` as default
6593
- */
6594
- _getHierarchicalFacetSortBy: function(hierarchicalFacet) {
6595
- return hierarchicalFacet.sortBy || ['isRefined:desc', 'name:asc'];
6596
- },
6597
-
6598
- /**
6599
- * Helper function to get the hierarchicalFacet separator or the default one (`>`)
6600
- * @param {object} hierarchicalFacet
6601
- * @return {string} returns the hierarchicalFacet.separator or `>` as default
6602
- */
6603
- _getHierarchicalFacetSeparator: function(hierarchicalFacet) {
6604
- return hierarchicalFacet.separator || ' > ';
6605
- },
6606
-
6607
- /**
6608
- * Helper function to get the hierarchicalFacet by it's name
6609
- * @param {string} hierarchicalFacetName
6610
- * @return {object} a hierarchicalFacet
6611
- */
6612
- getHierarchicalFacetByName: function(hierarchicalFacetName) {
6613
- return find(
6614
- this.hierarchicalFacets,
6615
- {name: hierarchicalFacetName}
6616
- );
6617
- }
6618
- };
6619
-
6620
- /**
6621
- * Callback used for clearRefinement method
6622
- * @callback SearchParameters.clearCallback
6623
- * @param {OperatorList|FacetList} value
6624
- * @param {string} key
6625
- * @param {string} type numeric, disjunctiveFacet, conjunctiveFacet or exclude
6626
- * depending on the type of facet
6627
- * @return {boolean}
6628
- */
6629
- module.exports = SearchParameters;
6630
-
6631
- },{"../functions/deepFreeze":156,"./RefinementList":151,"lodash/array/indexOf":5,"lodash/array/intersection":6,"lodash/collection/filter":9,"lodash/collection/find":10,"lodash/collection/forEach":11,"lodash/collection/pluck":14,"lodash/collection/reduce":15,"lodash/lang/isEmpty":128,"lodash/lang/isFunction":129,"lodash/lang/isString":133,"lodash/lang/isUndefined":135,"lodash/object/defaults":139,"lodash/object/keys":140,"lodash/object/merge":142,"lodash/object/omit":143}],153:[function(require,module,exports){
6632
- 'use strict';
6633
-
6634
- module.exports = generateTrees;
6635
-
6636
- var last = require('lodash/array/last');
6637
- var map = require('lodash/collection/map');
6638
- var reduce = require('lodash/collection/reduce');
6639
- var sortByOrder = require('lodash/collection/sortByOrder');
6640
- var trim = require('lodash/string/trim');
6641
- var find = require('lodash/collection/find');
6642
- var pick = require('lodash/object/pick');
6643
-
6644
- function generateTrees(state) {
6645
- return function generate(hierarchicalFacetResult, hierarchicalFacetIndex) {
6646
- var hierarchicalFacet = state.hierarchicalFacets[hierarchicalFacetIndex];
6647
- var hierarchicalFacetRefinement = state.hierarchicalFacetsRefinements[hierarchicalFacet.name] &&
6648
- state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0] || '';
6649
- var hierarchicalSeparator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
6650
- var sortBy = prepareHierarchicalFacetSortBy(state._getHierarchicalFacetSortBy(hierarchicalFacet));
6651
- var alwaysGetRootLevel = hierarchicalFacet.alwaysGetRootLevel;
6652
-
6653
- return reduce(hierarchicalFacetResult, generateHierarchicalTree(sortBy, hierarchicalSeparator, hierarchicalFacetRefinement, alwaysGetRootLevel), {
6654
- name: state.hierarchicalFacets[hierarchicalFacetIndex].name,
6655
- count: null, // root level, no count
6656
- isRefined: true, // root level, always refined
6657
- path: null, // root level, no path
6658
- data: null
6659
- });
6660
- };
6661
- }
6662
-
6663
- function generateHierarchicalTree(sortBy, hierarchicalSeparator, currentRefinement, alwaysGetRootLevel) {
6664
- return function generateTree(hierarchicalTree, hierarchicalFacetResult, currentHierarchicalLevel) {
6665
- var parent = hierarchicalTree;
6666
-
6667
- if (currentHierarchicalLevel > 0) {
6668
- var level = 0;
6669
-
6670
- parent = hierarchicalTree;
6671
-
6672
- while (level < currentHierarchicalLevel) {
6673
- parent = parent && find(parent.data, {isRefined: true});
6674
- level++;
6675
- }
6676
- }
6677
-
6678
- // we found a refined parent, let's add current level data under it
6679
- if (parent) {
6680
- parent.data = sortByOrder(
6681
- map(
6682
- // filter values in case an object has:
6683
- // {
6684
- // categories: {
6685
- // level0: ['beers', 'bières'],
6686
- // level1: ['beers > IPA', 'bières > Belges']
6687
- // }
6688
- // }
6689
- //
6690
- // If parent refinement is `beers`, then we do not want to have `bières > Belges`
6691
- // showing up
6692
- pick(hierarchicalFacetResult.data, filterFacetValues(parent.path, currentRefinement, hierarchicalSeparator, alwaysGetRootLevel)),
6693
- formatHierarchicalFacetValue(hierarchicalSeparator, currentRefinement)
6694
- ),
6695
- sortBy[0], sortBy[1]
6696
- );
6697
- }
6698
-
6699
- return hierarchicalTree;
6700
- };
6701
- }
6702
-
6703
- function filterFacetValues(parentPath, currentRefinement, hierarchicalSeparator, alwaysGetRootLevel) {
6704
- return function(facetCount, facetValue) {
6705
- // we always want root levels and facetValue is a root level
6706
- return alwaysGetRootLevel === true && facetValue.indexOf(hierarchicalSeparator) === -1 ||
6707
- // if current refinement is a root level and current facetValue is a root level,
6708
- // keep the facetValue
6709
- facetValue.indexOf(hierarchicalSeparator) === -1 &&
6710
- currentRefinement.indexOf(hierarchicalSeparator) === -1 ||
6711
- // currentRefinement is a child of the facet value
6712
- currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0 ||
6713
- // facetValue is a child of the current parent, add it
6714
- facetValue.indexOf(parentPath + hierarchicalSeparator) === 0;
6715
- };
6716
- }
6717
-
6718
- function formatHierarchicalFacetValue(hierarchicalSeparator, currentRefinement) {
6719
- return function format(facetCount, facetValue) {
6720
- return {
6721
- name: trim(last(facetValue.split(hierarchicalSeparator))),
6722
- path: facetValue,
6723
- count: facetCount,
6724
- isRefined: currentRefinement === facetValue || currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0,
6725
- data: null
6726
- };
6727
- };
6728
- }
6729
-
6730
- // ['isRefined:desc', 'count:asc'] => [['isRefined', 'count'], ['desc', 'asc']] (lodash sortByOrder format)
6731
- function prepareHierarchicalFacetSortBy(sortBy) {
6732
- return reduce(sortBy, function prepare(out, sortInstruction) {
6733
- var sortInstructions = sortInstruction.split(':');
6734
- out[0].push(sortInstructions[0]);
6735
- out[1].push(sortInstructions[1]);
6736
- return out;
6737
- }, [[], []]);
6738
- }
6739
-
6740
- },{"lodash/array/last":7,"lodash/collection/find":10,"lodash/collection/map":13,"lodash/collection/reduce":15,"lodash/collection/sortByOrder":16,"lodash/object/pick":145,"lodash/string/trim":147}],154:[function(require,module,exports){
6741
- 'use strict';
6742
-
6743
- var forEach = require('lodash/collection/forEach');
6744
- var compact = require('lodash/array/compact');
6745
- var indexOf = require('lodash/array/indexOf');
6746
- var sum = require('lodash/collection/sum');
6747
- var find = require('lodash/collection/find');
6748
- var includes = require('lodash/collection/includes');
6749
- var map = require('lodash/collection/map');
6750
- var findIndex = require('lodash/array/findIndex');
6751
- var defaults = require('lodash/object/defaults');
6752
- var merge = require('lodash/object/merge');
6753
-
6754
- var generateHierarchicalTree = require('./generate-hierarchical-tree');
6755
-
6756
- /**
6757
- * @typedef SearchResults.Facet
6758
- * @type {object}
6759
- * @property {string} name name of the attribute in the record
6760
- * @property {object.<string, number>} data the facetting data: value, number of entries
6761
- * @property {object} stats undefined unless facet_stats is retrieved from algolia
6762
- */
6763
-
6764
- function getIndices(obj) {
6765
- var indices = {};
6766
-
6767
- forEach(obj, function(val, idx) { indices[val] = idx; });
6768
-
6769
- return indices;
6770
- }
6771
-
6772
- function assignFacetStats(dest, facetStats, key) {
6773
- if (facetStats && facetStats[key]) {
6774
- dest.stats = facetStats[key];
6775
- }
6776
- }
6777
-
6778
- function findMatchingHierarchicalFacetFromAttributeName(hierarchicalFacets, hierarchicalAttributeName) {
6779
- return find(
6780
- hierarchicalFacets,
6781
- function facetKeyMatchesAttribute(hierarchicalFacet) {
6782
- return includes(hierarchicalFacet.attributes, hierarchicalAttributeName);
6783
- }
6784
- );
6785
- }
6786
-
6787
- /**
6788
- * Constructor for SearchResults
6789
- * @class
6790
- * @classdesc SearchResults contains the results of a query to Algolia using the
6791
- * {@link AlgoliaSearchHelper}.
6792
- * @param {SearchParameters} state state that led to the response
6793
- * @param {object} algoliaResponse the response from algolia client
6794
- * @example <caption>SearchResults of the first query in <a href="http://demos.algolia.com/instant-search-demo">the instant search demo</a></caption>
6795
- {
6796
- "hitsPerPage": 10,
6797
- "processingTimeMS": 2,
6798
- "facets": [
6799
- {
6800
- "name": "type",
6801
- "data": {
6802
- "HardGood": 6627,
6803
- "BlackTie": 550,
6804
- "Music": 665,
6805
- "Software": 131,
6806
- "Game": 456,
6807
- "Movie": 1571
6808
- },
6809
- "exhaustive": false
6810
- },
6811
- {
6812
- "exhaustive": false,
6813
- "data": {
6814
- "Free shipping": 5507
6815
- },
6816
- "name": "shipping"
6817
- }
6818
- ],
6819
- "hits": [
6820
- {
6821
- "thumbnailImage": "http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_54x108_s.gif",
6822
- "_highlightResult": {
6823
- "shortDescription": {
6824
- "matchLevel": "none",
6825
- "value": "Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection",
6826
- "matchedWords": []
6827
- },
6828
- "category": {
6829
- "matchLevel": "none",
6830
- "value": "Computer Security Software",
6831
- "matchedWords": []
6832
- },
6833
- "manufacturer": {
6834
- "matchedWords": [],
6835
- "value": "Webroot",
6836
- "matchLevel": "none"
6837
- },
6838
- "name": {
6839
- "value": "Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows",
6840
- "matchedWords": [],
6841
- "matchLevel": "none"
6842
- }
6843
- },
6844
- "image": "http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_105x210_sc.jpg",
6845
- "shipping": "Free shipping",
6846
- "bestSellingRank": 4,
6847
- "shortDescription": "Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection",
6848
- "url": "http://www.bestbuy.com/site/webroot-secureanywhere-internet-security-3-devi…d=1219060687969&skuId=1688832&cmp=RMX&ky=2d3GfEmNIzjA0vkzveHdZEBgpPCyMnLTJ",
6849
- "name": "Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows",
6850
- "category": "Computer Security Software",
6851
- "salePrice_range": "1 - 50",
6852
- "objectID": "1688832",
6853
- "type": "Software",
6854
- "customerReviewCount": 5980,
6855
- "salePrice": 49.99,
6856
- "manufacturer": "Webroot"
6857
- },
6858
- ....
6859
- ],
6860
- "nbHits": 10000,
6861
- "disjunctiveFacets": [
6862
- {
6863
- "exhaustive": false,
6864
- "data": {
6865
- "5": 183,
6866
- "12": 112,
6867
- "7": 149,
6868
- ...
6869
- },
6870
- "name": "customerReviewCount",
6871
- "stats": {
6872
- "max": 7461,
6873
- "avg": 157.939,
6874
- "min": 1
6875
- }
6876
- },
6877
- {
6878
- "data": {
6879
- "Printer Ink": 142,
6880
- "Wireless Speakers": 60,
6881
- "Point & Shoot Cameras": 48,
6882
- ...
6883
- },
6884
- "name": "category",
6885
- "exhaustive": false
6886
- },
6887
- {
6888
- "exhaustive": false,
6889
- "data": {
6890
- "> 5000": 2,
6891
- "1 - 50": 6524,
6892
- "501 - 2000": 566,
6893
- "201 - 500": 1501,
6894
- "101 - 200": 1360,
6895
- "2001 - 5000": 47
6896
- },
6897
- "name": "salePrice_range"
6898
- },
6899
- {
6900
- "data": {
6901
- "Dynex™": 202,
6902
- "Insignia™": 230,
6903
- "PNY": 72,
6904
- ...
6905
- },
6906
- "name": "manufacturer",
6907
- "exhaustive": false
6908
- }
6909
- ],
6910
- "query": "",
6911
- "nbPages": 100,
6912
- "page": 0,
6913
- "index": "bestbuy"
6914
- }
6915
- **/
6916
- function SearchResults(state, algoliaResponse) {
6917
- var mainSubResponse = algoliaResponse.results[0];
6918
-
6919
- /**
6920
- * query used to generate the results
6921
- * @member {string}
6922
- */
6923
- this.query = mainSubResponse.query;
6924
- /**
6925
- * all the records that match the search parameters. It also contains _highlightResult,
6926
- * which describe which and how the attributes are matched.
6927
- * @member {object[]}
6928
- */
6929
- this.hits = mainSubResponse.hits;
6930
- /**
6931
- * index where the results come from
6932
- * @member {string}
6933
- */
6934
- this.index = mainSubResponse.index;
6935
- /**
6936
- * number of hits per page requested
6937
- * @member {number}
6938
- */
6939
- this.hitsPerPage = mainSubResponse.hitsPerPage;
6940
- /**
6941
- * total number of hits of this query on the index
6942
- * @member {number}
6943
- */
6944
- this.nbHits = mainSubResponse.nbHits;
6945
- /**
6946
- * total number of pages with respect to the number of hits per page and the total number of hits
6947
- * @member {number}
6948
- */
6949
- this.nbPages = mainSubResponse.nbPages;
6950
- /**
6951
- * current page
6952
- * @member {number}
6953
- */
6954
- this.page = mainSubResponse.page;
6955
- /**
6956
- * sum of the processing time of all the queries
6957
- * @member {number}
6958
- */
6959
- this.processingTimeMS = sum(algoliaResponse.results, 'processingTimeMS');
6960
- /**
6961
- * disjunctive facets results
6962
- * @member {SearchResults.Facet[]}
6963
- */
6964
- this.disjunctiveFacets = [];
6965
- /**
6966
- * disjunctive facets results
6967
- * @member {SearchResults.Facet[]}
6968
- */
6969
- this.hierarchicalFacets = map(state.hierarchicalFacets, function initFutureTree() {
6970
- return [];
6971
- });
6972
- /**
6973
- * other facets results
6974
- * @member {SearchResults.Facet[]}
6975
- */
6976
- this.facets = [];
6977
-
6978
- var disjunctiveFacets = state.getRefinedDisjunctiveFacets();
6979
-
6980
- var facetsIndices = getIndices(state.facets);
6981
- var disjunctiveFacetsIndices = getIndices(state.disjunctiveFacets);
6982
- var disjunctiveIndexResult;
6983
-
6984
- // Since we send request only for disjunctive facets that have been refined,
6985
- // we get the facets informations from the first, general, response.
6986
- forEach(mainSubResponse.facets, function(facetValueObject, facetKey) {
6987
- var hierarchicalFacet;
6988
-
6989
- if (hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(state.hierarchicalFacets, facetKey)) {
6990
- this.hierarchicalFacets[findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name})].push({
6991
- attribute: facetKey,
6992
- data: facetValueObject,
6993
- exhaustive: mainSubResponse.exhaustiveFacetsCount
6994
- });
6995
- } else {
6996
- var isFacetDisjunctive = indexOf(state.disjunctiveFacets, facetKey) !== -1;
6997
- var position = isFacetDisjunctive ? disjunctiveFacetsIndices[facetKey] :
6998
- facetsIndices[facetKey];
6999
-
7000
- if (isFacetDisjunctive) {
7001
- this.disjunctiveFacets[position] = {
7002
- name: facetKey,
7003
- data: facetValueObject,
7004
- exhaustive: mainSubResponse.exhaustiveFacetsCount
7005
- };
7006
- assignFacetStats(this.disjunctiveFacets[position], mainSubResponse.facets_stats, facetKey);
7007
- } else {
7008
- this.facets[position] = {
7009
- name: facetKey,
7010
- data: facetValueObject,
7011
- exhaustive: mainSubResponse.exhaustiveFacetsCount
7012
- };
7013
- assignFacetStats(this.facets[position], mainSubResponse.facets_stats, facetKey);
7014
- }
7015
- }
7016
- }, this);
7017
-
7018
- // aggregate the refined disjunctive facets
7019
- forEach(disjunctiveFacets, function(disjunctiveFacet, idx) {
7020
- disjunctiveIndexResult = idx + 1;
7021
- var result = algoliaResponse.results[disjunctiveIndexResult];
7022
- // TODO if alwaysGetRootLevel && current refinement > level 2 (in another loop)
7023
- var hierarchicalFacet = state.getHierarchicalFacetByName(disjunctiveFacet);
7024
-
7025
- // There should be only item in facets.
7026
- forEach(result.facets, function(facetResults, dfacet) {
7027
- var position;
7028
-
7029
- if (hierarchicalFacet) {
7030
- position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});
7031
- var attributeIndex = findIndex(this.hierarchicalFacets[position], {attribute: dfacet});
7032
- // if (hierarchicalFacet.alwaysGetRootLevel) {
7033
- // // when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),
7034
- // // then the disjunctive values will be `beers` (count: 100),
7035
- // // but we do not want to display
7036
- // // | beers (100)
7037
- // // > IPA (5)
7038
- // // We want
7039
- // // | beers (5)
7040
- // // > IPA (5)
7041
- // var currentRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name);
7042
- // var defaultData = {};
7043
-
7044
- // if (currentRefinement && currentRefinement.length > 0) {
7045
- // var root = currentRefinement[0].split(state._getHierarchicalFacetSeparator(hierarchicalFacet))[0];
7046
- // defaultData[root] = this.hierarchicalFacets[position][attributeIndex].data[root];
7047
- // }
7048
-
7049
- // this.hierarchicalFacets[position][attributeIndex].data = defaults(defaultData, facetResults, this.hierarchicalFacets[position][attributeIndex].data);
7050
- // } else {
7051
- this.hierarchicalFacets[position][attributeIndex].data = merge({}, this.hierarchicalFacets[position][attributeIndex].data, facetResults);
7052
- // }
7053
- } else {
7054
- position = disjunctiveFacetsIndices[dfacet];
7055
-
7056
- var dataFromMainRequest = mainSubResponse.facets && mainSubResponse.facets[dfacet] || {};
7057
-
7058
- this.disjunctiveFacets[position] = {
7059
- name: dfacet,
7060
- data: defaults({}, facetResults, dataFromMainRequest),
7061
- exhaustive: result.exhaustiveFacetsCount
7062
- };
7063
- assignFacetStats(this.disjunctiveFacets[position], result.facets_stats, dfacet);
7064
-
7065
- if (state.disjunctiveFacetsRefinements[dfacet]) {
7066
- forEach(state.disjunctiveFacetsRefinements[dfacet], function(refinementValue) {
7067
- // add the disjunctive refinements if it is no more retrieved
7068
- if (!this.disjunctiveFacets[position].data[refinementValue] &&
7069
- indexOf(state.disjunctiveFacetsRefinements[dfacet], refinementValue) > -1) {
7070
- this.disjunctiveFacets[position].data[refinementValue] = 0;
7071
- }
7072
- }, this);
7073
- }
7074
- }
7075
- }, this);
7076
- }, this);
7077
-
7078
- // if we have some root level values for hierarchical facets, merge them
7079
- forEach(state.getRefinedHierarchicalFacets(), function(refinedFacet) {
7080
- var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
7081
-
7082
- if (hierarchicalFacet.alwaysGetRootLevel !== true) {
7083
- return;
7084
- }
7085
-
7086
- var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
7087
- // if we are already at a root refinement (or no refinement at all), there is no
7088
- // root level values request
7089
- if (currentRefinement.length === 0 || currentRefinement[0].split(state._getHierarchicalFacetSeparator(hierarchicalFacet)).length < 2) {
7090
- return;
7091
- }
7092
-
7093
- disjunctiveIndexResult++;
7094
-
7095
- var result = algoliaResponse.results[disjunctiveIndexResult];
7096
-
7097
- forEach(result.facets, function(facetResults, dfacet) {
7098
- var position = findIndex(state.hierarchicalFacets, {name: hierarchicalFacet.name});
7099
- var attributeIndex = findIndex(this.hierarchicalFacets[position], {attribute: dfacet});
7100
-
7101
- // when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),
7102
- // then the disjunctive values will be `beers` (count: 100),
7103
- // but we do not want to display
7104
- // | beers (100)
7105
- // > IPA (5)
7106
- // We want
7107
- // | beers (5)
7108
- // > IPA (5)
7109
- var defaultData = {};
7110
-
7111
- if (currentRefinement.length > 0) {
7112
- var root = currentRefinement[0].split(state._getHierarchicalFacetSeparator(hierarchicalFacet))[0];
7113
- defaultData[root] = this.hierarchicalFacets[position][attributeIndex].data[root];
7114
- }
7115
-
7116
- this.hierarchicalFacets[position][attributeIndex].data = defaults(defaultData, facetResults, this.hierarchicalFacets[position][attributeIndex].data);
7117
- }, this);
7118
- }, this);
7119
-
7120
- // add the excludes
7121
- forEach(state.facetsExcludes, function(excludes, facetName) {
7122
- var position = facetsIndices[facetName];
7123
-
7124
- this.facets[position] = {
7125
- name: facetName,
7126
- data: mainSubResponse.facets[facetName],
7127
- exhaustive: mainSubResponse.exhaustiveFacetsCount
7128
- };
7129
- forEach(excludes, function(facetValue) {
7130
- this.facets[position] = this.facets[position] || {name: facetName};
7131
- this.facets[position].data = this.facets[position].data || {};
7132
- this.facets[position].data[facetValue] = 0;
7133
- }, this);
7134
- }, this);
7135
-
7136
- this.hierarchicalFacets = map(this.hierarchicalFacets, generateHierarchicalTree(state));
7137
-
7138
- this.facets = compact(this.facets);
7139
- this.disjunctiveFacets = compact(this.disjunctiveFacets);
7140
-
7141
- this._state = state;
7142
- }
7143
-
7144
- /**
7145
- * Get a facet object with its name
7146
- * @param {string} name name of the attribute facetted
7147
- * @return {SearchResults.Facet} the facet object
7148
- */
7149
- SearchResults.prototype.getFacetByName = function(name) {
7150
- var predicate = {name: name};
7151
-
7152
- return find(this.facets, predicate) ||
7153
- find(this.disjunctiveFacets, predicate) ||
7154
- find(this.hierarchicalFacets, predicate);
7155
- };
7156
-
7157
- module.exports = SearchResults;
7158
-
7159
- },{"./generate-hierarchical-tree":153,"lodash/array/compact":3,"lodash/array/findIndex":4,"lodash/array/indexOf":5,"lodash/collection/find":10,"lodash/collection/forEach":11,"lodash/collection/includes":12,"lodash/collection/map":13,"lodash/collection/sum":17,"lodash/object/defaults":139,"lodash/object/merge":142}],155:[function(require,module,exports){
7160
- 'use strict';
7161
-
7162
- var SearchParameters = require('./SearchParameters');
7163
- var SearchResults = require('./SearchResults');
7164
- var util = require('util');
7165
- var events = require('events');
7166
- var forEach = require('lodash/collection/forEach');
7167
- var isEmpty = require('lodash/lang/isEmpty');
7168
- var bind = require('lodash/function/bind');
7169
- var reduce = require('lodash/collection/reduce');
7170
- var map = require('lodash/collection/map');
7171
- var trim = require('lodash/string/trim');
7172
- var merge = require('lodash/object/merge');
7173
-
7174
- /**
7175
- * Initialize a new AlgoliaSearchHelper
7176
- * @class
7177
- * @classdesc The AlgoliaSearchHelper is a class that ease the management of the
7178
- * search. It provides an event based interface for search callbacks:
7179
- * - change: when the internal search state is changed.
7180
- * This event contains a {@link SearchParameters} object and the {@link SearchResults} of the last result if any.
7181
- * - result: when the response is retrieved from Algolia and is processed.
7182
- * This event contains a {@link SearchResults} object and the {@link SearchParameters} corresponding to this answer.
7183
- * - error: when the response is an error. This event contains the error returned by the server.
7184
- * @param {AlgoliaSearch} client an AlgoliaSearch client
7185
- * @param {string} index the index name to query
7186
- * @param {SearchParameters | object} options an object defining the initial config of the search. It doesn't have to be a {SearchParameters}, just an object containing the properties you need from it.
7187
- */
7188
- function AlgoliaSearchHelper(client, index, options) {
7189
- this.client = client;
7190
- this.index = index;
7191
- this.state = SearchParameters.make(options);
7192
- this.lastResults = null;
7193
- this._queryId = 0;
7194
- this._lastQueryIdReceived = -1;
7195
- }
7196
-
7197
- util.inherits(AlgoliaSearchHelper, events.EventEmitter);
7198
-
7199
- /**
7200
- * Start the search with the parameters set in the state.
7201
- * @return {AlgoliaSearchHelper}
7202
- */
7203
- AlgoliaSearchHelper.prototype.search = function() {
7204
- this._search();
7205
- return this;
7206
- };
7207
-
7208
- /**
7209
- * Sets the query. Also sets the current page to 0.
7210
- * @param {string} q the user query
7211
- * @return {AlgoliaSearchHelper}
7212
- */
7213
- AlgoliaSearchHelper.prototype.setQuery = function(q) {
7214
- this.state = this.state.setQuery(q);
7215
- this._change();
7216
- return this;
7217
- };
7218
-
7219
- /**
7220
- * Remove all refinements (disjunctive + conjunctive + excludes + numeric filters)
7221
- * @param {string} [name] - If given, name of the facet / attribute on which we want to remove all refinements
7222
- * @return {AlgoliaSearchHelper}
7223
- */
7224
- AlgoliaSearchHelper.prototype.clearRefinements = function(name) {
7225
- this.state = this.state.clearRefinements(name);
7226
- this._change();
7227
- return this;
7228
- };
7229
-
7230
- /**
7231
- * Remove all the tag filtering
7232
- * @return {AlgoliaSearchHelper}
7233
- */
7234
- AlgoliaSearchHelper.prototype.clearTags = function() {
7235
- this.state = this.state.clearTags();
7236
- this._change();
7237
- return this;
7238
- };
7239
-
7240
- /**
7241
- * Ensure a facet refinement exists
7242
- * @param {string} facet the facet to refine
7243
- * @param {string} value the associated value (will be converted to string)
7244
- * @return {AlgoliaSearchHelper}
7245
- */
7246
- AlgoliaSearchHelper.prototype.addDisjunctiveRefine = function(facet, value) {
7247
- this.state = this.state.addDisjunctiveFacetRefinement(facet, value);
7248
- this._change();
7249
- return this;
7250
- };
7251
-
7252
- /**
7253
- * Add a numeric refinement on the given attribute
7254
- * @param {string} attribute the attribute on which the numeric filter applies
7255
- * @param {string} operator the operator of the filter
7256
- * @param {number} value the value of the filter
7257
- * @return {AlgoliaSearchHelper}
7258
- */
7259
- AlgoliaSearchHelper.prototype.addNumericRefinement = function(attribute, operator, value) {
7260
- this.state = this.state.addNumericRefinement(attribute, operator, value);
7261
- this._change();
7262
- return this;
7263
- };
7264
-
7265
- /**
7266
- * Ensure a facet refinement exists
7267
- * @param {string} facet the facet to refine
7268
- * @param {string} value the associated value (will be converted to string)
7269
- * @return {AlgoliaSearchHelper}
7270
- */
7271
- AlgoliaSearchHelper.prototype.addRefine = function(facet, value) {
7272
- this.state = this.state.addFacetRefinement(facet, value);
7273
- this._change();
7274
- return this;
7275
- };
7276
-
7277
- /**
7278
- * Ensure a facet exclude exists
7279
- * @param {string} facet the facet to refine
7280
- * @param {string} value the associated value (will be converted to string)
7281
- * @return {AlgoliaSearchHelper}
7282
- */
7283
- AlgoliaSearchHelper.prototype.addExclude = function(facet, value) {
7284
- this.state = this.state.addExcludeRefinement(facet, value);
7285
- this._change();
7286
- return this;
7287
- };
7288
-
7289
- /**
7290
- * Add a tag refinement
7291
- * @param {string} tag the tag to add to the filter
7292
- * @return {AlgoliaSearchHelper}
7293
- */
7294
- AlgoliaSearchHelper.prototype.addTag = function(tag) {
7295
- this.state = this.state.addTagRefinement(tag);
7296
- this._change();
7297
- return this;
7298
- };
7299
-
7300
- /**
7301
- * Remove a numeric filter.
7302
- * @param {string} attribute the attribute on which the numeric filter applies
7303
- * @param {string} operator the operator of the filter
7304
- * @param {number} value the value of the filter
7305
- * @return {AlgoliaSearchHelper}
7306
- */
7307
- AlgoliaSearchHelper.prototype.removeNumericRefinement = function(attribute, operator, value) {
7308
- this.state = this.state.removeNumericRefinement(attribute, operator, value);
7309
- this._change();
7310
- return this;
7311
- };
7312
-
7313
- /**
7314
- * Ensure a facet refinement does not exist
7315
- * @param {string} facet the facet to refine
7316
- * @param {string} value the associated value
7317
- * @return {AlgoliaSearchHelper}
7318
- */
7319
- AlgoliaSearchHelper.prototype.removeDisjunctiveRefine = function(facet, value) {
7320
- this.state = this.state.removeDisjunctiveFacetRefinement(facet, value);
7321
- this._change();
7322
- return this;
7323
- };
7324
-
7325
- /**
7326
- * Ensure a facet refinement does not exist
7327
- * @param {string} facet the facet to refine
7328
- * @param {string} value the associated value
7329
- * @return {AlgoliaSearchHelper}
7330
- */
7331
- AlgoliaSearchHelper.prototype.removeRefine = function(facet, value) {
7332
- this.state = this.state.removeFacetRefinement(facet, value);
7333
- this._change();
7334
- return this;
7335
- };
7336
-
7337
- /**
7338
- * Ensure a facet exclude does not exist
7339
- * @param {string} facet the facet to refine
7340
- * @param {string} value the associated value
7341
- * @return {AlgoliaSearchHelper}
7342
- */
7343
- AlgoliaSearchHelper.prototype.removeExclude = function(facet, value) {
7344
- this.state = this.state.removeExcludeRefinement(facet, value);
7345
- this._change();
7346
- return this;
7347
- };
7348
-
7349
- /**
7350
- * Ensure that a tag is not filtering the results
7351
- * @param {string} tag tag to remove from the filter
7352
- * @return {AlgoliaSearchHelper}
7353
- */
7354
- AlgoliaSearchHelper.prototype.removeTag = function(tag) {
7355
- this.state = this.state.removeTagRefinement(tag);
7356
- this._change();
7357
- return this;
7358
- };
7359
-
7360
- /**
7361
- * Toggle refinement state of an exclude
7362
- * @param {string} facet the facet to refine
7363
- * @param {string} value the associated value
7364
- * @return {AlgoliaSearchHelper}
7365
- */
7366
- AlgoliaSearchHelper.prototype.toggleExclude = function(facet, value) {
7367
- this.state = this.state.toggleExcludeFacetRefinement(facet, value);
7368
- this._change();
7369
- return this;
7370
- };
7371
-
7372
- /**
7373
- * Toggle refinement state of a facet
7374
- * @param {string} facet the facet to refine
7375
- * @param {string} value the associated value
7376
- * @return {AlgoliaSearchHelper}
7377
- * @throws will throw an error if the facet is not declared in the settings of the helper
7378
- */
7379
- AlgoliaSearchHelper.prototype.toggleRefine = function(facet, value) {
7380
- if (this.state.isHierarchicalFacet(facet)) {
7381
- this.state = this.state.toggleHierarchicalFacetRefinement(facet, value);
7382
- } else if (this.state.isConjunctiveFacet(facet)) {
7383
- this.state = this.state.toggleFacetRefinement(facet, value);
7384
- } else if (this.state.isDisjunctiveFacet(facet)) {
7385
- this.state = this.state.toggleDisjunctiveFacetRefinement(facet, value);
7386
- } else {
7387
- throw new Error('Cannot refine the undeclared facet ' + facet +
7388
- '; it should be added to the helper options facets or disjunctiveFacets');
7389
- }
7390
-
7391
- this._change();
7392
- return this;
7393
- };
7394
-
7395
- /**
7396
- * Toggle tag refinement
7397
- * @param {string} tag tag to remove or add
7398
- * @return {AlgoliaSearchHelper}
7399
- */
7400
- AlgoliaSearchHelper.prototype.toggleTag = function(tag) {
7401
- this.state = this.state.toggleTagRefinement(tag);
7402
- this._change();
7403
- return this;
7404
- };
7405
-
7406
- /**
7407
- * Go to next page
7408
- * @return {AlgoliaSearchHelper}
7409
- */
7410
- AlgoliaSearchHelper.prototype.nextPage = function() {
7411
- return this.setCurrentPage(this.state.page + 1);
7412
- };
7413
-
7414
- /**
7415
- * Go to previous page
7416
- * @return {AlgoliaSearchHelper}
7417
- */
7418
- AlgoliaSearchHelper.prototype.previousPage = function() {
7419
- return this.setCurrentPage(this.state.page - 1);
7420
- };
7421
-
7422
- /**
7423
- * Change the current page
7424
- * @param {integer} page The page number
7425
- * @return {AlgoliaSearchHelper}
7426
- */
7427
- AlgoliaSearchHelper.prototype.setCurrentPage = function(page) {
7428
- if (page < 0) throw new Error('Page requested below 0.');
7429
-
7430
- this.state = this.state.setPage(page);
7431
- this._change();
7432
- return this;
7433
- };
7434
-
7435
- /**
7436
- * Configure the underlying index name
7437
- * @param {string} name the index name
7438
- * @return {AlgoliaSearchHelper}
7439
- */
7440
- AlgoliaSearchHelper.prototype.setIndex = function(name) {
7441
- this.index = name;
7442
- this.setCurrentPage(0);
7443
- return this;
7444
- };
7445
-
7446
- /**
7447
- * Update any single parameter of the state/configuration (based on SearchParameters).
7448
- * @param {string} parameter name of the parameter to update
7449
- * @param {any} value new value of the parameter
7450
- * @return {AlgoliaSearchHelper}
7451
- */
7452
- AlgoliaSearchHelper.prototype.setQueryParameter = function(parameter, value) {
7453
- var newState = this.state.setQueryParameter(parameter, value);
7454
-
7455
- if (this.state === newState) return this;
7456
-
7457
- this.state = newState;
7458
- this._change();
7459
- return this;
7460
- };
7461
-
7462
- /**
7463
- * Set the whole state (warning: will erase previous state)
7464
- * @param {SearchParameters} newState the whole new state
7465
- * @return {AlgoliaSearchHelper}
7466
- */
7467
- AlgoliaSearchHelper.prototype.setState = function(newState) {
7468
- this.state = new SearchParameters(newState);
7469
- this._change();
7470
- return this;
7471
- };
7472
-
7473
- /**
7474
- * Get the current search state stored in the helper. This object is immutable.
7475
- * @return {SearchParameters}
7476
- */
7477
- AlgoliaSearchHelper.prototype.getState = function() {
7478
- return this.state;
7479
- };
7480
-
7481
- /**
7482
- * Override the current state without triggering a change event.
7483
- * Do not use this method unless you know what you are doing. (see the example
7484
- * for a legit use case)
7485
- * @param {SearchParameters} newState the whole new state
7486
- * @return {AlgoliaSearchHelper}
7487
- * @example
7488
- * helper.on('change', function(state){
7489
- * // In this function you might want to find a way to store the state in the url/history
7490
- * updateYourURL(state)
7491
- * })
7492
- * window.onpopstate = function(event){
7493
- * // This is naive though as you should check if the state is really defined etc.
7494
- * helper.overrideStateWithoutTriggeringChangeEvent(event.state).search()
7495
- * }
7496
- */
7497
- AlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent = function(newState) {
7498
- this.state = new SearchParameters(newState);
7499
- return this;
7500
- };
7501
-
7502
- /**
7503
- * Check the refinement state of a given value for a facet
7504
- * @param {string} facet the facet
7505
- * @param {string} value the associated value
7506
- * @return {boolean} true if refined
7507
- */
7508
- AlgoliaSearchHelper.prototype.isRefined = function(facet, value) {
7509
- if (this.state.isConjunctiveFacet(facet)) {
7510
- return this.state.isFacetRefined(facet, value);
7511
- } else if (this.state.isDisjunctiveFacet(facet)) {
7512
- return this.state.isDisjunctiveFacetRefined(facet, value);
7513
- }
7514
-
7515
- throw new Error(facet +
7516
- ' is not properly defined in this helper configuration' +
7517
- '(use the facets or disjunctiveFacets keys to configure it)');
7518
- };
7519
-
7520
- /**
7521
- * Check if the attribute has any numeric, disjunctive or conjunctive refinements
7522
- * @param {string} attribute the name of the attribute
7523
- * @return {boolean} true if the attribute is filtered by at least one value
7524
- */
7525
- AlgoliaSearchHelper.prototype.hasRefinements = function(attribute) {
7526
- var attributeHasNumericRefinements = !isEmpty(this.state.getNumericRefinements(attribute));
7527
- var isFacetDeclared = this.state.isConjunctiveFacet(attribute) || this.state.isDisjunctiveFacet(attribute);
7528
-
7529
- if (!attributeHasNumericRefinements && isFacetDeclared) {
7530
- return this.state.isFacetRefined(attribute);
7531
- }
7532
-
7533
- return attributeHasNumericRefinements;
7534
- };
7535
-
7536
- /**
7537
- * Check the exclude state of a facet
7538
- * @param {string} facet the facet
7539
- * @param {string} value the associated value
7540
- * @return {boolean} true if refined
7541
- */
7542
- AlgoliaSearchHelper.prototype.isExcluded = function(facet, value) {
7543
- return this.state.isExcludeRefined(facet, value);
7544
- };
7545
-
7546
- /**
7547
- * Check the refinement state of the disjunctive facet
7548
- * @param {string} facet the facet
7549
- * @param {string} value the associated value
7550
- * @return {boolean} true if refined
7551
- */
7552
- AlgoliaSearchHelper.prototype.isDisjunctiveRefined = function(facet, value) {
7553
- return this.state.isDisjunctiveFacetRefined(facet, value);
7554
- };
7555
-
7556
- /**
7557
- * Check if the string is a currently filtering tag
7558
- * @param {string} tag tag to check
7559
- * @return {boolean}
7560
- */
7561
- AlgoliaSearchHelper.prototype.isTagRefined = function(tag) {
7562
- return this.state.isTagRefined(tag);
7563
- };
7564
-
7565
- /**
7566
- * Get the underlying configured index name
7567
- * @return {string}
7568
- */
7569
- AlgoliaSearchHelper.prototype.getIndex = function() {
7570
- return this.index;
7571
- };
7572
-
7573
- /**
7574
- * Get the currently selected page
7575
- * @return {number} the current page
7576
- */
7577
- AlgoliaSearchHelper.prototype.getCurrentPage = function() {
7578
- return this.state.page;
7579
- };
7580
-
7581
- /**
7582
- * Get all the filtering tags
7583
- * @return {string[]}
7584
- */
7585
- AlgoliaSearchHelper.prototype.getTags = function() {
7586
- return this.state.tagRefinements;
7587
- };
7588
-
7589
- /**
7590
- * Get a parameter of the search by its name
7591
- * @param {string} parameterName the parameter name
7592
- * @return {any} the parameter value
7593
- */
7594
- AlgoliaSearchHelper.prototype.getQueryParameter = function(parameterName) {
7595
- return this.state.getQueryParameter(parameterName);
7596
- };
7597
-
7598
- /**
7599
- * Get the list of refinements for a given attribute.
7600
- * @param {string} facetName attribute name used for facetting
7601
- * @return {Refinement[]} All Refinement are objects that contain a value, and a type. Numeric also contains an operator.
7602
- */
7603
- AlgoliaSearchHelper.prototype.getRefinements = function(facetName) {
7604
- var refinements = [];
7605
-
7606
- if (this.state.isConjunctiveFacet(facetName)) {
7607
- var conjRefinements = this.state.getConjunctiveRefinements(facetName);
7608
-
7609
- forEach(conjRefinements, function(r) {
7610
- refinements.push({
7611
- value: r,
7612
- type: 'conjunctive'
7613
- });
7614
- });
7615
-
7616
- var excludeRefinements = this.state.getExcludeRefinements(facetName);
7617
-
7618
- forEach(excludeRefinements, function(r) {
7619
- refinements.push({
7620
- value: r,
7621
- type: 'exclude'
7622
- });
7623
- });
7624
- } else if (this.state.isDisjunctiveFacet(facetName)) {
7625
- var disjRefinements = this.state.getDisjunctiveRefinements(facetName);
7626
-
7627
- forEach(disjRefinements, function(r) {
7628
- refinements.push({
7629
- value: r,
7630
- type: 'disjunctive'
7631
- });
7632
- });
7633
- }
7634
-
7635
- var numericRefinements = this.state.getNumericRefinements(facetName);
7636
-
7637
- forEach(numericRefinements, function(value, operator) {
7638
- refinements.push({
7639
- value: value,
7640
- operator: operator,
7641
- type: 'numeric'
7642
- });
7643
- });
7644
-
7645
- return refinements;
7646
- };
7647
-
7648
- /**
7649
- * Get the current breadcrumb for a hierarchical facet, as an array
7650
- * @param {string} facetName Hierarchical facet name
7651
- * @return {array}
7652
- */
7653
- AlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function(facetName) {
7654
- return map(
7655
- this
7656
- .state
7657
- .getHierarchicalRefinement(facetName)[0]
7658
- .split(this.state._getHierarchicalFacetSeparator(
7659
- this.state.getHierarchicalFacetByName(facetName)
7660
- )), function trimName(facetValue) { return trim(facetValue); }
7661
- );
7662
- };
7663
-
7664
- // /////////// PRIVATE
7665
-
7666
- /**
7667
- * Perform the underlying queries
7668
- * @private
7669
- * @return {undefined}
7670
- */
7671
- AlgoliaSearchHelper.prototype._search = function() {
7672
- var state = this.state;
7673
-
7674
- this.client.search(this._getQueries(),
7675
- bind(this._handleResponse,
7676
- this,
7677
- state,
7678
- this._queryId++));
7679
- };
7680
-
7681
- /**
7682
- * Get all the queries to send to the client, those queries can used directly
7683
- * with the Algolia client.
7684
- * @private
7685
- * @return {object[]} The queries
7686
- */
7687
- AlgoliaSearchHelper.prototype._getQueries = function getQueries() {
7688
- var queries = [];
7689
-
7690
- // One query for the hits
7691
- queries.push({
7692
- indexName: this.index,
7693
- query: this.state.query,
7694
- params: this._getHitsSearchParams()
7695
- });
7696
-
7697
- // One for each disjunctive facets
7698
- forEach(this.state.getRefinedDisjunctiveFacets(), function(refinedFacet) {
7699
- queries.push({
7700
- indexName: this.index,
7701
- query: this.state.query,
7702
- params: this._getDisjunctiveFacetSearchParams(refinedFacet)
7703
- });
7704
- }, this);
7705
-
7706
- // maybe more to get the root level of hierarchical facets when activated
7707
- forEach(this.state.getRefinedHierarchicalFacets(), function(refinedFacet) {
7708
- var hierarchicalFacet = this.state.getHierarchicalFacetByName(refinedFacet);
7709
-
7710
- if (hierarchicalFacet.alwaysGetRootLevel !== true) {
7711
- return;
7712
- }
7713
-
7714
- var currentRefinement = this.state.getHierarchicalRefinement(refinedFacet);
7715
- // if we are deeper than level 0 (starting from `beer > IPA`)
7716
- // we want to get the root values
7717
- if (currentRefinement.length > 0 && currentRefinement[0].split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length > 1) {
7718
- queries.push({
7719
- indexName: this.index,
7720
- query: this.state.query,
7721
- params: this._getDisjunctiveFacetSearchParams(refinedFacet, true)
7722
- });
7723
- }
7724
- }, this);
7725
-
7726
- return queries;
7727
- };
7728
-
7729
- /**
7730
- * Transform the response as sent by the server and transform it into a user
7731
- * usable objet that merge the results of all the batch requests.
7732
- * @private
7733
- * @param {SearchParameters} state state used for to generate the request
7734
- * @param {number} queryId id of the current request
7735
- * @param {Error} err error if any, null otherwise
7736
- * @param {object} content content of the response
7737
- * @return {undefined}
7738
- */
7739
- AlgoliaSearchHelper.prototype._handleResponse = function(state, queryId, err, content) {
7740
- if (queryId < this._lastQueryIdReceived) {
7741
- // Outdated answer
7742
- return;
7743
- }
7744
-
7745
- this._lastQueryIdReceived = queryId;
7746
-
7747
- if (err) {
7748
- this.emit('error', err);
7749
- return;
7750
- }
7751
-
7752
- var formattedResponse = this.lastResults = new SearchResults(state, content);
7753
-
7754
- this.emit('result', formattedResponse, state);
7755
- };
7756
-
7757
- /**
7758
- * Build search parameters used to fetch hits
7759
- * @private
7760
- * @return {object.<string, any>}
7761
- */
7762
- AlgoliaSearchHelper.prototype._getHitsSearchParams = function() {
7763
- var facets = this.state.facets
7764
- .concat(this.state.disjunctiveFacets)
7765
- .concat(this._getHitsHierarchicalFacetsAttributes());
7766
-
7767
- var facetFilters = this._getFacetFilters();
7768
- var numericFilters = this._getNumericFilters();
7769
- var tagFilters = this._getTagFilters();
7770
- var additionalParams = {
7771
- facets: facets,
7772
- tagFilters: tagFilters
7773
- };
7774
-
7775
- if (this.state.distinct === true || this.state.distinct === false) {
7776
- additionalParams.distinct = this.state.distinct;
7777
- }
7778
-
7779
- if (facetFilters.length > 0) {
7780
- additionalParams.facetFilters = facetFilters;
7781
- }
7782
-
7783
- if (numericFilters.length > 0) {
7784
- additionalParams.numericFilters = numericFilters;
7785
- }
7786
-
7787
- return merge(this.state.getQueryParams(), additionalParams);
7788
- };
7789
-
7790
- /**
7791
- * Build search parameters used to fetch a disjunctive facet
7792
- * @private
7793
- * @param {string} facet the associated facet name
7794
- * @return {object}
7795
- */
7796
- AlgoliaSearchHelper.prototype._getDisjunctiveFacetSearchParams = function(facet, hierarchicalRootLevel) {
7797
- var facetFilters = this._getFacetFilters(facet, hierarchicalRootLevel);
7798
- var numericFilters = this._getNumericFilters(facet);
7799
- var tagFilters = this._getTagFilters();
7800
- var additionalParams = {
7801
- hitsPerPage: 1,
7802
- page: 0,
7803
- attributesToRetrieve: [],
7804
- attributesToHighlight: [],
7805
- attributesToSnippet: [],
7806
- tagFilters: tagFilters
7807
- };
7808
-
7809
- var hierarchicalFacet = this.state.getHierarchicalFacetByName(facet);
7810
-
7811
- if (hierarchicalFacet) {
7812
- additionalParams.facets = this._getDisjunctiveHierarchicalFacetAttribute(hierarchicalFacet, hierarchicalRootLevel);
7813
- } else {
7814
- additionalParams.facets = facet;
7815
- }
7816
-
7817
- if (this.state.distinct === true || this.state.distinct === false) {
7818
- additionalParams.distinct = this.state.distinct;
7819
- }
7820
-
7821
- if (numericFilters.length > 0) {
7822
- additionalParams.numericFilters = numericFilters;
7823
- }
7824
-
7825
- if (facetFilters.length > 0) {
7826
- additionalParams.facetFilters = facetFilters;
7827
- }
7828
-
7829
- return merge(this.state.getQueryParams(), additionalParams);
7830
- };
7831
-
7832
- AlgoliaSearchHelper.prototype.containsRefinement = function(query, facetFilters, numericFilters, tagFilters) {
7833
- return query ||
7834
- facetFilters.length !== 0 ||
7835
- numericFilters.length !== 0 ||
7836
- tagFilters.length !== 0;
7837
- };
7838
-
7839
- /**
7840
- * Return the numeric filters in an algolia request fashion
7841
- * @private
7842
- * @param {string} [facetName] the name of the attribute for which the filters should be excluded
7843
- * @return {string[]} the numeric filters in the algolia format
7844
- */
7845
- AlgoliaSearchHelper.prototype._getNumericFilters = function(facetName) {
7846
- var numericFilters = [];
7847
-
7848
- forEach(this.state.numericRefinements, function(operators, attribute) {
7849
- forEach(operators, function(value, operator) {
7850
- if (facetName !== attribute) {
7851
- numericFilters.push(attribute + operator + value);
7852
- }
7853
- });
7854
- });
7855
-
7856
- return numericFilters;
7857
- };
7858
-
7859
- /**
7860
- * Return the tags filters depending
7861
- * @private
7862
- * @return {string}
7863
- */
7864
- AlgoliaSearchHelper.prototype._getTagFilters = function() {
7865
- if (this.state.tagFilters) {
7866
- return this.state.tagFilters;
7867
- }
7868
-
7869
- return this.state.tagRefinements.join(',');
7870
- };
7871
-
7872
- /**
7873
- * Test if there are some disjunctive refinements on the facet
7874
- * @private
7875
- * @param {string} facet the attribute to test
7876
- * @return {boolean}
7877
- */
7878
- AlgoliaSearchHelper.prototype._hasDisjunctiveRefinements = function(facet) {
7879
- return this.state.disjunctiveRefinements[facet] &&
7880
- this.state.disjunctiveRefinements[facet].length > 0;
7881
- };
7882
-
7883
- /**
7884
- * Build facetFilters parameter based on current refinements. The array returned
7885
- * contains strings representing the facet filters in the algolia format.
7886
- * @private
7887
- * @param {string} [facet] if set, the current disjunctive facet
7888
- * @return {array.<string>}
7889
- */
7890
- AlgoliaSearchHelper.prototype._getFacetFilters = function(facet, hierarchicalRootLevel) {
7891
- var facetFilters = [];
7892
-
7893
- forEach(this.state.facetsRefinements, function(facetValues, facetName) {
7894
- forEach(facetValues, function(facetValue) {
7895
- facetFilters.push(facetName + ':' + facetValue);
7896
- });
7897
- });
7898
-
7899
- forEach(this.state.facetsExcludes, function(facetValues, facetName) {
7900
- forEach(facetValues, function(facetValue) {
7901
- facetFilters.push(facetName + ':-' + facetValue);
7902
- });
7903
- });
7904
-
7905
- forEach(this.state.disjunctiveFacetsRefinements, function(facetValues, facetName) {
7906
- if (facetName === facet || !facetValues || facetValues.length === 0) return;
7907
- var orFilters = [];
7908
-
7909
- forEach(facetValues, function(facetValue) {
7910
- orFilters.push(facetName + ':' + facetValue);
7911
- });
7912
-
7913
- facetFilters.push(orFilters);
7914
- });
7915
-
7916
- forEach(this.state.hierarchicalFacetsRefinements, function(facetValues, facetName) {
7917
- var facetValue = facetValues[0];
7918
-
7919
- if (facetValue === undefined) {
7920
- return;
7921
- }
7922
-
7923
- var hierarchicalFacet = this.state.getHierarchicalFacetByName(facetName);
7924
- var separator = this.state._getHierarchicalFacetSeparator(hierarchicalFacet);
7925
- var attributeToRefine;
7926
-
7927
- // we ask for parent facet values only when the `facet` is the current hierarchical facet
7928
- if (facet === facetName) {
7929
- // if we are at the root level already, no need to ask for facet values, we get them from
7930
- // the hits query
7931
- if (facetValue.indexOf(separator) === -1 || hierarchicalRootLevel === true) {
7932
- return;
7933
- }
7934
-
7935
- attributeToRefine = hierarchicalFacet.attributes[facetValue.split(separator).length - 2];
7936
- facetValue = facetValue.slice(0, facetValue.lastIndexOf(separator));
7937
- } else {
7938
- attributeToRefine = hierarchicalFacet.attributes[facetValue.split(separator).length - 1];
7939
- }
7940
-
7941
- facetFilters.push([attributeToRefine + ':' + facetValue]);
7942
- }, this);
7943
-
7944
- return facetFilters;
7945
- };
7946
-
7947
- AlgoliaSearchHelper.prototype._change = function() {
7948
- this.emit('change', this.state, this.lastResults);
7949
- };
7950
-
7951
- AlgoliaSearchHelper.prototype._getHitsHierarchicalFacetsAttributes = function() {
7952
- var out = [];
7953
-
7954
- return reduce(
7955
- this.state.hierarchicalFacets,
7956
- // ask for as much levels as there's hierarchical refinements
7957
- function getHitsAttributesForHierarchicalFacet(allAttributes, hierarchicalFacet) {
7958
- var hierarchicalRefinement = this.state.getHierarchicalRefinement(hierarchicalFacet.name)[0];
7959
-
7960
- // if no refinement, ask for root level
7961
- if (!hierarchicalRefinement) {
7962
- allAttributes.push(hierarchicalFacet.attributes[0]);
7963
- return allAttributes;
7964
- }
7965
-
7966
- var level = hierarchicalRefinement.split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length;
7967
- var newAttributes = hierarchicalFacet.attributes.slice(0, level + 1);
7968
-
7969
- return allAttributes.concat(newAttributes);
7970
- }, out, this);
7971
- };
7972
-
7973
- AlgoliaSearchHelper.prototype._getDisjunctiveHierarchicalFacetAttribute = function(hierarchicalFacet, rootLevel) {
7974
- if (rootLevel === true) {
7975
- return hierarchicalFacet.attributes[0];
7976
- }
7977
-
7978
- var hierarchicalRefinement = this.state.getHierarchicalRefinement(hierarchicalFacet.name)[0] || '';
7979
- // if refinement is 'beers > IPA > Flying dog',
7980
- // then we want `facets: ['beers > IPA']` as disjunctive facet (parent level values)
7981
-
7982
- var parentLevel = hierarchicalRefinement.split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length - 1;
7983
- return hierarchicalFacet.attributes.slice(0, parentLevel + 1);
7984
- };
7985
-
7986
- module.exports = AlgoliaSearchHelper;
7987
-
7988
- },{"./SearchParameters":152,"./SearchResults":154,"events":219,"lodash/collection/forEach":11,"lodash/collection/map":13,"lodash/collection/reduce":15,"lodash/function/bind":19,"lodash/lang/isEmpty":128,"lodash/object/merge":142,"lodash/string/trim":147,"util":226}],156:[function(require,module,exports){
7989
- 'use strict';
7990
-
7991
- var forEach = require('lodash/collection/forEach');
7992
- var identity = require('lodash/utility/identity');
7993
- var isObject = require('lodash/lang/isObject');
7994
-
7995
- /**
7996
- * Recursively freeze the parts of an object that are not frozen.
7997
- * @private
7998
- * @param {object} obj object to freeze
7999
- * @return {object} the object frozen
8000
- */
8001
- var deepFreeze = function(obj) {
8002
- if (!isObject(obj)) return obj;
8003
-
8004
- forEach(obj, deepFreeze);
8005
- if (!Object.isFrozen(obj)) {
8006
- Object.freeze(obj);
8007
- }
8008
-
8009
- return obj;
8010
- };
8011
-
8012
- module.exports = Object.freeze ? deepFreeze : identity;
8013
-
8014
- },{"lodash/collection/forEach":11,"lodash/lang/isObject":131,"lodash/utility/identity":148}],157:[function(require,module,exports){
8015
-
8016
- /**
8017
- * This is the web browser implementation of `debug()`.
8018
- *
8019
- * Expose `debug()` as the module.
8020
- */
8021
-
8022
- exports = module.exports = require('./debug');
8023
- exports.log = log;
8024
- exports.formatArgs = formatArgs;
8025
- exports.save = save;
8026
- exports.load = load;
8027
- exports.useColors = useColors;
8028
- exports.storage = 'undefined' != typeof chrome
8029
- && 'undefined' != typeof chrome.storage
8030
- ? chrome.storage.local
8031
- : localstorage();
8032
-
8033
- /**
8034
- * Colors.
8035
- */
8036
-
8037
- exports.colors = [
8038
- 'lightseagreen',
8039
- 'forestgreen',
8040
- 'goldenrod',
8041
- 'dodgerblue',
8042
- 'darkorchid',
8043
- 'crimson'
8044
- ];
8045
-
8046
- /**
8047
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
8048
- * and the Firebug extension (any Firefox version) are known
8049
- * to support "%c" CSS customizations.
8050
- *
8051
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
8052
- */
8053
-
8054
- function useColors() {
8055
- // is webkit? http://stackoverflow.com/a/16459606/376773
8056
- return ('WebkitAppearance' in document.documentElement.style) ||
8057
- // is firebug? http://stackoverflow.com/a/398120/376773
8058
- (window.console && (console.firebug || (console.exception && console.table))) ||
8059
- // is firefox >= v31?
8060
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
8061
- (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
8062
- }
8063
-
8064
- /**
8065
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
8066
- */
8067
-
8068
- exports.formatters.j = function(v) {
8069
- return JSON.stringify(v);
8070
- };
8071
-
8072
-
8073
- /**
8074
- * Colorize log arguments if enabled.
8075
- *
8076
- * @api public
8077
- */
8078
-
8079
- function formatArgs() {
8080
- var args = arguments;
8081
- var useColors = this.useColors;
8082
-
8083
- args[0] = (useColors ? '%c' : '')
8084
- + this.namespace
8085
- + (useColors ? ' %c' : ' ')
8086
- + args[0]
8087
- + (useColors ? '%c ' : ' ')
8088
- + '+' + exports.humanize(this.diff);
8089
-
8090
- if (!useColors) return args;
8091
-
8092
- var c = 'color: ' + this.color;
8093
- args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
8094
-
8095
- // the final "%c" is somewhat tricky, because there could be other
8096
- // arguments passed either before or after the %c, so we need to
8097
- // figure out the correct index to insert the CSS into
8098
- var index = 0;
8099
- var lastC = 0;
8100
- args[0].replace(/%[a-z%]/g, function(match) {
8101
- if ('%%' === match) return;
8102
- index++;
8103
- if ('%c' === match) {
8104
- // we only are interested in the *last* %c
8105
- // (the user may have provided their own)
8106
- lastC = index;
8107
- }
8108
- });
8109
-
8110
- args.splice(lastC, 0, c);
8111
- return args;
8112
- }
8113
-
8114
- /**
8115
- * Invokes `console.log()` when available.
8116
- * No-op when `console.log` is not a "function".
8117
- *
8118
- * @api public
8119
- */
8120
-
8121
- function log() {
8122
- // this hackery is required for IE8/9, where
8123
- // the `console.log` function doesn't have 'apply'
8124
- return 'object' === typeof console
8125
- && console.log
8126
- && Function.prototype.apply.call(console.log, console, arguments);
8127
- }
8128
-
8129
- /**
8130
- * Save `namespaces`.
8131
- *
8132
- * @param {String} namespaces
8133
- * @api private
8134
- */
8135
-
8136
- function save(namespaces) {
8137
- try {
8138
- if (null == namespaces) {
8139
- exports.storage.removeItem('debug');
8140
- } else {
8141
- exports.storage.debug = namespaces;
8142
- }
8143
- } catch(e) {}
8144
- }
8145
-
8146
- /**
8147
- * Load `namespaces`.
8148
- *
8149
- * @return {String} returns the previously persisted debug modes
8150
- * @api private
8151
- */
8152
-
8153
- function load() {
8154
- var r;
8155
- try {
8156
- r = exports.storage.debug;
8157
- } catch(e) {}
8158
- return r;
8159
- }
8160
-
8161
- /**
8162
- * Enable namespaces listed in `localStorage.debug` initially.
8163
- */
8164
-
8165
- exports.enable(load());
8166
-
8167
- /**
8168
- * Localstorage attempts to return the localstorage.
8169
- *
8170
- * This is necessary because safari throws
8171
- * when a user disables cookies/localstorage
8172
- * and you attempt to access it.
8173
- *
8174
- * @return {LocalStorage}
8175
- * @api private
8176
- */
8177
-
8178
- function localstorage(){
8179
- try {
8180
- return window.localStorage;
8181
- } catch (e) {}
8182
- }
8183
-
8184
- },{"./debug":158}],158:[function(require,module,exports){
8185
-
8186
- /**
8187
- * This is the common logic for both the Node.js and web browser
8188
- * implementations of `debug()`.
8189
- *
8190
- * Expose `debug()` as the module.
8191
- */
8192
-
8193
- exports = module.exports = debug;
8194
- exports.coerce = coerce;
8195
- exports.disable = disable;
8196
- exports.enable = enable;
8197
- exports.enabled = enabled;
8198
- exports.humanize = require('algolia-ms');
8199
-
8200
- /**
8201
- * The currently active debug mode names, and names to skip.
8202
- */
8203
-
8204
- exports.names = [];
8205
- exports.skips = [];
8206
-
8207
- /**
8208
- * Map of special "%n" handling functions, for the debug "format" argument.
8209
- *
8210
- * Valid key names are a single, lowercased letter, i.e. "n".
8211
- */
8212
-
8213
- exports.formatters = {};
8214
-
8215
- /**
8216
- * Previously assigned color.
8217
- */
8218
-
8219
- var prevColor = 0;
8220
-
8221
- /**
8222
- * Previous log timestamp.
8223
- */
8224
-
8225
- var prevTime;
8226
-
8227
- /**
8228
- * Select a color.
8229
- *
8230
- * @return {Number}
8231
- * @api private
8232
- */
8233
-
8234
- function selectColor() {
8235
- return exports.colors[prevColor++ % exports.colors.length];
8236
- }
8237
-
8238
- /**
8239
- * Create a debugger with the given `namespace`.
8240
- *
8241
- * @param {String} namespace
8242
- * @return {Function}
8243
- * @api public
8244
- */
8245
-
8246
- function debug(namespace) {
8247
-
8248
- // define the `disabled` version
8249
- function disabled() {
8250
- }
8251
- disabled.enabled = false;
8252
-
8253
- // define the `enabled` version
8254
- function enabled() {
8255
-
8256
- var self = enabled;
8257
-
8258
- // set `diff` timestamp
8259
- var curr = +new Date();
8260
- var ms = curr - (prevTime || curr);
8261
- self.diff = ms;
8262
- self.prev = prevTime;
8263
- self.curr = curr;
8264
- prevTime = curr;
8265
-
8266
- // add the `color` if not set
8267
- if (null == self.useColors) self.useColors = exports.useColors();
8268
- if (null == self.color && self.useColors) self.color = selectColor();
8269
-
8270
- var args = Array.prototype.slice.call(arguments);
8271
-
8272
- args[0] = exports.coerce(args[0]);
8273
-
8274
- if ('string' !== typeof args[0]) {
8275
- // anything else let's inspect with %o
8276
- args = ['%o'].concat(args);
8277
- }
8278
-
8279
- // apply any `formatters` transformations
8280
- var index = 0;
8281
- args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
8282
- // if we encounter an escaped % then don't increase the array index
8283
- if (match === '%%') return match;
8284
- index++;
8285
- var formatter = exports.formatters[format];
8286
- if ('function' === typeof formatter) {
8287
- var val = args[index];
8288
- match = formatter.call(self, val);
8289
-
8290
- // now we need to remove `args[index]` since it's inlined in the `format`
8291
- args.splice(index, 1);
8292
- index--;
8293
- }
8294
- return match;
8295
- });
8296
-
8297
- if ('function' === typeof exports.formatArgs) {
8298
- args = exports.formatArgs.apply(self, args);
8299
- }
8300
- var logFn = enabled.log || exports.log || console.log.bind(console);
8301
- logFn.apply(self, args);
8302
- }
8303
- enabled.enabled = true;
8304
-
8305
- var fn = exports.enabled(namespace) ? enabled : disabled;
8306
-
8307
- fn.namespace = namespace;
8308
-
8309
- return fn;
8310
- }
8311
-
8312
- /**
8313
- * Enables a debug mode by namespaces. This can include modes
8314
- * separated by a colon and wildcards.
8315
- *
8316
- * @param {String} namespaces
8317
- * @api public
8318
- */
8319
-
8320
- function enable(namespaces) {
8321
- exports.save(namespaces);
8322
-
8323
- var split = (namespaces || '').split(/[\s,]+/);
8324
- var len = split.length;
8325
-
8326
- for (var i = 0; i < len; i++) {
8327
- if (!split[i]) continue; // ignore empty strings
8328
- namespaces = split[i].replace(/\*/g, '.*?');
8329
- if (namespaces[0] === '-') {
8330
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
8331
- } else {
8332
- exports.names.push(new RegExp('^' + namespaces + '$'));
8333
- }
8334
- }
8335
- }
8336
-
8337
- /**
8338
- * Disable debug output.
8339
- *
8340
- * @api public
8341
- */
8342
-
8343
- function disable() {
8344
- exports.enable('');
8345
- }
8346
-
8347
- /**
8348
- * Returns true if the given mode name is enabled, false otherwise.
8349
- *
8350
- * @param {String} name
8351
- * @return {Boolean}
8352
- * @api public
8353
- */
8354
-
8355
- function enabled(name) {
8356
- var i, len;
8357
- for (i = 0, len = exports.skips.length; i < len; i++) {
8358
- if (exports.skips[i].test(name)) {
8359
- return false;
8360
- }
8361
- }
8362
- for (i = 0, len = exports.names.length; i < len; i++) {
8363
- if (exports.names[i].test(name)) {
8364
- return true;
8365
- }
8366
- }
8367
- return false;
8368
- }
8369
-
8370
- /**
8371
- * Coerce `val`.
8372
- *
8373
- * @param {Mixed} val
8374
- * @return {Mixed}
8375
- * @api private
8376
- */
8377
-
8378
- function coerce(val) {
8379
- if (val instanceof Error) return val.stack || val.message;
8380
- return val;
8381
- }
8382
-
8383
- },{"algolia-ms":159}],159:[function(require,module,exports){
8384
- /**
8385
- * Helpers.
8386
- */
8387
-
8388
- var s = 1000;
8389
- var m = s * 60;
8390
- var h = m * 60;
8391
- var d = h * 24;
8392
- var y = d * 365.25;
8393
-
8394
- /**
8395
- * Parse or format the given `val`.
8396
- *
8397
- * Options:
8398
- *
8399
- * - `long` verbose formatting [false]
8400
- *
8401
- * @param {String|Number} val
8402
- * @param {Object} options
8403
- * @return {String|Number}
8404
- * @api public
8405
- */
8406
-
8407
- module.exports = function(val, options){
8408
- options = options || {};
8409
- if ('string' == typeof val) return parse(val);
8410
- // long, short were "future reserved words in js", YUI compressor fail on them
8411
- // https://github.com/algolia/algoliasearch-client-js/issues/113#issuecomment-111978606
8412
- // https://github.com/yui/yuicompressor/issues/47
8413
- // https://github.com/rauchg/ms.js/pull/40
8414
- return options['long']
8415
- ? _long(val)
8416
- : _short(val);
8417
- };
8418
-
8419
- /**
8420
- * Parse the given `str` and return milliseconds.
8421
- *
8422
- * @param {String} str
8423
- * @return {Number}
8424
- * @api private
8425
- */
8426
-
8427
- function parse(str) {
8428
- str = '' + str;
8429
- if (str.length > 10000) return;
8430
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
8431
- if (!match) return;
8432
- var n = parseFloat(match[1]);
8433
- var type = (match[2] || 'ms').toLowerCase();
8434
- switch (type) {
8435
- case 'years':
8436
- case 'year':
8437
- case 'yrs':
8438
- case 'yr':
8439
- case 'y':
8440
- return n * y;
8441
- case 'days':
8442
- case 'day':
8443
- case 'd':
8444
- return n * d;
8445
- case 'hours':
8446
- case 'hour':
8447
- case 'hrs':
8448
- case 'hr':
8449
- case 'h':
8450
- return n * h;
8451
- case 'minutes':
8452
- case 'minute':
8453
- case 'mins':
8454
- case 'min':
8455
- case 'm':
8456
- return n * m;
8457
- case 'seconds':
8458
- case 'second':
8459
- case 'secs':
8460
- case 'sec':
8461
- case 's':
8462
- return n * s;
8463
- case 'milliseconds':
8464
- case 'millisecond':
8465
- case 'msecs':
8466
- case 'msec':
8467
- case 'ms':
8468
- return n;
8469
- }
8470
- }
8471
-
8472
- /**
8473
- * Short format for `ms`.
8474
- *
8475
- * @param {Number} ms
8476
- * @return {String}
8477
- * @api private
8478
- */
8479
-
8480
- function _short(ms) {
8481
- if (ms >= d) return Math.round(ms / d) + 'd';
8482
- if (ms >= h) return Math.round(ms / h) + 'h';
8483
- if (ms >= m) return Math.round(ms / m) + 'm';
8484
- if (ms >= s) return Math.round(ms / s) + 's';
8485
- return ms + 'ms';
8486
- }
8487
-
8488
- /**
8489
- * Long format for `ms`.
8490
- *
8491
- * @param {Number} ms
8492
- * @return {String}
8493
- * @api private
8494
- */
8495
-
8496
- function _long(ms) {
8497
- return plural(ms, d, 'day')
8498
- || plural(ms, h, 'hour')
8499
- || plural(ms, m, 'minute')
8500
- || plural(ms, s, 'second')
8501
- || ms + ' ms';
8502
- }
8503
-
8504
- /**
8505
- * Pluralization helper.
8506
- */
8507
-
8508
- function plural(ms, n, name) {
8509
- if (ms < n) return;
8510
- if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
8511
- return Math.ceil(ms / n) + ' ' + name + 's';
8512
- }
8513
-
8514
- },{}],160:[function(require,module,exports){
8515
- (function (process,global){
8516
- /*!
8517
- * @overview es6-promise - a tiny implementation of Promises/A+.
8518
- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
8519
- * @license Licensed under MIT license
8520
- * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
8521
- * @version 2.3.0
8522
- */
8523
-
8524
- (function() {
8525
- "use strict";
8526
- function lib$es6$promise$utils$$objectOrFunction(x) {
8527
- return typeof x === 'function' || (typeof x === 'object' && x !== null);
8528
- }
8529
-
8530
- function lib$es6$promise$utils$$isFunction(x) {
8531
- return typeof x === 'function';
8532
- }
8533
-
8534
- function lib$es6$promise$utils$$isMaybeThenable(x) {
8535
- return typeof x === 'object' && x !== null;
8536
- }
8537
-
8538
- var lib$es6$promise$utils$$_isArray;
8539
- if (!Array.isArray) {
8540
- lib$es6$promise$utils$$_isArray = function (x) {
8541
- return Object.prototype.toString.call(x) === '[object Array]';
8542
- };
8543
- } else {
8544
- lib$es6$promise$utils$$_isArray = Array.isArray;
8545
- }
8546
-
8547
- var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
8548
- var lib$es6$promise$asap$$len = 0;
8549
- var lib$es6$promise$asap$$toString = {}.toString;
8550
- var lib$es6$promise$asap$$vertxNext;
8551
- var lib$es6$promise$asap$$customSchedulerFn;
8552
-
8553
- var lib$es6$promise$asap$$asap = function asap(callback, arg) {
8554
- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
8555
- lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
8556
- lib$es6$promise$asap$$len += 2;
8557
- if (lib$es6$promise$asap$$len === 2) {
8558
- // If len is 2, that means that we need to schedule an async flush.
8559
- // If additional callbacks are queued before the queue is flushed, they
8560
- // will be processed by this flush that we are scheduling.
8561
- if (lib$es6$promise$asap$$customSchedulerFn) {
8562
- lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
8563
- } else {
8564
- lib$es6$promise$asap$$scheduleFlush();
8565
- }
8566
- }
8567
- }
8568
-
8569
- function lib$es6$promise$asap$$setScheduler(scheduleFn) {
8570
- lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
8571
- }
8572
-
8573
- function lib$es6$promise$asap$$setAsap(asapFn) {
8574
- lib$es6$promise$asap$$asap = asapFn;
8575
- }
8576
-
8577
- var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
8578
- var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
8579
- var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
8580
- var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
8581
-
8582
- // test for web worker but not in IE10
8583
- var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
8584
- typeof importScripts !== 'undefined' &&
8585
- typeof MessageChannel !== 'undefined';
8586
-
8587
- // node
8588
- function lib$es6$promise$asap$$useNextTick() {
8589
- var nextTick = process.nextTick;
8590
- // node version 0.10.x displays a deprecation warning when nextTick is used recursively
8591
- // setImmediate should be used instead instead
8592
- var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
8593
- if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
8594
- nextTick = setImmediate;
8595
- }
8596
- return function() {
8597
- nextTick(lib$es6$promise$asap$$flush);
8598
- };
8599
- }
8600
-
8601
- // vertx
8602
- function lib$es6$promise$asap$$useVertxTimer() {
8603
- return function() {
8604
- lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
8605
- };
8606
- }
8607
-
8608
- function lib$es6$promise$asap$$useMutationObserver() {
8609
- var iterations = 0;
8610
- var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
8611
- var node = document.createTextNode('');
8612
- observer.observe(node, { characterData: true });
8613
-
8614
- return function() {
8615
- node.data = (iterations = ++iterations % 2);
8616
- };
8617
- }
8618
-
8619
- // web worker
8620
- function lib$es6$promise$asap$$useMessageChannel() {
8621
- var channel = new MessageChannel();
8622
- channel.port1.onmessage = lib$es6$promise$asap$$flush;
8623
- return function () {
8624
- channel.port2.postMessage(0);
8625
- };
8626
- }
8627
-
8628
- function lib$es6$promise$asap$$useSetTimeout() {
8629
- return function() {
8630
- setTimeout(lib$es6$promise$asap$$flush, 1);
8631
- };
8632
- }
8633
-
8634
- var lib$es6$promise$asap$$queue = new Array(1000);
8635
- function lib$es6$promise$asap$$flush() {
8636
- for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
8637
- var callback = lib$es6$promise$asap$$queue[i];
8638
- var arg = lib$es6$promise$asap$$queue[i+1];
8639
-
8640
- callback(arg);
8641
-
8642
- lib$es6$promise$asap$$queue[i] = undefined;
8643
- lib$es6$promise$asap$$queue[i+1] = undefined;
8644
- }
8645
-
8646
- lib$es6$promise$asap$$len = 0;
8647
- }
8648
-
8649
- function lib$es6$promise$asap$$attemptVertex() {
8650
- try {
8651
- var r = require;
8652
- var vertx = r('vertx');
8653
- lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
8654
- return lib$es6$promise$asap$$useVertxTimer();
8655
- } catch(e) {
8656
- return lib$es6$promise$asap$$useSetTimeout();
8657
- }
8658
- }
8659
-
8660
- var lib$es6$promise$asap$$scheduleFlush;
8661
- // Decide what async method to use to triggering processing of queued callbacks:
8662
- if (lib$es6$promise$asap$$isNode) {
8663
- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
8664
- } else if (lib$es6$promise$asap$$BrowserMutationObserver) {
8665
- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
8666
- } else if (lib$es6$promise$asap$$isWorker) {
8667
- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
8668
- } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
8669
- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertex();
8670
- } else {
8671
- lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
8672
- }
8673
-
8674
- function lib$es6$promise$$internal$$noop() {}
8675
-
8676
- var lib$es6$promise$$internal$$PENDING = void 0;
8677
- var lib$es6$promise$$internal$$FULFILLED = 1;
8678
- var lib$es6$promise$$internal$$REJECTED = 2;
8679
-
8680
- var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
8681
-
8682
- function lib$es6$promise$$internal$$selfFullfillment() {
8683
- return new TypeError("You cannot resolve a promise with itself");
8684
- }
8685
-
8686
- function lib$es6$promise$$internal$$cannotReturnOwn() {
8687
- return new TypeError('A promises callback cannot return that same promise.');
8688
- }
8689
-
8690
- function lib$es6$promise$$internal$$getThen(promise) {
8691
- try {
8692
- return promise.then;
8693
- } catch(error) {
8694
- lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
8695
- return lib$es6$promise$$internal$$GET_THEN_ERROR;
8696
- }
8697
- }
8698
-
8699
- function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
8700
- try {
8701
- then.call(value, fulfillmentHandler, rejectionHandler);
8702
- } catch(e) {
8703
- return e;
8704
- }
8705
- }
8706
-
8707
- function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
8708
- lib$es6$promise$asap$$asap(function(promise) {
8709
- var sealed = false;
8710
- var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
8711
- if (sealed) { return; }
8712
- sealed = true;
8713
- if (thenable !== value) {
8714
- lib$es6$promise$$internal$$resolve(promise, value);
8715
- } else {
8716
- lib$es6$promise$$internal$$fulfill(promise, value);
8717
- }
8718
- }, function(reason) {
8719
- if (sealed) { return; }
8720
- sealed = true;
8721
-
8722
- lib$es6$promise$$internal$$reject(promise, reason);
8723
- }, 'Settle: ' + (promise._label || ' unknown promise'));
8724
-
8725
- if (!sealed && error) {
8726
- sealed = true;
8727
- lib$es6$promise$$internal$$reject(promise, error);
8728
- }
8729
- }, promise);
8730
- }
8731
-
8732
- function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
8733
- if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
8734
- lib$es6$promise$$internal$$fulfill(promise, thenable._result);
8735
- } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
8736
- lib$es6$promise$$internal$$reject(promise, thenable._result);
8737
- } else {
8738
- lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
8739
- lib$es6$promise$$internal$$resolve(promise, value);
8740
- }, function(reason) {
8741
- lib$es6$promise$$internal$$reject(promise, reason);
8742
- });
8743
- }
8744
- }
8745
-
8746
- function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
8747
- if (maybeThenable.constructor === promise.constructor) {
8748
- lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
8749
- } else {
8750
- var then = lib$es6$promise$$internal$$getThen(maybeThenable);
8751
-
8752
- if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
8753
- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
8754
- } else if (then === undefined) {
8755
- lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
8756
- } else if (lib$es6$promise$utils$$isFunction(then)) {
8757
- lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
8758
- } else {
8759
- lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
8760
- }
8761
- }
8762
- }
8763
-
8764
- function lib$es6$promise$$internal$$resolve(promise, value) {
8765
- if (promise === value) {
8766
- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFullfillment());
8767
- } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
8768
- lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
8769
- } else {
8770
- lib$es6$promise$$internal$$fulfill(promise, value);
8771
- }
8772
- }
8773
-
8774
- function lib$es6$promise$$internal$$publishRejection(promise) {
8775
- if (promise._onerror) {
8776
- promise._onerror(promise._result);
8777
- }
8778
-
8779
- lib$es6$promise$$internal$$publish(promise);
8780
- }
8781
-
8782
- function lib$es6$promise$$internal$$fulfill(promise, value) {
8783
- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
8784
-
8785
- promise._result = value;
8786
- promise._state = lib$es6$promise$$internal$$FULFILLED;
8787
-
8788
- if (promise._subscribers.length !== 0) {
8789
- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
8790
- }
8791
- }
8792
-
8793
- function lib$es6$promise$$internal$$reject(promise, reason) {
8794
- if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
8795
- promise._state = lib$es6$promise$$internal$$REJECTED;
8796
- promise._result = reason;
8797
-
8798
- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
8799
- }
8800
-
8801
- function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
8802
- var subscribers = parent._subscribers;
8803
- var length = subscribers.length;
8804
-
8805
- parent._onerror = null;
8806
-
8807
- subscribers[length] = child;
8808
- subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
8809
- subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
8810
-
8811
- if (length === 0 && parent._state) {
8812
- lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
8813
- }
8814
- }
8815
-
8816
- function lib$es6$promise$$internal$$publish(promise) {
8817
- var subscribers = promise._subscribers;
8818
- var settled = promise._state;
8819
-
8820
- if (subscribers.length === 0) { return; }
8821
-
8822
- var child, callback, detail = promise._result;
8823
-
8824
- for (var i = 0; i < subscribers.length; i += 3) {
8825
- child = subscribers[i];
8826
- callback = subscribers[i + settled];
8827
-
8828
- if (child) {
8829
- lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
8830
- } else {
8831
- callback(detail);
8832
- }
8833
- }
8834
-
8835
- promise._subscribers.length = 0;
8836
- }
8837
-
8838
- function lib$es6$promise$$internal$$ErrorObject() {
8839
- this.error = null;
8840
- }
8841
-
8842
- var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
8843
-
8844
- function lib$es6$promise$$internal$$tryCatch(callback, detail) {
8845
- try {
8846
- return callback(detail);
8847
- } catch(e) {
8848
- lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
8849
- return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
8850
- }
8851
- }
8852
-
8853
- function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
8854
- var hasCallback = lib$es6$promise$utils$$isFunction(callback),
8855
- value, error, succeeded, failed;
8856
-
8857
- if (hasCallback) {
8858
- value = lib$es6$promise$$internal$$tryCatch(callback, detail);
8859
-
8860
- if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
8861
- failed = true;
8862
- error = value.error;
8863
- value = null;
8864
- } else {
8865
- succeeded = true;
8866
- }
8867
-
8868
- if (promise === value) {
8869
- lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
8870
- return;
8871
- }
8872
-
8873
- } else {
8874
- value = detail;
8875
- succeeded = true;
8876
- }
8877
-
8878
- if (promise._state !== lib$es6$promise$$internal$$PENDING) {
8879
- // noop
8880
- } else if (hasCallback && succeeded) {
8881
- lib$es6$promise$$internal$$resolve(promise, value);
8882
- } else if (failed) {
8883
- lib$es6$promise$$internal$$reject(promise, error);
8884
- } else if (settled === lib$es6$promise$$internal$$FULFILLED) {
8885
- lib$es6$promise$$internal$$fulfill(promise, value);
8886
- } else if (settled === lib$es6$promise$$internal$$REJECTED) {
8887
- lib$es6$promise$$internal$$reject(promise, value);
8888
- }
8889
- }
8890
-
8891
- function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
8892
- try {
8893
- resolver(function resolvePromise(value){
8894
- lib$es6$promise$$internal$$resolve(promise, value);
8895
- }, function rejectPromise(reason) {
8896
- lib$es6$promise$$internal$$reject(promise, reason);
8897
- });
8898
- } catch(e) {
8899
- lib$es6$promise$$internal$$reject(promise, e);
8900
- }
8901
- }
8902
-
8903
- function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
8904
- var enumerator = this;
8905
-
8906
- enumerator._instanceConstructor = Constructor;
8907
- enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
8908
-
8909
- if (enumerator._validateInput(input)) {
8910
- enumerator._input = input;
8911
- enumerator.length = input.length;
8912
- enumerator._remaining = input.length;
8913
-
8914
- enumerator._init();
8915
-
8916
- if (enumerator.length === 0) {
8917
- lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
8918
- } else {
8919
- enumerator.length = enumerator.length || 0;
8920
- enumerator._enumerate();
8921
- if (enumerator._remaining === 0) {
8922
- lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
8923
- }
8924
- }
8925
- } else {
8926
- lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
8927
- }
8928
- }
8929
-
8930
- lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
8931
- return lib$es6$promise$utils$$isArray(input);
8932
- };
8933
-
8934
- lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
8935
- return new Error('Array Methods must be provided an Array');
8936
- };
8937
-
8938
- lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
8939
- this._result = new Array(this.length);
8940
- };
8941
-
8942
- var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
8943
-
8944
- lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
8945
- var enumerator = this;
8946
-
8947
- var length = enumerator.length;
8948
- var promise = enumerator.promise;
8949
- var input = enumerator._input;
8950
-
8951
- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
8952
- enumerator._eachEntry(input[i], i);
8953
- }
8954
- };
8955
-
8956
- lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
8957
- var enumerator = this;
8958
- var c = enumerator._instanceConstructor;
8959
-
8960
- if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
8961
- if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
8962
- entry._onerror = null;
8963
- enumerator._settledAt(entry._state, i, entry._result);
8964
- } else {
8965
- enumerator._willSettleAt(c.resolve(entry), i);
8966
- }
8967
- } else {
8968
- enumerator._remaining--;
8969
- enumerator._result[i] = entry;
8970
- }
8971
- };
8972
-
8973
- lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
8974
- var enumerator = this;
8975
- var promise = enumerator.promise;
8976
-
8977
- if (promise._state === lib$es6$promise$$internal$$PENDING) {
8978
- enumerator._remaining--;
8979
-
8980
- if (state === lib$es6$promise$$internal$$REJECTED) {
8981
- lib$es6$promise$$internal$$reject(promise, value);
8982
- } else {
8983
- enumerator._result[i] = value;
8984
- }
8985
- }
8986
-
8987
- if (enumerator._remaining === 0) {
8988
- lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
8989
- }
8990
- };
8991
-
8992
- lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
8993
- var enumerator = this;
8994
-
8995
- lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
8996
- enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
8997
- }, function(reason) {
8998
- enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
8999
- });
9000
- };
9001
- function lib$es6$promise$promise$all$$all(entries) {
9002
- return new lib$es6$promise$enumerator$$default(this, entries).promise;
9003
- }
9004
- var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
9005
- function lib$es6$promise$promise$race$$race(entries) {
9006
- /*jshint validthis:true */
9007
- var Constructor = this;
9008
-
9009
- var promise = new Constructor(lib$es6$promise$$internal$$noop);
9010
-
9011
- if (!lib$es6$promise$utils$$isArray(entries)) {
9012
- lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
9013
- return promise;
9014
- }
9015
-
9016
- var length = entries.length;
9017
-
9018
- function onFulfillment(value) {
9019
- lib$es6$promise$$internal$$resolve(promise, value);
9020
- }
9021
-
9022
- function onRejection(reason) {
9023
- lib$es6$promise$$internal$$reject(promise, reason);
9024
- }
9025
-
9026
- for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
9027
- lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
9028
- }
9029
-
9030
- return promise;
9031
- }
9032
- var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
9033
- function lib$es6$promise$promise$resolve$$resolve(object) {
9034
- /*jshint validthis:true */
9035
- var Constructor = this;
9036
-
9037
- if (object && typeof object === 'object' && object.constructor === Constructor) {
9038
- return object;
9039
- }
9040
-
9041
- var promise = new Constructor(lib$es6$promise$$internal$$noop);
9042
- lib$es6$promise$$internal$$resolve(promise, object);
9043
- return promise;
9044
- }
9045
- var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
9046
- function lib$es6$promise$promise$reject$$reject(reason) {
9047
- /*jshint validthis:true */
9048
- var Constructor = this;
9049
- var promise = new Constructor(lib$es6$promise$$internal$$noop);
9050
- lib$es6$promise$$internal$$reject(promise, reason);
9051
- return promise;
9052
- }
9053
- var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
9054
-
9055
- var lib$es6$promise$promise$$counter = 0;
9056
-
9057
- function lib$es6$promise$promise$$needsResolver() {
9058
- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
9059
- }
9060
-
9061
- function lib$es6$promise$promise$$needsNew() {
9062
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
9063
- }
9064
-
9065
- var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
9066
- /**
9067
- Promise objects represent the eventual result of an asynchronous operation. The
9068
- primary way of interacting with a promise is through its `then` method, which
9069
- registers callbacks to receive either a promise's eventual value or the reason
9070
- why the promise cannot be fulfilled.
9071
-
9072
- Terminology
9073
- -----------
9074
-
9075
- - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
9076
- - `thenable` is an object or function that defines a `then` method.
9077
- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
9078
- - `exception` is a value that is thrown using the throw statement.
9079
- - `reason` is a value that indicates why a promise was rejected.
9080
- - `settled` the final resting state of a promise, fulfilled or rejected.
9081
-
9082
- A promise can be in one of three states: pending, fulfilled, or rejected.
9083
-
9084
- Promises that are fulfilled have a fulfillment value and are in the fulfilled
9085
- state. Promises that are rejected have a rejection reason and are in the
9086
- rejected state. A fulfillment value is never a thenable.
9087
-
9088
- Promises can also be said to *resolve* a value. If this value is also a
9089
- promise, then the original promise's settled state will match the value's
9090
- settled state. So a promise that *resolves* a promise that rejects will
9091
- itself reject, and a promise that *resolves* a promise that fulfills will
9092
- itself fulfill.
9093
-
9094
-
9095
- Basic Usage:
9096
- ------------
9097
-
9098
- ```js
9099
- var promise = new Promise(function(resolve, reject) {
9100
- // on success
9101
- resolve(value);
9102
-
9103
- // on failure
9104
- reject(reason);
9105
- });
9106
-
9107
- promise.then(function(value) {
9108
- // on fulfillment
9109
- }, function(reason) {
9110
- // on rejection
9111
- });
9112
- ```
9113
-
9114
- Advanced Usage:
9115
- ---------------
9116
-
9117
- Promises shine when abstracting away asynchronous interactions such as
9118
- `XMLHttpRequest`s.
9119
-
9120
- ```js
9121
- function getJSON(url) {
9122
- return new Promise(function(resolve, reject){
9123
- var xhr = new XMLHttpRequest();
9124
-
9125
- xhr.open('GET', url);
9126
- xhr.onreadystatechange = handler;
9127
- xhr.responseType = 'json';
9128
- xhr.setRequestHeader('Accept', 'application/json');
9129
- xhr.send();
9130
-
9131
- function handler() {
9132
- if (this.readyState === this.DONE) {
9133
- if (this.status === 200) {
9134
- resolve(this.response);
9135
- } else {
9136
- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
9137
- }
9138
- }
9139
- };
9140
- });
9141
- }
9142
-
9143
- getJSON('/posts.json').then(function(json) {
9144
- // on fulfillment
9145
- }, function(reason) {
9146
- // on rejection
9147
- });
9148
- ```
9149
-
9150
- Unlike callbacks, promises are great composable primitives.
9151
-
9152
- ```js
9153
- Promise.all([
9154
- getJSON('/posts'),
9155
- getJSON('/comments')
9156
- ]).then(function(values){
9157
- values[0] // => postsJSON
9158
- values[1] // => commentsJSON
9159
-
9160
- return values;
9161
- });
9162
- ```
9163
-
9164
- @class Promise
9165
- @param {function} resolver
9166
- Useful for tooling.
9167
- @constructor
9168
- */
9169
- function lib$es6$promise$promise$$Promise(resolver) {
9170
- this._id = lib$es6$promise$promise$$counter++;
9171
- this._state = undefined;
9172
- this._result = undefined;
9173
- this._subscribers = [];
9174
-
9175
- if (lib$es6$promise$$internal$$noop !== resolver) {
9176
- if (!lib$es6$promise$utils$$isFunction(resolver)) {
9177
- lib$es6$promise$promise$$needsResolver();
9178
- }
9179
-
9180
- if (!(this instanceof lib$es6$promise$promise$$Promise)) {
9181
- lib$es6$promise$promise$$needsNew();
9182
- }
9183
-
9184
- lib$es6$promise$$internal$$initializePromise(this, resolver);
9185
- }
9186
- }
9187
-
9188
- lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
9189
- lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
9190
- lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
9191
- lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
9192
- lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
9193
- lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
9194
- lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
9195
-
9196
- lib$es6$promise$promise$$Promise.prototype = {
9197
- constructor: lib$es6$promise$promise$$Promise,
9198
-
9199
- /**
9200
- The primary way of interacting with a promise is through its `then` method,
9201
- which registers callbacks to receive either a promise's eventual value or the
9202
- reason why the promise cannot be fulfilled.
9203
-
9204
- ```js
9205
- findUser().then(function(user){
9206
- // user is available
9207
- }, function(reason){
9208
- // user is unavailable, and you are given the reason why
9209
- });
9210
- ```
9211
-
9212
- Chaining
9213
- --------
9214
-
9215
- The return value of `then` is itself a promise. This second, 'downstream'
9216
- promise is resolved with the return value of the first promise's fulfillment
9217
- or rejection handler, or rejected if the handler throws an exception.
9218
-
9219
- ```js
9220
- findUser().then(function (user) {
9221
- return user.name;
9222
- }, function (reason) {
9223
- return 'default name';
9224
- }).then(function (userName) {
9225
- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
9226
- // will be `'default name'`
9227
- });
9228
-
9229
- findUser().then(function (user) {
9230
- throw new Error('Found user, but still unhappy');
9231
- }, function (reason) {
9232
- throw new Error('`findUser` rejected and we're unhappy');
9233
- }).then(function (value) {
9234
- // never reached
9235
- }, function (reason) {
9236
- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
9237
- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
9238
- });
9239
- ```
9240
- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
9241
-
9242
- ```js
9243
- findUser().then(function (user) {
9244
- throw new PedagogicalException('Upstream error');
9245
- }).then(function (value) {
9246
- // never reached
9247
- }).then(function (value) {
9248
- // never reached
9249
- }, function (reason) {
9250
- // The `PedgagocialException` is propagated all the way down to here
9251
- });
9252
- ```
9253
-
9254
- Assimilation
9255
- ------------
9256
-
9257
- Sometimes the value you want to propagate to a downstream promise can only be
9258
- retrieved asynchronously. This can be achieved by returning a promise in the
9259
- fulfillment or rejection handler. The downstream promise will then be pending
9260
- until the returned promise is settled. This is called *assimilation*.
9261
-
9262
- ```js
9263
- findUser().then(function (user) {
9264
- return findCommentsByAuthor(user);
9265
- }).then(function (comments) {
9266
- // The user's comments are now available
9267
- });
9268
- ```
9269
-
9270
- If the assimliated promise rejects, then the downstream promise will also reject.
9271
-
9272
- ```js
9273
- findUser().then(function (user) {
9274
- return findCommentsByAuthor(user);
9275
- }).then(function (comments) {
9276
- // If `findCommentsByAuthor` fulfills, we'll have the value here
9277
- }, function (reason) {
9278
- // If `findCommentsByAuthor` rejects, we'll have the reason here
9279
- });
9280
- ```
9281
-
9282
- Simple Example
9283
- --------------
9284
-
9285
- Synchronous Example
9286
-
9287
- ```javascript
9288
- var result;
9289
-
9290
- try {
9291
- result = findResult();
9292
- // success
9293
- } catch(reason) {
9294
- // failure
9295
- }
9296
- ```
9297
-
9298
- Errback Example
9299
-
9300
- ```js
9301
- findResult(function(result, err){
9302
- if (err) {
9303
- // failure
9304
- } else {
9305
- // success
9306
- }
9307
- });
9308
- ```
9309
-
9310
- Promise Example;
9311
-
9312
- ```javascript
9313
- findResult().then(function(result){
9314
- // success
9315
- }, function(reason){
9316
- // failure
9317
- });
9318
- ```
9319
-
9320
- Advanced Example
9321
- --------------
9322
-
9323
- Synchronous Example
9324
-
9325
- ```javascript
9326
- var author, books;
9327
-
9328
- try {
9329
- author = findAuthor();
9330
- books = findBooksByAuthor(author);
9331
- // success
9332
- } catch(reason) {
9333
- // failure
9334
- }
9335
- ```
9336
-
9337
- Errback Example
9338
-
9339
- ```js
9340
-
9341
- function foundBooks(books) {
9342
-
9343
- }
9344
-
9345
- function failure(reason) {
9346
-
9347
- }
9348
-
9349
- findAuthor(function(author, err){
9350
- if (err) {
9351
- failure(err);
9352
- // failure
9353
- } else {
9354
- try {
9355
- findBoooksByAuthor(author, function(books, err) {
9356
- if (err) {
9357
- failure(err);
9358
- } else {
9359
- try {
9360
- foundBooks(books);
9361
- } catch(reason) {
9362
- failure(reason);
9363
- }
9364
- }
9365
- });
9366
- } catch(error) {
9367
- failure(err);
9368
- }
9369
- // success
9370
- }
9371
- });
9372
- ```
9373
-
9374
- Promise Example;
9375
-
9376
- ```javascript
9377
- findAuthor().
9378
- then(findBooksByAuthor).
9379
- then(function(books){
9380
- // found books
9381
- }).catch(function(reason){
9382
- // something went wrong
9383
- });
9384
- ```
9385
-
9386
- @method then
9387
- @param {Function} onFulfilled
9388
- @param {Function} onRejected
9389
- Useful for tooling.
9390
- @return {Promise}
9391
- */
9392
- then: function(onFulfillment, onRejection) {
9393
- var parent = this;
9394
- var state = parent._state;
9395
-
9396
- if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
9397
- return this;
9398
- }
9399
-
9400
- var child = new this.constructor(lib$es6$promise$$internal$$noop);
9401
- var result = parent._result;
9402
-
9403
- if (state) {
9404
- var callback = arguments[state - 1];
9405
- lib$es6$promise$asap$$asap(function(){
9406
- lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
9407
- });
9408
- } else {
9409
- lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
9410
- }
9411
-
9412
- return child;
9413
- },
9414
-
9415
- /**
9416
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
9417
- as the catch block of a try/catch statement.
9418
-
9419
- ```js
9420
- function findAuthor(){
9421
- throw new Error('couldn't find that author');
9422
- }
9423
-
9424
- // synchronous
9425
- try {
9426
- findAuthor();
9427
- } catch(reason) {
9428
- // something went wrong
9429
- }
9430
-
9431
- // async with promises
9432
- findAuthor().catch(function(reason){
9433
- // something went wrong
9434
- });
9435
- ```
9436
-
9437
- @method catch
9438
- @param {Function} onRejection
9439
- Useful for tooling.
9440
- @return {Promise}
9441
- */
9442
- 'catch': function(onRejection) {
9443
- return this.then(null, onRejection);
9444
- }
9445
- };
9446
- function lib$es6$promise$polyfill$$polyfill() {
9447
- var local;
9448
-
9449
- if (typeof global !== 'undefined') {
9450
- local = global;
9451
- } else if (typeof self !== 'undefined') {
9452
- local = self;
9453
- } else {
9454
- try {
9455
- local = Function('return this')();
9456
- } catch (e) {
9457
- throw new Error('polyfill failed because global object is unavailable in this environment');
9458
- }
9459
- }
9460
-
9461
- var P = local.Promise;
9462
-
9463
- if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
9464
- return;
9465
- }
9466
-
9467
- local.Promise = lib$es6$promise$promise$$default;
9468
- }
9469
- var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
9470
-
9471
- var lib$es6$promise$umd$$ES6Promise = {
9472
- 'Promise': lib$es6$promise$promise$$default,
9473
- 'polyfill': lib$es6$promise$polyfill$$default
9474
- };
9475
-
9476
- /* global define:true module:true window: true */
9477
- if (typeof define === 'function' && define['amd']) {
9478
- define(function() { return lib$es6$promise$umd$$ES6Promise; });
9479
- } else if (typeof module !== 'undefined' && module['exports']) {
9480
- module['exports'] = lib$es6$promise$umd$$ES6Promise;
9481
- } else if (typeof this !== 'undefined') {
9482
- this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
9483
- }
9484
-
9485
- lib$es6$promise$polyfill$$default();
9486
- }).call(this);
9487
-
9488
-
9489
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9490
- },{"_process":221}],161:[function(require,module,exports){
9491
- if (typeof Object.create === 'function') {
9492
- // implementation from standard node.js 'util' module
9493
- module.exports = function inherits(ctor, superCtor) {
9494
- ctor.super_ = superCtor
9495
- ctor.prototype = Object.create(superCtor.prototype, {
9496
- constructor: {
9497
- value: ctor,
9498
- enumerable: false,
9499
- writable: true,
9500
- configurable: true
9501
- }
9502
- });
9503
- };
9504
- } else {
9505
- // old school shim for old browsers
9506
- module.exports = function inherits(ctor, superCtor) {
9507
- ctor.super_ = superCtor
9508
- var TempCtor = function () {}
9509
- TempCtor.prototype = superCtor.prototype
9510
- ctor.prototype = new TempCtor()
9511
- ctor.prototype.constructor = ctor
9512
- }
9513
- }
9514
-
9515
- },{}],162:[function(require,module,exports){
9516
- arguments[4][11][0].apply(exports,arguments)
9517
- },{"../internal/arrayEach":165,"../internal/baseEach":169,"../internal/createForEach":181,"dup":11}],163:[function(require,module,exports){
9518
- arguments[4][20][0].apply(exports,arguments)
9519
- },{"dup":20}],164:[function(require,module,exports){
9520
- arguments[4][24][0].apply(exports,arguments)
9521
- },{"dup":24}],165:[function(require,module,exports){
9522
- arguments[4][25][0].apply(exports,arguments)
9523
- },{"dup":25}],166:[function(require,module,exports){
9524
- arguments[4][34][0].apply(exports,arguments)
9525
- },{"../object/keys":206,"./baseCopy":168,"dup":34}],167:[function(require,module,exports){
9526
- var arrayCopy = require('./arrayCopy'),
9527
- arrayEach = require('./arrayEach'),
9528
- baseAssign = require('./baseAssign'),
9529
- baseForOwn = require('./baseForOwn'),
9530
- initCloneArray = require('./initCloneArray'),
9531
- initCloneByTag = require('./initCloneByTag'),
9532
- initCloneObject = require('./initCloneObject'),
9533
- isArray = require('../lang/isArray'),
9534
- isHostObject = require('./isHostObject'),
9535
- isObject = require('../lang/isObject');
9536
-
9537
- /** `Object#toString` result references. */
9538
- var argsTag = '[object Arguments]',
9539
- arrayTag = '[object Array]',
9540
- boolTag = '[object Boolean]',
9541
- dateTag = '[object Date]',
9542
- errorTag = '[object Error]',
9543
- funcTag = '[object Function]',
9544
- mapTag = '[object Map]',
9545
- numberTag = '[object Number]',
9546
- objectTag = '[object Object]',
9547
- regexpTag = '[object RegExp]',
9548
- setTag = '[object Set]',
9549
- stringTag = '[object String]',
9550
- weakMapTag = '[object WeakMap]';
9551
-
9552
- var arrayBufferTag = '[object ArrayBuffer]',
9553
- float32Tag = '[object Float32Array]',
9554
- float64Tag = '[object Float64Array]',
9555
- int8Tag = '[object Int8Array]',
9556
- int16Tag = '[object Int16Array]',
9557
- int32Tag = '[object Int32Array]',
9558
- uint8Tag = '[object Uint8Array]',
9559
- uint8ClampedTag = '[object Uint8ClampedArray]',
9560
- uint16Tag = '[object Uint16Array]',
9561
- uint32Tag = '[object Uint32Array]';
9562
-
9563
- /** Used to identify `toStringTag` values supported by `_.clone`. */
9564
- var cloneableTags = {};
9565
- cloneableTags[argsTag] = cloneableTags[arrayTag] =
9566
- cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
9567
- cloneableTags[dateTag] = cloneableTags[float32Tag] =
9568
- cloneableTags[float64Tag] = cloneableTags[int8Tag] =
9569
- cloneableTags[int16Tag] = cloneableTags[int32Tag] =
9570
- cloneableTags[numberTag] = cloneableTags[objectTag] =
9571
- cloneableTags[regexpTag] = cloneableTags[stringTag] =
9572
- cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
9573
- cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
9574
- cloneableTags[errorTag] = cloneableTags[funcTag] =
9575
- cloneableTags[mapTag] = cloneableTags[setTag] =
9576
- cloneableTags[weakMapTag] = false;
9577
-
9578
- /** Used for native method references. */
9579
- var objectProto = Object.prototype;
9580
-
9581
- /**
9582
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
9583
- * of values.
9584
- */
9585
- var objToString = objectProto.toString;
9586
-
9587
- /**
9588
- * The base implementation of `_.clone` without support for argument juggling
9589
- * and `this` binding `customizer` functions.
9590
- *
9591
- * @private
9592
- * @param {*} value The value to clone.
9593
- * @param {boolean} [isDeep] Specify a deep clone.
9594
- * @param {Function} [customizer] The function to customize cloning values.
9595
- * @param {string} [key] The key of `value`.
9596
- * @param {Object} [object] The object `value` belongs to.
9597
- * @param {Array} [stackA=[]] Tracks traversed source objects.
9598
- * @param {Array} [stackB=[]] Associates clones with source counterparts.
9599
- * @returns {*} Returns the cloned value.
9600
- */
9601
- function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
9602
- var result;
9603
- if (customizer) {
9604
- result = object ? customizer(value, key, object) : customizer(value);
9605
- }
9606
- if (result !== undefined) {
9607
- return result;
9608
- }
9609
- if (!isObject(value)) {
9610
- return value;
9611
- }
9612
- var isArr = isArray(value);
9613
- if (isArr) {
9614
- result = initCloneArray(value);
9615
- if (!isDeep) {
9616
- return arrayCopy(value, result);
9617
- }
9618
- } else {
9619
- var tag = objToString.call(value),
9620
- isFunc = tag == funcTag;
9621
-
9622
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
9623
- if (isHostObject(value)) {
9624
- return object ? value : {};
9625
- }
9626
- result = initCloneObject(isFunc ? {} : value);
9627
- if (!isDeep) {
9628
- return baseAssign(result, value);
9629
- }
9630
- } else {
9631
- return cloneableTags[tag]
9632
- ? initCloneByTag(value, tag, isDeep)
9633
- : (object ? value : {});
9634
- }
9635
- }
9636
- // Check for circular references and return its corresponding clone.
9637
- stackA || (stackA = []);
9638
- stackB || (stackB = []);
9639
-
9640
- var length = stackA.length;
9641
- while (length--) {
9642
- if (stackA[length] == value) {
9643
- return stackB[length];
9644
- }
9645
- }
9646
- // Add the source value to the stack of traversed objects and associate it with its clone.
9647
- stackA.push(value);
9648
- stackB.push(result);
9649
-
9650
- // Recursively populate clone (susceptible to call stack limits).
9651
- (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
9652
- result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
9653
- });
9654
- return result;
9655
- }
9656
-
9657
- module.exports = baseClone;
9658
-
9659
- },{"../lang/isArray":198,"../lang/isObject":201,"./arrayCopy":164,"./arrayEach":165,"./baseAssign":166,"./baseForOwn":172,"./initCloneArray":184,"./initCloneByTag":185,"./initCloneObject":186,"./isHostObject":188}],168:[function(require,module,exports){
9660
- arguments[4][37][0].apply(exports,arguments)
9661
- },{"dup":37}],169:[function(require,module,exports){
9662
- arguments[4][40][0].apply(exports,arguments)
9663
- },{"./baseForOwn":172,"./createBaseEach":179,"dup":40}],170:[function(require,module,exports){
9664
- arguments[4][45][0].apply(exports,arguments)
9665
- },{"./createBaseFor":180,"dup":45}],171:[function(require,module,exports){
9666
- arguments[4][46][0].apply(exports,arguments)
9667
- },{"../object/keysIn":207,"./baseFor":170,"dup":46}],172:[function(require,module,exports){
9668
- arguments[4][47][0].apply(exports,arguments)
9669
- },{"../object/keys":206,"./baseFor":170,"dup":47}],173:[function(require,module,exports){
9670
- arguments[4][57][0].apply(exports,arguments)
9671
- },{"../lang/isArray":198,"../lang/isObject":201,"../lang/isTypedArray":204,"../object/keys":206,"./arrayEach":165,"./baseMergeDeep":174,"./isArrayLike":187,"./isObjectLike":192,"dup":57}],174:[function(require,module,exports){
9672
- arguments[4][58][0].apply(exports,arguments)
9673
- },{"../lang/isArguments":197,"../lang/isArray":198,"../lang/isPlainObject":202,"../lang/isTypedArray":204,"../lang/toPlainObject":205,"./arrayCopy":164,"./isArrayLike":187,"dup":58}],175:[function(require,module,exports){
9674
- var toObject = require('./toObject');
9675
-
9676
- /**
9677
- * The base implementation of `_.property` without support for deep paths.
9678
- *
9679
- * @private
9680
- * @param {string} key The key of the property to get.
9681
- * @returns {Function} Returns the new function.
9682
- */
9683
- function baseProperty(key) {
9684
- return function(object) {
9685
- return object == null ? undefined : toObject(object)[key];
9686
- };
9687
- }
9688
-
9689
- module.exports = baseProperty;
9690
-
9691
- },{"./toObject":194}],176:[function(require,module,exports){
9692
- arguments[4][71][0].apply(exports,arguments)
9693
- },{"../utility/identity":210,"dup":71}],177:[function(require,module,exports){
9694
- (function (global){
9695
- /** Native method references. */
9696
- var ArrayBuffer = global.ArrayBuffer,
9697
- Uint8Array = global.Uint8Array;
9698
-
9699
- /**
9700
- * Creates a clone of the given array buffer.
9701
- *
9702
- * @private
9703
- * @param {ArrayBuffer} buffer The array buffer to clone.
9704
- * @returns {ArrayBuffer} Returns the cloned array buffer.
9705
- */
9706
- function bufferClone(buffer) {
9707
- var result = new ArrayBuffer(buffer.byteLength),
9708
- view = new Uint8Array(result);
9709
-
9710
- view.set(new Uint8Array(buffer));
9711
- return result;
9712
- }
9713
-
9714
- module.exports = bufferClone;
9715
-
9716
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9717
- },{}],178:[function(require,module,exports){
9718
- arguments[4][79][0].apply(exports,arguments)
9719
- },{"../function/restParam":163,"./bindCallback":176,"./isIterateeCall":190,"dup":79}],179:[function(require,module,exports){
9720
- arguments[4][80][0].apply(exports,arguments)
9721
- },{"./getLength":182,"./isLength":191,"./toObject":194,"dup":80}],180:[function(require,module,exports){
9722
- arguments[4][81][0].apply(exports,arguments)
9723
- },{"./toObject":194,"dup":81}],181:[function(require,module,exports){
9724
- arguments[4][88][0].apply(exports,arguments)
9725
- },{"../lang/isArray":198,"./bindCallback":176,"dup":88}],182:[function(require,module,exports){
9726
- arguments[4][98][0].apply(exports,arguments)
9727
- },{"./baseProperty":175,"dup":98}],183:[function(require,module,exports){
9728
- arguments[4][100][0].apply(exports,arguments)
9729
- },{"../lang/isNative":200,"dup":100}],184:[function(require,module,exports){
9730
- /** Used for native method references. */
9731
- var objectProto = Object.prototype;
9732
-
9733
- /** Used to check objects for own properties. */
9734
- var hasOwnProperty = objectProto.hasOwnProperty;
9735
-
9736
- /**
9737
- * Initializes an array clone.
9738
- *
9739
- * @private
9740
- * @param {Array} array The array to clone.
9741
- * @returns {Array} Returns the initialized clone.
9742
- */
9743
- function initCloneArray(array) {
9744
- var length = array.length,
9745
- result = new array.constructor(length);
9746
-
9747
- // Add array properties assigned by `RegExp#exec`.
9748
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
9749
- result.index = array.index;
9750
- result.input = array.input;
9751
- }
9752
- return result;
9753
- }
9754
-
9755
- module.exports = initCloneArray;
9756
-
9757
- },{}],185:[function(require,module,exports){
9758
- (function (global){
9759
- var bufferClone = require('./bufferClone');
9760
-
9761
- /** `Object#toString` result references. */
9762
- var boolTag = '[object Boolean]',
9763
- dateTag = '[object Date]',
9764
- numberTag = '[object Number]',
9765
- regexpTag = '[object RegExp]',
9766
- stringTag = '[object String]';
9767
-
9768
- var arrayBufferTag = '[object ArrayBuffer]',
9769
- float32Tag = '[object Float32Array]',
9770
- float64Tag = '[object Float64Array]',
9771
- int8Tag = '[object Int8Array]',
9772
- int16Tag = '[object Int16Array]',
9773
- int32Tag = '[object Int32Array]',
9774
- uint8Tag = '[object Uint8Array]',
9775
- uint8ClampedTag = '[object Uint8ClampedArray]',
9776
- uint16Tag = '[object Uint16Array]',
9777
- uint32Tag = '[object Uint32Array]';
9778
-
9779
- /** Used to match `RegExp` flags from their coerced string values. */
9780
- var reFlags = /\w*$/;
9781
-
9782
- /** Native method references. */
9783
- var Uint8Array = global.Uint8Array;
9784
-
9785
- /** Used to lookup a type array constructors by `toStringTag`. */
9786
- var ctorByTag = {};
9787
- ctorByTag[float32Tag] = global.Float32Array;
9788
- ctorByTag[float64Tag] = global.Float64Array;
9789
- ctorByTag[int8Tag] = global.Int8Array;
9790
- ctorByTag[int16Tag] = global.Int16Array;
9791
- ctorByTag[int32Tag] = global.Int32Array;
9792
- ctorByTag[uint8Tag] = Uint8Array;
9793
- ctorByTag[uint8ClampedTag] = global.Uint8ClampedArray;
9794
- ctorByTag[uint16Tag] = global.Uint16Array;
9795
- ctorByTag[uint32Tag] = global.Uint32Array;
9796
-
9797
- /**
9798
- * Initializes an object clone based on its `toStringTag`.
9799
- *
9800
- * **Note:** This function only supports cloning values with tags of
9801
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
9802
- *
9803
- * @private
9804
- * @param {Object} object The object to clone.
9805
- * @param {string} tag The `toStringTag` of the object to clone.
9806
- * @param {boolean} [isDeep] Specify a deep clone.
9807
- * @returns {Object} Returns the initialized clone.
9808
- */
9809
- function initCloneByTag(object, tag, isDeep) {
9810
- var Ctor = object.constructor;
9811
- switch (tag) {
9812
- case arrayBufferTag:
9813
- return bufferClone(object);
9814
-
9815
- case boolTag:
9816
- case dateTag:
9817
- return new Ctor(+object);
9818
-
9819
- case float32Tag: case float64Tag:
9820
- case int8Tag: case int16Tag: case int32Tag:
9821
- case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
9822
- // Safari 5 mobile incorrectly has `Object` as the constructor of typed arrays.
9823
- if (Ctor instanceof Ctor) {
9824
- Ctor = ctorByTag[tag];
9825
- }
9826
- var buffer = object.buffer;
9827
- return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
9828
-
9829
- case numberTag:
9830
- case stringTag:
9831
- return new Ctor(object);
9832
-
9833
- case regexpTag:
9834
- var result = new Ctor(object.source, reFlags.exec(object));
9835
- result.lastIndex = object.lastIndex;
9836
- }
9837
- return result;
9838
- }
9839
-
9840
- module.exports = initCloneByTag;
9841
-
9842
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
9843
- },{"./bufferClone":177}],186:[function(require,module,exports){
9844
- /**
9845
- * Initializes an object clone.
9846
- *
9847
- * @private
9848
- * @param {Object} object The object to clone.
9849
- * @returns {Object} Returns the initialized clone.
9850
- */
9851
- function initCloneObject(object) {
9852
- var Ctor = object.constructor;
9853
- if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
9854
- Ctor = Object;
9855
- }
9856
- return new Ctor;
9857
- }
9858
-
9859
- module.exports = initCloneObject;
9860
-
9861
- },{}],187:[function(require,module,exports){
9862
- arguments[4][102][0].apply(exports,arguments)
9863
- },{"./getLength":182,"./isLength":191,"dup":102}],188:[function(require,module,exports){
9864
- /**
9865
- * Checks if `value` is a host object in IE < 9.
9866
- *
9867
- * @private
9868
- * @param {*} value The value to check.
9869
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
9870
- */
9871
- var isHostObject = (function() {
9872
- try {
9873
- Object({ 'toString': 0 } + '');
9874
- } catch(e) {
9875
- return function() { return false; };
9876
- }
9877
- return function(value) {
9878
- // IE < 9 presents many host objects as `Object` objects that can coerce
9879
- // to strings despite having improperly defined `toString` methods.
9880
- return typeof value.toString != 'function' && typeof (value + '') == 'string';
9881
- };
9882
- }());
9883
-
9884
- module.exports = isHostObject;
9885
-
9886
- },{}],189:[function(require,module,exports){
9887
- arguments[4][103][0].apply(exports,arguments)
9888
- },{"dup":103}],190:[function(require,module,exports){
9889
- arguments[4][104][0].apply(exports,arguments)
9890
- },{"../lang/isObject":201,"./isArrayLike":187,"./isIndex":189,"dup":104}],191:[function(require,module,exports){
9891
- arguments[4][107][0].apply(exports,arguments)
9892
- },{"dup":107}],192:[function(require,module,exports){
9893
- arguments[4][108][0].apply(exports,arguments)
9894
- },{"dup":108}],193:[function(require,module,exports){
9895
- var isArguments = require('../lang/isArguments'),
9896
- isArray = require('../lang/isArray'),
9897
- isIndex = require('./isIndex'),
9898
- isLength = require('./isLength'),
9899
- isString = require('../lang/isString'),
9900
- keysIn = require('../object/keysIn');
9901
-
9902
- /** Used for native method references. */
9903
- var objectProto = Object.prototype;
9904
-
9905
- /** Used to check objects for own properties. */
9906
- var hasOwnProperty = objectProto.hasOwnProperty;
9907
-
9908
- /**
9909
- * A fallback implementation of `Object.keys` which creates an array of the
9910
- * own enumerable property names of `object`.
9911
- *
9912
- * @private
9913
- * @param {Object} object The object to query.
9914
- * @returns {Array} Returns the array of property names.
9915
- */
9916
- function shimKeys(object) {
9917
- var props = keysIn(object),
9918
- propsLength = props.length,
9919
- length = propsLength && object.length;
9920
-
9921
- var allowIndexes = !!length && isLength(length) &&
9922
- (isArray(object) || isArguments(object) || isString(object));
9923
-
9924
- var index = -1,
9925
- result = [];
9926
-
9927
- while (++index < propsLength) {
9928
- var key = props[index];
9929
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
9930
- result.push(key);
9931
- }
9932
- }
9933
- return result;
9934
- }
9935
-
9936
- module.exports = shimKeys;
9937
-
9938
- },{"../lang/isArguments":197,"../lang/isArray":198,"../lang/isString":203,"../object/keysIn":207,"./isIndex":189,"./isLength":191}],194:[function(require,module,exports){
9939
- var isObject = require('../lang/isObject'),
9940
- isString = require('../lang/isString'),
9941
- support = require('../support');
9942
-
9943
- /**
9944
- * Converts `value` to an object if it's not one.
9945
- *
9946
- * @private
9947
- * @param {*} value The value to process.
9948
- * @returns {Object} Returns the object.
9949
- */
9950
- function toObject(value) {
9951
- if (support.unindexedChars && isString(value)) {
9952
- var index = -1,
9953
- length = value.length,
9954
- result = Object(value);
9955
-
9956
- while (++index < length) {
9957
- result[index] = value.charAt(index);
9958
- }
9959
- return result;
9960
- }
9961
- return isObject(value) ? value : Object(value);
9962
- }
9963
-
9964
- module.exports = toObject;
9965
-
9966
- },{"../lang/isObject":201,"../lang/isString":203,"../support":209}],195:[function(require,module,exports){
9967
- var baseClone = require('../internal/baseClone'),
9968
- bindCallback = require('../internal/bindCallback'),
9969
- isIterateeCall = require('../internal/isIterateeCall');
9970
-
9971
- /**
9972
- * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,
9973
- * otherwise they are assigned by reference. If `customizer` is provided it is
9974
- * invoked to produce the cloned values. If `customizer` returns `undefined`
9975
- * cloning is handled by the method instead. The `customizer` is bound to
9976
- * `thisArg` and invoked with two argument; (value [, index|key, object]).
9977
- *
9978
- * **Note:** This method is loosely based on the
9979
- * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
9980
- * The enumerable properties of `arguments` objects and objects created by
9981
- * constructors other than `Object` are cloned to plain `Object` objects. An
9982
- * empty object is returned for uncloneable values such as functions, DOM nodes,
9983
- * Maps, Sets, and WeakMaps.
9984
- *
9985
- * @static
9986
- * @memberOf _
9987
- * @category Lang
9988
- * @param {*} value The value to clone.
9989
- * @param {boolean} [isDeep] Specify a deep clone.
9990
- * @param {Function} [customizer] The function to customize cloning values.
9991
- * @param {*} [thisArg] The `this` binding of `customizer`.
9992
- * @returns {*} Returns the cloned value.
9993
- * @example
9994
- *
9995
- * var users = [
9996
- * { 'user': 'barney' },
9997
- * { 'user': 'fred' }
9998
- * ];
9999
- *
10000
- * var shallow = _.clone(users);
10001
- * shallow[0] === users[0];
10002
- * // => true
10003
- *
10004
- * var deep = _.clone(users, true);
10005
- * deep[0] === users[0];
10006
- * // => false
10007
- *
10008
- * // using a customizer callback
10009
- * var el = _.clone(document.body, function(value) {
10010
- * if (_.isElement(value)) {
10011
- * return value.cloneNode(false);
10012
- * }
10013
- * });
10014
- *
10015
- * el === document.body
10016
- * // => false
10017
- * el.nodeName
10018
- * // => BODY
10019
- * el.childNodes.length;
10020
- * // => 0
10021
- */
10022
- function clone(value, isDeep, customizer, thisArg) {
10023
- if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
10024
- isDeep = false;
10025
- }
10026
- else if (typeof isDeep == 'function') {
10027
- thisArg = customizer;
10028
- customizer = isDeep;
10029
- isDeep = false;
10030
- }
10031
- return typeof customizer == 'function'
10032
- ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))
10033
- : baseClone(value, isDeep);
10034
- }
10035
-
10036
- module.exports = clone;
10037
-
10038
- },{"../internal/baseClone":167,"../internal/bindCallback":176,"../internal/isIterateeCall":190}],196:[function(require,module,exports){
10039
- var baseClone = require('../internal/baseClone'),
10040
- bindCallback = require('../internal/bindCallback');
10041
-
10042
- /**
10043
- * Creates a deep clone of `value`. If `customizer` is provided it is invoked
10044
- * to produce the cloned values. If `customizer` returns `undefined` cloning
10045
- * is handled by the method instead. The `customizer` is bound to `thisArg`
10046
- * and invoked with two argument; (value [, index|key, object]).
10047
- *
10048
- * **Note:** This method is loosely based on the
10049
- * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
10050
- * The enumerable properties of `arguments` objects and objects created by
10051
- * constructors other than `Object` are cloned to plain `Object` objects. An
10052
- * empty object is returned for uncloneable values such as functions, DOM nodes,
10053
- * Maps, Sets, and WeakMaps.
10054
- *
10055
- * @static
10056
- * @memberOf _
10057
- * @category Lang
10058
- * @param {*} value The value to deep clone.
10059
- * @param {Function} [customizer] The function to customize cloning values.
10060
- * @param {*} [thisArg] The `this` binding of `customizer`.
10061
- * @returns {*} Returns the deep cloned value.
10062
- * @example
10063
- *
10064
- * var users = [
10065
- * { 'user': 'barney' },
10066
- * { 'user': 'fred' }
10067
- * ];
10068
- *
10069
- * var deep = _.cloneDeep(users);
10070
- * deep[0] === users[0];
10071
- * // => false
10072
- *
10073
- * // using a customizer callback
10074
- * var el = _.cloneDeep(document.body, function(value) {
10075
- * if (_.isElement(value)) {
10076
- * return value.cloneNode(true);
10077
- * }
10078
- * });
10079
- *
10080
- * el === document.body
10081
- * // => false
10082
- * el.nodeName
10083
- * // => BODY
10084
- * el.childNodes.length;
10085
- * // => 20
10086
- */
10087
- function cloneDeep(value, customizer, thisArg) {
10088
- return typeof customizer == 'function'
10089
- ? baseClone(value, true, bindCallback(customizer, thisArg, 1))
10090
- : baseClone(value, true);
10091
- }
10092
-
10093
- module.exports = cloneDeep;
10094
-
10095
- },{"../internal/baseClone":167,"../internal/bindCallback":176}],197:[function(require,module,exports){
10096
- arguments[4][126][0].apply(exports,arguments)
10097
- },{"../internal/isArrayLike":187,"../internal/isObjectLike":192,"dup":126}],198:[function(require,module,exports){
10098
- arguments[4][127][0].apply(exports,arguments)
10099
- },{"../internal/getNative":183,"../internal/isLength":191,"../internal/isObjectLike":192,"dup":127}],199:[function(require,module,exports){
10100
- arguments[4][129][0].apply(exports,arguments)
10101
- },{"./isObject":201,"dup":129}],200:[function(require,module,exports){
10102
- var isFunction = require('./isFunction'),
10103
- isHostObject = require('../internal/isHostObject'),
10104
- isObjectLike = require('../internal/isObjectLike');
10105
-
10106
- /** Used to detect host constructors (Safari > 5). */
10107
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
10108
-
10109
- /** Used for native method references. */
10110
- var objectProto = Object.prototype;
10111
-
10112
- /** Used to resolve the decompiled source of functions. */
10113
- var fnToString = Function.prototype.toString;
10114
-
10115
- /** Used to check objects for own properties. */
10116
- var hasOwnProperty = objectProto.hasOwnProperty;
10117
-
10118
- /** Used to detect if a method is native. */
10119
- var reIsNative = RegExp('^' +
10120
- fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
10121
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
10122
- );
10123
-
10124
- /**
10125
- * Checks if `value` is a native function.
10126
- *
10127
- * @static
10128
- * @memberOf _
10129
- * @category Lang
10130
- * @param {*} value The value to check.
10131
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
10132
- * @example
10133
- *
10134
- * _.isNative(Array.prototype.push);
10135
- * // => true
10136
- *
10137
- * _.isNative(_);
10138
- * // => false
10139
- */
10140
- function isNative(value) {
10141
- if (value == null) {
10142
- return false;
10143
- }
10144
- if (isFunction(value)) {
10145
- return reIsNative.test(fnToString.call(value));
10146
- }
10147
- return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value);
10148
- }
10149
-
10150
- module.exports = isNative;
10151
-
10152
- },{"../internal/isHostObject":188,"../internal/isObjectLike":192,"./isFunction":199}],201:[function(require,module,exports){
10153
- arguments[4][131][0].apply(exports,arguments)
10154
- },{"dup":131}],202:[function(require,module,exports){
10155
- var baseForIn = require('../internal/baseForIn'),
10156
- isArguments = require('./isArguments'),
10157
- isHostObject = require('../internal/isHostObject'),
10158
- isObjectLike = require('../internal/isObjectLike'),
10159
- support = require('../support');
10160
-
10161
- /** `Object#toString` result references. */
10162
- var objectTag = '[object Object]';
10163
-
10164
- /** Used for native method references. */
10165
- var objectProto = Object.prototype;
10166
-
10167
- /** Used to check objects for own properties. */
10168
- var hasOwnProperty = objectProto.hasOwnProperty;
10169
-
10170
- /**
10171
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
10172
- * of values.
10173
- */
10174
- var objToString = objectProto.toString;
10175
-
10176
- /**
10177
- * Checks if `value` is a plain object, that is, an object created by the
10178
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
10179
- *
10180
- * **Note:** This method assumes objects created by the `Object` constructor
10181
- * have no inherited enumerable properties.
10182
- *
10183
- * @static
10184
- * @memberOf _
10185
- * @category Lang
10186
- * @param {*} value The value to check.
10187
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
10188
- * @example
10189
- *
10190
- * function Foo() {
10191
- * this.a = 1;
10192
- * }
10193
- *
10194
- * _.isPlainObject(new Foo);
10195
- * // => false
10196
- *
10197
- * _.isPlainObject([1, 2, 3]);
10198
- * // => false
10199
- *
10200
- * _.isPlainObject({ 'x': 0, 'y': 0 });
10201
- * // => true
10202
- *
10203
- * _.isPlainObject(Object.create(null));
10204
- * // => true
10205
- */
10206
- function isPlainObject(value) {
10207
- var Ctor;
10208
-
10209
- // Exit early for non `Object` objects.
10210
- if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
10211
- (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
10212
- return false;
10213
- }
10214
- // IE < 9 iterates inherited properties before own properties. If the first
10215
- // iterated property is an object's own property then there are no inherited
10216
- // enumerable properties.
10217
- var result;
10218
- if (support.ownLast) {
10219
- baseForIn(value, function(subValue, key, object) {
10220
- result = hasOwnProperty.call(object, key);
10221
- return false;
10222
- });
10223
- return result !== false;
10224
- }
10225
- // In most environments an object's own properties are iterated before
10226
- // its inherited properties. If the last iterated property is an object's
10227
- // own property then there are no inherited enumerable properties.
10228
- baseForIn(value, function(subValue, key) {
10229
- result = key;
10230
- });
10231
- return result === undefined || hasOwnProperty.call(value, result);
10232
- }
10233
-
10234
- module.exports = isPlainObject;
10235
-
10236
- },{"../internal/baseForIn":171,"../internal/isHostObject":188,"../internal/isObjectLike":192,"../support":209,"./isArguments":197}],203:[function(require,module,exports){
10237
- arguments[4][133][0].apply(exports,arguments)
10238
- },{"../internal/isObjectLike":192,"dup":133}],204:[function(require,module,exports){
10239
- arguments[4][134][0].apply(exports,arguments)
10240
- },{"../internal/isLength":191,"../internal/isObjectLike":192,"dup":134}],205:[function(require,module,exports){
10241
- arguments[4][136][0].apply(exports,arguments)
10242
- },{"../internal/baseCopy":168,"../object/keysIn":207,"dup":136}],206:[function(require,module,exports){
10243
- var getNative = require('../internal/getNative'),
10244
- isArrayLike = require('../internal/isArrayLike'),
10245
- isObject = require('../lang/isObject'),
10246
- shimKeys = require('../internal/shimKeys'),
10247
- support = require('../support');
10248
-
10249
- /* Native method references for those with the same name as other `lodash` methods. */
10250
- var nativeKeys = getNative(Object, 'keys');
10251
-
10252
- /**
10253
- * Creates an array of the own enumerable property names of `object`.
10254
- *
10255
- * **Note:** Non-object values are coerced to objects. See the
10256
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
10257
- * for more details.
10258
- *
10259
- * @static
10260
- * @memberOf _
10261
- * @category Object
10262
- * @param {Object} object The object to query.
10263
- * @returns {Array} Returns the array of property names.
10264
- * @example
10265
- *
10266
- * function Foo() {
10267
- * this.a = 1;
10268
- * this.b = 2;
10269
- * }
10270
- *
10271
- * Foo.prototype.c = 3;
10272
- *
10273
- * _.keys(new Foo);
10274
- * // => ['a', 'b'] (iteration order is not guaranteed)
10275
- *
10276
- * _.keys('hi');
10277
- * // => ['0', '1']
10278
- */
10279
- var keys = !nativeKeys ? shimKeys : function(object) {
10280
- var Ctor = object == null ? undefined : object.constructor;
10281
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
10282
- (typeof object == 'function' ? support.enumPrototypes : isArrayLike(object))) {
10283
- return shimKeys(object);
10284
- }
10285
- return isObject(object) ? nativeKeys(object) : [];
10286
- };
10287
-
10288
- module.exports = keys;
10289
-
10290
- },{"../internal/getNative":183,"../internal/isArrayLike":187,"../internal/shimKeys":193,"../lang/isObject":201,"../support":209}],207:[function(require,module,exports){
10291
- var arrayEach = require('../internal/arrayEach'),
10292
- isArguments = require('../lang/isArguments'),
10293
- isArray = require('../lang/isArray'),
10294
- isFunction = require('../lang/isFunction'),
10295
- isIndex = require('../internal/isIndex'),
10296
- isLength = require('../internal/isLength'),
10297
- isObject = require('../lang/isObject'),
10298
- isString = require('../lang/isString'),
10299
- support = require('../support');
10300
-
10301
- /** `Object#toString` result references. */
10302
- var arrayTag = '[object Array]',
10303
- boolTag = '[object Boolean]',
10304
- dateTag = '[object Date]',
10305
- errorTag = '[object Error]',
10306
- funcTag = '[object Function]',
10307
- numberTag = '[object Number]',
10308
- objectTag = '[object Object]',
10309
- regexpTag = '[object RegExp]',
10310
- stringTag = '[object String]';
10311
-
10312
- /** Used to fix the JScript `[[DontEnum]]` bug. */
10313
- var shadowProps = [
10314
- 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable',
10315
- 'toLocaleString', 'toString', 'valueOf'
10316
- ];
10317
-
10318
- /** Used for native method references. */
10319
- var errorProto = Error.prototype,
10320
- objectProto = Object.prototype,
10321
- stringProto = String.prototype;
10322
-
10323
- /** Used to check objects for own properties. */
10324
- var hasOwnProperty = objectProto.hasOwnProperty;
10325
-
10326
- /**
10327
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
10328
- * of values.
10329
- */
10330
- var objToString = objectProto.toString;
10331
-
10332
- /** Used to avoid iterating over non-enumerable properties in IE < 9. */
10333
- var nonEnumProps = {};
10334
- nonEnumProps[arrayTag] = nonEnumProps[dateTag] = nonEnumProps[numberTag] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };
10335
- nonEnumProps[boolTag] = nonEnumProps[stringTag] = { 'constructor': true, 'toString': true, 'valueOf': true };
10336
- nonEnumProps[errorTag] = nonEnumProps[funcTag] = nonEnumProps[regexpTag] = { 'constructor': true, 'toString': true };
10337
- nonEnumProps[objectTag] = { 'constructor': true };
10338
-
10339
- arrayEach(shadowProps, function(key) {
10340
- for (var tag in nonEnumProps) {
10341
- if (hasOwnProperty.call(nonEnumProps, tag)) {
10342
- var props = nonEnumProps[tag];
10343
- props[key] = hasOwnProperty.call(props, key);
10344
- }
10345
- }
10346
- });
10347
-
10348
- /**
10349
- * Creates an array of the own and inherited enumerable property names of `object`.
10350
- *
10351
- * **Note:** Non-object values are coerced to objects.
10352
- *
10353
- * @static
10354
- * @memberOf _
10355
- * @category Object
10356
- * @param {Object} object The object to query.
10357
- * @returns {Array} Returns the array of property names.
10358
- * @example
10359
- *
10360
- * function Foo() {
10361
- * this.a = 1;
10362
- * this.b = 2;
10363
- * }
10364
- *
10365
- * Foo.prototype.c = 3;
10366
- *
10367
- * _.keysIn(new Foo);
10368
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
10369
- */
10370
- function keysIn(object) {
10371
- if (object == null) {
10372
- return [];
10373
- }
10374
- if (!isObject(object)) {
10375
- object = Object(object);
10376
- }
10377
- var length = object.length;
10378
-
10379
- length = (length && isLength(length) &&
10380
- (isArray(object) || isArguments(object) || isString(object)) && length) || 0;
10381
-
10382
- var Ctor = object.constructor,
10383
- index = -1,
10384
- proto = (isFunction(Ctor) && Ctor.prototype) || objectProto,
10385
- isProto = proto === object,
10386
- result = Array(length),
10387
- skipIndexes = length > 0,
10388
- skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error),
10389
- skipProto = support.enumPrototypes && isFunction(object);
10390
-
10391
- while (++index < length) {
10392
- result[index] = (index + '');
10393
- }
10394
- // lodash skips the `constructor` property when it infers it is iterating
10395
- // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]`
10396
- // attribute of an existing property and the `constructor` property of a
10397
- // prototype defaults to non-enumerable.
10398
- for (var key in object) {
10399
- if (!(skipProto && key == 'prototype') &&
10400
- !(skipErrorProps && (key == 'message' || key == 'name')) &&
10401
- !(skipIndexes && isIndex(key, length)) &&
10402
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
10403
- result.push(key);
10404
- }
10405
- }
10406
- if (support.nonEnumShadows && object !== objectProto) {
10407
- var tag = object === stringProto ? stringTag : (object === errorProto ? errorTag : objToString.call(object)),
10408
- nonEnums = nonEnumProps[tag] || nonEnumProps[objectTag];
10409
-
10410
- if (tag == objectTag) {
10411
- proto = objectProto;
10412
- }
10413
- length = shadowProps.length;
10414
- while (length--) {
10415
- key = shadowProps[length];
10416
- var nonEnum = nonEnums[key];
10417
- if (!(isProto && nonEnum) &&
10418
- (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) {
10419
- result.push(key);
10420
- }
10421
- }
10422
- }
10423
- return result;
10424
- }
10425
-
10426
- module.exports = keysIn;
10427
-
10428
- },{"../internal/arrayEach":165,"../internal/isIndex":189,"../internal/isLength":191,"../lang/isArguments":197,"../lang/isArray":198,"../lang/isFunction":199,"../lang/isObject":201,"../lang/isString":203,"../support":209}],208:[function(require,module,exports){
10429
- arguments[4][142][0].apply(exports,arguments)
10430
- },{"../internal/baseMerge":173,"../internal/createAssigner":178,"dup":142}],209:[function(require,module,exports){
10431
- /** Used for native method references. */
10432
- var arrayProto = Array.prototype,
10433
- errorProto = Error.prototype,
10434
- objectProto = Object.prototype;
10435
-
10436
- /** Native method references. */
10437
- var propertyIsEnumerable = objectProto.propertyIsEnumerable,
10438
- splice = arrayProto.splice;
10439
-
10440
- /**
10441
- * An object environment feature flags.
10442
- *
10443
- * @static
10444
- * @memberOf _
10445
- * @type Object
10446
- */
10447
- var support = {};
10448
-
10449
- (function(x) {
10450
- var Ctor = function() { this.x = x; },
10451
- object = { '0': x, 'length': x },
10452
- props = [];
10453
-
10454
- Ctor.prototype = { 'valueOf': x, 'y': x };
10455
- for (var key in new Ctor) { props.push(key); }
10456
-
10457
- /**
10458
- * Detect if `name` or `message` properties of `Error.prototype` are
10459
- * enumerable by default (IE < 9, Safari < 5.1).
10460
- *
10461
- * @memberOf _.support
10462
- * @type boolean
10463
- */
10464
- support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') ||
10465
- propertyIsEnumerable.call(errorProto, 'name');
10466
-
10467
- /**
10468
- * Detect if `prototype` properties are enumerable by default.
10469
- *
10470
- * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1
10471
- * (if the prototype or a property on the prototype has been set)
10472
- * incorrectly set the `[[Enumerable]]` value of a function's `prototype`
10473
- * property to `true`.
10474
- *
10475
- * @memberOf _.support
10476
- * @type boolean
10477
- */
10478
- support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
10479
-
10480
- /**
10481
- * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
10482
- *
10483
- * In IE < 9 an object's own properties, shadowing non-enumerable ones,
10484
- * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug).
10485
- *
10486
- * @memberOf _.support
10487
- * @type boolean
10488
- */
10489
- support.nonEnumShadows = !/valueOf/.test(props);
10490
-
10491
- /**
10492
- * Detect if own properties are iterated after inherited properties (IE < 9).
10493
- *
10494
- * @memberOf _.support
10495
- * @type boolean
10496
- */
10497
- support.ownLast = props[0] != 'x';
10498
-
10499
- /**
10500
- * Detect if `Array#shift` and `Array#splice` augment array-like objects
10501
- * correctly.
10502
- *
10503
- * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array
10504
- * `shift()` and `splice()` functions that fail to remove the last element,
10505
- * `value[0]`, of array-like objects even though the "length" property is
10506
- * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8,
10507
- * while `splice()` is buggy regardless of mode in IE < 9.
10508
- *
10509
- * @memberOf _.support
10510
- * @type boolean
10511
- */
10512
- support.spliceObjects = (splice.call(object, 0, 1), !object[0]);
10513
-
10514
- /**
10515
- * Detect lack of support for accessing string characters by index.
10516
- *
10517
- * IE < 8 can't access characters by index. IE 8 can only access characters
10518
- * by index on string literals, not string objects.
10519
- *
10520
- * @memberOf _.support
10521
- * @type boolean
10522
- */
10523
- support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx';
10524
- }(1, 0));
10525
-
10526
- module.exports = support;
10527
-
10528
- },{}],210:[function(require,module,exports){
10529
- arguments[4][148][0].apply(exports,arguments)
10530
- },{"dup":148}],211:[function(require,module,exports){
10531
- (function (process){
10532
- 'use strict';
10533
-
10534
- module.exports = AlgoliaSearch;
10535
-
10536
- // default debug activated in dev environments
10537
- // this is triggered in package.json, using the envify transform
10538
- if (process.env.APP_ENV === 'development') {
10539
- require('debug').enable('algoliasearch*');
10540
- }
10541
-
10542
- var errors = require('./errors');
10543
-
10544
- /*
10545
- * Algolia Search library initialization
10546
- * https://www.algolia.com/
10547
- *
10548
- * @param {string} applicationID - Your applicationID, found in your dashboard
10549
- * @param {string} apiKey - Your API key, found in your dashboard
10550
- * @param {Object} [opts]
10551
- * @param {number} [opts.timeout=2000] - The request timeout set in milliseconds,
10552
- * another request will be issued after this timeout
10553
- * @param {string} [opts.protocol='http:'] - The protocol used to query Algolia Search API.
10554
- * Set to 'https:' to force using https.
10555
- * Default to document.location.protocol in browsers
10556
- * @param {Object|Array} [opts.hosts={
10557
- * read: [this.applicationID + '-dsn.algolia.net'].concat([
10558
- * this.applicationID + '-1.algolianet.com',
10559
- * this.applicationID + '-2.algolianet.com',
10560
- * this.applicationID + '-3.algolianet.com']
10561
- * ]),
10562
- * write: [this.applicationID + '.algolia.net'].concat([
10563
- * this.applicationID + '-1.algolianet.com',
10564
- * this.applicationID + '-2.algolianet.com',
10565
- * this.applicationID + '-3.algolianet.com']
10566
- * ]) - The hosts to use for Algolia Search API.
10567
- * If you provide them, you will less benefit from our HA implementation
10568
- */
10569
- function AlgoliaSearch(applicationID, apiKey, opts) {
10570
- var debug = require('debug')('algoliasearch');
10571
-
10572
- var clone = require('lodash-compat/lang/clone');
10573
- var isArray = require('lodash-compat/lang/isArray');
10574
-
10575
- var usage = 'Usage: algoliasearch(applicationID, apiKey, opts)';
10576
-
10577
- if (!applicationID) {
10578
- throw new errors.AlgoliaSearchError('Please provide an application ID. ' + usage);
10579
- }
10580
-
10581
- if (!apiKey) {
10582
- throw new errors.AlgoliaSearchError('Please provide an API key. ' + usage);
10583
- }
10584
-
10585
- this.applicationID = applicationID;
10586
- this.apiKey = apiKey;
10587
-
10588
- var defaultHosts = [
10589
- this.applicationID + '-1.algolianet.com',
10590
- this.applicationID + '-2.algolianet.com',
10591
- this.applicationID + '-3.algolianet.com'
10592
- ];
10593
- this.hosts = {
10594
- read: [],
10595
- write: []
10596
- };
10597
-
10598
- this.hostIndex = {
10599
- read: 0,
10600
- write: 0
10601
- };
10602
-
10603
- opts = opts || {};
10604
-
10605
- var protocol = opts.protocol || 'https:';
10606
- var timeout = opts.timeout === undefined ? 2000 : opts.timeout;
10607
-
10608
- // while we advocate for colon-at-the-end values: 'http:' for `opts.protocol`
10609
- // we also accept `http` and `https`. It's a common error.
10610
- if (!/:$/.test(protocol)) {
10611
- protocol = protocol + ':';
10612
- }
10613
-
10614
- if (opts.protocol !== 'http:' && opts.protocol !== 'https:') {
10615
- throw new errors.AlgoliaSearchError('protocol must be `http:` or `https:` (was `' + opts.protocol + '`)');
10616
- }
10617
-
10618
- // no hosts given, add defaults
10619
- if (!opts.hosts) {
10620
- this.hosts.read = [this.applicationID + '-dsn.algolia.net'].concat(defaultHosts);
10621
- this.hosts.write = [this.applicationID + '.algolia.net'].concat(defaultHosts);
10622
- } else if (isArray(opts.hosts)) {
10623
- this.hosts.read = clone(opts.hosts);
10624
- this.hosts.write = clone(opts.hosts);
10625
- } else {
10626
- this.hosts.read = clone(opts.hosts.read);
10627
- this.hosts.write = clone(opts.hosts.write);
10628
- }
10629
-
10630
- // add protocol and lowercase hosts
10631
- this.hosts.read = map(this.hosts.read, prepareHost(protocol));
10632
- this.hosts.write = map(this.hosts.write, prepareHost(protocol));
10633
- this.requestTimeout = timeout;
10634
-
10635
- this.extraHeaders = [];
10636
- this.cache = {};
10637
-
10638
- this._ua = opts._ua;
10639
- this._useCache = opts._useCache === undefined ? true : opts._useCache;
10640
-
10641
- this._setTimeout = opts._setTimeout;
10642
-
10643
- debug('init done, %j', this);
10644
- }
10645
-
10646
- AlgoliaSearch.prototype = {
10647
- /*
10648
- * Delete an index
10649
- *
10650
- * @param indexName the name of index to delete
10651
- * @param callback the result callback called with two arguments
10652
- * error: null or Error('message')
10653
- * content: the server answer that contains the task ID
10654
- */
10655
- deleteIndex: function(indexName, callback) {
10656
- return this._jsonRequest({
10657
- method: 'DELETE',
10658
- url: '/1/indexes/' + encodeURIComponent(indexName),
10659
- hostType: 'write',
10660
- callback: callback
10661
- });
10662
- },
10663
- /**
10664
- * Move an existing index.
10665
- * @param srcIndexName the name of index to copy.
10666
- * @param dstIndexName the new index name that will contains a copy of
10667
- * srcIndexName (destination will be overriten if it already exist).
10668
- * @param callback the result callback called with two arguments
10669
- * error: null or Error('message')
10670
- * content: the server answer that contains the task ID
10671
- */
10672
- moveIndex: function(srcIndexName, dstIndexName, callback) {
10673
- var postObj = {
10674
- operation: 'move', destination: dstIndexName
10675
- };
10676
- return this._jsonRequest({
10677
- method: 'POST',
10678
- url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation',
10679
- body: postObj,
10680
- hostType: 'write',
10681
- callback: callback
10682
- });
10683
- },
10684
- /**
10685
- * Copy an existing index.
10686
- * @param srcIndexName the name of index to copy.
10687
- * @param dstIndexName the new index name that will contains a copy
10688
- * of srcIndexName (destination will be overriten if it already exist).
10689
- * @param callback the result callback called with two arguments
10690
- * error: null or Error('message')
10691
- * content: the server answer that contains the task ID
10692
- */
10693
- copyIndex: function(srcIndexName, dstIndexName, callback) {
10694
- var postObj = {
10695
- operation: 'copy', destination: dstIndexName
10696
- };
10697
- return this._jsonRequest({
10698
- method: 'POST',
10699
- url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation',
10700
- body: postObj,
10701
- hostType: 'write',
10702
- callback: callback
10703
- });
10704
- },
10705
- /**
10706
- * Return last log entries.
10707
- * @param offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
10708
- * @param length Specify the maximum number of entries to retrieve starting
10709
- * at offset. Maximum allowed value: 1000.
10710
- * @param callback the result callback called with two arguments
10711
- * error: null or Error('message')
10712
- * content: the server answer that contains the task ID
10713
- */
10714
- getLogs: function(offset, length, callback) {
10715
- if (arguments.length === 0 || typeof offset === 'function') {
10716
- // getLogs([cb])
10717
- callback = offset;
10718
- offset = 0;
10719
- length = 10;
10720
- } else if (arguments.length === 1 || typeof length === 'function') {
10721
- // getLogs(1, [cb)]
10722
- callback = length;
10723
- length = 10;
10724
- }
10725
-
10726
- return this._jsonRequest({
10727
- method: 'GET',
10728
- url: '/1/logs?offset=' + offset + '&length=' + length,
10729
- hostType: 'read',
10730
- callback: callback
10731
- });
10732
- },
10733
- /*
10734
- * List all existing indexes (paginated)
10735
- *
10736
- * @param page The page to retrieve, starting at 0.
10737
- * @param callback the result callback called with two arguments
10738
- * error: null or Error('message')
10739
- * content: the server answer with index list
10740
- */
10741
- listIndexes: function(page, callback) {
10742
- var params = '';
10743
-
10744
- if (page === undefined || typeof page === 'function') {
10745
- callback = page;
10746
- } else {
10747
- params = '?page=' + page;
10748
- }
10749
-
10750
- return this._jsonRequest({
10751
- method: 'GET',
10752
- url: '/1/indexes' + params,
10753
- hostType: 'read',
10754
- callback: callback
10755
- });
10756
- },
10757
-
10758
- /*
10759
- * Get the index object initialized
10760
- *
10761
- * @param indexName the name of index
10762
- * @param callback the result callback with one argument (the Index instance)
10763
- */
10764
- initIndex: function(indexName) {
10765
- return new this.Index(this, indexName);
10766
- },
10767
- /*
10768
- * List all existing user keys with their associated ACLs
10769
- *
10770
- * @param callback the result callback called with two arguments
10771
- * error: null or Error('message')
10772
- * content: the server answer with user keys list
10773
- */
10774
- listUserKeys: function(callback) {
10775
- return this._jsonRequest({
10776
- method: 'GET',
10777
- url: '/1/keys',
10778
- hostType: 'read',
10779
- callback: callback
10780
- });
10781
- },
10782
- /*
10783
- * Get ACL of a user key
10784
- *
10785
- * @param key
10786
- * @param callback the result callback called with two arguments
10787
- * error: null or Error('message')
10788
- * content: the server answer with user keys list
10789
- */
10790
- getUserKeyACL: function(key, callback) {
10791
- return this._jsonRequest({
10792
- method: 'GET',
10793
- url: '/1/keys/' + key,
10794
- hostType: 'read',
10795
- callback: callback
10796
- });
10797
- },
10798
- /*
10799
- * Delete an existing user key
10800
- * @param key
10801
- * @param callback the result callback called with two arguments
10802
- * error: null or Error('message')
10803
- * content: the server answer with user keys list
10804
- */
10805
- deleteUserKey: function(key, callback) {
10806
- return this._jsonRequest({
10807
- method: 'DELETE',
10808
- url: '/1/keys/' + key,
10809
- hostType: 'write',
10810
- callback: callback
10811
- });
10812
- },
10813
- /*
10814
- * Add a new global API key
10815
- *
10816
- * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that
10817
- * can contains the following values:
10818
- * - search: allow to search (https and http)
10819
- * - addObject: allows to add/update an object in the index (https only)
10820
- * - deleteObject : allows to delete an existing object (https only)
10821
- * - deleteIndex : allows to delete index content (https only)
10822
- * - settings : allows to get index settings (https only)
10823
- * - editSettings : allows to change index settings (https only)
10824
- * @param {Object} [params] - Optionnal parameters to set for the key
10825
- * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key)
10826
- * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour
10827
- * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call
10828
- * @param {string[]} params.indexes - Allowed targeted indexes for this key
10829
- * @param {string} params.description - A description for your key
10830
- * @param {string[]} params.referers - A list of authorized referers
10831
- * @param {Object} params.queryParameters - Force the key to use specific query parameters
10832
- * @param {Function} callback - The result callback called with two arguments
10833
- * error: null or Error('message')
10834
- * content: the server answer with user keys list
10835
- * @return {Promise|undefined} Returns a promise if no callback given
10836
- * @example
10837
- * client.addUserKey(['search'], {
10838
- * validity: 300,
10839
- * maxQueriesPerIPPerHour: 2000,
10840
- * maxHitsPerQuery: 3,
10841
- * indexes: ['fruits'],
10842
- * description: 'Eat three fruits',
10843
- * referers: ['*.algolia.com'],
10844
- * queryParameters: {
10845
- * tagFilters: ['public'],
10846
- * }
10847
- * })
10848
- * @see {@link https://www.algolia.com/doc/rest_api#AddKey|Algolia REST API Documentation}
10849
- */
10850
- addUserKey: function(acls, params, callback) {
10851
- if (arguments.length === 1 || typeof params === 'function') {
10852
- callback = params;
10853
- params = null;
10854
- }
10855
-
10856
- var postObj = {
10857
- acl: acls
10858
- };
10859
-
10860
- if (params) {
10861
- postObj.validity = params.validity;
10862
- postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour;
10863
- postObj.maxHitsPerQuery = params.maxHitsPerQuery;
10864
- postObj.indexes = params.indexes;
10865
- postObj.description = params.description;
10866
-
10867
- if (params.queryParameters) {
10868
- postObj.queryParameters = this._getSearchParams(params.queryParameters, '');
10869
- }
10870
-
10871
- postObj.referers = params.referers;
10872
- }
10873
-
10874
- return this._jsonRequest({
10875
- method: 'POST',
10876
- url: '/1/keys',
10877
- body: postObj,
10878
- hostType: 'write',
10879
- callback: callback
10880
- });
10881
- },
10882
- /**
10883
- * Add a new global API key
10884
- * @deprecated Please use client.addUserKey()
10885
- */
10886
- addUserKeyWithValidity: deprecate(function(acls, params, callback) {
10887
- return this.addUserKey(acls, params, callback);
10888
- }, deprecatedMessage('client.addUserKeyWithValidity()', 'client.addUserKey()')),
10889
-
10890
- /**
10891
- * Update an existing API key
10892
- * @param {string} key - The key to update
10893
- * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that
10894
- * can contains the following values:
10895
- * - search: allow to search (https and http)
10896
- * - addObject: allows to add/update an object in the index (https only)
10897
- * - deleteObject : allows to delete an existing object (https only)
10898
- * - deleteIndex : allows to delete index content (https only)
10899
- * - settings : allows to get index settings (https only)
10900
- * - editSettings : allows to change index settings (https only)
10901
- * @param {Object} [params] - Optionnal parameters to set for the key
10902
- * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key)
10903
- * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour
10904
- * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call
10905
- * @param {string[]} params.indexes - Allowed targeted indexes for this key
10906
- * @param {string} params.description - A description for your key
10907
- * @param {string[]} params.referers - A list of authorized referers
10908
- * @param {Object} params.queryParameters - Force the key to use specific query parameters
10909
- * @param {Function} callback - The result callback called with two arguments
10910
- * error: null or Error('message')
10911
- * content: the server answer with user keys list
10912
- * @return {Promise|undefined} Returns a promise if no callback given
10913
- * @example
10914
- * client.updateUserKey('APIKEY', ['search'], {
10915
- * validity: 300,
10916
- * maxQueriesPerIPPerHour: 2000,
10917
- * maxHitsPerQuery: 3,
10918
- * indexes: ['fruits'],
10919
- * description: 'Eat three fruits',
10920
- * referers: ['*.algolia.com'],
10921
- * queryParameters: {
10922
- * tagFilters: ['public'],
10923
- * }
10924
- * })
10925
- * @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation}
10926
- */
10927
- updateUserKey: function(key, acls, params, callback) {
10928
- if (arguments.length === 2 || typeof params === 'function') {
10929
- callback = params;
10930
- params = null;
10931
- }
10932
-
10933
- var putObj = {
10934
- acl: acls
10935
- };
10936
-
10937
- if (params) {
10938
- putObj.validity = params.validity;
10939
- putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour;
10940
- putObj.maxHitsPerQuery = params.maxHitsPerQuery;
10941
- putObj.indexes = params.indexes;
10942
- putObj.description = params.description;
10943
-
10944
- if (params.queryParameters) {
10945
- putObj.queryParameters = this._getSearchParams(params.queryParameters, '');
10946
- }
10947
-
10948
- putObj.referers = params.referers;
10949
- }
10950
-
10951
- return this._jsonRequest({
10952
- method: 'PUT',
10953
- url: '/1/keys/' + key,
10954
- body: putObj,
10955
- hostType: 'write',
10956
- callback: callback
10957
- });
10958
- },
10959
-
10960
- /**
10961
- * Set the extra security tagFilters header
10962
- * @param {string|array} tags The list of tags defining the current security filters
10963
- */
10964
- setSecurityTags: function(tags) {
10965
- if (Object.prototype.toString.call(tags) === '[object Array]') {
10966
- var strTags = [];
10967
- for (var i = 0; i < tags.length; ++i) {
10968
- if (Object.prototype.toString.call(tags[i]) === '[object Array]') {
10969
- var oredTags = [];
10970
- for (var j = 0; j < tags[i].length; ++j) {
10971
- oredTags.push(tags[i][j]);
10972
- }
10973
- strTags.push('(' + oredTags.join(',') + ')');
10974
- } else {
10975
- strTags.push(tags[i]);
10976
- }
10977
- }
10978
- tags = strTags.join(',');
10979
- }
10980
-
10981
- this.securityTags = tags;
10982
- },
10983
-
10984
- /**
10985
- * Set the extra user token header
10986
- * @param {string} userToken The token identifying a uniq user (used to apply rate limits)
10987
- */
10988
- setUserToken: function(userToken) {
10989
- this.userToken = userToken;
10990
- },
10991
-
10992
- /**
10993
- * Initialize a new batch of search queries
10994
- * @deprecated use client.search()
10995
- */
10996
- startQueriesBatch: deprecate(function startQueriesBatchDeprecated() {
10997
- this._batch = [];
10998
- }, deprecatedMessage('client.startQueriesBatch()', 'client.search()')),
10999
-
11000
- /**
11001
- * Add a search query in the batch
11002
- * @deprecated use client.search()
11003
- */
11004
- addQueryInBatch: deprecate(function addQueryInBatchDeprecated(indexName, query, args) {
11005
- this._batch.push({
11006
- indexName: indexName,
11007
- query: query,
11008
- params: args
11009
- });
11010
- }, deprecatedMessage('client.addQueryInBatch()', 'client.search()')),
11011
-
11012
- /**
11013
- * Clear all queries in client's cache
11014
- * @return undefined
11015
- */
11016
- clearCache: function() {
11017
- this.cache = {};
11018
- },
11019
-
11020
- /**
11021
- * Launch the batch of queries using XMLHttpRequest.
11022
- * @deprecated use client.search()
11023
- */
11024
- sendQueriesBatch: deprecate(function sendQueriesBatchDeprecated(callback) {
11025
- return this.search(this._batch, callback);
11026
- }, deprecatedMessage('client.sendQueriesBatch()', 'client.search()')),
11027
-
11028
- /**
11029
- * Set the number of milliseconds a request can take before automatically being terminated.
11030
- *
11031
- * @param {Number} milliseconds
11032
- */
11033
- setRequestTimeout: function(milliseconds) {
11034
- if (milliseconds) {
11035
- this.requestTimeout = parseInt(milliseconds, 10);
11036
- }
11037
- },
11038
-
11039
- /**
11040
- * Search through multiple indices at the same time
11041
- * @param {Object[]} queries An array of queries you want to run.
11042
- * @param {string} queries[].indexName The index name you want to target
11043
- * @param {string} [queries[].query] The query to issue on this index. Can also be passed into `params`
11044
- * @param {Object} queries[].params Any search param like hitsPerPage, ..
11045
- * @param {Function} callback Callback to be called
11046
- * @return {Promise|undefined} Returns a promise if no callback given
11047
- */
11048
- search: function(queries, callback) {
11049
- var client = this;
11050
-
11051
- var postObj = {
11052
- requests: map(queries, function prepareRequest(query) {
11053
- var params = '';
11054
-
11055
- // allow query.query
11056
- // so we are mimicing the index.search(query, params) method
11057
- // {indexName:, query:, params:}
11058
- if (query.query !== undefined) {
11059
- params += 'query=' + encodeURIComponent(query.query);
11060
- }
11061
-
11062
- return {
11063
- indexName: query.indexName,
11064
- params: client._getSearchParams(query.params, params)
11065
- };
11066
- })
11067
- };
11068
-
11069
- return this._jsonRequest({
11070
- cache: this.cache,
11071
- method: 'POST',
11072
- url: '/1/indexes/*/queries',
11073
- body: postObj,
11074
- hostType: 'read',
11075
- callback: callback
11076
- });
11077
- },
11078
-
11079
- /**
11080
- * Perform write operations accross multiple indexes.
11081
- *
11082
- * To reduce the amount of time spent on network round trips,
11083
- * you can create, update, or delete several objects in one call,
11084
- * using the batch endpoint (all operations are done in the given order).
11085
- *
11086
- * Available actions:
11087
- * - addObject
11088
- * - updateObject
11089
- * - partialUpdateObject
11090
- * - partialUpdateObjectNoCreate
11091
- * - deleteObject
11092
- *
11093
- * https://www.algolia.com/doc/rest_api#Indexes
11094
- * @param {Object[]} operations An array of operations to perform
11095
- * @return {Promise|undefined} Returns a promise if no callback given
11096
- * @example
11097
- * client.batch([{
11098
- * action: 'addObject',
11099
- * indexName: 'clients',
11100
- * body: {
11101
- * name: 'Bill'
11102
- * }
11103
- * }, {
11104
- * action: 'udpateObject',
11105
- * indexName: 'fruits',
11106
- * body: {
11107
- * objectID: '29138',
11108
- * name: 'banana'
11109
- * }
11110
- * }], cb)
11111
- */
11112
- batch: function(operations, callback) {
11113
- return this._jsonRequest({
11114
- method: 'POST',
11115
- url: '/1/indexes/*/batch',
11116
- body: {
11117
- requests: operations
11118
- },
11119
- hostType: 'write',
11120
- callback: callback
11121
- });
11122
- },
11123
-
11124
- // environment specific methods
11125
- destroy: notImplemented,
11126
- enableRateLimitForward: notImplemented,
11127
- disableRateLimitForward: notImplemented,
11128
- useSecuredAPIKey: notImplemented,
11129
- disableSecuredAPIKey: notImplemented,
11130
- generateSecuredApiKey: notImplemented,
11131
- /*
11132
- * Index class constructor.
11133
- * You should not use this method directly but use initIndex() function
11134
- */
11135
- Index: function(algoliasearch, indexName) {
11136
- this.indexName = indexName;
11137
- this.as = algoliasearch;
11138
- this.typeAheadArgs = null;
11139
- this.typeAheadValueOption = null;
11140
-
11141
- // make sure every index instance has it's own cache
11142
- this.cache = {};
11143
- },
11144
- /**
11145
- * Add an extra field to the HTTP request
11146
- *
11147
- * @param name the header field name
11148
- * @param value the header field value
11149
- */
11150
- setExtraHeader: function(name, value) {
11151
- this.extraHeaders.push({
11152
- name: name.toLowerCase(), value: value
11153
- });
11154
- },
11155
-
11156
- _sendQueriesBatch: function(params, callback) {
11157
- function prepareParams() {
11158
- var reqParams = '';
11159
- for (var i = 0; i < params.requests.length; ++i) {
11160
- var q = '/1/indexes/' +
11161
- encodeURIComponent(params.requests[i].indexName) +
11162
- '?' + params.requests[i].params;
11163
- reqParams += i + '=' + encodeURIComponent(q) + '&';
11164
- }
11165
- return reqParams;
11166
- }
11167
-
11168
- return this._jsonRequest({
11169
- cache: this.cache,
11170
- method: 'POST',
11171
- url: '/1/indexes/*/queries',
11172
- body: params,
11173
- hostType: 'read',
11174
- fallback: {
11175
- method: 'GET',
11176
- url: '/1/indexes/*',
11177
- body: {
11178
- params: prepareParams()
11179
- }
11180
- },
11181
- callback: callback
11182
- });
11183
- },
11184
- /*
11185
- * Wrapper that try all hosts to maximize the quality of service
11186
- */
11187
- _jsonRequest: function(opts) {
11188
- var requestDebug = require('debug')('algoliasearch:' + opts.url);
11189
-
11190
- var body;
11191
- var cache = opts.cache;
11192
- var client = this;
11193
- var tries = 0;
11194
- var usingFallback = false;
11195
-
11196
- if (opts.body !== undefined) {
11197
- body = safeJSONStringify(opts.body);
11198
- }
11199
-
11200
- requestDebug('request start');
11201
-
11202
- function doRequest(requester, reqOpts) {
11203
- var cacheID;
11204
-
11205
- if (client._useCache) {
11206
- cacheID = opts.url;
11207
- }
11208
-
11209
- // as we sometime use POST requests to pass parameters (like query='aa'),
11210
- // the cacheID must also include the body to be different between calls
11211
- if (client._useCache && body) {
11212
- cacheID += '_body_' + reqOpts.body;
11213
- }
11214
-
11215
- // handle cache existence
11216
- if (client._useCache && cache && cache[cacheID] !== undefined) {
11217
- requestDebug('serving response from cache');
11218
- return client._promise.resolve(JSON.parse(safeJSONStringify(cache[cacheID])));
11219
- }
11220
-
11221
- // if we reached max tries
11222
- if (tries >= client.hosts[opts.hostType].length ||
11223
- // or we need to switch to fallback
11224
- client.useFallback && !usingFallback) {
11225
- // and there's no fallback or we are already using a fallback
11226
- if (!opts.fallback || !client._request.fallback || usingFallback) {
11227
- requestDebug('could not get any response');
11228
- // then stop
11229
- return client._promise.reject(new errors.AlgoliaSearchError(
11230
- 'Cannot connect to the AlgoliaSearch API.' +
11231
- ' Send an email to support@algolia.com to report and resolve the issue.' +
11232
- ' Application id was: ' + client.applicationID
11233
- ));
11234
- }
11235
-
11236
- requestDebug('switching to fallback');
11237
-
11238
- // let's try the fallback starting from here
11239
- tries = 0;
11240
-
11241
- // method, url and body are fallback dependent
11242
- reqOpts.method = opts.fallback.method;
11243
- reqOpts.url = opts.fallback.url;
11244
- reqOpts.jsonBody = opts.fallback.body;
11245
- if (reqOpts.jsonBody) {
11246
- reqOpts.body = safeJSONStringify(reqOpts.jsonBody);
11247
- }
11248
-
11249
- reqOpts.timeout = client.requestTimeout * (tries + 1);
11250
- client.hostIndex[opts.hostType] = 0;
11251
- usingFallback = true; // the current request is now using fallback
11252
- return doRequest(client._request.fallback, reqOpts);
11253
- }
11254
-
11255
- var url = client.hosts[opts.hostType][client.hostIndex[opts.hostType]] + reqOpts.url;
11256
- var options = {
11257
- body: body,
11258
- jsonBody: opts.body,
11259
- method: reqOpts.method,
11260
- headers: client._computeRequestHeaders(),
11261
- timeout: reqOpts.timeout,
11262
- debug: requestDebug
11263
- };
11264
-
11265
- requestDebug('method: %s, url: %s, headers: %j, timeout: %d',
11266
- options.method, url, options.headers, options.timeout);
11267
-
11268
- if (requester === client._request.fallback) {
11269
- requestDebug('using fallback');
11270
- }
11271
-
11272
- // `requester` is any of this._request or this._request.fallback
11273
- // thus it needs to be called using the client as context
11274
- return requester.call(client, url, options).then(success, tryFallback);
11275
-
11276
- function success(httpResponse) {
11277
- // compute the status of the response,
11278
- //
11279
- // When in browser mode, using XDR or JSONP, we have no statusCode available
11280
- // So we rely on our API response `status` property.
11281
- // But `waitTask` can set a `status` property which is not the statusCode (it's the task status)
11282
- // So we check if there's a `message` along `status` and it means it's an error
11283
- //
11284
- // That's the only case where we have a response.status that's not the http statusCode
11285
- var status = httpResponse && httpResponse.body && httpResponse.body.message && httpResponse.body.status ||
11286
-
11287
- // this is important to check the request statusCode AFTER the body eventual
11288
- // statusCode because some implementations (jQuery XDomainRequest transport) may
11289
- // send statusCode 200 while we had an error
11290
- httpResponse.statusCode ||
11291
-
11292
- // When in browser mode, using XDR or JSONP
11293
- // we default to success when no error (no response.status && response.message)
11294
- // If there was a JSON.parse() error then body is null and it fails
11295
- httpResponse && httpResponse.body && 200;
11296
-
11297
- requestDebug('received response: statusCode: %s, computed statusCode: %d, headers: %j',
11298
- httpResponse.statusCode, status, httpResponse.headers);
11299
-
11300
- if (process.env.DEBUG && process.env.DEBUG.indexOf('debugBody') !== -1) {
11301
- requestDebug('body: %j', httpResponse.body);
11302
- }
11303
-
11304
- var ok = status === 200 || status === 201;
11305
- var retry = !ok && Math.floor(status / 100) !== 4 && Math.floor(status / 100) !== 1;
11306
-
11307
- if (client._useCache && ok && cache) {
11308
- cache[cacheID] = httpResponse.body;
11309
- }
11310
-
11311
- if (ok) {
11312
- return httpResponse.body;
11313
- }
11314
-
11315
- if (retry) {
11316
- tries += 1;
11317
- return retryRequest();
11318
- }
11319
-
11320
- var unrecoverableError = new errors.AlgoliaSearchError(
11321
- httpResponse.body && httpResponse.body.message
11322
- );
11323
-
11324
- return client._promise.reject(unrecoverableError);
11325
- }
11326
-
11327
- function tryFallback(err) {
11328
- // error cases:
11329
- // While not in fallback mode:
11330
- // - CORS not supported
11331
- // - network error
11332
- // While in fallback mode:
11333
- // - timeout
11334
- // - network error
11335
- // - badly formatted JSONP (script loaded, did not call our callback)
11336
- // In both cases:
11337
- // - uncaught exception occurs (TypeError)
11338
- requestDebug('error: %s, stack: %s', err.message, err.stack);
11339
-
11340
- if (!(err instanceof errors.AlgoliaSearchError)) {
11341
- err = new errors.Unknown(err && err.message, err);
11342
- }
11343
-
11344
- tries += 1;
11345
-
11346
- // stop the request implementation when:
11347
- if (
11348
- // we did not generate this error,
11349
- // it comes from a throw in some other piece of code
11350
- err instanceof errors.Unknown ||
11351
-
11352
- // server sent unparsable JSON
11353
- err instanceof errors.UnparsableJSON ||
11354
-
11355
- // no fallback and a network error occured (No CORS, bad APPID)
11356
- !requester.fallback && err instanceof errors.Network ||
11357
-
11358
- // max tries and already using fallback or no fallback
11359
- tries >= client.hosts[opts.hostType].length &&
11360
- (usingFallback || !opts.fallback || !client._request.fallback)) {
11361
- // stop request implementation for this command
11362
- return client._promise.reject(err);
11363
- }
11364
-
11365
- client.hostIndex[opts.hostType] = ++client.hostIndex[opts.hostType] % client.hosts[opts.hostType].length;
11366
-
11367
- if (err instanceof errors.RequestTimeout) {
11368
- return retryRequest();
11369
- } else if (client._request.fallback && !client.useFallback) {
11370
- // if any error occured but timeout, use fallback for the rest
11371
- // of the session
11372
- client.useFallback = true;
11373
- }
11374
-
11375
- return doRequest(requester, reqOpts);
11376
- }
11377
-
11378
- function retryRequest() {
11379
- client.hostIndex[opts.hostType] = ++client.hostIndex[opts.hostType] % client.hosts[opts.hostType].length;
11380
- reqOpts.timeout = client.requestTimeout * (tries + 1);
11381
- return doRequest(requester, reqOpts);
11382
- }
11383
- }
11384
-
11385
- // we can use a fallback if forced AND fallback parameters are available
11386
- var useFallback = client.useFallback && opts.fallback;
11387
- var requestOptions = useFallback ? opts.fallback : opts;
11388
-
11389
- var promise = doRequest(
11390
- // set the requester
11391
- useFallback ? client._request.fallback : client._request, {
11392
- url: requestOptions.url,
11393
- method: requestOptions.method,
11394
- body: body,
11395
- jsonBody: opts.body,
11396
- timeout: client.requestTimeout * (tries + 1)
11397
- }
11398
- );
11399
-
11400
- // either we have a callback
11401
- // either we are using promises
11402
- if (opts.callback) {
11403
- promise.then(function okCb(content) {
11404
- exitPromise(function() {
11405
- opts.callback(null, content);
11406
- }, client._setTimeout || setTimeout);
11407
- }, function nookCb(err) {
11408
- exitPromise(function() {
11409
- opts.callback(err);
11410
- }, client._setTimeout || setTimeout);
11411
- });
11412
- } else {
11413
- return promise;
11414
- }
11415
- },
11416
-
11417
- /*
11418
- * Transform search param object in query string
11419
- */
11420
- _getSearchParams: function(args, params) {
11421
- if (this._isUndefined(args) || args === null) {
11422
- return params;
11423
- }
11424
- for (var key in args) {
11425
- if (key !== null && args[key] !== undefined && args.hasOwnProperty(key)) {
11426
- params += params === '' ? '' : '&';
11427
- params += key + '=' + encodeURIComponent(Object.prototype.toString.call(args[key]) === '[object Array]' ? safeJSONStringify(args[key]) : args[key]);
11428
- }
11429
- }
11430
- return params;
11431
- },
11432
-
11433
- _isUndefined: function(obj) {
11434
- return obj === void 0;
11435
- },
11436
-
11437
- _computeRequestHeaders: function() {
11438
- var forEach = require('lodash-compat/collection/forEach');
11439
-
11440
- var requestHeaders = {
11441
- 'x-algolia-api-key': this.apiKey,
11442
- 'x-algolia-application-id': this.applicationID,
11443
- 'x-algolia-agent': this._ua
11444
- };
11445
-
11446
- if (this.userToken) {
11447
- requestHeaders['x-algolia-usertoken'] = this.userToken;
11448
- }
11449
-
11450
- if (this.securityTags) {
11451
- requestHeaders['x-algolia-tagfilters'] = this.securityTags;
11452
- }
11453
-
11454
- if (this.extraHeaders) {
11455
- forEach(this.extraHeaders, function addToRequestHeaders(header) {
11456
- requestHeaders[header.name] = header.value;
11457
- });
11458
- }
11459
-
11460
- return requestHeaders;
11461
- }
11462
- };
11463
-
11464
- /*
11465
- * Contains all the functions related to one index
11466
- * You should use AlgoliaSearch.initIndex(indexName) to retrieve this object
11467
- */
11468
- AlgoliaSearch.prototype.Index.prototype = {
11469
- /*
11470
- * Clear all queries in cache
11471
- */
11472
- clearCache: function() {
11473
- this.cache = {};
11474
- },
11475
- /*
11476
- * Add an object in this index
11477
- *
11478
- * @param content contains the javascript object to add inside the index
11479
- * @param objectID (optional) an objectID you want to attribute to this object
11480
- * (if the attribute already exist the old object will be overwrite)
11481
- * @param callback (optional) the result callback called with two arguments:
11482
- * error: null or Error('message')
11483
- * content: the server answer that contains 3 elements: createAt, taskId and objectID
11484
- */
11485
- addObject: function(content, objectID, callback) {
11486
- var indexObj = this;
11487
-
11488
- if (arguments.length === 1 || typeof objectID === 'function') {
11489
- callback = objectID;
11490
- objectID = undefined;
11491
- }
11492
-
11493
- return this.as._jsonRequest({
11494
- method: objectID !== undefined ?
11495
- 'PUT' : // update or create
11496
- 'POST', // create (API generates an objectID)
11497
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + // create
11498
- (objectID !== undefined ? '/' + encodeURIComponent(objectID) : ''), // update or create
11499
- body: content,
11500
- hostType: 'write',
11501
- callback: callback
11502
- });
11503
- },
11504
- /*
11505
- * Add several objects
11506
- *
11507
- * @param objects contains an array of objects to add
11508
- * @param callback (optional) the result callback called with two arguments:
11509
- * error: null or Error('message')
11510
- * content: the server answer that updateAt and taskID
11511
- */
11512
- addObjects: function(objects, callback) {
11513
- var indexObj = this;
11514
- var postObj = {
11515
- requests: []
11516
- };
11517
- for (var i = 0; i < objects.length; ++i) {
11518
- var request = {
11519
- action: 'addObject',
11520
- body: objects[i]
11521
- };
11522
- postObj.requests.push(request);
11523
- }
11524
- return this.as._jsonRequest({
11525
- method: 'POST',
11526
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch',
11527
- body: postObj,
11528
- hostType: 'write',
11529
- callback: callback
11530
- });
11531
- },
11532
- /*
11533
- * Get an object from this index
11534
- *
11535
- * @param objectID the unique identifier of the object to retrieve
11536
- * @param attrs (optional) if set, contains the array of attribute names to retrieve
11537
- * @param callback (optional) the result callback called with two arguments
11538
- * error: null or Error('message')
11539
- * content: the object to retrieve or the error message if a failure occured
11540
- */
11541
- getObject: function(objectID, attrs, callback) {
11542
- var indexObj = this;
11543
-
11544
- if (arguments.length === 1 || typeof attrs === 'function') {
11545
- callback = attrs;
11546
- attrs = undefined;
11547
- }
11548
-
11549
- var params = '';
11550
- if (attrs !== undefined) {
11551
- params = '?attributes=';
11552
- for (var i = 0; i < attrs.length; ++i) {
11553
- if (i !== 0) {
11554
- params += ',';
11555
- }
11556
- params += attrs[i];
11557
- }
11558
- }
11559
-
11560
- return this.as._jsonRequest({
11561
- method: 'GET',
11562
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID) + params,
11563
- hostType: 'read',
11564
- callback: callback
11565
- });
11566
- },
11567
-
11568
- /*
11569
- * Get several objects from this index
11570
- *
11571
- * @param objectIDs the array of unique identifier of objects to retrieve
11572
- */
11573
- getObjects: function(objectIDs, attributesToRetrieve, callback) {
11574
- var indexObj = this;
11575
-
11576
- if (arguments.length === 1 || typeof attributesToRetrieve === 'function') {
11577
- callback = attributesToRetrieve;
11578
- attributesToRetrieve = undefined;
11579
- }
11580
-
11581
- var body = {
11582
- requests: map(objectIDs, function prepareRequest(objectID) {
11583
- var request = {
11584
- 'indexName': indexObj.indexName,
11585
- 'objectID': objectID
11586
- };
11587
-
11588
- if (attributesToRetrieve) {
11589
- request.attributesToRetrieve = attributesToRetrieve.join(',');
11590
- }
11591
-
11592
- return request;
11593
- })
11594
- };
11595
-
11596
- return this.as._jsonRequest({
11597
- method: 'POST',
11598
- url: '/1/indexes/*/objects',
11599
- hostType: 'read',
11600
- body: body,
11601
- callback: callback
11602
- });
11603
- },
11604
-
11605
- /*
11606
- * Update partially an object (only update attributes passed in argument)
11607
- *
11608
- * @param partialObject contains the javascript attributes to override, the
11609
- * object must contains an objectID attribute
11610
- * @param callback (optional) the result callback called with two arguments:
11611
- * error: null or Error('message')
11612
- * content: the server answer that contains 3 elements: createAt, taskId and objectID
11613
- */
11614
- partialUpdateObject: function(partialObject, callback) {
11615
- var indexObj = this;
11616
- return this.as._jsonRequest({
11617
- method: 'POST',
11618
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(partialObject.objectID) + '/partial',
11619
- body: partialObject,
11620
- hostType: 'write',
11621
- callback: callback
11622
- });
11623
- },
11624
- /*
11625
- * Partially Override the content of several objects
11626
- *
11627
- * @param objects contains an array of objects to update (each object must contains a objectID attribute)
11628
- * @param callback (optional) the result callback called with two arguments:
11629
- * error: null or Error('message')
11630
- * content: the server answer that updateAt and taskID
11631
- */
11632
- partialUpdateObjects: function(objects, callback) {
11633
- var indexObj = this;
11634
- var postObj = {
11635
- requests: []
11636
- };
11637
- for (var i = 0; i < objects.length; ++i) {
11638
- var request = {
11639
- action: 'partialUpdateObject',
11640
- objectID: objects[i].objectID,
11641
- body: objects[i]
11642
- };
11643
- postObj.requests.push(request);
11644
- }
11645
- return this.as._jsonRequest({
11646
- method: 'POST',
11647
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch',
11648
- body: postObj,
11649
- hostType: 'write',
11650
- callback: callback
11651
- });
11652
- },
11653
- /*
11654
- * Override the content of object
11655
- *
11656
- * @param object contains the javascript object to save, the object must contains an objectID attribute
11657
- * @param callback (optional) the result callback called with two arguments:
11658
- * error: null or Error('message')
11659
- * content: the server answer that updateAt and taskID
11660
- */
11661
- saveObject: function(object, callback) {
11662
- var indexObj = this;
11663
- return this.as._jsonRequest({
11664
- method: 'PUT',
11665
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(object.objectID),
11666
- body: object,
11667
- hostType: 'write',
11668
- callback: callback
11669
- });
11670
- },
11671
- /*
11672
- * Override the content of several objects
11673
- *
11674
- * @param objects contains an array of objects to update (each object must contains a objectID attribute)
11675
- * @param callback (optional) the result callback called with two arguments:
11676
- * error: null or Error('message')
11677
- * content: the server answer that updateAt and taskID
11678
- */
11679
- saveObjects: function(objects, callback) {
11680
- var indexObj = this;
11681
- var postObj = {
11682
- requests: []
11683
- };
11684
- for (var i = 0; i < objects.length; ++i) {
11685
- var request = {
11686
- action: 'updateObject',
11687
- objectID: objects[i].objectID,
11688
- body: objects[i]
11689
- };
11690
- postObj.requests.push(request);
11691
- }
11692
- return this.as._jsonRequest({
11693
- method: 'POST',
11694
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch',
11695
- body: postObj,
11696
- hostType: 'write',
11697
- callback: callback
11698
- });
11699
- },
11700
- /*
11701
- * Delete an object from the index
11702
- *
11703
- * @param objectID the unique identifier of object to delete
11704
- * @param callback (optional) the result callback called with two arguments:
11705
- * error: null or Error('message')
11706
- * content: the server answer that contains 3 elements: createAt, taskId and objectID
11707
- */
11708
- deleteObject: function(objectID, callback) {
11709
- if (typeof objectID === 'function' || typeof objectID !== 'string' && typeof objectID !== 'number') {
11710
- var err = new errors.AlgoliaSearchError('Cannot delete an object without an objectID');
11711
- callback = objectID;
11712
- if (typeof callback === 'function') {
11713
- return callback(err);
11714
- }
11715
-
11716
- return this.as._promise.reject(err);
11717
- }
11718
-
11719
- var indexObj = this;
11720
- return this.as._jsonRequest({
11721
- method: 'DELETE',
11722
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID),
11723
- hostType: 'write',
11724
- callback: callback
11725
- });
11726
- },
11727
- /*
11728
- * Delete several objects from an index
11729
- *
11730
- * @param objectIDs contains an array of objectID to delete
11731
- * @param callback (optional) the result callback called with two arguments:
11732
- * error: null or Error('message')
11733
- * content: the server answer that contains 3 elements: createAt, taskId and objectID
11734
- */
11735
- deleteObjects: function(objectIDs, callback) {
11736
- var indexObj = this;
11737
- var postObj = {
11738
- requests: map(objectIDs, function prepareRequest(objectID) {
11739
- return {
11740
- action: 'deleteObject',
11741
- objectID: objectID,
11742
- body: {
11743
- objectID: objectID
11744
- }
11745
- };
11746
- })
11747
- };
11748
-
11749
- return this.as._jsonRequest({
11750
- method: 'POST',
11751
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch',
11752
- body: postObj,
11753
- hostType: 'write',
11754
- callback: callback
11755
- });
11756
- },
11757
- /*
11758
- * Delete all objects matching a query
11759
- *
11760
- * @param query the query string
11761
- * @param params the optional query parameters
11762
- * @param callback (optional) the result callback called with one argument
11763
- * error: null or Error('message')
11764
- */
11765
- deleteByQuery: function(query, params, callback) {
11766
- var indexObj = this;
11767
- var client = indexObj.as;
11768
-
11769
- if (arguments.length === 1 || typeof params === 'function') {
11770
- callback = params;
11771
- params = {};
11772
- }
11773
-
11774
- params.attributesToRetrieve = 'objectID';
11775
- params.hitsPerPage = 1000;
11776
-
11777
- // when deleting, we should never use cache to get the
11778
- // search results
11779
- this.clearCache();
11780
-
11781
- // there's a problem in how we use the promise chain,
11782
- // see how waitTask is done
11783
- var promise = this
11784
- .search(query, params)
11785
- .then(stopOrDelete);
11786
-
11787
- function stopOrDelete(searchContent) {
11788
- // stop here
11789
- if (searchContent.nbHits === 0) {
11790
- // return indexObj.as._request.resolve();
11791
- return searchContent;
11792
- }
11793
-
11794
- // continue and do a recursive call
11795
- var objectIDs = map(searchContent.hits, function getObjectID(object) {
11796
- return object.objectID;
11797
- });
11798
-
11799
- return indexObj
11800
- .deleteObjects(objectIDs)
11801
- .then(waitTask)
11802
- .then(doDeleteByQuery);
11803
- }
11804
-
11805
- function waitTask(deleteObjectsContent) {
11806
- return indexObj.waitTask(deleteObjectsContent.taskID);
11807
- }
11808
-
11809
- function doDeleteByQuery() {
11810
- return indexObj.deleteByQuery(query, params);
11811
- }
11812
-
11813
- if (!callback) {
11814
- return promise;
11815
- }
11816
-
11817
- promise.then(success, failure);
11818
-
11819
- function success() {
11820
- exitPromise(function exit() {
11821
- callback(null);
11822
- }, client._setTimeout || setTimeout);
11823
- }
11824
-
11825
- function failure(err) {
11826
- exitPromise(function exit() {
11827
- callback(err);
11828
- }, client._setTimeout || setTimeout);
11829
- }
11830
- },
11831
- /*
11832
- * Search inside the index using XMLHttpRequest request (Using a POST query to
11833
- * minimize number of OPTIONS queries: Cross-Origin Resource Sharing).
11834
- *
11835
- * @param query the full text query
11836
- * @param args (optional) if set, contains an object with query parameters:
11837
- * - page: (integer) Pagination parameter used to select the page to retrieve.
11838
- * Page is zero-based and defaults to 0. Thus,
11839
- * to retrieve the 10th page you need to set page=9
11840
- * - hitsPerPage: (integer) Pagination parameter used to select the number of hits per page. Defaults to 20.
11841
- * - attributesToRetrieve: a string that contains the list of object attributes
11842
- * you want to retrieve (let you minimize the answer size).
11843
- * Attributes are separated with a comma (for example "name,address").
11844
- * You can also use an array (for example ["name","address"]).
11845
- * By default, all attributes are retrieved. You can also use '*' to retrieve all
11846
- * values when an attributesToRetrieve setting is specified for your index.
11847
- * - attributesToHighlight: a string that contains the list of attributes you
11848
- * want to highlight according to the query.
11849
- * Attributes are separated by a comma. You can also use an array (for example ["name","address"]).
11850
- * If an attribute has no match for the query, the raw value is returned.
11851
- * By default all indexed text attributes are highlighted.
11852
- * You can use `*` if you want to highlight all textual attributes.
11853
- * Numerical attributes are not highlighted.
11854
- * A matchLevel is returned for each highlighted attribute and can contain:
11855
- * - full: if all the query terms were found in the attribute,
11856
- * - partial: if only some of the query terms were found,
11857
- * - none: if none of the query terms were found.
11858
- * - attributesToSnippet: a string that contains the list of attributes to snippet alongside
11859
- * the number of words to return (syntax is `attributeName:nbWords`).
11860
- * Attributes are separated by a comma (Example: attributesToSnippet=name:10,content:10).
11861
- * You can also use an array (Example: attributesToSnippet: ['name:10','content:10']).
11862
- * By default no snippet is computed.
11863
- * - minWordSizefor1Typo: the minimum number of characters in a query word to accept one typo in this word.
11864
- *D efaults to 3.
11865
- * - minWordSizefor2Typos: the minimum number of characters in a query word
11866
- * to accept two typos in this word. Defaults to 7.
11867
- * - getRankingInfo: if set to 1, the result hits will contain ranking
11868
- * information in _rankingInfo attribute.
11869
- * - aroundLatLng: search for entries around a given
11870
- * latitude/longitude (specified as two floats separated by a comma).
11871
- * For example aroundLatLng=47.316669,5.016670).
11872
- * You can specify the maximum distance in meters with the aroundRadius parameter (in meters)
11873
- * and the precision for ranking with aroundPrecision
11874
- * (for example if you set aroundPrecision=100, two objects that are distant of
11875
- * less than 100m will be considered as identical for "geo" ranking parameter).
11876
- * At indexing, you should specify geoloc of an object with the _geoloc attribute
11877
- * (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}})
11878
- * - insideBoundingBox: search entries inside a given area defined by the two extreme points
11879
- * of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng).
11880
- * For example insideBoundingBox=47.3165,4.9665,47.3424,5.0201).
11881
- * At indexing, you should specify geoloc of an object with the _geoloc attribute
11882
- * (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}})
11883
- * - numericFilters: a string that contains the list of numeric filters you want to
11884
- * apply separated by a comma.
11885
- * The syntax of one filter is `attributeName` followed by `operand` followed by `value`.
11886
- * Supported operands are `<`, `<=`, `=`, `>` and `>=`.
11887
- * You can have multiple conditions on one attribute like for example numericFilters=price>100,price<1000.
11888
- * You can also use an array (for example numericFilters: ["price>100","price<1000"]).
11889
- * - tagFilters: filter the query by a set of tags. You can AND tags by separating them by commas.
11890
- * To OR tags, you must add parentheses. For example, tags=tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3).
11891
- * You can also use an array, for example tagFilters: ["tag1",["tag2","tag3"]]
11892
- * means tag1 AND (tag2 OR tag3).
11893
- * At indexing, tags should be added in the _tags** attribute
11894
- * of objects (for example {"_tags":["tag1","tag2"]}).
11895
- * - facetFilters: filter the query by a list of facets.
11896
- * Facets are separated by commas and each facet is encoded as `attributeName:value`.
11897
- * For example: `facetFilters=category:Book,author:John%20Doe`.
11898
- * You can also use an array (for example `["category:Book","author:John%20Doe"]`).
11899
- * - facets: List of object attributes that you want to use for faceting.
11900
- * Comma separated list: `"category,author"` or array `['category','author']`
11901
- * Only attributes that have been added in **attributesForFaceting** index setting
11902
- * can be used in this parameter.
11903
- * You can also use `*` to perform faceting on all attributes specified in **attributesForFaceting**.
11904
- * - queryType: select how the query words are interpreted, it can be one of the following value:
11905
- * - prefixAll: all query words are interpreted as prefixes,
11906
- * - prefixLast: only the last word is interpreted as a prefix (default behavior),
11907
- * - prefixNone: no query word is interpreted as a prefix. This option is not recommended.
11908
- * - optionalWords: a string that contains the list of words that should
11909
- * be considered as optional when found in the query.
11910
- * Comma separated and array are accepted.
11911
- * - distinct: If set to 1, enable the distinct feature (disabled by default)
11912
- * if the attributeForDistinct index setting is set.
11913
- * This feature is similar to the SQL "distinct" keyword: when enabled
11914
- * in a query with the distinct=1 parameter,
11915
- * all hits containing a duplicate value for the attributeForDistinct attribute are removed from results.
11916
- * For example, if the chosen attribute is show_name and several hits have
11917
- * the same value for show_name, then only the best
11918
- * one is kept and others are removed.
11919
- * - restrictSearchableAttributes: List of attributes you want to use for
11920
- * textual search (must be a subset of the attributesToIndex index setting)
11921
- * either comma separated or as an array
11922
- * @param callback the result callback called with two arguments:
11923
- * error: null or Error('message'). If false, the content contains the error.
11924
- * content: the server answer that contains the list of results.
11925
- */
11926
- search: function(query, args, callback) {
11927
- // warn V2 users on how to search
11928
- if (typeof query === 'function' && typeof args === 'object' ||
11929
- typeof callback === 'object') {
11930
- // .search(query, params, cb)
11931
- // .search(cb, params)
11932
- throw new errors.AlgoliaSearchError('index.search usage is index.search(query, params, cb)');
11933
- }
11934
-
11935
- if (arguments.length === 0 || typeof query === 'function') {
11936
- // .search(), .search(cb)
11937
- callback = query;
11938
- query = '';
11939
- } else if (arguments.length === 1 || typeof args === 'function') {
11940
- // .search(query/args), .search(query, cb)
11941
- callback = args;
11942
- args = undefined;
11943
- }
11944
-
11945
- // .search(args), careful: typeof null === 'object'
11946
- if (typeof query === 'object' && query !== null) {
11947
- args = query;
11948
- query = undefined;
11949
- } else if (query === undefined || query === null) { // .search(undefined/null)
11950
- query = '';
11951
- }
11952
-
11953
- var params = '';
11954
-
11955
- if (query !== undefined) {
11956
- params += 'query=' + encodeURIComponent(query);
11957
- }
11958
-
11959
- if (args !== undefined) {
11960
- // `_getSearchParams` will augment params, do not be fooled by the = versus += from previous if
11961
- params = this.as._getSearchParams(args, params);
11962
- }
11963
-
11964
- return this._search(params, callback);
11965
- },
11966
-
11967
- /*
11968
- * Browse index content. The response content will have a `cursor` property that you can use
11969
- * to browse subsequent pages for this query. Use `index.browseNext(cursor)` when you want.
11970
- *
11971
- * @param {string} query - The full text query
11972
- * @param {Object} [queryParameters] - Any search query parameter
11973
- * @param {Function} [callback] - The result callback called with two arguments
11974
- * error: null or Error('message')
11975
- * content: the server answer with the browse result
11976
- * @return {Promise|undefined} Returns a promise if no callback given
11977
- * @example
11978
- * index.browse('cool songs', {
11979
- * tagFilters: 'public,comments',
11980
- * hitsPerPage: 500
11981
- * }, callback);
11982
- * @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation}
11983
- */
11984
- // pre 3.5.0 usage, backward compatible
11985
- // browse: function(page, hitsPerPage, callback) {
11986
- browse: function(query, queryParameters, callback) {
11987
- var merge = require('lodash-compat/object/merge');
11988
-
11989
- var indexObj = this;
11990
-
11991
- var page;
11992
- var hitsPerPage;
11993
-
11994
- // we check variadic calls that are not the one defined
11995
- // .browse()/.browse(fn)
11996
- // => page = 0
11997
- if (arguments.length === 0 || arguments.length === 1 && typeof arguments[0] === 'function') {
11998
- page = 0;
11999
- callback = arguments[0];
12000
- query = undefined;
12001
- } else if (typeof arguments[0] === 'number') {
12002
- // .browse(2)/.browse(2, 10)/.browse(2, fn)/.browse(2, 10, fn)
12003
- page = arguments[0];
12004
- if (typeof arguments[1] === 'number') {
12005
- hitsPerPage = arguments[1];
12006
- } else if (typeof arguments[1] === 'function') {
12007
- callback = arguments[1];
12008
- hitsPerPage = undefined;
12009
- }
12010
- query = undefined;
12011
- queryParameters = undefined;
12012
- } else if (typeof arguments[0] === 'object') {
12013
- // .browse(queryParameters)/.browse(queryParameters, cb)
12014
- if (typeof arguments[1] === 'function') {
12015
- callback = arguments[1];
12016
- }
12017
- queryParameters = arguments[0];
12018
- query = undefined;
12019
- } else if (typeof arguments[0] === 'string' && typeof arguments[1] === 'function') {
12020
- // .browse(query, cb)
12021
- callback = arguments[1];
12022
- queryParameters = undefined;
12023
- }
12024
-
12025
- // otherwise it's a .browse(query)/.browse(query, queryParameters)/.browse(query, queryParameters, cb)
12026
-
12027
- // get search query parameters combining various possible calls
12028
- // to .browse();
12029
- queryParameters = merge({}, queryParameters || {}, {
12030
- page: page,
12031
- hitsPerPage: hitsPerPage,
12032
- query: query
12033
- });
12034
-
12035
- var params = this.as._getSearchParams(queryParameters, '');
12036
-
12037
- return this.as._jsonRequest({
12038
- method: 'GET',
12039
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/browse?' + params,
12040
- hostType: 'read',
12041
- callback: callback
12042
- });
12043
- },
12044
-
12045
- /*
12046
- * Continue browsing from a previous position (cursor), obtained via a call to `.browse()`.
12047
- *
12048
- * @param {string} query - The full text query
12049
- * @param {Object} [queryParameters] - Any search query parameter
12050
- * @param {Function} [callback] - The result callback called with two arguments
12051
- * error: null or Error('message')
12052
- * content: the server answer with the browse result
12053
- * @return {Promise|undefined} Returns a promise if no callback given
12054
- * @example
12055
- * index.browseFrom('14lkfsakl32', callback);
12056
- * @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation}
12057
- */
12058
- browseFrom: function(cursor, callback) {
12059
- return this.as._jsonRequest({
12060
- method: 'GET',
12061
- url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/browse?cursor=' + cursor,
12062
- hostType: 'read',
12063
- callback: callback
12064
- });
12065
- },
12066
-
12067
- /*
12068
- * Browse all content from an index using events. Basically this will do
12069
- * .browse() -> .browseFrom -> .browseFrom -> .. until all the results are returned
12070
- *
12071
- * @param {string} query - The full text query
12072
- * @param {Object} [queryParameters] - Any search query parameter
12073
- * @return {EventEmitter}
12074
- * @example
12075
- * var browser = index.browseAll('cool songs', {
12076
- * tagFilters: 'public,comments',
12077
- * hitsPerPage: 500
12078
- * });
12079
- *
12080
- * browser.on('result', function resultCallback(content) {
12081
- * console.log(content.hits);
12082
- * });
12083
- *
12084
- * // if any error occurs, you get it
12085
- * browser.on('error', function(err) {
12086
- * throw err;
12087
- * });
12088
- *
12089
- * // when you have browsed the whole index, you get this event
12090
- * browser.on('end', function() {
12091
- * console.log('finished');
12092
- * });
12093
- *
12094
- * // at any point if you want to stop the browsing process, you can stop it manually
12095
- * // otherwise it will go on and on
12096
- * browser.stop();
12097
- *
12098
- * @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation}
12099
- */
12100
- browseAll: function(query, queryParameters) {
12101
- if (typeof query === 'object') {
12102
- queryParameters = query;
12103
- query = undefined;
12104
- }
12105
-
12106
- var merge = require('lodash-compat/object/merge');
12107
-
12108
- var IndexBrowser = require('./IndexBrowser');
12109
-
12110
- var browser = new IndexBrowser();
12111
- var client = this.as;
12112
- var index = this;
12113
- var params = client._getSearchParams(
12114
- merge({}, queryParameters || {}, {
12115
- query: query
12116
- }), ''
12117
- );
12118
-
12119
- // start browsing
12120
- browseLoop();
12121
-
12122
- function browseLoop(cursor) {
12123
- if (browser._stopped) {
12124
- return;
12125
- }
12126
-
12127
- var queryString;
12128
-
12129
- if (cursor !== undefined) {
12130
- queryString = 'cursor=' + encodeURIComponent(cursor);
12131
- } else {
12132
- queryString = params;
12133
- }
12134
-
12135
- client._jsonRequest({
12136
- method: 'GET',
12137
- url: '/1/indexes/' + encodeURIComponent(index.indexName) + '/browse?' + queryString,
12138
- hostType: 'read',
12139
- callback: browseCallback
12140
- });
12141
- }
12142
-
12143
- function browseCallback(err, content) {
12144
- if (browser._stopped) {
12145
- return;
12146
- }
12147
-
12148
- if (err) {
12149
- browser._error(err);
12150
- return;
12151
- }
12152
-
12153
- browser._result(content);
12154
-
12155
- // no cursor means we are finished browsing
12156
- if (content.cursor === undefined) {
12157
- browser._end();
12158
- return;
12159
- }
12160
-
12161
- browseLoop(content.cursor);
12162
- }
12163
-
12164
- return browser;
12165
- },
12166
-
12167
- /*
12168
- * Get a Typeahead.js adapter
12169
- * @param searchParams contains an object with query parameters (see search for details)
12170
- */
12171
- ttAdapter: function(params) {
12172
- var self = this;
12173
- return function ttAdapter(query, syncCb, asyncCb) {
12174
- var cb;
12175
-
12176
- if (typeof asyncCb === 'function') {
12177
- // typeahead 0.11
12178
- cb = asyncCb;
12179
- } else {
12180
- // pre typeahead 0.11
12181
- cb = syncCb;
12182
- }
12183
-
12184
- self.search(query, params, function searchDone(err, content) {
12185
- if (err) {
12186
- cb(err);
12187
- return;
12188
- }
12189
-
12190
- cb(content.hits);
12191
- });
12192
- };
12193
- },
12194
-
12195
- /*
12196
- * Wait the publication of a task on the server.
12197
- * All server task are asynchronous and you can check with this method that the task is published.
12198
- *
12199
- * @param taskID the id of the task returned by server
12200
- * @param callback the result callback with with two arguments:
12201
- * error: null or Error('message')
12202
- * content: the server answer that contains the list of results
12203
- */
12204
- waitTask: function(taskID, callback) {
12205
- // wait minimum 100ms before retrying
12206
- var baseDelay = 100;
12207
- // wait maximum 5s before retrying
12208
- var maxDelay = 5000;
12209
- var loop = 0;
12210
-
12211
- // waitTask() must be handled differently from other methods,
12212
- // it's a recursive method using a timeout
12213
- var indexObj = this;
12214
- var client = indexObj.as;
12215
-
12216
- var promise = retryLoop();
12217
-
12218
- function retryLoop() {
12219
- return client._jsonRequest({
12220
- method: 'GET',
12221
- hostType: 'read',
12222
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/task/' + taskID
12223
- }).then(function success(content) {
12224
- loop++;
12225
- var delay = baseDelay * loop * loop;
12226
- if (delay > maxDelay) {
12227
- delay = maxDelay;
12228
- }
12229
-
12230
- if (content.status !== 'published') {
12231
- return client._promise.delay(delay).then(retryLoop);
12232
- }
12233
-
12234
- return content;
12235
- });
12236
- }
12237
-
12238
- if (!callback) {
12239
- return promise;
12240
- }
12241
-
12242
- promise.then(successCb, failureCb);
12243
-
12244
- function successCb(content) {
12245
- exitPromise(function exit() {
12246
- callback(null, content);
12247
- }, client._setTimeout || setTimeout);
12248
- }
12249
-
12250
- function failureCb(err) {
12251
- exitPromise(function exit() {
12252
- callback(err);
12253
- }, client._setTimeout || setTimeout);
12254
- }
12255
- },
12256
-
12257
- /*
12258
- * This function deletes the index content. Settings and index specific API keys are kept untouched.
12259
- *
12260
- * @param callback (optional) the result callback called with two arguments
12261
- * error: null or Error('message')
12262
- * content: the settings object or the error message if a failure occured
12263
- */
12264
- clearIndex: function(callback) {
12265
- var indexObj = this;
12266
- return this.as._jsonRequest({
12267
- method: 'POST',
12268
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/clear',
12269
- hostType: 'write',
12270
- callback: callback
12271
- });
12272
- },
12273
- /*
12274
- * Get settings of this index
12275
- *
12276
- * @param callback (optional) the result callback called with two arguments
12277
- * error: null or Error('message')
12278
- * content: the settings object or the error message if a failure occured
12279
- */
12280
- getSettings: function(callback) {
12281
- var indexObj = this;
12282
- return this.as._jsonRequest({
12283
- method: 'GET',
12284
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/settings',
12285
- hostType: 'read',
12286
- callback: callback
12287
- });
12288
- },
12289
-
12290
- /*
12291
- * Set settings for this index
12292
- *
12293
- * @param settigns the settings object that can contains :
12294
- * - minWordSizefor1Typo: (integer) the minimum number of characters to accept one typo (default = 3).
12295
- * - minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7).
12296
- * - hitsPerPage: (integer) the number of hits per page (default = 10).
12297
- * - attributesToRetrieve: (array of strings) default list of attributes to retrieve in objects.
12298
- * If set to null, all attributes are retrieved.
12299
- * - attributesToHighlight: (array of strings) default list of attributes to highlight.
12300
- * If set to null, all indexed attributes are highlighted.
12301
- * - attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number
12302
- * of words to return (syntax is attributeName:nbWords).
12303
- * By default no snippet is computed. If set to null, no snippet is computed.
12304
- * - attributesToIndex: (array of strings) the list of fields you want to index.
12305
- * If set to null, all textual and numerical attributes of your objects are indexed,
12306
- * but you should update it to get optimal results.
12307
- * This parameter has two important uses:
12308
- * - Limit the attributes to index: For example if you store a binary image in base64,
12309
- * you want to store it and be able to
12310
- * retrieve it but you don't want to search in the base64 string.
12311
- * - Control part of the ranking*: (see the ranking parameter for full explanation)
12312
- * Matches in attributes at the beginning of
12313
- * the list will be considered more important than matches in attributes further down the list.
12314
- * In one attribute, matching text at the beginning of the attribute will be
12315
- * considered more important than text after, you can disable
12316
- * this behavior if you add your attribute inside `unordered(AttributeName)`,
12317
- * for example attributesToIndex: ["title", "unordered(text)"].
12318
- * - attributesForFaceting: (array of strings) The list of fields you want to use for faceting.
12319
- * All strings in the attribute selected for faceting are extracted and added as a facet.
12320
- * If set to null, no attribute is used for faceting.
12321
- * - attributeForDistinct: (string) The attribute name used for the Distinct feature.
12322
- * This feature is similar to the SQL "distinct" keyword: when enabled
12323
- * in query with the distinct=1 parameter, all hits containing a duplicate
12324
- * value for this attribute are removed from results.
12325
- * For example, if the chosen attribute is show_name and several hits have
12326
- * the same value for show_name, then only the best one is kept and others are removed.
12327
- * - ranking: (array of strings) controls the way results are sorted.
12328
- * We have six available criteria:
12329
- * - typo: sort according to number of typos,
12330
- * - geo: sort according to decreassing distance when performing a geo-location based search,
12331
- * - proximity: sort according to the proximity of query words in hits,
12332
- * - attribute: sort according to the order of attributes defined by attributesToIndex,
12333
- * - exact:
12334
- * - if the user query contains one word: sort objects having an attribute
12335
- * that is exactly the query word before others.
12336
- * For example if you search for the "V" TV show, you want to find it
12337
- * with the "V" query and avoid to have all popular TV
12338
- * show starting by the v letter before it.
12339
- * - if the user query contains multiple words: sort according to the
12340
- * number of words that matched exactly (and not as a prefix).
12341
- * - custom: sort according to a user defined formula set in **customRanking** attribute.
12342
- * The standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"]
12343
- * - customRanking: (array of strings) lets you specify part of the ranking.
12344
- * The syntax of this condition is an array of strings containing attributes
12345
- * prefixed by asc (ascending order) or desc (descending order) operator.
12346
- * For example `"customRanking" => ["desc(population)", "asc(name)"]`
12347
- * - queryType: Select how the query words are interpreted, it can be one of the following value:
12348
- * - prefixAll: all query words are interpreted as prefixes,
12349
- * - prefixLast: only the last word is interpreted as a prefix (default behavior),
12350
- * - prefixNone: no query word is interpreted as a prefix. This option is not recommended.
12351
- * - highlightPreTag: (string) Specify the string that is inserted before
12352
- * the highlighted parts in the query result (default to "<em>").
12353
- * - highlightPostTag: (string) Specify the string that is inserted after
12354
- * the highlighted parts in the query result (default to "</em>").
12355
- * - optionalWords: (array of strings) Specify a list of words that should
12356
- * be considered as optional when found in the query.
12357
- * @param callback (optional) the result callback called with two arguments
12358
- * error: null or Error('message')
12359
- * content: the server answer or the error message if a failure occured
12360
- */
12361
- setSettings: function(settings, callback) {
12362
- var indexObj = this;
12363
- return this.as._jsonRequest({
12364
- method: 'PUT',
12365
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/settings',
12366
- hostType: 'write',
12367
- body: settings,
12368
- callback: callback
12369
- });
12370
- },
12371
- /*
12372
- * List all existing user keys associated to this index
12373
- *
12374
- * @param callback the result callback called with two arguments
12375
- * error: null or Error('message')
12376
- * content: the server answer with user keys list
12377
- */
12378
- listUserKeys: function(callback) {
12379
- var indexObj = this;
12380
- return this.as._jsonRequest({
12381
- method: 'GET',
12382
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys',
12383
- hostType: 'read',
12384
- callback: callback
12385
- });
12386
- },
12387
- /*
12388
- * Get ACL of a user key associated to this index
12389
- *
12390
- * @param key
12391
- * @param callback the result callback called with two arguments
12392
- * error: null or Error('message')
12393
- * content: the server answer with user keys list
12394
- */
12395
- getUserKeyACL: function(key, callback) {
12396
- var indexObj = this;
12397
- return this.as._jsonRequest({
12398
- method: 'GET',
12399
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key,
12400
- hostType: 'read',
12401
- callback: callback
12402
- });
12403
- },
12404
- /*
12405
- * Delete an existing user key associated to this index
12406
- *
12407
- * @param key
12408
- * @param callback the result callback called with two arguments
12409
- * error: null or Error('message')
12410
- * content: the server answer with user keys list
12411
- */
12412
- deleteUserKey: function(key, callback) {
12413
- var indexObj = this;
12414
- return this.as._jsonRequest({
12415
- method: 'DELETE',
12416
- url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key,
12417
- hostType: 'write',
12418
- callback: callback
12419
- });
12420
- },
12421
- /*
12422
- * Add a new API key to this index
12423
- *
12424
- * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that
12425
- * can contains the following values:
12426
- * - search: allow to search (https and http)
12427
- * - addObject: allows to add/update an object in the index (https only)
12428
- * - deleteObject : allows to delete an existing object (https only)
12429
- * - deleteIndex : allows to delete index content (https only)
12430
- * - settings : allows to get index settings (https only)
12431
- * - editSettings : allows to change index settings (https only)
12432
- * @param {Object} [params] - Optionnal parameters to set for the key
12433
- * @param {number} params.validity - Number of seconds after which the key will
12434
- * be automatically removed (0 means no time limit for this key)
12435
- * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour
12436
- * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call
12437
- * @param {string} params.description - A description for your key
12438
- * @param {string[]} params.referers - A list of authorized referers
12439
- * @param {Object} params.queryParameters - Force the key to use specific query parameters
12440
- * @param {Function} callback - The result callback called with two arguments
12441
- * error: null or Error('message')
12442
- * content: the server answer with user keys list
12443
- * @return {Promise|undefined} Returns a promise if no callback given
12444
- * @example
12445
- * index.addUserKey(['search'], {
12446
- * validity: 300,
12447
- * maxQueriesPerIPPerHour: 2000,
12448
- * maxHitsPerQuery: 3,
12449
- * description: 'Eat three fruits',
12450
- * referers: ['*.algolia.com'],
12451
- * queryParameters: {
12452
- * tagFilters: ['public'],
12453
- * }
12454
- * })
12455
- * @see {@link https://www.algolia.com/doc/rest_api#AddIndexKey|Algolia REST API Documentation}
12456
- */
12457
- addUserKey: function(acls, params, callback) {
12458
- if (arguments.length === 1 || typeof params === 'function') {
12459
- callback = params;
12460
- params = null;
12461
- }
12462
-
12463
- var postObj = {
12464
- acl: acls
12465
- };
12466
-
12467
- if (params) {
12468
- postObj.validity = params.validity;
12469
- postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour;
12470
- postObj.maxHitsPerQuery = params.maxHitsPerQuery;
12471
- postObj.description = params.description;
12472
-
12473
- if (params.queryParameters) {
12474
- postObj.queryParameters = this.as._getSearchParams(params.queryParameters, '');
12475
- }
12476
-
12477
- postObj.referers = params.referers;
12478
- }
12479
-
12480
- return this.as._jsonRequest({
12481
- method: 'POST',
12482
- url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys',
12483
- body: postObj,
12484
- hostType: 'write',
12485
- callback: callback
12486
- });
12487
- },
12488
-
12489
- /**
12490
- * Add an existing user key associated to this index
12491
- * @deprecated use index.addUserKey()
12492
- */
12493
- addUserKeyWithValidity: deprecate(function deprecatedAddUserKeyWithValidity(acls, params, callback) {
12494
- return this.addUserKey(acls, params, callback);
12495
- }, deprecatedMessage('index.addUserKeyWithValidity()', 'index.addUserKey()')),
12496
-
12497
- /**
12498
- * Update an existing API key of this index
12499
- * @param {string} key - The key to update
12500
- * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that
12501
- * can contains the following values:
12502
- * - search: allow to search (https and http)
12503
- * - addObject: allows to add/update an object in the index (https only)
12504
- * - deleteObject : allows to delete an existing object (https only)
12505
- * - deleteIndex : allows to delete index content (https only)
12506
- * - settings : allows to get index settings (https only)
12507
- * - editSettings : allows to change index settings (https only)
12508
- * @param {Object} [params] - Optionnal parameters to set for the key
12509
- * @param {number} params.validity - Number of seconds after which the key will
12510
- * be automatically removed (0 means no time limit for this key)
12511
- * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour
12512
- * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call
12513
- * @param {string} params.description - A description for your key
12514
- * @param {string[]} params.referers - A list of authorized referers
12515
- * @param {Object} params.queryParameters - Force the key to use specific query parameters
12516
- * @param {Function} callback - The result callback called with two arguments
12517
- * error: null or Error('message')
12518
- * content: the server answer with user keys list
12519
- * @return {Promise|undefined} Returns a promise if no callback given
12520
- * @example
12521
- * index.updateUserKey('APIKEY', ['search'], {
12522
- * validity: 300,
12523
- * maxQueriesPerIPPerHour: 2000,
12524
- * maxHitsPerQuery: 3,
12525
- * description: 'Eat three fruits',
12526
- * referers: ['*.algolia.com'],
12527
- * queryParameters: {
12528
- * tagFilters: ['public'],
12529
- * }
12530
- * })
12531
- * @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation}
12532
- */
12533
- updateUserKey: function(key, acls, params, callback) {
12534
- if (arguments.length === 2 || typeof params === 'function') {
12535
- callback = params;
12536
- params = null;
12537
- }
12538
-
12539
- var putObj = {
12540
- acl: acls
12541
- };
12542
-
12543
- if (params) {
12544
- putObj.validity = params.validity;
12545
- putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour;
12546
- putObj.maxHitsPerQuery = params.maxHitsPerQuery;
12547
- putObj.description = params.description;
12548
-
12549
- if (params.queryParameters) {
12550
- putObj.queryParameters = this.as._getSearchParams(params.queryParameters, '');
12551
- }
12552
-
12553
- putObj.referers = params.referers;
12554
- }
12555
-
12556
- return this.as._jsonRequest({
12557
- method: 'PUT',
12558
- url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys/' + key,
12559
- body: putObj,
12560
- hostType: 'write',
12561
- callback: callback
12562
- });
12563
- },
12564
-
12565
- _search: function(params, callback) {
12566
- return this.as._jsonRequest({
12567
- cache: this.cache,
12568
- method: 'POST',
12569
- url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/query',
12570
- body: {params: params},
12571
- hostType: 'read',
12572
- fallback: {
12573
- method: 'GET',
12574
- url: '/1/indexes/' + encodeURIComponent(this.indexName),
12575
- body: {params: params}
12576
- },
12577
- callback: callback
12578
- });
12579
- },
12580
-
12581
- as: null,
12582
- indexName: null,
12583
- typeAheadArgs: null,
12584
- typeAheadValueOption: null
12585
- };
12586
-
12587
- // extracted from https://github.com/component/map/blob/master/index.js
12588
- // without the crazy toFunction thing
12589
- function map(arr, fn) {
12590
- var ret = [];
12591
- for (var i = 0; i < arr.length; ++i) {
12592
- ret.push(fn(arr[i], i));
12593
- }
12594
- return ret;
12595
- }
12596
-
12597
- function prepareHost(protocol) {
12598
- return function prepare(host) {
12599
- return protocol + '//' + host.toLowerCase();
12600
- };
12601
- }
12602
-
12603
- function notImplemented() {
12604
- var message = 'Not implemented in this environment.\n' +
12605
- 'If you feel this is a mistake, write to support@algolia.com';
12606
-
12607
- throw new errors.AlgoliaSearchError(message);
12608
- }
12609
-
12610
- function deprecatedMessage(previousUsage, newUsage) {
12611
- var githubAnchorLink = previousUsage.toLowerCase()
12612
- .replace('.', '')
12613
- .replace('()', '');
12614
-
12615
- return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage +
12616
- '`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#' + githubAnchorLink;
12617
- }
12618
-
12619
- // Parse cloud does not supports setTimeout
12620
- // We do not store a setTimeout reference in the client everytime
12621
- // We only fallback to a fake setTimeout when not available
12622
- // setTimeout cannot be override globally sadly
12623
- function exitPromise(fn, _setTimeout) {
12624
- _setTimeout(fn, 0);
12625
- }
12626
-
12627
- function deprecate(fn, message) {
12628
- var warned = false;
12629
-
12630
- function deprecated() {
12631
- if (!warned) {
12632
- /* eslint no-console:0 */
12633
- console.log(message);
12634
- warned = true;
12635
- }
12636
-
12637
- return fn.apply(this, arguments);
12638
- }
12639
-
12640
- return deprecated;
12641
- }
12642
-
12643
- // Prototype.js < 1.7, a widely used library, defines a weird
12644
- // Array.prototype.toJSON function that will fail to stringify our content
12645
- // appropriately
12646
- // refs:
12647
- // - https://groups.google.com/forum/#!topic/prototype-core/E-SAVvV_V9Q
12648
- // - https://github.com/sstephenson/prototype/commit/038a2985a70593c1a86c230fadbdfe2e4898a48c
12649
- // - http://stackoverflow.com/a/3148441/147079
12650
- function safeJSONStringify(obj) {
12651
- /* eslint no-extend-native:0 */
12652
-
12653
- if (Array.prototype.toJSON === undefined) {
12654
- return JSON.stringify(obj);
12655
- }
12656
-
12657
- var toJSON = Array.prototype.toJSON;
12658
- delete Array.prototype.toJSON;
12659
- var out = JSON.stringify(obj);
12660
- Array.prototype.toJSON = toJSON;
12661
-
12662
- return out;
12663
- }
12664
-
12665
- }).call(this,require('_process'))
12666
- },{"./IndexBrowser":212,"./errors":217,"_process":221,"debug":157,"lodash-compat/collection/forEach":162,"lodash-compat/lang/clone":195,"lodash-compat/lang/isArray":198,"lodash-compat/object/merge":208}],212:[function(require,module,exports){
12667
- 'use strict';
12668
-
12669
- // This is the object returned by the `index.browseAll()` method
12670
-
12671
- module.exports = IndexBrowser;
12672
-
12673
- var inherits = require('inherits');
12674
- var EventEmitter = require('events').EventEmitter;
12675
-
12676
- function IndexBrowser() {
12677
- }
12678
-
12679
- inherits(IndexBrowser, EventEmitter);
12680
-
12681
- IndexBrowser.prototype.stop = function() {
12682
- this._stopped = true;
12683
- this._clean();
12684
- };
12685
-
12686
- IndexBrowser.prototype._end = function() {
12687
- this.emit('end');
12688
- this._clean();
12689
- };
12690
-
12691
- IndexBrowser.prototype._error = function(err) {
12692
- this.emit('error', err);
12693
- this._clean();
12694
- };
12695
-
12696
- IndexBrowser.prototype._result = function(content) {
12697
- this.emit('result', content);
12698
- };
12699
-
12700
- IndexBrowser.prototype._clean = function() {
12701
- this.removeAllListeners('stop');
12702
- this.removeAllListeners('end');
12703
- this.removeAllListeners('error');
12704
- this.removeAllListeners('result');
12705
- };
12706
-
12707
- },{"events":219,"inherits":161}],213:[function(require,module,exports){
12708
- 'use strict';
12709
-
12710
- // This is the standalone browser build entry point
12711
- // Browser implementation of the Algolia Search JavaScript client,
12712
- // using XMLHttpRequest, XDomainRequest and JSONP as fallback
12713
- module.exports = algoliasearch;
12714
-
12715
- var inherits = require('inherits');
12716
- var Promise = window.Promise || require('es6-promise').Promise;
12717
-
12718
- var AlgoliaSearch = require('../../AlgoliaSearch');
12719
- var errors = require('../../errors');
12720
- var inlineHeaders = require('../inline-headers');
12721
- var jsonpRequest = require('../jsonp-request');
12722
-
12723
- function algoliasearch(applicationID, apiKey, opts) {
12724
- var cloneDeep = require('lodash-compat/lang/cloneDeep');
12725
-
12726
- var getDocumentProtocol = require('../get-document-protocol');
12727
-
12728
- opts = cloneDeep(opts || {});
12729
-
12730
- if (opts.protocol === undefined) {
12731
- opts.protocol = getDocumentProtocol();
12732
- }
12733
-
12734
- opts._ua = opts._ua || algoliasearch.ua;
12735
-
12736
- return new AlgoliaSearchBrowser(applicationID, apiKey, opts);
12737
- }
12738
-
12739
- algoliasearch.version = require('../../version.json');
12740
- algoliasearch.ua = 'Algolia for vanilla JavaScript ' + algoliasearch.version;
12741
-
12742
- // we expose into window no matter how we are used, this will allow
12743
- // us to easily debug any website running algolia
12744
- window.__algolia = {
12745
- debug: require('debug'),
12746
- algoliasearch: algoliasearch
12747
- };
12748
-
12749
- var support = {
12750
- hasXMLHttpRequest: 'XMLHttpRequest' in window,
12751
- hasXDomainRequest: 'XDomainRequest' in window,
12752
- cors: 'withCredentials' in new XMLHttpRequest(),
12753
- timeout: 'timeout' in new XMLHttpRequest()
12754
- };
12755
-
12756
- function AlgoliaSearchBrowser() {
12757
- // call AlgoliaSearch constructor
12758
- AlgoliaSearch.apply(this, arguments);
12759
- }
12760
-
12761
- inherits(AlgoliaSearchBrowser, AlgoliaSearch);
12762
-
12763
- AlgoliaSearchBrowser.prototype._request = function request(url, opts) {
12764
- return new Promise(function wrapRequest(resolve, reject) {
12765
- // no cors or XDomainRequest, no request
12766
- if (!support.cors && !support.hasXDomainRequest) {
12767
- // very old browser, not supported
12768
- reject(new errors.Network('CORS not supported'));
12769
- return;
12770
- }
12771
-
12772
- url = inlineHeaders(url, opts.headers);
12773
-
12774
- var body = opts.body;
12775
- var req = support.cors ? new XMLHttpRequest() : new XDomainRequest();
12776
- var ontimeout;
12777
- var timedOut;
12778
-
12779
- // do not rely on default XHR async flag, as some analytics code like hotjar
12780
- // breaks it and set it to false by default
12781
- if (req instanceof XMLHttpRequest) {
12782
- req.open(opts.method, url, true);
12783
- } else {
12784
- req.open(opts.method, url);
12785
- }
12786
-
12787
- if (support.cors) {
12788
- if (body) {
12789
- if (opts.method === 'POST') {
12790
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests
12791
- req.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
12792
- } else {
12793
- req.setRequestHeader('content-type', 'application/json');
12794
- }
12795
- }
12796
- req.setRequestHeader('accept', 'application/json');
12797
- }
12798
-
12799
- // we set an empty onprogress listener
12800
- // so that XDomainRequest on IE9 is not aborted
12801
- // refs:
12802
- // - https://github.com/algolia/algoliasearch-client-js/issues/76
12803
- // - https://social.msdn.microsoft.com/Forums/ie/en-US/30ef3add-767c-4436-b8a9-f1ca19b4812e/ie9-rtm-xdomainrequest-issued-requests-may-abort-if-all-event-handlers-not-specified?forum=iewebdevelopment
12804
- req.onprogress = function noop() {};
12805
-
12806
- req.onload = load;
12807
- req.onerror = error;
12808
-
12809
- if (support.timeout) {
12810
- // .timeout supported by both XHR and XDR,
12811
- // we do receive timeout event, tested
12812
- req.timeout = opts.timeout;
12813
-
12814
- req.ontimeout = timeout;
12815
- } else {
12816
- ontimeout = setTimeout(timeout, opts.timeout);
12817
- }
12818
-
12819
- req.send(body);
12820
-
12821
- // event object not received in IE8, at least
12822
- // but we do not use it, still important to note
12823
- function load(/*event*/) {
12824
- // When browser does not supports req.timeout, we can
12825
- // have both a load and timeout event, since handled by a dumb setTimeout
12826
- if (timedOut) {
12827
- return;
12828
- }
12829
-
12830
- if (!support.timeout) {
12831
- clearTimeout(ontimeout);
12832
- }
12833
-
12834
- var out;
12835
-
12836
- try {
12837
- out = {
12838
- body: JSON.parse(req.responseText),
12839
- statusCode: req.status,
12840
- // XDomainRequest does not have any response headers
12841
- headers: req.getAllResponseHeaders && req.getAllResponseHeaders() || {}
12842
- };
12843
- } catch (e) {
12844
- out = new errors.UnparsableJSON({
12845
- more: req.responseText
12846
- });
12847
- }
12848
-
12849
- if (out instanceof errors.UnparsableJSON) {
12850
- reject(out);
12851
- } else {
12852
- resolve(out);
12853
- }
12854
- }
12855
-
12856
- function error(event) {
12857
- if (timedOut) {
12858
- return;
12859
- }
12860
-
12861
- if (!support.timeout) {
12862
- clearTimeout(ontimeout);
12863
- }
12864
-
12865
- // error event is trigerred both with XDR/XHR on:
12866
- // - DNS error
12867
- // - unallowed cross domain request
12868
- reject(
12869
- new errors.Network({
12870
- more: event
12871
- })
12872
- );
12873
- }
12874
-
12875
- function timeout() {
12876
- if (!support.timeout) {
12877
- timedOut = true;
12878
- req.abort();
12879
- }
12880
-
12881
- reject(new errors.RequestTimeout());
12882
- }
12883
- });
12884
- };
12885
-
12886
- AlgoliaSearchBrowser.prototype._request.fallback = function requestFallback(url, opts) {
12887
- url = inlineHeaders(url, opts.headers);
12888
-
12889
- return new Promise(function wrapJsonpRequest(resolve, reject) {
12890
- jsonpRequest(url, opts, function jsonpRequestDone(err, content) {
12891
- if (err) {
12892
- reject(err);
12893
- return;
12894
- }
12895
-
12896
- resolve(content);
12897
- });
12898
- });
12899
- };
12900
-
12901
- AlgoliaSearchBrowser.prototype._promise = {
12902
- reject: function rejectPromise(val) {
12903
- return Promise.reject(val);
12904
- },
12905
- resolve: function resolvePromise(val) {
12906
- return Promise.resolve(val);
12907
- },
12908
- delay: function delayPromise(ms) {
12909
- return new Promise(function resolveOnTimeout(resolve/*, reject*/) {
12910
- setTimeout(resolve, ms);
12911
- });
12912
- }
12913
- };
12914
-
12915
- },{"../../AlgoliaSearch":211,"../../errors":217,"../../version.json":218,"../get-document-protocol":214,"../inline-headers":215,"../jsonp-request":216,"debug":157,"es6-promise":160,"inherits":161,"lodash-compat/lang/cloneDeep":196}],214:[function(require,module,exports){
12916
- 'use strict';
12917
-
12918
- module.exports = getDocumentProtocol;
12919
-
12920
- function getDocumentProtocol() {
12921
- var protocol = window.document.location.protocol;
12922
-
12923
- // when in `file:` mode (local html file), default to `http:`
12924
- if (protocol !== 'http:' && protocol !== 'https:') {
12925
- protocol = 'http:';
12926
- }
12927
-
12928
- return protocol;
12929
- }
12930
-
12931
- },{}],215:[function(require,module,exports){
12932
- 'use strict';
12933
-
12934
- module.exports = inlineHeaders;
12935
-
12936
- var querystring = require('querystring');
12937
-
12938
- function inlineHeaders(url, headers) {
12939
- if (/\?/.test(url)) {
12940
- url += '&';
12941
- } else {
12942
- url += '?';
12943
- }
12944
-
12945
- return url + querystring.encode(headers);
12946
- }
12947
-
12948
- },{"querystring":224}],216:[function(require,module,exports){
12949
- 'use strict';
12950
-
12951
- module.exports = jsonpRequest;
12952
-
12953
- var errors = require('../errors');
12954
-
12955
- var JSONPCounter = 0;
12956
-
12957
- function jsonpRequest(url, opts, cb) {
12958
- if (opts.method !== 'GET') {
12959
- cb(new Error('Method ' + opts.method + ' ' + url + ' is not supported by JSONP.'));
12960
- return;
12961
- }
12962
-
12963
- opts.debug('JSONP: start');
12964
-
12965
- var cbCalled = false;
12966
- var timedOut = false;
12967
-
12968
- JSONPCounter += 1;
12969
- var head = document.getElementsByTagName('head')[0];
12970
- var script = document.createElement('script');
12971
- var cbName = 'algoliaJSONP_' + JSONPCounter;
12972
- var done = false;
12973
-
12974
- window[cbName] = function(data) {
12975
- try {
12976
- delete window[cbName];
12977
- } catch (e) {
12978
- window[cbName] = undefined;
12979
- }
12980
-
12981
- if (timedOut) {
12982
- return;
12983
- }
12984
-
12985
- cbCalled = true;
12986
-
12987
- clean();
12988
-
12989
- cb(null, {
12990
- body: data/*,
12991
- // We do not send the statusCode, there's no statusCode in JSONP, it will be
12992
- // computed using data.status && data.message like with XDR
12993
- statusCode*/
12994
- });
12995
- };
12996
-
12997
- // add callback by hand
12998
- url += '&callback=' + cbName;
12999
-
13000
- // add body params manually
13001
- if (opts.jsonBody && opts.jsonBody.params) {
13002
- url += '&' + opts.jsonBody.params;
13003
- }
13004
-
13005
- var ontimeout = setTimeout(timeout, opts.timeout);
13006
-
13007
- // script onreadystatechange needed only for
13008
- // <= IE8
13009
- // https://github.com/angular/angular.js/issues/4523
13010
- script.onreadystatechange = readystatechange;
13011
- script.onload = success;
13012
- script.onerror = error;
13013
-
13014
- script.async = true;
13015
- script.defer = true;
13016
- script.src = url;
13017
- head.appendChild(script);
13018
-
13019
- function success() {
13020
- opts.debug('JSONP: success');
13021
-
13022
- if (done || timedOut) {
13023
- return;
13024
- }
13025
-
13026
- done = true;
13027
-
13028
- // script loaded but did not call the fn => script loading error
13029
- if (!cbCalled) {
13030
- opts.debug('JSONP: Fail. Script loaded but did not call the callback');
13031
- clean();
13032
- cb(new errors.JSONPScriptFail());
13033
- }
13034
- }
13035
-
13036
- function readystatechange() {
13037
- if (this.readyState === 'loaded' || this.readyState === 'complete') {
13038
- success();
13039
- }
13040
- }
13041
-
13042
- function clean() {
13043
- clearTimeout(ontimeout);
13044
- script.onload = null;
13045
- script.onreadystatechange = null;
13046
- script.onerror = null;
13047
- head.removeChild(script);
13048
-
13049
- try {
13050
- delete window[cbName];
13051
- delete window[cbName + '_loaded'];
13052
- } catch (e) {
13053
- window[cbName] = null;
13054
- window[cbName + '_loaded'] = null;
13055
- }
13056
- }
13057
-
13058
- function timeout() {
13059
- opts.debug('JSONP: Script timeout');
13060
-
13061
- timedOut = true;
13062
- clean();
13063
- cb(new errors.RequestTimeout());
13064
- }
13065
-
13066
- function error() {
13067
- opts.debug('JSONP: Script error');
13068
-
13069
- if (done || timedOut) {
13070
- return;
13071
- }
13072
-
13073
- clean();
13074
- cb(new errors.JSONPScriptError());
13075
- }
13076
- }
13077
-
13078
- },{"../errors":217}],217:[function(require,module,exports){
13079
- 'use strict';
13080
-
13081
- // This file hosts our error definitions
13082
- // We use custom error "types" so that we can act on them when we need it
13083
- // e.g.: if error instanceof errors.UnparsableJSON then..
13084
-
13085
- var inherits = require('inherits');
13086
-
13087
- function AlgoliaSearchError(message, extraProperties) {
13088
- var forEach = require('lodash-compat/collection/forEach');
13089
-
13090
- var error = this;
13091
-
13092
- // try to get a stacktrace
13093
- if (typeof Error.captureStackTrace === 'function') {
13094
- Error.captureStackTrace(this, this.constructor);
13095
- } else {
13096
- error.stack = (new Error()).stack || 'Cannot get a stacktrace, browser is too old';
13097
- }
13098
-
13099
- this.name = this.constructor.name;
13100
- this.message = message || 'Unknown error';
13101
-
13102
- if (extraProperties) {
13103
- forEach(extraProperties, function addToErrorObject(value, key) {
13104
- error[key] = value;
13105
- });
13106
- }
13107
- }
13108
-
13109
- inherits(AlgoliaSearchError, Error);
13110
-
13111
- function createCustomError(name, message) {
13112
- function AlgoliaSearchCustomError() {
13113
- var args = Array.prototype.slice.call(arguments, 0);
13114
-
13115
- // custom message not set, use default
13116
- if (typeof args[0] !== 'string') {
13117
- args.unshift(message);
13118
- }
13119
-
13120
- AlgoliaSearchError.apply(this, args);
13121
- this.name = 'AlgoliaSearch' + name + 'Error';
13122
- }
13123
-
13124
- inherits(AlgoliaSearchCustomError, AlgoliaSearchError);
13125
-
13126
- return AlgoliaSearchCustomError;
13127
- }
13128
-
13129
- // late exports to let various fn defs and inherits take place
13130
- module.exports = {
13131
- AlgoliaSearchError: AlgoliaSearchError,
13132
- UnparsableJSON: createCustomError(
13133
- 'UnparsableJSON',
13134
- 'Could not parse the incoming response as JSON, see err.more for details'
13135
- ),
13136
- RequestTimeout: createCustomError(
13137
- 'RequestTimeout',
13138
- 'Request timedout before getting a response'
13139
- ),
13140
- Network: createCustomError(
13141
- 'Network',
13142
- 'Network issue, see err.more for details'
13143
- ),
13144
- JSONPScriptFail: createCustomError(
13145
- 'JSONPScriptFail',
13146
- '<script> was loaded but did not call our provided callback'
13147
- ),
13148
- JSONPScriptError: createCustomError(
13149
- 'JSONPScriptError',
13150
- '<script> unable to load due to an `error` event on it'
13151
- ),
13152
- Unknown: createCustomError(
13153
- 'Unknown',
13154
- 'Unknown error occured'
13155
- )
13156
- };
13157
-
13158
- },{"inherits":161,"lodash-compat/collection/forEach":162}],218:[function(require,module,exports){
13159
- module.exports="3.7.4"
13160
- },{}],219:[function(require,module,exports){
13161
- // Copyright Joyent, Inc. and other Node contributors.
13162
- //
13163
- // Permission is hereby granted, free of charge, to any person obtaining a
13164
- // copy of this software and associated documentation files (the
13165
- // "Software"), to deal in the Software without restriction, including
13166
- // without limitation the rights to use, copy, modify, merge, publish,
13167
- // distribute, sublicense, and/or sell copies of the Software, and to permit
13168
- // persons to whom the Software is furnished to do so, subject to the
13169
- // following conditions:
13170
- //
13171
- // The above copyright notice and this permission notice shall be included
13172
- // in all copies or substantial portions of the Software.
13173
- //
13174
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13175
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13176
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13177
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13178
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13179
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13180
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
13181
-
13182
- function EventEmitter() {
13183
- this._events = this._events || {};
13184
- this._maxListeners = this._maxListeners || undefined;
13185
- }
13186
- module.exports = EventEmitter;
13187
-
13188
- // Backwards-compat with node 0.10.x
13189
- EventEmitter.EventEmitter = EventEmitter;
13190
-
13191
- EventEmitter.prototype._events = undefined;
13192
- EventEmitter.prototype._maxListeners = undefined;
13193
-
13194
- // By default EventEmitters will print a warning if more than 10 listeners are
13195
- // added to it. This is a useful default which helps finding memory leaks.
13196
- EventEmitter.defaultMaxListeners = 10;
13197
-
13198
- // Obviously not all Emitters should be limited to 10. This function allows
13199
- // that to be increased. Set to zero for unlimited.
13200
- EventEmitter.prototype.setMaxListeners = function(n) {
13201
- if (!isNumber(n) || n < 0 || isNaN(n))
13202
- throw TypeError('n must be a positive number');
13203
- this._maxListeners = n;
13204
- return this;
13205
- };
13206
-
13207
- EventEmitter.prototype.emit = function(type) {
13208
- var er, handler, len, args, i, listeners;
13209
-
13210
- if (!this._events)
13211
- this._events = {};
13212
-
13213
- // If there is no 'error' event listener then throw.
13214
- if (type === 'error') {
13215
- if (!this._events.error ||
13216
- (isObject(this._events.error) && !this._events.error.length)) {
13217
- er = arguments[1];
13218
- if (er instanceof Error) {
13219
- throw er; // Unhandled 'error' event
13220
- }
13221
- throw TypeError('Uncaught, unspecified "error" event.');
13222
- }
13223
- }
13224
-
13225
- handler = this._events[type];
13226
-
13227
- if (isUndefined(handler))
13228
- return false;
13229
-
13230
- if (isFunction(handler)) {
13231
- switch (arguments.length) {
13232
- // fast cases
13233
- case 1:
13234
- handler.call(this);
13235
- break;
13236
- case 2:
13237
- handler.call(this, arguments[1]);
13238
- break;
13239
- case 3:
13240
- handler.call(this, arguments[1], arguments[2]);
13241
- break;
13242
- // slower
13243
- default:
13244
- len = arguments.length;
13245
- args = new Array(len - 1);
13246
- for (i = 1; i < len; i++)
13247
- args[i - 1] = arguments[i];
13248
- handler.apply(this, args);
13249
- }
13250
- } else if (isObject(handler)) {
13251
- len = arguments.length;
13252
- args = new Array(len - 1);
13253
- for (i = 1; i < len; i++)
13254
- args[i - 1] = arguments[i];
13255
-
13256
- listeners = handler.slice();
13257
- len = listeners.length;
13258
- for (i = 0; i < len; i++)
13259
- listeners[i].apply(this, args);
13260
- }
13261
-
13262
- return true;
13263
- };
13264
-
13265
- EventEmitter.prototype.addListener = function(type, listener) {
13266
- var m;
13267
-
13268
- if (!isFunction(listener))
13269
- throw TypeError('listener must be a function');
13270
-
13271
- if (!this._events)
13272
- this._events = {};
13273
-
13274
- // To avoid recursion in the case that type === "newListener"! Before
13275
- // adding it to the listeners, first emit "newListener".
13276
- if (this._events.newListener)
13277
- this.emit('newListener', type,
13278
- isFunction(listener.listener) ?
13279
- listener.listener : listener);
13280
-
13281
- if (!this._events[type])
13282
- // Optimize the case of one listener. Don't need the extra array object.
13283
- this._events[type] = listener;
13284
- else if (isObject(this._events[type]))
13285
- // If we've already got an array, just append.
13286
- this._events[type].push(listener);
13287
- else
13288
- // Adding the second element, need to change to array.
13289
- this._events[type] = [this._events[type], listener];
13290
-
13291
- // Check for listener leak
13292
- if (isObject(this._events[type]) && !this._events[type].warned) {
13293
- var m;
13294
- if (!isUndefined(this._maxListeners)) {
13295
- m = this._maxListeners;
13296
- } else {
13297
- m = EventEmitter.defaultMaxListeners;
13298
- }
13299
-
13300
- if (m && m > 0 && this._events[type].length > m) {
13301
- this._events[type].warned = true;
13302
- console.error('(node) warning: possible EventEmitter memory ' +
13303
- 'leak detected. %d listeners added. ' +
13304
- 'Use emitter.setMaxListeners() to increase limit.',
13305
- this._events[type].length);
13306
- if (typeof console.trace === 'function') {
13307
- // not supported in IE 10
13308
- console.trace();
13309
- }
13310
- }
13311
- }
13312
-
13313
- return this;
13314
- };
13315
-
13316
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
13317
-
13318
- EventEmitter.prototype.once = function(type, listener) {
13319
- if (!isFunction(listener))
13320
- throw TypeError('listener must be a function');
13321
-
13322
- var fired = false;
13323
-
13324
- function g() {
13325
- this.removeListener(type, g);
13326
-
13327
- if (!fired) {
13328
- fired = true;
13329
- listener.apply(this, arguments);
13330
- }
13331
- }
13332
-
13333
- g.listener = listener;
13334
- this.on(type, g);
13335
-
13336
- return this;
13337
- };
13338
-
13339
- // emits a 'removeListener' event iff the listener was removed
13340
- EventEmitter.prototype.removeListener = function(type, listener) {
13341
- var list, position, length, i;
13342
-
13343
- if (!isFunction(listener))
13344
- throw TypeError('listener must be a function');
13345
-
13346
- if (!this._events || !this._events[type])
13347
- return this;
13348
-
13349
- list = this._events[type];
13350
- length = list.length;
13351
- position = -1;
13352
-
13353
- if (list === listener ||
13354
- (isFunction(list.listener) && list.listener === listener)) {
13355
- delete this._events[type];
13356
- if (this._events.removeListener)
13357
- this.emit('removeListener', type, listener);
13358
-
13359
- } else if (isObject(list)) {
13360
- for (i = length; i-- > 0;) {
13361
- if (list[i] === listener ||
13362
- (list[i].listener && list[i].listener === listener)) {
13363
- position = i;
13364
- break;
13365
- }
13366
- }
13367
-
13368
- if (position < 0)
13369
- return this;
13370
-
13371
- if (list.length === 1) {
13372
- list.length = 0;
13373
- delete this._events[type];
13374
- } else {
13375
- list.splice(position, 1);
13376
- }
13377
-
13378
- if (this._events.removeListener)
13379
- this.emit('removeListener', type, listener);
13380
- }
13381
-
13382
- return this;
13383
- };
13384
-
13385
- EventEmitter.prototype.removeAllListeners = function(type) {
13386
- var key, listeners;
13387
-
13388
- if (!this._events)
13389
- return this;
13390
-
13391
- // not listening for removeListener, no need to emit
13392
- if (!this._events.removeListener) {
13393
- if (arguments.length === 0)
13394
- this._events = {};
13395
- else if (this._events[type])
13396
- delete this._events[type];
13397
- return this;
13398
- }
13399
-
13400
- // emit removeListener for all listeners on all events
13401
- if (arguments.length === 0) {
13402
- for (key in this._events) {
13403
- if (key === 'removeListener') continue;
13404
- this.removeAllListeners(key);
13405
- }
13406
- this.removeAllListeners('removeListener');
13407
- this._events = {};
13408
- return this;
13409
- }
13410
-
13411
- listeners = this._events[type];
13412
-
13413
- if (isFunction(listeners)) {
13414
- this.removeListener(type, listeners);
13415
- } else {
13416
- // LIFO order
13417
- while (listeners.length)
13418
- this.removeListener(type, listeners[listeners.length - 1]);
13419
- }
13420
- delete this._events[type];
13421
-
13422
- return this;
13423
- };
13424
-
13425
- EventEmitter.prototype.listeners = function(type) {
13426
- var ret;
13427
- if (!this._events || !this._events[type])
13428
- ret = [];
13429
- else if (isFunction(this._events[type]))
13430
- ret = [this._events[type]];
13431
- else
13432
- ret = this._events[type].slice();
13433
- return ret;
13434
- };
13435
-
13436
- EventEmitter.listenerCount = function(emitter, type) {
13437
- var ret;
13438
- if (!emitter._events || !emitter._events[type])
13439
- ret = 0;
13440
- else if (isFunction(emitter._events[type]))
13441
- ret = 1;
13442
- else
13443
- ret = emitter._events[type].length;
13444
- return ret;
13445
- };
13446
-
13447
- function isFunction(arg) {
13448
- return typeof arg === 'function';
13449
- }
13450
-
13451
- function isNumber(arg) {
13452
- return typeof arg === 'number';
13453
- }
13454
-
13455
- function isObject(arg) {
13456
- return typeof arg === 'object' && arg !== null;
13457
- }
13458
-
13459
- function isUndefined(arg) {
13460
- return arg === void 0;
13461
- }
13462
-
13463
- },{}],220:[function(require,module,exports){
13464
- arguments[4][161][0].apply(exports,arguments)
13465
- },{"dup":161}],221:[function(require,module,exports){
13466
- // shim for using process in browser
13467
-
13468
- var process = module.exports = {};
13469
- var queue = [];
13470
- var draining = false;
13471
- var currentQueue;
13472
- var queueIndex = -1;
13473
-
13474
- function cleanUpNextTick() {
13475
- draining = false;
13476
- if (currentQueue.length) {
13477
- queue = currentQueue.concat(queue);
13478
- } else {
13479
- queueIndex = -1;
13480
- }
13481
- if (queue.length) {
13482
- drainQueue();
13483
- }
13484
- }
13485
-
13486
- function drainQueue() {
13487
- if (draining) {
13488
- return;
13489
- }
13490
- var timeout = setTimeout(cleanUpNextTick);
13491
- draining = true;
13492
-
13493
- var len = queue.length;
13494
- while(len) {
13495
- currentQueue = queue;
13496
- queue = [];
13497
- while (++queueIndex < len) {
13498
- currentQueue[queueIndex].run();
13499
- }
13500
- queueIndex = -1;
13501
- len = queue.length;
13502
- }
13503
- currentQueue = null;
13504
- draining = false;
13505
- clearTimeout(timeout);
13506
- }
13507
-
13508
- process.nextTick = function (fun) {
13509
- var args = new Array(arguments.length - 1);
13510
- if (arguments.length > 1) {
13511
- for (var i = 1; i < arguments.length; i++) {
13512
- args[i - 1] = arguments[i];
13513
- }
13514
- }
13515
- queue.push(new Item(fun, args));
13516
- if (queue.length === 1 && !draining) {
13517
- setTimeout(drainQueue, 0);
13518
- }
13519
- };
13520
-
13521
- // v8 likes predictible objects
13522
- function Item(fun, array) {
13523
- this.fun = fun;
13524
- this.array = array;
13525
- }
13526
- Item.prototype.run = function () {
13527
- this.fun.apply(null, this.array);
13528
- };
13529
- process.title = 'browser';
13530
- process.browser = true;
13531
- process.env = {};
13532
- process.argv = [];
13533
- process.version = ''; // empty string to avoid regexp issues
13534
- process.versions = {};
13535
-
13536
- function noop() {}
13537
-
13538
- process.on = noop;
13539
- process.addListener = noop;
13540
- process.once = noop;
13541
- process.off = noop;
13542
- process.removeListener = noop;
13543
- process.removeAllListeners = noop;
13544
- process.emit = noop;
13545
-
13546
- process.binding = function (name) {
13547
- throw new Error('process.binding is not supported');
13548
- };
13549
-
13550
- // TODO(shtylman)
13551
- process.cwd = function () { return '/' };
13552
- process.chdir = function (dir) {
13553
- throw new Error('process.chdir is not supported');
13554
- };
13555
- process.umask = function() { return 0; };
13556
-
13557
- },{}],222:[function(require,module,exports){
13558
- // Copyright Joyent, Inc. and other Node contributors.
13559
- //
13560
- // Permission is hereby granted, free of charge, to any person obtaining a
13561
- // copy of this software and associated documentation files (the
13562
- // "Software"), to deal in the Software without restriction, including
13563
- // without limitation the rights to use, copy, modify, merge, publish,
13564
- // distribute, sublicense, and/or sell copies of the Software, and to permit
13565
- // persons to whom the Software is furnished to do so, subject to the
13566
- // following conditions:
13567
- //
13568
- // The above copyright notice and this permission notice shall be included
13569
- // in all copies or substantial portions of the Software.
13570
- //
13571
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13572
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13573
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13574
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13575
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13576
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13577
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
13578
-
13579
- 'use strict';
13580
-
13581
- // If obj.hasOwnProperty has been overridden, then calling
13582
- // obj.hasOwnProperty(prop) will break.
13583
- // See: https://github.com/joyent/node/issues/1707
13584
- function hasOwnProperty(obj, prop) {
13585
- return Object.prototype.hasOwnProperty.call(obj, prop);
13586
- }
13587
-
13588
- module.exports = function(qs, sep, eq, options) {
13589
- sep = sep || '&';
13590
- eq = eq || '=';
13591
- var obj = {};
13592
-
13593
- if (typeof qs !== 'string' || qs.length === 0) {
13594
- return obj;
13595
- }
13596
-
13597
- var regexp = /\+/g;
13598
- qs = qs.split(sep);
13599
-
13600
- var maxKeys = 1000;
13601
- if (options && typeof options.maxKeys === 'number') {
13602
- maxKeys = options.maxKeys;
13603
- }
13604
-
13605
- var len = qs.length;
13606
- // maxKeys <= 0 means that we should not limit keys count
13607
- if (maxKeys > 0 && len > maxKeys) {
13608
- len = maxKeys;
13609
- }
13610
-
13611
- for (var i = 0; i < len; ++i) {
13612
- var x = qs[i].replace(regexp, '%20'),
13613
- idx = x.indexOf(eq),
13614
- kstr, vstr, k, v;
13615
-
13616
- if (idx >= 0) {
13617
- kstr = x.substr(0, idx);
13618
- vstr = x.substr(idx + 1);
13619
- } else {
13620
- kstr = x;
13621
- vstr = '';
13622
- }
13623
-
13624
- k = decodeURIComponent(kstr);
13625
- v = decodeURIComponent(vstr);
13626
-
13627
- if (!hasOwnProperty(obj, k)) {
13628
- obj[k] = v;
13629
- } else if (isArray(obj[k])) {
13630
- obj[k].push(v);
13631
- } else {
13632
- obj[k] = [obj[k], v];
13633
- }
13634
- }
13635
-
13636
- return obj;
13637
- };
13638
-
13639
- var isArray = Array.isArray || function (xs) {
13640
- return Object.prototype.toString.call(xs) === '[object Array]';
13641
- };
13642
-
13643
- },{}],223:[function(require,module,exports){
13644
- // Copyright Joyent, Inc. and other Node contributors.
13645
- //
13646
- // Permission is hereby granted, free of charge, to any person obtaining a
13647
- // copy of this software and associated documentation files (the
13648
- // "Software"), to deal in the Software without restriction, including
13649
- // without limitation the rights to use, copy, modify, merge, publish,
13650
- // distribute, sublicense, and/or sell copies of the Software, and to permit
13651
- // persons to whom the Software is furnished to do so, subject to the
13652
- // following conditions:
13653
- //
13654
- // The above copyright notice and this permission notice shall be included
13655
- // in all copies or substantial portions of the Software.
13656
- //
13657
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13658
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13659
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13660
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13661
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13662
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13663
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
13664
-
13665
- 'use strict';
13666
-
13667
- var stringifyPrimitive = function(v) {
13668
- switch (typeof v) {
13669
- case 'string':
13670
- return v;
13671
-
13672
- case 'boolean':
13673
- return v ? 'true' : 'false';
13674
-
13675
- case 'number':
13676
- return isFinite(v) ? v : '';
13677
-
13678
- default:
13679
- return '';
13680
- }
13681
- };
13682
-
13683
- module.exports = function(obj, sep, eq, name) {
13684
- sep = sep || '&';
13685
- eq = eq || '=';
13686
- if (obj === null) {
13687
- obj = undefined;
13688
- }
13689
-
13690
- if (typeof obj === 'object') {
13691
- return map(objectKeys(obj), function(k) {
13692
- var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
13693
- if (isArray(obj[k])) {
13694
- return map(obj[k], function(v) {
13695
- return ks + encodeURIComponent(stringifyPrimitive(v));
13696
- }).join(sep);
13697
- } else {
13698
- return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
13699
- }
13700
- }).join(sep);
13701
-
13702
- }
13703
-
13704
- if (!name) return '';
13705
- return encodeURIComponent(stringifyPrimitive(name)) + eq +
13706
- encodeURIComponent(stringifyPrimitive(obj));
13707
- };
13708
-
13709
- var isArray = Array.isArray || function (xs) {
13710
- return Object.prototype.toString.call(xs) === '[object Array]';
13711
- };
13712
-
13713
- function map (xs, f) {
13714
- if (xs.map) return xs.map(f);
13715
- var res = [];
13716
- for (var i = 0; i < xs.length; i++) {
13717
- res.push(f(xs[i], i));
13718
- }
13719
- return res;
13720
- }
13721
-
13722
- var objectKeys = Object.keys || function (obj) {
13723
- var res = [];
13724
- for (var key in obj) {
13725
- if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
13726
- }
13727
- return res;
13728
- };
13729
-
13730
- },{}],224:[function(require,module,exports){
13731
- 'use strict';
13732
-
13733
- exports.decode = exports.parse = require('./decode');
13734
- exports.encode = exports.stringify = require('./encode');
13735
-
13736
- },{"./decode":222,"./encode":223}],225:[function(require,module,exports){
13737
- module.exports = function isBuffer(arg) {
13738
- return arg && typeof arg === 'object'
13739
- && typeof arg.copy === 'function'
13740
- && typeof arg.fill === 'function'
13741
- && typeof arg.readUInt8 === 'function';
13742
- }
13743
- },{}],226:[function(require,module,exports){
13744
- (function (process,global){
13745
- // Copyright Joyent, Inc. and other Node contributors.
13746
- //
13747
- // Permission is hereby granted, free of charge, to any person obtaining a
13748
- // copy of this software and associated documentation files (the
13749
- // "Software"), to deal in the Software without restriction, including
13750
- // without limitation the rights to use, copy, modify, merge, publish,
13751
- // distribute, sublicense, and/or sell copies of the Software, and to permit
13752
- // persons to whom the Software is furnished to do so, subject to the
13753
- // following conditions:
13754
- //
13755
- // The above copyright notice and this permission notice shall be included
13756
- // in all copies or substantial portions of the Software.
13757
- //
13758
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13759
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13760
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13761
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13762
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13763
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13764
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
13765
-
13766
- var formatRegExp = /%[sdj%]/g;
13767
- exports.format = function(f) {
13768
- if (!isString(f)) {
13769
- var objects = [];
13770
- for (var i = 0; i < arguments.length; i++) {
13771
- objects.push(inspect(arguments[i]));
13772
- }
13773
- return objects.join(' ');
13774
- }
13775
-
13776
- var i = 1;
13777
- var args = arguments;
13778
- var len = args.length;
13779
- var str = String(f).replace(formatRegExp, function(x) {
13780
- if (x === '%%') return '%';
13781
- if (i >= len) return x;
13782
- switch (x) {
13783
- case '%s': return String(args[i++]);
13784
- case '%d': return Number(args[i++]);
13785
- case '%j':
13786
- try {
13787
- return JSON.stringify(args[i++]);
13788
- } catch (_) {
13789
- return '[Circular]';
13790
- }
13791
- default:
13792
- return x;
13793
- }
13794
- });
13795
- for (var x = args[i]; i < len; x = args[++i]) {
13796
- if (isNull(x) || !isObject(x)) {
13797
- str += ' ' + x;
13798
- } else {
13799
- str += ' ' + inspect(x);
13800
- }
13801
- }
13802
- return str;
13803
- };
13804
-
13805
-
13806
- // Mark that a method should not be used.
13807
- // Returns a modified function which warns once by default.
13808
- // If --no-deprecation is set, then it is a no-op.
13809
- exports.deprecate = function(fn, msg) {
13810
- // Allow for deprecating things in the process of starting up.
13811
- if (isUndefined(global.process)) {
13812
- return function() {
13813
- return exports.deprecate(fn, msg).apply(this, arguments);
13814
- };
13815
- }
13816
-
13817
- if (process.noDeprecation === true) {
13818
- return fn;
13819
- }
13820
-
13821
- var warned = false;
13822
- function deprecated() {
13823
- if (!warned) {
13824
- if (process.throwDeprecation) {
13825
- throw new Error(msg);
13826
- } else if (process.traceDeprecation) {
13827
- console.trace(msg);
13828
- } else {
13829
- console.error(msg);
13830
- }
13831
- warned = true;
13832
- }
13833
- return fn.apply(this, arguments);
13834
- }
13835
-
13836
- return deprecated;
13837
- };
13838
-
13839
-
13840
- var debugs = {};
13841
- var debugEnviron;
13842
- exports.debuglog = function(set) {
13843
- if (isUndefined(debugEnviron))
13844
- debugEnviron = process.env.NODE_DEBUG || '';
13845
- set = set.toUpperCase();
13846
- if (!debugs[set]) {
13847
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
13848
- var pid = process.pid;
13849
- debugs[set] = function() {
13850
- var msg = exports.format.apply(exports, arguments);
13851
- console.error('%s %d: %s', set, pid, msg);
13852
- };
13853
- } else {
13854
- debugs[set] = function() {};
13855
- }
13856
- }
13857
- return debugs[set];
13858
- };
13859
-
13860
-
13861
- /**
13862
- * Echos the value of a value. Trys to print the value out
13863
- * in the best way possible given the different types.
13864
- *
13865
- * @param {Object} obj The object to print out.
13866
- * @param {Object} opts Optional options object that alters the output.
13867
- */
13868
- /* legacy: obj, showHidden, depth, colors*/
13869
- function inspect(obj, opts) {
13870
- // default options
13871
- var ctx = {
13872
- seen: [],
13873
- stylize: stylizeNoColor
13874
- };
13875
- // legacy...
13876
- if (arguments.length >= 3) ctx.depth = arguments[2];
13877
- if (arguments.length >= 4) ctx.colors = arguments[3];
13878
- if (isBoolean(opts)) {
13879
- // legacy...
13880
- ctx.showHidden = opts;
13881
- } else if (opts) {
13882
- // got an "options" object
13883
- exports._extend(ctx, opts);
13884
- }
13885
- // set default options
13886
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
13887
- if (isUndefined(ctx.depth)) ctx.depth = 2;
13888
- if (isUndefined(ctx.colors)) ctx.colors = false;
13889
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
13890
- if (ctx.colors) ctx.stylize = stylizeWithColor;
13891
- return formatValue(ctx, obj, ctx.depth);
13892
- }
13893
- exports.inspect = inspect;
13894
-
13895
-
13896
- // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
13897
- inspect.colors = {
13898
- 'bold' : [1, 22],
13899
- 'italic' : [3, 23],
13900
- 'underline' : [4, 24],
13901
- 'inverse' : [7, 27],
13902
- 'white' : [37, 39],
13903
- 'grey' : [90, 39],
13904
- 'black' : [30, 39],
13905
- 'blue' : [34, 39],
13906
- 'cyan' : [36, 39],
13907
- 'green' : [32, 39],
13908
- 'magenta' : [35, 39],
13909
- 'red' : [31, 39],
13910
- 'yellow' : [33, 39]
13911
- };
13912
-
13913
- // Don't use 'blue' not visible on cmd.exe
13914
- inspect.styles = {
13915
- 'special': 'cyan',
13916
- 'number': 'yellow',
13917
- 'boolean': 'yellow',
13918
- 'undefined': 'grey',
13919
- 'null': 'bold',
13920
- 'string': 'green',
13921
- 'date': 'magenta',
13922
- // "name": intentionally not styling
13923
- 'regexp': 'red'
13924
- };
13925
-
13926
-
13927
- function stylizeWithColor(str, styleType) {
13928
- var style = inspect.styles[styleType];
13929
-
13930
- if (style) {
13931
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
13932
- '\u001b[' + inspect.colors[style][1] + 'm';
13933
- } else {
13934
- return str;
13935
- }
13936
- }
13937
-
13938
-
13939
- function stylizeNoColor(str, styleType) {
13940
- return str;
13941
- }
13942
-
13943
-
13944
- function arrayToHash(array) {
13945
- var hash = {};
13946
-
13947
- array.forEach(function(val, idx) {
13948
- hash[val] = true;
13949
- });
13950
-
13951
- return hash;
13952
- }
13953
-
13954
-
13955
- function formatValue(ctx, value, recurseTimes) {
13956
- // Provide a hook for user-specified inspect functions.
13957
- // Check that value is an object with an inspect function on it
13958
- if (ctx.customInspect &&
13959
- value &&
13960
- isFunction(value.inspect) &&
13961
- // Filter out the util module, it's inspect function is special
13962
- value.inspect !== exports.inspect &&
13963
- // Also filter out any prototype objects using the circular check.
13964
- !(value.constructor && value.constructor.prototype === value)) {
13965
- var ret = value.inspect(recurseTimes, ctx);
13966
- if (!isString(ret)) {
13967
- ret = formatValue(ctx, ret, recurseTimes);
13968
- }
13969
- return ret;
13970
- }
13971
-
13972
- // Primitive types cannot have properties
13973
- var primitive = formatPrimitive(ctx, value);
13974
- if (primitive) {
13975
- return primitive;
13976
- }
13977
-
13978
- // Look up the keys of the object.
13979
- var keys = Object.keys(value);
13980
- var visibleKeys = arrayToHash(keys);
13981
-
13982
- if (ctx.showHidden) {
13983
- keys = Object.getOwnPropertyNames(value);
13984
- }
13985
-
13986
- // IE doesn't make error fields non-enumerable
13987
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
13988
- if (isError(value)
13989
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
13990
- return formatError(value);
13991
- }
13992
-
13993
- // Some type of object without properties can be shortcutted.
13994
- if (keys.length === 0) {
13995
- if (isFunction(value)) {
13996
- var name = value.name ? ': ' + value.name : '';
13997
- return ctx.stylize('[Function' + name + ']', 'special');
13998
- }
13999
- if (isRegExp(value)) {
14000
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
14001
- }
14002
- if (isDate(value)) {
14003
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
14004
- }
14005
- if (isError(value)) {
14006
- return formatError(value);
14007
- }
14008
- }
14009
-
14010
- var base = '', array = false, braces = ['{', '}'];
14011
-
14012
- // Make Array say that they are Array
14013
- if (isArray(value)) {
14014
- array = true;
14015
- braces = ['[', ']'];
14016
- }
14017
-
14018
- // Make functions say that they are functions
14019
- if (isFunction(value)) {
14020
- var n = value.name ? ': ' + value.name : '';
14021
- base = ' [Function' + n + ']';
14022
- }
14023
-
14024
- // Make RegExps say that they are RegExps
14025
- if (isRegExp(value)) {
14026
- base = ' ' + RegExp.prototype.toString.call(value);
14027
- }
14028
-
14029
- // Make dates with properties first say the date
14030
- if (isDate(value)) {
14031
- base = ' ' + Date.prototype.toUTCString.call(value);
14032
- }
14033
-
14034
- // Make error with message first say the error
14035
- if (isError(value)) {
14036
- base = ' ' + formatError(value);
14037
- }
14038
-
14039
- if (keys.length === 0 && (!array || value.length == 0)) {
14040
- return braces[0] + base + braces[1];
14041
- }
14042
-
14043
- if (recurseTimes < 0) {
14044
- if (isRegExp(value)) {
14045
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
14046
- } else {
14047
- return ctx.stylize('[Object]', 'special');
14048
- }
14049
- }
14050
-
14051
- ctx.seen.push(value);
14052
-
14053
- var output;
14054
- if (array) {
14055
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
14056
- } else {
14057
- output = keys.map(function(key) {
14058
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
14059
- });
14060
- }
14061
-
14062
- ctx.seen.pop();
14063
-
14064
- return reduceToSingleString(output, base, braces);
14065
- }
14066
-
14067
-
14068
- function formatPrimitive(ctx, value) {
14069
- if (isUndefined(value))
14070
- return ctx.stylize('undefined', 'undefined');
14071
- if (isString(value)) {
14072
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
14073
- .replace(/'/g, "\\'")
14074
- .replace(/\\"/g, '"') + '\'';
14075
- return ctx.stylize(simple, 'string');
14076
- }
14077
- if (isNumber(value))
14078
- return ctx.stylize('' + value, 'number');
14079
- if (isBoolean(value))
14080
- return ctx.stylize('' + value, 'boolean');
14081
- // For some reason typeof null is "object", so special case here.
14082
- if (isNull(value))
14083
- return ctx.stylize('null', 'null');
14084
- }
14085
-
14086
-
14087
- function formatError(value) {
14088
- return '[' + Error.prototype.toString.call(value) + ']';
14089
- }
14090
-
14091
-
14092
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
14093
- var output = [];
14094
- for (var i = 0, l = value.length; i < l; ++i) {
14095
- if (hasOwnProperty(value, String(i))) {
14096
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
14097
- String(i), true));
14098
- } else {
14099
- output.push('');
14100
- }
14101
- }
14102
- keys.forEach(function(key) {
14103
- if (!key.match(/^\d+$/)) {
14104
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
14105
- key, true));
14106
- }
14107
- });
14108
- return output;
14109
- }
14110
-
14111
-
14112
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
14113
- var name, str, desc;
14114
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
14115
- if (desc.get) {
14116
- if (desc.set) {
14117
- str = ctx.stylize('[Getter/Setter]', 'special');
14118
- } else {
14119
- str = ctx.stylize('[Getter]', 'special');
14120
- }
14121
- } else {
14122
- if (desc.set) {
14123
- str = ctx.stylize('[Setter]', 'special');
14124
- }
14125
- }
14126
- if (!hasOwnProperty(visibleKeys, key)) {
14127
- name = '[' + key + ']';
14128
- }
14129
- if (!str) {
14130
- if (ctx.seen.indexOf(desc.value) < 0) {
14131
- if (isNull(recurseTimes)) {
14132
- str = formatValue(ctx, desc.value, null);
14133
- } else {
14134
- str = formatValue(ctx, desc.value, recurseTimes - 1);
14135
- }
14136
- if (str.indexOf('\n') > -1) {
14137
- if (array) {
14138
- str = str.split('\n').map(function(line) {
14139
- return ' ' + line;
14140
- }).join('\n').substr(2);
14141
- } else {
14142
- str = '\n' + str.split('\n').map(function(line) {
14143
- return ' ' + line;
14144
- }).join('\n');
14145
- }
14146
- }
14147
- } else {
14148
- str = ctx.stylize('[Circular]', 'special');
14149
- }
14150
- }
14151
- if (isUndefined(name)) {
14152
- if (array && key.match(/^\d+$/)) {
14153
- return str;
14154
- }
14155
- name = JSON.stringify('' + key);
14156
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
14157
- name = name.substr(1, name.length - 2);
14158
- name = ctx.stylize(name, 'name');
14159
- } else {
14160
- name = name.replace(/'/g, "\\'")
14161
- .replace(/\\"/g, '"')
14162
- .replace(/(^"|"$)/g, "'");
14163
- name = ctx.stylize(name, 'string');
14164
- }
14165
- }
14166
-
14167
- return name + ': ' + str;
14168
- }
14169
-
14170
-
14171
- function reduceToSingleString(output, base, braces) {
14172
- var numLinesEst = 0;
14173
- var length = output.reduce(function(prev, cur) {
14174
- numLinesEst++;
14175
- if (cur.indexOf('\n') >= 0) numLinesEst++;
14176
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
14177
- }, 0);
14178
-
14179
- if (length > 60) {
14180
- return braces[0] +
14181
- (base === '' ? '' : base + '\n ') +
14182
- ' ' +
14183
- output.join(',\n ') +
14184
- ' ' +
14185
- braces[1];
14186
- }
14187
-
14188
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
14189
- }
14190
-
14191
-
14192
- // NOTE: These type checking functions intentionally don't use `instanceof`
14193
- // because it is fragile and can be easily faked with `Object.create()`.
14194
- function isArray(ar) {
14195
- return Array.isArray(ar);
14196
- }
14197
- exports.isArray = isArray;
14198
-
14199
- function isBoolean(arg) {
14200
- return typeof arg === 'boolean';
14201
- }
14202
- exports.isBoolean = isBoolean;
14203
-
14204
- function isNull(arg) {
14205
- return arg === null;
14206
- }
14207
- exports.isNull = isNull;
14208
-
14209
- function isNullOrUndefined(arg) {
14210
- return arg == null;
14211
- }
14212
- exports.isNullOrUndefined = isNullOrUndefined;
14213
-
14214
- function isNumber(arg) {
14215
- return typeof arg === 'number';
14216
- }
14217
- exports.isNumber = isNumber;
14218
-
14219
- function isString(arg) {
14220
- return typeof arg === 'string';
14221
- }
14222
- exports.isString = isString;
14223
-
14224
- function isSymbol(arg) {
14225
- return typeof arg === 'symbol';
14226
- }
14227
- exports.isSymbol = isSymbol;
14228
-
14229
- function isUndefined(arg) {
14230
- return arg === void 0;
14231
- }
14232
- exports.isUndefined = isUndefined;
14233
-
14234
- function isRegExp(re) {
14235
- return isObject(re) && objectToString(re) === '[object RegExp]';
14236
- }
14237
- exports.isRegExp = isRegExp;
14238
-
14239
- function isObject(arg) {
14240
- return typeof arg === 'object' && arg !== null;
14241
- }
14242
- exports.isObject = isObject;
14243
-
14244
- function isDate(d) {
14245
- return isObject(d) && objectToString(d) === '[object Date]';
14246
- }
14247
- exports.isDate = isDate;
14248
-
14249
- function isError(e) {
14250
- return isObject(e) &&
14251
- (objectToString(e) === '[object Error]' || e instanceof Error);
14252
- }
14253
- exports.isError = isError;
14254
-
14255
- function isFunction(arg) {
14256
- return typeof arg === 'function';
14257
- }
14258
- exports.isFunction = isFunction;
14259
-
14260
- function isPrimitive(arg) {
14261
- return arg === null ||
14262
- typeof arg === 'boolean' ||
14263
- typeof arg === 'number' ||
14264
- typeof arg === 'string' ||
14265
- typeof arg === 'symbol' || // ES6 symbol
14266
- typeof arg === 'undefined';
14267
- }
14268
- exports.isPrimitive = isPrimitive;
14269
-
14270
- exports.isBuffer = require('./support/isBuffer');
14271
-
14272
- function objectToString(o) {
14273
- return Object.prototype.toString.call(o);
14274
- }
14275
-
14276
-
14277
- function pad(n) {
14278
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
14279
- }
14280
-
14281
-
14282
- var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
14283
- 'Oct', 'Nov', 'Dec'];
14284
-
14285
- // 26 Feb 16:19:34
14286
- function timestamp() {
14287
- var d = new Date();
14288
- var time = [pad(d.getHours()),
14289
- pad(d.getMinutes()),
14290
- pad(d.getSeconds())].join(':');
14291
- return [d.getDate(), months[d.getMonth()], time].join(' ');
14292
- }
14293
-
14294
-
14295
- // log is just a thin wrapper to console.log that prepends a timestamp
14296
- exports.log = function() {
14297
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
14298
- };
14299
-
14300
-
14301
- /**
14302
- * Inherit the prototype methods from one constructor into another.
14303
- *
14304
- * The Function.prototype.inherits from lang.js rewritten as a standalone
14305
- * function (not on Function.prototype). NOTE: If this file is to be loaded
14306
- * during bootstrapping this function needs to be rewritten using some native
14307
- * functions as prototype setup using normal JavaScript does not work as
14308
- * expected during bootstrapping (see mirror.js in r114903).
14309
- *
14310
- * @param {function} ctor Constructor function which needs to inherit the
14311
- * prototype.
14312
- * @param {function} superCtor Constructor function to inherit prototype from.
14313
- */
14314
- exports.inherits = require('inherits');
14315
-
14316
- exports._extend = function(origin, add) {
14317
- // Don't do anything if add isn't an object
14318
- if (!add || !isObject(add)) return origin;
14319
-
14320
- var keys = Object.keys(add);
14321
- var i = keys.length;
14322
- while (i--) {
14323
- origin[keys[i]] = add[keys[i]];
14324
- }
14325
- return origin;
14326
- };
14327
-
14328
- function hasOwnProperty(obj, prop) {
14329
- return Object.prototype.hasOwnProperty.call(obj, prop);
14330
- }
14331
-
14332
- }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14333
- },{"./support/isBuffer":225,"_process":221,"inherits":220}],227:[function(require,module,exports){
14334
- /*
14335
- * Copyright 2011 Twitter, Inc.
14336
- * Licensed under the Apache License, Version 2.0 (the "License");
14337
- * you may not use this file except in compliance with the License.
14338
- * You may obtain a copy of the License at
14339
- *
14340
- * http://www.apache.org/licenses/LICENSE-2.0
14341
- *
14342
- * Unless required by applicable law or agreed to in writing, software
14343
- * distributed under the License is distributed on an "AS IS" BASIS,
14344
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14345
- * See the License for the specific language governing permissions and
14346
- * limitations under the License.
14347
- */
14348
-
14349
- (function (Hogan) {
14350
- // Setup regex assignments
14351
- // remove whitespace according to Mustache spec
14352
- var rIsWhitespace = /\S/,
14353
- rQuot = /\"/g,
14354
- rNewline = /\n/g,
14355
- rCr = /\r/g,
14356
- rSlash = /\\/g,
14357
- rLineSep = /\u2028/,
14358
- rParagraphSep = /\u2029/;
14359
-
14360
- Hogan.tags = {
14361
- '#': 1, '^': 2, '<': 3, '$': 4,
14362
- '/': 5, '!': 6, '>': 7, '=': 8, '_v': 9,
14363
- '{': 10, '&': 11, '_t': 12
14364
- };
14365
-
14366
- Hogan.scan = function scan(text, delimiters) {
14367
- var len = text.length,
14368
- IN_TEXT = 0,
14369
- IN_TAG_TYPE = 1,
14370
- IN_TAG = 2,
14371
- state = IN_TEXT,
14372
- tagType = null,
14373
- tag = null,
14374
- buf = '',
14375
- tokens = [],
14376
- seenTag = false,
14377
- i = 0,
14378
- lineStart = 0,
14379
- otag = '{{',
14380
- ctag = '}}';
14381
-
14382
- function addBuf() {
14383
- if (buf.length > 0) {
14384
- tokens.push({tag: '_t', text: new String(buf)});
14385
- buf = '';
14386
- }
14387
- }
14388
-
14389
- function lineIsWhitespace() {
14390
- var isAllWhitespace = true;
14391
- for (var j = lineStart; j < tokens.length; j++) {
14392
- isAllWhitespace =
14393
- (Hogan.tags[tokens[j].tag] < Hogan.tags['_v']) ||
14394
- (tokens[j].tag == '_t' && tokens[j].text.match(rIsWhitespace) === null);
14395
- if (!isAllWhitespace) {
14396
- return false;
14397
- }
14398
- }
14399
-
14400
- return isAllWhitespace;
14401
- }
14402
-
14403
- function filterLine(haveSeenTag, noNewLine) {
14404
- addBuf();
14405
-
14406
- if (haveSeenTag && lineIsWhitespace()) {
14407
- for (var j = lineStart, next; j < tokens.length; j++) {
14408
- if (tokens[j].text) {
14409
- if ((next = tokens[j+1]) && next.tag == '>') {
14410
- // set indent to token value
14411
- next.indent = tokens[j].text.toString()
14412
- }
14413
- tokens.splice(j, 1);
14414
- }
14415
- }
14416
- } else if (!noNewLine) {
14417
- tokens.push({tag:'\n'});
14418
- }
14419
-
14420
- seenTag = false;
14421
- lineStart = tokens.length;
14422
- }
14423
-
14424
- function changeDelimiters(text, index) {
14425
- var close = '=' + ctag,
14426
- closeIndex = text.indexOf(close, index),
14427
- delimiters = trim(
14428
- text.substring(text.indexOf('=', index) + 1, closeIndex)
14429
- ).split(' ');
14430
-
14431
- otag = delimiters[0];
14432
- ctag = delimiters[delimiters.length - 1];
14433
-
14434
- return closeIndex + close.length - 1;
14435
- }
14436
-
14437
- if (delimiters) {
14438
- delimiters = delimiters.split(' ');
14439
- otag = delimiters[0];
14440
- ctag = delimiters[1];
14441
- }
14442
-
14443
- for (i = 0; i < len; i++) {
14444
- if (state == IN_TEXT) {
14445
- if (tagChange(otag, text, i)) {
14446
- --i;
14447
- addBuf();
14448
- state = IN_TAG_TYPE;
14449
- } else {
14450
- if (text.charAt(i) == '\n') {
14451
- filterLine(seenTag);
14452
- } else {
14453
- buf += text.charAt(i);
14454
- }
14455
- }
14456
- } else if (state == IN_TAG_TYPE) {
14457
- i += otag.length - 1;
14458
- tag = Hogan.tags[text.charAt(i + 1)];
14459
- tagType = tag ? text.charAt(i + 1) : '_v';
14460
- if (tagType == '=') {
14461
- i = changeDelimiters(text, i);
14462
- state = IN_TEXT;
14463
- } else {
14464
- if (tag) {
14465
- i++;
14466
- }
14467
- state = IN_TAG;
14468
- }
14469
- seenTag = i;
14470
- } else {
14471
- if (tagChange(ctag, text, i)) {
14472
- tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
14473
- i: (tagType == '/') ? seenTag - otag.length : i + ctag.length});
14474
- buf = '';
14475
- i += ctag.length - 1;
14476
- state = IN_TEXT;
14477
- if (tagType == '{') {
14478
- if (ctag == '}}') {
14479
- i++;
14480
- } else {
14481
- cleanTripleStache(tokens[tokens.length - 1]);
14482
- }
14483
- }
14484
- } else {
14485
- buf += text.charAt(i);
14486
- }
14487
- }
14488
- }
14489
-
14490
- filterLine(seenTag, true);
14491
-
14492
- return tokens;
14493
- }
14494
-
14495
- function cleanTripleStache(token) {
14496
- if (token.n.substr(token.n.length - 1) === '}') {
14497
- token.n = token.n.substring(0, token.n.length - 1);
14498
- }
14499
- }
14500
-
14501
- function trim(s) {
14502
- if (s.trim) {
14503
- return s.trim();
14504
- }
14505
-
14506
- return s.replace(/^\s*|\s*$/g, '');
14507
- }
14508
-
14509
- function tagChange(tag, text, index) {
14510
- if (text.charAt(index) != tag.charAt(0)) {
14511
- return false;
14512
- }
14513
-
14514
- for (var i = 1, l = tag.length; i < l; i++) {
14515
- if (text.charAt(index + i) != tag.charAt(i)) {
14516
- return false;
14517
- }
14518
- }
14519
-
14520
- return true;
14521
- }
14522
-
14523
- // the tags allowed inside super templates
14524
- var allowedInSuper = {'_t': true, '\n': true, '$': true, '/': true};
14525
-
14526
- function buildTree(tokens, kind, stack, customTags) {
14527
- var instructions = [],
14528
- opener = null,
14529
- tail = null,
14530
- token = null;
14531
-
14532
- tail = stack[stack.length - 1];
14533
-
14534
- while (tokens.length > 0) {
14535
- token = tokens.shift();
14536
-
14537
- if (tail && tail.tag == '<' && !(token.tag in allowedInSuper)) {
14538
- throw new Error('Illegal content in < super tag.');
14539
- }
14540
-
14541
- if (Hogan.tags[token.tag] <= Hogan.tags['$'] || isOpener(token, customTags)) {
14542
- stack.push(token);
14543
- token.nodes = buildTree(tokens, token.tag, stack, customTags);
14544
- } else if (token.tag == '/') {
14545
- if (stack.length === 0) {
14546
- throw new Error('Closing tag without opener: /' + token.n);
14547
- }
14548
- opener = stack.pop();
14549
- if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
14550
- throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
14551
- }
14552
- opener.end = token.i;
14553
- return instructions;
14554
- } else if (token.tag == '\n') {
14555
- token.last = (tokens.length == 0) || (tokens[0].tag == '\n');
14556
- }
14557
-
14558
- instructions.push(token);
14559
- }
14560
-
14561
- if (stack.length > 0) {
14562
- throw new Error('missing closing tag: ' + stack.pop().n);
14563
- }
14564
-
14565
- return instructions;
14566
- }
14567
-
14568
- function isOpener(token, tags) {
14569
- for (var i = 0, l = tags.length; i < l; i++) {
14570
- if (tags[i].o == token.n) {
14571
- token.tag = '#';
14572
- return true;
14573
- }
14574
- }
14575
- }
14576
-
14577
- function isCloser(close, open, tags) {
14578
- for (var i = 0, l = tags.length; i < l; i++) {
14579
- if (tags[i].c == close && tags[i].o == open) {
14580
- return true;
14581
- }
14582
- }
14583
- }
14584
-
14585
- function stringifySubstitutions(obj) {
14586
- var items = [];
14587
- for (var key in obj) {
14588
- items.push('"' + esc(key) + '": function(c,p,t,i) {' + obj[key] + '}');
14589
- }
14590
- return "{ " + items.join(",") + " }";
14591
- }
14592
-
14593
- function stringifyPartials(codeObj) {
14594
- var partials = [];
14595
- for (var key in codeObj.partials) {
14596
- partials.push('"' + esc(key) + '":{name:"' + esc(codeObj.partials[key].name) + '", ' + stringifyPartials(codeObj.partials[key]) + "}");
14597
- }
14598
- return "partials: {" + partials.join(",") + "}, subs: " + stringifySubstitutions(codeObj.subs);
14599
- }
14600
-
14601
- Hogan.stringify = function(codeObj, text, options) {
14602
- return "{code: function (c,p,i) { " + Hogan.wrapMain(codeObj.code) + " }," + stringifyPartials(codeObj) + "}";
14603
- }
14604
-
14605
- var serialNo = 0;
14606
- Hogan.generate = function(tree, text, options) {
14607
- serialNo = 0;
14608
- var context = { code: '', subs: {}, partials: {} };
14609
- Hogan.walk(tree, context);
14610
-
14611
- if (options.asString) {
14612
- return this.stringify(context, text, options);
14613
- }
14614
-
14615
- return this.makeTemplate(context, text, options);
14616
- }
14617
-
14618
- Hogan.wrapMain = function(code) {
14619
- return 'var t=this;t.b(i=i||"");' + code + 'return t.fl();';
14620
- }
14621
-
14622
- Hogan.template = Hogan.Template;
14623
-
14624
- Hogan.makeTemplate = function(codeObj, text, options) {
14625
- var template = this.makePartials(codeObj);
14626
- template.code = new Function('c', 'p', 'i', this.wrapMain(codeObj.code));
14627
- return new this.template(template, text, this, options);
14628
- }
14629
-
14630
- Hogan.makePartials = function(codeObj) {
14631
- var key, template = {subs: {}, partials: codeObj.partials, name: codeObj.name};
14632
- for (key in template.partials) {
14633
- template.partials[key] = this.makePartials(template.partials[key]);
14634
- }
14635
- for (key in codeObj.subs) {
14636
- template.subs[key] = new Function('c', 'p', 't', 'i', codeObj.subs[key]);
14637
- }
14638
- return template;
14639
- }
14640
-
14641
- function esc(s) {
14642
- return s.replace(rSlash, '\\\\')
14643
- .replace(rQuot, '\\\"')
14644
- .replace(rNewline, '\\n')
14645
- .replace(rCr, '\\r')
14646
- .replace(rLineSep, '\\u2028')
14647
- .replace(rParagraphSep, '\\u2029');
14648
- }
14649
-
14650
- function chooseMethod(s) {
14651
- return (~s.indexOf('.')) ? 'd' : 'f';
14652
- }
14653
-
14654
- function createPartial(node, context) {
14655
- var prefix = "<" + (context.prefix || "");
14656
- var sym = prefix + node.n + serialNo++;
14657
- context.partials[sym] = {name: node.n, partials: {}};
14658
- context.code += 't.b(t.rp("' + esc(sym) + '",c,p,"' + (node.indent || '') + '"));';
14659
- return sym;
14660
- }
14661
-
14662
- Hogan.codegen = {
14663
- '#': function(node, context) {
14664
- context.code += 'if(t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),' +
14665
- 'c,p,0,' + node.i + ',' + node.end + ',"' + node.otag + " " + node.ctag + '")){' +
14666
- 't.rs(c,p,' + 'function(c,p,t){';
14667
- Hogan.walk(node.nodes, context);
14668
- context.code += '});c.pop();}';
14669
- },
14670
-
14671
- '^': function(node, context) {
14672
- context.code += 'if(!t.s(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,1),c,p,1,0,0,"")){';
14673
- Hogan.walk(node.nodes, context);
14674
- context.code += '};';
14675
- },
14676
-
14677
- '>': createPartial,
14678
- '<': function(node, context) {
14679
- var ctx = {partials: {}, code: '', subs: {}, inPartial: true};
14680
- Hogan.walk(node.nodes, ctx);
14681
- var template = context.partials[createPartial(node, context)];
14682
- template.subs = ctx.subs;
14683
- template.partials = ctx.partials;
14684
- },
14685
-
14686
- '$': function(node, context) {
14687
- var ctx = {subs: {}, code: '', partials: context.partials, prefix: node.n};
14688
- Hogan.walk(node.nodes, ctx);
14689
- context.subs[node.n] = ctx.code;
14690
- if (!context.inPartial) {
14691
- context.code += 't.sub("' + esc(node.n) + '",c,p,i);';
14692
- }
14693
- },
14694
-
14695
- '\n': function(node, context) {
14696
- context.code += write('"\\n"' + (node.last ? '' : ' + i'));
14697
- },
14698
-
14699
- '_v': function(node, context) {
14700
- context.code += 't.b(t.v(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
14701
- },
14702
-
14703
- '_t': function(node, context) {
14704
- context.code += write('"' + esc(node.text) + '"');
14705
- },
14706
-
14707
- '{': tripleStache,
14708
-
14709
- '&': tripleStache
14710
- }
14711
-
14712
- function tripleStache(node, context) {
14713
- context.code += 't.b(t.t(t.' + chooseMethod(node.n) + '("' + esc(node.n) + '",c,p,0)));';
14714
- }
14715
-
14716
- function write(s) {
14717
- return 't.b(' + s + ');';
14718
- }
14719
-
14720
- Hogan.walk = function(nodelist, context) {
14721
- var func;
14722
- for (var i = 0, l = nodelist.length; i < l; i++) {
14723
- func = Hogan.codegen[nodelist[i].tag];
14724
- func && func(nodelist[i], context);
14725
- }
14726
- return context;
14727
- }
14728
-
14729
- Hogan.parse = function(tokens, text, options) {
14730
- options = options || {};
14731
- return buildTree(tokens, '', [], options.sectionTags || []);
14732
- }
14733
-
14734
- Hogan.cache = {};
14735
-
14736
- Hogan.cacheKey = function(text, options) {
14737
- return [text, !!options.asString, !!options.disableLambda, options.delimiters, !!options.modelGet].join('||');
14738
- }
14739
-
14740
- Hogan.compile = function(text, options) {
14741
- options = options || {};
14742
- var key = Hogan.cacheKey(text, options);
14743
- var template = this.cache[key];
14744
-
14745
- if (template) {
14746
- var partials = template.partials;
14747
- for (var name in partials) {
14748
- delete partials[name].instance;
14749
- }
14750
- return template;
14751
- }
14752
-
14753
- template = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);
14754
- return this.cache[key] = template;
14755
- }
14756
- })(typeof exports !== 'undefined' ? exports : Hogan);
14757
-
14758
- },{}],228:[function(require,module,exports){
14759
- /*
14760
- * Copyright 2011 Twitter, Inc.
14761
- * Licensed under the Apache License, Version 2.0 (the "License");
14762
- * you may not use this file except in compliance with the License.
14763
- * You may obtain a copy of the License at
14764
- *
14765
- * http://www.apache.org/licenses/LICENSE-2.0
14766
- *
14767
- * Unless required by applicable law or agreed to in writing, software
14768
- * distributed under the License is distributed on an "AS IS" BASIS,
14769
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14770
- * See the License for the specific language governing permissions and
14771
- * limitations under the License.
14772
- */
14773
-
14774
- // This file is for use with Node.js. See dist/ for browser files.
14775
-
14776
- var Hogan = require('./compiler');
14777
- Hogan.Template = require('./template').Template;
14778
- Hogan.template = Hogan.Template;
14779
- module.exports = Hogan;
14780
-
14781
- },{"./compiler":227,"./template":229}],229:[function(require,module,exports){
14782
- /*
14783
- * Copyright 2011 Twitter, Inc.
14784
- * Licensed under the Apache License, Version 2.0 (the "License");
14785
- * you may not use this file except in compliance with the License.
14786
- * You may obtain a copy of the License at
14787
- *
14788
- * http://www.apache.org/licenses/LICENSE-2.0
14789
- *
14790
- * Unless required by applicable law or agreed to in writing, software
14791
- * distributed under the License is distributed on an "AS IS" BASIS,
14792
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14793
- * See the License for the specific language governing permissions and
14794
- * limitations under the License.
14795
- */
14796
-
14797
- var Hogan = {};
14798
-
14799
- (function (Hogan) {
14800
- Hogan.Template = function (codeObj, text, compiler, options) {
14801
- codeObj = codeObj || {};
14802
- this.r = codeObj.code || this.r;
14803
- this.c = compiler;
14804
- this.options = options || {};
14805
- this.text = text || '';
14806
- this.partials = codeObj.partials || {};
14807
- this.subs = codeObj.subs || {};
14808
- this.buf = '';
14809
- }
14810
-
14811
- Hogan.Template.prototype = {
14812
- // render: replaced by generated code.
14813
- r: function (context, partials, indent) { return ''; },
14814
-
14815
- // variable escaping
14816
- v: hoganEscape,
14817
-
14818
- // triple stache
14819
- t: coerceToString,
14820
-
14821
- render: function render(context, partials, indent) {
14822
- return this.ri([context], partials || {}, indent);
14823
- },
14824
-
14825
- // render internal -- a hook for overrides that catches partials too
14826
- ri: function (context, partials, indent) {
14827
- return this.r(context, partials, indent);
14828
- },
14829
-
14830
- // ensurePartial
14831
- ep: function(symbol, partials) {
14832
- var partial = this.partials[symbol];
14833
-
14834
- // check to see that if we've instantiated this partial before
14835
- var template = partials[partial.name];
14836
- if (partial.instance && partial.base == template) {
14837
- return partial.instance;
14838
- }
14839
-
14840
- if (typeof template == 'string') {
14841
- if (!this.c) {
14842
- throw new Error("No compiler available.");
14843
- }
14844
- template = this.c.compile(template, this.options);
14845
- }
14846
-
14847
- if (!template) {
14848
- return null;
14849
- }
14850
-
14851
- // We use this to check whether the partials dictionary has changed
14852
- this.partials[symbol].base = template;
14853
-
14854
- if (partial.subs) {
14855
- // Make sure we consider parent template now
14856
- if (!partials.stackText) partials.stackText = {};
14857
- for (key in partial.subs) {
14858
- if (!partials.stackText[key]) {
14859
- partials.stackText[key] = (this.activeSub !== undefined && partials.stackText[this.activeSub]) ? partials.stackText[this.activeSub] : this.text;
14860
- }
14861
- }
14862
- template = createSpecializedPartial(template, partial.subs, partial.partials,
14863
- this.stackSubs, this.stackPartials, partials.stackText);
14864
- }
14865
- this.partials[symbol].instance = template;
14866
-
14867
- return template;
14868
- },
14869
-
14870
- // tries to find a partial in the current scope and render it
14871
- rp: function(symbol, context, partials, indent) {
14872
- var partial = this.ep(symbol, partials);
14873
- if (!partial) {
14874
- return '';
14875
- }
14876
-
14877
- return partial.ri(context, partials, indent);
14878
- },
14879
-
14880
- // render a section
14881
- rs: function(context, partials, section) {
14882
- var tail = context[context.length - 1];
14883
-
14884
- if (!isArray(tail)) {
14885
- section(context, partials, this);
14886
- return;
14887
- }
14888
-
14889
- for (var i = 0; i < tail.length; i++) {
14890
- context.push(tail[i]);
14891
- section(context, partials, this);
14892
- context.pop();
14893
- }
14894
- },
14895
-
14896
- // maybe start a section
14897
- s: function(val, ctx, partials, inverted, start, end, tags) {
14898
- var pass;
14899
-
14900
- if (isArray(val) && val.length === 0) {
14901
- return false;
14902
- }
14903
-
14904
- if (typeof val == 'function') {
14905
- val = this.ms(val, ctx, partials, inverted, start, end, tags);
14906
- }
14907
-
14908
- pass = !!val;
14909
-
14910
- if (!inverted && pass && ctx) {
14911
- ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
14912
- }
14913
-
14914
- return pass;
14915
- },
14916
-
14917
- // find values with dotted names
14918
- d: function(key, ctx, partials, returnFound) {
14919
- var found,
14920
- names = key.split('.'),
14921
- val = this.f(names[0], ctx, partials, returnFound),
14922
- doModelGet = this.options.modelGet,
14923
- cx = null;
14924
-
14925
- if (key === '.' && isArray(ctx[ctx.length - 2])) {
14926
- val = ctx[ctx.length - 1];
14927
- } else {
14928
- for (var i = 1; i < names.length; i++) {
14929
- found = findInScope(names[i], val, doModelGet);
14930
- if (found !== undefined) {
14931
- cx = val;
14932
- val = found;
14933
- } else {
14934
- val = '';
14935
- }
14936
- }
14937
- }
14938
-
14939
- if (returnFound && !val) {
14940
- return false;
14941
- }
14942
-
14943
- if (!returnFound && typeof val == 'function') {
14944
- ctx.push(cx);
14945
- val = this.mv(val, ctx, partials);
14946
- ctx.pop();
14947
- }
14948
-
14949
- return val;
14950
- },
14951
-
14952
- // find values with normal names
14953
- f: function(key, ctx, partials, returnFound) {
14954
- var val = false,
14955
- v = null,
14956
- found = false,
14957
- doModelGet = this.options.modelGet;
14958
-
14959
- for (var i = ctx.length - 1; i >= 0; i--) {
14960
- v = ctx[i];
14961
- val = findInScope(key, v, doModelGet);
14962
- if (val !== undefined) {
14963
- found = true;
14964
- break;
14965
- }
14966
- }
14967
-
14968
- if (!found) {
14969
- return (returnFound) ? false : "";
14970
- }
14971
-
14972
- if (!returnFound && typeof val == 'function') {
14973
- val = this.mv(val, ctx, partials);
14974
- }
14975
-
14976
- return val;
14977
- },
14978
-
14979
- // higher order templates
14980
- ls: function(func, cx, partials, text, tags) {
14981
- var oldTags = this.options.delimiters;
14982
-
14983
- this.options.delimiters = tags;
14984
- this.b(this.ct(coerceToString(func.call(cx, text)), cx, partials));
14985
- this.options.delimiters = oldTags;
14986
-
14987
- return false;
14988
- },
14989
-
14990
- // compile text
14991
- ct: function(text, cx, partials) {
14992
- if (this.options.disableLambda) {
14993
- throw new Error('Lambda features disabled.');
14994
- }
14995
- return this.c.compile(text, this.options).render(cx, partials);
14996
- },
14997
-
14998
- // template result buffering
14999
- b: function(s) { this.buf += s; },
15000
-
15001
- fl: function() { var r = this.buf; this.buf = ''; return r; },
15002
-
15003
- // method replace section
15004
- ms: function(func, ctx, partials, inverted, start, end, tags) {
15005
- var textSource,
15006
- cx = ctx[ctx.length - 1],
15007
- result = func.call(cx);
15008
-
15009
- if (typeof result == 'function') {
15010
- if (inverted) {
15011
- return true;
15012
- } else {
15013
- textSource = (this.activeSub && this.subsText && this.subsText[this.activeSub]) ? this.subsText[this.activeSub] : this.text;
15014
- return this.ls(result, cx, partials, textSource.substring(start, end), tags);
15015
- }
15016
- }
15017
-
15018
- return result;
15019
- },
15020
-
15021
- // method replace variable
15022
- mv: function(func, ctx, partials) {
15023
- var cx = ctx[ctx.length - 1];
15024
- var result = func.call(cx);
15025
-
15026
- if (typeof result == 'function') {
15027
- return this.ct(coerceToString(result.call(cx)), cx, partials);
15028
- }
15029
-
15030
- return result;
15031
- },
15032
-
15033
- sub: function(name, context, partials, indent) {
15034
- var f = this.subs[name];
15035
- if (f) {
15036
- this.activeSub = name;
15037
- f(context, partials, this, indent);
15038
- this.activeSub = false;
15039
- }
15040
- }
15041
-
15042
- };
15043
-
15044
- //Find a key in an object
15045
- function findInScope(key, scope, doModelGet) {
15046
- var val;
15047
-
15048
- if (scope && typeof scope == 'object') {
15049
-
15050
- if (scope[key] !== undefined) {
15051
- val = scope[key];
15052
-
15053
- // try lookup with get for backbone or similar model data
15054
- } else if (doModelGet && scope.get && typeof scope.get == 'function') {
15055
- val = scope.get(key);
15056
- }
15057
- }
15058
-
15059
- return val;
15060
- }
15061
-
15062
- function createSpecializedPartial(instance, subs, partials, stackSubs, stackPartials, stackText) {
15063
- function PartialTemplate() {};
15064
- PartialTemplate.prototype = instance;
15065
- function Substitutions() {};
15066
- Substitutions.prototype = instance.subs;
15067
- var key;
15068
- var partial = new PartialTemplate();
15069
- partial.subs = new Substitutions();
15070
- partial.subsText = {}; //hehe. substext.
15071
- partial.buf = '';
15072
-
15073
- stackSubs = stackSubs || {};
15074
- partial.stackSubs = stackSubs;
15075
- partial.subsText = stackText;
15076
- for (key in subs) {
15077
- if (!stackSubs[key]) stackSubs[key] = subs[key];
15078
- }
15079
- for (key in stackSubs) {
15080
- partial.subs[key] = stackSubs[key];
15081
- }
15082
-
15083
- stackPartials = stackPartials || {};
15084
- partial.stackPartials = stackPartials;
15085
- for (key in partials) {
15086
- if (!stackPartials[key]) stackPartials[key] = partials[key];
15087
- }
15088
- for (key in stackPartials) {
15089
- partial.partials[key] = stackPartials[key];
15090
- }
15091
-
15092
- return partial;
15093
- }
15094
-
15095
- var rAmp = /&/g,
15096
- rLt = /</g,
15097
- rGt = />/g,
15098
- rApos = /\'/g,
15099
- rQuot = /\"/g,
15100
- hChars = /[&<>\"\']/;
15101
-
15102
- function coerceToString(val) {
15103
- return String((val === null || val === undefined) ? '' : val);
15104
- }
15105
-
15106
- function hoganEscape(str) {
15107
- str = coerceToString(str);
15108
- return hChars.test(str) ?
15109
- str
15110
- .replace(rAmp, '&amp;')
15111
- .replace(rLt, '&lt;')
15112
- .replace(rGt, '&gt;')
15113
- .replace(rApos, '&#39;')
15114
- .replace(rQuot, '&quot;') :
15115
- str;
15116
- }
15117
-
15118
- var isArray = Array.isArray || function(a) {
15119
- return Object.prototype.toString.call(a) === '[object Array]';
15120
- };
15121
-
15122
- })(typeof exports !== 'undefined' ? exports : Hogan);
15123
-
15124
- },{}],230:[function(require,module,exports){
15125
- /*!
15126
- * jQuery UI Touch Punch 0.2.3
15127
- *
15128
- * Copyright 2011–2014, Dave Furfero
15129
- * Dual licensed under the MIT or GPL Version 2 licenses.
15130
- *
15131
- * Depends:
15132
- * jquery.ui.widget.js
15133
- * jquery.ui.mouse.js
15134
- */
15135
- (function ($) {
15136
-
15137
- // Detect touch support
15138
- $.support.touch = 'ontouchend' in document;
15139
-
15140
- // Ignore browsers without touch support
15141
- if (!$.support.touch) {
15142
- return;
15143
- }
15144
-
15145
- var mouseProto = $.ui.mouse.prototype,
15146
- _mouseInit = mouseProto._mouseInit,
15147
- _mouseDestroy = mouseProto._mouseDestroy,
15148
- touchHandled;
15149
-
15150
- /**
15151
- * Simulate a mouse event based on a corresponding touch event
15152
- * @param {Object} event A touch event
15153
- * @param {String} simulatedType The corresponding mouse event
15154
- */
15155
- function simulateMouseEvent (event, simulatedType) {
15156
-
15157
- // Ignore multi-touch events
15158
- if (event.originalEvent.touches.length > 1) {
15159
- return;
15160
- }
15161
-
15162
- event.preventDefault();
15163
-
15164
- var touch = event.originalEvent.changedTouches[0],
15165
- simulatedEvent = document.createEvent('MouseEvents');
15166
-
15167
- // Initialize the simulated mouse event using the touch event's coordinates
15168
- simulatedEvent.initMouseEvent(
15169
- simulatedType, // type
15170
- true, // bubbles
15171
- true, // cancelable
15172
- window, // view
15173
- 1, // detail
15174
- touch.screenX, // screenX
15175
- touch.screenY, // screenY
15176
- touch.clientX, // clientX
15177
- touch.clientY, // clientY
15178
- false, // ctrlKey
15179
- false, // altKey
15180
- false, // shiftKey
15181
- false, // metaKey
15182
- 0, // button
15183
- null // relatedTarget
15184
- );
15185
-
15186
- // Dispatch the simulated event to the target element
15187
- event.target.dispatchEvent(simulatedEvent);
15188
- }
15189
-
15190
- /**
15191
- * Handle the jQuery UI widget's touchstart events
15192
- * @param {Object} event The widget element's touchstart event
15193
- */
15194
- mouseProto._touchStart = function (event) {
15195
-
15196
- var self = this;
15197
-
15198
- // Ignore the event if another widget is already being handled
15199
- if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
15200
- return;
15201
- }
15202
-
15203
- // Set the flag to prevent other widgets from inheriting the touch event
15204
- touchHandled = true;
15205
-
15206
- // Track movement to determine if interaction was a click
15207
- self._touchMoved = false;
15208
-
15209
- // Simulate the mouseover event
15210
- simulateMouseEvent(event, 'mouseover');
15211
-
15212
- // Simulate the mousemove event
15213
- simulateMouseEvent(event, 'mousemove');
15214
-
15215
- // Simulate the mousedown event
15216
- simulateMouseEvent(event, 'mousedown');
15217
- };
15218
-
15219
- /**
15220
- * Handle the jQuery UI widget's touchmove events
15221
- * @param {Object} event The document's touchmove event
15222
- */
15223
- mouseProto._touchMove = function (event) {
15224
-
15225
- // Ignore event if not handled
15226
- if (!touchHandled) {
15227
- return;
15228
- }
15229
-
15230
- // Interaction was not a click
15231
- this._touchMoved = true;
15232
-
15233
- // Simulate the mousemove event
15234
- simulateMouseEvent(event, 'mousemove');
15235
- };
15236
-
15237
- /**
15238
- * Handle the jQuery UI widget's touchend events
15239
- * @param {Object} event The document's touchend event
15240
- */
15241
- mouseProto._touchEnd = function (event) {
15242
-
15243
- // Ignore event if not handled
15244
- if (!touchHandled) {
15245
- return;
15246
- }
15247
-
15248
- // Simulate the mouseup event
15249
- simulateMouseEvent(event, 'mouseup');
15250
-
15251
- // Simulate the mouseout event
15252
- simulateMouseEvent(event, 'mouseout');
15253
-
15254
- // If the touch interaction did not move, it should trigger a click
15255
- if (!this._touchMoved) {
15256
-
15257
- // Simulate the click event
15258
- simulateMouseEvent(event, 'click');
15259
- }
15260
-
15261
- // Unset the flag to allow other widgets to inherit the touch event
15262
- touchHandled = false;
15263
- };
15264
-
15265
- /**
15266
- * A duck punch of the $.ui.mouse _mouseInit method to support touch events.
15267
- * This method extends the widget with bound touch event handlers that
15268
- * translate touch events to mouse events and pass them to the widget's
15269
- * original mouse event handling methods.
15270
- */
15271
- mouseProto._mouseInit = function () {
15272
-
15273
- var self = this;
15274
-
15275
- // Delegate the touch handlers to the widget's element
15276
- self.element.bind({
15277
- touchstart: $.proxy(self, '_touchStart'),
15278
- touchmove: $.proxy(self, '_touchMove'),
15279
- touchend: $.proxy(self, '_touchEnd')
15280
- });
15281
-
15282
- // Call the original $.ui.mouse init method
15283
- _mouseInit.call(self);
15284
- };
15285
-
15286
- /**
15287
- * Remove the touch event handlers
15288
- */
15289
- mouseProto._mouseDestroy = function () {
15290
-
15291
- var self = this;
15292
-
15293
- // Delegate the touch handlers to the widget's element
15294
- self.element.unbind({
15295
- touchstart: $.proxy(self, '_touchStart'),
15296
- touchmove: $.proxy(self, '_touchMove'),
15297
- touchend: $.proxy(self, '_touchEnd')
15298
- });
15299
-
15300
- // Call the original $.ui.mouse destroy method
15301
- _mouseDestroy.call(self);
15302
- };
15303
-
15304
- })(jQuery);
15305
- },{}],231:[function(require,module,exports){
15306
- var jQuery = require('jquery');
15307
-
15308
- /*!
15309
- * jQuery UI Core 1.10.4
15310
- * http://jqueryui.com
15311
- *
15312
- * Copyright 2014 jQuery Foundation and other contributors
15313
- * Released under the MIT license.
15314
- * http://jquery.org/license
15315
- *
15316
- * http://api.jqueryui.com/category/ui-core/
15317
- */
15318
- (function( $, undefined ) {
15319
-
15320
- var uuid = 0,
15321
- runiqueId = /^ui-id-\d+$/;
15322
-
15323
- // $.ui might exist from components with no dependencies, e.g., $.ui.position
15324
- $.ui = $.ui || {};
15325
-
15326
- $.extend( $.ui, {
15327
- version: "1.10.4",
15328
-
15329
- keyCode: {
15330
- BACKSPACE: 8,
15331
- COMMA: 188,
15332
- DELETE: 46,
15333
- DOWN: 40,
15334
- END: 35,
15335
- ENTER: 13,
15336
- ESCAPE: 27,
15337
- HOME: 36,
15338
- LEFT: 37,
15339
- NUMPAD_ADD: 107,
15340
- NUMPAD_DECIMAL: 110,
15341
- NUMPAD_DIVIDE: 111,
15342
- NUMPAD_ENTER: 108,
15343
- NUMPAD_MULTIPLY: 106,
15344
- NUMPAD_SUBTRACT: 109,
15345
- PAGE_DOWN: 34,
15346
- PAGE_UP: 33,
15347
- PERIOD: 190,
15348
- RIGHT: 39,
15349
- SPACE: 32,
15350
- TAB: 9,
15351
- UP: 38
15352
- }
15353
- });
15354
-
15355
- // plugins
15356
- $.fn.extend({
15357
- focus: (function( orig ) {
15358
- return function( delay, fn ) {
15359
- return typeof delay === "number" ?
15360
- this.each(function() {
15361
- var elem = this;
15362
- setTimeout(function() {
15363
- $( elem ).focus();
15364
- if ( fn ) {
15365
- fn.call( elem );
15366
- }
15367
- }, delay );
15368
- }) :
15369
- orig.apply( this, arguments );
15370
- };
15371
- })( $.fn.focus ),
15372
-
15373
- scrollParent: function() {
15374
- var scrollParent;
15375
- if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
15376
- scrollParent = this.parents().filter(function() {
15377
- return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
15378
- }).eq(0);
15379
- } else {
15380
- scrollParent = this.parents().filter(function() {
15381
- return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
15382
- }).eq(0);
15383
- }
15384
-
15385
- return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
15386
- },
15387
-
15388
- zIndex: function( zIndex ) {
15389
- if ( zIndex !== undefined ) {
15390
- return this.css( "zIndex", zIndex );
15391
- }
15392
-
15393
- if ( this.length ) {
15394
- var elem = $( this[ 0 ] ), position, value;
15395
- while ( elem.length && elem[ 0 ] !== document ) {
15396
- // Ignore z-index if position is set to a value where z-index is ignored by the browser
15397
- // This makes behavior of this function consistent across browsers
15398
- // WebKit always returns auto if the element is positioned
15399
- position = elem.css( "position" );
15400
- if ( position === "absolute" || position === "relative" || position === "fixed" ) {
15401
- // IE returns 0 when zIndex is not specified
15402
- // other browsers return a string
15403
- // we ignore the case of nested elements with an explicit value of 0
15404
- // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
15405
- value = parseInt( elem.css( "zIndex" ), 10 );
15406
- if ( !isNaN( value ) && value !== 0 ) {
15407
- return value;
15408
- }
15409
- }
15410
- elem = elem.parent();
15411
- }
15412
- }
15413
-
15414
- return 0;
15415
- },
15416
-
15417
- uniqueId: function() {
15418
- return this.each(function() {
15419
- if ( !this.id ) {
15420
- this.id = "ui-id-" + (++uuid);
15421
- }
15422
- });
15423
- },
15424
-
15425
- removeUniqueId: function() {
15426
- return this.each(function() {
15427
- if ( runiqueId.test( this.id ) ) {
15428
- $( this ).removeAttr( "id" );
15429
- }
15430
- });
15431
- }
15432
- });
15433
-
15434
- // selectors
15435
- function focusable( element, isTabIndexNotNaN ) {
15436
- var map, mapName, img,
15437
- nodeName = element.nodeName.toLowerCase();
15438
- if ( "area" === nodeName ) {
15439
- map = element.parentNode;
15440
- mapName = map.name;
15441
- if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
15442
- return false;
15443
- }
15444
- img = $( "img[usemap=#" + mapName + "]" )[0];
15445
- return !!img && visible( img );
15446
- }
15447
- return ( /input|select|textarea|button|object/.test( nodeName ) ?
15448
- !element.disabled :
15449
- "a" === nodeName ?
15450
- element.href || isTabIndexNotNaN :
15451
- isTabIndexNotNaN) &&
15452
- // the element and all of its ancestors must be visible
15453
- visible( element );
15454
- }
15455
-
15456
- function visible( element ) {
15457
- return $.expr.filters.visible( element ) &&
15458
- !$( element ).parents().addBack().filter(function() {
15459
- return $.css( this, "visibility" ) === "hidden";
15460
- }).length;
15461
- }
15462
-
15463
- $.extend( $.expr[ ":" ], {
15464
- data: $.expr.createPseudo ?
15465
- $.expr.createPseudo(function( dataName ) {
15466
- return function( elem ) {
15467
- return !!$.data( elem, dataName );
15468
- };
15469
- }) :
15470
- // support: jQuery <1.8
15471
- function( elem, i, match ) {
15472
- return !!$.data( elem, match[ 3 ] );
15473
- },
15474
-
15475
- focusable: function( element ) {
15476
- return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
15477
- },
15478
-
15479
- tabbable: function( element ) {
15480
- var tabIndex = $.attr( element, "tabindex" ),
15481
- isTabIndexNaN = isNaN( tabIndex );
15482
- return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
15483
- }
15484
- });
15485
-
15486
- // support: jQuery <1.8
15487
- if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
15488
- $.each( [ "Width", "Height" ], function( i, name ) {
15489
- var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
15490
- type = name.toLowerCase(),
15491
- orig = {
15492
- innerWidth: $.fn.innerWidth,
15493
- innerHeight: $.fn.innerHeight,
15494
- outerWidth: $.fn.outerWidth,
15495
- outerHeight: $.fn.outerHeight
15496
- };
15497
-
15498
- function reduce( elem, size, border, margin ) {
15499
- $.each( side, function() {
15500
- size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
15501
- if ( border ) {
15502
- size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
15503
- }
15504
- if ( margin ) {
15505
- size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
15506
- }
15507
- });
15508
- return size;
15509
- }
15510
-
15511
- $.fn[ "inner" + name ] = function( size ) {
15512
- if ( size === undefined ) {
15513
- return orig[ "inner" + name ].call( this );
15514
- }
15515
-
15516
- return this.each(function() {
15517
- $( this ).css( type, reduce( this, size ) + "px" );
15518
- });
15519
- };
15520
-
15521
- $.fn[ "outer" + name] = function( size, margin ) {
15522
- if ( typeof size !== "number" ) {
15523
- return orig[ "outer" + name ].call( this, size );
15524
- }
15525
-
15526
- return this.each(function() {
15527
- $( this).css( type, reduce( this, size, true, margin ) + "px" );
15528
- });
15529
- };
15530
- });
15531
- }
15532
-
15533
- // support: jQuery <1.8
15534
- if ( !$.fn.addBack ) {
15535
- $.fn.addBack = function( selector ) {
15536
- return this.add( selector == null ?
15537
- this.prevObject : this.prevObject.filter( selector )
15538
- );
15539
- };
15540
- }
15541
-
15542
- // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
15543
- if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
15544
- $.fn.removeData = (function( removeData ) {
15545
- return function( key ) {
15546
- if ( arguments.length ) {
15547
- return removeData.call( this, $.camelCase( key ) );
15548
- } else {
15549
- return removeData.call( this );
15550
- }
15551
- };
15552
- })( $.fn.removeData );
15553
- }
15554
-
15555
-
15556
-
15557
-
15558
-
15559
- // deprecated
15560
- $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
15561
-
15562
- $.support.selectstart = "onselectstart" in document.createElement( "div" );
15563
- $.fn.extend({
15564
- disableSelection: function() {
15565
- return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
15566
- ".ui-disableSelection", function( event ) {
15567
- event.preventDefault();
15568
- });
15569
- },
15570
-
15571
- enableSelection: function() {
15572
- return this.unbind( ".ui-disableSelection" );
15573
- }
15574
- });
15575
-
15576
- $.extend( $.ui, {
15577
- // $.ui.plugin is deprecated. Use $.widget() extensions instead.
15578
- plugin: {
15579
- add: function( module, option, set ) {
15580
- var i,
15581
- proto = $.ui[ module ].prototype;
15582
- for ( i in set ) {
15583
- proto.plugins[ i ] = proto.plugins[ i ] || [];
15584
- proto.plugins[ i ].push( [ option, set[ i ] ] );
15585
- }
15586
- },
15587
- call: function( instance, name, args ) {
15588
- var i,
15589
- set = instance.plugins[ name ];
15590
- if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
15591
- return;
15592
- }
15593
-
15594
- for ( i = 0; i < set.length; i++ ) {
15595
- if ( instance.options[ set[ i ][ 0 ] ] ) {
15596
- set[ i ][ 1 ].apply( instance.element, args );
15597
- }
15598
- }
15599
- }
15600
- },
15601
-
15602
- // only used by resizable
15603
- hasScroll: function( el, a ) {
15604
-
15605
- //If overflow is hidden, the element might have extra content, but the user wants to hide it
15606
- if ( $( el ).css( "overflow" ) === "hidden") {
15607
- return false;
15608
- }
15609
-
15610
- var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
15611
- has = false;
15612
-
15613
- if ( el[ scroll ] > 0 ) {
15614
- return true;
15615
- }
15616
-
15617
- // TODO: determine which cases actually cause this to happen
15618
- // if the element doesn't have the scroll set, see if it's possible to
15619
- // set the scroll
15620
- el[ scroll ] = 1;
15621
- has = ( el[ scroll ] > 0 );
15622
- el[ scroll ] = 0;
15623
- return has;
15624
- }
15625
- });
15626
-
15627
- })( jQuery );
15628
-
15629
- },{"jquery":237}],232:[function(require,module,exports){
15630
- var jQuery = require('jquery');
15631
- require('./core');
15632
- require('./mouse');
15633
- require('./widget');
15634
-
15635
- /*!
15636
- * jQuery UI Draggable 1.10.4
15637
- * http://jqueryui.com
15638
- *
15639
- * Copyright 2014 jQuery Foundation and other contributors
15640
- * Released under the MIT license.
15641
- * http://jquery.org/license
15642
- *
15643
- * http://api.jqueryui.com/draggable/
15644
- *
15645
- * Depends:
15646
- * jquery.ui.core.js
15647
- * jquery.ui.mouse.js
15648
- * jquery.ui.widget.js
15649
- */
15650
- (function( $, undefined ) {
15651
-
15652
- $.widget("ui.draggable", $.ui.mouse, {
15653
- version: "1.10.4",
15654
- widgetEventPrefix: "drag",
15655
- options: {
15656
- addClasses: true,
15657
- appendTo: "parent",
15658
- axis: false,
15659
- connectToSortable: false,
15660
- containment: false,
15661
- cursor: "auto",
15662
- cursorAt: false,
15663
- grid: false,
15664
- handle: false,
15665
- helper: "original",
15666
- iframeFix: false,
15667
- opacity: false,
15668
- refreshPositions: false,
15669
- revert: false,
15670
- revertDuration: 500,
15671
- scope: "default",
15672
- scroll: true,
15673
- scrollSensitivity: 20,
15674
- scrollSpeed: 20,
15675
- snap: false,
15676
- snapMode: "both",
15677
- snapTolerance: 20,
15678
- stack: false,
15679
- zIndex: false,
15680
-
15681
- // callbacks
15682
- drag: null,
15683
- start: null,
15684
- stop: null
15685
- },
15686
- _create: function() {
15687
-
15688
- if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
15689
- this.element[0].style.position = "relative";
15690
- }
15691
- if (this.options.addClasses){
15692
- this.element.addClass("ui-draggable");
15693
- }
15694
- if (this.options.disabled){
15695
- this.element.addClass("ui-draggable-disabled");
15696
- }
15697
-
15698
- this._mouseInit();
15699
-
15700
- },
15701
-
15702
- _destroy: function() {
15703
- this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
15704
- this._mouseDestroy();
15705
- },
15706
-
15707
- _mouseCapture: function(event) {
15708
-
15709
- var o = this.options;
15710
-
15711
- // among others, prevent a drag on a resizable-handle
15712
- if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
15713
- return false;
15714
- }
15715
-
15716
- //Quit if we're not on a valid handle
15717
- this.handle = this._getHandle(event);
15718
- if (!this.handle) {
15719
- return false;
15720
- }
15721
-
15722
- $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
15723
- $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
15724
- .css({
15725
- width: this.offsetWidth+"px", height: this.offsetHeight+"px",
15726
- position: "absolute", opacity: "0.001", zIndex: 1000
15727
- })
15728
- .css($(this).offset())
15729
- .appendTo("body");
15730
- });
15731
-
15732
- return true;
15733
-
15734
- },
15735
-
15736
- _mouseStart: function(event) {
15737
-
15738
- var o = this.options;
15739
-
15740
- //Create and append the visible helper
15741
- this.helper = this._createHelper(event);
15742
-
15743
- this.helper.addClass("ui-draggable-dragging");
15744
-
15745
- //Cache the helper size
15746
- this._cacheHelperProportions();
15747
-
15748
- //If ddmanager is used for droppables, set the global draggable
15749
- if($.ui.ddmanager) {
15750
- $.ui.ddmanager.current = this;
15751
- }
15752
-
15753
- /*
15754
- * - Position generation -
15755
- * This block generates everything position related - it's the core of draggables.
15756
- */
15757
-
15758
- //Cache the margins of the original element
15759
- this._cacheMargins();
15760
-
15761
- //Store the helper's css position
15762
- this.cssPosition = this.helper.css( "position" );
15763
- this.scrollParent = this.helper.scrollParent();
15764
- this.offsetParent = this.helper.offsetParent();
15765
- this.offsetParentCssPosition = this.offsetParent.css( "position" );
15766
-
15767
- //The element's absolute position on the page minus margins
15768
- this.offset = this.positionAbs = this.element.offset();
15769
- this.offset = {
15770
- top: this.offset.top - this.margins.top,
15771
- left: this.offset.left - this.margins.left
15772
- };
15773
-
15774
- //Reset scroll cache
15775
- this.offset.scroll = false;
15776
-
15777
- $.extend(this.offset, {
15778
- click: { //Where the click happened, relative to the element
15779
- left: event.pageX - this.offset.left,
15780
- top: event.pageY - this.offset.top
15781
- },
15782
- parent: this._getParentOffset(),
15783
- relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
15784
- });
15785
-
15786
- //Generate the original position
15787
- this.originalPosition = this.position = this._generatePosition(event);
15788
- this.originalPageX = event.pageX;
15789
- this.originalPageY = event.pageY;
15790
-
15791
- //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
15792
- (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
15793
-
15794
- //Set a containment if given in the options
15795
- this._setContainment();
15796
-
15797
- //Trigger event + callbacks
15798
- if(this._trigger("start", event) === false) {
15799
- this._clear();
15800
- return false;
15801
- }
15802
-
15803
- //Recache the helper size
15804
- this._cacheHelperProportions();
15805
-
15806
- //Prepare the droppable offsets
15807
- if ($.ui.ddmanager && !o.dropBehaviour) {
15808
- $.ui.ddmanager.prepareOffsets(this, event);
15809
- }
15810
-
15811
-
15812
- this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
15813
-
15814
- //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
15815
- if ( $.ui.ddmanager ) {
15816
- $.ui.ddmanager.dragStart(this, event);
15817
- }
15818
-
15819
- return true;
15820
- },
15821
-
15822
- _mouseDrag: function(event, noPropagation) {
15823
- // reset any necessary cached properties (see #5009)
15824
- if ( this.offsetParentCssPosition === "fixed" ) {
15825
- this.offset.parent = this._getParentOffset();
15826
- }
15827
-
15828
- //Compute the helpers position
15829
- this.position = this._generatePosition(event);
15830
- this.positionAbs = this._convertPositionTo("absolute");
15831
-
15832
- //Call plugins and callbacks and use the resulting position if something is returned
15833
- if (!noPropagation) {
15834
- var ui = this._uiHash();
15835
- if(this._trigger("drag", event, ui) === false) {
15836
- this._mouseUp({});
15837
- return false;
15838
- }
15839
- this.position = ui.position;
15840
- }
15841
-
15842
- if(!this.options.axis || this.options.axis !== "y") {
15843
- this.helper[0].style.left = this.position.left+"px";
15844
- }
15845
- if(!this.options.axis || this.options.axis !== "x") {
15846
- this.helper[0].style.top = this.position.top+"px";
15847
- }
15848
- if($.ui.ddmanager) {
15849
- $.ui.ddmanager.drag(this, event);
15850
- }
15851
-
15852
- return false;
15853
- },
15854
-
15855
- _mouseStop: function(event) {
15856
-
15857
- //If we are using droppables, inform the manager about the drop
15858
- var that = this,
15859
- dropped = false;
15860
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
15861
- dropped = $.ui.ddmanager.drop(this, event);
15862
- }
15863
-
15864
- //if a drop comes from outside (a sortable)
15865
- if(this.dropped) {
15866
- dropped = this.dropped;
15867
- this.dropped = false;
15868
- }
15869
-
15870
- //if the original element is no longer in the DOM don't bother to continue (see #8269)
15871
- if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
15872
- return false;
15873
- }
15874
-
15875
- if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
15876
- $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
15877
- if(that._trigger("stop", event) !== false) {
15878
- that._clear();
15879
- }
15880
- });
15881
- } else {
15882
- if(this._trigger("stop", event) !== false) {
15883
- this._clear();
15884
- }
15885
- }
15886
-
15887
- return false;
15888
- },
15889
-
15890
- _mouseUp: function(event) {
15891
- //Remove frame helpers
15892
- $("div.ui-draggable-iframeFix").each(function() {
15893
- this.parentNode.removeChild(this);
15894
- });
15895
-
15896
- //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
15897
- if( $.ui.ddmanager ) {
15898
- $.ui.ddmanager.dragStop(this, event);
15899
- }
15900
-
15901
- return $.ui.mouse.prototype._mouseUp.call(this, event);
15902
- },
15903
-
15904
- cancel: function() {
15905
-
15906
- if(this.helper.is(".ui-draggable-dragging")) {
15907
- this._mouseUp({});
15908
- } else {
15909
- this._clear();
15910
- }
15911
-
15912
- return this;
15913
-
15914
- },
15915
-
15916
- _getHandle: function(event) {
15917
- return this.options.handle ?
15918
- !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
15919
- true;
15920
- },
15921
-
15922
- _createHelper: function(event) {
15923
-
15924
- var o = this.options,
15925
- helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
15926
-
15927
- if(!helper.parents("body").length) {
15928
- helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
15929
- }
15930
-
15931
- if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
15932
- helper.css("position", "absolute");
15933
- }
15934
-
15935
- return helper;
15936
-
15937
- },
15938
-
15939
- _adjustOffsetFromHelper: function(obj) {
15940
- if (typeof obj === "string") {
15941
- obj = obj.split(" ");
15942
- }
15943
- if ($.isArray(obj)) {
15944
- obj = {left: +obj[0], top: +obj[1] || 0};
15945
- }
15946
- if ("left" in obj) {
15947
- this.offset.click.left = obj.left + this.margins.left;
15948
- }
15949
- if ("right" in obj) {
15950
- this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
15951
- }
15952
- if ("top" in obj) {
15953
- this.offset.click.top = obj.top + this.margins.top;
15954
- }
15955
- if ("bottom" in obj) {
15956
- this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
15957
- }
15958
- },
15959
-
15960
- _getParentOffset: function() {
15961
-
15962
- //Get the offsetParent and cache its position
15963
- var po = this.offsetParent.offset();
15964
-
15965
- // This is a special case where we need to modify a offset calculated on start, since the following happened:
15966
- // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
15967
- // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
15968
- // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
15969
- if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
15970
- po.left += this.scrollParent.scrollLeft();
15971
- po.top += this.scrollParent.scrollTop();
15972
- }
15973
-
15974
- //This needs to be actually done for all browsers, since pageX/pageY includes this information
15975
- //Ugly IE fix
15976
- if((this.offsetParent[0] === document.body) ||
15977
- (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
15978
- po = { top: 0, left: 0 };
15979
- }
15980
-
15981
- return {
15982
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
15983
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
15984
- };
15985
-
15986
- },
15987
-
15988
- _getRelativeOffset: function() {
15989
-
15990
- if(this.cssPosition === "relative") {
15991
- var p = this.element.position();
15992
- return {
15993
- top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
15994
- left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
15995
- };
15996
- } else {
15997
- return { top: 0, left: 0 };
15998
- }
15999
-
16000
- },
16001
-
16002
- _cacheMargins: function() {
16003
- this.margins = {
16004
- left: (parseInt(this.element.css("marginLeft"),10) || 0),
16005
- top: (parseInt(this.element.css("marginTop"),10) || 0),
16006
- right: (parseInt(this.element.css("marginRight"),10) || 0),
16007
- bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
16008
- };
16009
- },
16010
-
16011
- _cacheHelperProportions: function() {
16012
- this.helperProportions = {
16013
- width: this.helper.outerWidth(),
16014
- height: this.helper.outerHeight()
16015
- };
16016
- },
16017
-
16018
- _setContainment: function() {
16019
-
16020
- var over, c, ce,
16021
- o = this.options;
16022
-
16023
- if ( !o.containment ) {
16024
- this.containment = null;
16025
- return;
16026
- }
16027
-
16028
- if ( o.containment === "window" ) {
16029
- this.containment = [
16030
- $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
16031
- $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
16032
- $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
16033
- $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
16034
- ];
16035
- return;
16036
- }
16037
-
16038
- if ( o.containment === "document") {
16039
- this.containment = [
16040
- 0,
16041
- 0,
16042
- $( document ).width() - this.helperProportions.width - this.margins.left,
16043
- ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
16044
- ];
16045
- return;
16046
- }
16047
-
16048
- if ( o.containment.constructor === Array ) {
16049
- this.containment = o.containment;
16050
- return;
16051
- }
16052
-
16053
- if ( o.containment === "parent" ) {
16054
- o.containment = this.helper[ 0 ].parentNode;
16055
- }
16056
-
16057
- c = $( o.containment );
16058
- ce = c[ 0 ];
16059
-
16060
- if( !ce ) {
16061
- return;
16062
- }
16063
-
16064
- over = c.css( "overflow" ) !== "hidden";
16065
-
16066
- this.containment = [
16067
- ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
16068
- ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
16069
- ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
16070
- ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
16071
- ];
16072
- this.relative_container = c;
16073
- },
16074
-
16075
- _convertPositionTo: function(d, pos) {
16076
-
16077
- if(!pos) {
16078
- pos = this.position;
16079
- }
16080
-
16081
- var mod = d === "absolute" ? 1 : -1,
16082
- scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
16083
-
16084
- //Cache the scroll
16085
- if (!this.offset.scroll) {
16086
- this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
16087
- }
16088
-
16089
- return {
16090
- top: (
16091
- pos.top + // The absolute mouse position
16092
- this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
16093
- this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
16094
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
16095
- ),
16096
- left: (
16097
- pos.left + // The absolute mouse position
16098
- this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
16099
- this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
16100
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
16101
- )
16102
- };
16103
-
16104
- },
16105
-
16106
- _generatePosition: function(event) {
16107
-
16108
- var containment, co, top, left,
16109
- o = this.options,
16110
- scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
16111
- pageX = event.pageX,
16112
- pageY = event.pageY;
16113
-
16114
- //Cache the scroll
16115
- if (!this.offset.scroll) {
16116
- this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
16117
- }
16118
-
16119
- /*
16120
- * - Position constraining -
16121
- * Constrain the position to a mix of grid, containment.
16122
- */
16123
-
16124
- // If we are not dragging yet, we won't check for options
16125
- if ( this.originalPosition ) {
16126
- if ( this.containment ) {
16127
- if ( this.relative_container ){
16128
- co = this.relative_container.offset();
16129
- containment = [
16130
- this.containment[ 0 ] + co.left,
16131
- this.containment[ 1 ] + co.top,
16132
- this.containment[ 2 ] + co.left,
16133
- this.containment[ 3 ] + co.top
16134
- ];
16135
- }
16136
- else {
16137
- containment = this.containment;
16138
- }
16139
-
16140
- if(event.pageX - this.offset.click.left < containment[0]) {
16141
- pageX = containment[0] + this.offset.click.left;
16142
- }
16143
- if(event.pageY - this.offset.click.top < containment[1]) {
16144
- pageY = containment[1] + this.offset.click.top;
16145
- }
16146
- if(event.pageX - this.offset.click.left > containment[2]) {
16147
- pageX = containment[2] + this.offset.click.left;
16148
- }
16149
- if(event.pageY - this.offset.click.top > containment[3]) {
16150
- pageY = containment[3] + this.offset.click.top;
16151
- }
16152
- }
16153
-
16154
- if(o.grid) {
16155
- //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
16156
- top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
16157
- pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
16158
-
16159
- left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
16160
- pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
16161
- }
16162
-
16163
- }
16164
-
16165
- return {
16166
- top: (
16167
- pageY - // The absolute mouse position
16168
- this.offset.click.top - // Click offset (relative to the element)
16169
- this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
16170
- this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
16171
- ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
16172
- ),
16173
- left: (
16174
- pageX - // The absolute mouse position
16175
- this.offset.click.left - // Click offset (relative to the element)
16176
- this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
16177
- this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
16178
- ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
16179
- )
16180
- };
16181
-
16182
- },
16183
-
16184
- _clear: function() {
16185
- this.helper.removeClass("ui-draggable-dragging");
16186
- if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
16187
- this.helper.remove();
16188
- }
16189
- this.helper = null;
16190
- this.cancelHelperRemoval = false;
16191
- },
16192
-
16193
- // From now on bulk stuff - mainly helpers
16194
-
16195
- _trigger: function(type, event, ui) {
16196
- ui = ui || this._uiHash();
16197
- $.ui.plugin.call(this, type, [event, ui]);
16198
- //The absolute position has to be recalculated after plugins
16199
- if(type === "drag") {
16200
- this.positionAbs = this._convertPositionTo("absolute");
16201
- }
16202
- return $.Widget.prototype._trigger.call(this, type, event, ui);
16203
- },
16204
-
16205
- plugins: {},
16206
-
16207
- _uiHash: function() {
16208
- return {
16209
- helper: this.helper,
16210
- position: this.position,
16211
- originalPosition: this.originalPosition,
16212
- offset: this.positionAbs
16213
- };
16214
- }
16215
-
16216
- });
16217
-
16218
- $.ui.plugin.add("draggable", "connectToSortable", {
16219
- start: function(event, ui) {
16220
-
16221
- var inst = $(this).data("ui-draggable"), o = inst.options,
16222
- uiSortable = $.extend({}, ui, { item: inst.element });
16223
- inst.sortables = [];
16224
- $(o.connectToSortable).each(function() {
16225
- var sortable = $.data(this, "ui-sortable");
16226
- if (sortable && !sortable.options.disabled) {
16227
- inst.sortables.push({
16228
- instance: sortable,
16229
- shouldRevert: sortable.options.revert
16230
- });
16231
- sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
16232
- sortable._trigger("activate", event, uiSortable);
16233
- }
16234
- });
16235
-
16236
- },
16237
- stop: function(event, ui) {
16238
-
16239
- //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
16240
- var inst = $(this).data("ui-draggable"),
16241
- uiSortable = $.extend({}, ui, { item: inst.element });
16242
-
16243
- $.each(inst.sortables, function() {
16244
- if(this.instance.isOver) {
16245
-
16246
- this.instance.isOver = 0;
16247
-
16248
- inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
16249
- this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
16250
-
16251
- //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
16252
- if(this.shouldRevert) {
16253
- this.instance.options.revert = this.shouldRevert;
16254
- }
16255
-
16256
- //Trigger the stop of the sortable
16257
- this.instance._mouseStop(event);
16258
-
16259
- this.instance.options.helper = this.instance.options._helper;
16260
-
16261
- //If the helper has been the original item, restore properties in the sortable
16262
- if(inst.options.helper === "original") {
16263
- this.instance.currentItem.css({ top: "auto", left: "auto" });
16264
- }
16265
-
16266
- } else {
16267
- this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
16268
- this.instance._trigger("deactivate", event, uiSortable);
16269
- }
16270
-
16271
- });
16272
-
16273
- },
16274
- drag: function(event, ui) {
16275
-
16276
- var inst = $(this).data("ui-draggable"), that = this;
16277
-
16278
- $.each(inst.sortables, function() {
16279
-
16280
- var innermostIntersecting = false,
16281
- thisSortable = this;
16282
-
16283
- //Copy over some variables to allow calling the sortable's native _intersectsWith
16284
- this.instance.positionAbs = inst.positionAbs;
16285
- this.instance.helperProportions = inst.helperProportions;
16286
- this.instance.offset.click = inst.offset.click;
16287
-
16288
- if(this.instance._intersectsWith(this.instance.containerCache)) {
16289
- innermostIntersecting = true;
16290
- $.each(inst.sortables, function () {
16291
- this.instance.positionAbs = inst.positionAbs;
16292
- this.instance.helperProportions = inst.helperProportions;
16293
- this.instance.offset.click = inst.offset.click;
16294
- if (this !== thisSortable &&
16295
- this.instance._intersectsWith(this.instance.containerCache) &&
16296
- $.contains(thisSortable.instance.element[0], this.instance.element[0])
16297
- ) {
16298
- innermostIntersecting = false;
16299
- }
16300
- return innermostIntersecting;
16301
- });
16302
- }
16303
-
16304
-
16305
- if(innermostIntersecting) {
16306
- //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
16307
- if(!this.instance.isOver) {
16308
-
16309
- this.instance.isOver = 1;
16310
- //Now we fake the start of dragging for the sortable instance,
16311
- //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
16312
- //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
16313
- this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
16314
- this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
16315
- this.instance.options.helper = function() { return ui.helper[0]; };
16316
-
16317
- event.target = this.instance.currentItem[0];
16318
- this.instance._mouseCapture(event, true);
16319
- this.instance._mouseStart(event, true, true);
16320
-
16321
- //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
16322
- this.instance.offset.click.top = inst.offset.click.top;
16323
- this.instance.offset.click.left = inst.offset.click.left;
16324
- this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
16325
- this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
16326
-
16327
- inst._trigger("toSortable", event);
16328
- inst.dropped = this.instance.element; //draggable revert needs that
16329
- //hack so receive/update callbacks work (mostly)
16330
- inst.currentItem = inst.element;
16331
- this.instance.fromOutside = inst;
16332
-
16333
- }
16334
-
16335
- //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
16336
- if(this.instance.currentItem) {
16337
- this.instance._mouseDrag(event);
16338
- }
16339
-
16340
- } else {
16341
-
16342
- //If it doesn't intersect with the sortable, and it intersected before,
16343
- //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
16344
- if(this.instance.isOver) {
16345
-
16346
- this.instance.isOver = 0;
16347
- this.instance.cancelHelperRemoval = true;
16348
-
16349
- //Prevent reverting on this forced stop
16350
- this.instance.options.revert = false;
16351
-
16352
- // The out event needs to be triggered independently
16353
- this.instance._trigger("out", event, this.instance._uiHash(this.instance));
16354
-
16355
- this.instance._mouseStop(event, true);
16356
- this.instance.options.helper = this.instance.options._helper;
16357
-
16358
- //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
16359
- this.instance.currentItem.remove();
16360
- if(this.instance.placeholder) {
16361
- this.instance.placeholder.remove();
16362
- }
16363
-
16364
- inst._trigger("fromSortable", event);
16365
- inst.dropped = false; //draggable revert needs that
16366
- }
16367
-
16368
- }
16369
-
16370
- });
16371
-
16372
- }
16373
- });
16374
-
16375
- $.ui.plugin.add("draggable", "cursor", {
16376
- start: function() {
16377
- var t = $("body"), o = $(this).data("ui-draggable").options;
16378
- if (t.css("cursor")) {
16379
- o._cursor = t.css("cursor");
16380
- }
16381
- t.css("cursor", o.cursor);
16382
- },
16383
- stop: function() {
16384
- var o = $(this).data("ui-draggable").options;
16385
- if (o._cursor) {
16386
- $("body").css("cursor", o._cursor);
16387
- }
16388
- }
16389
- });
16390
-
16391
- $.ui.plugin.add("draggable", "opacity", {
16392
- start: function(event, ui) {
16393
- var t = $(ui.helper), o = $(this).data("ui-draggable").options;
16394
- if(t.css("opacity")) {
16395
- o._opacity = t.css("opacity");
16396
- }
16397
- t.css("opacity", o.opacity);
16398
- },
16399
- stop: function(event, ui) {
16400
- var o = $(this).data("ui-draggable").options;
16401
- if(o._opacity) {
16402
- $(ui.helper).css("opacity", o._opacity);
16403
- }
16404
- }
16405
- });
16406
-
16407
- $.ui.plugin.add("draggable", "scroll", {
16408
- start: function() {
16409
- var i = $(this).data("ui-draggable");
16410
- if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
16411
- i.overflowOffset = i.scrollParent.offset();
16412
- }
16413
- },
16414
- drag: function( event ) {
16415
-
16416
- var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
16417
-
16418
- if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
16419
-
16420
- if(!o.axis || o.axis !== "x") {
16421
- if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
16422
- i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
16423
- } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
16424
- i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
16425
- }
16426
- }
16427
-
16428
- if(!o.axis || o.axis !== "y") {
16429
- if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
16430
- i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
16431
- } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
16432
- i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
16433
- }
16434
- }
16435
-
16436
- } else {
16437
-
16438
- if(!o.axis || o.axis !== "x") {
16439
- if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
16440
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
16441
- } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
16442
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
16443
- }
16444
- }
16445
-
16446
- if(!o.axis || o.axis !== "y") {
16447
- if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
16448
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
16449
- } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
16450
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
16451
- }
16452
- }
16453
-
16454
- }
16455
-
16456
- if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
16457
- $.ui.ddmanager.prepareOffsets(i, event);
16458
- }
16459
-
16460
- }
16461
- });
16462
-
16463
- $.ui.plugin.add("draggable", "snap", {
16464
- start: function() {
16465
-
16466
- var i = $(this).data("ui-draggable"),
16467
- o = i.options;
16468
-
16469
- i.snapElements = [];
16470
-
16471
- $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
16472
- var $t = $(this),
16473
- $o = $t.offset();
16474
- if(this !== i.element[0]) {
16475
- i.snapElements.push({
16476
- item: this,
16477
- width: $t.outerWidth(), height: $t.outerHeight(),
16478
- top: $o.top, left: $o.left
16479
- });
16480
- }
16481
- });
16482
-
16483
- },
16484
- drag: function(event, ui) {
16485
-
16486
- var ts, bs, ls, rs, l, r, t, b, i, first,
16487
- inst = $(this).data("ui-draggable"),
16488
- o = inst.options,
16489
- d = o.snapTolerance,
16490
- x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
16491
- y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
16492
-
16493
- for (i = inst.snapElements.length - 1; i >= 0; i--){
16494
-
16495
- l = inst.snapElements[i].left;
16496
- r = l + inst.snapElements[i].width;
16497
- t = inst.snapElements[i].top;
16498
- b = t + inst.snapElements[i].height;
16499
-
16500
- if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
16501
- if(inst.snapElements[i].snapping) {
16502
- (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
16503
- }
16504
- inst.snapElements[i].snapping = false;
16505
- continue;
16506
- }
16507
-
16508
- if(o.snapMode !== "inner") {
16509
- ts = Math.abs(t - y2) <= d;
16510
- bs = Math.abs(b - y1) <= d;
16511
- ls = Math.abs(l - x2) <= d;
16512
- rs = Math.abs(r - x1) <= d;
16513
- if(ts) {
16514
- ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
16515
- }
16516
- if(bs) {
16517
- ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
16518
- }
16519
- if(ls) {
16520
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
16521
- }
16522
- if(rs) {
16523
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
16524
- }
16525
- }
16526
-
16527
- first = (ts || bs || ls || rs);
16528
-
16529
- if(o.snapMode !== "outer") {
16530
- ts = Math.abs(t - y1) <= d;
16531
- bs = Math.abs(b - y2) <= d;
16532
- ls = Math.abs(l - x1) <= d;
16533
- rs = Math.abs(r - x2) <= d;
16534
- if(ts) {
16535
- ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
16536
- }
16537
- if(bs) {
16538
- ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
16539
- }
16540
- if(ls) {
16541
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
16542
- }
16543
- if(rs) {
16544
- ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
16545
- }
16546
- }
16547
-
16548
- if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
16549
- (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
16550
- }
16551
- inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
16552
-
16553
- }
16554
-
16555
- }
16556
- });
16557
-
16558
- $.ui.plugin.add("draggable", "stack", {
16559
- start: function() {
16560
- var min,
16561
- o = this.data("ui-draggable").options,
16562
- group = $.makeArray($(o.stack)).sort(function(a,b) {
16563
- return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
16564
- });
16565
-
16566
- if (!group.length) { return; }
16567
-
16568
- min = parseInt($(group[0]).css("zIndex"), 10) || 0;
16569
- $(group).each(function(i) {
16570
- $(this).css("zIndex", min + i);
16571
- });
16572
- this.css("zIndex", (min + group.length));
16573
- }
16574
- });
16575
-
16576
- $.ui.plugin.add("draggable", "zIndex", {
16577
- start: function(event, ui) {
16578
- var t = $(ui.helper), o = $(this).data("ui-draggable").options;
16579
- if(t.css("zIndex")) {
16580
- o._zIndex = t.css("zIndex");
16581
- }
16582
- t.css("zIndex", o.zIndex);
16583
- },
16584
- stop: function(event, ui) {
16585
- var o = $(this).data("ui-draggable").options;
16586
- if(o._zIndex) {
16587
- $(ui.helper).css("zIndex", o._zIndex);
16588
- }
16589
- }
16590
- });
16591
-
16592
- })(jQuery);
16593
-
16594
- },{"./core":231,"./mouse":233,"./widget":236,"jquery":237}],233:[function(require,module,exports){
16595
- var jQuery = require('jquery');
16596
- require('./widget');
16597
-
16598
- /*!
16599
- * jQuery UI Mouse 1.10.4
16600
- * http://jqueryui.com
16601
- *
16602
- * Copyright 2014 jQuery Foundation and other contributors
16603
- * Released under the MIT license.
16604
- * http://jquery.org/license
16605
- *
16606
- * http://api.jqueryui.com/mouse/
16607
- *
16608
- * Depends:
16609
- * jquery.ui.widget.js
16610
- */
16611
- (function( $, undefined ) {
16612
-
16613
- var mouseHandled = false;
16614
- $( document ).mouseup( function() {
16615
- mouseHandled = false;
16616
- });
16617
-
16618
- $.widget("ui.mouse", {
16619
- version: "1.10.4",
16620
- options: {
16621
- cancel: "input,textarea,button,select,option",
16622
- distance: 1,
16623
- delay: 0
16624
- },
16625
- _mouseInit: function() {
16626
- var that = this;
16627
-
16628
- this.element
16629
- .bind("mousedown."+this.widgetName, function(event) {
16630
- return that._mouseDown(event);
16631
- })
16632
- .bind("click."+this.widgetName, function(event) {
16633
- if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
16634
- $.removeData(event.target, that.widgetName + ".preventClickEvent");
16635
- event.stopImmediatePropagation();
16636
- return false;
16637
- }
16638
- });
16639
-
16640
- this.started = false;
16641
- },
16642
-
16643
- // TODO: make sure destroying one instance of mouse doesn't mess with
16644
- // other instances of mouse
16645
- _mouseDestroy: function() {
16646
- this.element.unbind("."+this.widgetName);
16647
- if ( this._mouseMoveDelegate ) {
16648
- $(document)
16649
- .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
16650
- .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
16651
- }
16652
- },
16653
-
16654
- _mouseDown: function(event) {
16655
- // don't let more than one widget handle mouseStart
16656
- if( mouseHandled ) { return; }
16657
-
16658
- // we may have missed mouseup (out of window)
16659
- (this._mouseStarted && this._mouseUp(event));
16660
-
16661
- this._mouseDownEvent = event;
16662
-
16663
- var that = this,
16664
- btnIsLeft = (event.which === 1),
16665
- // event.target.nodeName works around a bug in IE 8 with
16666
- // disabled inputs (#7620)
16667
- elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
16668
- if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
16669
- return true;
16670
- }
16671
-
16672
- this.mouseDelayMet = !this.options.delay;
16673
- if (!this.mouseDelayMet) {
16674
- this._mouseDelayTimer = setTimeout(function() {
16675
- that.mouseDelayMet = true;
16676
- }, this.options.delay);
16677
- }
16678
-
16679
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
16680
- this._mouseStarted = (this._mouseStart(event) !== false);
16681
- if (!this._mouseStarted) {
16682
- event.preventDefault();
16683
- return true;
16684
- }
16685
- }
16686
-
16687
- // Click event may never have fired (Gecko & Opera)
16688
- if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
16689
- $.removeData(event.target, this.widgetName + ".preventClickEvent");
16690
- }
16691
-
16692
- // these delegates are required to keep context
16693
- this._mouseMoveDelegate = function(event) {
16694
- return that._mouseMove(event);
16695
- };
16696
- this._mouseUpDelegate = function(event) {
16697
- return that._mouseUp(event);
16698
- };
16699
- $(document)
16700
- .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
16701
- .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
16702
-
16703
- event.preventDefault();
16704
-
16705
- mouseHandled = true;
16706
- return true;
16707
- },
16708
-
16709
- _mouseMove: function(event) {
16710
- // IE mouseup check - mouseup happened when mouse was out of window
16711
- if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
16712
- return this._mouseUp(event);
16713
- }
16714
-
16715
- if (this._mouseStarted) {
16716
- this._mouseDrag(event);
16717
- return event.preventDefault();
16718
- }
16719
-
16720
- if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
16721
- this._mouseStarted =
16722
- (this._mouseStart(this._mouseDownEvent, event) !== false);
16723
- (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
16724
- }
16725
-
16726
- return !this._mouseStarted;
16727
- },
16728
-
16729
- _mouseUp: function(event) {
16730
- $(document)
16731
- .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
16732
- .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
16733
-
16734
- if (this._mouseStarted) {
16735
- this._mouseStarted = false;
16736
-
16737
- if (event.target === this._mouseDownEvent.target) {
16738
- $.data(event.target, this.widgetName + ".preventClickEvent", true);
16739
- }
16740
-
16741
- this._mouseStop(event);
16742
- }
16743
-
16744
- return false;
16745
- },
16746
-
16747
- _mouseDistanceMet: function(event) {
16748
- return (Math.max(
16749
- Math.abs(this._mouseDownEvent.pageX - event.pageX),
16750
- Math.abs(this._mouseDownEvent.pageY - event.pageY)
16751
- ) >= this.options.distance
16752
- );
16753
- },
16754
-
16755
- _mouseDelayMet: function(/* event */) {
16756
- return this.mouseDelayMet;
16757
- },
16758
-
16759
- // These are placeholder methods, to be overriden by extending plugin
16760
- _mouseStart: function(/* event */) {},
16761
- _mouseDrag: function(/* event */) {},
16762
- _mouseStop: function(/* event */) {},
16763
- _mouseCapture: function(/* event */) { return true; }
16764
- });
16765
-
16766
- })(jQuery);
16767
-
16768
- },{"./widget":236,"jquery":237}],234:[function(require,module,exports){
16769
- var jQuery = require('jquery');
16770
- require('./core');
16771
- require('./mouse');
16772
- require('./widget');
16773
-
16774
- /*!
16775
- * jQuery UI Slider 1.10.4
16776
- * http://jqueryui.com
16777
- *
16778
- * Copyright 2014 jQuery Foundation and other contributors
16779
- * Released under the MIT license.
16780
- * http://jquery.org/license
16781
- *
16782
- * http://api.jqueryui.com/slider/
16783
- *
16784
- * Depends:
16785
- * jquery.ui.core.js
16786
- * jquery.ui.mouse.js
16787
- * jquery.ui.widget.js
16788
- */
16789
- (function( $, undefined ) {
16790
-
16791
- // number of pages in a slider
16792
- // (how many times can you page up/down to go through the whole range)
16793
- var numPages = 5;
16794
-
16795
- $.widget( "ui.slider", $.ui.mouse, {
16796
- version: "1.10.4",
16797
- widgetEventPrefix: "slide",
16798
-
16799
- options: {
16800
- animate: false,
16801
- distance: 0,
16802
- max: 100,
16803
- min: 0,
16804
- orientation: "horizontal",
16805
- range: false,
16806
- step: 1,
16807
- value: 0,
16808
- values: null,
16809
-
16810
- // callbacks
16811
- change: null,
16812
- slide: null,
16813
- start: null,
16814
- stop: null
16815
- },
16816
-
16817
- _create: function() {
16818
- this._keySliding = false;
16819
- this._mouseSliding = false;
16820
- this._animateOff = true;
16821
- this._handleIndex = null;
16822
- this._detectOrientation();
16823
- this._mouseInit();
16824
-
16825
- this.element
16826
- .addClass( "ui-slider" +
16827
- " ui-slider-" + this.orientation +
16828
- " ui-widget" +
16829
- " ui-widget-content" +
16830
- " ui-corner-all");
16831
-
16832
- this._refresh();
16833
- this._setOption( "disabled", this.options.disabled );
16834
-
16835
- this._animateOff = false;
16836
- },
16837
-
16838
- _refresh: function() {
16839
- this._createRange();
16840
- this._createHandles();
16841
- this._setupEvents();
16842
- this._refreshValue();
16843
- },
16844
-
16845
- _createHandles: function() {
16846
- var i, handleCount,
16847
- options = this.options,
16848
- existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
16849
- handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
16850
- handles = [];
16851
-
16852
- handleCount = ( options.values && options.values.length ) || 1;
16853
-
16854
- if ( existingHandles.length > handleCount ) {
16855
- existingHandles.slice( handleCount ).remove();
16856
- existingHandles = existingHandles.slice( 0, handleCount );
16857
- }
16858
-
16859
- for ( i = existingHandles.length; i < handleCount; i++ ) {
16860
- handles.push( handle );
16861
- }
16862
-
16863
- this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
16864
-
16865
- this.handle = this.handles.eq( 0 );
16866
-
16867
- this.handles.each(function( i ) {
16868
- $( this ).data( "ui-slider-handle-index", i );
16869
- });
16870
- },
16871
-
16872
- _createRange: function() {
16873
- var options = this.options,
16874
- classes = "";
16875
-
16876
- if ( options.range ) {
16877
- if ( options.range === true ) {
16878
- if ( !options.values ) {
16879
- options.values = [ this._valueMin(), this._valueMin() ];
16880
- } else if ( options.values.length && options.values.length !== 2 ) {
16881
- options.values = [ options.values[0], options.values[0] ];
16882
- } else if ( $.isArray( options.values ) ) {
16883
- options.values = options.values.slice(0);
16884
- }
16885
- }
16886
-
16887
- if ( !this.range || !this.range.length ) {
16888
- this.range = $( "<div></div>" )
16889
- .appendTo( this.element );
16890
-
16891
- classes = "ui-slider-range" +
16892
- // note: this isn't the most fittingly semantic framework class for this element,
16893
- // but worked best visually with a variety of themes
16894
- " ui-widget-header ui-corner-all";
16895
- } else {
16896
- this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
16897
- // Handle range switching from true to min/max
16898
- .css({
16899
- "left": "",
16900
- "bottom": ""
16901
- });
16902
- }
16903
-
16904
- this.range.addClass( classes +
16905
- ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
16906
- } else {
16907
- if ( this.range ) {
16908
- this.range.remove();
16909
- }
16910
- this.range = null;
16911
- }
16912
- },
16913
-
16914
- _setupEvents: function() {
16915
- var elements = this.handles.add( this.range ).filter( "a" );
16916
- this._off( elements );
16917
- this._on( elements, this._handleEvents );
16918
- this._hoverable( elements );
16919
- this._focusable( elements );
16920
- },
16921
-
16922
- _destroy: function() {
16923
- this.handles.remove();
16924
- if ( this.range ) {
16925
- this.range.remove();
16926
- }
16927
-
16928
- this.element
16929
- .removeClass( "ui-slider" +
16930
- " ui-slider-horizontal" +
16931
- " ui-slider-vertical" +
16932
- " ui-widget" +
16933
- " ui-widget-content" +
16934
- " ui-corner-all" );
16935
-
16936
- this._mouseDestroy();
16937
- },
16938
-
16939
- _mouseCapture: function( event ) {
16940
- var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
16941
- that = this,
16942
- o = this.options;
16943
-
16944
- if ( o.disabled ) {
16945
- return false;
16946
- }
16947
-
16948
- this.elementSize = {
16949
- width: this.element.outerWidth(),
16950
- height: this.element.outerHeight()
16951
- };
16952
- this.elementOffset = this.element.offset();
16953
-
16954
- position = { x: event.pageX, y: event.pageY };
16955
- normValue = this._normValueFromMouse( position );
16956
- distance = this._valueMax() - this._valueMin() + 1;
16957
- this.handles.each(function( i ) {
16958
- var thisDistance = Math.abs( normValue - that.values(i) );
16959
- if (( distance > thisDistance ) ||
16960
- ( distance === thisDistance &&
16961
- (i === that._lastChangedValue || that.values(i) === o.min ))) {
16962
- distance = thisDistance;
16963
- closestHandle = $( this );
16964
- index = i;
16965
- }
16966
- });
16967
-
16968
- allowed = this._start( event, index );
16969
- if ( allowed === false ) {
16970
- return false;
16971
- }
16972
- this._mouseSliding = true;
16973
-
16974
- this._handleIndex = index;
16975
-
16976
- closestHandle
16977
- .addClass( "ui-state-active" )
16978
- .focus();
16979
-
16980
- offset = closestHandle.offset();
16981
- mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
16982
- this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
16983
- left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
16984
- top: event.pageY - offset.top -
16985
- ( closestHandle.height() / 2 ) -
16986
- ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
16987
- ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
16988
- ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
16989
- };
16990
-
16991
- if ( !this.handles.hasClass( "ui-state-hover" ) ) {
16992
- this._slide( event, index, normValue );
16993
- }
16994
- this._animateOff = true;
16995
- return true;
16996
- },
16997
-
16998
- _mouseStart: function() {
16999
- return true;
17000
- },
17001
-
17002
- _mouseDrag: function( event ) {
17003
- var position = { x: event.pageX, y: event.pageY },
17004
- normValue = this._normValueFromMouse( position );
17005
-
17006
- this._slide( event, this._handleIndex, normValue );
17007
-
17008
- return false;
17009
- },
17010
-
17011
- _mouseStop: function( event ) {
17012
- this.handles.removeClass( "ui-state-active" );
17013
- this._mouseSliding = false;
17014
-
17015
- this._stop( event, this._handleIndex );
17016
- this._change( event, this._handleIndex );
17017
-
17018
- this._handleIndex = null;
17019
- this._clickOffset = null;
17020
- this._animateOff = false;
17021
-
17022
- return false;
17023
- },
17024
-
17025
- _detectOrientation: function() {
17026
- this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
17027
- },
17028
-
17029
- _normValueFromMouse: function( position ) {
17030
- var pixelTotal,
17031
- pixelMouse,
17032
- percentMouse,
17033
- valueTotal,
17034
- valueMouse;
17035
-
17036
- if ( this.orientation === "horizontal" ) {
17037
- pixelTotal = this.elementSize.width;
17038
- pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
17039
- } else {
17040
- pixelTotal = this.elementSize.height;
17041
- pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
17042
- }
17043
-
17044
- percentMouse = ( pixelMouse / pixelTotal );
17045
- if ( percentMouse > 1 ) {
17046
- percentMouse = 1;
17047
- }
17048
- if ( percentMouse < 0 ) {
17049
- percentMouse = 0;
17050
- }
17051
- if ( this.orientation === "vertical" ) {
17052
- percentMouse = 1 - percentMouse;
17053
- }
17054
-
17055
- valueTotal = this._valueMax() - this._valueMin();
17056
- valueMouse = this._valueMin() + percentMouse * valueTotal;
17057
-
17058
- return this._trimAlignValue( valueMouse );
17059
- },
17060
-
17061
- _start: function( event, index ) {
17062
- var uiHash = {
17063
- handle: this.handles[ index ],
17064
- value: this.value()
17065
- };
17066
- if ( this.options.values && this.options.values.length ) {
17067
- uiHash.value = this.values( index );
17068
- uiHash.values = this.values();
17069
- }
17070
- return this._trigger( "start", event, uiHash );
17071
- },
17072
-
17073
- _slide: function( event, index, newVal ) {
17074
- var otherVal,
17075
- newValues,
17076
- allowed;
17077
-
17078
- if ( this.options.values && this.options.values.length ) {
17079
- otherVal = this.values( index ? 0 : 1 );
17080
-
17081
- if ( ( this.options.values.length === 2 && this.options.range === true ) &&
17082
- ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
17083
- ) {
17084
- newVal = otherVal;
17085
- }
17086
-
17087
- if ( newVal !== this.values( index ) ) {
17088
- newValues = this.values();
17089
- newValues[ index ] = newVal;
17090
- // A slide can be canceled by returning false from the slide callback
17091
- allowed = this._trigger( "slide", event, {
17092
- handle: this.handles[ index ],
17093
- value: newVal,
17094
- values: newValues
17095
- } );
17096
- otherVal = this.values( index ? 0 : 1 );
17097
- if ( allowed !== false ) {
17098
- this.values( index, newVal );
17099
- }
17100
- }
17101
- } else {
17102
- if ( newVal !== this.value() ) {
17103
- // A slide can be canceled by returning false from the slide callback
17104
- allowed = this._trigger( "slide", event, {
17105
- handle: this.handles[ index ],
17106
- value: newVal
17107
- } );
17108
- if ( allowed !== false ) {
17109
- this.value( newVal );
17110
- }
17111
- }
17112
- }
17113
- },
17114
-
17115
- _stop: function( event, index ) {
17116
- var uiHash = {
17117
- handle: this.handles[ index ],
17118
- value: this.value()
17119
- };
17120
- if ( this.options.values && this.options.values.length ) {
17121
- uiHash.value = this.values( index );
17122
- uiHash.values = this.values();
17123
- }
17124
-
17125
- this._trigger( "stop", event, uiHash );
17126
- },
17127
-
17128
- _change: function( event, index ) {
17129
- if ( !this._keySliding && !this._mouseSliding ) {
17130
- var uiHash = {
17131
- handle: this.handles[ index ],
17132
- value: this.value()
17133
- };
17134
- if ( this.options.values && this.options.values.length ) {
17135
- uiHash.value = this.values( index );
17136
- uiHash.values = this.values();
17137
- }
17138
-
17139
- //store the last changed value index for reference when handles overlap
17140
- this._lastChangedValue = index;
17141
-
17142
- this._trigger( "change", event, uiHash );
17143
- }
17144
- },
17145
-
17146
- value: function( newValue ) {
17147
- if ( arguments.length ) {
17148
- this.options.value = this._trimAlignValue( newValue );
17149
- this._refreshValue();
17150
- this._change( null, 0 );
17151
- return;
17152
- }
17153
-
17154
- return this._value();
17155
- },
17156
-
17157
- values: function( index, newValue ) {
17158
- var vals,
17159
- newValues,
17160
- i;
17161
-
17162
- if ( arguments.length > 1 ) {
17163
- this.options.values[ index ] = this._trimAlignValue( newValue );
17164
- this._refreshValue();
17165
- this._change( null, index );
17166
- return;
17167
- }
17168
-
17169
- if ( arguments.length ) {
17170
- if ( $.isArray( arguments[ 0 ] ) ) {
17171
- vals = this.options.values;
17172
- newValues = arguments[ 0 ];
17173
- for ( i = 0; i < vals.length; i += 1 ) {
17174
- vals[ i ] = this._trimAlignValue( newValues[ i ] );
17175
- this._change( null, i );
17176
- }
17177
- this._refreshValue();
17178
- } else {
17179
- if ( this.options.values && this.options.values.length ) {
17180
- return this._values( index );
17181
- } else {
17182
- return this.value();
17183
- }
17184
- }
17185
- } else {
17186
- return this._values();
17187
- }
17188
- },
17189
-
17190
- _setOption: function( key, value ) {
17191
- var i,
17192
- valsLength = 0;
17193
-
17194
- if ( key === "range" && this.options.range === true ) {
17195
- if ( value === "min" ) {
17196
- this.options.value = this._values( 0 );
17197
- this.options.values = null;
17198
- } else if ( value === "max" ) {
17199
- this.options.value = this._values( this.options.values.length-1 );
17200
- this.options.values = null;
17201
- }
17202
- }
17203
-
17204
- if ( $.isArray( this.options.values ) ) {
17205
- valsLength = this.options.values.length;
17206
- }
17207
-
17208
- $.Widget.prototype._setOption.apply( this, arguments );
17209
-
17210
- switch ( key ) {
17211
- case "orientation":
17212
- this._detectOrientation();
17213
- this.element
17214
- .removeClass( "ui-slider-horizontal ui-slider-vertical" )
17215
- .addClass( "ui-slider-" + this.orientation );
17216
- this._refreshValue();
17217
- break;
17218
- case "value":
17219
- this._animateOff = true;
17220
- this._refreshValue();
17221
- this._change( null, 0 );
17222
- this._animateOff = false;
17223
- break;
17224
- case "values":
17225
- this._animateOff = true;
17226
- this._refreshValue();
17227
- for ( i = 0; i < valsLength; i += 1 ) {
17228
- this._change( null, i );
17229
- }
17230
- this._animateOff = false;
17231
- break;
17232
- case "min":
17233
- case "max":
17234
- this._animateOff = true;
17235
- this._refreshValue();
17236
- this._animateOff = false;
17237
- break;
17238
- case "range":
17239
- this._animateOff = true;
17240
- this._refresh();
17241
- this._animateOff = false;
17242
- break;
17243
- }
17244
- },
17245
-
17246
- //internal value getter
17247
- // _value() returns value trimmed by min and max, aligned by step
17248
- _value: function() {
17249
- var val = this.options.value;
17250
- val = this._trimAlignValue( val );
17251
-
17252
- return val;
17253
- },
17254
-
17255
- //internal values getter
17256
- // _values() returns array of values trimmed by min and max, aligned by step
17257
- // _values( index ) returns single value trimmed by min and max, aligned by step
17258
- _values: function( index ) {
17259
- var val,
17260
- vals,
17261
- i;
17262
-
17263
- if ( arguments.length ) {
17264
- val = this.options.values[ index ];
17265
- val = this._trimAlignValue( val );
17266
-
17267
- return val;
17268
- } else if ( this.options.values && this.options.values.length ) {
17269
- // .slice() creates a copy of the array
17270
- // this copy gets trimmed by min and max and then returned
17271
- vals = this.options.values.slice();
17272
- for ( i = 0; i < vals.length; i+= 1) {
17273
- vals[ i ] = this._trimAlignValue( vals[ i ] );
17274
- }
17275
-
17276
- return vals;
17277
- } else {
17278
- return [];
17279
- }
17280
- },
17281
-
17282
- // returns the step-aligned value that val is closest to, between (inclusive) min and max
17283
- _trimAlignValue: function( val ) {
17284
- if ( val <= this._valueMin() ) {
17285
- return this._valueMin();
17286
- }
17287
- if ( val >= this._valueMax() ) {
17288
- return this._valueMax();
17289
- }
17290
- var step = ( this.options.step > 0 ) ? this.options.step : 1,
17291
- valModStep = (val - this._valueMin()) % step,
17292
- alignValue = val - valModStep;
17293
-
17294
- if ( Math.abs(valModStep) * 2 >= step ) {
17295
- alignValue += ( valModStep > 0 ) ? step : ( -step );
17296
- }
17297
-
17298
- // Since JavaScript has problems with large floats, round
17299
- // the final value to 5 digits after the decimal point (see #4124)
17300
- return parseFloat( alignValue.toFixed(5) );
17301
- },
17302
-
17303
- _valueMin: function() {
17304
- return this.options.min;
17305
- },
17306
-
17307
- _valueMax: function() {
17308
- return this.options.max;
17309
- },
17310
-
17311
- _refreshValue: function() {
17312
- var lastValPercent, valPercent, value, valueMin, valueMax,
17313
- oRange = this.options.range,
17314
- o = this.options,
17315
- that = this,
17316
- animate = ( !this._animateOff ) ? o.animate : false,
17317
- _set = {};
17318
-
17319
- if ( this.options.values && this.options.values.length ) {
17320
- this.handles.each(function( i ) {
17321
- valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
17322
- _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
17323
- $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
17324
- if ( that.options.range === true ) {
17325
- if ( that.orientation === "horizontal" ) {
17326
- if ( i === 0 ) {
17327
- that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
17328
- }
17329
- if ( i === 1 ) {
17330
- that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
17331
- }
17332
- } else {
17333
- if ( i === 0 ) {
17334
- that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
17335
- }
17336
- if ( i === 1 ) {
17337
- that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
17338
- }
17339
- }
17340
- }
17341
- lastValPercent = valPercent;
17342
- });
17343
- } else {
17344
- value = this.value();
17345
- valueMin = this._valueMin();
17346
- valueMax = this._valueMax();
17347
- valPercent = ( valueMax !== valueMin ) ?
17348
- ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
17349
- 0;
17350
- _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
17351
- this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
17352
-
17353
- if ( oRange === "min" && this.orientation === "horizontal" ) {
17354
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
17355
- }
17356
- if ( oRange === "max" && this.orientation === "horizontal" ) {
17357
- this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
17358
- }
17359
- if ( oRange === "min" && this.orientation === "vertical" ) {
17360
- this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
17361
- }
17362
- if ( oRange === "max" && this.orientation === "vertical" ) {
17363
- this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
17364
- }
17365
- }
17366
- },
17367
-
17368
- _handleEvents: {
17369
- keydown: function( event ) {
17370
- var allowed, curVal, newVal, step,
17371
- index = $( event.target ).data( "ui-slider-handle-index" );
17372
-
17373
- switch ( event.keyCode ) {
17374
- case $.ui.keyCode.HOME:
17375
- case $.ui.keyCode.END:
17376
- case $.ui.keyCode.PAGE_UP:
17377
- case $.ui.keyCode.PAGE_DOWN:
17378
- case $.ui.keyCode.UP:
17379
- case $.ui.keyCode.RIGHT:
17380
- case $.ui.keyCode.DOWN:
17381
- case $.ui.keyCode.LEFT:
17382
- event.preventDefault();
17383
- if ( !this._keySliding ) {
17384
- this._keySliding = true;
17385
- $( event.target ).addClass( "ui-state-active" );
17386
- allowed = this._start( event, index );
17387
- if ( allowed === false ) {
17388
- return;
17389
- }
17390
- }
17391
- break;
17392
- }
17393
-
17394
- step = this.options.step;
17395
- if ( this.options.values && this.options.values.length ) {
17396
- curVal = newVal = this.values( index );
17397
- } else {
17398
- curVal = newVal = this.value();
17399
- }
17400
-
17401
- switch ( event.keyCode ) {
17402
- case $.ui.keyCode.HOME:
17403
- newVal = this._valueMin();
17404
- break;
17405
- case $.ui.keyCode.END:
17406
- newVal = this._valueMax();
17407
- break;
17408
- case $.ui.keyCode.PAGE_UP:
17409
- newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
17410
- break;
17411
- case $.ui.keyCode.PAGE_DOWN:
17412
- newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
17413
- break;
17414
- case $.ui.keyCode.UP:
17415
- case $.ui.keyCode.RIGHT:
17416
- if ( curVal === this._valueMax() ) {
17417
- return;
17418
- }
17419
- newVal = this._trimAlignValue( curVal + step );
17420
- break;
17421
- case $.ui.keyCode.DOWN:
17422
- case $.ui.keyCode.LEFT:
17423
- if ( curVal === this._valueMin() ) {
17424
- return;
17425
- }
17426
- newVal = this._trimAlignValue( curVal - step );
17427
- break;
17428
- }
17429
-
17430
- this._slide( event, index, newVal );
17431
- },
17432
- click: function( event ) {
17433
- event.preventDefault();
17434
- },
17435
- keyup: function( event ) {
17436
- var index = $( event.target ).data( "ui-slider-handle-index" );
17437
-
17438
- if ( this._keySliding ) {
17439
- this._keySliding = false;
17440
- this._stop( event, index );
17441
- this._change( event, index );
17442
- $( event.target ).removeClass( "ui-state-active" );
17443
- }
17444
- }
17445
- }
17446
-
17447
- });
17448
-
17449
- }(jQuery));
17450
-
17451
- },{"./core":231,"./mouse":233,"./widget":236,"jquery":237}],235:[function(require,module,exports){
17452
- var jQuery = require('jquery');
17453
- require('./core');
17454
- require('./mouse');
17455
- require('./widget');
17456
-
17457
- /*!
17458
- * jQuery UI Sortable 1.10.4
17459
- * http://jqueryui.com
17460
- *
17461
- * Copyright 2014 jQuery Foundation and other contributors
17462
- * Released under the MIT license.
17463
- * http://jquery.org/license
17464
- *
17465
- * http://api.jqueryui.com/sortable/
17466
- *
17467
- * Depends:
17468
- * jquery.ui.core.js
17469
- * jquery.ui.mouse.js
17470
- * jquery.ui.widget.js
17471
- */
17472
- (function( $, undefined ) {
17473
-
17474
- function isOverAxis( x, reference, size ) {
17475
- return ( x > reference ) && ( x < ( reference + size ) );
17476
- }
17477
-
17478
- function isFloating(item) {
17479
- return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
17480
- }
17481
-
17482
- $.widget("ui.sortable", $.ui.mouse, {
17483
- version: "1.10.4",
17484
- widgetEventPrefix: "sort",
17485
- ready: false,
17486
- options: {
17487
- appendTo: "parent",
17488
- axis: false,
17489
- connectWith: false,
17490
- containment: false,
17491
- cursor: "auto",
17492
- cursorAt: false,
17493
- dropOnEmpty: true,
17494
- forcePlaceholderSize: false,
17495
- forceHelperSize: false,
17496
- grid: false,
17497
- handle: false,
17498
- helper: "original",
17499
- items: "> *",
17500
- opacity: false,
17501
- placeholder: false,
17502
- revert: false,
17503
- scroll: true,
17504
- scrollSensitivity: 20,
17505
- scrollSpeed: 20,
17506
- scope: "default",
17507
- tolerance: "intersect",
17508
- zIndex: 1000,
17509
-
17510
- // callbacks
17511
- activate: null,
17512
- beforeStop: null,
17513
- change: null,
17514
- deactivate: null,
17515
- out: null,
17516
- over: null,
17517
- receive: null,
17518
- remove: null,
17519
- sort: null,
17520
- start: null,
17521
- stop: null,
17522
- update: null
17523
- },
17524
- _create: function() {
17525
-
17526
- var o = this.options;
17527
- this.containerCache = {};
17528
- this.element.addClass("ui-sortable");
17529
-
17530
- //Get the items
17531
- this.refresh();
17532
-
17533
- //Let's determine if the items are being displayed horizontally
17534
- this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
17535
-
17536
- //Let's determine the parent's offset
17537
- this.offset = this.element.offset();
17538
-
17539
- //Initialize mouse events for interaction
17540
- this._mouseInit();
17541
-
17542
- //We're ready to go
17543
- this.ready = true;
17544
-
17545
- },
17546
-
17547
- _destroy: function() {
17548
- this.element
17549
- .removeClass("ui-sortable ui-sortable-disabled");
17550
- this._mouseDestroy();
17551
-
17552
- for ( var i = this.items.length - 1; i >= 0; i-- ) {
17553
- this.items[i].item.removeData(this.widgetName + "-item");
17554
- }
17555
-
17556
- return this;
17557
- },
17558
-
17559
- _setOption: function(key, value){
17560
- if ( key === "disabled" ) {
17561
- this.options[ key ] = value;
17562
-
17563
- this.widget().toggleClass( "ui-sortable-disabled", !!value );
17564
- } else {
17565
- // Don't call widget base _setOption for disable as it adds ui-state-disabled class
17566
- $.Widget.prototype._setOption.apply(this, arguments);
17567
- }
17568
- },
17569
-
17570
- _mouseCapture: function(event, overrideHandle) {
17571
- var currentItem = null,
17572
- validHandle = false,
17573
- that = this;
17574
-
17575
- if (this.reverting) {
17576
- return false;
17577
- }
17578
-
17579
- if(this.options.disabled || this.options.type === "static") {
17580
- return false;
17581
- }
17582
-
17583
- //We have to refresh the items data once first
17584
- this._refreshItems(event);
17585
-
17586
- //Find out if the clicked node (or one of its parents) is a actual item in this.items
17587
- $(event.target).parents().each(function() {
17588
- if($.data(this, that.widgetName + "-item") === that) {
17589
- currentItem = $(this);
17590
- return false;
17591
- }
17592
- });
17593
- if($.data(event.target, that.widgetName + "-item") === that) {
17594
- currentItem = $(event.target);
17595
- }
17596
-
17597
- if(!currentItem) {
17598
- return false;
17599
- }
17600
- if(this.options.handle && !overrideHandle) {
17601
- $(this.options.handle, currentItem).find("*").addBack().each(function() {
17602
- if(this === event.target) {
17603
- validHandle = true;
17604
- }
17605
- });
17606
- if(!validHandle) {
17607
- return false;
17608
- }
17609
- }
17610
-
17611
- this.currentItem = currentItem;
17612
- this._removeCurrentsFromItems();
17613
- return true;
17614
-
17615
- },
17616
-
17617
- _mouseStart: function(event, overrideHandle, noActivation) {
17618
-
17619
- var i, body,
17620
- o = this.options;
17621
-
17622
- this.currentContainer = this;
17623
-
17624
- //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
17625
- this.refreshPositions();
17626
-
17627
- //Create and append the visible helper
17628
- this.helper = this._createHelper(event);
17629
-
17630
- //Cache the helper size
17631
- this._cacheHelperProportions();
17632
-
17633
- /*
17634
- * - Position generation -
17635
- * This block generates everything position related - it's the core of draggables.
17636
- */
17637
-
17638
- //Cache the margins of the original element
17639
- this._cacheMargins();
17640
-
17641
- //Get the next scrolling parent
17642
- this.scrollParent = this.helper.scrollParent();
17643
-
17644
- //The element's absolute position on the page minus margins
17645
- this.offset = this.currentItem.offset();
17646
- this.offset = {
17647
- top: this.offset.top - this.margins.top,
17648
- left: this.offset.left - this.margins.left
17649
- };
17650
-
17651
- $.extend(this.offset, {
17652
- click: { //Where the click happened, relative to the element
17653
- left: event.pageX - this.offset.left,
17654
- top: event.pageY - this.offset.top
17655
- },
17656
- parent: this._getParentOffset(),
17657
- relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
17658
- });
17659
-
17660
- // Only after we got the offset, we can change the helper's position to absolute
17661
- // TODO: Still need to figure out a way to make relative sorting possible
17662
- this.helper.css("position", "absolute");
17663
- this.cssPosition = this.helper.css("position");
17664
-
17665
- //Generate the original position
17666
- this.originalPosition = this._generatePosition(event);
17667
- this.originalPageX = event.pageX;
17668
- this.originalPageY = event.pageY;
17669
-
17670
- //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
17671
- (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
17672
-
17673
- //Cache the former DOM position
17674
- this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
17675
-
17676
- //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
17677
- if(this.helper[0] !== this.currentItem[0]) {
17678
- this.currentItem.hide();
17679
- }
17680
-
17681
- //Create the placeholder
17682
- this._createPlaceholder();
17683
-
17684
- //Set a containment if given in the options
17685
- if(o.containment) {
17686
- this._setContainment();
17687
- }
17688
-
17689
- if( o.cursor && o.cursor !== "auto" ) { // cursor option
17690
- body = this.document.find( "body" );
17691
-
17692
- // support: IE
17693
- this.storedCursor = body.css( "cursor" );
17694
- body.css( "cursor", o.cursor );
17695
-
17696
- this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
17697
- }
17698
-
17699
- if(o.opacity) { // opacity option
17700
- if (this.helper.css("opacity")) {
17701
- this._storedOpacity = this.helper.css("opacity");
17702
- }
17703
- this.helper.css("opacity", o.opacity);
17704
- }
17705
-
17706
- if(o.zIndex) { // zIndex option
17707
- if (this.helper.css("zIndex")) {
17708
- this._storedZIndex = this.helper.css("zIndex");
17709
- }
17710
- this.helper.css("zIndex", o.zIndex);
17711
- }
17712
-
17713
- //Prepare scrolling
17714
- if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
17715
- this.overflowOffset = this.scrollParent.offset();
17716
- }
17717
-
17718
- //Call callbacks
17719
- this._trigger("start", event, this._uiHash());
17720
-
17721
- //Recache the helper size
17722
- if(!this._preserveHelperProportions) {
17723
- this._cacheHelperProportions();
17724
- }
17725
-
17726
-
17727
- //Post "activate" events to possible containers
17728
- if( !noActivation ) {
17729
- for ( i = this.containers.length - 1; i >= 0; i-- ) {
17730
- this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
17731
- }
17732
- }
17733
-
17734
- //Prepare possible droppables
17735
- if($.ui.ddmanager) {
17736
- $.ui.ddmanager.current = this;
17737
- }
17738
-
17739
- if ($.ui.ddmanager && !o.dropBehaviour) {
17740
- $.ui.ddmanager.prepareOffsets(this, event);
17741
- }
17742
-
17743
- this.dragging = true;
17744
-
17745
- this.helper.addClass("ui-sortable-helper");
17746
- this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
17747
- return true;
17748
-
17749
- },
17750
-
17751
- _mouseDrag: function(event) {
17752
- var i, item, itemElement, intersection,
17753
- o = this.options,
17754
- scrolled = false;
17755
-
17756
- //Compute the helpers position
17757
- this.position = this._generatePosition(event);
17758
- this.positionAbs = this._convertPositionTo("absolute");
17759
-
17760
- if (!this.lastPositionAbs) {
17761
- this.lastPositionAbs = this.positionAbs;
17762
- }
17763
-
17764
- //Do scrolling
17765
- if(this.options.scroll) {
17766
- if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
17767
-
17768
- if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
17769
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
17770
- } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
17771
- this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
17772
- }
17773
-
17774
- if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
17775
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
17776
- } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
17777
- this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
17778
- }
17779
-
17780
- } else {
17781
-
17782
- if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
17783
- scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
17784
- } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
17785
- scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
17786
- }
17787
-
17788
- if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
17789
- scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
17790
- } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
17791
- scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
17792
- }
17793
-
17794
- }
17795
-
17796
- if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
17797
- $.ui.ddmanager.prepareOffsets(this, event);
17798
- }
17799
- }
17800
-
17801
- //Regenerate the absolute position used for position checks
17802
- this.positionAbs = this._convertPositionTo("absolute");
17803
-
17804
- //Set the helper position
17805
- if(!this.options.axis || this.options.axis !== "y") {
17806
- this.helper[0].style.left = this.position.left+"px";
17807
- }
17808
- if(!this.options.axis || this.options.axis !== "x") {
17809
- this.helper[0].style.top = this.position.top+"px";
17810
- }
17811
-
17812
- //Rearrange
17813
- for (i = this.items.length - 1; i >= 0; i--) {
17814
-
17815
- //Cache variables and intersection, continue if no intersection
17816
- item = this.items[i];
17817
- itemElement = item.item[0];
17818
- intersection = this._intersectsWithPointer(item);
17819
- if (!intersection) {
17820
- continue;
17821
- }
17822
-
17823
- // Only put the placeholder inside the current Container, skip all
17824
- // items from other containers. This works because when moving
17825
- // an item from one container to another the
17826
- // currentContainer is switched before the placeholder is moved.
17827
- //
17828
- // Without this, moving items in "sub-sortables" can cause
17829
- // the placeholder to jitter beetween the outer and inner container.
17830
- if (item.instance !== this.currentContainer) {
17831
- continue;
17832
- }
17833
-
17834
- // cannot intersect with itself
17835
- // no useless actions that have been done before
17836
- // no action if the item moved is the parent of the item checked
17837
- if (itemElement !== this.currentItem[0] &&
17838
- this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
17839
- !$.contains(this.placeholder[0], itemElement) &&
17840
- (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
17841
- ) {
17842
-
17843
- this.direction = intersection === 1 ? "down" : "up";
17844
-
17845
- if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
17846
- this._rearrange(event, item);
17847
- } else {
17848
- break;
17849
- }
17850
-
17851
- this._trigger("change", event, this._uiHash());
17852
- break;
17853
- }
17854
- }
17855
-
17856
- //Post events to containers
17857
- this._contactContainers(event);
17858
-
17859
- //Interconnect with droppables
17860
- if($.ui.ddmanager) {
17861
- $.ui.ddmanager.drag(this, event);
17862
- }
17863
-
17864
- //Call callbacks
17865
- this._trigger("sort", event, this._uiHash());
17866
-
17867
- this.lastPositionAbs = this.positionAbs;
17868
- return false;
17869
-
17870
- },
17871
-
17872
- _mouseStop: function(event, noPropagation) {
17873
-
17874
- if(!event) {
17875
- return;
17876
- }
17877
-
17878
- //If we are using droppables, inform the manager about the drop
17879
- if ($.ui.ddmanager && !this.options.dropBehaviour) {
17880
- $.ui.ddmanager.drop(this, event);
17881
- }
17882
-
17883
- if(this.options.revert) {
17884
- var that = this,
17885
- cur = this.placeholder.offset(),
17886
- axis = this.options.axis,
17887
- animation = {};
17888
-
17889
- if ( !axis || axis === "x" ) {
17890
- animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
17891
- }
17892
- if ( !axis || axis === "y" ) {
17893
- animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
17894
- }
17895
- this.reverting = true;
17896
- $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
17897
- that._clear(event);
17898
- });
17899
- } else {
17900
- this._clear(event, noPropagation);
17901
- }
17902
-
17903
- return false;
17904
-
17905
- },
17906
-
17907
- cancel: function() {
17908
-
17909
- if(this.dragging) {
17910
-
17911
- this._mouseUp({ target: null });
17912
-
17913
- if(this.options.helper === "original") {
17914
- this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
17915
- } else {
17916
- this.currentItem.show();
17917
- }
17918
-
17919
- //Post deactivating events to containers
17920
- for (var i = this.containers.length - 1; i >= 0; i--){
17921
- this.containers[i]._trigger("deactivate", null, this._uiHash(this));
17922
- if(this.containers[i].containerCache.over) {
17923
- this.containers[i]._trigger("out", null, this._uiHash(this));
17924
- this.containers[i].containerCache.over = 0;
17925
- }
17926
- }
17927
-
17928
- }
17929
-
17930
- if (this.placeholder) {
17931
- //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
17932
- if(this.placeholder[0].parentNode) {
17933
- this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
17934
- }
17935
- if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
17936
- this.helper.remove();
17937
- }
17938
-
17939
- $.extend(this, {
17940
- helper: null,
17941
- dragging: false,
17942
- reverting: false,
17943
- _noFinalSort: null
17944
- });
17945
-
17946
- if(this.domPosition.prev) {
17947
- $(this.domPosition.prev).after(this.currentItem);
17948
- } else {
17949
- $(this.domPosition.parent).prepend(this.currentItem);
17950
- }
17951
- }
17952
-
17953
- return this;
17954
-
17955
- },
17956
-
17957
- serialize: function(o) {
17958
-
17959
- var items = this._getItemsAsjQuery(o && o.connected),
17960
- str = [];
17961
- o = o || {};
17962
-
17963
- $(items).each(function() {
17964
- var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
17965
- if (res) {
17966
- str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
17967
- }
17968
- });
17969
-
17970
- if(!str.length && o.key) {
17971
- str.push(o.key + "=");
17972
- }
17973
-
17974
- return str.join("&");
17975
-
17976
- },
17977
-
17978
- toArray: function(o) {
17979
-
17980
- var items = this._getItemsAsjQuery(o && o.connected),
17981
- ret = [];
17982
-
17983
- o = o || {};
17984
-
17985
- items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
17986
- return ret;
17987
-
17988
- },
17989
-
17990
- /* Be careful with the following core functions */
17991
- _intersectsWith: function(item) {
17992
-
17993
- var x1 = this.positionAbs.left,
17994
- x2 = x1 + this.helperProportions.width,
17995
- y1 = this.positionAbs.top,
17996
- y2 = y1 + this.helperProportions.height,
17997
- l = item.left,
17998
- r = l + item.width,
17999
- t = item.top,
18000
- b = t + item.height,
18001
- dyClick = this.offset.click.top,
18002
- dxClick = this.offset.click.left,
18003
- isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
18004
- isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
18005
- isOverElement = isOverElementHeight && isOverElementWidth;
18006
-
18007
- if ( this.options.tolerance === "pointer" ||
18008
- this.options.forcePointerForContainers ||
18009
- (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
18010
- ) {
18011
- return isOverElement;
18012
- } else {
18013
-
18014
- return (l < x1 + (this.helperProportions.width / 2) && // Right Half
18015
- x2 - (this.helperProportions.width / 2) < r && // Left Half
18016
- t < y1 + (this.helperProportions.height / 2) && // Bottom Half
18017
- y2 - (this.helperProportions.height / 2) < b ); // Top Half
18018
-
18019
- }
18020
- },
18021
-
18022
- _intersectsWithPointer: function(item) {
18023
-
18024
- var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
18025
- isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
18026
- isOverElement = isOverElementHeight && isOverElementWidth,
18027
- verticalDirection = this._getDragVerticalDirection(),
18028
- horizontalDirection = this._getDragHorizontalDirection();
18029
-
18030
- if (!isOverElement) {
18031
- return false;
18032
- }
18033
-
18034
- return this.floating ?
18035
- ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
18036
- : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
18037
-
18038
- },
18039
-
18040
- _intersectsWithSides: function(item) {
18041
-
18042
- var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
18043
- isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
18044
- verticalDirection = this._getDragVerticalDirection(),
18045
- horizontalDirection = this._getDragHorizontalDirection();
18046
-
18047
- if (this.floating && horizontalDirection) {
18048
- return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
18049
- } else {
18050
- return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
18051
- }
18052
-
18053
- },
18054
-
18055
- _getDragVerticalDirection: function() {
18056
- var delta = this.positionAbs.top - this.lastPositionAbs.top;
18057
- return delta !== 0 && (delta > 0 ? "down" : "up");
18058
- },
18059
-
18060
- _getDragHorizontalDirection: function() {
18061
- var delta = this.positionAbs.left - this.lastPositionAbs.left;
18062
- return delta !== 0 && (delta > 0 ? "right" : "left");
18063
- },
18064
-
18065
- refresh: function(event) {
18066
- this._refreshItems(event);
18067
- this.refreshPositions();
18068
- return this;
18069
- },
18070
-
18071
- _connectWith: function() {
18072
- var options = this.options;
18073
- return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
18074
- },
18075
-
18076
- _getItemsAsjQuery: function(connected) {
18077
-
18078
- var i, j, cur, inst,
18079
- items = [],
18080
- queries = [],
18081
- connectWith = this._connectWith();
18082
-
18083
- if(connectWith && connected) {
18084
- for (i = connectWith.length - 1; i >= 0; i--){
18085
- cur = $(connectWith[i]);
18086
- for ( j = cur.length - 1; j >= 0; j--){
18087
- inst = $.data(cur[j], this.widgetFullName);
18088
- if(inst && inst !== this && !inst.options.disabled) {
18089
- queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
18090
- }
18091
- }
18092
- }
18093
- }
18094
-
18095
- queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
18096
-
18097
- function addItems() {
18098
- items.push( this );
18099
- }
18100
- for (i = queries.length - 1; i >= 0; i--){
18101
- queries[i][0].each( addItems );
18102
- }
18103
-
18104
- return $(items);
18105
-
18106
- },
18107
-
18108
- _removeCurrentsFromItems: function() {
18109
-
18110
- var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
18111
-
18112
- this.items = $.grep(this.items, function (item) {
18113
- for (var j=0; j < list.length; j++) {
18114
- if(list[j] === item.item[0]) {
18115
- return false;
18116
- }
18117
- }
18118
- return true;
18119
- });
18120
-
18121
- },
18122
-
18123
- _refreshItems: function(event) {
18124
-
18125
- this.items = [];
18126
- this.containers = [this];
18127
-
18128
- var i, j, cur, inst, targetData, _queries, item, queriesLength,
18129
- items = this.items,
18130
- queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
18131
- connectWith = this._connectWith();
18132
-
18133
- if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
18134
- for (i = connectWith.length - 1; i >= 0; i--){
18135
- cur = $(connectWith[i]);
18136
- for (j = cur.length - 1; j >= 0; j--){
18137
- inst = $.data(cur[j], this.widgetFullName);
18138
- if(inst && inst !== this && !inst.options.disabled) {
18139
- queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
18140
- this.containers.push(inst);
18141
- }
18142
- }
18143
- }
18144
- }
18145
-
18146
- for (i = queries.length - 1; i >= 0; i--) {
18147
- targetData = queries[i][1];
18148
- _queries = queries[i][0];
18149
-
18150
- for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
18151
- item = $(_queries[j]);
18152
-
18153
- item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
18154
-
18155
- items.push({
18156
- item: item,
18157
- instance: targetData,
18158
- width: 0, height: 0,
18159
- left: 0, top: 0
18160
- });
18161
- }
18162
- }
18163
-
18164
- },
18165
-
18166
- refreshPositions: function(fast) {
18167
-
18168
- //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
18169
- if(this.offsetParent && this.helper) {
18170
- this.offset.parent = this._getParentOffset();
18171
- }
18172
-
18173
- var i, item, t, p;
18174
-
18175
- for (i = this.items.length - 1; i >= 0; i--){
18176
- item = this.items[i];
18177
-
18178
- //We ignore calculating positions of all connected containers when we're not over them
18179
- if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
18180
- continue;
18181
- }
18182
-
18183
- t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
18184
-
18185
- if (!fast) {
18186
- item.width = t.outerWidth();
18187
- item.height = t.outerHeight();
18188
- }
18189
-
18190
- p = t.offset();
18191
- item.left = p.left;
18192
- item.top = p.top;
18193
- }
18194
-
18195
- if(this.options.custom && this.options.custom.refreshContainers) {
18196
- this.options.custom.refreshContainers.call(this);
18197
- } else {
18198
- for (i = this.containers.length - 1; i >= 0; i--){
18199
- p = this.containers[i].element.offset();
18200
- this.containers[i].containerCache.left = p.left;
18201
- this.containers[i].containerCache.top = p.top;
18202
- this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
18203
- this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
18204
- }
18205
- }
18206
-
18207
- return this;
18208
- },
18209
-
18210
- _createPlaceholder: function(that) {
18211
- that = that || this;
18212
- var className,
18213
- o = that.options;
18214
-
18215
- if(!o.placeholder || o.placeholder.constructor === String) {
18216
- className = o.placeholder;
18217
- o.placeholder = {
18218
- element: function() {
18219
-
18220
- var nodeName = that.currentItem[0].nodeName.toLowerCase(),
18221
- element = $( "<" + nodeName + ">", that.document[0] )
18222
- .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
18223
- .removeClass("ui-sortable-helper");
18224
-
18225
- if ( nodeName === "tr" ) {
18226
- that.currentItem.children().each(function() {
18227
- $( "<td>&#160;</td>", that.document[0] )
18228
- .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
18229
- .appendTo( element );
18230
- });
18231
- } else if ( nodeName === "img" ) {
18232
- element.attr( "src", that.currentItem.attr( "src" ) );
18233
- }
18234
-
18235
- if ( !className ) {
18236
- element.css( "visibility", "hidden" );
18237
- }
18238
-
18239
- return element;
18240
- },
18241
- update: function(container, p) {
18242
-
18243
- // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
18244
- // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
18245
- if(className && !o.forcePlaceholderSize) {
18246
- return;
18247
- }
18248
-
18249
- //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
18250
- if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
18251
- if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
18252
- }
18253
- };
18254
- }
18255
-
18256
- //Create the placeholder
18257
- that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
18258
-
18259
- //Append it after the actual current item
18260
- that.currentItem.after(that.placeholder);
18261
-
18262
- //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
18263
- o.placeholder.update(that, that.placeholder);
18264
-
18265
- },
18266
-
18267
- _contactContainers: function(event) {
18268
- var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
18269
- innermostContainer = null,
18270
- innermostIndex = null;
18271
-
18272
- // get innermost container that intersects with item
18273
- for (i = this.containers.length - 1; i >= 0; i--) {
18274
-
18275
- // never consider a container that's located within the item itself
18276
- if($.contains(this.currentItem[0], this.containers[i].element[0])) {
18277
- continue;
18278
- }
18279
-
18280
- if(this._intersectsWith(this.containers[i].containerCache)) {
18281
-
18282
- // if we've already found a container and it's more "inner" than this, then continue
18283
- if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
18284
- continue;
18285
- }
18286
-
18287
- innermostContainer = this.containers[i];
18288
- innermostIndex = i;
18289
-
18290
- } else {
18291
- // container doesn't intersect. trigger "out" event if necessary
18292
- if(this.containers[i].containerCache.over) {
18293
- this.containers[i]._trigger("out", event, this._uiHash(this));
18294
- this.containers[i].containerCache.over = 0;
18295
- }
18296
- }
18297
-
18298
- }
18299
-
18300
- // if no intersecting containers found, return
18301
- if(!innermostContainer) {
18302
- return;
18303
- }
18304
-
18305
- // move the item into the container if it's not there already
18306
- if(this.containers.length === 1) {
18307
- if (!this.containers[innermostIndex].containerCache.over) {
18308
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
18309
- this.containers[innermostIndex].containerCache.over = 1;
18310
- }
18311
- } else {
18312
-
18313
- //When entering a new container, we will find the item with the least distance and append our item near it
18314
- dist = 10000;
18315
- itemWithLeastDistance = null;
18316
- floating = innermostContainer.floating || isFloating(this.currentItem);
18317
- posProperty = floating ? "left" : "top";
18318
- sizeProperty = floating ? "width" : "height";
18319
- base = this.positionAbs[posProperty] + this.offset.click[posProperty];
18320
- for (j = this.items.length - 1; j >= 0; j--) {
18321
- if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
18322
- continue;
18323
- }
18324
- if(this.items[j].item[0] === this.currentItem[0]) {
18325
- continue;
18326
- }
18327
- if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
18328
- continue;
18329
- }
18330
- cur = this.items[j].item.offset()[posProperty];
18331
- nearBottom = false;
18332
- if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
18333
- nearBottom = true;
18334
- cur += this.items[j][sizeProperty];
18335
- }
18336
-
18337
- if(Math.abs(cur - base) < dist) {
18338
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
18339
- this.direction = nearBottom ? "up": "down";
18340
- }
18341
- }
18342
-
18343
- //Check if dropOnEmpty is enabled
18344
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
18345
- return;
18346
- }
18347
-
18348
- if(this.currentContainer === this.containers[innermostIndex]) {
18349
- return;
18350
- }
18351
-
18352
- itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
18353
- this._trigger("change", event, this._uiHash());
18354
- this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
18355
- this.currentContainer = this.containers[innermostIndex];
18356
-
18357
- //Update the placeholder
18358
- this.options.placeholder.update(this.currentContainer, this.placeholder);
18359
-
18360
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
18361
- this.containers[innermostIndex].containerCache.over = 1;
18362
- }
18363
-
18364
-
18365
- },
18366
-
18367
- _createHelper: function(event) {
18368
-
18369
- var o = this.options,
18370
- helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
18371
-
18372
- //Add the helper to the DOM if that didn't happen already
18373
- if(!helper.parents("body").length) {
18374
- $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
18375
- }
18376
-
18377
- if(helper[0] === this.currentItem[0]) {
18378
- this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
18379
- }
18380
-
18381
- if(!helper[0].style.width || o.forceHelperSize) {
18382
- helper.width(this.currentItem.width());
18383
- }
18384
- if(!helper[0].style.height || o.forceHelperSize) {
18385
- helper.height(this.currentItem.height());
18386
- }
18387
-
18388
- return helper;
18389
-
18390
- },
18391
-
18392
- _adjustOffsetFromHelper: function(obj) {
18393
- if (typeof obj === "string") {
18394
- obj = obj.split(" ");
18395
- }
18396
- if ($.isArray(obj)) {
18397
- obj = {left: +obj[0], top: +obj[1] || 0};
18398
- }
18399
- if ("left" in obj) {
18400
- this.offset.click.left = obj.left + this.margins.left;
18401
- }
18402
- if ("right" in obj) {
18403
- this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
18404
- }
18405
- if ("top" in obj) {
18406
- this.offset.click.top = obj.top + this.margins.top;
18407
- }
18408
- if ("bottom" in obj) {
18409
- this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
18410
- }
18411
- },
18412
-
18413
- _getParentOffset: function() {
18414
-
18415
-
18416
- //Get the offsetParent and cache its position
18417
- this.offsetParent = this.helper.offsetParent();
18418
- var po = this.offsetParent.offset();
18419
-
18420
- // This is a special case where we need to modify a offset calculated on start, since the following happened:
18421
- // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
18422
- // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
18423
- // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
18424
- if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
18425
- po.left += this.scrollParent.scrollLeft();
18426
- po.top += this.scrollParent.scrollTop();
18427
- }
18428
-
18429
- // This needs to be actually done for all browsers, since pageX/pageY includes this information
18430
- // with an ugly IE fix
18431
- if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
18432
- po = { top: 0, left: 0 };
18433
- }
18434
-
18435
- return {
18436
- top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
18437
- left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
18438
- };
18439
-
18440
- },
18441
-
18442
- _getRelativeOffset: function() {
18443
-
18444
- if(this.cssPosition === "relative") {
18445
- var p = this.currentItem.position();
18446
- return {
18447
- top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
18448
- left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
18449
- };
18450
- } else {
18451
- return { top: 0, left: 0 };
18452
- }
18453
-
18454
- },
18455
-
18456
- _cacheMargins: function() {
18457
- this.margins = {
18458
- left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
18459
- top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
18460
- };
18461
- },
18462
-
18463
- _cacheHelperProportions: function() {
18464
- this.helperProportions = {
18465
- width: this.helper.outerWidth(),
18466
- height: this.helper.outerHeight()
18467
- };
18468
- },
18469
-
18470
- _setContainment: function() {
18471
-
18472
- var ce, co, over,
18473
- o = this.options;
18474
- if(o.containment === "parent") {
18475
- o.containment = this.helper[0].parentNode;
18476
- }
18477
- if(o.containment === "document" || o.containment === "window") {
18478
- this.containment = [
18479
- 0 - this.offset.relative.left - this.offset.parent.left,
18480
- 0 - this.offset.relative.top - this.offset.parent.top,
18481
- $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
18482
- ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
18483
- ];
18484
- }
18485
-
18486
- if(!(/^(document|window|parent)$/).test(o.containment)) {
18487
- ce = $(o.containment)[0];
18488
- co = $(o.containment).offset();
18489
- over = ($(ce).css("overflow") !== "hidden");
18490
-
18491
- this.containment = [
18492
- co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
18493
- co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
18494
- co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
18495
- co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
18496
- ];
18497
- }
18498
-
18499
- },
18500
-
18501
- _convertPositionTo: function(d, pos) {
18502
-
18503
- if(!pos) {
18504
- pos = this.position;
18505
- }
18506
- var mod = d === "absolute" ? 1 : -1,
18507
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
18508
- scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
18509
-
18510
- return {
18511
- top: (
18512
- pos.top + // The absolute mouse position
18513
- this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
18514
- this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
18515
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
18516
- ),
18517
- left: (
18518
- pos.left + // The absolute mouse position
18519
- this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
18520
- this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
18521
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
18522
- )
18523
- };
18524
-
18525
- },
18526
-
18527
- _generatePosition: function(event) {
18528
-
18529
- var top, left,
18530
- o = this.options,
18531
- pageX = event.pageX,
18532
- pageY = event.pageY,
18533
- scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
18534
-
18535
- // This is another very weird special case that only happens for relative elements:
18536
- // 1. If the css position is relative
18537
- // 2. and the scroll parent is the document or similar to the offset parent
18538
- // we have to refresh the relative offset during the scroll so there are no jumps
18539
- if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
18540
- this.offset.relative = this._getRelativeOffset();
18541
- }
18542
-
18543
- /*
18544
- * - Position constraining -
18545
- * Constrain the position to a mix of grid, containment.
18546
- */
18547
-
18548
- if(this.originalPosition) { //If we are not dragging yet, we won't check for options
18549
-
18550
- if(this.containment) {
18551
- if(event.pageX - this.offset.click.left < this.containment[0]) {
18552
- pageX = this.containment[0] + this.offset.click.left;
18553
- }
18554
- if(event.pageY - this.offset.click.top < this.containment[1]) {
18555
- pageY = this.containment[1] + this.offset.click.top;
18556
- }
18557
- if(event.pageX - this.offset.click.left > this.containment[2]) {
18558
- pageX = this.containment[2] + this.offset.click.left;
18559
- }
18560
- if(event.pageY - this.offset.click.top > this.containment[3]) {
18561
- pageY = this.containment[3] + this.offset.click.top;
18562
- }
18563
- }
18564
-
18565
- if(o.grid) {
18566
- top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
18567
- pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
18568
-
18569
- left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
18570
- pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
18571
- }
18572
-
18573
- }
18574
-
18575
- return {
18576
- top: (
18577
- pageY - // The absolute mouse position
18578
- this.offset.click.top - // Click offset (relative to the element)
18579
- this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
18580
- this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
18581
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
18582
- ),
18583
- left: (
18584
- pageX - // The absolute mouse position
18585
- this.offset.click.left - // Click offset (relative to the element)
18586
- this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
18587
- this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
18588
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
18589
- )
18590
- };
18591
-
18592
- },
18593
-
18594
- _rearrange: function(event, i, a, hardRefresh) {
18595
-
18596
- a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
18597
-
18598
- //Various things done here to improve the performance:
18599
- // 1. we create a setTimeout, that calls refreshPositions
18600
- // 2. on the instance, we have a counter variable, that get's higher after every append
18601
- // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
18602
- // 4. this lets only the last addition to the timeout stack through
18603
- this.counter = this.counter ? ++this.counter : 1;
18604
- var counter = this.counter;
18605
-
18606
- this._delay(function() {
18607
- if(counter === this.counter) {
18608
- this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
18609
- }
18610
- });
18611
-
18612
- },
18613
-
18614
- _clear: function(event, noPropagation) {
18615
-
18616
- this.reverting = false;
18617
- // We delay all events that have to be triggered to after the point where the placeholder has been removed and
18618
- // everything else normalized again
18619
- var i,
18620
- delayedTriggers = [];
18621
-
18622
- // We first have to update the dom position of the actual currentItem
18623
- // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
18624
- if(!this._noFinalSort && this.currentItem.parent().length) {
18625
- this.placeholder.before(this.currentItem);
18626
- }
18627
- this._noFinalSort = null;
18628
-
18629
- if(this.helper[0] === this.currentItem[0]) {
18630
- for(i in this._storedCSS) {
18631
- if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
18632
- this._storedCSS[i] = "";
18633
- }
18634
- }
18635
- this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
18636
- } else {
18637
- this.currentItem.show();
18638
- }
18639
-
18640
- if(this.fromOutside && !noPropagation) {
18641
- delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
18642
- }
18643
- if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
18644
- delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
18645
- }
18646
-
18647
- // Check if the items Container has Changed and trigger appropriate
18648
- // events.
18649
- if (this !== this.currentContainer) {
18650
- if(!noPropagation) {
18651
- delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
18652
- delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
18653
- delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
18654
- }
18655
- }
18656
-
18657
-
18658
- //Post events to containers
18659
- function delayEvent( type, instance, container ) {
18660
- return function( event ) {
18661
- container._trigger( type, event, instance._uiHash( instance ) );
18662
- };
18663
- }
18664
- for (i = this.containers.length - 1; i >= 0; i--){
18665
- if (!noPropagation) {
18666
- delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
18667
- }
18668
- if(this.containers[i].containerCache.over) {
18669
- delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
18670
- this.containers[i].containerCache.over = 0;
18671
- }
18672
- }
18673
-
18674
- //Do what was originally in plugins
18675
- if ( this.storedCursor ) {
18676
- this.document.find( "body" ).css( "cursor", this.storedCursor );
18677
- this.storedStylesheet.remove();
18678
- }
18679
- if(this._storedOpacity) {
18680
- this.helper.css("opacity", this._storedOpacity);
18681
- }
18682
- if(this._storedZIndex) {
18683
- this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
18684
- }
18685
-
18686
- this.dragging = false;
18687
- if(this.cancelHelperRemoval) {
18688
- if(!noPropagation) {
18689
- this._trigger("beforeStop", event, this._uiHash());
18690
- for (i=0; i < delayedTriggers.length; i++) {
18691
- delayedTriggers[i].call(this, event);
18692
- } //Trigger all delayed events
18693
- this._trigger("stop", event, this._uiHash());
18694
- }
18695
-
18696
- this.fromOutside = false;
18697
- return false;
18698
- }
18699
-
18700
- if(!noPropagation) {
18701
- this._trigger("beforeStop", event, this._uiHash());
18702
- }
18703
-
18704
- //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
18705
- this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
18706
-
18707
- if(this.helper[0] !== this.currentItem[0]) {
18708
- this.helper.remove();
18709
- }
18710
- this.helper = null;
18711
-
18712
- if(!noPropagation) {
18713
- for (i=0; i < delayedTriggers.length; i++) {
18714
- delayedTriggers[i].call(this, event);
18715
- } //Trigger all delayed events
18716
- this._trigger("stop", event, this._uiHash());
18717
- }
18718
-
18719
- this.fromOutside = false;
18720
- return true;
18721
-
18722
- },
18723
-
18724
- _trigger: function() {
18725
- if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
18726
- this.cancel();
18727
- }
18728
- },
18729
-
18730
- _uiHash: function(_inst) {
18731
- var inst = _inst || this;
18732
- return {
18733
- helper: inst.helper,
18734
- placeholder: inst.placeholder || $([]),
18735
- position: inst.position,
18736
- originalPosition: inst.originalPosition,
18737
- offset: inst.positionAbs,
18738
- item: inst.currentItem,
18739
- sender: _inst ? _inst.element : null
18740
- };
18741
- }
18742
-
18743
- });
18744
-
18745
- })(jQuery);
18746
-
18747
- },{"./core":231,"./mouse":233,"./widget":236,"jquery":237}],236:[function(require,module,exports){
18748
- var jQuery = require('jquery');
18749
-
18750
- /*!
18751
- * jQuery UI Widget 1.10.4
18752
- * http://jqueryui.com
18753
- *
18754
- * Copyright 2014 jQuery Foundation and other contributors
18755
- * Released under the MIT license.
18756
- * http://jquery.org/license
18757
- *
18758
- * http://api.jqueryui.com/jQuery.widget/
18759
- */
18760
- (function( $, undefined ) {
18761
-
18762
- var uuid = 0,
18763
- slice = Array.prototype.slice,
18764
- _cleanData = $.cleanData;
18765
- $.cleanData = function( elems ) {
18766
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
18767
- try {
18768
- $( elem ).triggerHandler( "remove" );
18769
- // http://bugs.jquery.com/ticket/8235
18770
- } catch( e ) {}
18771
- }
18772
- _cleanData( elems );
18773
- };
18774
-
18775
- $.widget = function( name, base, prototype ) {
18776
- var fullName, existingConstructor, constructor, basePrototype,
18777
- // proxiedPrototype allows the provided prototype to remain unmodified
18778
- // so that it can be used as a mixin for multiple widgets (#8876)
18779
- proxiedPrototype = {},
18780
- namespace = name.split( "." )[ 0 ];
18781
-
18782
- name = name.split( "." )[ 1 ];
18783
- fullName = namespace + "-" + name;
18784
-
18785
- if ( !prototype ) {
18786
- prototype = base;
18787
- base = $.Widget;
18788
- }
18789
-
18790
- // create selector for plugin
18791
- $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
18792
- return !!$.data( elem, fullName );
18793
- };
18794
-
18795
- $[ namespace ] = $[ namespace ] || {};
18796
- existingConstructor = $[ namespace ][ name ];
18797
- constructor = $[ namespace ][ name ] = function( options, element ) {
18798
- // allow instantiation without "new" keyword
18799
- if ( !this._createWidget ) {
18800
- return new constructor( options, element );
18801
- }
18802
-
18803
- // allow instantiation without initializing for simple inheritance
18804
- // must use "new" keyword (the code above always passes args)
18805
- if ( arguments.length ) {
18806
- this._createWidget( options, element );
18807
- }
18808
- };
18809
- // extend with the existing constructor to carry over any static properties
18810
- $.extend( constructor, existingConstructor, {
18811
- version: prototype.version,
18812
- // copy the object used to create the prototype in case we need to
18813
- // redefine the widget later
18814
- _proto: $.extend( {}, prototype ),
18815
- // track widgets that inherit from this widget in case this widget is
18816
- // redefined after a widget inherits from it
18817
- _childConstructors: []
18818
- });
18819
-
18820
- basePrototype = new base();
18821
- // we need to make the options hash a property directly on the new instance
18822
- // otherwise we'll modify the options hash on the prototype that we're
18823
- // inheriting from
18824
- basePrototype.options = $.widget.extend( {}, basePrototype.options );
18825
- $.each( prototype, function( prop, value ) {
18826
- if ( !$.isFunction( value ) ) {
18827
- proxiedPrototype[ prop ] = value;
18828
- return;
18829
- }
18830
- proxiedPrototype[ prop ] = (function() {
18831
- var _super = function() {
18832
- return base.prototype[ prop ].apply( this, arguments );
18833
- },
18834
- _superApply = function( args ) {
18835
- return base.prototype[ prop ].apply( this, args );
18836
- };
18837
- return function() {
18838
- var __super = this._super,
18839
- __superApply = this._superApply,
18840
- returnValue;
18841
-
18842
- this._super = _super;
18843
- this._superApply = _superApply;
18844
-
18845
- returnValue = value.apply( this, arguments );
18846
-
18847
- this._super = __super;
18848
- this._superApply = __superApply;
18849
-
18850
- return returnValue;
18851
- };
18852
- })();
18853
- });
18854
- constructor.prototype = $.widget.extend( basePrototype, {
18855
- // TODO: remove support for widgetEventPrefix
18856
- // always use the name + a colon as the prefix, e.g., draggable:start
18857
- // don't prefix for widgets that aren't DOM-based
18858
- widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
18859
- }, proxiedPrototype, {
18860
- constructor: constructor,
18861
- namespace: namespace,
18862
- widgetName: name,
18863
- widgetFullName: fullName
18864
- });
18865
-
18866
- // If this widget is being redefined then we need to find all widgets that
18867
- // are inheriting from it and redefine all of them so that they inherit from
18868
- // the new version of this widget. We're essentially trying to replace one
18869
- // level in the prototype chain.
18870
- if ( existingConstructor ) {
18871
- $.each( existingConstructor._childConstructors, function( i, child ) {
18872
- var childPrototype = child.prototype;
18873
-
18874
- // redefine the child widget using the same prototype that was
18875
- // originally used, but inherit from the new version of the base
18876
- $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
18877
- });
18878
- // remove the list of existing child constructors from the old constructor
18879
- // so the old child constructors can be garbage collected
18880
- delete existingConstructor._childConstructors;
18881
- } else {
18882
- base._childConstructors.push( constructor );
18883
- }
18884
-
18885
- $.widget.bridge( name, constructor );
18886
- };
18887
-
18888
- $.widget.extend = function( target ) {
18889
- var input = slice.call( arguments, 1 ),
18890
- inputIndex = 0,
18891
- inputLength = input.length,
18892
- key,
18893
- value;
18894
- for ( ; inputIndex < inputLength; inputIndex++ ) {
18895
- for ( key in input[ inputIndex ] ) {
18896
- value = input[ inputIndex ][ key ];
18897
- if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
18898
- // Clone objects
18899
- if ( $.isPlainObject( value ) ) {
18900
- target[ key ] = $.isPlainObject( target[ key ] ) ?
18901
- $.widget.extend( {}, target[ key ], value ) :
18902
- // Don't extend strings, arrays, etc. with objects
18903
- $.widget.extend( {}, value );
18904
- // Copy everything else by reference
18905
- } else {
18906
- target[ key ] = value;
18907
- }
18908
- }
18909
- }
18910
- }
18911
- return target;
18912
- };
18913
-
18914
- $.widget.bridge = function( name, object ) {
18915
- var fullName = object.prototype.widgetFullName || name;
18916
- $.fn[ name ] = function( options ) {
18917
- var isMethodCall = typeof options === "string",
18918
- args = slice.call( arguments, 1 ),
18919
- returnValue = this;
18920
-
18921
- // allow multiple hashes to be passed on init
18922
-
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.algoliaBundle=f()}})(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<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports={$:require("jquery"),Hogan:require("hogan.js"),algoliasearch:require("algoliasearch"),algoliasearchHelper:require("algoliasearch-helper")};require("jquery-ui/slider");require("jquery-ui/sortable");require("jquery-ui/draggable");require("jquery-ui/mouse");var oldJQuery=window.jQuery;window.jQuery=module.exports.$;require("jquery-ui-touch-punch");require("typeahead.js");window.jQuery=oldJQuery},{algoliasearch:213,"algoliasearch-helper":2,"hogan.js":228,jquery:237,"jquery-ui-touch-punch":230,"jquery-ui/draggable":232,"jquery-ui/mouse":233,"jquery-ui/slider":234,"jquery-ui/sortable":235,"typeahead.js":238}],2:[function(require,module,exports){"use strict";var AlgoliaSearchHelper=require("./src/algoliasearch.helper");var SearchParameters=require("./src/SearchParameters");var SearchResults=require("./src/SearchResults");function algoliasearchHelper(client,index,opts){return new AlgoliaSearchHelper(client,index,opts)}algoliasearchHelper.version="2.1.2";algoliasearchHelper.AlgoliaSearchHelper=AlgoliaSearchHelper;algoliasearchHelper.SearchParameters=SearchParameters;algoliasearchHelper.SearchResults=SearchResults;module.exports=algoliasearchHelper},{"./src/SearchParameters":152,"./src/SearchResults":154,"./src/algoliasearch.helper":155}],3:[function(require,module,exports){function compact(array){var index=-1,length=array?array.length:0,resIndex=-1,result=[];while(++index<length){var value=array[index];if(value){result[++resIndex]=value}}return result}module.exports=compact},{}],4:[function(require,module,exports){var createFindIndex=require("../internal/createFindIndex");var findIndex=createFindIndex();module.exports=findIndex},{"../internal/createFindIndex":87}],5:[function(require,module,exports){var baseIndexOf=require("../internal/baseIndexOf"),binaryIndex=require("../internal/binaryIndex");var nativeMax=Math.max;function indexOf(array,value,fromIndex){var length=array?array.length:0;if(!length){return-1}if(typeof fromIndex=="number"){fromIndex=fromIndex<0?nativeMax(length+fromIndex,0):fromIndex}else if(fromIndex){var index=binaryIndex(array,value);if(index<length&&(value===value?value===array[index]:array[index]!==array[index])){return index}return-1}return baseIndexOf(array,value,fromIndex||0)}module.exports=indexOf},{"../internal/baseIndexOf":49,"../internal/binaryIndex":69}],6:[function(require,module,exports){var baseIndexOf=require("../internal/baseIndexOf"),cacheIndexOf=require("../internal/cacheIndexOf"),createCache=require("../internal/createCache"),isArrayLike=require("../internal/isArrayLike"),restParam=require("../function/restParam");var intersection=restParam(function(arrays){var othLength=arrays.length,othIndex=othLength,caches=Array(length),indexOf=baseIndexOf,isCommon=true,result=[];while(othIndex--){var value=arrays[othIndex]=isArrayLike(value=arrays[othIndex])?value:[];caches[othIndex]=isCommon&&value.length>=120?createCache(othIndex&&value):null}var array=arrays[0],index=-1,length=array?array.length:0,seen=caches[0];outer:while(++index<length){value=array[index];if((seen?cacheIndexOf(seen,value):indexOf(result,value,0))<0){var othIndex=othLength;while(--othIndex){var cache=caches[othIndex];if((cache?cacheIndexOf(cache,value):indexOf(arrays[othIndex],value,0))<0){continue outer}}if(seen){seen.push(value)}result.push(value)}}return result});module.exports=intersection},{"../function/restParam":20,"../internal/baseIndexOf":49,"../internal/cacheIndexOf":72,"../internal/createCache":83,"../internal/isArrayLike":102}],7:[function(require,module,exports){function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}module.exports=last},{}],8:[function(require,module,exports){var LazyWrapper=require("../internal/LazyWrapper"),LodashWrapper=require("../internal/LodashWrapper"),baseLodash=require("../internal/baseLodash"),isArray=require("../lang/isArray"),isObjectLike=require("../internal/isObjectLike"),wrapperClone=require("../internal/wrapperClone");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function lodash(value){if(isObjectLike(value)&&!isArray(value)&&!(value instanceof LazyWrapper)){if(value instanceof LodashWrapper){return value}if(hasOwnProperty.call(value,"__chain__")&&hasOwnProperty.call(value,"__wrapped__")){return wrapperClone(value)}}return new LodashWrapper(value)}lodash.prototype=baseLodash.prototype;module.exports=lodash},{"../internal/LazyWrapper":21,"../internal/LodashWrapper":22,"../internal/baseLodash":53,"../internal/isObjectLike":108,"../internal/wrapperClone":125,"../lang/isArray":127}],9:[function(require,module,exports){var arrayFilter=require("../internal/arrayFilter"),baseCallback=require("../internal/baseCallback"),baseFilter=require("../internal/baseFilter"),isArray=require("../lang/isArray");function filter(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;predicate=baseCallback(predicate,thisArg,3);return func(collection,predicate)}module.exports=filter},{"../internal/arrayFilter":26,"../internal/baseCallback":35,"../internal/baseFilter":41,"../lang/isArray":127}],10:[function(require,module,exports){var baseEach=require("../internal/baseEach"),createFind=require("../internal/createFind");var find=createFind(baseEach);module.exports=find},{"../internal/baseEach":40,"../internal/createFind":86}],11:[function(require,module,exports){var arrayEach=require("../internal/arrayEach"),baseEach=require("../internal/baseEach"),createForEach=require("../internal/createForEach");var forEach=createForEach(arrayEach,baseEach);module.exports=forEach},{"../internal/arrayEach":25,"../internal/baseEach":40,"../internal/createForEach":88}],12:[function(require,module,exports){var baseIndexOf=require("../internal/baseIndexOf"),getLength=require("../internal/getLength"),isArray=require("../lang/isArray"),isIterateeCall=require("../internal/isIterateeCall"),isLength=require("../internal/isLength"),isString=require("../lang/isString"),values=require("../object/values");var nativeMax=Math.max;function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;if(!isLength(length)){collection=values(collection);length=collection.length}if(typeof fromIndex!="number"||guard&&isIterateeCall(target,fromIndex,guard)){fromIndex=0}else{fromIndex=fromIndex<0?nativeMax(length+fromIndex,0):fromIndex||0}return typeof collection=="string"||!isArray(collection)&&isString(collection)?fromIndex<=length&&collection.indexOf(target,fromIndex)>-1:!!length&&baseIndexOf(collection,target,fromIndex)>-1}module.exports=includes},{"../internal/baseIndexOf":49,"../internal/getLength":98,"../internal/isIterateeCall":104,"../internal/isLength":107,"../lang/isArray":127,"../lang/isString":133,"../object/values":146}],13:[function(require,module,exports){var arrayMap=require("../internal/arrayMap"),baseCallback=require("../internal/baseCallback"),baseMap=require("../internal/baseMap"),isArray=require("../lang/isArray");function map(collection,iteratee,thisArg){var func=isArray(collection)?arrayMap:baseMap;iteratee=baseCallback(iteratee,thisArg,3);return func(collection,iteratee)}module.exports=map},{"../internal/arrayMap":27,"../internal/baseCallback":35,"../internal/baseMap":54,"../lang/isArray":127}],14:[function(require,module,exports){var map=require("./map"),property=require("../utility/property");function pluck(collection,path){return map(collection,property(path))}module.exports=pluck},{"../utility/property":150,"./map":13}],15:[function(require,module,exports){var arrayReduce=require("../internal/arrayReduce"),baseEach=require("../internal/baseEach"),createReduce=require("../internal/createReduce");var reduce=createReduce(arrayReduce,baseEach);module.exports=reduce},{"../internal/arrayReduce":29,"../internal/baseEach":40,"../internal/createReduce":91}],16:[function(require,module,exports){var baseSortByOrder=require("../internal/baseSortByOrder"),isArray=require("../lang/isArray"),isIterateeCall=require("../internal/isIterateeCall");function sortByOrder(collection,iteratees,orders,guard){if(collection==null){return[]}if(guard&&isIterateeCall(iteratees,orders,guard)){orders=undefined}if(!isArray(iteratees)){iteratees=iteratees==null?[]:[iteratees]}if(!isArray(orders)){orders=orders==null?[]:[orders]}return baseSortByOrder(collection,iteratees,orders)}module.exports=sortByOrder},{"../internal/baseSortByOrder":65,"../internal/isIterateeCall":104,"../lang/isArray":127}],17:[function(require,module,exports){module.exports=require("../math/sum")},{"../math/sum":137}],18:[function(require,module,exports){var getNative=require("../internal/getNative");var nativeNow=getNative(Date,"now");var now=nativeNow||function(){return(new Date).getTime()};module.exports=now},{"../internal/getNative":100}],19:[function(require,module,exports){var createWrapper=require("../internal/createWrapper"),replaceHolders=require("../internal/replaceHolders"),restParam=require("./restParam");var BIND_FLAG=1,PARTIAL_FLAG=32;var bind=restParam(function(func,thisArg,partials){var bitmask=BIND_FLAG;if(partials.length){var holders=replaceHolders(partials,bind.placeholder);bitmask|=PARTIAL_FLAG}return createWrapper(func,bitmask,thisArg,partials,holders)});bind.placeholder={};module.exports=bind},{"../internal/createWrapper":92,"../internal/replaceHolders":117,"./restParam":20}],20:[function(require,module,exports){var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max;function restParam(func,start){if(typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}start=nativeMax(start===undefined?func.length-1:+start||0,0);return function(){var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);while(++index<length){rest[index]=args[start+index]}switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);index=-1;while(++index<start){otherArgs[index]=args[index]}otherArgs[start]=rest;return func.apply(this,otherArgs)}}module.exports=restParam},{}],21:[function(require,module,exports){var baseCreate=require("./baseCreate"),baseLodash=require("./baseLodash");var POSITIVE_INFINITY=Number.POSITIVE_INFINITY;function LazyWrapper(value){this.__wrapped__=value;this.__actions__=[];this.__dir__=1;this.__filtered__=false;this.__iteratees__=[];this.__takeCount__=POSITIVE_INFINITY;this.__views__=[]}LazyWrapper.prototype=baseCreate(baseLodash.prototype);LazyWrapper.prototype.constructor=LazyWrapper;module.exports=LazyWrapper},{"./baseCreate":38,"./baseLodash":53}],22:[function(require,module,exports){var baseCreate=require("./baseCreate"),baseLodash=require("./baseLodash");function LodashWrapper(value,chainAll,actions){this.__wrapped__=value;this.__actions__=actions||[];this.__chain__=!!chainAll}LodashWrapper.prototype=baseCreate(baseLodash.prototype);LodashWrapper.prototype.constructor=LodashWrapper;module.exports=LodashWrapper},{"./baseCreate":38,"./baseLodash":53}],23:[function(require,module,exports){(function(global){var cachePush=require("./cachePush"),getNative=require("./getNative");var Set=getNative(global,"Set");var nativeCreate=getNative(Object,"create");function SetCache(values){var length=values?values.length:0;this.data={hash:nativeCreate(null),set:new Set};while(length--){this.push(values[length])}}SetCache.prototype.push=cachePush;module.exports=SetCache}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./cachePush":73,"./getNative":100}],24:[function(require,module,exports){function arrayCopy(source,array){var index=-1,length=source.length;array||(array=Array(length));while(++index<length){array[index]=source[index]}return array}module.exports=arrayCopy},{}],25:[function(require,module,exports){function arrayEach(array,iteratee){var index=-1,length=array.length;while(++index<length){if(iteratee(array[index],index,array)===false){break}}return array}module.exports=arrayEach},{}],26:[function(require,module,exports){function arrayFilter(array,predicate){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){var value=array[index];if(predicate(value,index,array)){result[++resIndex]=value}}return result}module.exports=arrayFilter},{}],27:[function(require,module,exports){function arrayMap(array,iteratee){var index=-1,length=array.length,result=Array(length);while(++index<length){result[index]=iteratee(array[index],index,array)}return result}module.exports=arrayMap},{}],28:[function(require,module,exports){function arrayPush(array,values){var index=-1,length=values.length,offset=array.length;while(++index<length){array[offset+index]=values[index]}return array}module.exports=arrayPush},{}],29:[function(require,module,exports){function arrayReduce(array,iteratee,accumulator,initFromArray){var index=-1,length=array.length;if(initFromArray&&length){accumulator=array[++index]}while(++index<length){accumulator=iteratee(accumulator,array[index],index,array)}return accumulator}module.exports=arrayReduce},{}],30:[function(require,module,exports){function arraySome(array,predicate){var index=-1,length=array.length;while(++index<length){if(predicate(array[index],index,array)){return true}}return false}module.exports=arraySome},{}],31:[function(require,module,exports){function arraySum(array,iteratee){var length=array.length,result=0;while(length--){result+=+iteratee(array[length])||0}return result}module.exports=arraySum},{}],32:[function(require,module,exports){function assignDefaults(objectValue,sourceValue){return objectValue===undefined?sourceValue:objectValue}module.exports=assignDefaults},{}],33:[function(require,module,exports){var keys=require("../object/keys");function assignWith(object,source,customizer){var index=-1,props=keys(source),length=props.length;while(++index<length){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);if((result===result?result!==value:value===value)||value===undefined&&!(key in object)){object[key]=result}}return object}module.exports=assignWith},{"../object/keys":140}],34:[function(require,module,exports){var baseCopy=require("./baseCopy"),keys=require("../object/keys");function baseAssign(object,source){return source==null?object:baseCopy(source,keys(source),object)}module.exports=baseAssign},{"../object/keys":140,"./baseCopy":37}],35:[function(require,module,exports){var baseMatches=require("./baseMatches"),baseMatchesProperty=require("./baseMatchesProperty"),bindCallback=require("./bindCallback"),identity=require("../utility/identity"),property=require("../utility/property");function baseCallback(func,thisArg,argCount){var type=typeof func;if(type=="function"){return thisArg===undefined?func:bindCallback(func,thisArg,argCount)}if(func==null){return identity}if(type=="object"){return baseMatches(func)}return thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}module.exports=baseCallback},{"../utility/identity":148,"../utility/property":150,"./baseMatches":55,"./baseMatchesProperty":56,"./bindCallback":71}],36:[function(require,module,exports){function baseCompareAscending(value,other){if(value!==other){var valIsNull=value===null,valIsUndef=value===undefined,valIsReflexive=value===value;var othIsNull=other===null,othIsUndef=other===undefined,othIsReflexive=other===other;if(value>other&&!othIsNull||!valIsReflexive||valIsNull&&!othIsUndef&&othIsReflexive||valIsUndef&&othIsReflexive){return 1}if(value<other&&!valIsNull||!othIsReflexive||othIsNull&&!valIsUndef&&valIsReflexive||othIsUndef&&valIsReflexive){return-1}}return 0}module.exports=baseCompareAscending},{}],37:[function(require,module,exports){function baseCopy(source,props,object){object||(object={});var index=-1,length=props.length;while(++index<length){var key=props[index];object[key]=source[key]}return object}module.exports=baseCopy},{}],38:[function(require,module,exports){var isObject=require("../lang/isObject");var baseCreate=function(){function object(){}return function(prototype){if(isObject(prototype)){object.prototype=prototype;var result=new object;object.prototype=undefined}return result||{}}}();module.exports=baseCreate},{"../lang/isObject":131}],39:[function(require,module,exports){var baseIndexOf=require("./baseIndexOf"),cacheIndexOf=require("./cacheIndexOf"),createCache=require("./createCache");var LARGE_ARRAY_SIZE=200;function baseDifference(array,values){var length=array?array.length:0,result=[];if(!length){return result}var index=-1,indexOf=baseIndexOf,isCommon=true,cache=isCommon&&values.length>=LARGE_ARRAY_SIZE?createCache(values):null,valuesLength=values.length;if(cache){indexOf=cacheIndexOf;isCommon=false;values=cache}outer:while(++index<length){var value=array[index];if(isCommon&&value===value){var valuesIndex=valuesLength;while(valuesIndex--){if(values[valuesIndex]===value){continue outer}}result.push(value)}else if(indexOf(values,value,0)<0){result.push(value)}}return result}module.exports=baseDifference},{"./baseIndexOf":49,"./cacheIndexOf":72,"./createCache":83}],40:[function(require,module,exports){var baseForOwn=require("./baseForOwn"),createBaseEach=require("./createBaseEach");var baseEach=createBaseEach(baseForOwn);module.exports=baseEach},{"./baseForOwn":47,"./createBaseEach":80}],41:[function(require,module,exports){var baseEach=require("./baseEach");function baseFilter(collection,predicate){var result=[];baseEach(collection,function(value,index,collection){if(predicate(value,index,collection)){result.push(value)}});return result}module.exports=baseFilter},{"./baseEach":40}],42:[function(require,module,exports){function baseFind(collection,predicate,eachFunc,retKey){var result;eachFunc(collection,function(value,key,collection){if(predicate(value,key,collection)){result=retKey?key:value;return false}});return result}module.exports=baseFind},{}],43:[function(require,module,exports){function baseFindIndex(array,predicate,fromRight){var length=array.length,index=fromRight?length:-1;while(fromRight?index--:++index<length){if(predicate(array[index],index,array)){return index}}return-1}module.exports=baseFindIndex},{}],44:[function(require,module,exports){var arrayPush=require("./arrayPush"),isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isArrayLike=require("./isArrayLike"),isObjectLike=require("./isObjectLike");function baseFlatten(array,isDeep,isStrict,result){result||(result=[]);var index=-1,length=array.length;while(++index<length){var value=array[index];if(isObjectLike(value)&&isArrayLike(value)&&(isStrict||isArray(value)||isArguments(value))){if(isDeep){baseFlatten(value,isDeep,isStrict,result)}else{arrayPush(result,value)}}else if(!isStrict){result[result.length]=value}}return result}module.exports=baseFlatten},{"../lang/isArguments":126,"../lang/isArray":127,"./arrayPush":28,"./isArrayLike":102,"./isObjectLike":108}],45:[function(require,module,exports){var createBaseFor=require("./createBaseFor");var baseFor=createBaseFor();module.exports=baseFor},{"./createBaseFor":81}],46:[function(require,module,exports){var baseFor=require("./baseFor"),keysIn=require("../object/keysIn");function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}module.exports=baseForIn},{"../object/keysIn":141,"./baseFor":45}],47:[function(require,module,exports){var baseFor=require("./baseFor"),keys=require("../object/keys");function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}module.exports=baseForOwn},{"../object/keys":140,"./baseFor":45}],48:[function(require,module,exports){var toObject=require("./toObject");function baseGet(object,path,pathKey){if(object==null){return}if(pathKey!==undefined&&pathKey in toObject(object)){path=[pathKey]}var index=0,length=path.length;while(object!=null&&index<length){object=object[path[index++]]}return index&&index==length?object:undefined}module.exports=baseGet},{"./toObject":121}],49:[function(require,module,exports){var indexOfNaN=require("./indexOfNaN");function baseIndexOf(array,value,fromIndex){if(value!==value){return indexOfNaN(array,fromIndex)}var index=fromIndex-1,length=array.length;while(++index<length){if(array[index]===value){return index}}return-1}module.exports=baseIndexOf},{"./indexOfNaN":101}],50:[function(require,module,exports){var baseIsEqualDeep=require("./baseIsEqualDeep"),isObject=require("../lang/isObject"),isObjectLike=require("./isObjectLike");function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other){return true}if(value==null||other==null||!isObject(value)&&!isObjectLike(other)){return value!==value&&other!==other}return baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}module.exports=baseIsEqual},{"../lang/isObject":131,"./baseIsEqualDeep":51,"./isObjectLike":108}],51:[function(require,module,exports){var equalArrays=require("./equalArrays"),equalByTag=require("./equalByTag"),equalObjects=require("./equalObjects"),isArray=require("../lang/isArray"),isTypedArray=require("../lang/isTypedArray");var argsTag="[object Arguments]",arrayTag="[object Array]",objectTag="[object Object]";var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;if(!objIsArr){objTag=objToString.call(object);if(objTag==argsTag){objTag=objectTag}else if(objTag!=objectTag){objIsArr=isTypedArray(object)}}if(!othIsArr){othTag=objToString.call(other);if(othTag==argsTag){othTag=objectTag}else if(othTag!=objectTag){othIsArr=isTypedArray(other)}}var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!(objIsArr||objIsObj)){return equalByTag(object,other,objTag)}if(!isLoose){var objIsWrapped=objIsObj&&hasOwnProperty.call(object,"__wrapped__"),othIsWrapped=othIsObj&&hasOwnProperty.call(other,"__wrapped__");if(objIsWrapped||othIsWrapped){return equalFunc(objIsWrapped?object.value():object,othIsWrapped?other.value():other,customizer,isLoose,stackA,stackB)}}if(!isSameTag){return false}stackA||(stackA=[]);stackB||(stackB=[]);var length=stackA.length;while(length--){if(stackA[length]==object){return stackB[length]==other}}stackA.push(object);stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);stackA.pop();stackB.pop();return result}module.exports=baseIsEqualDeep},{"../lang/isArray":127,"../lang/isTypedArray":134,"./equalArrays":93,"./equalByTag":94,"./equalObjects":95}],52:[function(require,module,exports){var baseIsEqual=require("./baseIsEqual"),toObject=require("./toObject");function baseIsMatch(object,matchData,customizer){var index=matchData.length,length=index,noCustomizer=!customizer;if(object==null){return!length}object=toObject(object);while(index--){var data=matchData[index];if(noCustomizer&&data[2]?data[1]!==object[data[0]]:!(data[0]in object)){return false}}while(++index<length){data=matchData[index];var key=data[0],objValue=object[key],srcValue=data[1];if(noCustomizer&&data[2]){if(objValue===undefined&&!(key in object)){return false}}else{var result=customizer?customizer(objValue,srcValue,key):undefined;if(!(result===undefined?baseIsEqual(srcValue,objValue,customizer,true):result)){return false}}}return true}module.exports=baseIsMatch},{"./baseIsEqual":50,"./toObject":121}],53:[function(require,module,exports){function baseLodash(){}module.exports=baseLodash},{}],54:[function(require,module,exports){var baseEach=require("./baseEach"),isArrayLike=require("./isArrayLike");function baseMap(collection,iteratee){var index=-1,result=isArrayLike(collection)?Array(collection.length):[];baseEach(collection,function(value,key,collection){result[++index]=iteratee(value,key,collection)});return result}module.exports=baseMap},{"./baseEach":40,"./isArrayLike":102}],55:[function(require,module,exports){var baseIsMatch=require("./baseIsMatch"),getMatchData=require("./getMatchData"),toObject=require("./toObject");function baseMatches(source){var matchData=getMatchData(source);if(matchData.length==1&&matchData[0][2]){var key=matchData[0][0],value=matchData[0][1];return function(object){if(object==null){return false}return object[key]===value&&(value!==undefined||key in toObject(object))}}return function(object){return baseIsMatch(object,matchData)}}module.exports=baseMatches},{"./baseIsMatch":52,"./getMatchData":99,"./toObject":121}],56:[function(require,module,exports){var baseGet=require("./baseGet"),baseIsEqual=require("./baseIsEqual"),baseSlice=require("./baseSlice"),isArray=require("../lang/isArray"),isKey=require("./isKey"),isStrictComparable=require("./isStrictComparable"),last=require("../array/last"),toObject=require("./toObject"),toPath=require("./toPath");function baseMatchesProperty(path,srcValue){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(srcValue),pathKey=path+"";path=toPath(path);return function(object){if(object==null){return false}var key=pathKey;object=toObject(object);if((isArr||!isCommon)&&!(key in object)){object=path.length==1?object:baseGet(object,baseSlice(path,0,-1));if(object==null){return false}key=last(path);object=toObject(object)}return object[key]===srcValue?srcValue!==undefined||key in object:baseIsEqual(srcValue,object[key],undefined,true)}}module.exports=baseMatchesProperty},{"../array/last":7,"../lang/isArray":127,"./baseGet":48,"./baseIsEqual":50,"./baseSlice":63,"./isKey":105,"./isStrictComparable":110,"./toObject":121,"./toPath":122}],57:[function(require,module,exports){var arrayEach=require("./arrayEach"),baseMergeDeep=require("./baseMergeDeep"),isArray=require("../lang/isArray"),isArrayLike=require("./isArrayLike"),isObject=require("../lang/isObject"),isObjectLike=require("./isObjectLike"),isTypedArray=require("../lang/isTypedArray"),keys=require("../object/keys");function baseMerge(object,source,customizer,stackA,stackB){if(!isObject(object)){return object}var isSrcArr=isArrayLike(source)&&(isArray(source)||isTypedArray(source)),props=isSrcArr?undefined:keys(source);arrayEach(props||source,function(srcValue,key){if(props){key=srcValue;srcValue=source[key]}if(isObjectLike(srcValue)){stackA||(stackA=[]);stackB||(stackB=[]);baseMergeDeep(object,source,key,baseMerge,customizer,stackA,stackB)}else{var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;if(isCommon){result=srcValue}if((result!==undefined||isSrcArr&&!(key in object))&&(isCommon||(result===result?result!==value:value===value))){object[key]=result}}});return object}module.exports=baseMerge},{"../lang/isArray":127,"../lang/isObject":131,"../lang/isTypedArray":134,"../object/keys":140,"./arrayEach":25,"./baseMergeDeep":58,"./isArrayLike":102,"./isObjectLike":108}],58:[function(require,module,exports){var arrayCopy=require("./arrayCopy"),isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isArrayLike=require("./isArrayLike"),isPlainObject=require("../lang/isPlainObject"),isTypedArray=require("../lang/isTypedArray"),toPlainObject=require("../lang/toPlainObject");function baseMergeDeep(object,source,key,mergeFunc,customizer,stackA,stackB){var length=stackA.length,srcValue=source[key];while(length--){if(stackA[length]==srcValue){object[key]=stackB[length];return}}var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;if(isCommon){result=srcValue;if(isArrayLike(srcValue)&&(isArray(srcValue)||isTypedArray(srcValue))){result=isArray(value)?value:isArrayLike(value)?arrayCopy(value):[]}else if(isPlainObject(srcValue)||isArguments(srcValue)){result=isArguments(value)?toPlainObject(value):isPlainObject(value)?value:{}}else{isCommon=false}}stackA.push(srcValue);stackB.push(result);if(isCommon){object[key]=mergeFunc(result,srcValue,customizer,stackA,stackB)}else if(result===result?result!==value:value===value){object[key]=result}}module.exports=baseMergeDeep},{"../lang/isArguments":126,"../lang/isArray":127,"../lang/isPlainObject":132,"../lang/isTypedArray":134,"../lang/toPlainObject":136,"./arrayCopy":24,"./isArrayLike":102}],59:[function(require,module,exports){function baseProperty(key){return function(object){return object==null?undefined:object[key]}}module.exports=baseProperty},{}],60:[function(require,module,exports){var baseGet=require("./baseGet"),toPath=require("./toPath");function basePropertyDeep(path){var pathKey=path+"";path=toPath(path);return function(object){return baseGet(object,path,pathKey)}}module.exports=basePropertyDeep},{"./baseGet":48,"./toPath":122}],61:[function(require,module,exports){function baseReduce(collection,iteratee,accumulator,initFromCollection,eachFunc){eachFunc(collection,function(value,index,collection){accumulator=initFromCollection?(initFromCollection=false,value):iteratee(accumulator,value,index,collection)});return accumulator}module.exports=baseReduce},{}],62:[function(require,module,exports){var identity=require("../utility/identity"),metaMap=require("./metaMap");var baseSetData=!metaMap?identity:function(func,data){metaMap.set(func,data);return func};module.exports=baseSetData},{"../utility/identity":148,"./metaMap":112}],63:[function(require,module,exports){function baseSlice(array,start,end){var index=-1,length=array.length;start=start==null?0:+start||0;if(start<0){start=-start>length?0:length+start}end=end===undefined||end>length?length:+end||0;if(end<0){end+=length}length=start>end?0:end-start>>>0;start>>>=0;var result=Array(length);while(++index<length){result[index]=array[index+start]}return result}module.exports=baseSlice},{}],64:[function(require,module,exports){function baseSortBy(array,comparer){var length=array.length;array.sort(comparer);while(length--){array[length]=array[length].value}return array}module.exports=baseSortBy},{}],65:[function(require,module,exports){var arrayMap=require("./arrayMap"),baseCallback=require("./baseCallback"),baseMap=require("./baseMap"),baseSortBy=require("./baseSortBy"),compareMultiple=require("./compareMultiple");function baseSortByOrder(collection,iteratees,orders){var index=-1;iteratees=arrayMap(iteratees,function(iteratee){return baseCallback(iteratee)});var result=baseMap(collection,function(value){var criteria=arrayMap(iteratees,function(iteratee){return iteratee(value)});return{criteria:criteria,index:++index,value:value}});return baseSortBy(result,function(object,other){return compareMultiple(object,other,orders)})}module.exports=baseSortByOrder},{"./arrayMap":27,"./baseCallback":35,"./baseMap":54,"./baseSortBy":64,"./compareMultiple":76}],66:[function(require,module,exports){var baseEach=require("./baseEach");function baseSum(collection,iteratee){var result=0;baseEach(collection,function(value,index,collection){result+=+iteratee(value,index,collection)||0});return result}module.exports=baseSum},{"./baseEach":40}],67:[function(require,module,exports){function baseToString(value){return value==null?"":value+""}module.exports=baseToString},{}],68:[function(require,module,exports){
2
+ function baseValues(object,props){var index=-1,length=props.length,result=Array(length);while(++index<length){result[index]=object[props[index]]}return result}module.exports=baseValues},{}],69:[function(require,module,exports){var binaryIndexBy=require("./binaryIndexBy"),identity=require("../utility/identity");var MAX_ARRAY_LENGTH=4294967295,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1;function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(typeof value=="number"&&value===value&&high<=HALF_MAX_ARRAY_LENGTH){while(low<high){var mid=low+high>>>1,computed=array[mid];if((retHighest?computed<=value:computed<value)&&computed!==null){low=mid+1}else{high=mid}}return high}return binaryIndexBy(array,value,identity,retHighest)}module.exports=binaryIndex},{"../utility/identity":148,"./binaryIndexBy":70}],70:[function(require,module,exports){var nativeFloor=Math.floor,nativeMin=Math.min;var MAX_ARRAY_LENGTH=4294967295,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1;function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsNull=value===null,valIsUndef=value===undefined;while(low<high){var mid=nativeFloor((low+high)/2),computed=iteratee(array[mid]),isDef=computed!==undefined,isReflexive=computed===computed;if(valIsNaN){var setLow=isReflexive||retHighest}else if(valIsNull){setLow=isReflexive&&isDef&&(retHighest||computed!=null)}else if(valIsUndef){setLow=isReflexive&&(retHighest||isDef)}else if(computed==null){setLow=false}else{setLow=retHighest?computed<=value:computed<value}if(setLow){low=mid+1}else{high=mid}}return nativeMin(high,MAX_ARRAY_INDEX)}module.exports=binaryIndexBy},{}],71:[function(require,module,exports){var identity=require("../utility/identity");function bindCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(thisArg===undefined){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}module.exports=bindCallback},{"../utility/identity":148}],72:[function(require,module,exports){var isObject=require("../lang/isObject");function cacheIndexOf(cache,value){var data=cache.data,result=typeof value=="string"||isObject(value)?data.set.has(value):data.hash[value];return result?0:-1}module.exports=cacheIndexOf},{"../lang/isObject":131}],73:[function(require,module,exports){var isObject=require("../lang/isObject");function cachePush(value){var data=this.data;if(typeof value=="string"||isObject(value)){data.set.add(value)}else{data.hash[value]=true}}module.exports=cachePush},{"../lang/isObject":131}],74:[function(require,module,exports){function charsLeftIndex(string,chars){var index=-1,length=string.length;while(++index<length&&chars.indexOf(string.charAt(index))>-1){}return index}module.exports=charsLeftIndex},{}],75:[function(require,module,exports){function charsRightIndex(string,chars){var index=string.length;while(index--&&chars.indexOf(string.charAt(index))>-1){}return index}module.exports=charsRightIndex},{}],76:[function(require,module,exports){var baseCompareAscending=require("./baseCompareAscending");function compareMultiple(object,other,orders){var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;while(++index<length){var result=baseCompareAscending(objCriteria[index],othCriteria[index]);if(result){if(index>=ordersLength){return result}var order=orders[index];return result*(order==="asc"||order===true?1:-1)}}return object.index-other.index}module.exports=compareMultiple},{"./baseCompareAscending":36}],77:[function(require,module,exports){var nativeMax=Math.max;function composeArgs(args,partials,holders){var holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),leftIndex=-1,leftLength=partials.length,result=Array(leftLength+argsLength);while(++leftIndex<leftLength){result[leftIndex]=partials[leftIndex]}while(++argsIndex<holdersLength){result[holders[argsIndex]]=args[argsIndex]}while(argsLength--){result[leftIndex++]=args[argsIndex++]}return result}module.exports=composeArgs},{}],78:[function(require,module,exports){var nativeMax=Math.max;function composeArgsRight(args,partials,holders){var holdersIndex=-1,holdersLength=holders.length,argsIndex=-1,argsLength=nativeMax(args.length-holdersLength,0),rightIndex=-1,rightLength=partials.length,result=Array(argsLength+rightLength);while(++argsIndex<argsLength){result[argsIndex]=args[argsIndex]}var offset=argsIndex;while(++rightIndex<rightLength){result[offset+rightIndex]=partials[rightIndex]}while(++holdersIndex<holdersLength){result[offset+holders[holdersIndex]]=args[argsIndex++]}return result}module.exports=composeArgsRight},{}],79:[function(require,module,exports){var bindCallback=require("./bindCallback"),isIterateeCall=require("./isIterateeCall"),restParam=require("../function/restParam");function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=object==null?0:sources.length,customizer=length>2?sources[length-2]:undefined,guard=length>2?sources[2]:undefined,thisArg=length>1?sources[length-1]:undefined;if(typeof customizer=="function"){customizer=bindCallback(customizer,thisArg,5);length-=2}else{customizer=typeof thisArg=="function"?thisArg:undefined;length-=customizer?1:0}if(guard&&isIterateeCall(sources[0],sources[1],guard)){customizer=length<3?undefined:customizer;length=1}while(++index<length){var source=sources[index];if(source){assigner(object,source,customizer)}}return object})}module.exports=createAssigner},{"../function/restParam":20,"./bindCallback":71,"./isIterateeCall":104}],80:[function(require,module,exports){var getLength=require("./getLength"),isLength=require("./isLength"),toObject=require("./toObject");function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length)){return eachFunc(collection,iteratee)}var index=fromRight?length:-1,iterable=toObject(collection);while(fromRight?index--:++index<length){if(iteratee(iterable[index],index,iterable)===false){break}}return collection}}module.exports=createBaseEach},{"./getLength":98,"./isLength":107,"./toObject":121}],81:[function(require,module,exports){var toObject=require("./toObject");function createBaseFor(fromRight){return function(object,iteratee,keysFunc){var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;while(fromRight?index--:++index<length){var key=props[index];if(iteratee(iterable[key],key,iterable)===false){break}}return object}}module.exports=createBaseFor},{"./toObject":121}],82:[function(require,module,exports){(function(global){var createCtorWrapper=require("./createCtorWrapper");function createBindWrapper(func,thisArg){var Ctor=createCtorWrapper(func);function wrapper(){var fn=this&&this!==global&&this instanceof wrapper?Ctor:func;return fn.apply(thisArg,arguments)}return wrapper}module.exports=createBindWrapper}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./createCtorWrapper":84}],83:[function(require,module,exports){(function(global){var SetCache=require("./SetCache"),getNative=require("./getNative");var Set=getNative(global,"Set");var nativeCreate=getNative(Object,"create");function createCache(values){return nativeCreate&&Set?new SetCache(values):null}module.exports=createCache}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./SetCache":23,"./getNative":100}],84:[function(require,module,exports){var baseCreate=require("./baseCreate"),isObject=require("../lang/isObject");function createCtorWrapper(Ctor){return function(){var args=arguments;switch(args.length){case 0:return new Ctor;case 1:return new Ctor(args[0]);case 2:return new Ctor(args[0],args[1]);case 3:return new Ctor(args[0],args[1],args[2]);case 4:return new Ctor(args[0],args[1],args[2],args[3]);case 5:return new Ctor(args[0],args[1],args[2],args[3],args[4]);case 6:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5]);case 7:return new Ctor(args[0],args[1],args[2],args[3],args[4],args[5],args[6])}var thisBinding=baseCreate(Ctor.prototype),result=Ctor.apply(thisBinding,args);return isObject(result)?result:thisBinding}}module.exports=createCtorWrapper},{"../lang/isObject":131,"./baseCreate":38}],85:[function(require,module,exports){var restParam=require("../function/restParam");function createDefaults(assigner,customizer){return restParam(function(args){var object=args[0];if(object==null){return object}args.push(customizer);return assigner.apply(undefined,args)})}module.exports=createDefaults},{"../function/restParam":20}],86:[function(require,module,exports){var baseCallback=require("./baseCallback"),baseFind=require("./baseFind"),baseFindIndex=require("./baseFindIndex"),isArray=require("../lang/isArray");function createFind(eachFunc,fromRight){return function(collection,predicate,thisArg){predicate=baseCallback(predicate,thisArg,3);if(isArray(collection)){var index=baseFindIndex(collection,predicate,fromRight);return index>-1?collection[index]:undefined}return baseFind(collection,predicate,eachFunc)}}module.exports=createFind},{"../lang/isArray":127,"./baseCallback":35,"./baseFind":42,"./baseFindIndex":43}],87:[function(require,module,exports){var baseCallback=require("./baseCallback"),baseFindIndex=require("./baseFindIndex");function createFindIndex(fromRight){return function(array,predicate,thisArg){if(!(array&&array.length)){return-1}predicate=baseCallback(predicate,thisArg,3);return baseFindIndex(array,predicate,fromRight)}}module.exports=createFindIndex},{"./baseCallback":35,"./baseFindIndex":43}],88:[function(require,module,exports){var bindCallback=require("./bindCallback"),isArray=require("../lang/isArray");function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return typeof iteratee=="function"&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}module.exports=createForEach},{"../lang/isArray":127,"./bindCallback":71}],89:[function(require,module,exports){(function(global){var arrayCopy=require("./arrayCopy"),composeArgs=require("./composeArgs"),composeArgsRight=require("./composeArgsRight"),createCtorWrapper=require("./createCtorWrapper"),isLaziable=require("./isLaziable"),reorder=require("./reorder"),replaceHolders=require("./replaceHolders"),setData=require("./setData");var BIND_FLAG=1,BIND_KEY_FLAG=2,CURRY_BOUND_FLAG=4,CURRY_FLAG=8,CURRY_RIGHT_FLAG=16,PARTIAL_FLAG=32,PARTIAL_RIGHT_FLAG=64,ARY_FLAG=128;var nativeMax=Math.max;function createHybridWrapper(func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity){var isAry=bitmask&ARY_FLAG,isBind=bitmask&BIND_FLAG,isBindKey=bitmask&BIND_KEY_FLAG,isCurry=bitmask&CURRY_FLAG,isCurryBound=bitmask&CURRY_BOUND_FLAG,isCurryRight=bitmask&CURRY_RIGHT_FLAG,Ctor=isBindKey?undefined:createCtorWrapper(func);function wrapper(){var length=arguments.length,index=length,args=Array(length);while(index--){args[index]=arguments[index]}if(partials){args=composeArgs(args,partials,holders)}if(partialsRight){args=composeArgsRight(args,partialsRight,holdersRight)}if(isCurry||isCurryRight){var placeholder=wrapper.placeholder,argsHolders=replaceHolders(args,placeholder);length-=argsHolders.length;if(length<arity){var newArgPos=argPos?arrayCopy(argPos):undefined,newArity=nativeMax(arity-length,0),newsHolders=isCurry?argsHolders:undefined,newHoldersRight=isCurry?undefined:argsHolders,newPartials=isCurry?args:undefined,newPartialsRight=isCurry?undefined:args;bitmask|=isCurry?PARTIAL_FLAG:PARTIAL_RIGHT_FLAG;bitmask&=~(isCurry?PARTIAL_RIGHT_FLAG:PARTIAL_FLAG);if(!isCurryBound){bitmask&=~(BIND_FLAG|BIND_KEY_FLAG)}var newData=[func,bitmask,thisArg,newPartials,newsHolders,newPartialsRight,newHoldersRight,newArgPos,ary,newArity],result=createHybridWrapper.apply(undefined,newData);if(isLaziable(func)){setData(result,newData)}result.placeholder=placeholder;return result}}var thisBinding=isBind?thisArg:this,fn=isBindKey?thisBinding[func]:func;if(argPos){args=reorder(args,argPos)}if(isAry&&ary<args.length){args.length=ary}if(this&&this!==global&&this instanceof wrapper){fn=Ctor||createCtorWrapper(func)}return fn.apply(thisBinding,args)}return wrapper}module.exports=createHybridWrapper}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./arrayCopy":24,"./composeArgs":77,"./composeArgsRight":78,"./createCtorWrapper":84,"./isLaziable":106,"./reorder":116,"./replaceHolders":117,"./setData":118}],90:[function(require,module,exports){(function(global){var createCtorWrapper=require("./createCtorWrapper");var BIND_FLAG=1;function createPartialWrapper(func,bitmask,thisArg,partials){var isBind=bitmask&BIND_FLAG,Ctor=createCtorWrapper(func);function wrapper(){var argsIndex=-1,argsLength=arguments.length,leftIndex=-1,leftLength=partials.length,args=Array(leftLength+argsLength);while(++leftIndex<leftLength){args[leftIndex]=partials[leftIndex]}while(argsLength--){args[leftIndex++]=arguments[++argsIndex]}var fn=this&&this!==global&&this instanceof wrapper?Ctor:func;return fn.apply(isBind?thisArg:this,args)}return wrapper}module.exports=createPartialWrapper}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./createCtorWrapper":84}],91:[function(require,module,exports){var baseCallback=require("./baseCallback"),baseReduce=require("./baseReduce"),isArray=require("../lang/isArray");function createReduce(arrayFunc,eachFunc){return function(collection,iteratee,accumulator,thisArg){var initFromArray=arguments.length<3;return typeof iteratee=="function"&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee,accumulator,initFromArray):baseReduce(collection,baseCallback(iteratee,thisArg,4),accumulator,initFromArray,eachFunc)}}module.exports=createReduce},{"../lang/isArray":127,"./baseCallback":35,"./baseReduce":61}],92:[function(require,module,exports){var baseSetData=require("./baseSetData"),createBindWrapper=require("./createBindWrapper"),createHybridWrapper=require("./createHybridWrapper"),createPartialWrapper=require("./createPartialWrapper"),getData=require("./getData"),mergeData=require("./mergeData"),setData=require("./setData");var BIND_FLAG=1,BIND_KEY_FLAG=2,PARTIAL_FLAG=32,PARTIAL_RIGHT_FLAG=64;var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max;function createWrapper(func,bitmask,thisArg,partials,holders,argPos,ary,arity){var isBindKey=bitmask&BIND_KEY_FLAG;if(!isBindKey&&typeof func!="function"){throw new TypeError(FUNC_ERROR_TEXT)}var length=partials?partials.length:0;if(!length){bitmask&=~(PARTIAL_FLAG|PARTIAL_RIGHT_FLAG);partials=holders=undefined}length-=holders?holders.length:0;if(bitmask&PARTIAL_RIGHT_FLAG){var partialsRight=partials,holdersRight=holders;partials=holders=undefined}var data=isBindKey?undefined:getData(func),newData=[func,bitmask,thisArg,partials,holders,partialsRight,holdersRight,argPos,ary,arity];if(data){mergeData(newData,data);bitmask=newData[1];arity=newData[9]}newData[9]=arity==null?isBindKey?0:func.length:nativeMax(arity-length,0)||0;if(bitmask==BIND_FLAG){var result=createBindWrapper(newData[0],newData[2])}else if((bitmask==PARTIAL_FLAG||bitmask==(BIND_FLAG|PARTIAL_FLAG))&&!newData[4].length){result=createPartialWrapper.apply(undefined,newData)}else{result=createHybridWrapper.apply(undefined,newData)}var setter=data?baseSetData:setData;return setter(result,newData)}module.exports=createWrapper},{"./baseSetData":62,"./createBindWrapper":82,"./createHybridWrapper":89,"./createPartialWrapper":90,"./getData":96,"./mergeData":111,"./setData":118}],93:[function(require,module,exports){var arraySome=require("./arraySome");function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength)){return false}while(++index<arrLength){var arrValue=array[index],othValue=other[index],result=customizer?customizer(isLoose?othValue:arrValue,isLoose?arrValue:othValue,index):undefined;if(result!==undefined){if(result){continue}return false}if(isLoose){if(!arraySome(other,function(othValue){return arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)})){return false}}else if(!(arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))){return false}}return true}module.exports=equalArrays},{"./arraySome":30}],94:[function(require,module,exports){var boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",numberTag="[object Number]",regexpTag="[object RegExp]",stringTag="[object String]";function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:object==+other;case regexpTag:case stringTag:return object==other+""}return false}module.exports=equalByTag},{}],95:[function(require,module,exports){var keys=require("../object/keys");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose){return false}var index=objLength;while(index--){var key=objProps[index];if(!(isLoose?key in other:hasOwnProperty.call(other,key))){return false}}var skipCtor=isLoose;while(++index<objLength){key=objProps[index];var objValue=object[key],othValue=other[key],result=customizer?customizer(isLoose?othValue:objValue,isLoose?objValue:othValue,key):undefined;if(!(result===undefined?equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB):result)){return false}skipCtor||(skipCtor=key=="constructor")}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&("constructor"in object&&"constructor"in other)&&!(typeof objCtor=="function"&&objCtor instanceof objCtor&&typeof othCtor=="function"&&othCtor instanceof othCtor)){return false}}return true}module.exports=equalObjects},{"../object/keys":140}],96:[function(require,module,exports){var metaMap=require("./metaMap"),noop=require("../utility/noop");var getData=!metaMap?noop:function(func){return metaMap.get(func)};module.exports=getData},{"../utility/noop":149,"./metaMap":112}],97:[function(require,module,exports){var realNames=require("./realNames");function getFuncName(func){var result=func.name,array=realNames[result],length=array?array.length:0;while(length--){var data=array[length],otherFunc=data.func;if(otherFunc==null||otherFunc==func){return data.name}}return result}module.exports=getFuncName},{"./realNames":115}],98:[function(require,module,exports){var baseProperty=require("./baseProperty");var getLength=baseProperty("length");module.exports=getLength},{"./baseProperty":59}],99:[function(require,module,exports){var isStrictComparable=require("./isStrictComparable"),pairs=require("../object/pairs");function getMatchData(object){var result=pairs(object),length=result.length;while(length--){result[length][2]=isStrictComparable(result[length][1])}return result}module.exports=getMatchData},{"../object/pairs":144,"./isStrictComparable":110}],100:[function(require,module,exports){var isNative=require("../lang/isNative");function getNative(object,key){var value=object==null?undefined:object[key];return isNative(value)?value:undefined}module.exports=getNative},{"../lang/isNative":130}],101:[function(require,module,exports){function indexOfNaN(array,fromIndex,fromRight){var length=array.length,index=fromIndex+(fromRight?0:-1);while(fromRight?index--:++index<length){var other=array[index];if(other!==other){return index}}return-1}module.exports=indexOfNaN},{}],102:[function(require,module,exports){var getLength=require("./getLength"),isLength=require("./isLength");function isArrayLike(value){return value!=null&&isLength(getLength(value))}module.exports=isArrayLike},{"./getLength":98,"./isLength":107}],103:[function(require,module,exports){var reIsUint=/^\d+$/;var MAX_SAFE_INTEGER=9007199254740991;function isIndex(value,length){value=typeof value=="number"||reIsUint.test(value)?+value:-1;length=length==null?MAX_SAFE_INTEGER:length;return value>-1&&value%1==0&&value<length}module.exports=isIndex},{}],104:[function(require,module,exports){var isArrayLike=require("./isArrayLike"),isIndex=require("./isIndex"),isObject=require("../lang/isObject");function isIterateeCall(value,index,object){if(!isObject(object)){return false}var type=typeof index;if(type=="number"?isArrayLike(object)&&isIndex(index,object.length):type=="string"&&index in object){var other=object[index];return value===value?value===other:other!==other}return false}module.exports=isIterateeCall},{"../lang/isObject":131,"./isArrayLike":102,"./isIndex":103}],105:[function(require,module,exports){var isArray=require("../lang/isArray"),toObject=require("./toObject");var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey(value,object){var type=typeof value;if(type=="string"&&reIsPlainProp.test(value)||type=="number"){return true}if(isArray(value)){return false}var result=!reIsDeepProp.test(value);return result||object!=null&&value in toObject(object)}module.exports=isKey},{"../lang/isArray":127,"./toObject":121}],106:[function(require,module,exports){var LazyWrapper=require("./LazyWrapper"),getData=require("./getData"),getFuncName=require("./getFuncName"),lodash=require("../chain/lodash");function isLaziable(func){var funcName=getFuncName(func);if(!(funcName in LazyWrapper.prototype)){return false}var other=lodash[funcName];if(func===other){return true}var data=getData(other);return!!data&&func===data[0]}module.exports=isLaziable},{"../chain/lodash":8,"./LazyWrapper":21,"./getData":96,"./getFuncName":97}],107:[function(require,module,exports){var MAX_SAFE_INTEGER=9007199254740991;function isLength(value){return typeof value=="number"&&value>-1&&value%1==0&&value<=MAX_SAFE_INTEGER}module.exports=isLength},{}],108:[function(require,module,exports){function isObjectLike(value){return!!value&&typeof value=="object"}module.exports=isObjectLike},{}],109:[function(require,module,exports){function isSpace(charCode){return charCode<=160&&(charCode>=9&&charCode<=13)||charCode==32||charCode==160||charCode==5760||charCode==6158||charCode>=8192&&(charCode<=8202||charCode==8232||charCode==8233||charCode==8239||charCode==8287||charCode==12288||charCode==65279)}module.exports=isSpace},{}],110:[function(require,module,exports){var isObject=require("../lang/isObject");function isStrictComparable(value){return value===value&&!isObject(value)}module.exports=isStrictComparable},{"../lang/isObject":131}],111:[function(require,module,exports){var arrayCopy=require("./arrayCopy"),composeArgs=require("./composeArgs"),composeArgsRight=require("./composeArgsRight"),replaceHolders=require("./replaceHolders");var BIND_FLAG=1,CURRY_BOUND_FLAG=4,CURRY_FLAG=8,ARY_FLAG=128,REARG_FLAG=256;var PLACEHOLDER="__lodash_placeholder__";var nativeMin=Math.min;function mergeData(data,source){var bitmask=data[1],srcBitmask=source[1],newBitmask=bitmask|srcBitmask,isCommon=newBitmask<ARY_FLAG;var isCombo=srcBitmask==ARY_FLAG&&bitmask==CURRY_FLAG||srcBitmask==ARY_FLAG&&bitmask==REARG_FLAG&&data[7].length<=source[8]||srcBitmask==(ARY_FLAG|REARG_FLAG)&&bitmask==CURRY_FLAG;if(!(isCommon||isCombo)){return data}if(srcBitmask&BIND_FLAG){data[2]=source[2];newBitmask|=bitmask&BIND_FLAG?0:CURRY_BOUND_FLAG}var value=source[3];if(value){var partials=data[3];data[3]=partials?composeArgs(partials,value,source[4]):arrayCopy(value);data[4]=partials?replaceHolders(data[3],PLACEHOLDER):arrayCopy(source[4])}value=source[5];if(value){partials=data[5];data[5]=partials?composeArgsRight(partials,value,source[6]):arrayCopy(value);data[6]=partials?replaceHolders(data[5],PLACEHOLDER):arrayCopy(source[6])}value=source[7];if(value){data[7]=arrayCopy(value)}if(srcBitmask&ARY_FLAG){data[8]=data[8]==null?source[8]:nativeMin(data[8],source[8])}if(data[9]==null){data[9]=source[9]}data[0]=source[0];data[1]=newBitmask;return data}module.exports=mergeData},{"./arrayCopy":24,"./composeArgs":77,"./composeArgsRight":78,"./replaceHolders":117}],112:[function(require,module,exports){(function(global){var getNative=require("./getNative");var WeakMap=getNative(global,"WeakMap");var metaMap=WeakMap&&new WeakMap;module.exports=metaMap}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./getNative":100}],113:[function(require,module,exports){var toObject=require("./toObject");function pickByArray(object,props){object=toObject(object);var index=-1,length=props.length,result={};while(++index<length){var key=props[index];if(key in object){result[key]=object[key]}}return result}module.exports=pickByArray},{"./toObject":121}],114:[function(require,module,exports){var baseForIn=require("./baseForIn");function pickByCallback(object,predicate){var result={};baseForIn(object,function(value,key,object){if(predicate(value,key,object)){result[key]=value}});return result}module.exports=pickByCallback},{"./baseForIn":46}],115:[function(require,module,exports){var realNames={};module.exports=realNames},{}],116:[function(require,module,exports){var arrayCopy=require("./arrayCopy"),isIndex=require("./isIndex");var nativeMin=Math.min;function reorder(array,indexes){var arrLength=array.length,length=nativeMin(indexes.length,arrLength),oldArray=arrayCopy(array);while(length--){var index=indexes[length];array[length]=isIndex(index,arrLength)?oldArray[index]:undefined}return array}module.exports=reorder},{"./arrayCopy":24,"./isIndex":103}],117:[function(require,module,exports){var PLACEHOLDER="__lodash_placeholder__";function replaceHolders(array,placeholder){var index=-1,length=array.length,resIndex=-1,result=[];while(++index<length){if(array[index]===placeholder){array[index]=PLACEHOLDER;result[++resIndex]=index}}return result}module.exports=replaceHolders},{}],118:[function(require,module,exports){var baseSetData=require("./baseSetData"),now=require("../date/now");var HOT_COUNT=150,HOT_SPAN=16;var setData=function(){var count=0,lastCalled=0;return function(key,value){var stamp=now(),remaining=HOT_SPAN-(stamp-lastCalled);lastCalled=stamp;if(remaining>0){if(++count>=HOT_COUNT){return key}}else{count=0}return baseSetData(key,value)}}();module.exports=setData},{"../date/now":18,"./baseSetData":62}],119:[function(require,module,exports){var isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isIndex=require("./isIndex"),isLength=require("./isLength"),keysIn=require("../object/keysIn");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}module.exports=shimKeys},{"../lang/isArguments":126,"../lang/isArray":127,"../object/keysIn":141,"./isIndex":103,"./isLength":107}],120:[function(require,module,exports){var isArrayLike=require("./isArrayLike"),isObject=require("../lang/isObject"),values=require("../object/values");function toIterable(value){if(value==null){return[]}if(!isArrayLike(value)){return values(value)}return isObject(value)?value:Object(value)}module.exports=toIterable},{"../lang/isObject":131,"../object/values":146,"./isArrayLike":102}],121:[function(require,module,exports){var isObject=require("../lang/isObject");function toObject(value){return isObject(value)?value:Object(value)}module.exports=toObject},{"../lang/isObject":131}],122:[function(require,module,exports){var baseToString=require("./baseToString"),isArray=require("../lang/isArray");var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;var reEscapeChar=/\\(\\)?/g;function toPath(value){if(isArray(value)){return value}var result=[];baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,"$1"):number||match)});return result}module.exports=toPath},{"../lang/isArray":127,"./baseToString":67}],123:[function(require,module,exports){var isSpace=require("./isSpace");function trimmedLeftIndex(string){var index=-1,length=string.length;while(++index<length&&isSpace(string.charCodeAt(index))){}return index}module.exports=trimmedLeftIndex},{"./isSpace":109}],124:[function(require,module,exports){var isSpace=require("./isSpace");function trimmedRightIndex(string){var index=string.length;while(index--&&isSpace(string.charCodeAt(index))){}return index}module.exports=trimmedRightIndex},{"./isSpace":109}],125:[function(require,module,exports){var LazyWrapper=require("./LazyWrapper"),LodashWrapper=require("./LodashWrapper"),arrayCopy=require("./arrayCopy");function wrapperClone(wrapper){return wrapper instanceof LazyWrapper?wrapper.clone():new LodashWrapper(wrapper.__wrapped__,wrapper.__chain__,arrayCopy(wrapper.__actions__))}module.exports=wrapperClone},{"./LazyWrapper":21,"./LodashWrapper":22,"./arrayCopy":24}],126:[function(require,module,exports){var isArrayLike=require("../internal/isArrayLike"),isObjectLike=require("../internal/isObjectLike");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var propertyIsEnumerable=objectProto.propertyIsEnumerable;function isArguments(value){return isObjectLike(value)&&isArrayLike(value)&&hasOwnProperty.call(value,"callee")&&!propertyIsEnumerable.call(value,"callee")}module.exports=isArguments},{"../internal/isArrayLike":102,"../internal/isObjectLike":108}],127:[function(require,module,exports){var getNative=require("../internal/getNative"),isLength=require("../internal/isLength"),isObjectLike=require("../internal/isObjectLike");var arrayTag="[object Array]";var objectProto=Object.prototype;var objToString=objectProto.toString;var nativeIsArray=getNative(Array,"isArray");var isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};module.exports=isArray},{"../internal/getNative":100,"../internal/isLength":107,"../internal/isObjectLike":108}],128:[function(require,module,exports){var isArguments=require("./isArguments"),isArray=require("./isArray"),isArrayLike=require("../internal/isArrayLike"),isFunction=require("./isFunction"),isObjectLike=require("../internal/isObjectLike"),isString=require("./isString"),keys=require("../object/keys");function isEmpty(value){if(value==null){return true}if(isArrayLike(value)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))){return!value.length}return!keys(value).length}module.exports=isEmpty},{"../internal/isArrayLike":102,"../internal/isObjectLike":108,"../object/keys":140,"./isArguments":126,"./isArray":127,"./isFunction":129,"./isString":133}],129:[function(require,module,exports){var isObject=require("./isObject");var funcTag="[object Function]";var objectProto=Object.prototype;var objToString=objectProto.toString;function isFunction(value){
3
+ return isObject(value)&&objToString.call(value)==funcTag}module.exports=isFunction},{"./isObject":131}],130:[function(require,module,exports){var isFunction=require("./isFunction"),isObjectLike=require("../internal/isObjectLike");var reIsHostCtor=/^\[object .+?Constructor\]$/;var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&reIsHostCtor.test(value)}module.exports=isNative},{"../internal/isObjectLike":108,"./isFunction":129}],131:[function(require,module,exports){function isObject(value){var type=typeof value;return!!value&&(type=="object"||type=="function")}module.exports=isObject},{}],132:[function(require,module,exports){var baseForIn=require("../internal/baseForIn"),isArguments=require("./isArguments"),isObjectLike=require("../internal/isObjectLike");var objectTag="[object Object]";var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function isPlainObject(value){var Ctor;if(!(isObjectLike(value)&&objToString.call(value)==objectTag&&!isArguments(value))||!hasOwnProperty.call(value,"constructor")&&(Ctor=value.constructor,typeof Ctor=="function"&&!(Ctor instanceof Ctor))){return false}var result;baseForIn(value,function(subValue,key){result=key});return result===undefined||hasOwnProperty.call(value,result)}module.exports=isPlainObject},{"../internal/baseForIn":46,"../internal/isObjectLike":108,"./isArguments":126}],133:[function(require,module,exports){var isObjectLike=require("../internal/isObjectLike");var stringTag="[object String]";var objectProto=Object.prototype;var objToString=objectProto.toString;function isString(value){return typeof value=="string"||isObjectLike(value)&&objToString.call(value)==stringTag}module.exports=isString},{"../internal/isObjectLike":108}],134:[function(require,module,exports){var isLength=require("../internal/isLength"),isObjectLike=require("../internal/isObjectLike");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=true;typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=false;var objectProto=Object.prototype;var objToString=objectProto.toString;function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}module.exports=isTypedArray},{"../internal/isLength":107,"../internal/isObjectLike":108}],135:[function(require,module,exports){function isUndefined(value){return value===undefined}module.exports=isUndefined},{}],136:[function(require,module,exports){var baseCopy=require("../internal/baseCopy"),keysIn=require("../object/keysIn");function toPlainObject(value){return baseCopy(value,keysIn(value))}module.exports=toPlainObject},{"../internal/baseCopy":37,"../object/keysIn":141}],137:[function(require,module,exports){var arraySum=require("../internal/arraySum"),baseCallback=require("../internal/baseCallback"),baseSum=require("../internal/baseSum"),isArray=require("../lang/isArray"),isIterateeCall=require("../internal/isIterateeCall"),toIterable=require("../internal/toIterable");function sum(collection,iteratee,thisArg){if(thisArg&&isIterateeCall(collection,iteratee,thisArg)){iteratee=undefined}iteratee=baseCallback(iteratee,thisArg,3);return iteratee.length==1?arraySum(isArray(collection)?collection:toIterable(collection),iteratee):baseSum(collection,iteratee)}module.exports=sum},{"../internal/arraySum":31,"../internal/baseCallback":35,"../internal/baseSum":66,"../internal/isIterateeCall":104,"../internal/toIterable":120,"../lang/isArray":127}],138:[function(require,module,exports){var assignWith=require("../internal/assignWith"),baseAssign=require("../internal/baseAssign"),createAssigner=require("../internal/createAssigner");var assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)});module.exports=assign},{"../internal/assignWith":33,"../internal/baseAssign":34,"../internal/createAssigner":79}],139:[function(require,module,exports){var assign=require("./assign"),assignDefaults=require("../internal/assignDefaults"),createDefaults=require("../internal/createDefaults");var defaults=createDefaults(assign,assignDefaults);module.exports=defaults},{"../internal/assignDefaults":32,"../internal/createDefaults":85,"./assign":138}],140:[function(require,module,exports){var getNative=require("../internal/getNative"),isArrayLike=require("../internal/isArrayLike"),isObject=require("../lang/isObject"),shimKeys=require("../internal/shimKeys");var nativeKeys=getNative(Object,"keys");var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||typeof object!="function"&&isArrayLike(object)){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};module.exports=keys},{"../internal/getNative":100,"../internal/isArrayLike":102,"../internal/shimKeys":119,"../lang/isObject":131}],141:[function(require,module,exports){var isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isIndex=require("../internal/isIndex"),isLength=require("../internal/isLength"),isObject=require("../lang/isObject");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;var Ctor=object.constructor,index=-1,isProto=typeof Ctor=="function"&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;while(++index<length){result[index]=index+""}for(var key in object){if(!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){result.push(key)}}return result}module.exports=keysIn},{"../internal/isIndex":103,"../internal/isLength":107,"../lang/isArguments":126,"../lang/isArray":127,"../lang/isObject":131}],142:[function(require,module,exports){var baseMerge=require("../internal/baseMerge"),createAssigner=require("../internal/createAssigner");var merge=createAssigner(baseMerge);module.exports=merge},{"../internal/baseMerge":57,"../internal/createAssigner":79}],143:[function(require,module,exports){var arrayMap=require("../internal/arrayMap"),baseDifference=require("../internal/baseDifference"),baseFlatten=require("../internal/baseFlatten"),bindCallback=require("../internal/bindCallback"),keysIn=require("./keysIn"),pickByArray=require("../internal/pickByArray"),pickByCallback=require("../internal/pickByCallback"),restParam=require("../function/restParam");var omit=restParam(function(object,props){if(object==null){return{}}if(typeof props[0]!="function"){var props=arrayMap(baseFlatten(props),String);return pickByArray(object,baseDifference(keysIn(object),props))}var predicate=bindCallback(props[0],props[1],3);return pickByCallback(object,function(value,key,object){return!predicate(value,key,object)})});module.exports=omit},{"../function/restParam":20,"../internal/arrayMap":27,"../internal/baseDifference":39,"../internal/baseFlatten":44,"../internal/bindCallback":71,"../internal/pickByArray":113,"../internal/pickByCallback":114,"./keysIn":141}],144:[function(require,module,exports){var keys=require("./keys"),toObject=require("../internal/toObject");function pairs(object){object=toObject(object);var index=-1,props=keys(object),length=props.length,result=Array(length);while(++index<length){var key=props[index];result[index]=[key,object[key]]}return result}module.exports=pairs},{"../internal/toObject":121,"./keys":140}],145:[function(require,module,exports){var baseFlatten=require("../internal/baseFlatten"),bindCallback=require("../internal/bindCallback"),pickByArray=require("../internal/pickByArray"),pickByCallback=require("../internal/pickByCallback"),restParam=require("../function/restParam");var pick=restParam(function(object,props){if(object==null){return{}}return typeof props[0]=="function"?pickByCallback(object,bindCallback(props[0],props[1],3)):pickByArray(object,baseFlatten(props))});module.exports=pick},{"../function/restParam":20,"../internal/baseFlatten":44,"../internal/bindCallback":71,"../internal/pickByArray":113,"../internal/pickByCallback":114}],146:[function(require,module,exports){var baseValues=require("../internal/baseValues"),keys=require("./keys");function values(object){return baseValues(object,keys(object))}module.exports=values},{"../internal/baseValues":68,"./keys":140}],147:[function(require,module,exports){var baseToString=require("../internal/baseToString"),charsLeftIndex=require("../internal/charsLeftIndex"),charsRightIndex=require("../internal/charsRightIndex"),isIterateeCall=require("../internal/isIterateeCall"),trimmedLeftIndex=require("../internal/trimmedLeftIndex"),trimmedRightIndex=require("../internal/trimmedRightIndex");function trim(string,chars,guard){var value=string;string=baseToString(string);if(!string){return string}if(guard?isIterateeCall(value,chars,guard):chars==null){return string.slice(trimmedLeftIndex(string),trimmedRightIndex(string)+1)}chars=chars+"";return string.slice(charsLeftIndex(string,chars),charsRightIndex(string,chars)+1)}module.exports=trim},{"../internal/baseToString":67,"../internal/charsLeftIndex":74,"../internal/charsRightIndex":75,"../internal/isIterateeCall":104,"../internal/trimmedLeftIndex":123,"../internal/trimmedRightIndex":124}],148:[function(require,module,exports){function identity(value){return value}module.exports=identity},{}],149:[function(require,module,exports){function noop(){}module.exports=noop},{}],150:[function(require,module,exports){var baseProperty=require("../internal/baseProperty"),basePropertyDeep=require("../internal/basePropertyDeep"),isKey=require("../internal/isKey");function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}module.exports=property},{"../internal/baseProperty":59,"../internal/basePropertyDeep":60,"../internal/isKey":105}],151:[function(require,module,exports){"use strict";var isUndefined=require("lodash/lang/isUndefined");var isString=require("lodash/lang/isString");var isFunction=require("lodash/lang/isFunction");var isEmpty=require("lodash/lang/isEmpty");var defaults=require("lodash/object/defaults");var reduce=require("lodash/collection/reduce");var filter=require("lodash/collection/filter");var omit=require("lodash/object/omit");var lib={addRefinement:function addRefinement(refinementList,attribute,value){if(lib.isRefined(refinementList,attribute,value)){return refinementList}var valueAsString=""+value;var facetRefinement=!refinementList[attribute]?[valueAsString]:refinementList[attribute].concat(valueAsString);var mod={};mod[attribute]=facetRefinement;return defaults({},mod,refinementList)},removeRefinement:function removeRefinement(refinementList,attribute,value){if(isUndefined(value)){return lib.clearRefinement(refinementList,attribute)}var valueAsString=""+value;return lib.clearRefinement(refinementList,function(v,f){return attribute===f&&valueAsString===v})},toggleRefinement:function toggleRefinement(refinementList,attribute,value){if(isUndefined(value))throw new Error("toggleRefinement should be used with a value");if(lib.isRefined(refinementList,attribute,value)){return lib.removeRefinement(refinementList,attribute,value)}return lib.addRefinement(refinementList,attribute,value)},clearRefinement:function clearRefinement(refinementList,attribute,refinementType){if(isUndefined(attribute)){return{}}else if(isString(attribute)){return omit(refinementList,attribute)}else if(isFunction(attribute)){return reduce(refinementList,function(memo,values,key){var facetList=filter(values,function(value){return!attribute(value,key,refinementType)});if(!isEmpty(facetList))memo[key]=facetList;return memo},{})}},isRefined:function isRefined(refinementList,attribute,refinementValue){var indexOf=require("lodash/array/indexOf");var containsRefinements=!!refinementList[attribute]&&refinementList[attribute].length>0;if(isUndefined(refinementValue)||!containsRefinements){return containsRefinements}var refinementValueAsString=""+refinementValue;return indexOf(refinementList[attribute],refinementValueAsString)!==-1}};module.exports=lib},{"lodash/array/indexOf":5,"lodash/collection/filter":9,"lodash/collection/reduce":15,"lodash/lang/isEmpty":128,"lodash/lang/isFunction":129,"lodash/lang/isString":133,"lodash/lang/isUndefined":135,"lodash/object/defaults":139,"lodash/object/omit":143}],152:[function(require,module,exports){"use strict";var keys=require("lodash/object/keys");var intersection=require("lodash/array/intersection");var forEach=require("lodash/collection/forEach");var reduce=require("lodash/collection/reduce");var filter=require("lodash/collection/filter");var omit=require("lodash/object/omit");var indexOf=require("lodash/array/indexOf");var isEmpty=require("lodash/lang/isEmpty");var isUndefined=require("lodash/lang/isUndefined");var isString=require("lodash/lang/isString");var isFunction=require("lodash/lang/isFunction");var find=require("lodash/collection/find");var pluck=require("lodash/collection/pluck");var defaults=require("lodash/object/defaults");var merge=require("lodash/object/merge");var deepFreeze=require("../functions/deepFreeze");var RefinementList=require("./RefinementList");function SearchParameters(newParameters){var params=newParameters||{};this.query=params.query||"";this.facets=params.facets||[];this.disjunctiveFacets=params.disjunctiveFacets||[];this.hierarchicalFacets=params.hierarchicalFacets||[];this.facetsRefinements=params.facetsRefinements||{};this.facetsExcludes=params.facetsExcludes||{};this.disjunctiveFacetsRefinements=params.disjunctiveFacetsRefinements||{};this.numericRefinements=params.numericRefinements||{};this.tagRefinements=params.tagRefinements||[];this.hierarchicalFacetsRefinements=params.hierarchicalFacetsRefinements||{};this.tagFilters=params.tagFilters;this.hitsPerPage=params.hitsPerPage;this.maxValuesPerFacet=params.maxValuesPerFacet;this.page=params.page||0;this.queryType=params.queryType;this.typoTolerance=params.typoTolerance;this.minWordSizefor1Typo=params.minWordSizefor1Typo;this.minWordSizefor2Typos=params.minWordSizefor2Typos;this.allowTyposOnNumericTokens=params.allowTyposOnNumericTokens;this.ignorePlurals=params.ignorePlurals;this.restrictSearchableAttributes=params.restrictSearchableAttributes;this.advancedSyntax=params.advancedSyntax;this.analytics=params.analytics;this.analyticsTags=params.analyticsTags;this.synonyms=params.synonyms;this.replaceSynonymsInHighlight=params.replaceSynonymsInHighlight;this.optionalWords=params.optionalWords;this.removeWordsIfNoResults=params.removeWordsIfNoResults;this.attributesToRetrieve=params.attributesToRetrieve;this.attributesToHighlight=params.attributesToHighlight;this.highlightPreTag=params.highlightPreTag;this.highlightPostTag=params.highlightPostTag;this.attributesToSnippet=params.attributesToSnippet;this.getRankingInfo=params.getRankingInfo;this.distinct=params.distinct;this.aroundLatLng=params.aroundLatLng;this.aroundLatLngViaIP=params.aroundLatLngViaIP;this.aroundRadius=params.aroundRadius;this.aroundPrecision=params.aroundPrecision;this.insideBoundingBox=params.insideBoundingBox}SearchParameters.make=function makeSearchParameters(newParameters){var instance=new SearchParameters(newParameters);return deepFreeze(instance)};SearchParameters.validate=function(currentState,parameters){var params=parameters||{};var ks=keys(params);var unknownKeys=filter(ks,function(k){return!currentState.hasOwnProperty(k)});if(unknownKeys.length===1)return new Error("Property "+unknownKeys[0]+" is not defined on SearchParameters (see http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)");if(unknownKeys.length>1)return new Error("Properties "+unknownKeys.join(" ")+" are not defined on SearchParameters (see http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)");if(currentState.tagFilters&&params.tagRefinements&&params.tagRefinements.length>0){return new Error("[Tags] Can't switch from the managed tag API to the advanced API. It is probably an error, if it's really what you want, you should first clear the tags with clearTags method.")}if(currentState.tagRefinements.length>0&&params.tagFilters){return new Error("[Tags] Can't switch from the advanced tag API to the managed API. It is probably an error, if it's not, you should first clear the tags with clearTags method.")}return null};SearchParameters.prototype={constructor:SearchParameters,clearRefinements:function clearRefinements(attribute){return this.setQueryParameters({page:0,numericRefinements:this._clearNumericRefinements(attribute),facetsRefinements:RefinementList.clearRefinement(this.facetsRefinements,attribute,"conjunctiveFacet"),facetsExcludes:RefinementList.clearRefinement(this.facetsExcludes,attribute,"exclude"),disjunctiveFacetsRefinements:RefinementList.clearRefinement(this.disjunctiveFacetsRefinements,attribute,"disjunctiveFacet"),hierarchicalFacetsRefinements:RefinementList.clearRefinement(this.hierarchicalFacetsRefinements,attribute,"hierarchicalFacet")})},clearTags:function clearTags(){if(this.tagFilters===undefined&&this.tagRefinements.length===0)return this;return this.setQueryParameters({page:0,tagFilters:undefined,tagRefinements:[]})},setQuery:function setQuery(newQuery){if(newQuery===this.query)return this;return this.setQueryParameters({query:newQuery,page:0})},setPage:function setPage(newPage){if(newPage===this.page)return this;return this.setQueryParameters({page:newPage})},setFacets:function setFacets(facets){return this.setQueryParameters({facets:facets})},setDisjunctiveFacets:function setDisjunctiveFacets(facets){return this.setQueryParameters({disjunctiveFacets:facets})},setHitsPerPage:function setHitsPerPage(n){if(this.hitsPerPage===n)return this;return this.setQueryParameters({hitsPerPage:n,page:0})},setTypoTolerance:function setTypoTolerance(typoTolerance){if(this.typoTolerance===typoTolerance)return this;return this.setQueryParameters({typoTolerance:typoTolerance,page:0})},addNumericRefinement:function(attribute,operator,value){if(this.isNumericRefined(attribute,operator,value))return this;var mod=merge({},this.numericRefinements);mod[attribute]=merge({},mod[attribute]);mod[attribute][operator]=value;return this.setQueryParameters({page:0,numericRefinements:mod})},getConjunctiveRefinements:function(facetName){if(!this.isConjunctiveFacet(facetName)){throw new Error(facetName+" is not defined in the facets attribute of the helper configuration")}return this.facetsRefinements[facetName]||[]},getDisjunctiveRefinements:function(facetName){if(!this.isDisjunctiveFacet(facetName)){throw new Error(facetName+" is not defined in the disjunctiveFacets attribute of the helper configuration")}return this.disjunctiveFacetsRefinements[facetName]||[]},getHierarchicalRefinement:function(facetName){return this.hierarchicalFacetsRefinements[facetName]||[]},getExcludeRefinements:function(facetName){if(!this.isConjunctiveFacet(facetName)){throw new Error(facetName+" is not defined in the facets attribute of the helper configuration")}return this.facetsExcludes[facetName]||[]},removeNumericRefinement:function(attribute,operator){if(!this.isNumericRefined(attribute,operator))return this;return this.setQueryParameters({page:0,numericRefinements:this._clearNumericRefinements(function(value,key){return key===attribute&&value.op===operator})})},getNumericRefinements:function(facetName){return this.numericRefinements[facetName]||[]},getNumericRefinement:function(attribute,operator){return this.numericRefinements[attribute]&&this.numericRefinements[attribute][operator]},_clearNumericRefinements:function _clearNumericRefinements(attribute){if(isUndefined(attribute)){return{}}else if(isString(attribute)){return omit(this.numericRefinements,attribute)}else if(isFunction(attribute)){return reduce(this.numericRefinements,function(memo,operators,key){var operatorList=omit(operators,function(value,operator){return attribute({val:value,op:operator},key,"numeric")});if(!isEmpty(operatorList))memo[key]=operatorList;return memo},{})}},addFacetRefinement:function addFacetRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}if(RefinementList.isRefined(this.facetsRefinements,facet,value))return this;return this.setQueryParameters({page:0,facetsRefinements:RefinementList.addRefinement(this.facetsRefinements,facet,value)})},addExcludeRefinement:function addExcludeRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}if(RefinementList.isRefined(this.facetsExcludes,facet,value))return this;return this.setQueryParameters({page:0,facetsExcludes:RefinementList.addRefinement(this.facetsExcludes,facet,value)})},addDisjunctiveFacetRefinement:function addDisjunctiveFacetRefinement(facet,value){if(!this.isDisjunctiveFacet(facet)){throw new Error(facet+" is not defined in the disjunctiveFacets attribute of the helper configuration")}if(RefinementList.isRefined(this.disjunctiveFacetsRefinements,facet,value))return this;return this.setQueryParameters({page:0,disjunctiveFacetsRefinements:RefinementList.addRefinement(this.disjunctiveFacetsRefinements,facet,value)})},addTagRefinement:function addTagRefinement(tag){if(this.isTagRefined(tag))return this;var modification={page:0,tagRefinements:this.tagRefinements.concat(tag)};return this.setQueryParameters(modification)},removeFacetRefinement:function removeFacetRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}if(!RefinementList.isRefined(this.facetsRefinements,facet,value))return this;return this.setQueryParameters({page:0,facetsRefinements:RefinementList.removeRefinement(this.facetsRefinements,facet,value)})},removeExcludeRefinement:function removeExcludeRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}if(!RefinementList.isRefined(this.facetsExcludes,facet,value))return this;return this.setQueryParameters({page:0,facetsExcludes:RefinementList.removeRefinement(this.facetsExcludes,facet,value)})},removeDisjunctiveFacetRefinement:function removeDisjunctiveFacetRefinement(facet,value){if(!this.isDisjunctiveFacet(facet)){throw new Error(facet+" is not defined in the disjunctiveFacets attribute of the helper configuration")}if(!RefinementList.isRefined(this.disjunctiveFacetsRefinements,facet,value))return this;return this.setQueryParameters({page:0,disjunctiveFacetsRefinements:RefinementList.removeRefinement(this.disjunctiveFacetsRefinements,facet,value)})},removeTagRefinement:function removeTagRefinement(tag){if(!this.isTagRefined(tag))return this;var modification={page:0,tagRefinements:filter(this.tagRefinements,function(t){return t!==tag})};return this.setQueryParameters(modification)},toggleFacetRefinement:function toggleFacetRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}return this.setQueryParameters({page:0,facetsRefinements:RefinementList.toggleRefinement(this.facetsRefinements,facet,value)})},toggleExcludeFacetRefinement:function toggleExcludeFacetRefinement(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}return this.setQueryParameters({page:0,facetsExcludes:RefinementList.toggleRefinement(this.facetsExcludes,facet,value)})},toggleDisjunctiveFacetRefinement:function toggleDisjunctiveFacetRefinement(facet,value){if(!this.isDisjunctiveFacet(facet)){throw new Error(facet+" is not defined in the disjunctiveFacets attribute of the helper configuration")}return this.setQueryParameters({page:0,disjunctiveFacetsRefinements:RefinementList.toggleRefinement(this.disjunctiveFacetsRefinements,facet,value)})},toggleHierarchicalFacetRefinement:function toggleHierarchicalFacetRefinement(facet,value){if(!this.isHierarchicalFacet(facet)){throw new Error(facet+" is not defined in the hierarchicalFacets attribute of the helper configuration")}var separator=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facet));var mod={};var upOneOrMultipleLevel=this.hierarchicalFacetsRefinements[facet]!==undefined&&this.hierarchicalFacetsRefinements[facet].length>0&&(this.hierarchicalFacetsRefinements[facet][0]===value||this.hierarchicalFacetsRefinements[facet][0].indexOf(value+separator)===0);if(upOneOrMultipleLevel){if(value.indexOf(separator)===-1){mod[facet]=[]}else{mod[facet]=[value.slice(0,value.lastIndexOf(separator))]}}else{mod[facet]=[value]}return this.setQueryParameters({hierarchicalFacetsRefinements:defaults({},mod,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function toggleTagRefinement(tag){if(this.isTagRefined(tag)){return this.removeTagRefinement(tag)}return this.addTagRefinement(tag)},isDisjunctiveFacet:function(facet){return indexOf(this.disjunctiveFacets,facet)>-1},isHierarchicalFacet:function(facetName){return this.getHierarchicalFacetByName(facetName)!==undefined},isConjunctiveFacet:function(facet){return indexOf(this.facets,facet)>-1},isFacetRefined:function isFacetRefined(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}return RefinementList.isRefined(this.facetsRefinements,facet,value)},isExcludeRefined:function isExcludeRefined(facet,value){if(!this.isConjunctiveFacet(facet)){throw new Error(facet+" is not defined in the facets attribute of the helper configuration")}return RefinementList.isRefined(this.facetsExcludes,facet,value)},isDisjunctiveFacetRefined:function isDisjunctiveFacetRefined(facet,value){if(!this.isDisjunctiveFacet(facet)){throw new Error(facet+" is not defined in the disjunctiveFacets attribute of the helper configuration")}return RefinementList.isRefined(this.disjunctiveFacetsRefinements,facet,value)},isNumericRefined:function isNumericRefined(attribute,operator,value){if(isUndefined(value)){return this.numericRefinements[attribute]&&!isUndefined(this.numericRefinements[attribute][operator])}return this.numericRefinements[attribute]&&!isUndefined(this.numericRefinements[attribute][operator])&&this.numericRefinements[attribute][operator]===value},isTagRefined:function isTagRefined(tag){return indexOf(this.tagRefinements,tag)!==-1},getRefinedDisjunctiveFacets:function getRefinedDisjunctiveFacets(){var disjunctiveNumericRefinedFacets=intersection(keys(this.numericRefinements),this.disjunctiveFacets);return keys(this.disjunctiveFacetsRefinements).concat(disjunctiveNumericRefinedFacets).concat(this.getRefinedHierarchicalFacets())},getRefinedHierarchicalFacets:function getRefinedHierarchicalFacets(){return intersection(pluck(this.hierarchicalFacets,"name"),keys(this.hierarchicalFacetsRefinements))},getUnrefinedDisjunctiveFacets:function(){var refinedFacets=this.getRefinedDisjunctiveFacets();return filter(this.disjunctiveFacets,function(f){return indexOf(refinedFacets,f)===-1})},managedParameters:["facets","disjunctiveFacets","facetsRefinements","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacets","hierarchicalFacetsRefinements"],getQueryParams:function getQueryParams(){var managedParameters=this.managedParameters;return reduce(this,function(memo,value,parameter,parameters){if(indexOf(managedParameters,parameter)===-1&&parameters[parameter]!==undefined){memo[parameter]=value}return memo},{})},getQueryParameter:function getQueryParameter(paramName){if(!this.hasOwnProperty(paramName))throw new Error("Parameter '"+paramName+"' is not an attribute of SearchParameters (http://algolia.github.io/algoliasearch-helper-js/docs/SearchParameters.html)");return this[paramName]},setQueryParameter:function setParameter(parameter,value){if(this[parameter]===value)return this;var modification={};modification[parameter]=value;return this.setQueryParameters(modification)},setQueryParameters:function setQueryParameters(params){var error=SearchParameters.validate(this,params);if(error){throw error}return this.mutateMe(function mergeWith(newInstance){var ks=keys(params);forEach(ks,function(k){newInstance[k]=params[k]});return newInstance})},mutateMe:function mutateMe(fn){var newState=new this.constructor(this);fn(newState,this);return deepFreeze(newState)},_getHierarchicalFacetSortBy:function(hierarchicalFacet){return hierarchicalFacet.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(hierarchicalFacet){return hierarchicalFacet.separator||" > "},getHierarchicalFacetByName:function(hierarchicalFacetName){return find(this.hierarchicalFacets,{name:hierarchicalFacetName})}};module.exports=SearchParameters},{"../functions/deepFreeze":156,"./RefinementList":151,"lodash/array/indexOf":5,"lodash/array/intersection":6,"lodash/collection/filter":9,"lodash/collection/find":10,"lodash/collection/forEach":11,"lodash/collection/pluck":14,"lodash/collection/reduce":15,"lodash/lang/isEmpty":128,"lodash/lang/isFunction":129,"lodash/lang/isString":133,"lodash/lang/isUndefined":135,"lodash/object/defaults":139,"lodash/object/keys":140,"lodash/object/merge":142,"lodash/object/omit":143}],153:[function(require,module,exports){"use strict";module.exports=generateTrees;var last=require("lodash/array/last");var map=require("lodash/collection/map");var reduce=require("lodash/collection/reduce");var sortByOrder=require("lodash/collection/sortByOrder");var trim=require("lodash/string/trim");var find=require("lodash/collection/find");var pick=require("lodash/object/pick");function generateTrees(state){return function generate(hierarchicalFacetResult,hierarchicalFacetIndex){var hierarchicalFacet=state.hierarchicalFacets[hierarchicalFacetIndex];var hierarchicalFacetRefinement=state.hierarchicalFacetsRefinements[hierarchicalFacet.name]&&state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0]||"";var hierarchicalSeparator=state._getHierarchicalFacetSeparator(hierarchicalFacet);var sortBy=prepareHierarchicalFacetSortBy(state._getHierarchicalFacetSortBy(hierarchicalFacet));var generateTreeFn=generateHierarchicalTree(sortBy,hierarchicalSeparator,hierarchicalFacetRefinement);
 
 
 
 
4
 
5
+ return reduce(hierarchicalFacetResult,generateTreeFn,{name:state.hierarchicalFacets[hierarchicalFacetIndex].name,count:null,isRefined:true,path:null,data:null})}}function generateHierarchicalTree(sortBy,hierarchicalSeparator,currentRefinement){return function generateTree(hierarchicalTree,hierarchicalFacetResult,currentHierarchicalLevel){var parent=hierarchicalTree;if(currentHierarchicalLevel>0){var level=0;parent=hierarchicalTree;while(level<currentHierarchicalLevel){parent=parent&&find(parent.data,{isRefined:true});level++}}if(parent){var onlyMatchingValuesFn=filterFacetValues(parent.path,currentRefinement,hierarchicalSeparator);parent.data=sortByOrder(map(pick(hierarchicalFacetResult.data,onlyMatchingValuesFn),formatHierarchicalFacetValue(hierarchicalSeparator,currentRefinement)),sortBy[0],sortBy[1])}return hierarchicalTree}}function filterFacetValues(parentPath,currentRefinement,hierarchicalSeparator){return function(facetCount,facetValue){return facetValue.indexOf(hierarchicalSeparator)===-1||facetValue.indexOf(hierarchicalSeparator)===-1&&currentRefinement.indexOf(hierarchicalSeparator)===-1||currentRefinement.indexOf(facetValue+hierarchicalSeparator)===0||facetValue.indexOf(parentPath+hierarchicalSeparator)===0}}function formatHierarchicalFacetValue(hierarchicalSeparator,currentRefinement){return function format(facetCount,facetValue){return{name:trim(last(facetValue.split(hierarchicalSeparator))),path:facetValue,count:facetCount,isRefined:currentRefinement===facetValue||currentRefinement.indexOf(facetValue+hierarchicalSeparator)===0,data:null}}}function prepareHierarchicalFacetSortBy(sortBy){return reduce(sortBy,function prepare(out,sortInstruction){var sortInstructions=sortInstruction.split(":");out[0].push(sortInstructions[0]);out[1].push(sortInstructions[1]);return out},[[],[]])}},{"lodash/array/last":7,"lodash/collection/find":10,"lodash/collection/map":13,"lodash/collection/reduce":15,"lodash/collection/sortByOrder":16,"lodash/object/pick":145,"lodash/string/trim":147}],154:[function(require,module,exports){"use strict";var forEach=require("lodash/collection/forEach");var compact=require("lodash/array/compact");var indexOf=require("lodash/array/indexOf");var sum=require("lodash/collection/sum");var find=require("lodash/collection/find");var includes=require("lodash/collection/includes");var map=require("lodash/collection/map");var findIndex=require("lodash/array/findIndex");var defaults=require("lodash/object/defaults");var merge=require("lodash/object/merge");var generateHierarchicalTree=require("./generate-hierarchical-tree");function getIndices(obj){var indices={};forEach(obj,function(val,idx){indices[val]=idx});return indices}function assignFacetStats(dest,facetStats,key){if(facetStats&&facetStats[key]){dest.stats=facetStats[key]}}function findMatchingHierarchicalFacetFromAttributeName(hierarchicalFacets,hierarchicalAttributeName){return find(hierarchicalFacets,function facetKeyMatchesAttribute(hierarchicalFacet){return includes(hierarchicalFacet.attributes,hierarchicalAttributeName)})}function SearchResults(state,algoliaResponse){var mainSubResponse=algoliaResponse.results[0];this.query=mainSubResponse.query;this.hits=mainSubResponse.hits;this.index=mainSubResponse.index;this.hitsPerPage=mainSubResponse.hitsPerPage;this.nbHits=mainSubResponse.nbHits;this.nbPages=mainSubResponse.nbPages;this.page=mainSubResponse.page;this.processingTimeMS=sum(algoliaResponse.results,"processingTimeMS");this.disjunctiveFacets=[];this.hierarchicalFacets=map(state.hierarchicalFacets,function initFutureTree(){return[]});this.facets=[];var disjunctiveFacets=state.getRefinedDisjunctiveFacets();var facetsIndices=getIndices(state.facets);var disjunctiveFacetsIndices=getIndices(state.disjunctiveFacets);var nextDisjunctiveResult=1;forEach(mainSubResponse.facets,function(facetValueObject,facetKey){var hierarchicalFacet;if(hierarchicalFacet=findMatchingHierarchicalFacetFromAttributeName(state.hierarchicalFacets,facetKey)){this.hierarchicalFacets[findIndex(state.hierarchicalFacets,{name:hierarchicalFacet.name})].push({attribute:facetKey,data:facetValueObject,exhaustive:mainSubResponse.exhaustiveFacetsCount})}else{var isFacetDisjunctive=indexOf(state.disjunctiveFacets,facetKey)!==-1;var position=isFacetDisjunctive?disjunctiveFacetsIndices[facetKey]:facetsIndices[facetKey];if(isFacetDisjunctive){this.disjunctiveFacets[position]={name:facetKey,data:facetValueObject,exhaustive:mainSubResponse.exhaustiveFacetsCount};assignFacetStats(this.disjunctiveFacets[position],mainSubResponse.facets_stats,facetKey)}else{this.facets[position]={name:facetKey,data:facetValueObject,exhaustive:mainSubResponse.exhaustiveFacetsCount};assignFacetStats(this.facets[position],mainSubResponse.facets_stats,facetKey)}}},this);forEach(disjunctiveFacets,function(disjunctiveFacet){var result=algoliaResponse.results[nextDisjunctiveResult];var hierarchicalFacet=state.getHierarchicalFacetByName(disjunctiveFacet);forEach(result.facets,function(facetResults,dfacet){var position;if(hierarchicalFacet){position=findIndex(state.hierarchicalFacets,{name:hierarchicalFacet.name});var attributeIndex=findIndex(this.hierarchicalFacets[position],{attribute:dfacet});this.hierarchicalFacets[position][attributeIndex].data=merge({},this.hierarchicalFacets[position][attributeIndex].data,facetResults)}else{position=disjunctiveFacetsIndices[dfacet];var dataFromMainRequest=mainSubResponse.facets&&mainSubResponse.facets[dfacet]||{};this.disjunctiveFacets[position]={name:dfacet,data:defaults({},facetResults,dataFromMainRequest),exhaustive:result.exhaustiveFacetsCount};assignFacetStats(this.disjunctiveFacets[position],result.facets_stats,dfacet);if(state.disjunctiveFacetsRefinements[dfacet]){forEach(state.disjunctiveFacetsRefinements[dfacet],function(refinementValue){if(!this.disjunctiveFacets[position].data[refinementValue]&&indexOf(state.disjunctiveFacetsRefinements[dfacet],refinementValue)>-1){this.disjunctiveFacets[position].data[refinementValue]=0}},this)}}},this);nextDisjunctiveResult++},this);forEach(state.getRefinedHierarchicalFacets(),function(refinedFacet){var hierarchicalFacet=state.getHierarchicalFacetByName(refinedFacet);var currentRefinement=state.getHierarchicalRefinement(refinedFacet);if(currentRefinement.length===0||currentRefinement[0].split(state._getHierarchicalFacetSeparator(hierarchicalFacet)).length<2){return}var result=algoliaResponse.results[nextDisjunctiveResult];forEach(result.facets,function(facetResults,dfacet){var position=findIndex(state.hierarchicalFacets,{name:hierarchicalFacet.name});var attributeIndex=findIndex(this.hierarchicalFacets[position],{attribute:dfacet});var defaultData={};if(currentRefinement.length>0){var root=currentRefinement[0].split(state._getHierarchicalFacetSeparator(hierarchicalFacet))[0];defaultData[root]=this.hierarchicalFacets[position][attributeIndex].data[root]}this.hierarchicalFacets[position][attributeIndex].data=defaults(defaultData,facetResults,this.hierarchicalFacets[position][attributeIndex].data)},this);nextDisjunctiveResult++},this);forEach(state.facetsExcludes,function(excludes,facetName){var position=facetsIndices[facetName];this.facets[position]={name:facetName,data:mainSubResponse.facets[facetName],exhaustive:mainSubResponse.exhaustiveFacetsCount};forEach(excludes,function(facetValue){this.facets[position]=this.facets[position]||{name:facetName};this.facets[position].data=this.facets[position].data||{};this.facets[position].data[facetValue]=0},this)},this);this.hierarchicalFacets=map(this.hierarchicalFacets,generateHierarchicalTree(state));this.facets=compact(this.facets);this.disjunctiveFacets=compact(this.disjunctiveFacets);this._state=state}SearchResults.prototype.getFacetByName=function(name){var predicate={name:name};return find(this.facets,predicate)||find(this.disjunctiveFacets,predicate)||find(this.hierarchicalFacets,predicate)};module.exports=SearchResults},{"./generate-hierarchical-tree":153,"lodash/array/compact":3,"lodash/array/findIndex":4,"lodash/array/indexOf":5,"lodash/collection/find":10,"lodash/collection/forEach":11,"lodash/collection/includes":12,"lodash/collection/map":13,"lodash/collection/sum":17,"lodash/object/defaults":139,"lodash/object/merge":142}],155:[function(require,module,exports){"use strict";var SearchParameters=require("./SearchParameters");var SearchResults=require("./SearchResults");var util=require("util");var events=require("events");var forEach=require("lodash/collection/forEach");var isEmpty=require("lodash/lang/isEmpty");var bind=require("lodash/function/bind");var reduce=require("lodash/collection/reduce");var map=require("lodash/collection/map");var trim=require("lodash/string/trim");var merge=require("lodash/object/merge");function AlgoliaSearchHelper(client,index,options){this.client=client;this.index=index;this.state=SearchParameters.make(options);this.lastResults=null;this._queryId=0;this._lastQueryIdReceived=-1}util.inherits(AlgoliaSearchHelper,events.EventEmitter);AlgoliaSearchHelper.prototype.search=function(){this._search();return this};AlgoliaSearchHelper.prototype.setQuery=function(q){this.state=this.state.setQuery(q);this._change();return this};AlgoliaSearchHelper.prototype.clearRefinements=function(name){this.state=this.state.clearRefinements(name);this._change();return this};AlgoliaSearchHelper.prototype.clearTags=function(){this.state=this.state.clearTags();this._change();return this};AlgoliaSearchHelper.prototype.addDisjunctiveRefine=function(facet,value){this.state=this.state.addDisjunctiveFacetRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.addNumericRefinement=function(attribute,operator,value){this.state=this.state.addNumericRefinement(attribute,operator,value);this._change();return this};AlgoliaSearchHelper.prototype.addRefine=function(facet,value){this.state=this.state.addFacetRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.addExclude=function(facet,value){this.state=this.state.addExcludeRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.addTag=function(tag){this.state=this.state.addTagRefinement(tag);this._change();return this};AlgoliaSearchHelper.prototype.removeNumericRefinement=function(attribute,operator,value){this.state=this.state.removeNumericRefinement(attribute,operator,value);this._change();return this};AlgoliaSearchHelper.prototype.removeDisjunctiveRefine=function(facet,value){this.state=this.state.removeDisjunctiveFacetRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.removeRefine=function(facet,value){this.state=this.state.removeFacetRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.removeExclude=function(facet,value){this.state=this.state.removeExcludeRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.removeTag=function(tag){this.state=this.state.removeTagRefinement(tag);this._change();return this};AlgoliaSearchHelper.prototype.toggleExclude=function(facet,value){this.state=this.state.toggleExcludeFacetRefinement(facet,value);this._change();return this};AlgoliaSearchHelper.prototype.toggleRefine=function(facet,value){if(this.state.isHierarchicalFacet(facet)){this.state=this.state.toggleHierarchicalFacetRefinement(facet,value)}else if(this.state.isConjunctiveFacet(facet)){this.state=this.state.toggleFacetRefinement(facet,value)}else if(this.state.isDisjunctiveFacet(facet)){this.state=this.state.toggleDisjunctiveFacetRefinement(facet,value)}else{throw new Error("Cannot refine the undeclared facet "+facet+"; it should be added to the helper options facets or disjunctiveFacets")}this._change();return this};AlgoliaSearchHelper.prototype.toggleTag=function(tag){this.state=this.state.toggleTagRefinement(tag);this._change();return this};AlgoliaSearchHelper.prototype.nextPage=function(){return this.setCurrentPage(this.state.page+1)};AlgoliaSearchHelper.prototype.previousPage=function(){return this.setCurrentPage(this.state.page-1)};AlgoliaSearchHelper.prototype.setCurrentPage=function(page){if(page<0)throw new Error("Page requested below 0.");this.state=this.state.setPage(page);this._change();return this};AlgoliaSearchHelper.prototype.setIndex=function(name){this.index=name;this.setCurrentPage(0);return this};AlgoliaSearchHelper.prototype.setQueryParameter=function(parameter,value){var newState=this.state.setQueryParameter(parameter,value);if(this.state===newState)return this;this.state=newState;this._change();return this};AlgoliaSearchHelper.prototype.setState=function(newState){this.state=new SearchParameters(newState);this._change();return this};AlgoliaSearchHelper.prototype.getState=function(){return this.state};AlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent=function(newState){this.state=new SearchParameters(newState);return this};AlgoliaSearchHelper.prototype.isRefined=function(facet,value){if(this.state.isConjunctiveFacet(facet)){return this.state.isFacetRefined(facet,value)}else if(this.state.isDisjunctiveFacet(facet)){return this.state.isDisjunctiveFacetRefined(facet,value)}throw new Error(facet+" is not properly defined in this helper configuration"+"(use the facets or disjunctiveFacets keys to configure it)")};AlgoliaSearchHelper.prototype.hasRefinements=function(attribute){var attributeHasNumericRefinements=!isEmpty(this.state.getNumericRefinements(attribute));var isFacetDeclared=this.state.isConjunctiveFacet(attribute)||this.state.isDisjunctiveFacet(attribute);if(!attributeHasNumericRefinements&&isFacetDeclared){return this.state.isFacetRefined(attribute)}return attributeHasNumericRefinements};AlgoliaSearchHelper.prototype.isExcluded=function(facet,value){return this.state.isExcludeRefined(facet,value)};AlgoliaSearchHelper.prototype.isDisjunctiveRefined=function(facet,value){return this.state.isDisjunctiveFacetRefined(facet,value)};AlgoliaSearchHelper.prototype.isTagRefined=function(tag){return this.state.isTagRefined(tag)};AlgoliaSearchHelper.prototype.getIndex=function(){return this.index};AlgoliaSearchHelper.prototype.getCurrentPage=function(){return this.state.page};AlgoliaSearchHelper.prototype.getTags=function(){return this.state.tagRefinements};AlgoliaSearchHelper.prototype.getQueryParameter=function(parameterName){return this.state.getQueryParameter(parameterName)};AlgoliaSearchHelper.prototype.getRefinements=function(facetName){var refinements=[];if(this.state.isConjunctiveFacet(facetName)){var conjRefinements=this.state.getConjunctiveRefinements(facetName);forEach(conjRefinements,function(r){refinements.push({value:r,type:"conjunctive"})});var excludeRefinements=this.state.getExcludeRefinements(facetName);forEach(excludeRefinements,function(r){refinements.push({value:r,type:"exclude"})})}else if(this.state.isDisjunctiveFacet(facetName)){var disjRefinements=this.state.getDisjunctiveRefinements(facetName);forEach(disjRefinements,function(r){refinements.push({value:r,type:"disjunctive"})})}var numericRefinements=this.state.getNumericRefinements(facetName);forEach(numericRefinements,function(value,operator){refinements.push({value:value,operator:operator,type:"numeric"})});return refinements};AlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb=function(facetName){return map(this.state.getHierarchicalRefinement(facetName)[0].split(this.state._getHierarchicalFacetSeparator(this.state.getHierarchicalFacetByName(facetName))),function trimName(facetValue){return trim(facetValue)})};AlgoliaSearchHelper.prototype._search=function(){var state=this.state;this.client.search(this._getQueries(),bind(this._handleResponse,this,state,this._queryId++))};AlgoliaSearchHelper.prototype._getQueries=function getQueries(){var queries=[];queries.push({indexName:this.index,query:this.state.query,params:this._getHitsSearchParams()});forEach(this.state.getRefinedDisjunctiveFacets(),function(refinedFacet){queries.push({indexName:this.index,query:this.state.query,params:this._getDisjunctiveFacetSearchParams(refinedFacet)})},this);forEach(this.state.getRefinedHierarchicalFacets(),function(refinedFacet){var hierarchicalFacet=this.state.getHierarchicalFacetByName(refinedFacet);var currentRefinement=this.state.getHierarchicalRefinement(refinedFacet);if(currentRefinement.length>0&&currentRefinement[0].split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length>1){queries.push({indexName:this.index,query:this.state.query,params:this._getDisjunctiveFacetSearchParams(refinedFacet,true)})}},this);return queries};AlgoliaSearchHelper.prototype._handleResponse=function(state,queryId,err,content){if(queryId<this._lastQueryIdReceived){return}this._lastQueryIdReceived=queryId;if(err){this.emit("error",err);return}var formattedResponse=this.lastResults=new SearchResults(state,content);this.emit("result",formattedResponse,state)};AlgoliaSearchHelper.prototype._getHitsSearchParams=function(){var facets=this.state.facets.concat(this.state.disjunctiveFacets).concat(this._getHitsHierarchicalFacetsAttributes());var facetFilters=this._getFacetFilters();var numericFilters=this._getNumericFilters();var tagFilters=this._getTagFilters();var additionalParams={facets:facets,tagFilters:tagFilters};if(this.state.distinct===true||this.state.distinct===false){additionalParams.distinct=this.state.distinct}if(facetFilters.length>0){additionalParams.facetFilters=facetFilters}if(numericFilters.length>0){additionalParams.numericFilters=numericFilters}return merge(this.state.getQueryParams(),additionalParams)};AlgoliaSearchHelper.prototype._getDisjunctiveFacetSearchParams=function(facet,hierarchicalRootLevel){var facetFilters=this._getFacetFilters(facet,hierarchicalRootLevel);var numericFilters=this._getNumericFilters(facet);var tagFilters=this._getTagFilters();var additionalParams={hitsPerPage:1,page:0,attributesToRetrieve:[],attributesToHighlight:[],attributesToSnippet:[],tagFilters:tagFilters};var hierarchicalFacet=this.state.getHierarchicalFacetByName(facet);if(hierarchicalFacet){additionalParams.facets=this._getDisjunctiveHierarchicalFacetAttribute(hierarchicalFacet,hierarchicalRootLevel)}else{additionalParams.facets=facet}if(this.state.distinct===true||this.state.distinct===false){additionalParams.distinct=this.state.distinct}if(numericFilters.length>0){additionalParams.numericFilters=numericFilters}if(facetFilters.length>0){additionalParams.facetFilters=facetFilters}return merge(this.state.getQueryParams(),additionalParams)};AlgoliaSearchHelper.prototype.containsRefinement=function(query,facetFilters,numericFilters,tagFilters){return query||facetFilters.length!==0||numericFilters.length!==0||tagFilters.length!==0};AlgoliaSearchHelper.prototype._getNumericFilters=function(facetName){var numericFilters=[];forEach(this.state.numericRefinements,function(operators,attribute){forEach(operators,function(value,operator){if(facetName!==attribute){numericFilters.push(attribute+operator+value)}})});return numericFilters};AlgoliaSearchHelper.prototype._getTagFilters=function(){if(this.state.tagFilters){return this.state.tagFilters}return this.state.tagRefinements.join(",")};AlgoliaSearchHelper.prototype._hasDisjunctiveRefinements=function(facet){return this.state.disjunctiveRefinements[facet]&&this.state.disjunctiveRefinements[facet].length>0};AlgoliaSearchHelper.prototype._getFacetFilters=function(facet,hierarchicalRootLevel){var facetFilters=[];forEach(this.state.facetsRefinements,function(facetValues,facetName){forEach(facetValues,function(facetValue){facetFilters.push(facetName+":"+facetValue)})});forEach(this.state.facetsExcludes,function(facetValues,facetName){forEach(facetValues,function(facetValue){facetFilters.push(facetName+":-"+facetValue)})});forEach(this.state.disjunctiveFacetsRefinements,function(facetValues,facetName){if(facetName===facet||!facetValues||facetValues.length===0)return;var orFilters=[];forEach(facetValues,function(facetValue){orFilters.push(facetName+":"+facetValue)});facetFilters.push(orFilters)});forEach(this.state.hierarchicalFacetsRefinements,function(facetValues,facetName){var facetValue=facetValues[0];if(facetValue===undefined){return}var hierarchicalFacet=this.state.getHierarchicalFacetByName(facetName);var separator=this.state._getHierarchicalFacetSeparator(hierarchicalFacet);var attributeToRefine;if(facet===facetName){if(facetValue.indexOf(separator)===-1||hierarchicalRootLevel===true){return}attributeToRefine=hierarchicalFacet.attributes[facetValue.split(separator).length-2];facetValue=facetValue.slice(0,facetValue.lastIndexOf(separator))}else{attributeToRefine=hierarchicalFacet.attributes[facetValue.split(separator).length-1]}facetFilters.push([attributeToRefine+":"+facetValue])},this);return facetFilters};AlgoliaSearchHelper.prototype._change=function(){this.emit("change",this.state,this.lastResults)};AlgoliaSearchHelper.prototype._getHitsHierarchicalFacetsAttributes=function(){var out=[];return reduce(this.state.hierarchicalFacets,function getHitsAttributesForHierarchicalFacet(allAttributes,hierarchicalFacet){var hierarchicalRefinement=this.state.getHierarchicalRefinement(hierarchicalFacet.name)[0];if(!hierarchicalRefinement){allAttributes.push(hierarchicalFacet.attributes[0]);return allAttributes}var level=hierarchicalRefinement.split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length;var newAttributes=hierarchicalFacet.attributes.slice(0,level+1);return allAttributes.concat(newAttributes)},out,this)};AlgoliaSearchHelper.prototype._getDisjunctiveHierarchicalFacetAttribute=function(hierarchicalFacet,rootLevel){if(rootLevel===true){return[hierarchicalFacet.attributes[0]]}var hierarchicalRefinement=this.state.getHierarchicalRefinement(hierarchicalFacet.name)[0]||"";var parentLevel=hierarchicalRefinement.split(this.state._getHierarchicalFacetSeparator(hierarchicalFacet)).length-1;return hierarchicalFacet.attributes.slice(0,parentLevel+1)};module.exports=AlgoliaSearchHelper},{"./SearchParameters":152,"./SearchResults":154,events:219,"lodash/collection/forEach":11,"lodash/collection/map":13,"lodash/collection/reduce":15,"lodash/function/bind":19,"lodash/lang/isEmpty":128,"lodash/object/merge":142,"lodash/string/trim":147,util:226}],156:[function(require,module,exports){"use strict";var forEach=require("lodash/collection/forEach");var identity=require("lodash/utility/identity");var isObject=require("lodash/lang/isObject");var deepFreeze=function(obj){if(!isObject(obj))return obj;forEach(obj,deepFreeze);if(!Object.isFrozen(obj)){Object.freeze(obj)}return obj};module.exports=Object.freeze?deepFreeze:identity},{"lodash/collection/forEach":11,"lodash/lang/isObject":131,"lodash/utility/identity":148}],157:[function(require,module,exports){exports=module.exports=require("./debug");exports.log=log;exports.formatArgs=formatArgs;exports.save=save;exports.load=load;exports.useColors=useColors;exports.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:localstorage();exports.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function useColors(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}exports.formatters.j=function(v){return JSON.stringify(v)};function formatArgs(){var args=arguments;var useColors=this.useColors;args[0]=(useColors?"%c":"")+this.namespace+(useColors?" %c":" ")+args[0]+(useColors?"%c ":" ")+"+"+exports.humanize(this.diff);if(!useColors)return args;var c="color: "+this.color;args=[args[0],c,"color: inherit"].concat(Array.prototype.slice.call(args,1));var index=0;var lastC=0;args[0].replace(/%[a-z%]/g,function(match){if("%%"===match)return;index++;if("%c"===match){lastC=index}});args.splice(lastC,0,c);return args}function log(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function save(namespaces){try{if(null==namespaces){exports.storage.removeItem("debug")}else{exports.storage.debug=namespaces}}catch(e){}}function load(){var r;try{r=exports.storage.debug}catch(e){}return r}exports.enable(load());function localstorage(){try{return window.localStorage}catch(e){}}},{"./debug":158}],158:[function(require,module,exports){exports=module.exports=debug;exports.coerce=coerce;exports.disable=disable;exports.enable=enable;exports.enabled=enabled;exports.humanize=require("algolia-ms");exports.names=[];exports.skips=[];exports.formatters={};var prevColor=0;var prevTime;function selectColor(){return exports.colors[prevColor++%exports.colors.length]}function debug(namespace){function disabled(){}disabled.enabled=false;function enabled(){var self=enabled;var curr=+new Date;var ms=curr-(prevTime||curr);self.diff=ms;self.prev=prevTime;self.curr=curr;prevTime=curr;if(null==self.useColors)self.useColors=exports.useColors();if(null==self.color&&self.useColors)self.color=selectColor();var args=Array.prototype.slice.call(arguments);args[0]=exports.coerce(args[0]);if("string"!==typeof args[0]){args=["%o"].concat(args)}var index=0;args[0]=args[0].replace(/%([a-z%])/g,function(match,format){if(match==="%%")return match;index++;var formatter=exports.formatters[format];if("function"===typeof formatter){var val=args[index];match=formatter.call(self,val);args.splice(index,1);index--}return match});if("function"===typeof exports.formatArgs){args=exports.formatArgs.apply(self,args)}var logFn=enabled.log||exports.log||console.log.bind(console);logFn.apply(self,args)}enabled.enabled=true;var fn=exports.enabled(namespace)?enabled:disabled;fn.namespace=namespace;return fn}function enable(namespaces){exports.save(namespaces);var split=(namespaces||"").split(/[\s,]+/);var len=split.length;for(var i=0;i<len;i++){if(!split[i])continue;namespaces=split[i].replace(/\*/g,".*?");if(namespaces[0]==="-"){exports.skips.push(new RegExp("^"+namespaces.substr(1)+"$"))}else{exports.names.push(new RegExp("^"+namespaces+"$"))}}}function disable(){exports.enable("")}function enabled(name){var i,len;for(i=0,len=exports.skips.length;i<len;i++){if(exports.skips[i].test(name)){return false}}for(i=0,len=exports.names.length;i<len;i++){if(exports.names[i].test(name)){return true}}return false}function coerce(val){if(val instanceof Error)return val.stack||val.message;return val}},{"algolia-ms":159}],159:[function(require,module,exports){var s=1e3;var m=s*60;var h=m*60;var d=h*24;var y=d*365.25;module.exports=function(val,options){options=options||{};if("string"==typeof val)return parse(val);return options["long"]?_long(val):_short(val)};function parse(str){str=""+str;if(str.length>1e4)return;var match=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);if(!match)return;var n=parseFloat(match[1]);var type=(match[2]||"ms").toLowerCase();switch(type){case"years":case"year":case"yrs":case"yr":case"y":return n*y;case"days":case"day":case"d":return n*d;case"hours":case"hour":case"hrs":case"hr":case"h":return n*h;case"minutes":case"minute":case"mins":case"min":case"m":return n*m;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}function _short(ms){if(ms>=d)return Math.round(ms/d)+"d";if(ms>=h)return Math.round(ms/h)+"h";if(ms>=m)return Math.round(ms/m)+"m";if(ms>=s)return Math.round(ms/s)+"s";return ms+"ms"}function _long(ms){return plural(ms,d,"day")||plural(ms,h,"hour")||plural(ms,m,"minute")||plural(ms,s,"second")||ms+" ms"}function plural(ms,n,name){if(ms<n)return;if(ms<n*1.5)return Math.floor(ms/n)+" "+name;return Math.ceil(ms/n)+" "+name+"s"}},{}],160:[function(require,module,exports){(function(process,global){(function(){"use strict";function lib$es6$promise$utils$$objectOrFunction(x){return typeof x==="function"||typeof x==="object"&&x!==null}function lib$es6$promise$utils$$isFunction(x){return typeof x==="function"}function lib$es6$promise$utils$$isMaybeThenable(x){return typeof x==="object"&&x!==null}var lib$es6$promise$utils$$_isArray;if(!Array.isArray){lib$es6$promise$utils$$_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}else{lib$es6$promise$utils$$_isArray=Array.isArray}var lib$es6$promise$utils$$isArray=lib$es6$promise$utils$$_isArray;var lib$es6$promise$asap$$len=0;var lib$es6$promise$asap$$toString={}.toString;var lib$es6$promise$asap$$vertxNext;var lib$es6$promise$asap$$customSchedulerFn;var lib$es6$promise$asap$$asap=function asap(callback,arg){lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len]=callback;lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len+1]=arg;lib$es6$promise$asap$$len+=2;if(lib$es6$promise$asap$$len===2){if(lib$es6$promise$asap$$customSchedulerFn){lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush)}else{lib$es6$promise$asap$$scheduleFlush()}}};function lib$es6$promise$asap$$setScheduler(scheduleFn){lib$es6$promise$asap$$customSchedulerFn=scheduleFn}function lib$es6$promise$asap$$setAsap(asapFn){lib$es6$promise$asap$$asap=asapFn}var lib$es6$promise$asap$$browserWindow=typeof window!=="undefined"?window:undefined;var lib$es6$promise$asap$$browserGlobal=lib$es6$promise$asap$$browserWindow||{};var lib$es6$promise$asap$$BrowserMutationObserver=lib$es6$promise$asap$$browserGlobal.MutationObserver||lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;var lib$es6$promise$asap$$isNode=typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var lib$es6$promise$asap$$isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function lib$es6$promise$asap$$useNextTick(){var nextTick=process.nextTick;var version=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);if(Array.isArray(version)&&version[1]==="0"&&version[2]==="10"){nextTick=setImmediate}return function(){nextTick(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useVertxTimer(){return function(){lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush)}}function lib$es6$promise$asap$$useMutationObserver(){var iterations=0;var observer=new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){node.data=iterations=++iterations%2}}function lib$es6$promise$asap$$useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=lib$es6$promise$asap$$flush;return function(){channel.port2.postMessage(0)}}function lib$es6$promise$asap$$useSetTimeout(){return function(){setTimeout(lib$es6$promise$asap$$flush,1)}}var lib$es6$promise$asap$$queue=new Array(1e3);function lib$es6$promise$asap$$flush(){for(var i=0;i<lib$es6$promise$asap$$len;i+=2){var callback=lib$es6$promise$asap$$queue[i];var arg=lib$es6$promise$asap$$queue[i+1];callback(arg);lib$es6$promise$asap$$queue[i]=undefined;lib$es6$promise$asap$$queue[i+1]=undefined}lib$es6$promise$asap$$len=0}function lib$es6$promise$asap$$attemptVertex(){try{var r=require;var vertx=r("vertx");lib$es6$promise$asap$$vertxNext=vertx.runOnLoop||vertx.runOnContext;return lib$es6$promise$asap$$useVertxTimer()}catch(e){return lib$es6$promise$asap$$useSetTimeout()}}var lib$es6$promise$asap$$scheduleFlush;if(lib$es6$promise$asap$$isNode){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useNextTick()}else if(lib$es6$promise$asap$$BrowserMutationObserver){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useMutationObserver()}else if(lib$es6$promise$asap$$isWorker){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useMessageChannel()}else if(lib$es6$promise$asap$$browserWindow===undefined&&typeof require==="function"){lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$attemptVertex()}else{lib$es6$promise$asap$$scheduleFlush=lib$es6$promise$asap$$useSetTimeout()}function lib$es6$promise$$internal$$noop(){}var lib$es6$promise$$internal$$PENDING=void 0;
 
 
 
6
 
7
+ var lib$es6$promise$$internal$$FULFILLED=1;var lib$es6$promise$$internal$$REJECTED=2;var lib$es6$promise$$internal$$GET_THEN_ERROR=new lib$es6$promise$$internal$$ErrorObject;function lib$es6$promise$$internal$$selfFullfillment(){return new TypeError("You cannot resolve a promise with itself")}function lib$es6$promise$$internal$$cannotReturnOwn(){return new TypeError("A promises callback cannot return that same promise.")}function lib$es6$promise$$internal$$getThen(promise){try{return promise.then}catch(error){lib$es6$promise$$internal$$GET_THEN_ERROR.error=error;return lib$es6$promise$$internal$$GET_THEN_ERROR}}function lib$es6$promise$$internal$$tryThen(then,value,fulfillmentHandler,rejectionHandler){try{then.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function lib$es6$promise$$internal$$handleForeignThenable(promise,thenable,then){lib$es6$promise$asap$$asap(function(promise){var sealed=false;var error=lib$es6$promise$$internal$$tryThen(then,thenable,function(value){if(sealed){return}sealed=true;if(thenable!==value){lib$es6$promise$$internal$$resolve(promise,value)}else{lib$es6$promise$$internal$$fulfill(promise,value)}},function(reason){if(sealed){return}sealed=true;lib$es6$promise$$internal$$reject(promise,reason)},"Settle: "+(promise._label||" unknown promise"));if(!sealed&&error){sealed=true;lib$es6$promise$$internal$$reject(promise,error)}},promise)}function lib$es6$promise$$internal$$handleOwnThenable(promise,thenable){if(thenable._state===lib$es6$promise$$internal$$FULFILLED){lib$es6$promise$$internal$$fulfill(promise,thenable._result)}else if(thenable._state===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,thenable._result)}else{lib$es6$promise$$internal$$subscribe(thenable,undefined,function(value){lib$es6$promise$$internal$$resolve(promise,value)},function(reason){lib$es6$promise$$internal$$reject(promise,reason)})}}function lib$es6$promise$$internal$$handleMaybeThenable(promise,maybeThenable){if(maybeThenable.constructor===promise.constructor){lib$es6$promise$$internal$$handleOwnThenable(promise,maybeThenable)}else{var then=lib$es6$promise$$internal$$getThen(maybeThenable);if(then===lib$es6$promise$$internal$$GET_THEN_ERROR){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$GET_THEN_ERROR.error)}else if(then===undefined){lib$es6$promise$$internal$$fulfill(promise,maybeThenable)}else if(lib$es6$promise$utils$$isFunction(then)){lib$es6$promise$$internal$$handleForeignThenable(promise,maybeThenable,then)}else{lib$es6$promise$$internal$$fulfill(promise,maybeThenable)}}}function lib$es6$promise$$internal$$resolve(promise,value){if(promise===value){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$selfFullfillment())}else if(lib$es6$promise$utils$$objectOrFunction(value)){lib$es6$promise$$internal$$handleMaybeThenable(promise,value)}else{lib$es6$promise$$internal$$fulfill(promise,value)}}function lib$es6$promise$$internal$$publishRejection(promise){if(promise._onerror){promise._onerror(promise._result)}lib$es6$promise$$internal$$publish(promise)}function lib$es6$promise$$internal$$fulfill(promise,value){if(promise._state!==lib$es6$promise$$internal$$PENDING){return}promise._result=value;promise._state=lib$es6$promise$$internal$$FULFILLED;if(promise._subscribers.length!==0){lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish,promise)}}function lib$es6$promise$$internal$$reject(promise,reason){if(promise._state!==lib$es6$promise$$internal$$PENDING){return}promise._state=lib$es6$promise$$internal$$REJECTED;promise._result=reason;lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection,promise)}function lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection){var subscribers=parent._subscribers;var length=subscribers.length;parent._onerror=null;subscribers[length]=child;subscribers[length+lib$es6$promise$$internal$$FULFILLED]=onFulfillment;subscribers[length+lib$es6$promise$$internal$$REJECTED]=onRejection;if(length===0&&parent._state){lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish,parent)}}function lib$es6$promise$$internal$$publish(promise){var subscribers=promise._subscribers;var settled=promise._state;if(subscribers.length===0){return}var child,callback,detail=promise._result;for(var i=0;i<subscribers.length;i+=3){child=subscribers[i];callback=subscribers[i+settled];if(child){lib$es6$promise$$internal$$invokeCallback(settled,child,callback,detail)}else{callback(detail)}}promise._subscribers.length=0}function lib$es6$promise$$internal$$ErrorObject(){this.error=null}var lib$es6$promise$$internal$$TRY_CATCH_ERROR=new lib$es6$promise$$internal$$ErrorObject;function lib$es6$promise$$internal$$tryCatch(callback,detail){try{return callback(detail)}catch(e){lib$es6$promise$$internal$$TRY_CATCH_ERROR.error=e;return lib$es6$promise$$internal$$TRY_CATCH_ERROR}}function lib$es6$promise$$internal$$invokeCallback(settled,promise,callback,detail){var hasCallback=lib$es6$promise$utils$$isFunction(callback),value,error,succeeded,failed;if(hasCallback){value=lib$es6$promise$$internal$$tryCatch(callback,detail);if(value===lib$es6$promise$$internal$$TRY_CATCH_ERROR){failed=true;error=value.error;value=null}else{succeeded=true}if(promise===value){lib$es6$promise$$internal$$reject(promise,lib$es6$promise$$internal$$cannotReturnOwn());return}}else{value=detail;succeeded=true}if(promise._state!==lib$es6$promise$$internal$$PENDING){}else if(hasCallback&&succeeded){lib$es6$promise$$internal$$resolve(promise,value)}else if(failed){lib$es6$promise$$internal$$reject(promise,error)}else if(settled===lib$es6$promise$$internal$$FULFILLED){lib$es6$promise$$internal$$fulfill(promise,value)}else if(settled===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,value)}}function lib$es6$promise$$internal$$initializePromise(promise,resolver){try{resolver(function resolvePromise(value){lib$es6$promise$$internal$$resolve(promise,value)},function rejectPromise(reason){lib$es6$promise$$internal$$reject(promise,reason)})}catch(e){lib$es6$promise$$internal$$reject(promise,e)}}function lib$es6$promise$enumerator$$Enumerator(Constructor,input){var enumerator=this;enumerator._instanceConstructor=Constructor;enumerator.promise=new Constructor(lib$es6$promise$$internal$$noop);if(enumerator._validateInput(input)){enumerator._input=input;enumerator.length=input.length;enumerator._remaining=input.length;enumerator._init();if(enumerator.length===0){lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result)}else{enumerator.length=enumerator.length||0;enumerator._enumerate();if(enumerator._remaining===0){lib$es6$promise$$internal$$fulfill(enumerator.promise,enumerator._result)}}}else{lib$es6$promise$$internal$$reject(enumerator.promise,enumerator._validationError())}}lib$es6$promise$enumerator$$Enumerator.prototype._validateInput=function(input){return lib$es6$promise$utils$$isArray(input)};lib$es6$promise$enumerator$$Enumerator.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")};lib$es6$promise$enumerator$$Enumerator.prototype._init=function(){this._result=new Array(this.length)};var lib$es6$promise$enumerator$$default=lib$es6$promise$enumerator$$Enumerator;lib$es6$promise$enumerator$$Enumerator.prototype._enumerate=function(){var enumerator=this;var length=enumerator.length;var promise=enumerator.promise;var input=enumerator._input;for(var i=0;promise._state===lib$es6$promise$$internal$$PENDING&&i<length;i++){enumerator._eachEntry(input[i],i)}};lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry=function(entry,i){var enumerator=this;var c=enumerator._instanceConstructor;if(lib$es6$promise$utils$$isMaybeThenable(entry)){if(entry.constructor===c&&entry._state!==lib$es6$promise$$internal$$PENDING){entry._onerror=null;enumerator._settledAt(entry._state,i,entry._result)}else{enumerator._willSettleAt(c.resolve(entry),i)}}else{enumerator._remaining--;enumerator._result[i]=entry}};lib$es6$promise$enumerator$$Enumerator.prototype._settledAt=function(state,i,value){var enumerator=this;var promise=enumerator.promise;if(promise._state===lib$es6$promise$$internal$$PENDING){enumerator._remaining--;if(state===lib$es6$promise$$internal$$REJECTED){lib$es6$promise$$internal$$reject(promise,value)}else{enumerator._result[i]=value}}if(enumerator._remaining===0){lib$es6$promise$$internal$$fulfill(promise,enumerator._result)}};lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;lib$es6$promise$$internal$$subscribe(promise,undefined,function(value){enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED,i,value)},function(reason){enumerator._settledAt(lib$es6$promise$$internal$$REJECTED,i,reason)})};function lib$es6$promise$promise$all$$all(entries){return new lib$es6$promise$enumerator$$default(this,entries).promise}var lib$es6$promise$promise$all$$default=lib$es6$promise$promise$all$$all;function lib$es6$promise$promise$race$$race(entries){var Constructor=this;var promise=new Constructor(lib$es6$promise$$internal$$noop);if(!lib$es6$promise$utils$$isArray(entries)){lib$es6$promise$$internal$$reject(promise,new TypeError("You must pass an array to race."));return promise}var length=entries.length;function onFulfillment(value){lib$es6$promise$$internal$$resolve(promise,value)}function onRejection(reason){lib$es6$promise$$internal$$reject(promise,reason)}for(var i=0;promise._state===lib$es6$promise$$internal$$PENDING&&i<length;i++){lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]),undefined,onFulfillment,onRejection)}return promise}var lib$es6$promise$promise$race$$default=lib$es6$promise$promise$race$$race;function lib$es6$promise$promise$resolve$$resolve(object){var Constructor=this;if(object&&typeof object==="object"&&object.constructor===Constructor){return object}var promise=new Constructor(lib$es6$promise$$internal$$noop);lib$es6$promise$$internal$$resolve(promise,object);return promise}var lib$es6$promise$promise$resolve$$default=lib$es6$promise$promise$resolve$$resolve;function lib$es6$promise$promise$reject$$reject(reason){var Constructor=this;var promise=new Constructor(lib$es6$promise$$internal$$noop);lib$es6$promise$$internal$$reject(promise,reason);return promise}var lib$es6$promise$promise$reject$$default=lib$es6$promise$promise$reject$$reject;var lib$es6$promise$promise$$counter=0;function lib$es6$promise$promise$$needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function lib$es6$promise$promise$$needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var lib$es6$promise$promise$$default=lib$es6$promise$promise$$Promise;function lib$es6$promise$promise$$Promise(resolver){this._id=lib$es6$promise$promise$$counter++;this._state=undefined;this._result=undefined;this._subscribers=[];if(lib$es6$promise$$internal$$noop!==resolver){if(!lib$es6$promise$utils$$isFunction(resolver)){lib$es6$promise$promise$$needsResolver()}if(!(this instanceof lib$es6$promise$promise$$Promise)){lib$es6$promise$promise$$needsNew()}lib$es6$promise$$internal$$initializePromise(this,resolver)}}lib$es6$promise$promise$$Promise.all=lib$es6$promise$promise$all$$default;lib$es6$promise$promise$$Promise.race=lib$es6$promise$promise$race$$default;lib$es6$promise$promise$$Promise.resolve=lib$es6$promise$promise$resolve$$default;lib$es6$promise$promise$$Promise.reject=lib$es6$promise$promise$reject$$default;lib$es6$promise$promise$$Promise._setScheduler=lib$es6$promise$asap$$setScheduler;lib$es6$promise$promise$$Promise._setAsap=lib$es6$promise$asap$$setAsap;lib$es6$promise$promise$$Promise._asap=lib$es6$promise$asap$$asap;lib$es6$promise$promise$$Promise.prototype={constructor:lib$es6$promise$promise$$Promise,then:function(onFulfillment,onRejection){var parent=this;var state=parent._state;if(state===lib$es6$promise$$internal$$FULFILLED&&!onFulfillment||state===lib$es6$promise$$internal$$REJECTED&&!onRejection){return this}var child=new this.constructor(lib$es6$promise$$internal$$noop);var result=parent._result;if(state){var callback=arguments[state-1];lib$es6$promise$asap$$asap(function(){lib$es6$promise$$internal$$invokeCallback(state,child,callback,result)})}else{lib$es6$promise$$internal$$subscribe(parent,child,onFulfillment,onRejection)}return child},"catch":function(onRejection){return this.then(null,onRejection)}};function lib$es6$promise$polyfill$$polyfill(){var local;if(typeof global!=="undefined"){local=global}else if(typeof self!=="undefined"){local=self}else{try{local=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}}var P=local.Promise;if(P&&Object.prototype.toString.call(P.resolve())==="[object Promise]"&&!P.cast){return}local.Promise=lib$es6$promise$promise$$default}var lib$es6$promise$polyfill$$default=lib$es6$promise$polyfill$$polyfill;var lib$es6$promise$umd$$ES6Promise={Promise:lib$es6$promise$promise$$default,polyfill:lib$es6$promise$polyfill$$default};if(typeof define==="function"&&define["amd"]){define(function(){return lib$es6$promise$umd$$ES6Promise})}else if(typeof module!=="undefined"&&module["exports"]){module["exports"]=lib$es6$promise$umd$$ES6Promise}else if(typeof this!=="undefined"){this["ES6Promise"]=lib$es6$promise$umd$$ES6Promise}lib$es6$promise$polyfill$$default()}).call(this)}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:221}],161:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],162:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"../internal/arrayEach":165,"../internal/baseEach":169,"../internal/createForEach":181,dup:11}],163:[function(require,module,exports){arguments[4][20][0].apply(exports,arguments)},{dup:20}],164:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{dup:24}],165:[function(require,module,exports){arguments[4][25][0].apply(exports,arguments)},{dup:25}],166:[function(require,module,exports){arguments[4][34][0].apply(exports,arguments)},{"../object/keys":206,"./baseCopy":168,dup:34}],167:[function(require,module,exports){var arrayCopy=require("./arrayCopy"),arrayEach=require("./arrayEach"),baseAssign=require("./baseAssign"),baseForOwn=require("./baseForOwn"),initCloneArray=require("./initCloneArray"),initCloneByTag=require("./initCloneByTag"),initCloneObject=require("./initCloneObject"),isArray=require("../lang/isArray"),isHostObject=require("./isHostObject"),isObject=require("../lang/isObject");var argsTag="[object Arguments]",arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",mapTag="[object Map]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",weakMapTag="[object WeakMap]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=true;cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=false;var objectProto=Object.prototype;var objToString=objectProto.toString;function baseClone(value,isDeep,customizer,key,object,stackA,stackB){var result;if(customizer){result=object?customizer(value,key,object):customizer(value)}if(result!==undefined){return result}if(!isObject(value)){return value}var isArr=isArray(value);if(isArr){result=initCloneArray(value);if(!isDeep){return arrayCopy(value,result)}}else{var tag=objToString.call(value),isFunc=tag==funcTag;if(tag==objectTag||tag==argsTag||isFunc&&!object){if(isHostObject(value)){return object?value:{}}result=initCloneObject(isFunc?{}:value);if(!isDeep){return baseAssign(result,value)}}else{return cloneableTags[tag]?initCloneByTag(value,tag,isDeep):object?value:{}}}stackA||(stackA=[]);stackB||(stackB=[]);var length=stackA.length;while(length--){if(stackA[length]==value){return stackB[length]}}stackA.push(value);stackB.push(result);(isArr?arrayEach:baseForOwn)(value,function(subValue,key){result[key]=baseClone(subValue,isDeep,customizer,key,value,stackA,stackB)});return result}module.exports=baseClone},{"../lang/isArray":198,"../lang/isObject":201,"./arrayCopy":164,"./arrayEach":165,"./baseAssign":166,"./baseForOwn":172,"./initCloneArray":184,"./initCloneByTag":185,"./initCloneObject":186,"./isHostObject":188}],168:[function(require,module,exports){arguments[4][37][0].apply(exports,arguments)},{dup:37}],169:[function(require,module,exports){arguments[4][40][0].apply(exports,arguments)},{"./baseForOwn":172,"./createBaseEach":179,dup:40}],170:[function(require,module,exports){arguments[4][45][0].apply(exports,arguments)},{"./createBaseFor":180,dup:45}],171:[function(require,module,exports){arguments[4][46][0].apply(exports,arguments)},{"../object/keysIn":207,"./baseFor":170,dup:46}],172:[function(require,module,exports){arguments[4][47][0].apply(exports,arguments)},{"../object/keys":206,"./baseFor":170,dup:47}],173:[function(require,module,exports){arguments[4][57][0].apply(exports,arguments)},{"../lang/isArray":198,"../lang/isObject":201,"../lang/isTypedArray":204,"../object/keys":206,"./arrayEach":165,"./baseMergeDeep":174,"./isArrayLike":187,"./isObjectLike":192,dup:57}],174:[function(require,module,exports){arguments[4][58][0].apply(exports,arguments)},{"../lang/isArguments":197,"../lang/isArray":198,"../lang/isPlainObject":202,"../lang/isTypedArray":204,"../lang/toPlainObject":205,"./arrayCopy":164,"./isArrayLike":187,dup:58}],175:[function(require,module,exports){var toObject=require("./toObject");function baseProperty(key){return function(object){return object==null?undefined:toObject(object)[key]}}module.exports=baseProperty},{"./toObject":194}],176:[function(require,module,exports){arguments[4][71][0].apply(exports,arguments)},{"../utility/identity":210,dup:71}],177:[function(require,module,exports){(function(global){var ArrayBuffer=global.ArrayBuffer,Uint8Array=global.Uint8Array;function bufferClone(buffer){var result=new ArrayBuffer(buffer.byteLength),view=new Uint8Array(result);view.set(new Uint8Array(buffer));return result}module.exports=bufferClone}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],178:[function(require,module,exports){arguments[4][79][0].apply(exports,arguments)},{"../function/restParam":163,"./bindCallback":176,"./isIterateeCall":190,dup:79}],179:[function(require,module,exports){arguments[4][80][0].apply(exports,arguments)},{"./getLength":182,"./isLength":191,"./toObject":194,dup:80}],180:[function(require,module,exports){arguments[4][81][0].apply(exports,arguments)},{"./toObject":194,dup:81}],181:[function(require,module,exports){arguments[4][88][0].apply(exports,arguments)},{"../lang/isArray":198,"./bindCallback":176,dup:88}],182:[function(require,module,exports){arguments[4][98][0].apply(exports,arguments)},{"./baseProperty":175,dup:98}],183:[function(require,module,exports){arguments[4][100][0].apply(exports,arguments)},{"../lang/isNative":200,dup:100}],184:[function(require,module,exports){var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function initCloneArray(array){var length=array.length,result=new array.constructor(length);if(length&&typeof array[0]=="string"&&hasOwnProperty.call(array,"index")){result.index=array.index;result.input=array.input}return result}module.exports=initCloneArray},{}],185:[function(require,module,exports){(function(global){var bufferClone=require("./bufferClone");var boolTag="[object Boolean]",dateTag="[object Date]",numberTag="[object Number]",regexpTag="[object RegExp]",stringTag="[object String]";var arrayBufferTag="[object ArrayBuffer]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]";var reFlags=/\w*$/;var Uint8Array=global.Uint8Array;var ctorByTag={};ctorByTag[float32Tag]=global.Float32Array;ctorByTag[float64Tag]=global.Float64Array;ctorByTag[int8Tag]=global.Int8Array;ctorByTag[int16Tag]=global.Int16Array;ctorByTag[int32Tag]=global.Int32Array;ctorByTag[uint8Tag]=Uint8Array;ctorByTag[uint8ClampedTag]=global.Uint8ClampedArray;ctorByTag[uint16Tag]=global.Uint16Array;ctorByTag[uint32Tag]=global.Uint32Array;function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return bufferClone(object);case boolTag:case dateTag:return new Ctor(+object);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:if(Ctor instanceof Ctor){Ctor=ctorByTag[tag]}var buffer=object.buffer;return new Ctor(isDeep?bufferClone(buffer):buffer,object.byteOffset,object.length);case numberTag:case stringTag:return new Ctor(object);case regexpTag:var result=new Ctor(object.source,reFlags.exec(object));result.lastIndex=object.lastIndex}return result}module.exports=initCloneByTag}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./bufferClone":177}],186:[function(require,module,exports){function initCloneObject(object){var Ctor=object.constructor;if(!(typeof Ctor=="function"&&Ctor instanceof Ctor)){Ctor=Object}return new Ctor}module.exports=initCloneObject},{}],187:[function(require,module,exports){arguments[4][102][0].apply(exports,arguments)},{"./getLength":182,"./isLength":191,dup:102}],188:[function(require,module,exports){var isHostObject=function(){try{Object({toString:0}+"")}catch(e){return function(){return false}}return function(value){return typeof value.toString!="function"&&typeof(value+"")=="string"}}();module.exports=isHostObject},{}],189:[function(require,module,exports){arguments[4][103][0].apply(exports,arguments)},{dup:103}],190:[function(require,module,exports){arguments[4][104][0].apply(exports,arguments)},{"../lang/isObject":201,"./isArrayLike":187,"./isIndex":189,dup:104}],191:[function(require,module,exports){arguments[4][107][0].apply(exports,arguments)},{dup:107}],192:[function(require,module,exports){arguments[4][108][0].apply(exports,arguments)},{dup:108}],193:[function(require,module,exports){var isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isIndex=require("./isIndex"),isLength=require("./isLength"),isString=require("../lang/isString"),keysIn=require("../object/keysIn");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;function shimKeys(object){var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length;var allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object)||isString(object));var index=-1,result=[];while(++index<propsLength){var key=props[index];if(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key)){result.push(key)}}return result}module.exports=shimKeys},{"../lang/isArguments":197,"../lang/isArray":198,"../lang/isString":203,"../object/keysIn":207,"./isIndex":189,"./isLength":191}],194:[function(require,module,exports){var isObject=require("../lang/isObject"),isString=require("../lang/isString"),support=require("../support");function toObject(value){if(support.unindexedChars&&isString(value)){var index=-1,length=value.length,result=Object(value);while(++index<length){result[index]=value.charAt(index)}return result}return isObject(value)?value:Object(value)}module.exports=toObject},{"../lang/isObject":201,"../lang/isString":203,"../support":209}],195:[function(require,module,exports){var baseClone=require("../internal/baseClone"),bindCallback=require("../internal/bindCallback"),isIterateeCall=require("../internal/isIterateeCall");function clone(value,isDeep,customizer,thisArg){if(isDeep&&typeof isDeep!="boolean"&&isIterateeCall(value,isDeep,customizer)){isDeep=false}else if(typeof isDeep=="function"){thisArg=customizer;customizer=isDeep;isDeep=false}return typeof customizer=="function"?baseClone(value,isDeep,bindCallback(customizer,thisArg,1)):baseClone(value,isDeep)}module.exports=clone},{"../internal/baseClone":167,"../internal/bindCallback":176,"../internal/isIterateeCall":190}],196:[function(require,module,exports){var baseClone=require("../internal/baseClone"),bindCallback=require("../internal/bindCallback");function cloneDeep(value,customizer,thisArg){return typeof customizer=="function"?baseClone(value,true,bindCallback(customizer,thisArg,1)):baseClone(value,true)}module.exports=cloneDeep},{"../internal/baseClone":167,"../internal/bindCallback":176}],197:[function(require,module,exports){arguments[4][126][0].apply(exports,arguments)},{"../internal/isArrayLike":187,"../internal/isObjectLike":192,dup:126}],198:[function(require,module,exports){arguments[4][127][0].apply(exports,arguments)},{"../internal/getNative":183,"../internal/isLength":191,"../internal/isObjectLike":192,dup:127}],199:[function(require,module,exports){arguments[4][129][0].apply(exports,arguments)},{"./isObject":201,dup:129}],200:[function(require,module,exports){var isFunction=require("./isFunction"),isHostObject=require("../internal/isHostObject"),isObjectLike=require("../internal/isObjectLike");var reIsHostCtor=/^\[object .+?Constructor\]$/;var objectProto=Object.prototype;var fnToString=Function.prototype.toString;var hasOwnProperty=objectProto.hasOwnProperty;var reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function isNative(value){if(value==null){return false}if(isFunction(value)){return reIsNative.test(fnToString.call(value))}return isObjectLike(value)&&(isHostObject(value)?reIsNative:reIsHostCtor).test(value)}module.exports=isNative},{"../internal/isHostObject":188,"../internal/isObjectLike":192,"./isFunction":199}],201:[function(require,module,exports){arguments[4][131][0].apply(exports,arguments)},{dup:131}],202:[function(require,module,exports){var baseForIn=require("../internal/baseForIn"),isArguments=require("./isArguments"),isHostObject=require("../internal/isHostObject"),isObjectLike=require("../internal/isObjectLike"),support=require("../support");var objectTag="[object Object]";var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;function isPlainObject(value){var Ctor;if(!(isObjectLike(value)&&objToString.call(value)==objectTag&&!isHostObject(value)&&!isArguments(value))||!hasOwnProperty.call(value,"constructor")&&(Ctor=value.constructor,typeof Ctor=="function"&&!(Ctor instanceof Ctor))){return false}var result;if(support.ownLast){baseForIn(value,function(subValue,key,object){result=hasOwnProperty.call(object,key);return false});return result!==false}baseForIn(value,function(subValue,key){result=key});return result===undefined||hasOwnProperty.call(value,result)}module.exports=isPlainObject},{"../internal/baseForIn":171,"../internal/isHostObject":188,"../internal/isObjectLike":192,"../support":209,"./isArguments":197}],203:[function(require,module,exports){arguments[4][133][0].apply(exports,arguments)},{"../internal/isObjectLike":192,dup:133}],204:[function(require,module,exports){arguments[4][134][0].apply(exports,arguments)},{"../internal/isLength":191,"../internal/isObjectLike":192,dup:134}],205:[function(require,module,exports){arguments[4][136][0].apply(exports,arguments)},{"../internal/baseCopy":168,"../object/keysIn":207,dup:136}],206:[function(require,module,exports){var getNative=require("../internal/getNative"),isArrayLike=require("../internal/isArrayLike"),isObject=require("../lang/isObject"),shimKeys=require("../internal/shimKeys"),support=require("../support");var nativeKeys=getNative(Object,"keys");var keys=!nativeKeys?shimKeys:function(object){var Ctor=object==null?undefined:object.constructor;if(typeof Ctor=="function"&&Ctor.prototype===object||(typeof object=="function"?support.enumPrototypes:isArrayLike(object))){return shimKeys(object)}return isObject(object)?nativeKeys(object):[]};module.exports=keys},{"../internal/getNative":183,"../internal/isArrayLike":187,"../internal/shimKeys":193,"../lang/isObject":201,"../support":209}],207:[function(require,module,exports){var arrayEach=require("../internal/arrayEach"),isArguments=require("../lang/isArguments"),isArray=require("../lang/isArray"),isFunction=require("../lang/isFunction"),isIndex=require("../internal/isIndex"),isLength=require("../internal/isLength"),isObject=require("../lang/isObject"),isString=require("../lang/isString"),support=require("../support");var arrayTag="[object Array]",boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",funcTag="[object Function]",numberTag="[object Number]",objectTag="[object Object]",regexpTag="[object RegExp]",stringTag="[object String]";var shadowProps=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"];var errorProto=Error.prototype,objectProto=Object.prototype,stringProto=String.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var objToString=objectProto.toString;var nonEnumProps={};nonEnumProps[arrayTag]=nonEnumProps[dateTag]=nonEnumProps[numberTag]={constructor:true,toLocaleString:true,toString:true,valueOf:true};nonEnumProps[boolTag]=nonEnumProps[stringTag]={constructor:true,toString:true,valueOf:true};nonEnumProps[errorTag]=nonEnumProps[funcTag]=nonEnumProps[regexpTag]={constructor:true,toString:true};nonEnumProps[objectTag]={constructor:true};arrayEach(shadowProps,function(key){for(var tag in nonEnumProps){if(hasOwnProperty.call(nonEnumProps,tag)){var props=nonEnumProps[tag];props[key]=hasOwnProperty.call(props,key)}}});function keysIn(object){if(object==null){return[]}if(!isObject(object)){object=Object(object)}var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object)||isString(object))&&length||0;var Ctor=object.constructor,index=-1,proto=isFunction(Ctor)&&Ctor.prototype||objectProto,isProto=proto===object,result=Array(length),skipIndexes=length>0,skipErrorProps=support.enumErrorProps&&(object===errorProto||object instanceof Error),skipProto=support.enumPrototypes&&isFunction(object);while(++index<length){result[index]=index+""}for(var key in object){if(!(skipProto&&key=="prototype")&&!(skipErrorProps&&(key=="message"||key=="name"))&&!(skipIndexes&&isIndex(key,length))&&!(key=="constructor"&&(isProto||!hasOwnProperty.call(object,key)))){
8
+ result.push(key)}}if(support.nonEnumShadows&&object!==objectProto){var tag=object===stringProto?stringTag:object===errorProto?errorTag:objToString.call(object),nonEnums=nonEnumProps[tag]||nonEnumProps[objectTag];if(tag==objectTag){proto=objectProto}length=shadowProps.length;while(length--){key=shadowProps[length];var nonEnum=nonEnums[key];if(!(isProto&&nonEnum)&&(nonEnum?hasOwnProperty.call(object,key):object[key]!==proto[key])){result.push(key)}}}return result}module.exports=keysIn},{"../internal/arrayEach":165,"../internal/isIndex":189,"../internal/isLength":191,"../lang/isArguments":197,"../lang/isArray":198,"../lang/isFunction":199,"../lang/isObject":201,"../lang/isString":203,"../support":209}],208:[function(require,module,exports){arguments[4][142][0].apply(exports,arguments)},{"../internal/baseMerge":173,"../internal/createAssigner":178,dup:142}],209:[function(require,module,exports){var arrayProto=Array.prototype,errorProto=Error.prototype,objectProto=Object.prototype;var propertyIsEnumerable=objectProto.propertyIsEnumerable,splice=arrayProto.splice;var support={};(function(x){var Ctor=function(){this.x=x},object={0:x,length:x},props=[];Ctor.prototype={valueOf:x,y:x};for(var key in new Ctor){props.push(key)}support.enumErrorProps=propertyIsEnumerable.call(errorProto,"message")||propertyIsEnumerable.call(errorProto,"name");support.enumPrototypes=propertyIsEnumerable.call(Ctor,"prototype");support.nonEnumShadows=!/valueOf/.test(props);support.ownLast=props[0]!="x";support.spliceObjects=(splice.call(object,0,1),!object[0]);support.unindexedChars="x"[0]+Object("x")[0]!="xx"})(1,0);module.exports=support},{}],210:[function(require,module,exports){arguments[4][148][0].apply(exports,arguments)},{dup:148}],211:[function(require,module,exports){(function(process){"use strict";module.exports=AlgoliaSearch;if(process.env.APP_ENV==="development"){require("debug").enable("algoliasearch*")}var errors=require("./errors");function AlgoliaSearch(applicationID,apiKey,opts){var debug=require("debug")("algoliasearch");var clone=require("lodash-compat/lang/clone");var isArray=require("lodash-compat/lang/isArray");var usage="Usage: algoliasearch(applicationID, apiKey, opts)";if(!applicationID){throw new errors.AlgoliaSearchError("Please provide an application ID. "+usage)}if(!apiKey){throw new errors.AlgoliaSearchError("Please provide an API key. "+usage)}this.applicationID=applicationID;this.apiKey=apiKey;var defaultHosts=[this.applicationID+"-1.algolianet.com",this.applicationID+"-2.algolianet.com",this.applicationID+"-3.algolianet.com"];this.hosts={read:[],write:[]};this.hostIndex={read:0,write:0};opts=opts||{};var protocol=opts.protocol||"https:";var timeout=opts.timeout===undefined?2e3:opts.timeout;if(!/:$/.test(protocol)){protocol=protocol+":"}if(opts.protocol!=="http:"&&opts.protocol!=="https:"){throw new errors.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+opts.protocol+"`)")}if(!opts.hosts){this.hosts.read=[this.applicationID+"-dsn.algolia.net"].concat(defaultHosts);this.hosts.write=[this.applicationID+".algolia.net"].concat(defaultHosts)}else if(isArray(opts.hosts)){this.hosts.read=clone(opts.hosts);this.hosts.write=clone(opts.hosts)}else{this.hosts.read=clone(opts.hosts.read);this.hosts.write=clone(opts.hosts.write)}this.hosts.read=map(this.hosts.read,prepareHost(protocol));this.hosts.write=map(this.hosts.write,prepareHost(protocol));this.requestTimeout=timeout;this.extraHeaders=[];this.cache={};this._ua=opts._ua;this._useCache=opts._useCache===undefined?true:opts._useCache;this._setTimeout=opts._setTimeout;debug("init done, %j",this)}AlgoliaSearch.prototype={deleteIndex:function(indexName,callback){return this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(indexName),hostType:"write",callback:callback})},moveIndex:function(srcIndexName,dstIndexName,callback){var postObj={operation:"move",destination:dstIndexName};return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(srcIndexName)+"/operation",body:postObj,hostType:"write",callback:callback})},copyIndex:function(srcIndexName,dstIndexName,callback){var postObj={operation:"copy",destination:dstIndexName};return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(srcIndexName)+"/operation",body:postObj,hostType:"write",callback:callback})},getLogs:function(offset,length,callback){if(arguments.length===0||typeof offset==="function"){callback=offset;offset=0;length=10}else if(arguments.length===1||typeof length==="function"){callback=length;length=10}return this._jsonRequest({method:"GET",url:"/1/logs?offset="+offset+"&length="+length,hostType:"read",callback:callback})},listIndexes:function(page,callback){var params="";if(page===undefined||typeof page==="function"){callback=page}else{params="?page="+page}return this._jsonRequest({method:"GET",url:"/1/indexes"+params,hostType:"read",callback:callback})},initIndex:function(indexName){return new this.Index(this,indexName)},listUserKeys:function(callback){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:callback})},getUserKeyACL:function(key,callback){return this._jsonRequest({method:"GET",url:"/1/keys/"+key,hostType:"read",callback:callback})},deleteUserKey:function(key,callback){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+key,hostType:"write",callback:callback})},addUserKey:function(acls,params,callback){if(arguments.length===1||typeof params==="function"){callback=params;params=null}var postObj={acl:acls};if(params){postObj.validity=params.validity;postObj.maxQueriesPerIPPerHour=params.maxQueriesPerIPPerHour;postObj.maxHitsPerQuery=params.maxHitsPerQuery;postObj.indexes=params.indexes;postObj.description=params.description;if(params.queryParameters){postObj.queryParameters=this._getSearchParams(params.queryParameters,"")}postObj.referers=params.referers}return this._jsonRequest({method:"POST",url:"/1/keys",body:postObj,hostType:"write",callback:callback})},addUserKeyWithValidity:deprecate(function(acls,params,callback){return this.addUserKey(acls,params,callback)},deprecatedMessage("client.addUserKeyWithValidity()","client.addUserKey()")),updateUserKey:function(key,acls,params,callback){if(arguments.length===2||typeof params==="function"){callback=params;params=null}var putObj={acl:acls};if(params){putObj.validity=params.validity;putObj.maxQueriesPerIPPerHour=params.maxQueriesPerIPPerHour;putObj.maxHitsPerQuery=params.maxHitsPerQuery;putObj.indexes=params.indexes;putObj.description=params.description;if(params.queryParameters){putObj.queryParameters=this._getSearchParams(params.queryParameters,"")}putObj.referers=params.referers}return this._jsonRequest({method:"PUT",url:"/1/keys/"+key,body:putObj,hostType:"write",callback:callback})},setSecurityTags:function(tags){if(Object.prototype.toString.call(tags)==="[object Array]"){var strTags=[];for(var i=0;i<tags.length;++i){if(Object.prototype.toString.call(tags[i])==="[object Array]"){var oredTags=[];for(var j=0;j<tags[i].length;++j){oredTags.push(tags[i][j])}strTags.push("("+oredTags.join(",")+")")}else{strTags.push(tags[i])}}tags=strTags.join(",")}this.securityTags=tags},setUserToken:function(userToken){this.userToken=userToken},startQueriesBatch:deprecate(function startQueriesBatchDeprecated(){this._batch=[]},deprecatedMessage("client.startQueriesBatch()","client.search()")),addQueryInBatch:deprecate(function addQueryInBatchDeprecated(indexName,query,args){this._batch.push({indexName:indexName,query:query,params:args})},deprecatedMessage("client.addQueryInBatch()","client.search()")),clearCache:function(){this.cache={}},sendQueriesBatch:deprecate(function sendQueriesBatchDeprecated(callback){return this.search(this._batch,callback)},deprecatedMessage("client.sendQueriesBatch()","client.search()")),setRequestTimeout:function(milliseconds){if(milliseconds){this.requestTimeout=parseInt(milliseconds,10)}},search:function(queries,callback){var client=this;var postObj={requests:map(queries,function prepareRequest(query){var params="";if(query.query!==undefined){params+="query="+encodeURIComponent(query.query)}return{indexName:query.indexName,params:client._getSearchParams(query.params,params)}})};return this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:postObj,hostType:"read",callback:callback})},batch:function(operations,callback){return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:operations},hostType:"write",callback:callback})},destroy:notImplemented,enableRateLimitForward:notImplemented,disableRateLimitForward:notImplemented,useSecuredAPIKey:notImplemented,disableSecuredAPIKey:notImplemented,generateSecuredApiKey:notImplemented,Index:function(algoliasearch,indexName){this.indexName=indexName;this.as=algoliasearch;this.typeAheadArgs=null;this.typeAheadValueOption=null;this.cache={}},setExtraHeader:function(name,value){this.extraHeaders.push({name:name.toLowerCase(),value:value})},_sendQueriesBatch:function(params,callback){function prepareParams(){var reqParams="";for(var i=0;i<params.requests.length;++i){var q="/1/indexes/"+encodeURIComponent(params.requests[i].indexName)+"?"+params.requests[i].params;reqParams+=i+"="+encodeURIComponent(q)+"&"}return reqParams}return this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:params,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:prepareParams()}},callback:callback})},_jsonRequest:function(opts){var requestDebug=require("debug")("algoliasearch:"+opts.url);var body;var cache=opts.cache;var client=this;var tries=0;var usingFallback=false;if(opts.body!==undefined){body=safeJSONStringify(opts.body)}requestDebug("request start");function doRequest(requester,reqOpts){var cacheID;if(client._useCache){cacheID=opts.url}if(client._useCache&&body){cacheID+="_body_"+reqOpts.body}if(client._useCache&&cache&&cache[cacheID]!==undefined){requestDebug("serving response from cache");return client._promise.resolve(JSON.parse(safeJSONStringify(cache[cacheID])))}if(tries>=client.hosts[opts.hostType].length||client.useFallback&&!usingFallback){if(!opts.fallback||!client._request.fallback||usingFallback){requestDebug("could not get any response");return client._promise.reject(new errors.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API."+" Send an email to support@algolia.com to report and resolve the issue."+" Application id was: "+client.applicationID))}requestDebug("switching to fallback");tries=0;reqOpts.method=opts.fallback.method;reqOpts.url=opts.fallback.url;reqOpts.jsonBody=opts.fallback.body;if(reqOpts.jsonBody){reqOpts.body=safeJSONStringify(reqOpts.jsonBody)}reqOpts.timeout=client.requestTimeout*(tries+1);client.hostIndex[opts.hostType]=0;usingFallback=true;return doRequest(client._request.fallback,reqOpts)}var url=client.hosts[opts.hostType][client.hostIndex[opts.hostType]]+reqOpts.url;var options={body:body,jsonBody:opts.body,method:reqOpts.method,headers:client._computeRequestHeaders(),timeout:reqOpts.timeout,debug:requestDebug};requestDebug("method: %s, url: %s, headers: %j, timeout: %d",options.method,url,options.headers,options.timeout);if(requester===client._request.fallback){requestDebug("using fallback")}return requester.call(client,url,options).then(success,tryFallback);function success(httpResponse){var status=httpResponse&&httpResponse.body&&httpResponse.body.message&&httpResponse.body.status||httpResponse.statusCode||httpResponse&&httpResponse.body&&200;requestDebug("received response: statusCode: %s, computed statusCode: %d, headers: %j",httpResponse.statusCode,status,httpResponse.headers);if(process.env.DEBUG&&process.env.DEBUG.indexOf("debugBody")!==-1){requestDebug("body: %j",httpResponse.body)}var ok=status===200||status===201;var retry=!ok&&Math.floor(status/100)!==4&&Math.floor(status/100)!==1;if(client._useCache&&ok&&cache){cache[cacheID]=httpResponse.body}if(ok){return httpResponse.body}if(retry){tries+=1;return retryRequest()}var unrecoverableError=new errors.AlgoliaSearchError(httpResponse.body&&httpResponse.body.message);return client._promise.reject(unrecoverableError)}function tryFallback(err){requestDebug("error: %s, stack: %s",err.message,err.stack);if(!(err instanceof errors.AlgoliaSearchError)){err=new errors.Unknown(err&&err.message,err)}tries+=1;if(err instanceof errors.Unknown||err instanceof errors.UnparsableJSON||!requester.fallback&&err instanceof errors.Network||tries>=client.hosts[opts.hostType].length&&(usingFallback||!opts.fallback||!client._request.fallback)){return client._promise.reject(err)}client.hostIndex[opts.hostType]=++client.hostIndex[opts.hostType]%client.hosts[opts.hostType].length;if(err instanceof errors.RequestTimeout){return retryRequest()}else if(client._request.fallback&&!client.useFallback){client.useFallback=true}return doRequest(requester,reqOpts)}function retryRequest(){client.hostIndex[opts.hostType]=++client.hostIndex[opts.hostType]%client.hosts[opts.hostType].length;reqOpts.timeout=client.requestTimeout*(tries+1);return doRequest(requester,reqOpts)}}var useFallback=client.useFallback&&opts.fallback;var requestOptions=useFallback?opts.fallback:opts;var promise=doRequest(useFallback?client._request.fallback:client._request,{url:requestOptions.url,method:requestOptions.method,body:body,jsonBody:opts.body,timeout:client.requestTimeout*(tries+1)});if(opts.callback){promise.then(function okCb(content){exitPromise(function(){opts.callback(null,content)},client._setTimeout||setTimeout)},function nookCb(err){exitPromise(function(){opts.callback(err)},client._setTimeout||setTimeout)})}else{return promise}},_getSearchParams:function(args,params){if(this._isUndefined(args)||args===null){return params}for(var key in args){if(key!==null&&args[key]!==undefined&&args.hasOwnProperty(key)){params+=params===""?"":"&";params+=key+"="+encodeURIComponent(Object.prototype.toString.call(args[key])==="[object Array]"?safeJSONStringify(args[key]):args[key])}}return params},_isUndefined:function(obj){return obj===void 0},_computeRequestHeaders:function(){var forEach=require("lodash-compat/collection/forEach");var requestHeaders={"x-algolia-api-key":this.apiKey,"x-algolia-application-id":this.applicationID,"x-algolia-agent":this._ua};if(this.userToken){requestHeaders["x-algolia-usertoken"]=this.userToken}if(this.securityTags){requestHeaders["x-algolia-tagfilters"]=this.securityTags}if(this.extraHeaders){forEach(this.extraHeaders,function addToRequestHeaders(header){requestHeaders[header.name]=header.value})}return requestHeaders}};AlgoliaSearch.prototype.Index.prototype={clearCache:function(){this.cache={}},addObject:function(content,objectID,callback){var indexObj=this;if(arguments.length===1||typeof objectID==="function"){callback=objectID;objectID=undefined}return this.as._jsonRequest({method:objectID!==undefined?"PUT":"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+(objectID!==undefined?"/"+encodeURIComponent(objectID):""),body:content,hostType:"write",callback:callback})},addObjects:function(objects,callback){var indexObj=this;var postObj={requests:[]};for(var i=0;i<objects.length;++i){var request={action:"addObject",body:objects[i]};postObj.requests.push(request)}return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/batch",body:postObj,hostType:"write",callback:callback})},getObject:function(objectID,attrs,callback){var indexObj=this;if(arguments.length===1||typeof attrs==="function"){callback=attrs;attrs=undefined}var params="";if(attrs!==undefined){params="?attributes=";for(var i=0;i<attrs.length;++i){if(i!==0){params+=","}params+=attrs[i]}}return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/"+encodeURIComponent(objectID)+params,hostType:"read",callback:callback})},getObjects:function(objectIDs,attributesToRetrieve,callback){var indexObj=this;if(arguments.length===1||typeof attributesToRetrieve==="function"){callback=attributesToRetrieve;attributesToRetrieve=undefined}var body={requests:map(objectIDs,function prepareRequest(objectID){var request={indexName:indexObj.indexName,objectID:objectID};if(attributesToRetrieve){request.attributesToRetrieve=attributesToRetrieve.join(",")}return request})};return this.as._jsonRequest({method:"POST",url:"/1/indexes/*/objects",hostType:"read",body:body,callback:callback})},partialUpdateObject:function(partialObject,callback){var indexObj=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/"+encodeURIComponent(partialObject.objectID)+"/partial",body:partialObject,hostType:"write",callback:callback})},partialUpdateObjects:function(objects,callback){var indexObj=this;var postObj={requests:[]};for(var i=0;i<objects.length;++i){var request={action:"partialUpdateObject",objectID:objects[i].objectID,body:objects[i]};postObj.requests.push(request)}return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/batch",body:postObj,hostType:"write",callback:callback})},saveObject:function(object,callback){var indexObj=this;return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/"+encodeURIComponent(object.objectID),body:object,hostType:"write",callback:callback})},saveObjects:function(objects,callback){var indexObj=this;var postObj={requests:[]};for(var i=0;i<objects.length;++i){var request={action:"updateObject",objectID:objects[i].objectID,body:objects[i]};postObj.requests.push(request)}return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/batch",body:postObj,hostType:"write",callback:callback})},deleteObject:function(objectID,callback){if(typeof objectID==="function"||typeof objectID!=="string"&&typeof objectID!=="number"){var err=new errors.AlgoliaSearchError("Cannot delete an object without an objectID");callback=objectID;if(typeof callback==="function"){return callback(err)}return this.as._promise.reject(err)}var indexObj=this;return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/"+encodeURIComponent(objectID),hostType:"write",callback:callback})},deleteObjects:function(objectIDs,callback){var indexObj=this;var postObj={requests:map(objectIDs,function prepareRequest(objectID){return{action:"deleteObject",objectID:objectID,body:{objectID:objectID}}})};return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/batch",body:postObj,hostType:"write",callback:callback})},deleteByQuery:function(query,params,callback){var indexObj=this;var client=indexObj.as;if(arguments.length===1||typeof params==="function"){callback=params;params={}}params.attributesToRetrieve="objectID";params.hitsPerPage=1e3;this.clearCache();var promise=this.search(query,params).then(stopOrDelete);function stopOrDelete(searchContent){if(searchContent.nbHits===0){return searchContent}var objectIDs=map(searchContent.hits,function getObjectID(object){return object.objectID});return indexObj.deleteObjects(objectIDs).then(waitTask).then(doDeleteByQuery)}function waitTask(deleteObjectsContent){return indexObj.waitTask(deleteObjectsContent.taskID)}function doDeleteByQuery(){return indexObj.deleteByQuery(query,params)}if(!callback){return promise}promise.then(success,failure);function success(){exitPromise(function exit(){callback(null)},client._setTimeout||setTimeout)}function failure(err){exitPromise(function exit(){callback(err)},client._setTimeout||setTimeout)}},search:function(query,args,callback){if(typeof query==="function"&&typeof args==="object"||typeof callback==="object"){throw new errors.AlgoliaSearchError("index.search usage is index.search(query, params, cb)")}if(arguments.length===0||typeof query==="function"){callback=query;query=""}else if(arguments.length===1||typeof args==="function"){callback=args;args=undefined}if(typeof query==="object"&&query!==null){args=query;query=undefined}else if(query===undefined||query===null){query=""}var params="";if(query!==undefined){params+="query="+encodeURIComponent(query)}if(args!==undefined){params=this.as._getSearchParams(args,params)}return this._search(params,callback)},browse:function(query,queryParameters,callback){var merge=require("lodash-compat/object/merge");var indexObj=this;var page;var hitsPerPage;if(arguments.length===0||arguments.length===1&&typeof arguments[0]==="function"){page=0;callback=arguments[0];query=undefined}else if(typeof arguments[0]==="number"){page=arguments[0];if(typeof arguments[1]==="number"){hitsPerPage=arguments[1]}else if(typeof arguments[1]==="function"){callback=arguments[1];hitsPerPage=undefined}query=undefined;queryParameters=undefined}else if(typeof arguments[0]==="object"){if(typeof arguments[1]==="function"){callback=arguments[1]}queryParameters=arguments[0];query=undefined}else if(typeof arguments[0]==="string"&&typeof arguments[1]==="function"){callback=arguments[1];queryParameters=undefined}queryParameters=merge({},queryParameters||{},{page:page,hitsPerPage:hitsPerPage,query:query});var params=this.as._getSearchParams(queryParameters,"");return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/browse?"+params,hostType:"read",callback:callback})},browseFrom:function(cursor,callback){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/browse?cursor="+cursor,hostType:"read",callback:callback})},browseAll:function(query,queryParameters){if(typeof query==="object"){queryParameters=query;query=undefined}var merge=require("lodash-compat/object/merge");var IndexBrowser=require("./IndexBrowser");var browser=new IndexBrowser;var client=this.as;var index=this;var params=client._getSearchParams(merge({},queryParameters||{},{query:query}),"");browseLoop();function browseLoop(cursor){if(browser._stopped){return}var queryString;if(cursor!==undefined){queryString="cursor="+encodeURIComponent(cursor)}else{queryString=params}client._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(index.indexName)+"/browse?"+queryString,hostType:"read",callback:browseCallback})}function browseCallback(err,content){if(browser._stopped){return}if(err){browser._error(err);return}browser._result(content);if(content.cursor===undefined){browser._end();return}browseLoop(content.cursor)}return browser},ttAdapter:function(params){var self=this;return function ttAdapter(query,syncCb,asyncCb){var cb;if(typeof asyncCb==="function"){cb=asyncCb}else{cb=syncCb}self.search(query,params,function searchDone(err,content){if(err){cb(err);return}cb(content.hits)})}},waitTask:function(taskID,callback){var baseDelay=100;var maxDelay=5e3;var loop=0;var indexObj=this;var client=indexObj.as;var promise=retryLoop();function retryLoop(){return client._jsonRequest({method:"GET",hostType:"read",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/task/"+taskID}).then(function success(content){loop++;var delay=baseDelay*loop*loop;if(delay>maxDelay){delay=maxDelay}if(content.status!=="published"){return client._promise.delay(delay).then(retryLoop)}return content})}if(!callback){return promise}promise.then(successCb,failureCb);function successCb(content){exitPromise(function exit(){callback(null,content)},client._setTimeout||setTimeout)}function failureCb(err){exitPromise(function exit(){callback(err)},client._setTimeout||setTimeout)}},clearIndex:function(callback){var indexObj=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/clear",hostType:"write",callback:callback})},getSettings:function(callback){var indexObj=this;return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/settings",hostType:"read",callback:callback})},setSettings:function(settings,callback){var indexObj=this;return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/settings",hostType:"write",body:settings,callback:callback})},listUserKeys:function(callback){var indexObj=this;return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/keys",hostType:"read",callback:callback})},getUserKeyACL:function(key,callback){var indexObj=this;return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/keys/"+key,hostType:"read",callback:callback})},deleteUserKey:function(key,callback){var indexObj=this;return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(indexObj.indexName)+"/keys/"+key,hostType:"write",callback:callback})},addUserKey:function(acls,params,callback){if(arguments.length===1||typeof params==="function"){callback=params;params=null}var postObj={acl:acls};if(params){postObj.validity=params.validity;postObj.maxQueriesPerIPPerHour=params.maxQueriesPerIPPerHour;postObj.maxHitsPerQuery=params.maxHitsPerQuery;postObj.description=params.description;if(params.queryParameters){postObj.queryParameters=this.as._getSearchParams(params.queryParameters,"")}postObj.referers=params.referers}return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys",body:postObj,hostType:"write",callback:callback})},addUserKeyWithValidity:deprecate(function deprecatedAddUserKeyWithValidity(acls,params,callback){return this.addUserKey(acls,params,callback)},deprecatedMessage("index.addUserKeyWithValidity()","index.addUserKey()")),updateUserKey:function(key,acls,params,callback){if(arguments.length===2||typeof params==="function"){callback=params;params=null}var putObj={acl:acls};if(params){putObj.validity=params.validity;putObj.maxQueriesPerIPPerHour=params.maxQueriesPerIPPerHour;putObj.maxHitsPerQuery=params.maxHitsPerQuery;putObj.description=params.description;if(params.queryParameters){putObj.queryParameters=this.as._getSearchParams(params.queryParameters,"")}putObj.referers=params.referers}return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/keys/"+key,body:putObj,hostType:"write",callback:callback})},_search:function(params,callback){return this.as._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:{params:params},hostType:"read",fallback:{method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName),body:{params:params}},callback:callback})},as:null,indexName:null,typeAheadArgs:null,typeAheadValueOption:null};function map(arr,fn){var ret=[];for(var i=0;i<arr.length;++i){ret.push(fn(arr[i],i))}return ret}function prepareHost(protocol){return function prepare(host){return protocol+"//"+host.toLowerCase()}}function notImplemented(){var message="Not implemented in this environment.\n"+"If you feel this is a mistake, write to support@algolia.com";throw new errors.AlgoliaSearchError(message)}function deprecatedMessage(previousUsage,newUsage){var githubAnchorLink=previousUsage.toLowerCase().replace(".","").replace("()","");return"algoliasearch: `"+previousUsage+"` was replaced by `"+newUsage+"`. Please see https://github.com/algolia/algoliasearch-client-js/wiki/Deprecated#"+githubAnchorLink}function exitPromise(fn,_setTimeout){_setTimeout(fn,0)}function deprecate(fn,message){var warned=false;function deprecated(){if(!warned){console.log(message);warned=true}return fn.apply(this,arguments)}return deprecated}function safeJSONStringify(obj){if(Array.prototype.toJSON===undefined){return JSON.stringify(obj)}var toJSON=Array.prototype.toJSON;delete Array.prototype.toJSON;var out=JSON.stringify(obj);Array.prototype.toJSON=toJSON;return out}}).call(this,require("_process"))},{"./IndexBrowser":212,"./errors":217,_process:221,debug:157,"lodash-compat/collection/forEach":162,"lodash-compat/lang/clone":195,"lodash-compat/lang/isArray":198,"lodash-compat/object/merge":208}],212:[function(require,module,exports){"use strict";module.exports=IndexBrowser;var inherits=require("inherits");var EventEmitter=require("events").EventEmitter;function IndexBrowser(){}inherits(IndexBrowser,EventEmitter);IndexBrowser.prototype.stop=function(){this._stopped=true;this._clean()};IndexBrowser.prototype._end=function(){this.emit("end");this._clean()};IndexBrowser.prototype._error=function(err){this.emit("error",err);this._clean()};IndexBrowser.prototype._result=function(content){this.emit("result",content)};IndexBrowser.prototype._clean=function(){this.removeAllListeners("stop");this.removeAllListeners("end");this.removeAllListeners("error");this.removeAllListeners("result")}},{events:219,inherits:161}],213:[function(require,module,exports){"use strict";module.exports=algoliasearch;var inherits=require("inherits");var Promise=window.Promise||require("es6-promise").Promise;var AlgoliaSearch=require("../../AlgoliaSearch");var errors=require("../../errors");var inlineHeaders=require("../inline-headers");var jsonpRequest=require("../jsonp-request");function algoliasearch(applicationID,apiKey,opts){var cloneDeep=require("lodash-compat/lang/cloneDeep");var getDocumentProtocol=require("../get-document-protocol");opts=cloneDeep(opts||{});if(opts.protocol===undefined){opts.protocol=getDocumentProtocol()}opts._ua=opts._ua||algoliasearch.ua;return new AlgoliaSearchBrowser(applicationID,apiKey,opts)}algoliasearch.version=require("../../version.json");algoliasearch.ua="Algolia for vanilla JavaScript "+algoliasearch.version;window.__algolia={debug:require("debug"),algoliasearch:algoliasearch};var support={hasXMLHttpRequest:"XMLHttpRequest"in window,hasXDomainRequest:"XDomainRequest"in window,cors:"withCredentials"in new XMLHttpRequest,timeout:"timeout"in new XMLHttpRequest};function AlgoliaSearchBrowser(){AlgoliaSearch.apply(this,arguments)}inherits(AlgoliaSearchBrowser,AlgoliaSearch);AlgoliaSearchBrowser.prototype._request=function request(url,opts){return new Promise(function wrapRequest(resolve,reject){if(!support.cors&&!support.hasXDomainRequest){reject(new errors.Network("CORS not supported"));return}url=inlineHeaders(url,opts.headers);var body=opts.body;var req=support.cors?new XMLHttpRequest:new XDomainRequest;var ontimeout;var timedOut;if(req instanceof XMLHttpRequest){req.open(opts.method,url,true)}else{req.open(opts.method,url)}if(support.cors){if(body){if(opts.method==="POST"){req.setRequestHeader("content-type","application/x-www-form-urlencoded")}else{req.setRequestHeader("content-type","application/json")}}req.setRequestHeader("accept","application/json")}req.onprogress=function noop(){};req.onload=load;req.onerror=error;if(support.timeout){req.timeout=opts.timeout;req.ontimeout=timeout}else{ontimeout=setTimeout(timeout,opts.timeout)}req.send(body);function load(){if(timedOut){return}if(!support.timeout){clearTimeout(ontimeout)}var out;try{out={body:JSON.parse(req.responseText),statusCode:req.status,headers:req.getAllResponseHeaders&&req.getAllResponseHeaders()||{}}}catch(e){out=new errors.UnparsableJSON({more:req.responseText})}if(out instanceof errors.UnparsableJSON){reject(out)}else{resolve(out)}}function error(event){if(timedOut){return}if(!support.timeout){clearTimeout(ontimeout)}reject(new errors.Network({more:event}))}function timeout(){if(!support.timeout){timedOut=true;req.abort()}reject(new errors.RequestTimeout)}})};AlgoliaSearchBrowser.prototype._request.fallback=function requestFallback(url,opts){url=inlineHeaders(url,opts.headers);return new Promise(function wrapJsonpRequest(resolve,reject){jsonpRequest(url,opts,function jsonpRequestDone(err,content){if(err){reject(err);return}resolve(content)})})};AlgoliaSearchBrowser.prototype._promise={reject:function rejectPromise(val){return Promise.reject(val)},resolve:function resolvePromise(val){return Promise.resolve(val)},delay:function delayPromise(ms){return new Promise(function resolveOnTimeout(resolve){setTimeout(resolve,ms)})}}},{"../../AlgoliaSearch":211,"../../errors":217,"../../version.json":218,"../get-document-protocol":214,"../inline-headers":215,
9
+ "../jsonp-request":216,debug:157,"es6-promise":160,inherits:161,"lodash-compat/lang/cloneDeep":196}],214:[function(require,module,exports){"use strict";module.exports=getDocumentProtocol;function getDocumentProtocol(){var protocol=window.document.location.protocol;if(protocol!=="http:"&&protocol!=="https:"){protocol="http:"}return protocol}},{}],215:[function(require,module,exports){"use strict";module.exports=inlineHeaders;var querystring=require("querystring");function inlineHeaders(url,headers){if(/\?/.test(url)){url+="&"}else{url+="?"}return url+querystring.encode(headers)}},{querystring:224}],216:[function(require,module,exports){"use strict";module.exports=jsonpRequest;var errors=require("../errors");var JSONPCounter=0;function jsonpRequest(url,opts,cb){if(opts.method!=="GET"){cb(new Error("Method "+opts.method+" "+url+" is not supported by JSONP."));return}opts.debug("JSONP: start");var cbCalled=false;var timedOut=false;JSONPCounter+=1;var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");var cbName="algoliaJSONP_"+JSONPCounter;var done=false;window[cbName]=function(data){try{delete window[cbName]}catch(e){window[cbName]=undefined}if(timedOut){return}cbCalled=true;clean();cb(null,{body:data})};url+="&callback="+cbName;if(opts.jsonBody&&opts.jsonBody.params){url+="&"+opts.jsonBody.params}var ontimeout=setTimeout(timeout,opts.timeout);script.onreadystatechange=readystatechange;script.onload=success;script.onerror=error;script.async=true;script.defer=true;script.src=url;head.appendChild(script);function success(){opts.debug("JSONP: success");if(done||timedOut){return}done=true;if(!cbCalled){opts.debug("JSONP: Fail. Script loaded but did not call the callback");clean();cb(new errors.JSONPScriptFail)}}function readystatechange(){if(this.readyState==="loaded"||this.readyState==="complete"){success()}}function clean(){clearTimeout(ontimeout);script.onload=null;script.onreadystatechange=null;script.onerror=null;head.removeChild(script);try{delete window[cbName];delete window[cbName+"_loaded"]}catch(e){window[cbName]=null;window[cbName+"_loaded"]=null}}function timeout(){opts.debug("JSONP: Script timeout");timedOut=true;clean();cb(new errors.RequestTimeout)}function error(){opts.debug("JSONP: Script error");if(done||timedOut){return}clean();cb(new errors.JSONPScriptError)}}},{"../errors":217}],217:[function(require,module,exports){"use strict";var inherits=require("inherits");function AlgoliaSearchError(message,extraProperties){var forEach=require("lodash-compat/collection/forEach");var error=this;if(typeof Error.captureStackTrace==="function"){Error.captureStackTrace(this,this.constructor)}else{error.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old"}this.name=this.constructor.name;this.message=message||"Unknown error";if(extraProperties){forEach(extraProperties,function addToErrorObject(value,key){error[key]=value})}}inherits(AlgoliaSearchError,Error);function createCustomError(name,message){function AlgoliaSearchCustomError(){var args=Array.prototype.slice.call(arguments,0);if(typeof args[0]!=="string"){args.unshift(message)}AlgoliaSearchError.apply(this,args);this.name="AlgoliaSearch"+name+"Error"}inherits(AlgoliaSearchCustomError,AlgoliaSearchError);return AlgoliaSearchCustomError}module.exports={AlgoliaSearchError:AlgoliaSearchError,UnparsableJSON:createCustomError("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:createCustomError("RequestTimeout","Request timedout before getting a response"),Network:createCustomError("Network","Network issue, see err.more for details"),JSONPScriptFail:createCustomError("JSONPScriptFail","<script> was loaded but did not call our provided callback"),JSONPScriptError:createCustomError("JSONPScriptError","<script> unable to load due to an `error` event on it"),Unknown:createCustomError("Unknown","Unknown error occured")}},{inherits:161,"lodash-compat/collection/forEach":162}],218:[function(require,module,exports){module.exports="3.7.5"},{}],219:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}throw TypeError('Uncaught, unspecified "error" event.')}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],220:[function(require,module,exports){arguments[4][161][0].apply(exports,arguments)},{dup:161}],221:[function(require,module,exports){var process=module.exports={};var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=setTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){currentQueue[queueIndex].run()}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;clearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){setTimeout(drainQueue,0)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],222:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&";eq=eq||"=";var obj={};if(typeof qs!=="string"||qs.length===0){return obj}var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;if(options&&typeof options.maxKeys==="number"){maxKeys=options.maxKeys}var len=qs.length;if(maxKeys>0&&len>maxKeys){len=maxKeys}for(var i=0;i<len;++i){var x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;if(idx>=0){kstr=x.substr(0,idx);vstr=x.substr(idx+1)}else{kstr=x;vstr=""}k=decodeURIComponent(kstr);v=decodeURIComponent(vstr);if(!hasOwnProperty(obj,k)){obj[k]=v}else if(isArray(obj[k])){obj[k].push(v)}else{obj[k]=[obj[k],v]}}return obj};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{}],223:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){sep=sep||"&";eq=eq||"=";if(obj===null){obj=undefined}if(typeof obj==="object"){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep)}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]))}}).join(sep)}if(!name)return"";return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj))};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i))}return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key)}return res}},{}],224:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode");exports.encode=exports.stringify=require("./encode")},{"./decode":222,"./encode":223}],225:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],226:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":225,_process:221,inherits:220}],227:[function(require,module,exports){(function(Hogan){var rIsWhitespace=/\S/,rQuot=/\"/g,rNewline=/\n/g,rCr=/\r/g,rSlash=/\\/g,rLineSep=/\u2028/,rParagraphSep=/\u2029/;Hogan.tags={"#":1,"^":2,"<":3,$:4,"/":5,"!":6,">":7,"=":8,_v:9,"{":10,"&":11,_t:12};Hogan.scan=function scan(text,delimiters){var len=text.length,IN_TEXT=0,IN_TAG_TYPE=1,IN_TAG=2,state=IN_TEXT,tagType=null,tag=null,buf="",tokens=[],seenTag=false,i=0,lineStart=0,otag="{{",ctag="}}";function addBuf(){if(buf.length>0){tokens.push({tag:"_t",text:new String(buf)});buf=""}}function lineIsWhitespace(){var isAllWhitespace=true;for(var j=lineStart;j<tokens.length;j++){isAllWhitespace=Hogan.tags[tokens[j].tag]<Hogan.tags["_v"]||tokens[j].tag=="_t"&&tokens[j].text.match(rIsWhitespace)===null;if(!isAllWhitespace){return false}}return isAllWhitespace}function filterLine(haveSeenTag,noNewLine){addBuf();if(haveSeenTag&&lineIsWhitespace()){for(var j=lineStart,next;j<tokens.length;j++){if(tokens[j].text){if((next=tokens[j+1])&&next.tag==">"){next.indent=tokens[j].text.toString()}tokens.splice(j,1)}}}else if(!noNewLine){tokens.push({tag:"\n"})}seenTag=false;lineStart=tokens.length}function changeDelimiters(text,index){var close="="+ctag,closeIndex=text.indexOf(close,index),delimiters=trim(text.substring(text.indexOf("=",index)+1,closeIndex)).split(" ");otag=delimiters[0];ctag=delimiters[delimiters.length-1];return closeIndex+close.length-1}if(delimiters){delimiters=delimiters.split(" ");otag=delimiters[0];ctag=delimiters[1]}for(i=0;i<len;i++){if(state==IN_TEXT){if(tagChange(otag,text,i)){--i;addBuf();state=IN_TAG_TYPE}else{if(text.charAt(i)=="\n"){filterLine(seenTag)}else{buf+=text.charAt(i)}}}else if(state==IN_TAG_TYPE){i+=otag.length-1;tag=Hogan.tags[text.charAt(i+1)];tagType=tag?text.charAt(i+1):"_v";if(tagType=="="){i=changeDelimiters(text,i);state=IN_TEXT}else{if(tag){i++}state=IN_TAG}seenTag=i}else{if(tagChange(ctag,text,i)){tokens.push({tag:tagType,n:trim(buf),otag:otag,ctag:ctag,i:tagType=="/"?seenTag-otag.length:i+ctag.length});buf="";i+=ctag.length-1;state=IN_TEXT;if(tagType=="{"){if(ctag=="}}"){i++}else{cleanTripleStache(tokens[tokens.length-1])}}}else{buf+=text.charAt(i)}}}filterLine(seenTag,true);return tokens};function cleanTripleStache(token){if(token.n.substr(token.n.length-1)==="}"){token.n=token.n.substring(0,token.n.length-1)}}function trim(s){if(s.trim){return s.trim()}return s.replace(/^\s*|\s*$/g,"")}function tagChange(tag,text,index){if(text.charAt(index)!=tag.charAt(0)){return false}for(var i=1,l=tag.length;i<l;i++){if(text.charAt(index+i)!=tag.charAt(i)){return false}}return true}var allowedInSuper={_t:true,"\n":true,$:true,"/":true};function buildTree(tokens,kind,stack,customTags){var instructions=[],opener=null,tail=null,token=null;tail=stack[stack.length-1];while(tokens.length>0){token=tokens.shift();if(tail&&tail.tag=="<"&&!(token.tag in allowedInSuper)){throw new Error("Illegal content in < super tag.")}if(Hogan.tags[token.tag]<=Hogan.tags["$"]||isOpener(token,customTags)){stack.push(token);token.nodes=buildTree(tokens,token.tag,stack,customTags)}else if(token.tag=="/"){if(stack.length===0){throw new Error("Closing tag without opener: /"+token.n)}opener=stack.pop();if(token.n!=opener.n&&!isCloser(token.n,opener.n,customTags)){throw new Error("Nesting error: "+opener.n+" vs. "+token.n)}opener.end=token.i;return instructions}else if(token.tag=="\n"){token.last=tokens.length==0||tokens[0].tag=="\n"}instructions.push(token)}if(stack.length>0){throw new Error("missing closing tag: "+stack.pop().n)}return instructions}function isOpener(token,tags){for(var i=0,l=tags.length;i<l;i++){if(tags[i].o==token.n){token.tag="#";return true}}}function isCloser(close,open,tags){for(var i=0,l=tags.length;i<l;i++){if(tags[i].c==close&&tags[i].o==open){return true}}}function stringifySubstitutions(obj){var items=[];for(var key in obj){items.push('"'+esc(key)+'": function(c,p,t,i) {'+obj[key]+"}")}return"{ "+items.join(",")+" }"}function stringifyPartials(codeObj){var partials=[];for(var key in codeObj.partials){partials.push('"'+esc(key)+'":{name:"'+esc(codeObj.partials[key].name)+'", '+stringifyPartials(codeObj.partials[key])+"}")}return"partials: {"+partials.join(",")+"}, subs: "+stringifySubstitutions(codeObj.subs)}Hogan.stringify=function(codeObj,text,options){return"{code: function (c,p,i) { "+Hogan.wrapMain(codeObj.code)+" },"+stringifyPartials(codeObj)+"}"};var serialNo=0;Hogan.generate=function(tree,text,options){serialNo=0;var context={code:"",subs:{},partials:{}};Hogan.walk(tree,context);if(options.asString){return this.stringify(context,text,options)}return this.makeTemplate(context,text,options)};Hogan.wrapMain=function(code){return'var t=this;t.b(i=i||"");'+code+"return t.fl();"};Hogan.template=Hogan.Template;Hogan.makeTemplate=function(codeObj,text,options){var template=this.makePartials(codeObj);template.code=new Function("c","p","i",this.wrapMain(codeObj.code));return new this.template(template,text,this,options)};Hogan.makePartials=function(codeObj){var key,template={subs:{},partials:codeObj.partials,name:codeObj.name};for(key in template.partials){template.partials[key]=this.makePartials(template.partials[key])}for(key in codeObj.subs){template.subs[key]=new Function("c","p","t","i",codeObj.subs[key])}return template};function esc(s){return s.replace(rSlash,"\\\\").replace(rQuot,'\\"').replace(rNewline,"\\n").replace(rCr,"\\r").replace(rLineSep,"\\u2028").replace(rParagraphSep,"\\u2029")}function chooseMethod(s){return~s.indexOf(".")?"d":"f"}function createPartial(node,context){var prefix="<"+(context.prefix||"");var sym=prefix+node.n+serialNo++;context.partials[sym]={name:node.n,partials:{}};context.code+='t.b(t.rp("'+esc(sym)+'",c,p,"'+(node.indent||"")+'"));';return sym}Hogan.codegen={"#":function(node,context){context.code+="if(t.s(t."+chooseMethod(node.n)+'("'+esc(node.n)+'",c,p,1),'+"c,p,0,"+node.i+","+node.end+',"'+node.otag+" "+node.ctag+'")){'+"t.rs(c,p,"+"function(c,p,t){";Hogan.walk(node.nodes,context);context.code+="});c.pop();}"},"^":function(node,context){context.code+="if(!t.s(t."+chooseMethod(node.n)+'("'+esc(node.n)+'",c,p,1),c,p,1,0,0,"")){';Hogan.walk(node.nodes,context);context.code+="};"},">":createPartial,"<":function(node,context){var ctx={partials:{},code:"",subs:{},inPartial:true};Hogan.walk(node.nodes,ctx);var template=context.partials[createPartial(node,context)];template.subs=ctx.subs;template.partials=ctx.partials},$:function(node,context){var ctx={subs:{},code:"",partials:context.partials,prefix:node.n};Hogan.walk(node.nodes,ctx);context.subs[node.n]=ctx.code;if(!context.inPartial){context.code+='t.sub("'+esc(node.n)+'",c,p,i);'}},"\n":function(node,context){context.code+=write('"\\n"'+(node.last?"":" + i"))},_v:function(node,context){context.code+="t.b(t.v(t."+chooseMethod(node.n)+'("'+esc(node.n)+'",c,p,0)));'},_t:function(node,context){context.code+=write('"'+esc(node.text)+'"')},"{":tripleStache,"&":tripleStache};function tripleStache(node,context){context.code+="t.b(t.t(t."+chooseMethod(node.n)+'("'+esc(node.n)+'",c,p,0)));'}function write(s){return"t.b("+s+");"}Hogan.walk=function(nodelist,context){var func;for(var i=0,l=nodelist.length;i<l;i++){func=Hogan.codegen[nodelist[i].tag];func&&func(nodelist[i],context)}return context};Hogan.parse=function(tokens,text,options){options=options||{};return buildTree(tokens,"",[],options.sectionTags||[])};Hogan.cache={};Hogan.cacheKey=function(text,options){return[text,!!options.asString,!!options.disableLambda,options.delimiters,!!options.modelGet].join("||")};Hogan.compile=function(text,options){options=options||{};var key=Hogan.cacheKey(text,options);var template=this.cache[key];if(template){var partials=template.partials;for(var name in partials){delete partials[name].instance}return template}template=this.generate(this.parse(this.scan(text,options.delimiters),text,options),text,options);return this.cache[key]=template}})(typeof exports!=="undefined"?exports:Hogan)},{}],228:[function(require,module,exports){var Hogan=require("./compiler");Hogan.Template=require("./template").Template;Hogan.template=Hogan.Template;module.exports=Hogan},{"./compiler":227,"./template":229}],229:[function(require,module,exports){var Hogan={};(function(Hogan){Hogan.Template=function(codeObj,text,compiler,options){codeObj=codeObj||{};this.r=codeObj.code||this.r;this.c=compiler;this.options=options||{};this.text=text||"";this.partials=codeObj.partials||{};this.subs=codeObj.subs||{};this.buf=""};Hogan.Template.prototype={r:function(context,partials,indent){return""},v:hoganEscape,t:coerceToString,render:function render(context,partials,indent){return this.ri([context],partials||{},indent)},ri:function(context,partials,indent){return this.r(context,partials,indent)},ep:function(symbol,partials){var partial=this.partials[symbol];var template=partials[partial.name];if(partial.instance&&partial.base==template){return partial.instance}if(typeof template=="string"){if(!this.c){throw new Error("No compiler available.")}template=this.c.compile(template,this.options)}if(!template){return null}this.partials[symbol].base=template;if(partial.subs){if(!partials.stackText)partials.stackText={};for(key in partial.subs){if(!partials.stackText[key]){partials.stackText[key]=this.activeSub!==undefined&&partials.stackText[this.activeSub]?partials.stackText[this.activeSub]:this.text}}template=createSpecializedPartial(template,partial.subs,partial.partials,this.stackSubs,this.stackPartials,partials.stackText)}this.partials[symbol].instance=template;return template},rp:function(symbol,context,partials,indent){var partial=this.ep(symbol,partials);if(!partial){return""}return partial.ri(context,partials,indent)},rs:function(context,partials,section){var tail=context[context.length-1];if(!isArray(tail)){section(context,partials,this);return}for(var i=0;i<tail.length;i++){context.push(tail[i]);section(context,partials,this);context.pop()}},s:function(val,ctx,partials,inverted,start,end,tags){var pass;if(isArray(val)&&val.length===0){
10
+ return false}if(typeof val=="function"){val=this.ms(val,ctx,partials,inverted,start,end,tags)}pass=!!val;if(!inverted&&pass&&ctx){ctx.push(typeof val=="object"?val:ctx[ctx.length-1])}return pass},d:function(key,ctx,partials,returnFound){var found,names=key.split("."),val=this.f(names[0],ctx,partials,returnFound),doModelGet=this.options.modelGet,cx=null;if(key==="."&&isArray(ctx[ctx.length-2])){val=ctx[ctx.length-1]}else{for(var i=1;i<names.length;i++){found=findInScope(names[i],val,doModelGet);if(found!==undefined){cx=val;val=found}else{val=""}}}if(returnFound&&!val){return false}if(!returnFound&&typeof val=="function"){ctx.push(cx);val=this.mv(val,ctx,partials);ctx.pop()}return val},f:function(key,ctx,partials,returnFound){var val=false,v=null,found=false,doModelGet=this.options.modelGet;for(var i=ctx.length-1;i>=0;i--){v=ctx[i];val=findInScope(key,v,doModelGet);if(val!==undefined){found=true;break}}if(!found){return returnFound?false:""}if(!returnFound&&typeof val=="function"){val=this.mv(val,ctx,partials)}return val},ls:function(func,cx,partials,text,tags){var oldTags=this.options.delimiters;this.options.delimiters=tags;this.b(this.ct(coerceToString(func.call(cx,text)),cx,partials));this.options.delimiters=oldTags;return false},ct:function(text,cx,partials){if(this.options.disableLambda){throw new Error("Lambda features disabled.")}return this.c.compile(text,this.options).render(cx,partials)},b:function(s){this.buf+=s},fl:function(){var r=this.buf;this.buf="";return r},ms:function(func,ctx,partials,inverted,start,end,tags){var textSource,cx=ctx[ctx.length-1],result=func.call(cx);if(typeof result=="function"){if(inverted){return true}else{textSource=this.activeSub&&this.subsText&&this.subsText[this.activeSub]?this.subsText[this.activeSub]:this.text;return this.ls(result,cx,partials,textSource.substring(start,end),tags)}}return result},mv:function(func,ctx,partials){var cx=ctx[ctx.length-1];var result=func.call(cx);if(typeof result=="function"){return this.ct(coerceToString(result.call(cx)),cx,partials)}return result},sub:function(name,context,partials,indent){var f=this.subs[name];if(f){this.activeSub=name;f(context,partials,this,indent);this.activeSub=false}}};function findInScope(key,scope,doModelGet){var val;if(scope&&typeof scope=="object"){if(scope[key]!==undefined){val=scope[key]}else if(doModelGet&&scope.get&&typeof scope.get=="function"){val=scope.get(key)}}return val}function createSpecializedPartial(instance,subs,partials,stackSubs,stackPartials,stackText){function PartialTemplate(){}PartialTemplate.prototype=instance;function Substitutions(){}Substitutions.prototype=instance.subs;var key;var partial=new PartialTemplate;partial.subs=new Substitutions;partial.subsText={};partial.buf="";stackSubs=stackSubs||{};partial.stackSubs=stackSubs;partial.subsText=stackText;for(key in subs){if(!stackSubs[key])stackSubs[key]=subs[key]}for(key in stackSubs){partial.subs[key]=stackSubs[key]}stackPartials=stackPartials||{};partial.stackPartials=stackPartials;for(key in partials){if(!stackPartials[key])stackPartials[key]=partials[key]}for(key in stackPartials){partial.partials[key]=stackPartials[key]}return partial}var rAmp=/&/g,rLt=/</g,rGt=/>/g,rApos=/\'/g,rQuot=/\"/g,hChars=/[&<>\"\']/;function coerceToString(val){return String(val===null||val===undefined?"":val)}function hoganEscape(str){str=coerceToString(str);return hChars.test(str)?str.replace(rAmp,"&amp;").replace(rLt,"&lt;").replace(rGt,"&gt;").replace(rApos,"&#39;").replace(rQuot,"&quot;"):str}var isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"}})(typeof exports!=="undefined"?exports:Hogan)},{}],230:[function(require,module,exports){(function($){$.support.touch="ontouchend"in document;if(!$.support.touch){return}var mouseProto=$.ui.mouse.prototype,_mouseInit=mouseProto._mouseInit,_mouseDestroy=mouseProto._mouseDestroy,touchHandled;function simulateMouseEvent(event,simulatedType){if(event.originalEvent.touches.length>1){return}event.preventDefault();var touch=event.originalEvent.changedTouches[0],simulatedEvent=document.createEvent("MouseEvents");simulatedEvent.initMouseEvent(simulatedType,true,true,window,1,touch.screenX,touch.screenY,touch.clientX,touch.clientY,false,false,false,false,0,null);event.target.dispatchEvent(simulatedEvent)}mouseProto._touchStart=function(event){var self=this;if(touchHandled||!self._mouseCapture(event.originalEvent.changedTouches[0])){return}touchHandled=true;self._touchMoved=false;simulateMouseEvent(event,"mouseover");simulateMouseEvent(event,"mousemove");simulateMouseEvent(event,"mousedown")};mouseProto._touchMove=function(event){if(!touchHandled){return}this._touchMoved=true;simulateMouseEvent(event,"mousemove")};mouseProto._touchEnd=function(event){if(!touchHandled){return}simulateMouseEvent(event,"mouseup");simulateMouseEvent(event,"mouseout");if(!this._touchMoved){simulateMouseEvent(event,"click")}touchHandled=false};mouseProto._mouseInit=function(){var self=this;self.element.bind({touchstart:$.proxy(self,"_touchStart"),touchmove:$.proxy(self,"_touchMove"),touchend:$.proxy(self,"_touchEnd")});_mouseInit.call(self)};mouseProto._mouseDestroy=function(){var self=this;self.element.unbind({touchstart:$.proxy(self,"_touchStart"),touchmove:$.proxy(self,"_touchMove"),touchend:$.proxy(self,"_touchEnd")});_mouseDestroy.call(self)}})(jQuery)},{}],231:[function(require,module,exports){var jQuery=require("jquery");(function($,undefined){var uuid=0,runiqueId=/^ui-id-\d+$/;$.ui=$.ui||{};$.extend($.ui,{version:"1.10.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}});$.fn.extend({focus:function(orig){return function(delay,fn){return typeof delay==="number"?this.each(function(){var elem=this;setTimeout(function(){$(elem).focus();if(fn){fn.call(elem)}},delay)}):orig.apply(this,arguments)}}($.fn.focus),scrollParent:function(){var scrollParent;if($.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))){scrollParent=this.parents().filter(function(){return/(relative|absolute|fixed)/.test($.css(this,"position"))&&/(auto|scroll)/.test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"))}).eq(0)}else{scrollParent=this.parents().filter(function(){return/(auto|scroll)/.test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"))}).eq(0)}return/fixed/.test(this.css("position"))||!scrollParent.length?$(document):scrollParent},zIndex:function(zIndex){if(zIndex!==undefined){return this.css("zIndex",zIndex)}if(this.length){var elem=$(this[0]),position,value;while(elem.length&&elem[0]!==document){position=elem.css("position");if(position==="absolute"||position==="relative"||position==="fixed"){value=parseInt(elem.css("zIndex"),10);if(!isNaN(value)&&value!==0){return value}}elem=elem.parent()}}return 0},uniqueId:function(){return this.each(function(){if(!this.id){this.id="ui-id-"+ ++uuid}})},removeUniqueId:function(){return this.each(function(){if(runiqueId.test(this.id)){$(this).removeAttr("id")}})}});function focusable(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();if("area"===nodeName){map=element.parentNode;mapName=map.name;if(!element.href||!mapName||map.nodeName.toLowerCase()!=="map"){return false}img=$("img[usemap=#"+mapName+"]")[0];return!!img&&visible(img)}return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)}function visible(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return $.css(this,"visibility")==="hidden"}).length}$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}});if(!$("<a>").outerWidth(1).jquery){$.each(["Width","Height"],function(i,name){var side=name==="Width"?["Left","Right"]:["Top","Bottom"],type=name.toLowerCase(),orig={innerWidth:$.fn.innerWidth,innerHeight:$.fn.innerHeight,outerWidth:$.fn.outerWidth,outerHeight:$.fn.outerHeight};function reduce(elem,size,border,margin){$.each(side,function(){size-=parseFloat($.css(elem,"padding"+this))||0;if(border){size-=parseFloat($.css(elem,"border"+this+"Width"))||0}if(margin){size-=parseFloat($.css(elem,"margin"+this))||0}});return size}$.fn["inner"+name]=function(size){if(size===undefined){return orig["inner"+name].call(this)}return this.each(function(){$(this).css(type,reduce(this,size)+"px")})};$.fn["outer"+name]=function(size,margin){if(typeof size!=="number"){return orig["outer"+name].call(this,size)}return this.each(function(){$(this).css(type,reduce(this,size,true,margin)+"px")})}})}if(!$.fn.addBack){$.fn.addBack=function(selector){return this.add(selector==null?this.prevObject:this.prevObject.filter(selector))}}if($("<a>").data("a-b","a").removeData("a-b").data("a-b")){$.fn.removeData=function(removeData){return function(key){if(arguments.length){return removeData.call(this,$.camelCase(key))}else{return removeData.call(this)}}}($.fn.removeData)}$.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());$.support.selectstart="onselectstart"in document.createElement("div");$.fn.extend({disableSelection:function(){return this.bind(($.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(event){event.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});$.extend($.ui,{plugin:{add:function(module,option,set){var i,proto=$.ui[module].prototype;for(i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]])}},call:function(instance,name,args){var i,set=instance.plugins[name];if(!set||!instance.element[0].parentNode||instance.element[0].parentNode.nodeType===11){return}for(i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args)}}}},hasScroll:function(el,a){if($(el).css("overflow")==="hidden"){return false}var scroll=a&&a==="left"?"scrollLeft":"scrollTop",has=false;if(el[scroll]>0){return true}el[scroll]=1;has=el[scroll]>0;el[scroll]=0;return has}})})(jQuery)},{jquery:237}],232:[function(require,module,exports){var jQuery=require("jquery");require("./core");require("./mouse");require("./widget");(function($,undefined){$.widget("ui.draggable",$.ui.mouse,{version:"1.10.4",widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false,drag:null,start:null,stop:null},_create:function(){if(this.options.helper==="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))){this.element[0].style.position="relative"}if(this.options.addClasses){this.element.addClass("ui-draggable")}if(this.options.disabled){this.element.addClass("ui-draggable-disabled")}this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy()},_mouseCapture:function(event){var o=this.options;if(this.helper||o.disabled||$(event.target).closest(".ui-resizable-handle").length>0){return false}this.handle=this._getHandle(event);if(!this.handle){return false}$(o.iframeFix===true?"iframe":o.iframeFix).each(function(){$("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css($(this).offset()).appendTo("body")});return true},_mouseStart:function(event){var o=this.options;this.helper=this._createHelper(event);this.helper.addClass("ui-draggable-dragging");this._cacheHelperProportions();if($.ui.ddmanager){$.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offsetParent=this.helper.offsetParent();this.offsetParentCssPosition=this.offsetParent.css("position");this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.scroll=false;$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt);this._setContainment();if(this._trigger("start",event)===false){this._clear();return false}this._cacheHelperProportions();if($.ui.ddmanager&&!o.dropBehaviour){$.ui.ddmanager.prepareOffsets(this,event)}this._mouseDrag(event,true);if($.ui.ddmanager){$.ui.ddmanager.dragStart(this,event)}return true},_mouseDrag:function(event,noPropagation){if(this.offsetParentCssPosition==="fixed"){this.offset.parent=this._getParentOffset()}this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!noPropagation){var ui=this._uiHash();if(this._trigger("drag",event,ui)===false){this._mouseUp({});return false}this.position=ui.position}if(!this.options.axis||this.options.axis!=="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!=="x"){this.helper[0].style.top=this.position.top+"px"}if($.ui.ddmanager){$.ui.ddmanager.drag(this,event)}return false},_mouseStop:function(event){var that=this,dropped=false;if($.ui.ddmanager&&!this.options.dropBehaviour){dropped=$.ui.ddmanager.drop(this,event)}if(this.dropped){dropped=this.dropped;this.dropped=false}if(this.options.helper==="original"&&!$.contains(this.element[0].ownerDocument,this.element[0])){return false}if(this.options.revert==="invalid"&&!dropped||this.options.revert==="valid"&&dropped||this.options.revert===true||$.isFunction(this.options.revert)&&this.options.revert.call(this.element,dropped)){$(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){if(that._trigger("stop",event)!==false){that._clear()}})}else{if(this._trigger("stop",event)!==false){this._clear()}}return false},_mouseUp:function(event){$("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});if($.ui.ddmanager){$.ui.ddmanager.dragStop(this,event)}return $.ui.mouse.prototype._mouseUp.call(this,event)},cancel:function(){if(this.helper.is(".ui-draggable-dragging")){this._mouseUp({})}else{this._clear()}return this},_getHandle:function(event){return this.options.handle?!!$(event.target).closest(this.element.find(this.options.handle)).length:true},_createHelper:function(event){var o=this.options,helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event])):o.helper==="clone"?this.element.clone().removeAttr("id"):this.element;if(!helper.parents("body").length){helper.appendTo(o.appendTo==="parent"?this.element[0].parentNode:o.appendTo)}if(helper[0]!==this.element[0]&&!/(fixed|absolute)/.test(helper.css("position"))){helper.css("position","absolute")}return helper},_adjustOffsetFromHelper:function(obj){if(typeof obj==="string"){obj=obj.split(" ")}if($.isArray(obj)){obj={left:+obj[0],top:+obj[1]||0}}if("left"in obj){this.offset.click.left=obj.left+this.margins.left}if("right"in obj){this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left}if("top"in obj){this.offset.click.top=obj.top+this.margins.top}if("bottom"in obj){this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top}},_getParentOffset:function(){var po=this.offsetParent.offset();if(this.cssPosition==="absolute"&&this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()==="html"&&$.ui.ie){po={top:0,left:0}}return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==="relative"){var p=this.element.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var over,c,ce,o=this.options;if(!o.containment){this.containment=null;return}if(o.containment==="window"){this.containment=[$(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,$(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,$(window).scrollLeft()+$(window).width()-this.helperProportions.width-this.margins.left,$(window).scrollTop()+($(window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];return}if(o.containment==="document"){this.containment=[0,0,$(document).width()-this.helperProportions.width-this.margins.left,($(document).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];return}if(o.containment.constructor===Array){this.containment=o.containment;return}if(o.containment==="parent"){o.containment=this.helper[0].parentNode}c=$(o.containment);ce=c[0];if(!ce){return}over=c.css("overflow")!=="hidden";this.containment=[(parseInt(c.css("borderLeftWidth"),10)||0)+(parseInt(c.css("paddingLeft"),10)||0),(parseInt(c.css("borderTopWidth"),10)||0)+(parseInt(c.css("paddingTop"),10)||0),(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt(c.css("borderRightWidth"),10)||0)-(parseInt(c.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt(c.css("borderBottomWidth"),10)||0)-(parseInt(c.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=c},_convertPositionTo:function(d,pos){if(!pos){pos=this.position}var mod=d==="absolute"?1:-1,scroll=this.cssPosition==="absolute"&&!(this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent;if(!this.offset.scroll){this.offset.scroll={top:scroll.scrollTop(),left:scroll.scrollLeft()}}return{top:pos.top+this.offset.relative.top*mod+this.offset.parent.top*mod-(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():this.offset.scroll.top)*mod,left:pos.left+this.offset.relative.left*mod+this.offset.parent.left*mod-(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():this.offset.scroll.left)*mod}},_generatePosition:function(event){var containment,co,top,left,o=this.options,scroll=this.cssPosition==="absolute"&&!(this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,pageX=event.pageX,pageY=event.pageY;if(!this.offset.scroll){this.offset.scroll={top:scroll.scrollTop(),left:scroll.scrollLeft()}}if(this.originalPosition){if(this.containment){if(this.relative_container){co=this.relative_container.offset();containment=[this.containment[0]+co.left,this.containment[1]+co.top,this.containment[2]+co.left,this.containment[3]+co.top]}else{containment=this.containment}if(event.pageX-this.offset.click.left<containment[0]){pageX=containment[0]+this.offset.click.left}if(event.pageY-this.offset.click.top<containment[1]){pageY=containment[1]+this.offset.click.top}if(event.pageX-this.offset.click.left>containment[2]){pageX=containment[2]+this.offset.click.left}if(event.pageY-this.offset.click.top>containment[3]){pageY=containment[3]+this.offset.click.top}}if(o.grid){top=o.grid[1]?this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY;pageY=containment?top-this.offset.click.top>=containment[1]||top-this.offset.click.top>containment[3]?top:top-this.offset.click.top>=containment[1]?top-o.grid[1]:top+o.grid[1]:top;left=o.grid[0]?this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX;pageX=containment?left-this.offset.click.left>=containment[0]||left-this.offset.click.left>containment[2]?left:left-this.offset.click.left>=containment[0]?left-o.grid[0]:left+o.grid[0]:left}}return{top:pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():this.offset.scroll.top),left:pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!==this.element[0]&&!this.cancelHelperRemoval){this.helper.remove()}this.helper=null;this.cancelHelperRemoval=false},_trigger:function(type,event,ui){ui=ui||this._uiHash();$.ui.plugin.call(this,type,[event,ui]);if(type==="drag"){this.positionAbs=this._convertPositionTo("absolute")}return $.Widget.prototype._trigger.call(this,type,event,ui)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});$.ui.plugin.add("draggable","connectToSortable",{start:function(event,ui){var inst=$(this).data("ui-draggable"),o=inst.options,uiSortable=$.extend({},ui,{item:inst.element});inst.sortables=[];$(o.connectToSortable).each(function(){var sortable=$.data(this,"ui-sortable");if(sortable&&!sortable.options.disabled){inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable.refreshPositions();sortable._trigger("activate",event,uiSortable)}})},stop:function(event,ui){var inst=$(this).data("ui-draggable"),uiSortable=$.extend({},ui,{item:inst.element});$.each(inst.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;inst.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert){this.instance.options.revert=this.shouldRevert}this.instance._mouseStop(event);this.instance.options.helper=this.instance.options._helper;if(inst.options.helper==="original"){this.instance.currentItem.css({top:"auto",left:"auto"})}}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",event,uiSortable)}})},drag:function(event,ui){var inst=$(this).data("ui-draggable"),that=this;$.each(inst.sortables,function(){var innermostIntersecting=false,thisSortable=this;this.instance.positionAbs=inst.positionAbs;this.instance.helperProportions=inst.helperProportions;this.instance.offset.click=inst.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){innermostIntersecting=true;$.each(inst.sortables,function(){this.instance.positionAbs=inst.positionAbs;this.instance.helperProportions=inst.helperProportions;this.instance.offset.click=inst.offset.click;if(this!==thisSortable&&this.instance._intersectsWith(this.instance.containerCache)&&$.contains(thisSortable.instance.element[0],this.instance.element[0])){innermostIntersecting=false}return innermostIntersecting})}if(innermostIntersecting){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=$(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return ui.helper[0]};event.target=this.instance.currentItem[0];this.instance._mouseCapture(event,true);this.instance._mouseStart(event,true,true);this.instance.offset.click.top=inst.offset.click.top;this.instance.offset.click.left=inst.offset.click.left;this.instance.offset.parent.left-=inst.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=inst.offset.parent.top-this.instance.offset.parent.top;inst._trigger("toSortable",event);inst.dropped=this.instance.element;inst.currentItem=inst.element;this.instance.fromOutside=inst}if(this.instance.currentItem){this.instance._mouseDrag(event)}}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",event,this.instance._uiHash(this.instance));this.instance._mouseStop(event,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder){this.instance.placeholder.remove()}inst._trigger("fromSortable",event);inst.dropped=false}}})}});$.ui.plugin.add("draggable","cursor",{start:function(){var t=$("body"),o=$(this).data("ui-draggable").options;if(t.css("cursor")){o._cursor=t.css("cursor")}t.css("cursor",o.cursor)},stop:function(){var o=$(this).data("ui-draggable").options;if(o._cursor){$("body").css("cursor",o._cursor)}}});$.ui.plugin.add("draggable","opacity",{start:function(event,ui){var t=$(ui.helper),o=$(this).data("ui-draggable").options;if(t.css("opacity")){o._opacity=t.css("opacity")}t.css("opacity",o.opacity)},stop:function(event,ui){var o=$(this).data("ui-draggable").options;if(o._opacity){$(ui.helper).css("opacity",o._opacity)}}});$.ui.plugin.add("draggable","scroll",{start:function(){var i=$(this).data("ui-draggable");if(i.scrollParent[0]!==document&&i.scrollParent[0].tagName!=="HTML"){i.overflowOffset=i.scrollParent.offset()}},drag:function(event){var i=$(this).data("ui-draggable"),o=i.options,scrolled=false;if(i.scrollParent[0]!==document&&i.scrollParent[0].tagName!=="HTML"){if(!o.axis||o.axis!=="x"){if(i.overflowOffset.top+i.scrollParent[0].offsetHeight-event.pageY<o.scrollSensitivity){i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop+o.scrollSpeed}else if(event.pageY-i.overflowOffset.top<o.scrollSensitivity){i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop-o.scrollSpeed}}if(!o.axis||o.axis!=="y"){if(i.overflowOffset.left+i.scrollParent[0].offsetWidth-event.pageX<o.scrollSensitivity){i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft+o.scrollSpeed}else if(event.pageX-i.overflowOffset.left<o.scrollSensitivity){i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft-o.scrollSpeed}}}else{if(!o.axis||o.axis!=="x"){if(event.pageY-$(document).scrollTop()<o.scrollSensitivity){scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed)}else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity){scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed)}}if(!o.axis||o.axis!=="y"){if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity){scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed)}else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity){scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed)}}}if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour){$.ui.ddmanager.prepareOffsets(i,event)}}});$.ui.plugin.add("draggable","snap",{start:function(){var i=$(this).data("ui-draggable"),o=i.options;i.snapElements=[];$(o.snap.constructor!==String?o.snap.items||":data(ui-draggable)":o.snap).each(function(){var $t=$(this),$o=$t.offset();if(this!==i.element[0]){i.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left})}})},drag:function(event,ui){var ts,bs,ls,rs,l,r,t,b,i,first,inst=$(this).data("ui-draggable"),o=inst.options,d=o.snapTolerance,x1=ui.offset.left,x2=x1+inst.helperProportions.width,y1=ui.offset.top,y2=y1+inst.helperProportions.height;for(i=inst.snapElements.length-1;i>=0;i--){l=inst.snapElements[i].left;r=l+inst.snapElements[i].width;t=inst.snapElements[i].top;b=t+inst.snapElements[i].height;if(x2<l-d||x1>r+d||y2<t-d||y1>b+d||!$.contains(inst.snapElements[i].item.ownerDocument,inst.snapElements[i].item)){if(inst.snapElements[i].snapping){inst.options.snap.release&&inst.options.snap.release.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item}))}inst.snapElements[i].snapping=false;continue}if(o.snapMode!=="inner"){ts=Math.abs(t-y2)<=d;bs=Math.abs(b-y1)<=d;ls=Math.abs(l-x2)<=d;rs=Math.abs(r-x1)<=d;if(ts){ui.position.top=inst._convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top-inst.margins.top}if(bs){ui.position.top=inst._convertPositionTo("relative",{top:b,left:0}).top-inst.margins.top}if(ls){ui.position.left=inst._convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left-inst.margins.left}if(rs){ui.position.left=inst._convertPositionTo("relative",{top:0,left:r}).left-inst.margins.left}}first=ts||bs||ls||rs;if(o.snapMode!=="outer"){ts=Math.abs(t-y1)<=d;bs=Math.abs(b-y2)<=d;ls=Math.abs(l-x1)<=d;rs=Math.abs(r-x2)<=d;if(ts){ui.position.top=inst._convertPositionTo("relative",{top:t,left:0}).top-inst.margins.top}if(bs){ui.position.top=inst._convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top-inst.margins.top}if(ls){ui.position.left=inst._convertPositionTo("relative",{top:0,left:l}).left-inst.margins.left}if(rs){ui.position.left=inst._convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left-inst.margins.left}}if(!inst.snapElements[i].snapping&&(ts||bs||ls||rs||first)){inst.options.snap.snap&&inst.options.snap.snap.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item}))}inst.snapElements[i].snapping=ts||bs||ls||rs||first}}});$.ui.plugin.add("draggable","stack",{start:function(){var min,o=this.data("ui-draggable").options,group=$.makeArray($(o.stack)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||0)-(parseInt($(b).css("zIndex"),10)||0)});if(!group.length){return}min=parseInt($(group[0]).css("zIndex"),10)||0;$(group).each(function(i){$(this).css("zIndex",min+i)});this.css("zIndex",min+group.length)}});$.ui.plugin.add("draggable","zIndex",{start:function(event,ui){var t=$(ui.helper),o=$(this).data("ui-draggable").options;if(t.css("zIndex")){o._zIndex=t.css("zIndex")}t.css("zIndex",o.zIndex)},stop:function(event,ui){var o=$(this).data("ui-draggable").options;if(o._zIndex){$(ui.helper).css("zIndex",o._zIndex)}}})})(jQuery)},{"./core":231,"./mouse":233,"./widget":236,jquery:237}],233:[function(require,module,exports){var jQuery=require("jquery");require("./widget");(function($,undefined){var mouseHandled=false;$(document).mouseup(function(){mouseHandled=false});$.widget("ui.mouse",{version:"1.10.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var that=this;this.element.bind("mousedown."+this.widgetName,function(event){return that._mouseDown(event)}).bind("click."+this.widgetName,function(event){if(true===$.data(event.target,that.widgetName+".preventClickEvent")){$.removeData(event.target,that.widgetName+".preventClickEvent");event.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);if(this._mouseMoveDelegate){$(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);
 
 
 
 
11
 
12
+ }},_mouseDown:function(event){if(mouseHandled){return}this._mouseStarted&&this._mouseUp(event);this._mouseDownEvent=event;var that=this,btnIsLeft=event.which===1,elIsCancel=typeof this.options.cancel==="string"&&event.target.nodeName?$(event.target).closest(this.options.cancel).length:false;if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){that.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=this._mouseStart(event)!==false;if(!this._mouseStarted){event.preventDefault();return true}}if(true===$.data(event.target,this.widgetName+".preventClickEvent")){$.removeData(event.target,this.widgetName+".preventClickEvent")}this._mouseMoveDelegate=function(event){return that._mouseMove(event)};this._mouseUpDelegate=function(event){return that._mouseUp(event)};$(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);event.preventDefault();mouseHandled=true;return true},_mouseMove:function(event){if($.ui.ie&&(!document.documentMode||document.documentMode<9)&&!event.button){return this._mouseUp(event)}if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault()}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=this._mouseStart(this._mouseDownEvent,event)!==false;this._mouseStarted?this._mouseDrag(event):this._mouseUp(event)}return!this._mouseStarted},_mouseUp:function(event){$(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;if(event.target===this._mouseDownEvent.target){$.data(event.target,this.widgetName+".preventClickEvent",true)}this._mouseStop(event)}return false},_mouseDistanceMet:function(event){return Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery)},{"./widget":236,jquery:237}],234:[function(require,module,exports){var jQuery=require("jquery");require("./core");require("./mouse");require("./widget");(function($,undefined){var numPages=5;$.widget("ui.slider",$.ui.mouse,{version:"1.10.4",widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},_create:function(){this._keySliding=false;this._mouseSliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider"+" ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all");this._refresh();this._setOption("disabled",this.options.disabled);this._animateOff=false},_refresh:function(){this._createRange();this._createHandles();this._setupEvents();this._refreshValue()},_createHandles:function(){var i,handleCount,options=this.options,existingHandles=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),handle="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",handles=[];handleCount=options.values&&options.values.length||1;if(existingHandles.length>handleCount){existingHandles.slice(handleCount).remove();existingHandles=existingHandles.slice(0,handleCount)}for(i=existingHandles.length;i<handleCount;i++){handles.push(handle)}this.handles=existingHandles.add($(handles.join("")).appendTo(this.element));this.handle=this.handles.eq(0);this.handles.each(function(i){$(this).data("ui-slider-handle-index",i)})},_createRange:function(){var options=this.options,classes="";if(options.range){if(options.range===true){if(!options.values){options.values=[this._valueMin(),this._valueMin()]}else if(options.values.length&&options.values.length!==2){options.values=[options.values[0],options.values[0]]}else if($.isArray(options.values)){options.values=options.values.slice(0)}}if(!this.range||!this.range.length){this.range=$("<div></div>").appendTo(this.element);classes="ui-slider-range"+" ui-widget-header ui-corner-all"}else{this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""})}this.range.addClass(classes+(options.range==="min"||options.range==="max"?" ui-slider-range-"+options.range:""))}else{if(this.range){this.range.remove()}this.range=null}},_setupEvents:function(){var elements=this.handles.add(this.range).filter("a");this._off(elements);this._on(elements,this._handleEvents);this._hoverable(elements);this._focusable(elements)},_destroy:function(){this.handles.remove();if(this.range){this.range.remove()}this.element.removeClass("ui-slider"+" ui-slider-horizontal"+" ui-slider-vertical"+" ui-widget"+" ui-widget-content"+" ui-corner-all");this._mouseDestroy()},_mouseCapture:function(event){var position,normValue,distance,closestHandle,index,allowed,offset,mouseOverHandle,that=this,o=this.options;if(o.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();position={x:event.pageX,y:event.pageY};normValue=this._normValueFromMouse(position);distance=this._valueMax()-this._valueMin()+1;this.handles.each(function(i){var thisDistance=Math.abs(normValue-that.values(i));if(distance>thisDistance||distance===thisDistance&&(i===that._lastChangedValue||that.values(i)===o.min)){distance=thisDistance;closestHandle=$(this);index=i}});allowed=this._start(event,index);if(allowed===false){return false}this._mouseSliding=true;this._handleIndex=index;closestHandle.addClass("ui-state-active").focus();offset=closestHandle.offset();mouseOverHandle=!$(event.target).parents().addBack().is(".ui-slider-handle");this._clickOffset=mouseOverHandle?{left:0,top:0}:{left:event.pageX-offset.left-closestHandle.width()/2,top:event.pageY-offset.top-closestHandle.height()/2-(parseInt(closestHandle.css("borderTopWidth"),10)||0)-(parseInt(closestHandle.css("borderBottomWidth"),10)||0)+(parseInt(closestHandle.css("marginTop"),10)||0)};if(!this.handles.hasClass("ui-state-hover")){this._slide(event,index,normValue)}this._animateOff=true;return true},_mouseStart:function(){return true},_mouseDrag:function(event){var position={x:event.pageX,y:event.pageY},normValue=this._normValueFromMouse(position);this._slide(event,this._handleIndex,normValue);return false},_mouseStop:function(event){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(event,this._handleIndex);this._change(event,this._handleIndex);this._handleIndex=null;this._clickOffset=null;this._animateOff=false;return false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(position){var pixelTotal,pixelMouse,percentMouse,valueTotal,valueMouse;if(this.orientation==="horizontal"){pixelTotal=this.elementSize.width;pixelMouse=position.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{pixelTotal=this.elementSize.height;pixelMouse=position.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}percentMouse=pixelMouse/pixelTotal;if(percentMouse>1){percentMouse=1}if(percentMouse<0){percentMouse=0}if(this.orientation==="vertical"){percentMouse=1-percentMouse}valueTotal=this._valueMax()-this._valueMin();valueMouse=this._valueMin()+percentMouse*valueTotal;return this._trimAlignValue(valueMouse)},_start:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}return this._trigger("start",event,uiHash)},_slide:function(event,index,newVal){var otherVal,newValues,allowed;if(this.options.values&&this.options.values.length){otherVal=this.values(index?0:1);if(this.options.values.length===2&&this.options.range===true&&(index===0&&newVal>otherVal||index===1&&newVal<otherVal)){newVal=otherVal}if(newVal!==this.values(index)){newValues=this.values();newValues[index]=newVal;allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal,values:newValues});otherVal=this.values(index?0:1);if(allowed!==false){this.values(index,newVal)}}}else{if(newVal!==this.value()){allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal});if(allowed!==false){this.value(newVal)}}}},_stop:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}this._trigger("stop",event,uiHash)},_change:function(event,index){if(!this._keySliding&&!this._mouseSliding){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values()}this._lastChangedValue=index;this._trigger("change",event,uiHash)}},value:function(newValue){if(arguments.length){this.options.value=this._trimAlignValue(newValue);this._refreshValue();this._change(null,0);return}return this._value()},values:function(index,newValue){var vals,newValues,i;if(arguments.length>1){this.options.values[index]=this._trimAlignValue(newValue);this._refreshValue();this._change(null,index);return}if(arguments.length){if($.isArray(arguments[0])){vals=this.options.values;newValues=arguments[0];for(i=0;i<vals.length;i+=1){vals[i]=this._trimAlignValue(newValues[i]);this._change(null,i)}this._refreshValue()}else{if(this.options.values&&this.options.values.length){return this._values(index)}else{return this.value()}}}else{return this._values()}},_setOption:function(key,value){var i,valsLength=0;if(key==="range"&&this.options.range===true){if(value==="min"){this.options.value=this._values(0);this.options.values=null}else if(value==="max"){this.options.value=this._values(this.options.values.length-1);this.options.values=null}}if($.isArray(this.options.values)){valsLength=this.options.values.length}$.Widget.prototype._setOption.apply(this,arguments);switch(key){case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case"value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case"values":this._animateOff=true;this._refreshValue();for(i=0;i<valsLength;i+=1){this._change(null,i)}this._animateOff=false;break;case"min":case"max":this._animateOff=true;this._refreshValue();this._animateOff=false;break;case"range":this._animateOff=true;this._refresh();this._animateOff=false;break}},_value:function(){var val=this.options.value;val=this._trimAlignValue(val);return val},_values:function(index){var val,vals,i;if(arguments.length){val=this.options.values[index];val=this._trimAlignValue(val);return val}else if(this.options.values&&this.options.values.length){vals=this.options.values.slice();for(i=0;i<vals.length;i+=1){vals[i]=this._trimAlignValue(vals[i])}return vals}else{return[]}},_trimAlignValue:function(val){if(val<=this._valueMin()){return this._valueMin()}if(val>=this._valueMax()){return this._valueMax()}var step=this.options.step>0?this.options.step:1,valModStep=(val-this._valueMin())%step,alignValue=val-valModStep;if(Math.abs(valModStep)*2>=step){alignValue+=valModStep>0?step:-step}return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var lastValPercent,valPercent,value,valueMin,valueMax,oRange=this.options.range,o=this.options,that=this,animate=!this._animateOff?o.animate:false,_set={};if(this.options.values&&this.options.values.length){this.handles.each(function(i){valPercent=(that.values(i)-that._valueMin())/(that._valueMax()-that._valueMin())*100;_set[that.orientation==="horizontal"?"left":"bottom"]=valPercent+"%";$(this).stop(1,1)[animate?"animate":"css"](_set,o.animate);if(that.options.range===true){if(that.orientation==="horizontal"){if(i===0){that.range.stop(1,1)[animate?"animate":"css"]({left:valPercent+"%"},o.animate)}if(i===1){that.range[animate?"animate":"css"]({width:valPercent-lastValPercent+"%"},{queue:false,duration:o.animate})}}else{if(i===0){that.range.stop(1,1)[animate?"animate":"css"]({bottom:valPercent+"%"},o.animate)}if(i===1){that.range[animate?"animate":"css"]({height:valPercent-lastValPercent+"%"},{queue:false,duration:o.animate})}}}lastValPercent=valPercent})}else{value=this.value();valueMin=this._valueMin();valueMax=this._valueMax();valPercent=valueMax!==valueMin?(value-valueMin)/(valueMax-valueMin)*100:0;_set[this.orientation==="horizontal"?"left":"bottom"]=valPercent+"%";this.handle.stop(1,1)[animate?"animate":"css"](_set,o.animate);if(oRange==="min"&&this.orientation==="horizontal"){this.range.stop(1,1)[animate?"animate":"css"]({width:valPercent+"%"},o.animate)}if(oRange==="max"&&this.orientation==="horizontal"){this.range[animate?"animate":"css"]({width:100-valPercent+"%"},{queue:false,duration:o.animate})}if(oRange==="min"&&this.orientation==="vertical"){this.range.stop(1,1)[animate?"animate":"css"]({height:valPercent+"%"},o.animate)}if(oRange==="max"&&this.orientation==="vertical"){this.range[animate?"animate":"css"]({height:100-valPercent+"%"},{queue:false,duration:o.animate})}}},_handleEvents:{keydown:function(event){var allowed,curVal,newVal,step,index=$(event.target).data("ui-slider-handle-index");switch(event.keyCode){case $.ui.keyCode.HOME:case $.ui.keyCode.END:case $.ui.keyCode.PAGE_UP:case $.ui.keyCode.PAGE_DOWN:case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:event.preventDefault();if(!this._keySliding){this._keySliding=true;$(event.target).addClass("ui-state-active");allowed=this._start(event,index);if(allowed===false){return}}break}step=this.options.step;if(this.options.values&&this.options.values.length){curVal=newVal=this.values(index)}else{curVal=newVal=this.value()}switch(event.keyCode){case $.ui.keyCode.HOME:newVal=this._valueMin();break;case $.ui.keyCode.END:newVal=this._valueMax();break;case $.ui.keyCode.PAGE_UP:newVal=this._trimAlignValue(curVal+(this._valueMax()-this._valueMin())/numPages);break;case $.ui.keyCode.PAGE_DOWN:newVal=this._trimAlignValue(curVal-(this._valueMax()-this._valueMin())/numPages);break;case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:if(curVal===this._valueMax()){return}newVal=this._trimAlignValue(curVal+step);break;case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:if(curVal===this._valueMin()){return}newVal=this._trimAlignValue(curVal-step);break}this._slide(event,index,newVal)},click:function(event){event.preventDefault()},keyup:function(event){var index=$(event.target).data("ui-slider-handle-index");if(this._keySliding){this._keySliding=false;this._stop(event,index);this._change(event,index);$(event.target).removeClass("ui-state-active")}}}})})(jQuery)},{"./core":231,"./mouse":233,"./widget":236,jquery:237}],235:[function(require,module,exports){var jQuery=require("jquery");require("./core");require("./mouse");require("./widget");(function($,undefined){function isOverAxis(x,reference,size){return x>reference&&x<reference+size}function isFloating(item){return/left|right/.test(item.css("float"))||/inline|table-cell/.test(item.css("display"))}$.widget("ui.sortable",$.ui.mouse,{version:"1.10.4",widgetEventPrefix:"sort",ready:false,options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var o=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?o.axis==="x"||isFloating(this.items[0].item):false;this.offset=this.element.offset();this._mouseInit();this.ready=true},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled");this._mouseDestroy();for(var i=this.items.length-1;i>=0;i--){this.items[i].item.removeData(this.widgetName+"-item")}return this},_setOption:function(key,value){if(key==="disabled"){this.options[key]=value;this.widget().toggleClass("ui-sortable-disabled",!!value)}else{$.Widget.prototype._setOption.apply(this,arguments)}},_mouseCapture:function(event,overrideHandle){var currentItem=null,validHandle=false,that=this;if(this.reverting){return false}if(this.options.disabled||this.options.type==="static"){return false}this._refreshItems(event);$(event.target).parents().each(function(){if($.data(this,that.widgetName+"-item")===that){currentItem=$(this);return false}});if($.data(event.target,that.widgetName+"-item")===that){currentItem=$(event.target)}if(!currentItem){return false}if(this.options.handle&&!overrideHandle){$(this.options.handle,currentItem).find("*").addBack().each(function(){if(this===event.target){validHandle=true}});if(!validHandle){return false}}this.currentItem=currentItem;this._removeCurrentsFromItems();return true},_mouseStart:function(event,overrideHandle,noActivation){var i,body,o=this.options;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(event);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};if(this.helper[0]!==this.currentItem[0]){this.currentItem.hide()}this._createPlaceholder();if(o.containment){this._setContainment()}if(o.cursor&&o.cursor!=="auto"){body=this.document.find("body");this.storedCursor=body.css("cursor");body.css("cursor",o.cursor);this.storedStylesheet=$("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(body)}if(o.opacity){if(this.helper.css("opacity")){this._storedOpacity=this.helper.css("opacity")}this.helper.css("opacity",o.opacity)}if(o.zIndex){if(this.helper.css("zIndex")){this._storedZIndex=this.helper.css("zIndex")}this.helper.css("zIndex",o.zIndex)}if(this.scrollParent[0]!==document&&this.scrollParent[0].tagName!=="HTML"){this.overflowOffset=this.scrollParent.offset()}this._trigger("start",event,this._uiHash());if(!this._preserveHelperProportions){this._cacheHelperProportions()}if(!noActivation){for(i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("activate",event,this._uiHash(this))}}if($.ui.ddmanager){$.ui.ddmanager.current=this}if($.ui.ddmanager&&!o.dropBehaviour){$.ui.ddmanager.prepareOffsets(this,event)}this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(event);return true},_mouseDrag:function(event){var i,item,itemElement,intersection,o=this.options,scrolled=false;this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs){this.lastPositionAbs=this.positionAbs}if(this.options.scroll){if(this.scrollParent[0]!==document&&this.scrollParent[0].tagName!=="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-event.pageY<o.scrollSensitivity){this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop+o.scrollSpeed}else if(event.pageY-this.overflowOffset.top<o.scrollSensitivity){this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop-o.scrollSpeed}if(this.overflowOffset.left+this.scrollParent[0].offsetWidth-event.pageX<o.scrollSensitivity){this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft+o.scrollSpeed}else if(event.pageX-this.overflowOffset.left<o.scrollSensitivity){this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft-o.scrollSpeed}}else{if(event.pageY-$(document).scrollTop()<o.scrollSensitivity){scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed)}else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity){scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed)}if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity){scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed)}else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity){scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed)}}if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour){$.ui.ddmanager.prepareOffsets(this,event)}}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!=="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!=="x"){this.helper[0].style.top=this.position.top+"px"}for(i=this.items.length-1;i>=0;i--){item=this.items[i];itemElement=item.item[0];intersection=this._intersectsWithPointer(item);if(!intersection){continue}if(item.instance!==this.currentContainer){continue}if(itemElement!==this.currentItem[0]&&this.placeholder[intersection===1?"next":"prev"]()[0]!==itemElement&&!$.contains(this.placeholder[0],itemElement)&&(this.options.type==="semi-dynamic"?!$.contains(this.element[0],itemElement):true)){this.direction=intersection===1?"down":"up";if(this.options.tolerance==="pointer"||this._intersectsWithSides(item)){this._rearrange(event,item)}else{break}this._trigger("change",event,this._uiHash());break}}this._contactContainers(event);if($.ui.ddmanager){$.ui.ddmanager.drag(this,event)}this._trigger("sort",event,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(event,noPropagation){if(!event){return}if($.ui.ddmanager&&!this.options.dropBehaviour){$.ui.ddmanager.drop(this,event)}if(this.options.revert){var that=this,cur=this.placeholder.offset(),axis=this.options.axis,animation={};if(!axis||axis==="x"){animation.left=cur.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)}if(!axis||axis==="y"){animation.top=cur.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)}this.reverting=true;$(this.helper).animate(animation,parseInt(this.options.revert,10)||500,function(){that._clear(event)})}else{this._clear(event,noPropagation)}return false},cancel:function(){if(this.dragging){this._mouseUp({target:null});if(this.options.helper==="original"){this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else{this.currentItem.show()}for(var i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("deactivate",null,this._uiHash(this));if(this.containers[i].containerCache.over){this.containers[i]._trigger("out",null,this._uiHash(this));this.containers[i].containerCache.over=0}}}if(this.placeholder){if(this.placeholder[0].parentNode){this.placeholder[0].parentNode.removeChild(this.placeholder[0])}if(this.options.helper!=="original"&&this.helper&&this.helper[0].parentNode){this.helper.remove()}$.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});if(this.domPosition.prev){$(this.domPosition.prev).after(this.currentItem)}else{$(this.domPosition.parent).prepend(this.currentItem)}}return this},serialize:function(o){var items=this._getItemsAsjQuery(o&&o.connected),str=[];o=o||{};$(items).each(function(){var res=($(o.item||this).attr(o.attribute||"id")||"").match(o.expression||/(.+)[\-=_](.+)/);if(res){str.push((o.key||res[1]+"[]")+"="+(o.key&&o.expression?res[1]:res[2]))}});if(!str.length&&o.key){str.push(o.key+"=")}return str.join("&")},toArray:function(o){var items=this._getItemsAsjQuery(o&&o.connected),ret=[];o=o||{};items.each(function(){ret.push($(o.item||this).attr(o.attribute||"id")||"")});return ret},_intersectsWith:function(item){var x1=this.positionAbs.left,x2=x1+this.helperProportions.width,y1=this.positionAbs.top,y2=y1+this.helperProportions.height,l=item.left,r=l+item.width,t=item.top,b=t+item.height,dyClick=this.offset.click.top,dxClick=this.offset.click.left,isOverElementHeight=this.options.axis==="x"||y1+dyClick>t&&y1+dyClick<b,isOverElementWidth=this.options.axis==="y"||x1+dxClick>l&&x1+dxClick<r,isOverElement=isOverElementHeight&&isOverElementWidth;if(this.options.tolerance==="pointer"||this.options.forcePointerForContainers||this.options.tolerance!=="pointer"&&this.helperProportions[this.floating?"width":"height"]>item[this.floating?"width":"height"]){return isOverElement}else{return l<x1+this.helperProportions.width/2&&x2-this.helperProportions.width/2<r&&t<y1+this.helperProportions.height/2&&y2-this.helperProportions.height/2<b}},_intersectsWithPointer:function(item){var isOverElementHeight=this.options.axis==="x"||isOverAxis(this.positionAbs.top+this.offset.click.top,item.top,item.height),isOverElementWidth=this.options.axis==="y"||isOverAxis(this.positionAbs.left+this.offset.click.left,item.left,item.width),isOverElement=isOverElementHeight&&isOverElementWidth,verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(!isOverElement){return false}return this.floating?horizontalDirection&&horizontalDirection==="right"||verticalDirection==="down"?2:1:verticalDirection&&(verticalDirection==="down"?2:1)},_intersectsWithSides:function(item){var isOverBottomHalf=isOverAxis(this.positionAbs.top+this.offset.click.top,item.top+item.height/2,item.height),isOverRightHalf=isOverAxis(this.positionAbs.left+this.offset.click.left,item.left+item.width/2,item.width),verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(this.floating&&horizontalDirection){return horizontalDirection==="right"&&isOverRightHalf||horizontalDirection==="left"&&!isOverRightHalf}else{return verticalDirection&&(verticalDirection==="down"&&isOverBottomHalf||verticalDirection==="up"&&!isOverBottomHalf)}},_getDragVerticalDirection:function(){var delta=this.positionAbs.top-this.lastPositionAbs.top;return delta!==0&&(delta>0?"down":"up")},_getDragHorizontalDirection:function(){var delta=this.positionAbs.left-this.lastPositionAbs.left;return delta!==0&&(delta>0?"right":"left")},refresh:function(event){this._refreshItems(event);this.refreshPositions();return this},_connectWith:function(){var options=this.options;return options.connectWith.constructor===String?[options.connectWith]:options.connectWith},_getItemsAsjQuery:function(connected){var i,j,cur,inst,items=[],queries=[],connectWith=this._connectWith();if(connectWith&&connected){for(i=connectWith.length-1;i>=0;i--){cur=$(connectWith[i]);for(j=cur.length-1;j>=0;j--){inst=$.data(cur[j],this.widgetFullName);if(inst&&inst!==this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element):$(inst.options.items,inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),inst])}}}}queries.push([$.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):$(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);function addItems(){items.push(this)}for(i=queries.length-1;i>=0;i--){queries[i][0].each(addItems)}return $(items)},_removeCurrentsFromItems:function(){var list=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=$.grep(this.items,function(item){for(var j=0;j<list.length;j++){if(list[j]===item.item[0]){return false}}return true})},_refreshItems:function(event){this.items=[];this.containers=[this];var i,j,cur,inst,targetData,_queries,item,queriesLength,items=this.items,queries=[[$.isFunction(this.options.items)?this.options.items.call(this.element[0],event,{item:this.currentItem}):$(this.options.items,this.element),this]],connectWith=this._connectWith();if(connectWith&&this.ready){for(i=connectWith.length-1;i>=0;i--){cur=$(connectWith[i]);for(j=cur.length-1;j>=0;j--){inst=$.data(cur[j],this.widgetFullName);if(inst&&inst!==this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element[0],event,{item:this.currentItem}):$(inst.options.items,inst.element),inst]);this.containers.push(inst)}}}}for(i=queries.length-1;i>=0;i--){targetData=queries[i][1];_queries=queries[i][0];for(j=0,queriesLength=_queries.length;j<queriesLength;j++){item=$(_queries[j]);item.data(this.widgetName+"-item",targetData);items.push({item:item,instance:targetData,width:0,height:0,left:0,top:0})}}},refreshPositions:function(fast){if(this.offsetParent&&this.helper){this.offset.parent=this._getParentOffset()}var i,item,t,p;for(i=this.items.length-1;i>=0;i--){item=this.items[i];if(item.instance!==this.currentContainer&&this.currentContainer&&item.item[0]!==this.currentItem[0]){continue}t=this.options.toleranceElement?$(this.options.toleranceElement,item.item):item.item;if(!fast){item.width=t.outerWidth();item.height=t.outerHeight()}p=t.offset();item.left=p.left;item.top=p.top}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(i=this.containers.length-1;i>=0;i--){p=this.containers[i].element.offset();this.containers[i].containerCache.left=p.left;this.containers[i].containerCache.top=p.top;this.containers[i].containerCache.width=this.containers[i].element.outerWidth();this.containers[i].containerCache.height=this.containers[i].element.outerHeight()}}return this},_createPlaceholder:function(that){that=that||this;var className,o=that.options;if(!o.placeholder||o.placeholder.constructor===String){className=o.placeholder;o.placeholder={element:function(){var nodeName=that.currentItem[0].nodeName.toLowerCase(),element=$("<"+nodeName+">",that.document[0]).addClass(className||that.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");if(nodeName==="tr"){that.currentItem.children().each(function(){$("<td>&#160;</td>",that.document[0]).attr("colspan",$(this).attr("colspan")||1).appendTo(element)})}else if(nodeName==="img"){element.attr("src",that.currentItem.attr("src"))}if(!className){element.css("visibility","hidden")}return element},update:function(container,p){if(className&&!o.forcePlaceholderSize){return}if(!p.height()){p.height(that.currentItem.innerHeight()-parseInt(that.currentItem.css("paddingTop")||0,10)-parseInt(that.currentItem.css("paddingBottom")||0,10))}if(!p.width()){p.width(that.currentItem.innerWidth()-parseInt(that.currentItem.css("paddingLeft")||0,10)-parseInt(that.currentItem.css("paddingRight")||0,10))}}}}that.placeholder=$(o.placeholder.element.call(that.element,that.currentItem));that.currentItem.after(that.placeholder);o.placeholder.update(that,that.placeholder)},_contactContainers:function(event){var i,j,dist,itemWithLeastDistance,posProperty,sizeProperty,base,cur,nearBottom,floating,innermostContainer=null,innermostIndex=null;for(i=this.containers.length-1;i>=0;i--){if($.contains(this.currentItem[0],this.containers[i].element[0])){continue}if(this._intersectsWith(this.containers[i].containerCache)){if(innermostContainer&&$.contains(this.containers[i].element[0],innermostContainer.element[0])){continue}innermostContainer=this.containers[i];innermostIndex=i}else{if(this.containers[i].containerCache.over){
13
+ this.containers[i]._trigger("out",event,this._uiHash(this));this.containers[i].containerCache.over=0}}}if(!innermostContainer){return}if(this.containers.length===1){if(!this.containers[innermostIndex].containerCache.over){this.containers[innermostIndex]._trigger("over",event,this._uiHash(this));this.containers[innermostIndex].containerCache.over=1}}else{dist=1e4;itemWithLeastDistance=null;floating=innermostContainer.floating||isFloating(this.currentItem);posProperty=floating?"left":"top";sizeProperty=floating?"width":"height";base=this.positionAbs[posProperty]+this.offset.click[posProperty];for(j=this.items.length-1;j>=0;j--){if(!$.contains(this.containers[innermostIndex].element[0],this.items[j].item[0])){continue}if(this.items[j].item[0]===this.currentItem[0]){continue}if(floating&&!isOverAxis(this.positionAbs.top+this.offset.click.top,this.items[j].top,this.items[j].height)){continue}cur=this.items[j].item.offset()[posProperty];nearBottom=false;if(Math.abs(cur-base)>Math.abs(cur+this.items[j][sizeProperty]-base)){nearBottom=true;cur+=this.items[j][sizeProperty]}if(Math.abs(cur-base)<dist){dist=Math.abs(cur-base);itemWithLeastDistance=this.items[j];this.direction=nearBottom?"up":"down"}}if(!itemWithLeastDistance&&!this.options.dropOnEmpty){return}if(this.currentContainer===this.containers[innermostIndex]){return}itemWithLeastDistance?this._rearrange(event,itemWithLeastDistance,null,true):this._rearrange(event,null,this.containers[innermostIndex].element,true);this._trigger("change",event,this._uiHash());this.containers[innermostIndex]._trigger("change",event,this._uiHash(this));this.currentContainer=this.containers[innermostIndex];this.options.placeholder.update(this.currentContainer,this.placeholder);this.containers[innermostIndex]._trigger("over",event,this._uiHash(this));this.containers[innermostIndex].containerCache.over=1}},_createHelper:function(event){var o=this.options,helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event,this.currentItem])):o.helper==="clone"?this.currentItem.clone():this.currentItem;if(!helper.parents("body").length){$(o.appendTo!=="parent"?o.appendTo:this.currentItem[0].parentNode)[0].appendChild(helper[0])}if(helper[0]===this.currentItem[0]){this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}}if(!helper[0].style.width||o.forceHelperSize){helper.width(this.currentItem.width())}if(!helper[0].style.height||o.forceHelperSize){helper.height(this.currentItem.height())}return helper},_adjustOffsetFromHelper:function(obj){if(typeof obj==="string"){obj=obj.split(" ")}if($.isArray(obj)){obj={left:+obj[0],top:+obj[1]||0}}if("left"in obj){this.offset.click.left=obj.left+this.margins.left}if("right"in obj){this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left}if("top"in obj){this.offset.click.top=obj.top+this.margins.top}if("bottom"in obj){this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition==="absolute"&&this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()==="html"&&$.ui.ie){po={top:0,left:0}}return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==="relative"){var p=this.currentItem.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var ce,co,over,o=this.options;if(o.containment==="parent"){o.containment=this.helper[0].parentNode}if(o.containment==="document"||o.containment==="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment==="document"?document:window).width()-this.helperProportions.width-this.margins.left,($(o.containment==="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!/^(document|window|parent)$/.test(o.containment)){ce=$(o.containment)[0];co=$(o.containment).offset();over=$(ce).css("overflow")!=="hidden";this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,co.left+(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-(parseInt($(ce).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,co.top+(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-(parseInt($(ce).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(d,pos){if(!pos){pos=this.position}var mod=d==="absolute"?1:-1,scroll=this.cssPosition==="absolute"&&!(this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=/(html|body)/i.test(scroll[0].tagName);return{top:pos.top+this.offset.relative.top*mod+this.offset.parent.top*mod-(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():scrollIsRootNode?0:scroll.scrollTop())*mod,left:pos.left+this.offset.relative.left*mod+this.offset.parent.left*mod-(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod}},_generatePosition:function(event){var top,left,o=this.options,pageX=event.pageX,pageY=event.pageY,scroll=this.cssPosition==="absolute"&&!(this.scrollParent[0]!==document&&$.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=/(html|body)/i.test(scroll[0].tagName);if(this.cssPosition==="relative"&&!(this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0])){this.offset.relative=this._getRelativeOffset()}if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0]){pageX=this.containment[0]+this.offset.click.left}if(event.pageY-this.offset.click.top<this.containment[1]){pageY=this.containment[1]+this.offset.click.top}if(event.pageX-this.offset.click.left>this.containment[2]){pageX=this.containment[2]+this.offset.click.left}if(event.pageY-this.offset.click.top>this.containment[3]){pageY=this.containment[3]+this.offset.click.top}}if(o.grid){top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];pageY=this.containment?top-this.offset.click.top>=this.containment[1]&&top-this.offset.click.top<=this.containment[3]?top:top-this.offset.click.top>=this.containment[1]?top-o.grid[1]:top+o.grid[1]:top;left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];pageX=this.containment?left-this.offset.click.left>=this.containment[0]&&left-this.offset.click.left<=this.containment[2]?left:left-this.offset.click.left>=this.containment[0]?left-o.grid[0]:left+o.grid[0]:left}}return{top:pageY-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():scrollIsRootNode?0:scroll.scrollTop()),left:pageX-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())}},_rearrange:function(event,i,a,hardRefresh){a?a[0].appendChild(this.placeholder[0]):i.item[0].parentNode.insertBefore(this.placeholder[0],this.direction==="down"?i.item[0]:i.item[0].nextSibling);this.counter=this.counter?++this.counter:1;var counter=this.counter;this._delay(function(){if(counter===this.counter){this.refreshPositions(!hardRefresh)}})},_clear:function(event,noPropagation){this.reverting=false;var i,delayedTriggers=[];if(!this._noFinalSort&&this.currentItem.parent().length){this.placeholder.before(this.currentItem)}this._noFinalSort=null;if(this.helper[0]===this.currentItem[0]){for(i in this._storedCSS){if(this._storedCSS[i]==="auto"||this._storedCSS[i]==="static"){this._storedCSS[i]=""}}this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else{this.currentItem.show()}if(this.fromOutside&&!noPropagation){delayedTriggers.push(function(event){this._trigger("receive",event,this._uiHash(this.fromOutside))})}if((this.fromOutside||this.domPosition.prev!==this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!==this.currentItem.parent()[0])&&!noPropagation){delayedTriggers.push(function(event){this._trigger("update",event,this._uiHash())})}if(this!==this.currentContainer){if(!noPropagation){delayedTriggers.push(function(event){this._trigger("remove",event,this._uiHash())});delayedTriggers.push(function(c){return function(event){c._trigger("receive",event,this._uiHash(this))}}.call(this,this.currentContainer));delayedTriggers.push(function(c){return function(event){c._trigger("update",event,this._uiHash(this))}}.call(this,this.currentContainer))}}function delayEvent(type,instance,container){return function(event){container._trigger(type,event,instance._uiHash(instance))}}for(i=this.containers.length-1;i>=0;i--){if(!noPropagation){delayedTriggers.push(delayEvent("deactivate",this,this.containers[i]))}if(this.containers[i].containerCache.over){delayedTriggers.push(delayEvent("out",this,this.containers[i]));this.containers[i].containerCache.over=0}}if(this.storedCursor){this.document.find("body").css("cursor",this.storedCursor);this.storedStylesheet.remove()}if(this._storedOpacity){this.helper.css("opacity",this._storedOpacity)}if(this._storedZIndex){this.helper.css("zIndex",this._storedZIndex==="auto"?"":this._storedZIndex)}this.dragging=false;if(this.cancelHelperRemoval){if(!noPropagation){this._trigger("beforeStop",event,this._uiHash());for(i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event)}this._trigger("stop",event,this._uiHash())}this.fromOutside=false;return false}if(!noPropagation){this._trigger("beforeStop",event,this._uiHash())}this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(this.helper[0]!==this.currentItem[0]){this.helper.remove()}this.helper=null;if(!noPropagation){for(i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event)}this._trigger("stop",event,this._uiHash())}this.fromOutside=false;return true},_trigger:function(){if($.Widget.prototype._trigger.apply(this,arguments)===false){this.cancel()}},_uiHash:function(_inst){var inst=_inst||this;return{helper:inst.helper,placeholder:inst.placeholder||$([]),position:inst.position,originalPosition:inst.originalPosition,offset:inst.positionAbs,item:inst.currentItem,sender:_inst?_inst.element:null}}})})(jQuery)},{"./core":231,"./mouse":233,"./widget":236,jquery:237}],236:[function(require,module,exports){var jQuery=require("jquery");(function($,undefined){var uuid=0,slice=Array.prototype.slice,_cleanData=$.cleanData;$.cleanData=function(elems){for(var i=0,elem;(elem=elems[i])!=null;i++){try{$(elem).triggerHandler("remove")}catch(e){}}_cleanData(elems)};$.widget=function(name,base,prototype){var fullName,existingConstructor,constructor,basePrototype,proxiedPrototype={},namespace=name.split(".")[0];name=name.split(".")[1];fullName=namespace+"-"+name;if(!prototype){prototype=base;base=$.Widget}$.expr[":"][fullName.toLowerCase()]=function(elem){return!!$.data(elem,fullName)};$[namespace]=$[namespace]||{};existingConstructor=$[namespace][name];constructor=$[namespace][name]=function(options,element){if(!this._createWidget){return new constructor(options,element)}if(arguments.length){this._createWidget(options,element)}};$.extend(constructor,existingConstructor,{version:prototype.version,_proto:$.extend({},prototype),_childConstructors:[]});basePrototype=new base;basePrototype.options=$.widget.extend({},basePrototype.options);$.each(prototype,function(prop,value){if(!$.isFunction(value)){proxiedPrototype[prop]=value;return}proxiedPrototype[prop]=function(){var _super=function(){return base.prototype[prop].apply(this,arguments)},_superApply=function(args){return base.prototype[prop].apply(this,args)};return function(){var __super=this._super,__superApply=this._superApply,returnValue;this._super=_super;this._superApply=_superApply;returnValue=value.apply(this,arguments);this._super=__super;this._superApply=__superApply;return returnValue}}()});constructor.prototype=$.widget.extend(basePrototype,{widgetEventPrefix:existingConstructor?basePrototype.widgetEventPrefix||name:name},proxiedPrototype,{constructor:constructor,namespace:namespace,widgetName:name,widgetFullName:fullName});if(existingConstructor){$.each(existingConstructor._childConstructors,function(i,child){var childPrototype=child.prototype;$.widget(childPrototype.namespace+"."+childPrototype.widgetName,constructor,child._proto)});delete existingConstructor._childConstructors}else{base._childConstructors.push(constructor)}$.widget.bridge(name,constructor)};$.widget.extend=function(target){var input=slice.call(arguments,1),inputIndex=0,inputLength=input.length,key,value;for(;inputIndex<inputLength;inputIndex++){for(key in input[inputIndex]){value=input[inputIndex][key];if(input[inputIndex].hasOwnProperty(key)&&value!==undefined){if($.isPlainObject(value)){target[key]=$.isPlainObject(target[key])?$.widget.extend({},target[key],value):$.widget.extend({},value)}else{target[key]=value}}}}return target};$.widget.bridge=function(name,object){var fullName=object.prototype.widgetFullName||name;$.fn[name]=function(options){var isMethodCall=typeof options==="string",args=slice.call(arguments,1),returnValue=this;options=!isMethodCall&&args.length?$.widget.extend.apply(null,[options].concat(args)):options;if(isMethodCall){this.each(function(){var methodValue,instance=$.data(this,fullName);if(!instance){return $.error("cannot call methods on "+name+" prior to initialization; "+"attempted to call method '"+options+"'")}if(!$.isFunction(instance[options])||options.charAt(0)==="_"){return $.error("no such method '"+options+"' for "+name+" widget instance")}methodValue=instance[options].apply(instance,args);if(methodValue!==instance&&methodValue!==undefined){returnValue=methodValue&&methodValue.jquery?returnValue.pushStack(methodValue.get()):methodValue;return false}})}else{this.each(function(){var instance=$.data(this,fullName);if(instance){instance.option(options||{})._init()}else{$.data(this,fullName,new object(options,this))}})}return returnValue}};$.Widget=function(){};$.Widget._childConstructors=[];$.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:false,create:null},_createWidget:function(options,element){element=$(element||this.defaultElement||this)[0];this.element=$(element);this.uuid=uuid++;this.eventNamespace="."+this.widgetName+this.uuid;this.options=$.widget.extend({},this.options,this._getCreateOptions(),options);this.bindings=$();this.hoverable=$();this.focusable=$();if(element!==this){$.data(element,this.widgetFullName,this);this._on(true,this.element,{remove:function(event){if(event.target===element){this.destroy()}}});this.document=$(element.style?element.ownerDocument:element.document||element);this.window=$(this.document[0].defaultView||this.document[0].parentWindow)}this._create();this._trigger("create",null,this._getCreateEventData());this._init()},_getCreateOptions:$.noop,_getCreateEventData:$.noop,_create:$.noop,_init:$.noop,destroy:function(){this._destroy();this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData($.camelCase(this.widgetFullName));this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled");this.bindings.unbind(this.eventNamespace);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus")},_destroy:$.noop,widget:function(){return this.element},option:function(key,value){var options=key,parts,curOption,i;if(arguments.length===0){return $.widget.extend({},this.options)}if(typeof key==="string"){options={};parts=key.split(".");key=parts.shift();if(parts.length){curOption=options[key]=$.widget.extend({},this.options[key]);for(i=0;i<parts.length-1;i++){curOption[parts[i]]=curOption[parts[i]]||{};curOption=curOption[parts[i]]}key=parts.pop();if(arguments.length===1){return curOption[key]===undefined?null:curOption[key]}curOption[key]=value}else{if(arguments.length===1){return this.options[key]===undefined?null:this.options[key]}options[key]=value}}this._setOptions(options);return this},_setOptions:function(options){var key;for(key in options){this._setOption(key,options[key])}return this},_setOption:function(key,value){this.options[key]=value;if(key==="disabled"){this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!value).attr("aria-disabled",value);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus")}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_on:function(suppressDisabledCheck,element,handlers){var delegateElement,instance=this;if(typeof suppressDisabledCheck!=="boolean"){handlers=element;element=suppressDisabledCheck;suppressDisabledCheck=false}if(!handlers){handlers=element;element=this.element;delegateElement=this.widget()}else{element=delegateElement=$(element);this.bindings=this.bindings.add(element)}$.each(handlers,function(event,handler){function handlerProxy(){if(!suppressDisabledCheck&&(instance.options.disabled===true||$(this).hasClass("ui-state-disabled"))){return}return(typeof handler==="string"?instance[handler]:handler).apply(instance,arguments)}if(typeof handler!=="string"){handlerProxy.guid=handler.guid=handler.guid||handlerProxy.guid||$.guid++}var match=event.match(/^(\w+)\s*(.*)$/),eventName=match[1]+instance.eventNamespace,selector=match[2];if(selector){delegateElement.delegate(selector,eventName,handlerProxy)}else{element.bind(eventName,handlerProxy)}})},_off:function(element,eventName){eventName=(eventName||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace;element.unbind(eventName).undelegate(eventName)},_delay:function(handler,delay){function handlerProxy(){return(typeof handler==="string"?instance[handler]:handler).apply(instance,arguments)}var instance=this;return setTimeout(handlerProxy,delay||0)},_hoverable:function(element){this.hoverable=this.hoverable.add(element);this._on(element,{mouseenter:function(event){$(event.currentTarget).addClass("ui-state-hover")},mouseleave:function(event){$(event.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(element){this.focusable=this.focusable.add(element);this._on(element,{focusin:function(event){$(event.currentTarget).addClass("ui-state-focus")},focusout:function(event){$(event.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(type,event,data){var prop,orig,callback=this.options[type];data=data||{};event=$.Event(event);event.type=(type===this.widgetEventPrefix?type:this.widgetEventPrefix+type).toLowerCase();event.target=this.element[0];orig=event.originalEvent;if(orig){for(prop in orig){if(!(prop in event)){event[prop]=orig[prop]}}}this.element.trigger(event,data);return!($.isFunction(callback)&&callback.apply(this.element[0],[event].concat(data))===false||event.isDefaultPrevented())}};$.each({show:"fadeIn",hide:"fadeOut"},function(method,defaultEffect){$.Widget.prototype["_"+method]=function(element,options,callback){if(typeof options==="string"){options={effect:options}}var hasOptions,effectName=!options?method:options===true||typeof options==="number"?defaultEffect:options.effect||defaultEffect;options=options||{};if(typeof options==="number"){options={duration:options}}hasOptions=!$.isEmptyObject(options);options.complete=callback;if(options.delay){element.delay(options.delay)}if(hasOptions&&$.effects&&$.effects.effect[effectName]){element[method](options)}else if(effectName!==method&&element[effectName]){element[effectName](options.duration,options.easing,callback)}else{element.queue(function(next){$(this)[method]();if(callback){callback.call(element[0])}next()})}}})})(jQuery)},{jquery:237}],237:[function(require,module,exports){(function(global,factory){if(typeof module==="object"&&typeof module.exports==="object"){module.exports=global.document?factory(global,true):function(w){if(!w.document){throw new Error("jQuery requires a window with a document")}return factory(w)}}else{factory(global)}})(typeof window!=="undefined"?window:this,function(window,noGlobal){var deletedIds=[];var slice=deletedIds.slice;var concat=deletedIds.concat;var push=deletedIds.push;var indexOf=deletedIds.indexOf;var class2type={};var toString=class2type.toString;var hasOwn=class2type.hasOwnProperty;var support={};var version="1.11.3",jQuery=function(selector,context){return new jQuery.fn.init(selector,context)},rtrim=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,rmsPrefix=/^-ms-/,rdashAlpha=/-([\da-z])/gi,fcamelCase=function(all,letter){return letter.toUpperCase()};jQuery.fn=jQuery.prototype={jquery:version,constructor:jQuery,selector:"",length:0,toArray:function(){return slice.call(this)},get:function(num){return num!=null?num<0?this[num+this.length]:this[num]:slice.call(this)},pushStack:function(elems){var ret=jQuery.merge(this.constructor(),elems);ret.prevObject=this;ret.context=this.context;return ret},each:function(callback,args){return jQuery.each(this,callback,args)},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem)}))},slice:function(){return this.pushStack(slice.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(i){var len=this.length,j=+i+(i<0?len:0);return this.pushStack(j>=0&&j<len?[this[j]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:push,sort:deletedIds.sort,splice:deletedIds.splice};jQuery.extend=jQuery.fn.extend=function(){var src,copyIsArray,copy,name,options,clone,target=arguments[0]||{},i=1,length=arguments.length,deep=false;if(typeof target==="boolean"){deep=target;target=arguments[i]||{};i++}if(typeof target!=="object"&&!jQuery.isFunction(target)){target={}}if(i===length){target=this;i--}for(;i<length;i++){if((options=arguments[i])!=null){for(name in options){src=target[name];copy=options[name];if(target===copy){continue}if(deep&&copy&&(jQuery.isPlainObject(copy)||(copyIsArray=jQuery.isArray(copy)))){if(copyIsArray){copyIsArray=false;clone=src&&jQuery.isArray(src)?src:[]}else{clone=src&&jQuery.isPlainObject(src)?src:{}}target[name]=jQuery.extend(deep,clone,copy)}else if(copy!==undefined){target[name]=copy}}}}return target};jQuery.extend({expando:"jQuery"+(version+Math.random()).replace(/\D/g,""),isReady:true,error:function(msg){throw new Error(msg)},noop:function(){},isFunction:function(obj){return jQuery.type(obj)==="function"},isArray:Array.isArray||function(obj){return jQuery.type(obj)==="array"},isWindow:function(obj){return obj!=null&&obj==obj.window},isNumeric:function(obj){return!jQuery.isArray(obj)&&obj-parseFloat(obj)+1>=0},isEmptyObject:function(obj){var name;for(name in obj){return false}return true},isPlainObject:function(obj){var key;if(!obj||jQuery.type(obj)!=="object"||obj.nodeType||jQuery.isWindow(obj)){return false}try{if(obj.constructor&&!hasOwn.call(obj,"constructor")&&!hasOwn.call(obj.constructor.prototype,"isPrototypeOf")){return false}}catch(e){return false}if(support.ownLast){for(key in obj){return hasOwn.call(obj,key)}}for(key in obj){}return key===undefined||hasOwn.call(obj,key)},type:function(obj){if(obj==null){return obj+""}return typeof obj==="object"||typeof obj==="function"?class2type[toString.call(obj)]||"object":typeof obj},globalEval:function(data){if(data&&jQuery.trim(data)){(window.execScript||function(data){window["eval"].call(window,data)})(data)}},camelCase:function(string){return string.replace(rmsPrefix,"ms-").replace(rdashAlpha,fcamelCase)},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toLowerCase()===name.toLowerCase()},each:function(obj,callback,args){var value,i=0,length=obj.length,isArray=isArraylike(obj);if(args){if(isArray){for(;i<length;i++){value=callback.apply(obj[i],args);if(value===false){break}}}else{for(i in obj){value=callback.apply(obj[i],args);if(value===false){break}}}}else{if(isArray){for(;i<length;i++){value=callback.call(obj[i],i,obj[i]);if(value===false){break}}}else{for(i in obj){value=callback.call(obj[i],i,obj[i]);if(value===false){break}}}}return obj},trim:function(text){return text==null?"":(text+"").replace(rtrim,"")},makeArray:function(arr,results){var ret=results||[];if(arr!=null){if(isArraylike(Object(arr))){jQuery.merge(ret,typeof arr==="string"?[arr]:arr)}else{push.call(ret,arr)}}return ret},inArray:function(elem,arr,i){var len;if(arr){if(indexOf){return indexOf.call(arr,elem,i)}len=arr.length;i=i?i<0?Math.max(0,len+i):i:0;for(;i<len;i++){if(i in arr&&arr[i]===elem){return i}}}return-1},merge:function(first,second){var len=+second.length,j=0,i=first.length;while(j<len){first[i++]=second[j++]}if(len!==len){while(second[j]!==undefined){first[i++]=second[j++]}}first.length=i;return first},grep:function(elems,callback,invert){var callbackInverse,matches=[],i=0,length=elems.length,callbackExpect=!invert;for(;i<length;i++){callbackInverse=!callback(elems[i],i);if(callbackInverse!==callbackExpect){matches.push(elems[i])}}return matches},map:function(elems,callback,arg){var value,i=0,length=elems.length,isArray=isArraylike(elems),ret=[];if(isArray){for(;i<length;i++){value=callback(elems[i],i,arg);if(value!=null){ret.push(value)}}}else{for(i in elems){value=callback(elems[i],i,arg);if(value!=null){ret.push(value)}}}return concat.apply([],ret)},guid:1,proxy:function(fn,context){var args,proxy,tmp;if(typeof context==="string"){tmp=fn[context];context=fn;fn=tmp}if(!jQuery.isFunction(fn)){return undefined}args=slice.call(arguments,2);proxy=function(){return fn.apply(context||this,args.concat(slice.call(arguments)))};proxy.guid=fn.guid=fn.guid||jQuery.guid++;return proxy},now:function(){return+new Date},support:support});jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(i,name){class2type["[object "+name+"]"]=name.toLowerCase()});function isArraylike(obj){var length="length"in obj&&obj.length,type=jQuery.type(obj);if(type==="function"||jQuery.isWindow(obj)){return false}if(obj.nodeType===1&&length){return true}return type==="array"||length===0||typeof length==="number"&&length>0&&length-1 in obj}var Sizzle=function(window){var i,support,Expr,getText,isXML,tokenize,compile,select,outermostContext,sortInput,hasDuplicate,setDocument,document,docElem,documentIsHTML,rbuggyQSA,rbuggyMatches,matches,contains,expando="sizzle"+1*new Date,preferredDoc=window.document,dirruns=0,done=0,classCache=createCache(),tokenCache=createCache(),compilerCache=createCache(),sortOrder=function(a,b){if(a===b){hasDuplicate=true}return 0},MAX_NEGATIVE=1<<31,hasOwn={}.hasOwnProperty,arr=[],pop=arr.pop,push_native=arr.push,push=arr.push,slice=arr.slice,indexOf=function(list,elem){var i=0,len=list.length;for(;i<len;i++){if(list[i]===elem){return i}}return-1},booleans="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",whitespace="[\\x20\\t\\r\\n\\f]",characterEncoding="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",identifier=characterEncoding.replace("w","w#"),attributes="\\["+whitespace+"*("+characterEncoding+")(?:"+whitespace+"*([*^$|!~]?=)"+whitespace+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+identifier+"))|)"+whitespace+"*\\]",pseudos=":("+characterEncoding+")(?:\\(("+"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|"+"((?:\\\\.|[^\\\\()[\\]]|"+attributes+")*)|"+".*"+")\\)|)",rwhitespace=new RegExp(whitespace+"+","g"),rtrim=new RegExp("^"+whitespace+"+|((?:^|[^\\\\])(?:\\\\.)*)"+whitespace+"+$","g"),rcomma=new RegExp("^"+whitespace+"*,"+whitespace+"*"),rcombinators=new RegExp("^"+whitespace+"*([>+~]|"+whitespace+")"+whitespace+"*"),rattributeQuotes=new RegExp("="+whitespace+"*([^\\]'\"]*?)"+whitespace+"*\\]","g"),rpseudo=new RegExp(pseudos),ridentifier=new RegExp("^"+identifier+"$"),matchExpr={ID:new RegExp("^#("+characterEncoding+")"),CLASS:new RegExp("^\\.("+characterEncoding+")"),TAG:new RegExp("^("+characterEncoding.replace("w","w*")+")"),ATTR:new RegExp("^"+attributes),PSEUDO:new RegExp("^"+pseudos),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+whitespace+"*(even|odd|(([+-]|)(\\d*)n|)"+whitespace+"*(?:([+-]|)"+whitespace+"*(\\d+)|))"+whitespace+"*\\)|)","i"),bool:new RegExp("^(?:"+booleans+")$","i"),needsContext:new RegExp("^"+whitespace+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+whitespace+"*((?:-\\d)?\\d*)"+whitespace+"*\\)|)(?=[^-]|$)","i")},rinputs=/^(?:input|select|textarea|button)$/i,rheader=/^h\d$/i,rnative=/^[^{]+\{\s*\[native \w/,rquickExpr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,rsibling=/[+~]/,rescape=/'|\\/g,runescape=new RegExp("\\\\([\\da-f]{1,6}"+whitespace+"?|("+whitespace+")|.)","ig"),funescape=function(_,escaped,escapedWhitespace){var high="0x"+escaped-65536;return high!==high||escapedWhitespace?escaped:high<0?String.fromCharCode(high+65536):String.fromCharCode(high>>10|55296,high&1023|56320)},unloadHandler=function(){setDocument()};try{push.apply(arr=slice.call(preferredDoc.childNodes),preferredDoc.childNodes);arr[preferredDoc.childNodes.length].nodeType}catch(e){push={apply:arr.length?function(target,els){push_native.apply(target,slice.call(els))}:function(target,els){var j=target.length,i=0;while(target[j++]=els[i++]){}target.length=j-1}}}function Sizzle(selector,context,results,seed){var match,elem,m,nodeType,i,groups,old,nid,newContext,newSelector;if((context?context.ownerDocument||context:preferredDoc)!==document){setDocument(context)}context=context||document;results=results||[];nodeType=context.nodeType;if(typeof selector!=="string"||!selector||nodeType!==1&&nodeType!==9&&nodeType!==11){return results}if(!seed&&documentIsHTML){if(nodeType!==11&&(match=rquickExpr.exec(selector))){if(m=match[1]){if(nodeType===9){elem=context.getElementById(m);if(elem&&elem.parentNode){if(elem.id===m){results.push(elem);return results}}else{return results}}else{if(context.ownerDocument&&(elem=context.ownerDocument.getElementById(m))&&contains(context,elem)&&elem.id===m){results.push(elem);return results}}}else if(match[2]){push.apply(results,context.getElementsByTagName(selector));return results}else if((m=match[3])&&support.getElementsByClassName){push.apply(results,context.getElementsByClassName(m));return results}}if(support.qsa&&(!rbuggyQSA||!rbuggyQSA.test(selector))){nid=old=expando;newContext=context;newSelector=nodeType!==1&&selector;if(nodeType===1&&context.nodeName.toLowerCase()!=="object"){groups=tokenize(selector);if(old=context.getAttribute("id")){nid=old.replace(rescape,"\\$&")}else{context.setAttribute("id",nid)}nid="[id='"+nid+"'] ";i=groups.length;while(i--){groups[i]=nid+toSelector(groups[i])}newContext=rsibling.test(selector)&&testContext(context.parentNode)||context;
14
 
15
+ newSelector=groups.join(",")}if(newSelector){try{push.apply(results,newContext.querySelectorAll(newSelector));return results}catch(qsaError){}finally{if(!old){context.removeAttribute("id")}}}}}return select(selector.replace(rtrim,"$1"),context,results,seed)}function createCache(){var keys=[];function cache(key,value){if(keys.push(key+" ")>Expr.cacheLength){delete cache[keys.shift()]}return cache[key+" "]=value}return cache}function markFunction(fn){fn[expando]=true;return fn}function assert(fn){var div=document.createElement("div");try{return!!fn(div)}catch(e){return false}finally{if(div.parentNode){div.parentNode.removeChild(div)}div=null}}function addHandle(attrs,handler){var arr=attrs.split("|"),i=attrs.length;while(i--){Expr.attrHandle[arr[i]]=handler}}function siblingCheck(a,b){var cur=b&&a,diff=cur&&a.nodeType===1&&b.nodeType===1&&(~b.sourceIndex||MAX_NEGATIVE)-(~a.sourceIndex||MAX_NEGATIVE);if(diff){return diff}if(cur){while(cur=cur.nextSibling){if(cur===b){return-1}}}return a?1:-1}function createInputPseudo(type){return function(elem){var name=elem.nodeName.toLowerCase();return name==="input"&&elem.type===type}}function createButtonPseudo(type){return function(elem){var name=elem.nodeName.toLowerCase();return(name==="input"||name==="button")&&elem.type===type}}function createPositionalPseudo(fn){return markFunction(function(argument){argument=+argument;return markFunction(function(seed,matches){var j,matchIndexes=fn([],seed.length,argument),i=matchIndexes.length;while(i--){if(seed[j=matchIndexes[i]]){seed[j]=!(matches[j]=seed[j])}}})})}function testContext(context){return context&&typeof context.getElementsByTagName!=="undefined"&&context}support=Sizzle.support={};isXML=Sizzle.isXML=function(elem){var documentElement=elem&&(elem.ownerDocument||elem).documentElement;return documentElement?documentElement.nodeName!=="HTML":false};setDocument=Sizzle.setDocument=function(node){var hasCompare,parent,doc=node?node.ownerDocument||node:preferredDoc;if(doc===document||doc.nodeType!==9||!doc.documentElement){return document}document=doc;docElem=doc.documentElement;parent=doc.defaultView;if(parent&&parent!==parent.top){if(parent.addEventListener){parent.addEventListener("unload",unloadHandler,false)}else if(parent.attachEvent){parent.attachEvent("onunload",unloadHandler)}}documentIsHTML=!isXML(doc);support.attributes=assert(function(div){div.className="i";return!div.getAttribute("className")});support.getElementsByTagName=assert(function(div){div.appendChild(doc.createComment(""));return!div.getElementsByTagName("*").length});support.getElementsByClassName=rnative.test(doc.getElementsByClassName);support.getById=assert(function(div){docElem.appendChild(div).id=expando;return!doc.getElementsByName||!doc.getElementsByName(expando).length});if(support.getById){Expr.find["ID"]=function(id,context){if(typeof context.getElementById!=="undefined"&&documentIsHTML){var m=context.getElementById(id);return m&&m.parentNode?[m]:[]}};Expr.filter["ID"]=function(id){var attrId=id.replace(runescape,funescape);return function(elem){return elem.getAttribute("id")===attrId}}}else{delete Expr.find["ID"];Expr.filter["ID"]=function(id){var attrId=id.replace(runescape,funescape);return function(elem){var node=typeof elem.getAttributeNode!=="undefined"&&elem.getAttributeNode("id");return node&&node.value===attrId}}}Expr.find["TAG"]=support.getElementsByTagName?function(tag,context){if(typeof context.getElementsByTagName!=="undefined"){return context.getElementsByTagName(tag)}else if(support.qsa){return context.querySelectorAll(tag)}}:function(tag,context){var elem,tmp=[],i=0,results=context.getElementsByTagName(tag);if(tag==="*"){while(elem=results[i++]){if(elem.nodeType===1){tmp.push(elem)}}return tmp}return results};Expr.find["CLASS"]=support.getElementsByClassName&&function(className,context){if(documentIsHTML){return context.getElementsByClassName(className)}};rbuggyMatches=[];rbuggyQSA=[];if(support.qsa=rnative.test(doc.querySelectorAll)){assert(function(div){docElem.appendChild(div).innerHTML="<a id='"+expando+"'></a>"+"<select id='"+expando+"-\f]' msallowcapture=''>"+"<option selected=''></option></select>";if(div.querySelectorAll("[msallowcapture^='']").length){rbuggyQSA.push("[*^$]="+whitespace+"*(?:''|\"\")")}if(!div.querySelectorAll("[selected]").length){rbuggyQSA.push("\\["+whitespace+"*(?:value|"+booleans+")")}if(!div.querySelectorAll("[id~="+expando+"-]").length){rbuggyQSA.push("~=")}if(!div.querySelectorAll(":checked").length){rbuggyQSA.push(":checked")}if(!div.querySelectorAll("a#"+expando+"+*").length){rbuggyQSA.push(".#.+[+~]")}});assert(function(div){var input=doc.createElement("input");input.setAttribute("type","hidden");div.appendChild(input).setAttribute("name","D");if(div.querySelectorAll("[name=d]").length){rbuggyQSA.push("name"+whitespace+"*[*^$|!~]?=")}if(!div.querySelectorAll(":enabled").length){rbuggyQSA.push(":enabled",":disabled")}div.querySelectorAll("*,:x");rbuggyQSA.push(",.*:")})}if(support.matchesSelector=rnative.test(matches=docElem.matches||docElem.webkitMatchesSelector||docElem.mozMatchesSelector||docElem.oMatchesSelector||docElem.msMatchesSelector)){assert(function(div){support.disconnectedMatch=matches.call(div,"div");matches.call(div,"[s!='']:x");rbuggyMatches.push("!=",pseudos)})}rbuggyQSA=rbuggyQSA.length&&new RegExp(rbuggyQSA.join("|"));rbuggyMatches=rbuggyMatches.length&&new RegExp(rbuggyMatches.join("|"));hasCompare=rnative.test(docElem.compareDocumentPosition);contains=hasCompare||rnative.test(docElem.contains)?function(a,b){var adown=a.nodeType===9?a.documentElement:a,bup=b&&b.parentNode;return a===bup||!!(bup&&bup.nodeType===1&&(adown.contains?adown.contains(bup):a.compareDocumentPosition&&a.compareDocumentPosition(bup)&16))}:function(a,b){if(b){while(b=b.parentNode){if(b===a){return true}}}return false};sortOrder=hasCompare?function(a,b){if(a===b){hasDuplicate=true;return 0}var compare=!a.compareDocumentPosition-!b.compareDocumentPosition;if(compare){return compare}compare=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1;if(compare&1||!support.sortDetached&&b.compareDocumentPosition(a)===compare){if(a===doc||a.ownerDocument===preferredDoc&&contains(preferredDoc,a)){return-1}if(b===doc||b.ownerDocument===preferredDoc&&contains(preferredDoc,b)){return 1}return sortInput?indexOf(sortInput,a)-indexOf(sortInput,b):0}return compare&4?-1:1}:function(a,b){if(a===b){hasDuplicate=true;return 0}var cur,i=0,aup=a.parentNode,bup=b.parentNode,ap=[a],bp=[b];if(!aup||!bup){return a===doc?-1:b===doc?1:aup?-1:bup?1:sortInput?indexOf(sortInput,a)-indexOf(sortInput,b):0}else if(aup===bup){return siblingCheck(a,b)}cur=a;while(cur=cur.parentNode){ap.unshift(cur)}cur=b;while(cur=cur.parentNode){bp.unshift(cur)}while(ap[i]===bp[i]){i++}return i?siblingCheck(ap[i],bp[i]):ap[i]===preferredDoc?-1:bp[i]===preferredDoc?1:0};return doc};Sizzle.matches=function(expr,elements){return Sizzle(expr,null,null,elements)};Sizzle.matchesSelector=function(elem,expr){if((elem.ownerDocument||elem)!==document){setDocument(elem)}expr=expr.replace(rattributeQuotes,"='$1']");if(support.matchesSelector&&documentIsHTML&&(!rbuggyMatches||!rbuggyMatches.test(expr))&&(!rbuggyQSA||!rbuggyQSA.test(expr))){try{var ret=matches.call(elem,expr);if(ret||support.disconnectedMatch||elem.document&&elem.document.nodeType!==11){return ret}}catch(e){}}return Sizzle(expr,document,null,[elem]).length>0};Sizzle.contains=function(context,elem){if((context.ownerDocument||context)!==document){setDocument(context)}return contains(context,elem)};Sizzle.attr=function(elem,name){if((elem.ownerDocument||elem)!==document){setDocument(elem)}var fn=Expr.attrHandle[name.toLowerCase()],val=fn&&hasOwn.call(Expr.attrHandle,name.toLowerCase())?fn(elem,name,!documentIsHTML):undefined;return val!==undefined?val:support.attributes||!documentIsHTML?elem.getAttribute(name):(val=elem.getAttributeNode(name))&&val.specified?val.value:null};Sizzle.error=function(msg){throw new Error("Syntax error, unrecognized expression: "+msg)};Sizzle.uniqueSort=function(results){var elem,duplicates=[],j=0,i=0;hasDuplicate=!support.detectDuplicates;sortInput=!support.sortStable&&results.slice(0);results.sort(sortOrder);if(hasDuplicate){while(elem=results[i++]){if(elem===results[i]){j=duplicates.push(i)}}while(j--){results.splice(duplicates[j],1)}}sortInput=null;return results};getText=Sizzle.getText=function(elem){var node,ret="",i=0,nodeType=elem.nodeType;if(!nodeType){while(node=elem[i++]){ret+=getText(node)}}else if(nodeType===1||nodeType===9||nodeType===11){if(typeof elem.textContent==="string"){return elem.textContent}else{for(elem=elem.firstChild;elem;elem=elem.nextSibling){ret+=getText(elem)}}}else if(nodeType===3||nodeType===4){return elem.nodeValue}return ret};Expr=Sizzle.selectors={cacheLength:50,createPseudo:markFunction,match:matchExpr,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:true}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:true},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(match){match[1]=match[1].replace(runescape,funescape);match[3]=(match[3]||match[4]||match[5]||"").replace(runescape,funescape);if(match[2]==="~="){match[3]=" "+match[3]+" "}return match.slice(0,4)},CHILD:function(match){match[1]=match[1].toLowerCase();if(match[1].slice(0,3)==="nth"){if(!match[3]){Sizzle.error(match[0])}match[4]=+(match[4]?match[5]+(match[6]||1):2*(match[3]==="even"||match[3]==="odd"));match[5]=+(match[7]+match[8]||match[3]==="odd")}else if(match[3]){Sizzle.error(match[0])}return match},PSEUDO:function(match){var excess,unquoted=!match[6]&&match[2];if(matchExpr["CHILD"].test(match[0])){return null}if(match[3]){match[2]=match[4]||match[5]||""}else if(unquoted&&rpseudo.test(unquoted)&&(excess=tokenize(unquoted,true))&&(excess=unquoted.indexOf(")",unquoted.length-excess)-unquoted.length)){match[0]=match[0].slice(0,excess);match[2]=unquoted.slice(0,excess)}return match.slice(0,3)}},filter:{TAG:function(nodeNameSelector){var nodeName=nodeNameSelector.replace(runescape,funescape).toLowerCase();return nodeNameSelector==="*"?function(){return true}:function(elem){return elem.nodeName&&elem.nodeName.toLowerCase()===nodeName}},CLASS:function(className){var pattern=classCache[className+" "];return pattern||(pattern=new RegExp("(^|"+whitespace+")"+className+"("+whitespace+"|$)"))&&classCache(className,function(elem){return pattern.test(typeof elem.className==="string"&&elem.className||typeof elem.getAttribute!=="undefined"&&elem.getAttribute("class")||"")})},ATTR:function(name,operator,check){return function(elem){var result=Sizzle.attr(elem,name);if(result==null){return operator==="!="}if(!operator){return true}result+="";return operator==="="?result===check:operator==="!="?result!==check:operator==="^="?check&&result.indexOf(check)===0:operator==="*="?check&&result.indexOf(check)>-1:operator==="$="?check&&result.slice(-check.length)===check:operator==="~="?(" "+result.replace(rwhitespace," ")+" ").indexOf(check)>-1:operator==="|="?result===check||result.slice(0,check.length+1)===check+"-":false}},CHILD:function(type,what,argument,first,last){var simple=type.slice(0,3)!=="nth",forward=type.slice(-4)!=="last",ofType=what==="of-type";return first===1&&last===0?function(elem){return!!elem.parentNode}:function(elem,context,xml){var cache,outerCache,node,diff,nodeIndex,start,dir=simple!==forward?"nextSibling":"previousSibling",parent=elem.parentNode,name=ofType&&elem.nodeName.toLowerCase(),useCache=!xml&&!ofType;if(parent){if(simple){while(dir){node=elem;while(node=node[dir]){if(ofType?node.nodeName.toLowerCase()===name:node.nodeType===1){return false}}start=dir=type==="only"&&!start&&"nextSibling"}return true}start=[forward?parent.firstChild:parent.lastChild];if(forward&&useCache){outerCache=parent[expando]||(parent[expando]={});cache=outerCache[type]||[];nodeIndex=cache[0]===dirruns&&cache[1];diff=cache[0]===dirruns&&cache[2];node=nodeIndex&&parent.childNodes[nodeIndex];while(node=++nodeIndex&&node&&node[dir]||(diff=nodeIndex=0)||start.pop()){if(node.nodeType===1&&++diff&&node===elem){outerCache[type]=[dirruns,nodeIndex,diff];break}}}else if(useCache&&(cache=(elem[expando]||(elem[expando]={}))[type])&&cache[0]===dirruns){diff=cache[1]}else{while(node=++nodeIndex&&node&&node[dir]||(diff=nodeIndex=0)||start.pop()){if((ofType?node.nodeName.toLowerCase()===name:node.nodeType===1)&&++diff){if(useCache){(node[expando]||(node[expando]={}))[type]=[dirruns,diff]}if(node===elem){break}}}}diff-=last;return diff===first||diff%first===0&&diff/first>=0}}},PSEUDO:function(pseudo,argument){var args,fn=Expr.pseudos[pseudo]||Expr.setFilters[pseudo.toLowerCase()]||Sizzle.error("unsupported pseudo: "+pseudo);if(fn[expando]){return fn(argument)}if(fn.length>1){args=[pseudo,pseudo,"",argument];return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase())?markFunction(function(seed,matches){var idx,matched=fn(seed,argument),i=matched.length;while(i--){idx=indexOf(seed,matched[i]);seed[idx]=!(matches[idx]=matched[i])}}):function(elem){return fn(elem,0,args)}}return fn}},pseudos:{not:markFunction(function(selector){var input=[],results=[],matcher=compile(selector.replace(rtrim,"$1"));return matcher[expando]?markFunction(function(seed,matches,context,xml){var elem,unmatched=matcher(seed,null,xml,[]),i=seed.length;while(i--){if(elem=unmatched[i]){seed[i]=!(matches[i]=elem)}}}):function(elem,context,xml){input[0]=elem;matcher(input,null,xml,results);input[0]=null;return!results.pop()}}),has:markFunction(function(selector){return function(elem){return Sizzle(selector,elem).length>0}}),contains:markFunction(function(text){text=text.replace(runescape,funescape);return function(elem){return(elem.textContent||elem.innerText||getText(elem)).indexOf(text)>-1}}),lang:markFunction(function(lang){if(!ridentifier.test(lang||"")){Sizzle.error("unsupported lang: "+lang)}lang=lang.replace(runescape,funescape).toLowerCase();return function(elem){var elemLang;do{if(elemLang=documentIsHTML?elem.lang:elem.getAttribute("xml:lang")||elem.getAttribute("lang")){elemLang=elemLang.toLowerCase();return elemLang===lang||elemLang.indexOf(lang+"-")===0}}while((elem=elem.parentNode)&&elem.nodeType===1);return false}}),target:function(elem){var hash=window.location&&window.location.hash;return hash&&hash.slice(1)===elem.id},root:function(elem){return elem===docElem},focus:function(elem){return elem===document.activeElement&&(!document.hasFocus||document.hasFocus())&&!!(elem.type||elem.href||~elem.tabIndex)},enabled:function(elem){return elem.disabled===false},disabled:function(elem){return elem.disabled===true},checked:function(elem){var nodeName=elem.nodeName.toLowerCase();return nodeName==="input"&&!!elem.checked||nodeName==="option"&&!!elem.selected},selected:function(elem){if(elem.parentNode){elem.parentNode.selectedIndex}return elem.selected===true},empty:function(elem){for(elem=elem.firstChild;elem;elem=elem.nextSibling){if(elem.nodeType<6){return false}}return true},parent:function(elem){return!Expr.pseudos["empty"](elem)},header:function(elem){return rheader.test(elem.nodeName)},input:function(elem){return rinputs.test(elem.nodeName)},button:function(elem){var name=elem.nodeName.toLowerCase();return name==="input"&&elem.type==="button"||name==="button"},text:function(elem){var attr;return elem.nodeName.toLowerCase()==="input"&&elem.type==="text"&&((attr=elem.getAttribute("type"))==null||attr.toLowerCase()==="text")},first:createPositionalPseudo(function(){return[0]}),last:createPositionalPseudo(function(matchIndexes,length){return[length-1]}),eq:createPositionalPseudo(function(matchIndexes,length,argument){return[argument<0?argument+length:argument]}),even:createPositionalPseudo(function(matchIndexes,length){var i=0;for(;i<length;i+=2){matchIndexes.push(i)}return matchIndexes}),odd:createPositionalPseudo(function(matchIndexes,length){var i=1;for(;i<length;i+=2){matchIndexes.push(i)}return matchIndexes}),lt:createPositionalPseudo(function(matchIndexes,length,argument){var i=argument<0?argument+length:argument;for(;--i>=0;){matchIndexes.push(i)}return matchIndexes}),gt:createPositionalPseudo(function(matchIndexes,length,argument){var i=argument<0?argument+length:argument;for(;++i<length;){matchIndexes.push(i)}return matchIndexes})}};Expr.pseudos["nth"]=Expr.pseudos["eq"];for(i in{radio:true,checkbox:true,file:true,password:true,image:true}){Expr.pseudos[i]=createInputPseudo(i)}for(i in{submit:true,reset:true}){Expr.pseudos[i]=createButtonPseudo(i)}function setFilters(){}setFilters.prototype=Expr.filters=Expr.pseudos;Expr.setFilters=new setFilters;tokenize=Sizzle.tokenize=function(selector,parseOnly){var matched,match,tokens,type,soFar,groups,preFilters,cached=tokenCache[selector+" "];if(cached){return parseOnly?0:cached.slice(0)}soFar=selector;groups=[];preFilters=Expr.preFilter;while(soFar){if(!matched||(match=rcomma.exec(soFar))){if(match){soFar=soFar.slice(match[0].length)||soFar}groups.push(tokens=[])}matched=false;if(match=rcombinators.exec(soFar)){matched=match.shift();tokens.push({value:matched,type:match[0].replace(rtrim," ")});soFar=soFar.slice(matched.length)}for(type in Expr.filter){if((match=matchExpr[type].exec(soFar))&&(!preFilters[type]||(match=preFilters[type](match)))){matched=match.shift();tokens.push({value:matched,type:type,matches:match});soFar=soFar.slice(matched.length)}}if(!matched){break}}return parseOnly?soFar.length:soFar?Sizzle.error(selector):tokenCache(selector,groups).slice(0)};function toSelector(tokens){var i=0,len=tokens.length,selector="";for(;i<len;i++){selector+=tokens[i].value}return selector}function addCombinator(matcher,combinator,base){var dir=combinator.dir,checkNonElements=base&&dir==="parentNode",doneName=done++;return combinator.first?function(elem,context,xml){while(elem=elem[dir]){if(elem.nodeType===1||checkNonElements){return matcher(elem,context,xml)}}}:function(elem,context,xml){var oldCache,outerCache,newCache=[dirruns,doneName];if(xml){while(elem=elem[dir]){if(elem.nodeType===1||checkNonElements){if(matcher(elem,context,xml)){return true}}}}else{while(elem=elem[dir]){if(elem.nodeType===1||checkNonElements){outerCache=elem[expando]||(elem[expando]={});if((oldCache=outerCache[dir])&&oldCache[0]===dirruns&&oldCache[1]===doneName){return newCache[2]=oldCache[2]}else{outerCache[dir]=newCache;if(newCache[2]=matcher(elem,context,xml)){return true}}}}}}}function elementMatcher(matchers){return matchers.length>1?function(elem,context,xml){var i=matchers.length;while(i--){if(!matchers[i](elem,context,xml)){return false}}return true}:matchers[0]}function multipleContexts(selector,contexts,results){var i=0,len=contexts.length;for(;i<len;i++){Sizzle(selector,contexts[i],results)}return results}function condense(unmatched,map,filter,context,xml){var elem,newUnmatched=[],i=0,len=unmatched.length,mapped=map!=null;for(;i<len;i++){if(elem=unmatched[i]){if(!filter||filter(elem,context,xml)){newUnmatched.push(elem);if(mapped){map.push(i)}}}}return newUnmatched}function setMatcher(preFilter,selector,matcher,postFilter,postFinder,postSelector){if(postFilter&&!postFilter[expando]){postFilter=setMatcher(postFilter)}if(postFinder&&!postFinder[expando]){postFinder=setMatcher(postFinder,postSelector)}return markFunction(function(seed,results,context,xml){var temp,i,elem,preMap=[],postMap=[],preexisting=results.length,elems=seed||multipleContexts(selector||"*",context.nodeType?[context]:context,[]),matcherIn=preFilter&&(seed||!selector)?condense(elems,preMap,preFilter,context,xml):elems,matcherOut=matcher?postFinder||(seed?preFilter:preexisting||postFilter)?[]:results:matcherIn;if(matcher){matcher(matcherIn,matcherOut,context,xml)}if(postFilter){temp=condense(matcherOut,postMap);postFilter(temp,[],context,xml);i=temp.length;while(i--){if(elem=temp[i]){matcherOut[postMap[i]]=!(matcherIn[postMap[i]]=elem)}}}if(seed){if(postFinder||preFilter){if(postFinder){temp=[];i=matcherOut.length;while(i--){if(elem=matcherOut[i]){temp.push(matcherIn[i]=elem)}}postFinder(null,matcherOut=[],temp,xml)}i=matcherOut.length;while(i--){if((elem=matcherOut[i])&&(temp=postFinder?indexOf(seed,elem):preMap[i])>-1){seed[temp]=!(results[temp]=elem)}}}}else{matcherOut=condense(matcherOut===results?matcherOut.splice(preexisting,matcherOut.length):matcherOut);if(postFinder){postFinder(null,results,matcherOut,xml)}else{push.apply(results,matcherOut)}}})}function matcherFromTokens(tokens){var checkContext,matcher,j,len=tokens.length,leadingRelative=Expr.relative[tokens[0].type],implicitRelative=leadingRelative||Expr.relative[" "],i=leadingRelative?1:0,matchContext=addCombinator(function(elem){return elem===checkContext},implicitRelative,true),matchAnyContext=addCombinator(function(elem){return indexOf(checkContext,elem)>-1},implicitRelative,true),matchers=[function(elem,context,xml){var ret=!leadingRelative&&(xml||context!==outermostContext)||((checkContext=context).nodeType?matchContext(elem,context,xml):matchAnyContext(elem,context,xml));checkContext=null;return ret}];for(;i<len;i++){if(matcher=Expr.relative[tokens[i].type]){matchers=[addCombinator(elementMatcher(matchers),matcher)]}else{matcher=Expr.filter[tokens[i].type].apply(null,tokens[i].matches);if(matcher[expando]){j=++i;for(;j<len;j++){if(Expr.relative[tokens[j].type]){break}}return setMatcher(i>1&&elementMatcher(matchers),i>1&&toSelector(tokens.slice(0,i-1).concat({value:tokens[i-2].type===" "?"*":""})).replace(rtrim,"$1"),matcher,i<j&&matcherFromTokens(tokens.slice(i,j)),j<len&&matcherFromTokens(tokens=tokens.slice(j)),j<len&&toSelector(tokens))}matchers.push(matcher)}}return elementMatcher(matchers)}function matcherFromGroupMatchers(elementMatchers,setMatchers){var bySet=setMatchers.length>0,byElement=elementMatchers.length>0,superMatcher=function(seed,context,xml,results,outermost){var elem,j,matcher,matchedCount=0,i="0",unmatched=seed&&[],setMatched=[],contextBackup=outermostContext,elems=seed||byElement&&Expr.find["TAG"]("*",outermost),dirrunsUnique=dirruns+=contextBackup==null?1:Math.random()||.1,len=elems.length;if(outermost){outermostContext=context!==document&&context}for(;i!==len&&(elem=elems[i])!=null;i++){if(byElement&&elem){j=0;while(matcher=elementMatchers[j++]){if(matcher(elem,context,xml)){results.push(elem);break}}if(outermost){dirruns=dirrunsUnique}}if(bySet){if(elem=!matcher&&elem){matchedCount--}if(seed){unmatched.push(elem)}}}matchedCount+=i;if(bySet&&i!==matchedCount){j=0;while(matcher=setMatchers[j++]){matcher(unmatched,setMatched,context,xml)}if(seed){if(matchedCount>0){while(i--){if(!(unmatched[i]||setMatched[i])){setMatched[i]=pop.call(results)}}}setMatched=condense(setMatched)}push.apply(results,setMatched);if(outermost&&!seed&&setMatched.length>0&&matchedCount+setMatchers.length>1){Sizzle.uniqueSort(results)}}if(outermost){dirruns=dirrunsUnique;outermostContext=contextBackup}return unmatched};return bySet?markFunction(superMatcher):superMatcher}compile=Sizzle.compile=function(selector,match){var i,setMatchers=[],elementMatchers=[],cached=compilerCache[selector+" "];if(!cached){if(!match){match=tokenize(selector)}i=match.length;while(i--){cached=matcherFromTokens(match[i]);if(cached[expando]){setMatchers.push(cached)}else{elementMatchers.push(cached)}}cached=compilerCache(selector,matcherFromGroupMatchers(elementMatchers,setMatchers));cached.selector=selector}return cached};select=Sizzle.select=function(selector,context,results,seed){var i,tokens,token,type,find,compiled=typeof selector==="function"&&selector,match=!seed&&tokenize(selector=compiled.selector||selector);results=results||[];if(match.length===1){tokens=match[0]=match[0].slice(0);if(tokens.length>2&&(token=tokens[0]).type==="ID"&&support.getById&&context.nodeType===9&&documentIsHTML&&Expr.relative[tokens[1].type]){context=(Expr.find["ID"](token.matches[0].replace(runescape,funescape),context)||[])[0];if(!context){return results}else if(compiled){context=context.parentNode}selector=selector.slice(tokens.shift().value.length)}i=matchExpr["needsContext"].test(selector)?0:tokens.length;while(i--){token=tokens[i];if(Expr.relative[type=token.type]){break}if(find=Expr.find[type]){if(seed=find(token.matches[0].replace(runescape,funescape),rsibling.test(tokens[0].type)&&testContext(context.parentNode)||context)){tokens.splice(i,1);selector=seed.length&&toSelector(tokens);if(!selector){push.apply(results,seed);return results}break}}}}(compiled||compile(selector,match))(seed,context,!documentIsHTML,results,rsibling.test(selector)&&testContext(context.parentNode)||context);return results};support.sortStable=expando.split("").sort(sortOrder).join("")===expando;support.detectDuplicates=!!hasDuplicate;setDocument();support.sortDetached=assert(function(div1){return div1.compareDocumentPosition(document.createElement("div"))&1});if(!assert(function(div){div.innerHTML="<a href='#'></a>";return div.firstChild.getAttribute("href")==="#"})){addHandle("type|href|height|width",function(elem,name,isXML){if(!isXML){return elem.getAttribute(name,name.toLowerCase()==="type"?1:2)}})}if(!support.attributes||!assert(function(div){div.innerHTML="<input/>";div.firstChild.setAttribute("value","");return div.firstChild.getAttribute("value")===""})){addHandle("value",function(elem,name,isXML){if(!isXML&&elem.nodeName.toLowerCase()==="input"){return elem.defaultValue}})}if(!assert(function(div){return div.getAttribute("disabled")==null})){addHandle(booleans,function(elem,name,isXML){var val;if(!isXML){return elem[name]===true?name.toLowerCase():(val=elem.getAttributeNode(name))&&val.specified?val.value:null}})}return Sizzle}(window);jQuery.find=Sizzle;jQuery.expr=Sizzle.selectors;jQuery.expr[":"]=jQuery.expr.pseudos;jQuery.unique=Sizzle.uniqueSort;jQuery.text=Sizzle.getText;jQuery.isXMLDoc=Sizzle.isXML;jQuery.contains=Sizzle.contains;var rneedsContext=jQuery.expr.match.needsContext;var rsingleTag=/^<(\w+)\s*\/?>(?:<\/\1>|)$/;var risSimple=/^.[^:#\[\.,]*$/;function winnow(elements,qualifier,not){if(jQuery.isFunction(qualifier)){return jQuery.grep(elements,function(elem,i){return!!qualifier.call(elem,i,elem)!==not})}if(qualifier.nodeType){return jQuery.grep(elements,function(elem){return elem===qualifier!==not})}if(typeof qualifier==="string"){if(risSimple.test(qualifier)){return jQuery.filter(qualifier,elements,not)}qualifier=jQuery.filter(qualifier,elements)}return jQuery.grep(elements,function(elem){return jQuery.inArray(elem,qualifier)>=0!==not})}jQuery.filter=function(expr,elems,not){var elem=elems[0];if(not){expr=":not("+expr+")"}return elems.length===1&&elem.nodeType===1?jQuery.find.matchesSelector(elem,expr)?[elem]:[]:jQuery.find.matches(expr,jQuery.grep(elems,function(elem){return elem.nodeType===1}))};jQuery.fn.extend({find:function(selector){var i,ret=[],self=this,len=self.length;if(typeof selector!=="string"){return this.pushStack(jQuery(selector).filter(function(){for(i=0;i<len;i++){if(jQuery.contains(self[i],this)){return true}}}))}for(i=0;i<len;i++){jQuery.find(selector,self[i],ret)}ret=this.pushStack(len>1?jQuery.unique(ret):ret);ret.selector=this.selector?this.selector+" "+selector:selector;return ret},filter:function(selector){return this.pushStack(winnow(this,selector||[],false))},not:function(selector){return this.pushStack(winnow(this,selector||[],true))},is:function(selector){return!!winnow(this,typeof selector==="string"&&rneedsContext.test(selector)?jQuery(selector):selector||[],false).length}});var rootjQuery,document=window.document,rquickExpr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,init=jQuery.fn.init=function(selector,context){var match,elem;if(!selector){return this}if(typeof selector==="string"){if(selector.charAt(0)==="<"&&selector.charAt(selector.length-1)===">"&&selector.length>=3){match=[null,selector,null]}else{match=rquickExpr.exec(selector)}if(match&&(match[1]||!context)){if(match[1]){context=context instanceof jQuery?context[0]:context;jQuery.merge(this,jQuery.parseHTML(match[1],context&&context.nodeType?context.ownerDocument||context:document,true));if(rsingleTag.test(match[1])&&jQuery.isPlainObject(context)){for(match in context){if(jQuery.isFunction(this[match])){this[match](context[match])}else{this.attr(match,context[match])}}}return this}else{elem=document.getElementById(match[2]);if(elem&&elem.parentNode){if(elem.id!==match[2]){return rootjQuery.find(selector)}this.length=1;this[0]=elem}this.context=document;this.selector=selector;return this}}else if(!context||context.jquery){return(context||rootjQuery).find(selector)}else{return this.constructor(context).find(selector)}}else if(selector.nodeType){this.context=this[0]=selector;this.length=1;return this}else if(jQuery.isFunction(selector)){return typeof rootjQuery.ready!=="undefined"?rootjQuery.ready(selector):selector(jQuery)}if(selector.selector!==undefined){this.selector=selector.selector;this.context=selector.context}return jQuery.makeArray(selector,this)};init.prototype=jQuery.fn;rootjQuery=jQuery(document);var rparentsprev=/^(?:parents|prev(?:Until|All))/,guaranteedUnique={children:true,contents:true,next:true,prev:true};jQuery.extend({dir:function(elem,dir,until){var matched=[],cur=elem[dir];while(cur&&cur.nodeType!==9&&(until===undefined||cur.nodeType!==1||!jQuery(cur).is(until))){if(cur.nodeType===1){matched.push(cur)}cur=cur[dir]}return matched},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType===1&&n!==elem){r.push(n)}}return r}});jQuery.fn.extend({has:function(target){var i,targets=jQuery(target,this),len=targets.length;return this.filter(function(){for(i=0;i<len;i++){if(jQuery.contains(this,targets[i])){return true}}})},closest:function(selectors,context){var cur,i=0,l=this.length,matched=[],pos=rneedsContext.test(selectors)||typeof selectors!=="string"?jQuery(selectors,context||this.context):0;for(;i<l;i++){for(cur=this[i];cur&&cur!==context;cur=cur.parentNode){if(cur.nodeType<11&&(pos?pos.index(cur)>-1:cur.nodeType===1&&jQuery.find.matchesSelector(cur,selectors))){matched.push(cur);break}}}return this.pushStack(matched.length>1?jQuery.unique(matched):matched)},index:function(elem){if(!elem){return this[0]&&this[0].parentNode?this.first().prevAll().length:-1}if(typeof elem==="string"){return jQuery.inArray(this[0],jQuery(elem))}return jQuery.inArray(elem.jquery?elem[0]:elem,this)},add:function(selector,context){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),jQuery(selector,context))))},addBack:function(selector){return this.add(selector==null?this.prevObject:this.prevObject.filter(selector))}});function sibling(cur,dir){do{cur=cur[dir]}while(cur&&cur.nodeType!==1);return cur}jQuery.each({parent:function(elem){var parent=elem.parentNode;return parent&&parent.nodeType!==11?parent:null},parents:function(elem){return jQuery.dir(elem,"parentNode")},parentsUntil:function(elem,i,until){return jQuery.dir(elem,"parentNode",until)},next:function(elem){return sibling(elem,"nextSibling")},prev:function(elem){return sibling(elem,"previousSibling")},nextAll:function(elem){return jQuery.dir(elem,"nextSibling")},prevAll:function(elem){return jQuery.dir(elem,"previousSibling")},nextUntil:function(elem,i,until){return jQuery.dir(elem,"nextSibling",until)},prevUntil:function(elem,i,until){return jQuery.dir(elem,"previousSibling",until)},siblings:function(elem){return jQuery.sibling((elem.parentNode||{}).firstChild,elem)},children:function(elem){return jQuery.sibling(elem.firstChild)},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.merge([],elem.childNodes)}},function(name,fn){jQuery.fn[name]=function(until,selector){var ret=jQuery.map(this,fn,until);if(name.slice(-5)!=="Until"){selector=until}if(selector&&typeof selector==="string"){ret=jQuery.filter(selector,ret)}if(this.length>1){if(!guaranteedUnique[name]){ret=jQuery.unique(ret)}if(rparentsprev.test(name)){ret=ret.reverse()}}return this.pushStack(ret)}});var rnotwhite=/\S+/g;var optionsCache={};function createOptions(options){var object=optionsCache[options]={};jQuery.each(options.match(rnotwhite)||[],function(_,flag){
16
+ object[flag]=true});return object}jQuery.Callbacks=function(options){options=typeof options==="string"?optionsCache[options]||createOptions(options):jQuery.extend({},options);var firing,memory,fired,firingLength,firingIndex,firingStart,list=[],stack=!options.once&&[],fire=function(data){memory=options.memory&&data;fired=true;firingIndex=firingStart||0;firingStart=0;firingLength=list.length;firing=true;for(;list&&firingIndex<firingLength;firingIndex++){if(list[firingIndex].apply(data[0],data[1])===false&&options.stopOnFalse){memory=false;break}}firing=false;if(list){if(stack){if(stack.length){fire(stack.shift())}}else if(memory){list=[]}else{self.disable()}}},self={add:function(){if(list){var start=list.length;(function add(args){jQuery.each(args,function(_,arg){var type=jQuery.type(arg);if(type==="function"){if(!options.unique||!self.has(arg)){list.push(arg)}}else if(arg&&arg.length&&type!=="string"){add(arg)}})})(arguments);if(firing){firingLength=list.length}else if(memory){firingStart=start;fire(memory)}}return this},remove:function(){if(list){jQuery.each(arguments,function(_,arg){var index;while((index=jQuery.inArray(arg,list,index))>-1){list.splice(index,1);if(firing){if(index<=firingLength){firingLength--}if(index<=firingIndex){firingIndex--}}}})}return this},has:function(fn){return fn?jQuery.inArray(fn,list)>-1:!!(list&&list.length)},empty:function(){list=[];firingLength=0;return this},disable:function(){list=stack=memory=undefined;return this},disabled:function(){return!list},lock:function(){stack=undefined;if(!memory){self.disable()}return this},locked:function(){return!stack},fireWith:function(context,args){if(list&&(!fired||stack)){args=args||[];args=[context,args.slice?args.slice():args];if(firing){stack.push(args)}else{fire(args)}}return this},fire:function(){self.fireWith(this,arguments);return this},fired:function(){return!!fired}};return self};jQuery.extend({Deferred:function(func){var tuples=[["resolve","done",jQuery.Callbacks("once memory"),"resolved"],["reject","fail",jQuery.Callbacks("once memory"),"rejected"],["notify","progress",jQuery.Callbacks("memory")]],state="pending",promise={state:function(){return state},always:function(){deferred.done(arguments).fail(arguments);return this},then:function(){var fns=arguments;return jQuery.Deferred(function(newDefer){jQuery.each(tuples,function(i,tuple){var fn=jQuery.isFunction(fns[i])&&fns[i];deferred[tuple[1]](function(){var returned=fn&&fn.apply(this,arguments);if(returned&&jQuery.isFunction(returned.promise)){returned.promise().done(newDefer.resolve).fail(newDefer.reject).progress(newDefer.notify)}else{newDefer[tuple[0]+"With"](this===promise?newDefer.promise():this,fn?[returned]:arguments)}})});fns=null}).promise()},promise:function(obj){return obj!=null?jQuery.extend(obj,promise):promise}},deferred={};promise.pipe=promise.then;jQuery.each(tuples,function(i,tuple){var list=tuple[2],stateString=tuple[3];promise[tuple[1]]=list.add;if(stateString){list.add(function(){state=stateString},tuples[i^1][2].disable,tuples[2][2].lock)}deferred[tuple[0]]=function(){deferred[tuple[0]+"With"](this===deferred?promise:this,arguments);return this};deferred[tuple[0]+"With"]=list.fireWith});promise.promise(deferred);if(func){func.call(deferred,deferred)}return deferred},when:function(subordinate){var i=0,resolveValues=slice.call(arguments),length=resolveValues.length,remaining=length!==1||subordinate&&jQuery.isFunction(subordinate.promise)?length:0,deferred=remaining===1?subordinate:jQuery.Deferred(),updateFunc=function(i,contexts,values){return function(value){contexts[i]=this;values[i]=arguments.length>1?slice.call(arguments):value;if(values===progressValues){deferred.notifyWith(contexts,values)}else if(!--remaining){deferred.resolveWith(contexts,values)}}},progressValues,progressContexts,resolveContexts;if(length>1){progressValues=new Array(length);progressContexts=new Array(length);resolveContexts=new Array(length);for(;i<length;i++){if(resolveValues[i]&&jQuery.isFunction(resolveValues[i].promise)){resolveValues[i].promise().done(updateFunc(i,resolveContexts,resolveValues)).fail(deferred.reject).progress(updateFunc(i,progressContexts,progressValues))}else{--remaining}}}if(!remaining){deferred.resolveWith(resolveContexts,resolveValues)}return deferred.promise()}});var readyList;jQuery.fn.ready=function(fn){jQuery.ready.promise().done(fn);return this};jQuery.extend({isReady:false,readyWait:1,holdReady:function(hold){if(hold){jQuery.readyWait++}else{jQuery.ready(true)}},ready:function(wait){if(wait===true?--jQuery.readyWait:jQuery.isReady){return}if(!document.body){return setTimeout(jQuery.ready)}jQuery.isReady=true;if(wait!==true&&--jQuery.readyWait>0){return}readyList.resolveWith(document,[jQuery]);if(jQuery.fn.triggerHandler){jQuery(document).triggerHandler("ready");jQuery(document).off("ready")}}});function detach(){if(document.addEventListener){document.removeEventListener("DOMContentLoaded",completed,false);window.removeEventListener("load",completed,false)}else{document.detachEvent("onreadystatechange",completed);window.detachEvent("onload",completed)}}function completed(){if(document.addEventListener||event.type==="load"||document.readyState==="complete"){detach();jQuery.ready()}}jQuery.ready.promise=function(obj){if(!readyList){readyList=jQuery.Deferred();if(document.readyState==="complete"){setTimeout(jQuery.ready)}else if(document.addEventListener){document.addEventListener("DOMContentLoaded",completed,false);window.addEventListener("load",completed,false)}else{document.attachEvent("onreadystatechange",completed);window.attachEvent("onload",completed);var top=false;try{top=window.frameElement==null&&document.documentElement}catch(e){}if(top&&top.doScroll){(function doScrollCheck(){if(!jQuery.isReady){try{top.doScroll("left")}catch(e){return setTimeout(doScrollCheck,50)}detach();jQuery.ready()}})()}}}return readyList.promise(obj)};var strundefined=typeof undefined;var i;for(i in jQuery(support)){break}support.ownLast=i!=="0";support.inlineBlockNeedsLayout=false;jQuery(function(){var val,div,body,container;body=document.getElementsByTagName("body")[0];if(!body||!body.style){return}div=document.createElement("div");container=document.createElement("div");container.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px";body.appendChild(container).appendChild(div);if(typeof div.style.zoom!==strundefined){div.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";support.inlineBlockNeedsLayout=val=div.offsetWidth===3;if(val){body.style.zoom=1}}body.removeChild(container)});(function(){var div=document.createElement("div");if(support.deleteExpando==null){support.deleteExpando=true;try{delete div.test}catch(e){support.deleteExpando=false}}div=null})();jQuery.acceptData=function(elem){var noData=jQuery.noData[(elem.nodeName+" ").toLowerCase()],nodeType=+elem.nodeType||1;return nodeType!==1&&nodeType!==9?false:!noData||noData!==true&&elem.getAttribute("classid")===noData};var rbrace=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,rmultiDash=/([A-Z])/g;function dataAttr(elem,key,data){if(data===undefined&&elem.nodeType===1){var name="data-"+key.replace(rmultiDash,"-$1").toLowerCase();data=elem.getAttribute(name);if(typeof data==="string"){try{data=data==="true"?true:data==="false"?false:data==="null"?null:+data+""===data?+data:rbrace.test(data)?jQuery.parseJSON(data):data}catch(e){}jQuery.data(elem,key,data)}else{data=undefined}}return data}function isEmptyDataObject(obj){var name;for(name in obj){if(name==="data"&&jQuery.isEmptyObject(obj[name])){continue}if(name!=="toJSON"){return false}}return true}function internalData(elem,name,data,pvt){if(!jQuery.acceptData(elem)){return}var ret,thisCache,internalKey=jQuery.expando,isNode=elem.nodeType,cache=isNode?jQuery.cache:elem,id=isNode?elem[internalKey]:elem[internalKey]&&internalKey;if((!id||!cache[id]||!pvt&&!cache[id].data)&&data===undefined&&typeof name==="string"){return}if(!id){if(isNode){id=elem[internalKey]=deletedIds.pop()||jQuery.guid++}else{id=internalKey}}if(!cache[id]){cache[id]=isNode?{}:{toJSON:jQuery.noop}}if(typeof name==="object"||typeof name==="function"){if(pvt){cache[id]=jQuery.extend(cache[id],name)}else{cache[id].data=jQuery.extend(cache[id].data,name)}}thisCache=cache[id];if(!pvt){if(!thisCache.data){thisCache.data={}}thisCache=thisCache.data}if(data!==undefined){thisCache[jQuery.camelCase(name)]=data}if(typeof name==="string"){ret=thisCache[name];if(ret==null){ret=thisCache[jQuery.camelCase(name)]}}else{ret=thisCache}return ret}function internalRemoveData(elem,name,pvt){if(!jQuery.acceptData(elem)){return}var thisCache,i,isNode=elem.nodeType,cache=isNode?jQuery.cache:elem,id=isNode?elem[jQuery.expando]:jQuery.expando;if(!cache[id]){return}if(name){thisCache=pvt?cache[id]:cache[id].data;if(thisCache){if(!jQuery.isArray(name)){if(name in thisCache){name=[name]}else{name=jQuery.camelCase(name);if(name in thisCache){name=[name]}else{name=name.split(" ")}}}else{name=name.concat(jQuery.map(name,jQuery.camelCase))}i=name.length;while(i--){delete thisCache[name[i]]}if(pvt?!isEmptyDataObject(thisCache):!jQuery.isEmptyObject(thisCache)){return}}}if(!pvt){delete cache[id].data;if(!isEmptyDataObject(cache[id])){return}}if(isNode){jQuery.cleanData([elem],true)}else if(support.deleteExpando||cache!=cache.window){delete cache[id]}else{cache[id]=null}}jQuery.extend({cache:{},noData:{"applet ":true,"embed ":true,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(elem){elem=elem.nodeType?jQuery.cache[elem[jQuery.expando]]:elem[jQuery.expando];return!!elem&&!isEmptyDataObject(elem)},data:function(elem,name,data){return internalData(elem,name,data)},removeData:function(elem,name){return internalRemoveData(elem,name)},_data:function(elem,name,data){return internalData(elem,name,data,true)},_removeData:function(elem,name){return internalRemoveData(elem,name,true)}});jQuery.fn.extend({data:function(key,value){var i,name,data,elem=this[0],attrs=elem&&elem.attributes;if(key===undefined){if(this.length){data=jQuery.data(elem);if(elem.nodeType===1&&!jQuery._data(elem,"parsedAttrs")){i=attrs.length;while(i--){if(attrs[i]){name=attrs[i].name;if(name.indexOf("data-")===0){name=jQuery.camelCase(name.slice(5));dataAttr(elem,name,data[name])}}}jQuery._data(elem,"parsedAttrs",true)}}return data}if(typeof key==="object"){return this.each(function(){jQuery.data(this,key)})}return arguments.length>1?this.each(function(){jQuery.data(this,key,value)}):elem?dataAttr(elem,key,jQuery.data(elem,key)):undefined},removeData:function(key){return this.each(function(){jQuery.removeData(this,key)})}});jQuery.extend({queue:function(elem,type,data){var queue;if(elem){type=(type||"fx")+"queue";queue=jQuery._data(elem,type);if(data){if(!queue||jQuery.isArray(data)){queue=jQuery._data(elem,type,jQuery.makeArray(data))}else{queue.push(data)}}return queue||[]}},dequeue:function(elem,type){type=type||"fx";var queue=jQuery.queue(elem,type),startLength=queue.length,fn=queue.shift(),hooks=jQuery._queueHooks(elem,type),next=function(){jQuery.dequeue(elem,type)};if(fn==="inprogress"){fn=queue.shift();startLength--}if(fn){if(type==="fx"){queue.unshift("inprogress")}delete hooks.stop;fn.call(elem,next,hooks)}if(!startLength&&hooks){hooks.empty.fire()}},_queueHooks:function(elem,type){var key=type+"queueHooks";return jQuery._data(elem,key)||jQuery._data(elem,key,{empty:jQuery.Callbacks("once memory").add(function(){jQuery._removeData(elem,type+"queue");jQuery._removeData(elem,key)})})}});jQuery.fn.extend({queue:function(type,data){var setter=2;if(typeof type!=="string"){data=type;type="fx";setter--}if(arguments.length<setter){return jQuery.queue(this[0],type)}return data===undefined?this:this.each(function(){var queue=jQuery.queue(this,type,data);jQuery._queueHooks(this,type);if(type==="fx"&&queue[0]!=="inprogress"){jQuery.dequeue(this,type)}})},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type)})},clearQueue:function(type){return this.queue(type||"fx",[])},promise:function(type,obj){var tmp,count=1,defer=jQuery.Deferred(),elements=this,i=this.length,resolve=function(){if(!--count){defer.resolveWith(elements,[elements])}};if(typeof type!=="string"){obj=type;type=undefined}type=type||"fx";while(i--){tmp=jQuery._data(elements[i],type+"queueHooks");if(tmp&&tmp.empty){count++;tmp.empty.add(resolve)}}resolve();return defer.promise(obj)}});var pnum=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source;var cssExpand=["Top","Right","Bottom","Left"];var isHidden=function(elem,el){elem=el||elem;return jQuery.css(elem,"display")==="none"||!jQuery.contains(elem.ownerDocument,elem)};var access=jQuery.access=function(elems,fn,key,value,chainable,emptyGet,raw){var i=0,length=elems.length,bulk=key==null;if(jQuery.type(key)==="object"){chainable=true;for(i in key){jQuery.access(elems,fn,i,key[i],true,emptyGet,raw)}}else if(value!==undefined){chainable=true;if(!jQuery.isFunction(value)){raw=true}if(bulk){if(raw){fn.call(elems,value);fn=null}else{bulk=fn;fn=function(elem,key,value){return bulk.call(jQuery(elem),value)}}}if(fn){for(;i<length;i++){fn(elems[i],key,raw?value:value.call(elems[i],i,fn(elems[i],key)))}}}return chainable?elems:bulk?fn.call(elems):length?fn(elems[0],key):emptyGet};var rcheckableType=/^(?:checkbox|radio)$/i;(function(){var input=document.createElement("input"),div=document.createElement("div"),fragment=document.createDocumentFragment();div.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";support.leadingWhitespace=div.firstChild.nodeType===3;support.tbody=!div.getElementsByTagName("tbody").length;support.htmlSerialize=!!div.getElementsByTagName("link").length;support.html5Clone=document.createElement("nav").cloneNode(true).outerHTML!=="<:nav></:nav>";input.type="checkbox";input.checked=true;fragment.appendChild(input);support.appendChecked=input.checked;div.innerHTML="<textarea>x</textarea>";support.noCloneChecked=!!div.cloneNode(true).lastChild.defaultValue;fragment.appendChild(div);div.innerHTML="<input type='radio' checked='checked' name='t'/>";support.checkClone=div.cloneNode(true).cloneNode(true).lastChild.checked;support.noCloneEvent=true;if(div.attachEvent){div.attachEvent("onclick",function(){support.noCloneEvent=false});div.cloneNode(true).click()}if(support.deleteExpando==null){support.deleteExpando=true;try{delete div.test}catch(e){support.deleteExpando=false}}})();(function(){var i,eventName,div=document.createElement("div");for(i in{submit:true,change:true,focusin:true}){eventName="on"+i;if(!(support[i+"Bubbles"]=eventName in window)){div.setAttribute(eventName,"t");support[i+"Bubbles"]=div.attributes[eventName].expando===false}}div=null})();var rformElems=/^(?:input|select|textarea)$/i,rkeyEvent=/^key/,rmouseEvent=/^(?:mouse|pointer|contextmenu)|click/,rfocusMorph=/^(?:focusinfocus|focusoutblur)$/,rtypenamespace=/^([^.]*)(?:\.(.+)|)$/;function returnTrue(){return true}function returnFalse(){return false}function safeActiveElement(){try{return document.activeElement}catch(err){}}jQuery.event={global:{},add:function(elem,types,handler,data,selector){var tmp,events,t,handleObjIn,special,eventHandle,handleObj,handlers,type,namespaces,origType,elemData=jQuery._data(elem);if(!elemData){return}if(handler.handler){handleObjIn=handler;handler=handleObjIn.handler;selector=handleObjIn.selector}if(!handler.guid){handler.guid=jQuery.guid++}if(!(events=elemData.events)){events=elemData.events={}}if(!(eventHandle=elemData.handle)){eventHandle=elemData.handle=function(e){return typeof jQuery!==strundefined&&(!e||jQuery.event.triggered!==e.type)?jQuery.event.dispatch.apply(eventHandle.elem,arguments):undefined};eventHandle.elem=elem}types=(types||"").match(rnotwhite)||[""];t=types.length;while(t--){tmp=rtypenamespace.exec(types[t])||[];type=origType=tmp[1];namespaces=(tmp[2]||"").split(".").sort();if(!type){continue}special=jQuery.event.special[type]||{};type=(selector?special.delegateType:special.bindType)||type;special=jQuery.event.special[type]||{};handleObj=jQuery.extend({type:type,origType:origType,data:data,handler:handler,guid:handler.guid,selector:selector,needsContext:selector&&jQuery.expr.match.needsContext.test(selector),namespace:namespaces.join(".")},handleObjIn);if(!(handlers=events[type])){handlers=events[type]=[];handlers.delegateCount=0;if(!special.setup||special.setup.call(elem,data,namespaces,eventHandle)===false){if(elem.addEventListener){elem.addEventListener(type,eventHandle,false)}else if(elem.attachEvent){elem.attachEvent("on"+type,eventHandle)}}}if(special.add){special.add.call(elem,handleObj);if(!handleObj.handler.guid){handleObj.handler.guid=handler.guid}}if(selector){handlers.splice(handlers.delegateCount++,0,handleObj)}else{handlers.push(handleObj)}jQuery.event.global[type]=true}elem=null},remove:function(elem,types,handler,selector,mappedTypes){var j,handleObj,tmp,origCount,t,events,special,handlers,type,namespaces,origType,elemData=jQuery.hasData(elem)&&jQuery._data(elem);if(!elemData||!(events=elemData.events)){return}types=(types||"").match(rnotwhite)||[""];t=types.length;while(t--){tmp=rtypenamespace.exec(types[t])||[];type=origType=tmp[1];namespaces=(tmp[2]||"").split(".").sort();if(!type){for(type in events){jQuery.event.remove(elem,type+types[t],handler,selector,true)}continue}special=jQuery.event.special[type]||{};type=(selector?special.delegateType:special.bindType)||type;handlers=events[type]||[];tmp=tmp[2]&&new RegExp("(^|\\.)"+namespaces.join("\\.(?:.*\\.|)")+"(\\.|$)");origCount=j=handlers.length;while(j--){handleObj=handlers[j];if((mappedTypes||origType===handleObj.origType)&&(!handler||handler.guid===handleObj.guid)&&(!tmp||tmp.test(handleObj.namespace))&&(!selector||selector===handleObj.selector||selector==="**"&&handleObj.selector)){handlers.splice(j,1);if(handleObj.selector){handlers.delegateCount--}if(special.remove){special.remove.call(elem,handleObj)}}}if(origCount&&!handlers.length){if(!special.teardown||special.teardown.call(elem,namespaces,elemData.handle)===false){jQuery.removeEvent(elem,type,elemData.handle)}delete events[type]}}if(jQuery.isEmptyObject(events)){delete elemData.handle;jQuery._removeData(elem,"events")}},trigger:function(event,data,elem,onlyHandlers){var handle,ontype,cur,bubbleType,special,tmp,i,eventPath=[elem||document],type=hasOwn.call(event,"type")?event.type:event,namespaces=hasOwn.call(event,"namespace")?event.namespace.split("."):[];cur=tmp=elem=elem||document;if(elem.nodeType===3||elem.nodeType===8){return}if(rfocusMorph.test(type+jQuery.event.triggered)){return}if(type.indexOf(".")>=0){namespaces=type.split(".");type=namespaces.shift();namespaces.sort()}ontype=type.indexOf(":")<0&&"on"+type;event=event[jQuery.expando]?event:new jQuery.Event(type,typeof event==="object"&&event);event.isTrigger=onlyHandlers?2:3;event.namespace=namespaces.join(".");event.namespace_re=event.namespace?new RegExp("(^|\\.)"+namespaces.join("\\.(?:.*\\.|)")+"(\\.|$)"):null;event.result=undefined;if(!event.target){event.target=elem}data=data==null?[event]:jQuery.makeArray(data,[event]);special=jQuery.event.special[type]||{};if(!onlyHandlers&&special.trigger&&special.trigger.apply(elem,data)===false){return}if(!onlyHandlers&&!special.noBubble&&!jQuery.isWindow(elem)){bubbleType=special.delegateType||type;if(!rfocusMorph.test(bubbleType+type)){cur=cur.parentNode}for(;cur;cur=cur.parentNode){eventPath.push(cur);tmp=cur}if(tmp===(elem.ownerDocument||document)){eventPath.push(tmp.defaultView||tmp.parentWindow||window)}}i=0;while((cur=eventPath[i++])&&!event.isPropagationStopped()){event.type=i>1?bubbleType:special.bindType||type;handle=(jQuery._data(cur,"events")||{})[event.type]&&jQuery._data(cur,"handle");if(handle){handle.apply(cur,data)}handle=ontype&&cur[ontype];if(handle&&handle.apply&&jQuery.acceptData(cur)){event.result=handle.apply(cur,data);if(event.result===false){event.preventDefault()}}}event.type=type;if(!onlyHandlers&&!event.isDefaultPrevented()){if((!special._default||special._default.apply(eventPath.pop(),data)===false)&&jQuery.acceptData(elem)){if(ontype&&elem[type]&&!jQuery.isWindow(elem)){tmp=elem[ontype];if(tmp){elem[ontype]=null}jQuery.event.triggered=type;try{elem[type]()}catch(e){}jQuery.event.triggered=undefined;if(tmp){elem[ontype]=tmp}}}}return event.result},dispatch:function(event){event=jQuery.event.fix(event);var i,ret,handleObj,matched,j,handlerQueue=[],args=slice.call(arguments),handlers=(jQuery._data(this,"events")||{})[event.type]||[],special=jQuery.event.special[event.type]||{};args[0]=event;event.delegateTarget=this;if(special.preDispatch&&special.preDispatch.call(this,event)===false){return}handlerQueue=jQuery.event.handlers.call(this,event,handlers);i=0;while((matched=handlerQueue[i++])&&!event.isPropagationStopped()){event.currentTarget=matched.elem;j=0;while((handleObj=matched.handlers[j++])&&!event.isImmediatePropagationStopped()){if(!event.namespace_re||event.namespace_re.test(handleObj.namespace)){event.handleObj=handleObj;event.data=handleObj.data;ret=((jQuery.event.special[handleObj.origType]||{}).handle||handleObj.handler).apply(matched.elem,args);if(ret!==undefined){if((event.result=ret)===false){event.preventDefault();event.stopPropagation()}}}}}if(special.postDispatch){special.postDispatch.call(this,event)}return event.result},handlers:function(event,handlers){var sel,handleObj,matches,i,handlerQueue=[],delegateCount=handlers.delegateCount,cur=event.target;if(delegateCount&&cur.nodeType&&(!event.button||event.type!=="click")){for(;cur!=this;cur=cur.parentNode||this){if(cur.nodeType===1&&(cur.disabled!==true||event.type!=="click")){matches=[];for(i=0;i<delegateCount;i++){handleObj=handlers[i];sel=handleObj.selector+" ";if(matches[sel]===undefined){matches[sel]=handleObj.needsContext?jQuery(sel,this).index(cur)>=0:jQuery.find(sel,this,null,[cur]).length}if(matches[sel]){matches.push(handleObj)}}if(matches.length){handlerQueue.push({elem:cur,handlers:matches})}}}}if(delegateCount<handlers.length){handlerQueue.push({elem:this,handlers:handlers.slice(delegateCount)})}return handlerQueue},fix:function(event){if(event[jQuery.expando]){return event}var i,prop,copy,type=event.type,originalEvent=event,fixHook=this.fixHooks[type];if(!fixHook){this.fixHooks[type]=fixHook=rmouseEvent.test(type)?this.mouseHooks:rkeyEvent.test(type)?this.keyHooks:{}}copy=fixHook.props?this.props.concat(fixHook.props):this.props;event=new jQuery.Event(originalEvent);i=copy.length;while(i--){prop=copy[i];event[prop]=originalEvent[prop]}if(!event.target){event.target=originalEvent.srcElement||document}if(event.target.nodeType===3){event.target=event.target.parentNode}event.metaKey=!!event.metaKey;return fixHook.filter?fixHook.filter(event,originalEvent):event},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(event,original){if(event.which==null){event.which=original.charCode!=null?original.charCode:original.keyCode}return event}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(event,original){var body,eventDoc,doc,button=original.button,fromElement=original.fromElement;if(event.pageX==null&&original.clientX!=null){eventDoc=event.target.ownerDocument||document;doc=eventDoc.documentElement;body=eventDoc.body;event.pageX=original.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc&&doc.clientLeft||body&&body.clientLeft||0);event.pageY=original.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc&&doc.clientTop||body&&body.clientTop||0)}if(!event.relatedTarget&&fromElement){event.relatedTarget=fromElement===event.target?original.toElement:fromElement}if(!event.which&&button!==undefined){event.which=button&1?1:button&2?3:button&4?2:0}return event}},special:{load:{noBubble:true},focus:{trigger:function(){if(this!==safeActiveElement()&&this.focus){try{this.focus();return false}catch(e){}}},delegateType:"focusin"},blur:{trigger:function(){if(this===safeActiveElement()&&this.blur){this.blur();return false}},delegateType:"focusout"},click:{trigger:function(){if(jQuery.nodeName(this,"input")&&this.type==="checkbox"&&this.click){this.click();return false}},_default:function(event){return jQuery.nodeName(event.target,"a")}},beforeunload:{postDispatch:function(event){if(event.result!==undefined&&event.originalEvent){event.originalEvent.returnValue=event.result}}}},simulate:function(type,elem,event,bubble){var e=jQuery.extend(new jQuery.Event,event,{type:type,isSimulated:true,originalEvent:{}});if(bubble){jQuery.event.trigger(e,null,elem)}else{jQuery.event.dispatch.call(elem,e)}if(e.isDefaultPrevented()){event.preventDefault()}}};jQuery.removeEvent=document.removeEventListener?function(elem,type,handle){if(elem.removeEventListener){elem.removeEventListener(type,handle,false)}}:function(elem,type,handle){var name="on"+type;if(elem.detachEvent){if(typeof elem[name]===strundefined){elem[name]=null}elem.detachEvent(name,handle)}};jQuery.Event=function(src,props){if(!(this instanceof jQuery.Event)){return new jQuery.Event(src,props)}if(src&&src.type){this.originalEvent=src;this.type=src.type;this.isDefaultPrevented=src.defaultPrevented||src.defaultPrevented===undefined&&src.returnValue===false?returnTrue:returnFalse}else{this.type=src}if(props){jQuery.extend(this,props)}this.timeStamp=src&&src.timeStamp||jQuery.now();this[jQuery.expando]=true};jQuery.Event.prototype={isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=returnTrue;if(!e){return}if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=returnTrue;if(!e){return}if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=returnTrue;if(e&&e.stopImmediatePropagation){e.stopImmediatePropagation()}this.stopPropagation()}};jQuery.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(orig,fix){jQuery.event.special[orig]={delegateType:fix,bindType:fix,handle:function(event){var ret,target=this,related=event.relatedTarget,handleObj=event.handleObj;if(!related||related!==target&&!jQuery.contains(target,related)){event.type=handleObj.origType;ret=handleObj.handler.apply(this,arguments);event.type=fix}return ret}}});if(!support.submitBubbles){jQuery.event.special.submit={setup:function(){if(jQuery.nodeName(this,"form")){return false}jQuery.event.add(this,"click._submit keypress._submit",function(e){var elem=e.target,form=jQuery.nodeName(elem,"input")||jQuery.nodeName(elem,"button")?elem.form:undefined;if(form&&!jQuery._data(form,"submitBubbles")){jQuery.event.add(form,"submit._submit",function(event){event._submit_bubble=true});jQuery._data(form,"submitBubbles",true)}})},postDispatch:function(event){if(event._submit_bubble){delete event._submit_bubble;if(this.parentNode&&!event.isTrigger){jQuery.event.simulate("submit",this.parentNode,event,true)}}},teardown:function(){if(jQuery.nodeName(this,"form")){return false}jQuery.event.remove(this,"._submit")}}}if(!support.changeBubbles){jQuery.event.special.change={setup:function(){if(rformElems.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio"){jQuery.event.add(this,"propertychange._change",function(event){if(event.originalEvent.propertyName==="checked"){this._just_changed=true}});jQuery.event.add(this,"click._change",function(event){if(this._just_changed&&!event.isTrigger){this._just_changed=false}jQuery.event.simulate("change",this,event,true)})}return false}jQuery.event.add(this,"beforeactivate._change",function(e){var elem=e.target;if(rformElems.test(elem.nodeName)&&!jQuery._data(elem,"changeBubbles")){jQuery.event.add(elem,"change._change",function(event){if(this.parentNode&&!event.isSimulated&&!event.isTrigger){jQuery.event.simulate("change",this.parentNode,event,true)}});jQuery._data(elem,"changeBubbles",true)}})},handle:function(event){var elem=event.target;if(this!==elem||event.isSimulated||event.isTrigger||elem.type!=="radio"&&elem.type!=="checkbox"){return event.handleObj.handler.apply(this,arguments)}},teardown:function(){jQuery.event.remove(this,"._change");return!rformElems.test(this.nodeName)}}}if(!support.focusinBubbles){jQuery.each({focus:"focusin",blur:"focusout"},function(orig,fix){var handler=function(event){jQuery.event.simulate(fix,event.target,jQuery.event.fix(event),true)};jQuery.event.special[fix]={setup:function(){var doc=this.ownerDocument||this,attaches=jQuery._data(doc,fix);if(!attaches){doc.addEventListener(orig,handler,true)}jQuery._data(doc,fix,(attaches||0)+1)},teardown:function(){var doc=this.ownerDocument||this,attaches=jQuery._data(doc,fix)-1;if(!attaches){doc.removeEventListener(orig,handler,true);jQuery._removeData(doc,fix)}else{jQuery._data(doc,fix,attaches)}}}})}jQuery.fn.extend({on:function(types,selector,data,fn,one){var type,origFn;if(typeof types==="object"){if(typeof selector!=="string"){data=data||selector;selector=undefined}for(type in types){this.on(type,selector,data,types[type],one)}return this}if(data==null&&fn==null){fn=selector;data=selector=undefined}else if(fn==null){if(typeof selector==="string"){fn=data;data=undefined}else{fn=data;data=selector;selector=undefined}}if(fn===false){fn=returnFalse}else if(!fn){return this}if(one===1){origFn=fn;fn=function(event){jQuery().off(event);return origFn.apply(this,arguments)};fn.guid=origFn.guid||(origFn.guid=jQuery.guid++)}return this.each(function(){jQuery.event.add(this,types,fn,data,selector)})},one:function(types,selector,data,fn){return this.on(types,selector,data,fn,1)},off:function(types,selector,fn){var handleObj,type;if(types&&types.preventDefault&&types.handleObj){handleObj=types.handleObj;jQuery(types.delegateTarget).off(handleObj.namespace?handleObj.origType+"."+handleObj.namespace:handleObj.origType,handleObj.selector,handleObj.handler);return this}if(typeof types==="object"){for(type in types){this.off(type,selector,types[type])}return this}if(selector===false||typeof selector==="function"){fn=selector;selector=undefined}if(fn===false){fn=returnFalse}return this.each(function(){jQuery.event.remove(this,types,fn,selector)})},trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this)})},triggerHandler:function(type,data){var elem=this[0];if(elem){return jQuery.event.trigger(type,data,elem,true)}}});function createSafeFragment(document){var list=nodeNames.split("|"),safeFrag=document.createDocumentFragment();if(safeFrag.createElement){while(list.length){safeFrag.createElement(list.pop())}}return safeFrag}var nodeNames="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|"+"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",rinlinejQuery=/ jQuery\d+="(?:null|\d+)"/g,rnoshimcache=new RegExp("<(?:"+nodeNames+")[\\s/>]","i"),rleadingWhitespace=/^\s+/,rxhtmlTag=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,rtagName=/<([\w:]+)/,rtbody=/<tbody/i,rhtml=/<|&#?\w+;/,rnoInnerhtml=/<(?:script|style|link)/i,rchecked=/checked\s*(?:[^=]|=\s*.checked.)/i,rscriptType=/^$|\/(?:java|ecma)script/i,rscriptTypeMasked=/^true\/(.*)/,rcleanScript=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,wrapMap={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},safeFragment=createSafeFragment(document),fragmentDiv=safeFragment.appendChild(document.createElement("div"));
17