v1.2.8.420

This commit is contained in:
RainLoop Team 2013-10-03 02:14:31 +04:00
parent 059d5f6b94
commit d39ece3349
437 changed files with 734 additions and 3465 deletions

View file

@ -1 +1 @@
1.2.7.417
1.2.8.420

View file

@ -1 +0,0 @@
e8d95408c4fb00037eda2a60636ba793ab813305

View file

@ -1 +0,0 @@
1.2.7.417

View file

@ -1,195 +0,0 @@
<?php
namespace Buzz;
use Buzz\Client\ClientInterface;
use Buzz\Client\FileGetContents;
use Buzz\Listener\ListenerChain;
use Buzz\Listener\ListenerInterface;
use Buzz\Message\Factory\Factory;
use Buzz\Message\Factory\FactoryInterface;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Util\Url;
class Browser
{
private $client;
private $factory;
private $listener;
private $lastRequest;
private $lastResponse;
public function __construct(ClientInterface $client = null, FactoryInterface $factory = null)
{
$this->client = $client ?: new FileGetContents();
$this->factory = $factory ?: new Factory();
}
public function get($url, $headers = array())
{
return $this->call($url, RequestInterface::METHOD_GET, $headers);
}
public function post($url, $headers = array(), $content = '')
{
return $this->call($url, RequestInterface::METHOD_POST, $headers, $content);
}
public function head($url, $headers = array())
{
return $this->call($url, RequestInterface::METHOD_HEAD, $headers);
}
public function patch($url, $headers = array(), $content = '')
{
return $this->call($url, RequestInterface::METHOD_PATCH, $headers, $content);
}
public function put($url, $headers = array(), $content = '')
{
return $this->call($url, RequestInterface::METHOD_PUT, $headers, $content);
}
public function delete($url, $headers = array(), $content = '')
{
return $this->call($url, RequestInterface::METHOD_DELETE, $headers, $content);
}
/**
* Sends a request.
*
* @param string $url The URL to call
* @param string $method The request method to use
* @param array $headers An array of request headers
* @param string $content The request content
*
* @return MessageInterface The response object
*/
public function call($url, $method, $headers = array(), $content = '')
{
$request = $this->factory->createRequest($method);
if (!$url instanceof Url) {
$url = new Url($url);
}
$url->applyToRequest($request);
$request->addHeaders($headers);
$request->setContent($content);
return $this->send($request);
}
/**
* Sends a form request.
*
* @param string $url The URL to submit to
* @param array $fields An array of fields
* @param string $method The request method to use
* @param array $headers An array of request headers
*
* @return MessageInterface The response object
*/
public function submit($url, array $fields, $method = RequestInterface::METHOD_POST, $headers = array())
{
$request = $this->factory->createFormRequest();
if (!$url instanceof Url) {
$url = new Url($url);
}
$url->applyToRequest($request);
$request->addHeaders($headers);
$request->setMethod($method);
$request->setFields($fields);
return $this->send($request);
}
/**
* Sends a request.
*
* @param RequestInterface $request A request object
* @param MessageInterface $response A response object
*
* @return MessageInterface The response
*/
public function send(RequestInterface $request, MessageInterface $response = null)
{
if (null === $response) {
$response = $this->factory->createResponse();
}
if ($this->listener) {
$this->listener->preSend($request);
}
$this->client->send($request, $response);
$this->lastRequest = $request;
$this->lastResponse = $response;
if ($this->listener) {
$this->listener->postSend($request, $response);
}
return $response;
}
public function getLastRequest()
{
return $this->lastRequest;
}
public function getLastResponse()
{
return $this->lastResponse;
}
public function setClient(ClientInterface $client)
{
$this->client = $client;
}
public function getClient()
{
return $this->client;
}
public function setMessageFactory(FactoryInterface $factory)
{
$this->factory = $factory;
}
public function getMessageFactory()
{
return $this->factory;
}
public function setListener(ListenerInterface $listener)
{
$this->listener = $listener;
}
public function getListener()
{
return $this->listener;
}
public function addListener(ListenerInterface $listener)
{
if (!$this->listener) {
$this->listener = $listener;
} elseif ($this->listener instanceof ListenerChain) {
$this->listener->addListener($listener);
} else {
$this->listener = new ListenerChain(array(
$this->listener,
$listener,
));
}
}
}

View file

@ -1,62 +0,0 @@
<?php
namespace Buzz\Client;
abstract class AbstractClient implements ClientInterface
{
protected $ignoreErrors = true;
protected $maxRedirects = 5;
protected $timeout = 5;
protected $verifyPeer = true;
protected $proxy;
public function setIgnoreErrors($ignoreErrors)
{
$this->ignoreErrors = $ignoreErrors;
}
public function getIgnoreErrors()
{
return $this->ignoreErrors;
}
public function setMaxRedirects($maxRedirects)
{
$this->maxRedirects = $maxRedirects;
}
public function getMaxRedirects()
{
return $this->maxRedirects;
}
public function setTimeout($timeout)
{
$this->timeout = $timeout;
}
public function getTimeout()
{
return $this->timeout;
}
public function setVerifyPeer($verifyPeer)
{
$this->verifyPeer = $verifyPeer;
}
public function getVerifyPeer()
{
return $this->verifyPeer;
}
public function setProxy($proxy)
{
$this->proxy = $proxy;
}
public function getProxy()
{
return $this->proxy;
}
}

View file

@ -1,201 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\Form\FormRequestInterface;
use Buzz\Message\Form\FormUploadInterface;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Exception\ClientException;
/**
* Base client class with helpers for working with cURL.
*/
abstract class AbstractCurl extends AbstractClient
{
protected $options = array();
public function __construct()
{
if (defined('CURLOPT_PROTOCOLS')) {
$this->options = array(
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
);
}
}
/**
* Creates a new cURL resource.
*
* @see curl_init()
*
* @return resource A new cURL resource
*/
protected static function createCurlHandle()
{
if (false === $curl = curl_init()) {
throw new ClientException('Unable to create a new cURL handle');
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
return $curl;
}
/**
* Populates a response object.
*
* @param resource $curl A cURL resource
* @param string $raw The raw response string
* @param MessageInterface $response The response object
*/
protected static function populateResponse($curl, $raw, MessageInterface $response)
{
$pos = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$response->setHeaders(static::getLastHeaders(rtrim(substr($raw, 0, $pos))));
$response->setContent(substr($raw, $pos));
}
/**
* Sets options on a cURL resource based on a request.
*/
private static function setOptionsFromRequest($curl, RequestInterface $request)
{
$options = array(
CURLOPT_CUSTOMREQUEST => $request->getMethod(),
CURLOPT_URL => $request->getHost().$request->getResource(),
CURLOPT_HTTPHEADER => $request->getHeaders(),
);
switch ($request->getMethod()) {
case RequestInterface::METHOD_HEAD:
$options[CURLOPT_NOBODY] = true;
break;
case RequestInterface::METHOD_GET:
$options[CURLOPT_HTTPGET] = true;
break;
case RequestInterface::METHOD_POST:
case RequestInterface::METHOD_PUT:
case RequestInterface::METHOD_DELETE:
case RequestInterface::METHOD_PATCH:
$options[CURLOPT_POSTFIELDS] = $fields = static::getPostFields($request);
// remove the content-type header
if (is_array($fields)) {
$options[CURLOPT_HTTPHEADER] = array_filter($options[CURLOPT_HTTPHEADER], function($header) {
return 0 !== stripos($header, 'Content-Type: ');
});
}
break;
}
curl_setopt_array($curl, $options);
}
/**
* Returns a value for the CURLOPT_POSTFIELDS option.
*
* @return string|array A post fields value
*/
private static function getPostFields(RequestInterface $request)
{
if (!$request instanceof FormRequestInterface) {
return $request->getContent();
}
$fields = $request->getFields();
$multipart = false;
foreach ($fields as $name => $value) {
if ($value instanceof FormUploadInterface) {
$multipart = true;
if ($file = $value->getFile()) {
// replace value with upload string
$fields[$name] = '@'.$file;
if ($contentType = $value->getContentType()) {
$fields[$name] .= ';type='.$contentType;
}
} else {
return $request->getContent();
}
}
}
return $multipart ? $fields : http_build_query($fields);
}
/**
* A helper for getting the last set of headers.
*
* @param string $raw A string of many header chunks
*
* @return array An array of header lines
*/
private static function getLastHeaders($raw)
{
$headers = array();
foreach (preg_split('/(\\r?\\n)/', $raw) as $header) {
if ($header) {
$headers[] = $header;
} else {
$headers = array();
}
}
return $headers;
}
/**
* Stashes a cURL option to be set on send, when the resource is created.
*
* If the supplied value it set to null the option will be removed.
*
* @param integer $option The option
* @param mixed $value The value
*
* @see curl_setopt()
*/
public function setOption($option, $value)
{
if (null === $value) {
unset($this->options[$option]);
} else {
$this->options[$option] = $value;
}
}
/**
* Prepares a cURL resource to send a request.
*/
protected function prepare($curl, RequestInterface $request, array $options = array())
{
static::setOptionsFromRequest($curl, $request);
// apply settings from client
if ($this->getTimeout() < 1) {
curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->getTimeout() * 1000);
} else {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->getTimeout());
}
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxy);
}
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0 < $this->getMaxRedirects());
curl_setopt($curl, CURLOPT_MAXREDIRS, $this->getMaxRedirects());
curl_setopt($curl, CURLOPT_FAILONERROR, !$this->getIgnoreErrors());
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->getVerifyPeer());
// apply additional options
curl_setopt_array($curl, $options + $this->options);
}
}

View file

@ -1,43 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\RequestInterface;
abstract class AbstractStream extends AbstractClient
{
/**
* Converts a request into an array for stream_context_create().
*
* @param RequestInterface $request A request object
*
* @return array An array for stream_context_create()
*/
public function getStreamContextArray(RequestInterface $request)
{
$options = array(
'http' => array(
// values from the request
'method' => $request->getMethod(),
'header' => implode("\r\n", $request->getHeaders()),
'content' => $request->getContent(),
'protocol_version' => $request->getProtocolVersion(),
// values from the current client
'ignore_errors' => $this->getIgnoreErrors(),
'max_redirects' => $this->getMaxRedirects(),
'timeout' => $this->getTimeout(),
),
'ssl' => array(
'verify_peer' => $this->getVerifyPeer(),
),
);
if ($this->proxy) {
$options['http']['proxy'] = $this->proxy;
$options['http']['request_fulluri'] = true;
}
return $options;
}
}

View file

@ -1,11 +0,0 @@
<?php
namespace Buzz\Client;
interface BatchClientInterface extends ClientInterface
{
/**
* Processes the queued requests.
*/
public function flush();
}

View file

@ -1,17 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
interface ClientInterface
{
/**
* Populates the supplied response with the response for the supplied request.
*
* @param RequestInterface $request A request object
* @param MessageInterface $response A response object
*/
public function send(RequestInterface $request, MessageInterface $response);
}

View file

@ -1,55 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Exception\ClientException;
use Buzz\Exception\LogicException;
class Curl extends AbstractCurl
{
private $lastCurl;
public function send(RequestInterface $request, MessageInterface $response, array $options = array())
{
if (is_resource($this->lastCurl)) {
curl_close($this->lastCurl);
}
$this->lastCurl = static::createCurlHandle();
$this->prepare($this->lastCurl, $request, $options);
$data = curl_exec($this->lastCurl);
if (false === $data) {
$errorMsg = curl_error($this->lastCurl);
$errorNo = curl_errno($this->lastCurl);
throw new ClientException($errorMsg, $errorNo);
}
static::populateResponse($this->lastCurl, $data, $response);
}
/**
* Introspects the last cURL request.
*
* @see curl_getinfo()
*/
public function getInfo($opt = 0)
{
if (!is_resource($this->lastCurl)) {
throw new LogicException('There is no cURL resource');
}
return curl_getinfo($this->lastCurl, $opt);
}
public function __destruct()
{
if (is_resource($this->lastCurl)) {
curl_close($this->lastCurl);
}
}
}

View file

@ -1,87 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Util\CookieJar;
use Buzz\Exception\ClientException;
class FileGetContents extends AbstractStream
{
/**
* @var CookieJar
*/
protected $cookieJar;
/**
* @param CookieJar|null $cookieJar
*/
public function __construct(CookieJar $cookieJar = null)
{
if ($cookieJar) {
$this->setCookieJar($cookieJar);
}
}
/**
* @param CookieJar $cookieJar
*/
public function setCookieJar(CookieJar $cookieJar)
{
$this->cookieJar = $cookieJar;
}
/**
* @return CookieJar
*/
public function getCookieJar()
{
return $this->cookieJar;
}
/**
* @see ClientInterface
*
* @throws ClientException If file_get_contents() fires an error
*/
public function send(RequestInterface $request, MessageInterface $response)
{
if ($cookieJar = $this->getCookieJar()) {
$cookieJar->clearExpiredCookies();
$cookieJar->addCookieHeaders($request);
}
$context = stream_context_create($this->getStreamContextArray($request));
$url = $request->getHost().$request->getResource();
$level = error_reporting(0);
$content = file_get_contents($url, 0, $context);
error_reporting($level);
if (false === $content) {
$error = error_get_last();
throw new ClientException($error['message']);
}
$response->setHeaders($this->filterHeaders((array) $http_response_header));
$response->setContent($content);
if ($cookieJar) {
$cookieJar->processSetCookieHeaders($request, $response);
}
}
private function filterHeaders(array $headers)
{
$filtered = array();
foreach ($headers as $header) {
if (0 === stripos($header, 'http/')) {
$filtered = array();
}
$filtered[] = $header;
}
return $filtered;
}
}

View file

@ -1,53 +0,0 @@
<?php
namespace Buzz\Client;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Exception\ClientException;
class MultiCurl extends AbstractCurl implements BatchClientInterface
{
private $queue = array();
public function send(RequestInterface $request, MessageInterface $response, array $options = array())
{
$this->queue[] = array($request, $response, $options);
}
public function flush()
{
if (false === $curlm = curl_multi_init()) {
throw new ClientException('Unable to create a new cURL multi handle');
}
// prepare a cURL handle for each entry in the queue
foreach ($this->queue as $i => &$queue) {
list($request, $response, $options) = $queue;
$curl = $queue[] = static::createCurlHandle();
$this->prepare($curl, $request, $options);
curl_multi_add_handle($curlm, $curl);
}
$active = null;
do {
$mrc = curl_multi_exec($curlm, $active);
} while (CURLM_CALL_MULTI_PERFORM == $mrc);
while ($active && CURLM_OK == $mrc) {
if (-1 != curl_multi_select($curlm)) {
do {
$mrc = curl_multi_exec($curlm, $active);
} while (CURLM_CALL_MULTI_PERFORM == $mrc);
}
}
// populate the responses
while (list($request, $response, $options, $curl) = array_shift($this->queue)) {
static::populateResponse($curl, curl_multi_getcontent($curl), $response);
curl_multi_remove_handle($curlm, $curl);
}
curl_multi_close($curlm);
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace Buzz\Exception;
/**
* Thrown whenever a client process fails.
*/
class ClientException extends RuntimeException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace Buzz\Exception;
/**
* Marker interface to denote exceptions thrown from the Buzz context.
*/
interface ExceptionInterface
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace Buzz\Exception;
/**
* Thrown when an invalid argument is provided.
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace Buzz\Exception;
/**
* Thrown whenever a required call-flow is not respected.
*/
class LogicException extends \LogicException implements ExceptionInterface
{
}

View file

@ -1,7 +0,0 @@
<?php
namespace Buzz\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
}

View file

@ -1,27 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class BasicAuthListener implements ListenerInterface
{
private $username;
private $password;
public function __construct($username, $password)
{
$this->username = $username;
$this->password = $password;
}
public function preSend(RequestInterface $request)
{
$request->addHeader('Authorization: Basic '.base64_encode($this->username.':'.$this->password));
}
public function postSend(RequestInterface $request, MessageInterface $response)
{
}
}

View file

@ -1,49 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Exception\InvalidArgumentException;
class CallbackListener implements ListenerInterface
{
private $callable;
/**
* Constructor.
*
* The callback should expect either one or two arguments, depending on
* whether it is receiving a pre or post send notification.
*
* $listener = new CallbackListener(function($request, $response = null) {
* if ($response) {
* // postSend
* } else {
* // preSend
* }
* });
*
* @param mixed $callable A PHP callable
*
* @throws InvalidArgumentException If the argument is not callable
*/
public function __construct($callable)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException('The argument is not callable.');
}
$this->callable = $callable;
}
public function preSend(RequestInterface $request)
{
call_user_func($this->callable, $request);
}
public function postSend(RequestInterface $request, MessageInterface $response)
{
call_user_func($this->callable, $request, $response);
}
}

View file

@ -1,42 +0,0 @@
<?php
namespace Buzz\Listener\History;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class Entry
{
private $request;
private $response;
private $duration;
/**
* Constructor.
*
* @param RequestInterface $request The request
* @param MessageInterface $response The response
* @param integer $duration The duration in seconds
*/
public function __construct(RequestInterface $request, MessageInterface $response, $duration = null)
{
$this->request = $request;
$this->response = $response;
$this->duration = $duration;
}
public function getRequest()
{
return $this->request;
}
public function getResponse()
{
return $this->response;
}
public function getDuration()
{
return $this->duration;
}
}

View file

@ -1,76 +0,0 @@
<?php
namespace Buzz\Listener\History;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class Journal implements \Countable, \IteratorAggregate
{
private $entries = array();
private $limit = 10;
/**
* Records an entry in the journal.
*
* @param RequestInterface $request The request
* @param MessageInterface $response The response
* @param integer $duration The duration in seconds
*/
public function record(RequestInterface $request, MessageInterface $response, $duration = null)
{
$this->addEntry(new Entry($request, $response, $duration));
}
public function addEntry(Entry $entry)
{
array_push($this->entries, $entry);
$this->entries = array_slice($this->entries, $this->getLimit() * -1);
end($this->entries);
}
public function getEntries()
{
return $this->entries;
}
public function getLast()
{
return end($this->entries);
}
public function getLastRequest()
{
return $this->getLast()->getRequest();
}
public function getLastResponse()
{
return $this->getLast()->getResponse();
}
public function clear()
{
$this->entries = array();
}
public function count()
{
return count($this->entries);
}
public function setLimit($limit)
{
$this->limit = $limit;
}
public function getLimit()
{
return $this->limit;
}
public function getIterator()
{
return new \ArrayIterator(array_reverse($this->entries));
}
}

View file

@ -1,33 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Listener\History\Journal;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class HistoryListener implements ListenerInterface
{
private $journal;
private $startTime;
public function __construct(Journal $journal)
{
$this->journal = $journal;
}
public function getJournal()
{
return $this->journal;
}
public function preSend(RequestInterface $request)
{
$this->startTime = microtime(true);
}
public function postSend(RequestInterface $request, MessageInterface $response)
{
$this->journal->record($request, $response, microtime(true) - $this->startTime);
}
}

View file

@ -1,40 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class ListenerChain implements ListenerInterface
{
private $listeners;
public function __construct(array $listeners = array())
{
$this->listeners = $listeners;
}
public function addListener(ListenerInterface $listener)
{
$this->listeners[] = $listener;
}
public function getListeners()
{
return $this->listeners;
}
public function preSend(RequestInterface $request)
{
foreach ($this->listeners as $listener) {
$listener->preSend($request);
}
}
public function postSend(RequestInterface $request, MessageInterface $response)
{
foreach ($this->listeners as $listener) {
$listener->postSend($request, $response);
}
}
}

View file

@ -1,12 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
interface ListenerInterface
{
public function preSend(RequestInterface $request);
public function postSend(RequestInterface $request, MessageInterface $response);
}

View file

@ -1,36 +0,0 @@
<?php
namespace Buzz\Listener;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
use Buzz\Exception\InvalidArgumentException;
class LoggerListener implements ListenerInterface
{
private $logger;
private $prefix;
private $startTime;
public function __construct($logger, $prefix = null)
{
if (!is_callable($logger)) {
throw new InvalidArgumentException('The logger must be a callable.');
}
$this->logger = $logger;
$this->prefix = $prefix;
}
public function preSend(RequestInterface $request)
{
$this->startTime = microtime(true);
}
public function postSend(RequestInterface $request, MessageInterface $response)
{
$seconds = microtime(true) - $this->startTime;
call_user_func($this->logger, sprintf('%sSent "%s %s%s" in %dms', $this->prefix, $request->getMethod(), $request->getHost(), $request->getResource(), round($seconds * 1000)));
}
}

View file

@ -1,154 +0,0 @@
<?php
namespace Buzz\Message;
abstract class AbstractMessage implements MessageInterface
{
private $headers = array();
private $content;
/**
* Returns the value of a header.
*
* @param string $name
* @param string|boolean $glue Glue for implode, or false to return an array
*
* @return string|array|null
*/
public function getHeader($name, $glue = "\r\n")
{
$needle = $name.':';
$values = array();
foreach ($this->getHeaders() as $header) {
if (0 === stripos($header, $needle)) {
$values[] = trim(substr($header, strlen($needle)));
}
}
if (false === $glue) {
return $values;
} else {
return count($values) ? implode($glue, $values) : null;
}
}
/**
* Returns a header's attributes.
*
* @param string $name A header name
*
* @return array An associative array of attributes
*/
public function getHeaderAttributes($name)
{
$attributes = array();
foreach ($this->getHeader($name, false) as $header) {
if (false !== strpos($header, ';')) {
// remove header value
list(, $header) = explode(';', $header, 2);
// loop through attribute key=value pairs
foreach (array_map('trim', explode(';', trim($header))) as $pair) {
list($key, $value) = explode('=', $pair);
$attributes[$key] = $value;
}
}
}
return $attributes;
}
/**
* Returns the value of a particular header attribute.
*
* @param string $header A header name
* @param string $attribute An attribute name
*
* @return string|null The value of the attribute or null if it isn't set
*/
public function getHeaderAttribute($header, $attribute)
{
$attributes = $this->getHeaderAttributes($header);
if (isset($attributes[$attribute])) {
return $attributes[$attribute];
}
}
/**
* Returns the current message as a DOMDocument.
*
* @return \DOMDocument
*/
public function toDomDocument()
{
$revert = libxml_use_internal_errors(true);
$document = new \DOMDocument('1.0', $this->getHeaderAttribute('Content-Type', 'charset') ?: 'UTF-8');
if (0 === strpos($this->getHeader('Content-Type'), 'text/xml')) {
$document->loadXML($this->getContent());
} else {
$document->loadHTML($this->getContent());
}
libxml_use_internal_errors($revert);
return $document;
}
public function setHeaders(array $headers)
{
$this->headers = $this->flattenHeaders($headers);
}
public function addHeader($header)
{
$this->headers[] = $header;
}
public function addHeaders(array $headers)
{
$this->headers = array_merge($this->headers, $this->flattenHeaders($headers));
}
public function getHeaders()
{
return $this->headers;
}
public function setContent($content)
{
$this->content = $content;
}
public function getContent()
{
return $this->content;
}
public function __toString()
{
$string = implode("\r\n", $this->getHeaders())."\r\n";
if ($content = $this->getContent()) {
$string .= "\r\n$content\r\n";
}
return $string;
}
protected function flattenHeaders(array $headers)
{
$flattened = array();
foreach ($headers as $key => $header) {
if (is_int($key)) {
$flattened[] = $header;
} else {
$flattened[] = $key.': '.$header;
}
}
return $flattened;
}
}

View file

@ -1,26 +0,0 @@
<?php
namespace Buzz\Message\Factory;
use Buzz\Message\Form\FormRequest;
use Buzz\Message\Request;
use Buzz\Message\RequestInterface;
use Buzz\Message\Response;
class Factory implements FactoryInterface
{
public function createRequest($method = RequestInterface::METHOD_GET, $resource = '/', $host = null)
{
return new Request($method, $resource, $host);
}
public function createFormRequest($method = RequestInterface::METHOD_POST, $resource = '/', $host = null)
{
return new FormRequest($method, $resource, $host);
}
public function createResponse()
{
return new Response();
}
}

View file

@ -1,12 +0,0 @@
<?php
namespace Buzz\Message\Factory;
use Buzz\Message\RequestInterface;
interface FactoryInterface
{
public function createRequest($method = RequestInterface::METHOD_GET, $resource = '/', $host = null);
public function createFormRequest($method = RequestInterface::METHOD_POST, $resource = '/', $host = null);
public function createResponse();
}

View file

@ -1,187 +0,0 @@
<?php
namespace Buzz\Message\Form;
use Buzz\Message\Request;
use Buzz\Exception\LogicException;
/**
* FormRequest.
*
* $request = new FormRequest();
* $request->setField('user[name]', 'Kris Wallsmith');
* $request->setField('user[image]', new FormUpload('/path/to/image.jpg'));
*
* @author Marc Weistroff <marc.weistroff@sensio.com>
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
*/
class FormRequest extends Request implements FormRequestInterface
{
private $fields = array();
private $boundary;
/**
* Constructor.
*
* Defaults to POST rather than GET.
*/
public function __construct($method = self::METHOD_POST, $resource = '/', $host = null)
{
parent::__construct($method, $resource, $host);
}
/**
* Sets the value of a form field.
*
* If the value is an array it will be flattened and one field value will
* be added for each leaf.
*/
public function setField($name, $value)
{
if (is_array($value)) {
$this->addFields(array($name => $value));
return;
}
if ('[]' == substr($name, -2)) {
$this->fields[substr($name, 0, -2)][] = $value;
} else {
$this->fields[$name] = $value;
}
}
public function addFields(array $fields)
{
foreach ($this->flattenArray($fields) as $name => $value) {
$this->setField($name, $value);
}
}
public function setFields(array $fields)
{
$this->fields = array();
$this->addFields($fields);
}
public function getFields()
{
return $this->fields;
}
public function getResource()
{
$resource = parent::getResource();
if (!$this->isSafe() || !$this->fields) {
return $resource;
}
// append the query string
$resource .= false === strpos($resource, '?') ? '?' : '&';
$resource .= http_build_query($this->fields);
return $resource;
}
public function setContent($content)
{
throw new \BadMethodCallException('It is not permitted to set the content.');
}
public function getHeaders()
{
$headers = parent::getHeaders();
if ($this->isSafe()) {
return $headers;
}
if ($this->isMultipart()) {
$headers[] = 'Content-Type: multipart/form-data; boundary='.$this->getBoundary();
} else {
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
}
return $headers;
}
public function getContent()
{
if ($this->isSafe()) {
return;
}
if (!$this->isMultipart()) {
return http_build_query($this->fields);
}
$content = '';
foreach ($this->fields as $name => $values) {
$content .= '--'.$this->getBoundary()."\r\n";
if ($values instanceof FormUploadInterface) {
if (!$values->getFilename()) {
throw new LogicException(sprintf('Form upload at "%s" does not include a filename.', $name));
}
$values->setName($name);
$content .= (string) $values;
} else {
foreach (is_array($values) ? $values : array($values) as $value) {
$content .= "Content-Disposition: form-data; name=\"$name\"\r\n";
$content .= "\r\n";
$content .= $value."\r\n";
}
}
}
$content .= '--'.$this->getBoundary().'--';
return $content;
}
// private
private function flattenArray(array $values, $prefix = '', $format = '%s')
{
$flat = array();
foreach ($values as $name => $value) {
$flatName = $prefix.sprintf($format, $name);
if (is_array($value)) {
$flat += $this->flattenArray($value, $flatName, '[%s]');
} else {
$flat[$flatName] = $value;
}
}
return $flat;
}
private function isSafe()
{
return in_array($this->getMethod(), array(self::METHOD_GET, self::METHOD_HEAD));
}
private function isMultipart()
{
foreach ($this->fields as $name => $value) {
if (is_object($value) && $value instanceof FormUploadInterface) {
return true;
}
}
return false;
}
private function getBoundary()
{
if (!$this->boundary) {
$this->boundary = sha1(rand(11111, 99999).time().uniqid());
}
return $this->boundary;
}
}

View file

@ -1,27 +0,0 @@
<?php
namespace Buzz\Message\Form;
use Buzz\Message\RequestInterface;
/**
* An HTTP request message sent by a web form.
*
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
*/
interface FormRequestInterface extends RequestInterface
{
/**
* Returns an array of field names and values.
*
* @return array A array of names and values
*/
public function getFields();
/**
* Sets the form fields for the current request.
*
* @param array $fields An array of field names and values
*/
public function setFields(array $fields);
}

View file

@ -1,118 +0,0 @@
<?php
namespace Buzz\Message\Form;
use Buzz\Message\AbstractMessage;
class FormUpload extends AbstractMessage implements FormUploadInterface
{
private $name;
private $filename;
private $contentType;
private $file;
public function __construct($file = null, $contentType = null)
{
if ($file) {
$this->loadContent($file);
}
$this->contentType = $contentType;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getFilename()
{
if ($this->filename) {
return $this->filename;
} elseif ($this->file) {
return basename($this->file);
}
}
public function setFilename($filename)
{
$this->filename = $filename;
}
public function getContentType()
{
return $this->contentType ?: $this->detectContentType() ?: 'application/octet-stream';
}
public function setContentType($contentType)
{
$this->contentType = $contentType;
}
/**
* Prepends Content-Disposition and Content-Type headers.
*/
public function getHeaders()
{
$headers = array('Content-Disposition: form-data');
if ($name = $this->getName()) {
$headers[0] .= sprintf('; name="%s"', $name);
}
if ($filename = $this->getFilename()) {
$headers[0] .= sprintf('; filename="%s"', $filename);
}
if ($contentType = $this->getContentType()) {
$headers[] = 'Content-Type: '.$contentType;
}
return array_merge($headers, parent::getHeaders());
}
/**
* Loads the content from a file.
*/
public function loadContent($file)
{
$this->file = $file;
parent::setContent(null);
}
public function setContent($content)
{
parent::setContent($content);
$this->file = null;
}
public function getFile()
{
return $this->file;
}
public function getContent()
{
return $this->file ? file_get_contents($this->file) : parent::getContent();
}
// private
private function detectContentType()
{
if (!class_exists('finfo', false)) {
return false;
}
$finfo = new \finfo(FILEINFO_MIME_TYPE);
return $this->file ? $finfo->file($this->file) : $finfo->buffer(parent::getContent());
}
}

View file

@ -1,13 +0,0 @@
<?php
namespace Buzz\Message\Form;
use Buzz\Message\MessageInterface;
interface FormUploadInterface extends MessageInterface
{
public function setName($name);
public function getFile();
public function getFilename();
public function getContentType();
}

View file

@ -1,74 +0,0 @@
<?php
namespace Buzz\Message;
/**
* An HTTP message.
*
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
*/
interface MessageInterface
{
/**
* Returns a header value.
*
* @param string $name A header name
* @param string|boolean $glue Glue for implode, or false to return an array
*
* @return string|array|null The header value(s)
*/
public function getHeader($name, $glue = "\r\n");
/**
* Returns an array of header lines.
*
* @return array An array of header lines (integer indexes, e.g. ["Header: value"])
*/
public function getHeaders();
/**
* Sets all headers on the current message.
*
* Headers can be complete ["Header: value"] pairs or an associative array ["Header" => "value"]
*
* @param array $headers An array of header lines
*/
public function setHeaders(array $headers);
/**
* Adds a header to this message.
*
* @param string $header A header line
*/
public function addHeader($header);
/**
* Adds a set of headers to this message.
*
* Headers can be complete ["Header: value"] pairs or an associative array ["Header" => "value"]
*
* @param array $headers Headers
*/
public function addHeaders(array $headers);
/**
* Returns the content of the message.
*
* @return string The message content
*/
public function getContent();
/**
* Sets the content of the message.
*
* @param string $content The message content
*/
public function setContent($content);
/**
* Returns the message document.
*
* @return string The message
*/
public function __toString();
}

View file

@ -1,174 +0,0 @@
<?php
namespace Buzz\Message;
use Buzz\Util\Url;
class Request extends AbstractMessage implements RequestInterface
{
private $method;
private $resource;
private $host;
private $protocolVersion = 1.0;
/**
* Constructor.
*
* @param string $method
* @param string $resource
* @param string $host
*/
public function __construct($method = self::METHOD_GET, $resource = '/', $host = null)
{
$this->method = strtoupper($method);
$this->resource = $resource;
$this->host = $host;
}
public function setHeaders(array $headers)
{
parent::setHeaders(array());
foreach ($this->flattenHeaders($headers) as $header) {
$this->addHeader($header);
}
}
public function addHeader($header)
{
if (0 === stripos(substr($header, -8), 'HTTP/1.') && 3 == count($parts = explode(' ', $header))) {
list($method, $resource, $protocolVersion) = $parts;
$this->setMethod($method);
$this->setResource($resource);
$this->setProtocolVersion((float) substr($protocolVersion, 5));
} else {
parent::addHeader($header);
}
}
public function setMethod($method)
{
$this->method = strtoupper($method);
}
public function getMethod()
{
return $this->method;
}
public function setResource($resource)
{
$this->resource = $resource;
}
public function getResource()
{
return $this->resource;
}
public function setHost($host)
{
$this->host = $host;
}
public function getHost()
{
return $this->host;
}
public function setProtocolVersion($protocolVersion)
{
$this->protocolVersion = $protocolVersion;
}
public function getProtocolVersion()
{
return $this->protocolVersion;
}
/**
* A convenience method for getting the full URL of the current request.
*
* @return string
*/
public function getUrl()
{
return $this->getHost().$this->getResource();
}
/**
* A convenience method for populating the current request from a URL.
*
* @param Url|string $url An URL
*/
public function fromUrl($url)
{
if (!$url instanceof Url) {
$url = new Url($url);
}
$url->applyToRequest($this);
}
/**
* Returns true if the current request is secure.
*
* @return boolean
*/
public function isSecure()
{
return 'https' == parse_url($this->getHost(), PHP_URL_SCHEME);
}
/**
* Merges cookie headers on the way out.
*/
public function getHeaders()
{
return $this->mergeCookieHeaders(parent::getHeaders());
}
/**
* Returns a string representation of the current request.
*
* @return string
*/
public function __toString()
{
$string = sprintf("%s %s HTTP/%.1f\r\n", $this->getMethod(), $this->getResource(), $this->getProtocolVersion());
if ($host = $this->getHost()) {
$string .= 'Host: '.$host."\r\n";
}
if ($parent = trim(parent::__toString())) {
$string .= $parent."\r\n";
}
return $string;
}
// private
private function mergeCookieHeaders(array $headers)
{
$cookieHeader = null;
$needle = 'Cookie:';
foreach ($headers as $i => $header) {
if (0 !== stripos($header, $needle)) {
continue;
}
if (null === $cookieHeader) {
$cookieHeader = $i;
} else {
$headers[$cookieHeader] .= '; '.trim(substr($header, strlen($needle)));
unset($headers[$i]);
}
}
return array_values($headers);
}
}

View file

@ -1,75 +0,0 @@
<?php
namespace Buzz\Message;
/**
* An HTTP request message.
*
* @author Kris Wallsmith <kris.wallsmith@gmail.com>
*/
interface RequestInterface extends MessageInterface
{
const METHOD_OPTIONS = 'OPTIONS';
const METHOD_GET = 'GET';
const METHOD_HEAD = 'HEAD';
const METHOD_POST = 'POST';
const METHOD_PUT = 'PUT';
const METHOD_DELETE = 'DELETE';
const METHOD_PATCH = 'PATCH';
/**
* Returns the HTTP method of the current request.
*
* @return string An HTTP method
*/
public function getMethod();
/**
* Sets the HTTP method of the current request.
*
* @param string $method The request method
*/
public function setMethod($method);
/**
* Returns the resource portion of the request line.
*
* @return string The resource requested
*/
public function getResource();
/**
* Sets the resource for the current request.
*
* @param string $resource The resource being requested
*/
public function setResource($resource);
/**
* Returns the protocol version of the current request.
*
* @return float The protocol version
*/
public function getProtocolVersion();
/**
* Returns the value of the host header.
*
* @return string|null The host
*/
public function getHost();
/**
* Sets the host for the current request.
*
* @param string $host The host
*/
public function setHost($host);
/**
* Checks if the current request is secure.
*
* @return Boolean True if the request is secure
*/
public function isSecure();
}

View file

@ -1,193 +0,0 @@
<?php
namespace Buzz\Message;
class Response extends AbstractMessage
{
private $protocolVersion;
private $statusCode;
private $reasonPhrase;
/**
* Returns the protocol version of the current response.
*
* @return float
*/
public function getProtocolVersion()
{
if (null === $this->protocolVersion) {
$this->parseStatusLine();
}
return $this->protocolVersion ?: null;
}
/**
* Returns the status code of the current response.
*
* @return integer
*/
public function getStatusCode()
{
if (null === $this->statusCode) {
$this->parseStatusLine();
}
return $this->statusCode ?: null;
}
/**
* Returns the reason phrase for the current response.
*
* @return string
*/
public function getReasonPhrase()
{
if (null === $this->reasonPhrase) {
$this->parseStatusLine();
}
return $this->reasonPhrase ?: null;
}
public function setHeaders(array $headers)
{
parent::setHeaders($headers);
$this->resetStatusLine();
}
public function addHeader($header)
{
parent::addHeader($header);
$this->resetStatusLine();
}
public function addHeaders(array $headers)
{
parent::addHeaders($headers);
$this->resetStatusLine();
}
/**
* Is response invalid?
*
* @return Boolean
*/
public function isInvalid()
{
return $this->getStatusCode() < 100 || $this->getStatusCode() >= 600;
}
/**
* Is response informative?
*
* @return Boolean
*/
public function isInformational()
{
return $this->getStatusCode() >= 100 && $this->getStatusCode() < 200;
}
/**
* Is response successful?
*
* @return Boolean
*/
public function isSuccessful()
{
return $this->getStatusCode() >= 200 && $this->getStatusCode() < 300;
}
/**
* Is the response a redirect?
*
* @return Boolean
*/
public function isRedirection()
{
return $this->getStatusCode() >= 300 && $this->getStatusCode() < 400;
}
/**
* Is there a client error?
*
* @return Boolean
*/
public function isClientError()
{
return $this->getStatusCode() >= 400 && $this->getStatusCode() < 500;
}
/**
* Was there a server side error?
*
* @return Boolean
*/
public function isServerError()
{
return $this->getStatusCode() >= 500 && $this->getStatusCode() < 600;
}
/**
* Is the response OK?
*
* @return Boolean
*/
public function isOk()
{
return 200 === $this->getStatusCode();
}
/**
* Is the reponse forbidden?
*
* @return Boolean
*/
public function isForbidden()
{
return 403 === $this->getStatusCode();
}
/**
* Is the response a not found error?
*
* @return Boolean
*/
public function isNotFound()
{
return 404 === $this->getStatusCode();
}
/**
* Is the response empty?
*
* @return Boolean
*/
public function isEmpty()
{
return in_array($this->getStatusCode(), array(201, 204, 304));
}
// private
private function parseStatusLine()
{
$headers = $this->getHeaders();
if (isset($headers[0]) && 3 == count($parts = explode(' ', $headers[0], 3))) {
$this->protocolVersion = (float) $parts[0];
$this->statusCode = (integer) $parts[1];
$this->reasonPhrase = $parts[2];
} else {
$this->protocolVersion = $this->statusCode = $this->reasonPhrase = false;
}
}
private function resetStatusLine()
{
$this->protocolVersion = $this->statusCode = $this->reasonPhrase = null;
}
}

View file

@ -1,216 +0,0 @@
<?php
namespace Buzz\Util;
use Buzz\Message\RequestInterface;
class Cookie
{
const ATTR_DOMAIN = 'domain';
const ATTR_PATH = 'path';
const ATTR_SECURE = 'secure';
const ATTR_MAX_AGE = 'max-age';
const ATTR_EXPIRES = 'expires';
protected $name;
protected $value;
protected $attributes = array();
protected $createdAt;
/**
* Constructor.
*/
public function __construct()
{
$this->createdAt = time();
}
/**
* Returns true if the current cookie matches the supplied request.
*
* @return boolean
*/
public function matchesRequest(RequestInterface $request)
{
// domain
if (!$this->matchesDomain(parse_url($request->getHost(), PHP_URL_HOST))) {
return false;
}
// path
if (!$this->matchesPath($request->getResource())) {
return false;
}
// secure
if ($this->hasAttribute(static::ATTR_SECURE) && !$request->isSecure()) {
return false;
}
return true;
}
/**
* Returns true of the current cookie has expired.
*
* Checks the max-age and expires attributes.
*
* @return boolean Whether the current cookie has expired
*/
public function isExpired()
{
$maxAge = $this->getAttribute(static::ATTR_MAX_AGE);
if ($maxAge && time() - $this->getCreatedAt() > $maxAge) {
return true;
}
$expires = $this->getAttribute(static::ATTR_EXPIRES);
if ($expires && strtotime($expires) < time()) {
return true;
}
return false;
}
/**
* Returns true if the current cookie matches the supplied domain.
*
* @param string $domain A domain hostname
*
* @return boolean
*/
public function matchesDomain($domain)
{
$cookieDomain = $this->getAttribute(static::ATTR_DOMAIN);
if (0 === strpos($cookieDomain, '.')) {
$pattern = '/\b'.preg_quote(substr($cookieDomain, 1), '/').'$/i';
return (boolean) preg_match($pattern, $domain);
} else {
return 0 == strcasecmp($cookieDomain, $domain);
}
}
/**
* Returns true if the current cookie matches the supplied path.
*
* @param string $path A path
*
* @return boolean
*/
public function matchesPath($path)
{
$needle = $this->getAttribute(static::ATTR_PATH);
return null === $needle || 0 === strpos($path, $needle);
}
/**
* Populates the current cookie with data from the supplied Set-Cookie header.
*
* @param string $header A Set-Cookie header
* @param string $issuingDomain The domain that issued the header
*/
public function fromSetCookieHeader($header, $issuingDomain)
{
list($this->name, $header) = explode('=', $header, 2);
if (false === strpos($header, ';')) {
$this->value = $header;
$header = null;
} else {
list($this->value, $header) = explode(';', $header, 2);
}
$this->clearAttributes();
foreach (array_map('trim', explode(';', trim($header))) as $pair) {
if (false === strpos($pair, '=')) {
$name = $pair;
$value = null;
} else {
list($name, $value) = explode('=', $pair);
}
$this->setAttribute($name, $value);
}
if (!$this->getAttribute(static::ATTR_DOMAIN)) {
$this->setAttribute(static::ATTR_DOMAIN, $issuingDomain);
}
}
/**
* Formats a Cookie header for the current cookie.
*
* @return string An HTTP request Cookie header
*/
public function toCookieHeader()
{
return 'Cookie: '.$this->getName().'='.$this->getValue();
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setValue($value)
{
$this->value = $value;
}
public function getValue()
{
return $this->value;
}
public function setAttributes(array $attributes)
{
// attributes are case insensitive
$this->attributes = array_change_key_case($attributes);
}
public function setAttribute($name, $value)
{
$this->attributes[strtolower($name)] = $value;
}
public function getAttributes()
{
return $this->attributes;
}
public function getAttribute($name)
{
$name = strtolower($name);
if (isset($this->attributes[$name])) {
return $this->attributes[$name];
}
}
public function hasAttribute($name)
{
return array_key_exists($name, $this->attributes);
}
public function clearAttributes()
{
$this->setAttributes(array());
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
public function getCreatedAt()
{
return $this->createdAt;
}
}

View file

@ -1,79 +0,0 @@
<?php
namespace Buzz\Util;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class CookieJar
{
protected $cookies = array();
public function setCookies($cookies)
{
$this->cookies = array();
foreach ($cookies as $cookie) {
$this->addCookie($cookie);
}
}
public function getCookies()
{
return $this->cookies;
}
/**
* Adds a cookie to the current cookie jar.
*
* @param Cookie $cookie A cookie object
*/
public function addCookie(Cookie $cookie)
{
$this->cookies[] = $cookie;
}
/**
* Adds Cookie headers to the supplied request.
*
* @param RequestInterface $request A request object
*/
public function addCookieHeaders(RequestInterface $request)
{
foreach ($this->cookies as $cookie) {
if ($cookie->matchesRequest($request)) {
$request->addHeader($cookie->toCookieHeader());
}
}
}
/**
* Processes Set-Cookie headers from a request/response pair.
*
* @param RequestInterface $request A request object
* @param MessageInterface $response A response object
*/
public function processSetCookieHeaders(RequestInterface $request, MessageInterface $response)
{
foreach ($response->getHeader('Set-Cookie', false) as $header) {
$cookie = new Cookie();
$cookie->fromSetCookieHeader($header, parse_url($request->getHost(), PHP_URL_HOST));
$this->addCookie($cookie);
}
}
/**
* Removes expired cookies.
*/
public function clearExpiredCookies()
{
foreach ($this->cookies as $i => $cookie) {
if ($cookie->isExpired()) {
unset($this->cookies[$i]);
}
}
// reset array keys
$this->cookies = array_values($this->cookies);
}
}

View file

@ -1,190 +0,0 @@
<?php
namespace Buzz\Util;
use Buzz\Message\RequestInterface;
use Buzz\Exception\InvalidArgumentException;
class Url
{
private static $defaultPorts = array(
'http' => 80,
'https' => 443,
);
private $url;
private $components;
/**
* Constructor.
*
* @param string $url The URL
*
* @throws InvalidArgumentException If the URL is invalid
*/
public function __construct($url)
{
$components = parse_url($url);
if (false === $components) {
throw new InvalidArgumentException(sprintf('The URL "%s" is invalid.', $url));
}
// support scheme-less URLs
if (!isset($components['host']) && isset($components['path'])) {
$pos = strpos($components['path'], '/');
if (false === $pos) {
$components['host'] = $components['path'];
unset($components['path']);
} elseif (0 !== $pos) {
list($host, $path) = explode('/', $components['path'], 2);
$components['host'] = $host;
$components['path'] = '/'.$path;
}
}
// default port
if (isset($components['scheme']) && !isset($components['port']) && isset(self::$defaultPorts[$components['scheme']])) {
$components['port'] = self::$defaultPorts[$components['scheme']];
}
$this->url = $url;
$this->components = $components;
}
public function getScheme()
{
return $this->parseUrl('scheme');
}
public function getHostname()
{
return $this->parseUrl('host');
}
public function getPort()
{
return $this->parseUrl('port');
}
public function getUser()
{
return $this->parseUrl('user');
}
public function getPassword()
{
return $this->parseUrl('pass');
}
public function getPath()
{
return $this->parseUrl('path');
}
public function getQueryString()
{
return $this->parseUrl('query');
}
public function getFragment()
{
return $this->parseUrl('fragment');
}
/**
* Returns a host string that combines scheme, hostname and port.
*
* @return string A host value for an HTTP message
*/
public function getHost()
{
if ($hostname = $this->parseUrl('host')) {
$host = $scheme = $this->parseUrl('scheme', 'http');
$host .= '://';
$host .= $hostname;
$port = $this->parseUrl('port');
if ($port && (!isset(self::$defaultPorts[$scheme]) || self::$defaultPorts[$scheme] != $port)) {
$host .= ':'.$port;
}
return $host;
}
}
/**
* Returns a resource string that combines path and query string.
*
* @return string A resource value for an HTTP message
*/
public function getResource()
{
$resource = $this->parseUrl('path', '/');
if ($query = $this->parseUrl('query')) {
$resource .= '?'.$query;
}
return $resource;
}
/**
* Returns a formatted URL.
*/
public function format($pattern)
{
static $map = array(
's' => 'getScheme',
'u' => 'getUser',
'a' => 'getPassword',
'h' => 'getHostname',
'o' => 'getPort',
'p' => 'getPath',
'q' => 'getQueryString',
'f' => 'getFragment',
'H' => 'getHost',
'R' => 'getResource',
);
$url = '';
$parts = str_split($pattern);
while ($part = current($parts)) {
if (isset($map[$part])) {
$method = $map[$part];
$url .= $this->$method();
} elseif ('\\' == $part) {
$url .= next($parts);
} elseif (!ctype_alpha($part)) {
$url .= $part;
} else {
throw new InvalidArgumentException(sprintf('The format character "%s" is invalid.', $part));
}
next($parts);
}
return $url;
}
/**
* Applies the current URL to the supplied request.
*/
public function applyToRequest(RequestInterface $request)
{
$request->setResource($this->getResource());
$request->setHost($this->getHost());
}
private function parseUrl($component = null, $default = null)
{
if (null === $component) {
return $this->components;
} elseif (isset($this->components[$component])) {
return $this->components[$component];
} else {
return $default;
}
}
}

View file

@ -1,19 +0,0 @@
<?php
namespace KeenIO\Http\Adaptor;
/**
* Class AdaptorInterface
*
* @package KeenIO\Http\Adaptor
*/
interface AdaptorInterface
{
/**
* post to the KeenIO API
*
* @param $url
* @param array $parameters
* @return mixed
*/
public function doPost($url, array $parameters);
}

View file

@ -1,49 +0,0 @@
<?php
namespace KeenIO\Http\Adaptor;
use Buzz\Browser;
use Buzz\Client\Curl;
/**
* Class Buzz
* @package KeenIO\Http\Adaptor
*/
final class Buzz implements AdaptorInterface
{
private $apiKey;
private $browser;
/**
* @param $apiKey
* @param null $client
*/
public function __construct($apiKey)
{
$this->apiKey = $apiKey;
$this->browser = new Browser(new Curl());
$this->browser->getClient()->setVerifyPeer(false);
}
/**
* post to the KeenIO API
*
* @param $url
* @param array $parameters
* @return mixed
*/
public function doPost($url, array $parameters)
{
$headers = array(
// 'Authorization' => $this->apiKey,
'Content-Type' => 'application/json'
);
$content = json_encode($parameters);
$response = $this->browser->post($url, $headers, $content);
return $response->getContent();
}
}

View file

@ -1,215 +0,0 @@
<?php
namespace KeenIO\Service;
use KeenIO\Http\Adaptor\AdaptorInterface
, KeenIO\Http\Adaptor\Buzz as BuzzHttpAdaptor
;
/**
* Class KeenIO
*
* @package KeenIO\Service
*/
final class KeenIO
{
private static $projectId;
private static $apiKey;
private static $httpAdaptor;
public static function getApiKey()
{
return self::$apiKey;
}
/**
* @param $value
* @throws \Exception
*/
public static function setApiKey($value)
{
if (!ctype_alnum($value)) {
throw new \Exception(sprintf("API Key '%s' contains invalid characters or spaces.", $value));
}
self::$apiKey = $value;
}
public static function getProjectId()
{
return self::$projectId;
}
/**
* @param $value
* @throws \Exception
*/
public static function setProjectId($value)
{
// Validate collection name
if (!ctype_alnum($value)) {
throw new \Exception(
"Project ID '" . $value . "' contains invalid characters or spaces."
);
}
self::$projectId = $value;
}
/**
* @return BuzzHttpAdaptor
*/
public static function getHttpAdaptor()
{
if (!self::$httpAdaptor) {
self::$httpAdaptor = new BuzzHttpAdaptor(self::getApiKey());
}
return self::$httpAdaptor;
}
/**
* @param AdaptorInterface $httpAdaptor
*/
public static function setHttpAdaptor(AdaptorInterface $httpAdaptor)
{
self::$httpAdaptor = $httpAdaptor;
}
/**
* @param $projectId
* @param $apiKey
*/
public static function configure($projectId, $apiKey)
{
self::setProjectId($projectId);
self::setApiKey($apiKey);
}
/**
* add an event to KeenIO
*
* @param $collectionName
* @param $parameters
* @return mixed
* @throws \Exception
*/
public static function addEvent($collectionName, $parameters = array())
{
self::validateConfiguration();
if (!ctype_alnum($collectionName)) {
throw new \Exception(
sprintf("Collection name '%s' contains invalid characters or spaces.", $collectionName)
);
}
$url = sprintf(
'https://api.keen.io/3.0/projects/%s/events/%s',
self::getProjectId(),
$collectionName
);
$response = self::getHttpAdaptor()->doPost($url, $parameters);
$json = json_decode($response);
return $json->created;
}
/**
* get a scoped key for an array of filters
*
* @param $filters
* @return string
*/
public static function getScopedKey($filters)
{
self::validateConfiguration();
$filterArray = array('filters' => $filters);
$filterJson = self::padString(json_encode($filterArray));
$ivLength = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($ivLength);
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, self::getApiKey(), $filterJson, MCRYPT_MODE_CBC, $iv);
$ivHex = bin2hex($iv);
$encryptedHex = bin2hex($encrypted);
$scopedKey = $ivHex . $encryptedHex;
return $scopedKey;
}
/**
* decrypt a scoped key (primarily used for testing)
*
* @param $scopedKey
* @return mixed
*/
public static function decryptScopedKey($scopedKey)
{
$ivLength = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC) * 2;
$ivHex = substr($scopedKey, 0, $ivLength);
$encryptedHex = substr($scopedKey, $ivLength);
$resultPadded = mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
self::getApiKey(),
pack('H*', $encryptedHex),
MCRYPT_MODE_CBC,
pack('H*', $ivHex)
);
$result = self::unpadString($resultPadded);
$filterArray = json_decode($result, true);
return $filterArray['filters'];
}
/**
* implement PKCS7 padding
*
* @param $string
* @param int $blockSize
* @return string
*/
protected static function padString($string, $blockSize = 32)
{
$paddingSize = $blockSize - (strlen($string) % $blockSize);
$string .= str_repeat(chr($paddingSize), $paddingSize);
return $string;
}
/**
* remove padding for a PKCS7-padded string
*
* @param $string
* @return string
*/
protected static function unpadString($string)
{
$len = strlen($string);
$pad = ord($string[$len - 1]);
return substr($string, 0, $len - $pad);
}
protected static function validateConfiguration()
{
// Validate configuration
if (!self::getProjectId()) {
throw new \Exception('Keen IO has not been configured');
}
// if (!self::getProjectId() or !self::getApiKey()) {
// throw new \Exception('Keen IO has not been configured');
// }
}
}

File diff suppressed because one or more lines are too long

View file

@ -1,370 +0,0 @@
(function(h,j,e,Ta,P,Y,ra,i){function B(){this.sBase="#/";this.sCdnStaticDomain=f.settingsGet("CdnStaticDomain");this.sVersion=f.settingsGet("Version");this.sIndexFile=f.settingsGet("IndexFile");this.sSpecSuffix=f.settingsGet("AuthAccountHash")||"0";this.sServer=null===this.sIndexFile?"?":this.sIndexFile+"?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function n(a,b,d,l){this.oOptions=
l=j.extend({DisableHtml:!1,onSwitch:!1,LangSwitcherConferm:"EDITOR_TEXT_SWITCHER_CONFIRM",LangSwitcherTextLabel:"EDITOR_SWITCHER_TEXT_LABEL",LangSwitcherHtmlLabel:"EDITOR_SWITCHER_HTML_LABEL"},c.isUnd(l)?{}:l);this.bOnlyPlain=!!this.oOptions.DisableHtml;this.fOnSwitch=this.oOptions.onSwitch;this.textarea=j(a).empty().addClass("editorTextArea");this.htmlarea=j(b).empty().addClass("editorHtmlArea").prop("contentEditable","true");this.toolbar=j(d).empty().addClass("editorToolbar");n.htmlInitEditor.apply(this);
n.htmlInitToolbar.apply(this);n.htmlAttachEditorEvents.apply(this);this.bOnlyPlain&&this.toolbar.hide()}function M(a,b,d,l,f){this.list=a;this.selectedItem=b;this.selectedItem.extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.oContentScrollable=this.oContentVisible=null;this.sItemSelector=d;this.sItemSelectedSelector=l;this.sItemCheckedSelector=f;this.sLastUid="";this.oCallbacks={};this.iSelectTimer=0;this.bUseKeyboard=!0;this.emptyFunction=function(){};
this.useItemSelectCallback=!0;this.selectedItem.subscribe(function(a){this.useItemSelectCallback&&(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},this);var e=this,g=[],k=null;this.list.subscribe(function(){var a=this,b=this.list();c.isArray(b)&&i.each(b,function(b){b.checked()&&g.push(a.getItemUid(b));null===k&&b.selected()&&(k=a.getItemUid(b))})},this,"beforeChange");this.list.subscribe(function(a){this.useItemSelectCallback=!1;this.selectedItem(null);if(c.isArray(a)){var b=this,d=g.length;
i.each(a,function(a){0<d&&-1<c.inArray(b.getItemUid(a),g)&&(a.checked(!0),d--);null!==k&&k===b.getItemUid(a)&&(a.selected(!0),k=null,b.selectedItem(a))})}this.useItemSelectCallback=!0;g=[];k=null},this);this.list.setSelectedByUid=function(a){e.selectByUid(a,!1)}}function sa(){}function ta(){}function ua(){var a=i.find([ta,sa],function(a){return a.supported()});a&&(this.oDriver=new a)}function Ua(){}function C(a,b){this.sPosition=c.pString(a);this.sTemplate=c.pString(b);this.viewModelName="";this.viewModelVisibility=
e.observable(!1);"Popups"===this.sPosition&&(this.modalVisibility=e.observable(!1));this.viewModelDom=null}function J(a,b){this.sScreenName=a;this.aViewModels=c.isArray(b)?b:[]}function E(){this.sDefaultScreenName="";this.oScreens={};this.oCurrentScreen=this.oBoot=null;this.popupVisibility=e.observable(!1);this.popupVisibility.subscribe(function(a){f&&f.popupVisibility(a)})}function F(a,b){this.email=a||"";this.name=b||"";this.privateType=null;this.clearDuplicateName()}function ja(){this.idContact=
0;this.name=this.listName=this.imageHash="";this.emails=[];this.checked=e.observable(!1);this.selected=e.observable(!1);this.deleted=e.observable(!1)}function D(){this.fileName=this.mimeType="";this.estimatedSize=0;this.friendlySize="";this.isLinked=this.isInline=!1;this.mimeIndex=this.uid=this.folder=this.download=this.cidWithOutTags=this.cid=""}function N(a,b,d,l,f,q){this.id=a;this.isInline=c.isUnd(l)?!1:!!l;this.isLinked=c.isUnd(f)?!1:!!f;this.CID=c.isUnd(q)?"":q;this.fromMessage=!1;this.fileName=
e.observable(b);this.size=e.observable(c.isUnd(d)?null:d);this.tempName=e.observable("");this.progress=e.observable("");this.error=e.observable("");this.waiting=e.observable(!0);this.uploading=e.observable(!1);this.enabled=e.observable(!0);this.friendlySize=e.computed(function(){return null===this.size()?"":c.friendlySize(this.size())},this)}function m(){this.requestHash=this.uid=this.folderFullNameRaw="";this.subject=e.observable("");this.size=e.observable(0);this.dateTimeStampInUTC=e.observable(0);
this.priority=e.observable(g.MessagePriority.Normal);this.fromEmailString=e.observable("");this.toEmailsString=e.observable("");this.senderEmailsString=e.observable("");this.emails=[];this.from=[];this.to=[];this.cc=[];this.bcc=[];this.replyTo=[];this.newForAnimation=e.observable(!1);this.deleted=e.observable(!1);this.unseen=e.observable(!1);this.flagged=e.observable(!1);this.answered=e.observable(!1);this.forwarded=e.observable(!1);this.selected=e.observable(!1);this.checked=e.observable(!1);this.hasAttachments=
e.observable(!1);this.moment=e.observable(Y());this.fullFormatDateValue=e.computed(function(){return m.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this);this.fullFormatDateValue=e.computed(function(){return m.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this);this.momentDate=c.createMomentDate(this);this.momentShortDate=c.createMomentShortDate(this);this.dateTimeStampInUTC.subscribe(function(a){var b=Y().unix();this.moment(Y.unix(b<a?b:a))},this);this.body=null;this.isHtml=
e.observable(!1);this.hasImages=e.observable(!1);this.attachments=e.observableArray([]);this.priority=e.observable(g.MessagePriority.Normal);this.aDraftInfo=[];this.sReferences=this.sInReplyTo=this.sMessageId="";this.parentUid=e.observable(0);this.threads=e.observableArray([]);this.threadsLen=e.observable(0);this.hasUnseenSubMessage=e.observable(!1);this.hasFlaggedSubMessage=e.observable(!1);this.lastInCollapsedThread=e.observable(!1);this.lastInCollapsedThreadLoading=e.observable(!1);this.threadsLenResult=
e.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&0<a?a+1:""},this)}function G(){this.name=e.observable("");this.namespace=this.delimiter=this.fullNameHash=this.fullNameRaw=this.fullName="";this.deep=0;this.selectable=!1;this.existen=!0;this.isUnpaddigFolder=this.isGmailFolder=this.isNamespaceFolder=!1;this.type=e.observable(g.FolderType.User);this.selected=e.observable(!1);this.edited=e.observable(!1);this.collapsed=e.observable(!0);this.subScribed=e.observable(!0);this.subFolders=
e.observableArray([]);this.deleteAccess=e.observable(!1);this.actionBlink=e.observable(!1).extend({falseTimeout:1E3});this.nameForEdit=e.observable("");this.name.subscribe(function(a){this.nameForEdit(a)},this);this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this);this.canBeEdited=e.computed(function(){return g.FolderType.User===this.type()},this);this.privateMessageCountAll=e.observable(0);this.privateMessageCountUnread=e.observable(0);this.collapsedPrivate=e.observable(!0)}function Ka(a,
b){this.email=a;this.deleteAccess=e.observable(!1);this.canBeDalete=e.observable(b)}function va(){C.call(this,"Popups","PopupsFolderClear");this.selectedFolder=e.observable(null);this.clearingProcess=e.observable(!1);this.clearingError=e.observable("");this.folderFullNameForClear=e.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this);this.folderNameForClear=e.computed(function(){var a=this.selectedFolder();return a?a.localName():""},this);this.dangerDescHtml=e.computed(function(){return c.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",
{FOLDER:this.folderNameForClear()})},this);this.clearCommand=c.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(f.data().message(null),f.data().messageList([]),this.clearingProcess(!0),f.cache().setFolderHash(b.fullNameRaw,""),f.remote().folderClear(function(b,l){a.clearingProcess(!1);g.StorageResultType.Success===b&&l&&l.Result?(f.reloadMessageList(!0),a.cancelCommand()):l&&l.ErrorCode?a.clearingError(c.getNotification(l.ErrorCode)):a.clearingError(c.getNotification(g.Notification.MailServerError))},
b.fullNameRaw))},function(){var a=this.selectedFolder();return!this.clearingProcess()&&null!==a})}function ba(){C.call(this,"Popups","PopupsFolderCreate");c.initOnStartOrLangChange(function(){this.sNoParentText=c.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this);this.folderName=e.observable("");this.focusTrigger=e.observable(!1);this.selectedParentValue=e.observable(t.Values.UnuseOptionValue);this.parentFolderSelectList=e.computed(function(){var a=f.data(),b=[],d=null,l=a.folderList();b.push(["",
this.sNoParentText]);""!==a.namespace&&(d=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)});return f.folderListOptionsBuilder([],l,[],b,null,d,null,function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""})},this);this.createFolder=c.createCommand(this,function(){var a=f.data(),b=this.selectedParentValue();""===b&&1<a.namespace.length&&(b=a.namespace.substr(0,a.namespace.length-1));a.foldersCreating(!0);f.remote().folderCreate(function(a,
b){f.data().foldersCreating(!1);g.StorageResultType.Success===a&&b&&b.Result?f.folders(!1):f.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"))},this.folderName(),b);this.cancelCommand()},function(){return this.simpleFolderNameValidation(this.folderName())});this.defautOptionsAfterRender=c.defautOptionsAfterRender}function X(){C.call(this,"Popups","PopupsFolderSystem");c.initOnStartOrLangChange(function(){this.sChooseOnText=c.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE");
this.sUnuseText=c.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME")},this);this.notification=e.observable("");this.folderSelectList=e.computed(function(){return f.folderListOptionsBuilder([],f.data().folderList(),f.data().folderListSystemNames(),[["",this.sChooseOnText],[t.Values.UnuseOptionValue,this.sUnuseText]])},this);var a=f.data(),b=this,d=null,l=null;this.sentFolder=a.sentFolder;this.draftFolder=a.draftFolder;this.spamFolder=a.spamFolder;this.trashFolder=a.trashFolder;d=i.debounce(function(){f.settingsSet("SentFolder",
b.sentFolder());f.settingsSet("DraftFolder",b.draftFolder());f.settingsSet("SpamFolder",b.spamFolder());f.settingsSet("TrashFolder",b.trashFolder());f.remote().saveSystemFolders(c.emptyFunction,{SentFolder:b.sentFolder(),DraftFolder:b.draftFolder(),SpamFolder:b.spamFolder(),TrashFolder:b.trashFolder()})},1E3);l=function(){f.settingsSet("SentFolder",b.sentFolder());f.settingsSet("DraftFolder",b.draftFolder());f.settingsSet("SpamFolder",b.spamFolder());f.settingsSet("TrashFolder",b.trashFolder());d()};
this.sentFolder.subscribe(l);this.draftFolder.subscribe(l);this.spamFolder.subscribe(l);this.trashFolder.subscribe(l);this.defautOptionsAfterRender=c.defautOptionsAfterRender}function y(){C.call(this,"Popups","PopupsCompose");this.aDraftInfo=this.oEditor=null;this.sInReplyTo="";this.bFromDraft=!1;this.sReferences="";this.bReloadFolder=!1;var a=this,b=function(a){for(var b=0,d=a.length,c=[];b<d;b++)c.push(a[b].toLine(!1));return c.join(", ")},d=function(a){!1===this.showCcAndBcc()&&0<a.length&&this.showCcAndBcc(!0)};
this.resizer=e.observable(!1).extend({throttle:50});this.to=e.observableArray([]);this.cc=e.observableArray([]);this.bcc=e.observableArray([]);this.subject=e.observable("");this.sendError=e.observable(!1);this.sendSuccessButSaveError=e.observable(!1);this.savedError=e.observable(!1);this.savedTime=e.observable(0);this.savedOrSendingText=e.observable("");this.emptyToError=e.observable(!1);this.showCcAndBcc=e.observable(!1);this.cc.subscribe(d,this);this.bcc.subscribe(d,this);this.draftFolder=e.observable("");
this.draftUid=e.observable("");this.sending=e.observable(!1);this.saving=e.observable(!1);this.attachments=e.observableArray([]);this.attachmentsInProcess=e.computed(function(){return i.filter(this.attachments(),function(a){return a&&""===a.tempName()})},this);this.attachmentsInReady=e.computed(function(){return i.filter(this.attachments(),function(a){return a&&""!==a.tempName()})},this);this.attachments.subscribe(function(){this.triggerForResize()},this);this.isDraftFolderMessage=e.computed(function(){return""!==
this.draftFolder()&&""!==this.draftUid()},this);this.composeUploaderButton=e.observable(null);this.composeUploaderDropPlace=e.observable(null);this.dragAndDropEnabled=e.observable(!1);this.dragAndDropOver=e.observable(!1).extend({throttle:1});this.dragAndDropVisible=e.observable(!1).extend({throttle:1});this.attacheMultipleAllowed=e.observable(!1);this.addAttachmentEnabled=e.observable(!1);this.composeEditorTextArea=e.observable(null);this.composeEditorHtmlArea=e.observable(null);this.composeEditorToolbar=
e.observable(null);this.to.subscribe(function(a){this.emptyToError()&&0<a.length&&this.emptyToError(!1)},this);this.canBeSended=e.computed(function(){return!this.sending()&&!this.saving()&&0===this.attachmentsInProcess().length&&0<this.to().length},this);this.canBeSendedOrSaved=e.computed(function(){return!this.sending()&&!this.saving()},this);this.deleteCommand=c.createCommand(this,function(){var a=null,b=this.draftFolder(),d=this.draftUid();this.bFromDraft&&(a=f.data().message())&&(b===a.folderFullNameRaw&&
d===a.uid)&&f.data().message(null);f.data().currentFolderFullNameRaw()===this.draftFolder()&&i.each(f.data().messageList(),function(a){a&&(b===a.folderFullNameRaw&&d===a.uid)&&a.deleted(true)});f.data().messageListIsNotCompleted(!0);f.remote().messagesDelete(function(){f.cache().setFolderHash(b,"");f.reloadMessageList()},this.draftFolder(),[this.draftUid()]);this.bReloadFolder=!1;s.hideScreenPopup(y)},function(){return this.isDraftFolderMessage()});this.sendMessageResponse=i.bind(this.sendMessageResponse,
this);this.saveMessageResponse=i.bind(this.saveMessageResponse,this);this.sendCommand=c.createCommand(this,function(){var a=this.to(),d=f.data().sentFolder(),e=[];if(0===a.length)this.emptyToError(!0);else if(f.data().replySameFolder()&&c.isArray(this.aDraftInfo)&&(3===this.aDraftInfo.length&&c.isNormal(this.aDraftInfo[2])&&0<this.aDraftInfo[2].length)&&(d=this.aDraftInfo[2]),""===d)s.showScreenPopup(X,[g.SetSystemFoldersNotification.Sent]);else{this.sendError(!1);this.sending(!0);this.bReloadFolder=
!0;if(c.isArray(this.aDraftInfo)&&3===this.aDraftInfo.length&&(e=f.cache().getMessageFlagsFromCache(this.aDraftInfo[2],this.aDraftInfo[1])))"forward"===this.aDraftInfo[0]?e[3]=!0:e[2]=!0,f.cache().setMessageFlagsToCache(this.aDraftInfo[2],this.aDraftInfo[1],e),f.reloadFlagsCurrentMessageListAndMessageFromCache();d=t.Values.UnuseOptionValue===d?"":d;f.cache().setFolderHash(this.draftFolder(),"");f.cache().setFolderHash(d,"");f.remote().sendMessage(this.sendMessageResponse,this.draftFolder(),this.draftUid(),
d,b(a),b(this.cc()),b(this.bcc()),this.subject(),this.oEditor.isHtml(),this.oEditor.getTextForRequest(),this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences)}},this.canBeSendedOrSaved);this.saveCommand=c.createCommand(this,function(){f.data().draftFolderNotEnabled()?s.showScreenPopup(X,[g.SetSystemFoldersNotification.Draft]):(this.savedError(!1),this.saving(!0),this.bReloadFolder=!0,f.cache().setFolderHash(f.data().draftFolder(),""),f.remote().saveMessage(this.saveMessageResponse,
this.draftFolder(),this.draftUid(),f.data().draftFolder(),b(this.to()),b(this.cc()),b(this.bcc()),this.subject(),this.oEditor.isHtml(),this.oEditor.getTextForRequest(),this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences))},this.canBeSendedOrSaved);wa.subscribe(function(){this.modalVisibility()&&(!f.data().draftFolderNotEnabled()&&!this.isEmptyForm(!1)&&!this.saving()&&!this.sending()&&!this.savedError())&&this.saveCommand()},this);c.initOnStartOrLangChange(null,
this,function(){this.oEditor&&this.oEditor.initLanguage(c.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),c.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),c.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))});this.showCcAndBcc.subscribe(function(){this.triggerForResize()},this);this.dropboxEnabled=e.observable(f.settingsGet("DropboxApiKey")?!0:!1);this.dropboxCommand=c.createCommand(this,function(){Dropbox.choose({success:function(b){b&&(b[0]&&b[0].link)&&a.addDropboxAttachment(b[0])},linkType:"direct",multiselect:!1});
return!0},function(){return this.dropboxEnabled()});this.modalVisibility.subscribe(function(a){!a&&this.bReloadFolder&&(this.bReloadFolder=!1,f.reloadMessageList())},this);this.driveEnabled=e.observable(!1);this.driveCommand=c.createCommand(this,function(){return!0},function(){return this.driveEnabled()})}function L(){C.call(this,"Popups","PopupsContacts");var a=this;this.imageUploader=e.observable(null);this.imageDom=e.observable(null);this.imageTrigger=e.observable(!1);this.search=e.observable("");
this.contacts=e.observableArray([]);this.contacts.loading=e.observable(!1).extend({throttle:200});this.currentContact=e.observable(null);this.emptySelection=e.observable(!0);this.viewClearSearch=e.observable(!1);this.viewID=e.observable("");this.viewName=e.observable("");this.viewName.focused=e.observable(!1);this.viewEmail=e.observable("").validateEmail();this.viewEmail.focused=e.observable(!1);this.viewImageUrl=e.observable(f.link().emptyContactPic());this.viewSaving=e.observable(!1);this.useCheckboxesInList=
f.data().useCheckboxesInList;this.search.subscribe(function(){this.reloadContactList()},this);this.contacts.subscribe(function(){c.windowResize()},this);this.viewImageUrl.subscribe(function(a){this.imageDom().src=a},this);this.contactsChecked=e.computed(function(){return i.filter(this.contacts(),function(a){return a.checked()})},this);this.contactsCheckedOrSelected=e.computed(function(){var a=this.contactsChecked(),d=this.currentContact();return i.union(a,d?[d]:[])},this);this.contactsCheckedOrSelectedUids=
e.computed(function(){return i.map(this.contactsCheckedOrSelected(),function(a){return a.idContact})},this);this.newCommand=c.createCommand(this,function(){this.populateViewContact(null)});this.selector=new M(this.contacts,this.currentContact,".e-contact-item .actionHandle",".e-contact-item.selected",".e-contact-item .checkboxItem");this.selector.on("onItemSelect",i.bind(function(a){this.populateViewContact(a?a:null)},this));this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""});
this.selector.on("onDelete",i.bind(function(){this.deleteCommand()},this));this.newCommand=c.createCommand(this,function(){this.populateViewContact(null);this.currentContact(null)});this.deleteCommand=c.createCommand(this,function(){this.deleteSelectedContacts()},function(){return 0<this.contactsCheckedOrSelected().length});this.newMessageCommand=c.createCommand(this,function(){var a=this.contactsCheckedOrSelected(),d=[];c.isNonEmptyArray(a)&&(d=i.map(a,function(a){return a&&a.emails&&(a=new F(a.emails[0]||
"",a.name),a.validate())?a:null}),d=i.compact(d));c.isNonEmptyArray(a)&&(s.hideScreenPopup(L),s.showScreenPopup(y,[g.ComposeType.Empty,null,d]))},function(){return 0<this.contactsCheckedOrSelected().length});this.clearCommand=c.createCommand(this,function(){this.search("")});this.saveCommand=c.createCommand(this,function(){var b=c.fakeMd5(),d=this.imageTrigger();this.viewSaving(!0);f.remote().contactSave(function(l,e){a.viewSaving(!1);g.StorageResultType.Success===l&&(e&&e.Result&&e.Result.RequestUid===
b&&0<c.pInt(e.Result.ResultID))&&(""===a.viewID()&&a.viewID(c.pInt(e.Result.ResultID)),a.reloadContactList(),d&&f.emailsPicsHashes())},b,this.viewID(),this.viewName(),this.viewEmail(),d?this.imageDom().src:"")},function(){var a=this.viewName(),d=this.viewEmail();return!this.viewSaving()&&(""!==a||""!==d)})}function ca(){C.call(this,"Popups","PopupsAdvancedSearch");this.fromFocus=e.observable(!1);this.from=e.observable("");this.to=e.observable("");this.subject=e.observable("");this.text=e.observable("");
this.selectedDateValue=e.observable(-1);this.hasAttachments=e.observable(!1);this.searchCommand=c.createCommand(this,function(){var a=this.buildSearchString();""!==a&&f.data().mainMessageListSearch(a);this.cancelCommand()})}function da(){C.call(this,"Popups","PopupsAddAccount");this.email=e.observable("");this.login=e.observable("");this.password=e.observable("");this.emailError=e.observable(!1);this.loginError=e.observable(!1);this.passwordError=e.observable(!1);this.email.subscribe(function(){this.emailError(!1)},
this);this.login.subscribe(function(){this.loginError(!1)},this);this.password.subscribe(function(){this.passwordError(!1)},this);this.allowCustomLogin=e.observable(!1);this.submitRequest=e.observable(!1);this.submitError=e.observable("");this.emailFocus=e.observable(!1);this.loginFocus=e.observable(!1);this.addAccountCommand=c.createCommand(this,function(){this.emailError(""===c.trim(this.email()));this.passwordError(""===c.trim(this.password()));if(this.emailError()||this.passwordError())return!1;
this.submitRequest(!0);f.remote().accountAdd(i.bind(function(a,b){this.submitRequest(!1);g.StorageResultType.Success===a&&b&&"AccountAdd"===b.Action?b.Result?(f.accounts(),this.cancelCommand()):b.ErrorCode&&this.submitError(c.getNotification(b.ErrorCode)):this.submitError(c.getNotification(g.Notification.UnknownError))},this),this.email(),this.login(),this.password());return!0},function(){return!this.submitRequest()});this.loginFocus.subscribe(function(a){a&&(""===this.login()&&""!==this.email())&&
this.login(this.email())},this)}function ka(){C.call(this,"Right","Login");this.email=e.observable("");this.login=e.observable("");this.password=e.observable("");this.signMe=e.observable(!1);this.logoMain=e.observable("RainLoop");this.emailError=e.observable(!1);this.loginError=e.observable(!1);this.passwordError=e.observable(!1);this.emailFocus=e.observable(!1);this.loginFocus=e.observable(!1);this.submitFocus=e.observable(!1);this.email.subscribe(function(){this.emailError(!1)},this);this.login.subscribe(function(){this.loginError(!1)},
this);this.password.subscribe(function(){this.passwordError(!1)},this);this.allowCustomLogin=e.observable(!1);this.submitRequest=e.observable(!1);this.submitError=e.observable("");this.signMeType=e.observable(g.LoginSignMeType.Unused);this.signMeType.subscribe(function(a){this.signMe(g.LoginSignMeType.DefaultOn===a)},this);this.signMeVisibility=e.computed(function(){return g.LoginSignMeType.Unused!==this.signMeType()},this);this.submitCommand=c.createCommand(this,function(){this.emailError(""===c.trim(this.email()));
this.passwordError(""===c.trim(this.password()));if(this.emailError()||this.passwordError())return!1;this.submitRequest(!0);f.remote().login(i.bind(function(a,b){g.StorageResultType.Success===a&&b&&"Login"===b.Action?b.Result?f.loginAndLogoutReload():b.ErrorCode?(this.submitRequest(!1),this.submitError(c.getNotification(b.ErrorCode))):this.submitRequest(!1):(this.submitRequest(!1),this.submitError(c.getNotification(g.Notification.UnknownError)))},this),this.email(),this.login(),this.password(),!!this.signMe());
return!0},function(){return!this.submitRequest()});this.facebookLoginEnabled=e.observable(!1);this.facebookCommand=c.createCommand(this,function(){h.open(f.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");return!0},function(){return!this.submitRequest()&&this.facebookLoginEnabled()});this.googleLoginEnabled=e.observable(!1);this.googleCommand=c.createCommand(this,function(){h.open(f.link().socialGoogle(),"Google","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");
return!0},function(){return!this.submitRequest()&&this.googleLoginEnabled()});this.twitterLoginEnabled=e.observable(!1);this.twitterCommand=c.createCommand(this,function(){h.open(f.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");return!0},function(){return!this.submitRequest()&&this.twitterLoginEnabled()});this.loginFocus.subscribe(function(a){a&&(""===this.login()&&""!==this.email())&&this.login(this.email())},this)}function Q(){C.call(this,
"Right","SystemDropDown");var a=f.data();this.accounts=a.accounts;this.accountEmail=a.accountEmail;this.accountsLoading=a.accountsLoading;this.allowAddAccount=f.settingsGet("AllowAdditionalAccounts");this.loading=e.computed(function(){return this.accountsLoading()},this);this.accountClick=i.bind(this.accountClick,this)}function Va(){Q.call(this)}function Wa(){Q.call(this)}function ea(){C.call(this,"Left","MailFolderList");this.folderList=f.data().folderList;this.folderListSystem=f.data().folderListSystem;
this.allowContacts=!!f.settingsGet("ContactsIsSupported")}function z(){C.call(this,"Right","MailMessageList");this.sLastUid=null;this.emptySubjectValue="";var a=f.data();this.popupVisibility=f.popupVisibility;this.messageList=a.messageList;this.currentMessage=a.currentMessage;this.isMessageSelected=a.isMessageSelected;this.messageListSearch=a.messageListSearch;this.messageListError=a.messageListError;this.folderMenuForMove=a.folderMenuForMove;this.useCheckboxesInList=a.useCheckboxesInList;this.mainMessageListSearch=
a.mainMessageListSearch;this.messageListEndFolder=a.messageListEndFolder;this.messageListChecked=a.messageListChecked;this.messageListCheckedOrSelected=a.messageListCheckedOrSelected;this.messageListCheckedOrSelectedUidsWithSubMails=a.messageListCheckedOrSelectedUidsWithSubMails;this.messageListCompleteLoadingThrottle=a.messageListCompleteLoadingThrottle;c.initOnStartOrLangChange(function(){this.emptySubjectValue=c.i18n("MESSAGE_LIST/EMPTY_SUBJECT_TEXT")},this);this.userQuota=a.userQuota;this.userUsageSize=
a.userUsageSize;this.userUsageProc=a.userUsageProc;this.dragOver=e.observable(!1).extend({throttle:1});this.dragOverEnter=e.observable(!1).extend({throttle:1});this.dragOverArea=e.observable(null);this.dragOverBodyArea=e.observable(null);this.messageListItemTemplate=e.computed(function(){return a.usePreviewPane()?"MailMessageListItem":"MailMessageListItemNoPreviewPane"});this.messageListSearchDesc=e.computed(function(){var b=a.messageListEndSearch();return""===b?"":c.i18n("MESSAGE_LIST/SEARCH_RESULT_FOR",
{SEARCH:b})});this.messageListPagenator=e.computed(function(){var b=0,d=0,l=2,f=[],e=a.messageListPage(),g=a.messageListPageCount(),k=function(a,b,d){a={current:a===e,name:c.isUnd(d)?a.toString():d.toString(),custom:c.isUnd(d)?!1:!0,title:c.isUnd(d)?"":a.toString(),value:a.toString()};c.isUnd(b)||b?f.push(a):f.unshift(a)};if(1<g||0<g&&g<e){if(g<e)k(g),d=b=g;else{if(3>=e||g-2<=e)l+=2;k(e);d=b=e}for(;0<l;)if(b-=1,d+=1,0<b&&(k(b,!1),l--),g>=d)k(d,!0),l--;else if(0>=b)break;3===b?k(2,!1):3<b&&k(Math.round((b-
1)/2),!1,"...");g-2===d?k(g-1,!0):g-2>d&&k(Math.round((g+d)/2),!0,"...");1<b&&k(1,!1);g>d&&k(g,!0)}return f},this);this.checkAll=e.computed({read:function(){return 0<f.data().messageListCheckedOrSelected().length},write:function(a){a=!!a;i.each(f.data().messageList(),function(d){d.checked(a)});a||f.data().message(null)}});this.inputMessageListSearchFocus=e.observable(!1);this.sLastSearchValue="";this.inputProxyMessageListSearch=e.computed({read:this.mainMessageListSearch,write:function(a){this.sLastSearchValue=
a},owner:this});this.isIncompleteChecked=e.computed(function(){var a=f.data().messageList().length,d=f.data().messageListCheckedOrSelected().length;return 0<a&&0<d&&a>d},this);this.hasMessages=e.computed(function(){return 0<this.messageList().length},this);this.hasCheckedLines=e.computed(function(){return 0<this.messageListChecked().length},this);this.hasCheckedOrSelectedLines=e.computed(function(){return 0<this.messageListCheckedOrSelected().length},this);this.isSpamFolder=e.computed(function(){return f.data().spamFolder()===
this.messageListEndFolder()},this);this.isTrashFolder=e.computed(function(){return f.data().trashFolder()===this.messageListEndFolder()},this);this.canBeMoved=this.hasCheckedOrSelectedLines;this.clearCommand=c.createCommand(this,function(){s.showScreenPopup(va,[f.data().currentFolder()])});this.multyForwardCommand=c.createCommand(this,function(){s.showScreenPopup(y,[g.ComposeType.ForwardAsAttachment,f.data().messageListCheckedOrSelected()])},this.canBeMoved);this.deleteWithoutMoveCommand=c.createCommand(this,
function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Trash,!1)},this.canBeMoved);this.deleteCommand=c.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Trash,!0)},this.canBeMoved);this.spamCommand=c.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Spam,!0)},this.canBeMoved);this.moveCommand=c.createCommand(this,c.emptyFunction,this.canBeMoved);this.setCommand=c.createCommand(this,c.emptyFunction,this.hasCheckedLines);
this.checkCommand=c.createCommand(this,c.emptyFunction,this.hasCheckedLines);this.reloadCommand=c.createCommand(this,function(){f.data().messageListCompleteLoadingThrottle()||f.reloadMessageList(!1,!0)});this.quotaTooltip=i.bind(this.quotaTooltip,this);this.selector=new M(this.messageList,this.currentMessage,".messageListItem .actionHandle",".messageListItem.selected",".messageListItem .checkboxMessage");this.selector.on("onItemSelect",i.bind(function(b){b?(a.message(a.staticMessageList.populateByMessageListItem(b)),
this.populateMessageBody(a.message())):a.message(null)},this));this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""});this.selector.on("onDelete",i.bind(function(){0<f.data().messageListCheckedOrSelected().length&&this.deleteCommand()},this))}function H(){C.call(this,"Right","MailMessageView");var a="",b=f.data(),d=this,l=function(a){return c.createCommand(d,function(){this.replyOrforward(a)},d.canBeRepliedOrForwarded)};this.oMessageScrollerDom=null;this.message=b.message;this.messageLoading=
b.messageLoading;this.messageLoadingThrottle=b.messageLoadingThrottle;this.messagesBodiesDom=b.messagesBodiesDom;this.useThreads=b.useThreads;this.replySameFolder=b.replySameFolder;this.usePreviewPane=b.usePreviewPane;this.isMessageSelected=b.isMessageSelected;this.messageActiveDom=b.messageActiveDom;this.messageError=b.messageError;this.fullScreenMode=b.messageFullScreenMode;this.showFullInfo=e.observable(!1);this.canBeRepliedOrForwarded=this.messageVisibility=e.computed(function(){return!this.messageLoadingThrottle()&&
!!this.message()},this);this.closeMessage=c.createCommand(this,function(){b.message(null)});this.replyCommand=l(g.ComposeType.Reply);this.replyAllCommand=l(g.ComposeType.ReplyAll);this.forwardCommand=l(g.ComposeType.Forward);this.forwardAsAttachmentCommand=l(g.ComposeType.ForwardAsAttachment);this.messageVisibilityCommand=c.createCommand(this,c.emptyFunction,this.messageVisibility);this.viewSubject=e.observable("");this.viewFromShort=e.observable("");this.viewToShort=e.observable("");this.viewFrom=
e.observable("");this.viewTo=e.observable("");this.viewCc=e.observable("");this.viewBcc=e.observable("");this.viewDate=e.observable("");this.viewMoment=e.observable("");this.viewLineAsCcc=e.observable("");this.viewHasImages=e.observable(!1);this.viewHasVisibleAttachments=e.observable(!1);this.viewAttachments=e.observableArray([]);this.viewIsHtml=e.observable(!1);this.viewViewLink=e.observable("");this.viewDownloadLink=e.observable("");this.viewUserPic=e.observable(t.DataImages.UserDotPic);this.viewUserPicVisible=
e.observable(!1);this.message.subscribe(function(b){this.messageActiveDom(null);b&&(this.viewSubject(b.subject()),this.viewFromShort(b.fromToLine(!0,!0)),this.viewToShort(b.toToLine(!0,!0)),this.viewFrom(b.fromToLine(!1)),this.viewTo(b.toToLine(!1)),this.viewCc(b.ccToLine(!1)),this.viewBcc(b.bccToLine(!1)),this.viewDate(b.fullFormatDateValue()),this.viewMoment(b.momentDate()),this.viewLineAsCcc(b.lineAsCcc()),this.viewHasImages(b.hasImages()),this.viewHasVisibleAttachments(b.hasVisibleAttachments()),
this.viewAttachments(b.attachments()),this.viewIsHtml(b.isHtml()),this.viewViewLink(b.viewLink()),this.viewDownloadLink(b.downloadLink()),a=f.cache().getUserPic(b.fromAsSingleEmail()),a!==this.viewUserPic()&&(this.viewUserPicVisible(!1),this.viewUserPic(t.DataImages.UserDotPic),""!==a&&(this.viewUserPicVisible(!0),this.viewUserPic(a))))},this);this.fullScreenMode.subscribe(function(a){a?Z.addClass("rl-message-fullscreen"):Z.removeClass("rl-message-fullscreen")});this.messageActiveDom.subscribe(function(){this.scrollMessageToTop();
c.windowResize()},this)}function xa(a){C.call(this,"Left","SettingsMenu");this.menu=a.menu}function ya(){C.call(this,"Right","SettingsPane")}function La(){var a=f.data();this.mainLanguage=a.mainLanguage;this.mainMessagesPerPage=a.mainMessagesPerPage;this.editorDefaultType=a.editorDefaultType;this.showImages=a.showImages;this.showAnimation=a.showAnimation;this.useDesktopNotifications=a.useDesktopNotifications;this.useThreads=a.useThreads;this.replySameFolder=a.replySameFolder;this.usePreviewPane=a.usePreviewPane;
this.useCheckboxesInList=a.useCheckboxesInList;this.languagesOptions=e.computed(function(){return i.map(a.languages(),function(a){return{optValue:a,optText:c.i18n("LANGS_NAMES/LANG_"+a.toUpperCase(),null,a)}})});this.isDesctopNotificationsSupported=e.computed(function(){return g.DesctopNotifications.NotSupported!==a.desktopNotificationsPermisions()});this.isDesctopNotificationsDenied=e.computed(function(){return g.DesctopNotifications.NotSupported===a.desktopNotificationsPermisions()||g.DesctopNotifications.Denied===
a.desktopNotificationsPermisions()});this.languageTrigger=e.observable(g.SaveSettingsStep.Idle).extend({throttle:100});this.mppTrigger=e.observable(g.SaveSettingsStep.Idle)}function Xa(){var a=f.data();this.displayName=a.displayName;this.replyTo=a.replyTo;this.signature=a.signature;this.nameTrigger=e.observable(g.SaveSettingsStep.Idle);this.replyTrigger=e.observable(g.SaveSettingsStep.Idle);this.signatureTrigger=e.observable(g.SaveSettingsStep.Idle)}function la(){this.accounts=f.data().accounts;this.processText=
e.computed(function(){return f.data().accountsLoading()?c.i18n("SETTINGS_ACCOUNTS/LOADING_PROCESS"):""},this);this.visibility=e.computed(function(){return""===this.processText()?"hidden":"visible"},this);this.accountForDeletion=e.observable(null).extend({falseTimeout:3E3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function Ma(){var a=f.data();this.googleEnable=a.googleEnable;this.googleActions=a.googleActions;this.googleLoggined=a.googleLoggined;
this.googleUserName=a.googleUserName;this.facebookEnable=a.facebookEnable;this.facebookActions=a.facebookActions;this.facebookLoggined=a.facebookLoggined;this.facebookUserName=a.facebookUserName;this.twitterEnable=a.twitterEnable;this.twitterActions=a.twitterActions;this.twitterLoggined=a.twitterLoggined;this.twitterUserName=a.twitterUserName;this.connectGoogle=c.createCommand(this,function(){this.googleLoggined()||f.googleConnect()},function(){return!this.googleLoggined()&&!this.googleActions()});
this.disconnectGoogle=c.createCommand(this,function(){f.googleDisconnect()});this.connectFacebook=c.createCommand(this,function(){this.facebookLoggined()||f.facebookConnect()},function(){return!this.facebookLoggined()&&!this.facebookActions()});this.disconnectFacebook=c.createCommand(this,function(){f.facebookDisconnect()});this.connectTwitter=c.createCommand(this,function(){this.twitterLoggined()||f.twitterConnect()},function(){return!this.twitterLoggined()&&!this.twitterActions()});this.disconnectTwitter=
c.createCommand(this,function(){f.twitterDisconnect()})}function ma(){this.changeProcess=e.observable(!1);this.passwordUpdateError=e.observable(!1);this.passwordUpdateSuccess=e.observable(!1);this.currentPassword=e.observable("");this.newPassword=e.observable("");this.currentPassword.subscribe(function(){this.passwordUpdateError(!1);this.passwordUpdateSuccess(!1)},this);this.newPassword.subscribe(function(){this.passwordUpdateError(!1);this.passwordUpdateSuccess(!1)},this);this.saveNewPasswordCommand=
c.createCommand(this,function(){this.changeProcess(!0);this.passwordUpdateError(!1);this.passwordUpdateSuccess(!1);f.remote().changePassword(this.onChangePasswordResponse,this.currentPassword(),this.newPassword())},function(){return!this.changeProcess()&&""!==this.currentPassword()&&""!==this.newPassword()});this.onChangePasswordResponse=i.bind(this.onChangePasswordResponse,this)}function S(){var a=f.data();this.ignoreFolderSubscribe=a.ignoreFolderSubscribe;this.foldersListError=a.foldersListError;
this.folderList=a.folderList;this.processText=e.computed(function(){var a=f.data(),d=a.foldersLoading(),l=a.foldersCreating(),e=a.foldersDeleting(),a=a.foldersRenaming();return l?c.i18n("SETTINGS_FOLDERS/CREATING_PROCESS"):e?c.i18n("SETTINGS_FOLDERS/DELETING_PROCESS"):a?c.i18n("SETTINGS_FOLDERS/RENAMING_PROCESS"):d?c.i18n("SETTINGS_FOLDERS/LOADING_PROCESS"):""},this);this.visibility=e.computed(function(){return""===this.processText()?"hidden":"visible"},this);this.folderForDeletion=e.observable(null).extend({falseTimeout:3E3}).extend({toggleSubscribe:[this,
function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]});this.folderForEdit=e.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.edited(!1)},function(a){a&&a.canBeEdited()&&a.edited(!0)}]})}function za(){var a=this;this.mainTheme=f.data().mainTheme;this.customThemeType=e.observable(f.settingsGet("CustomThemeType"));this.customThemeImg=e.observable(f.settingsGet("CustomThemeImg"));this.themesObjects=e.observableArray([]);this.customThemeUploaderProgress=e.observable(!1);
this.customThemeUploaderButton=e.observable(null);this.showCustomThemeConfig=e.computed(function(){return"Custom"===this.mainTheme()},this);this.showCustomThemeConfig.subscribe(function(){c.windowResize()});this.themeTrigger=e.observable(g.SaveSettingsStep.Idle).extend({throttle:100});this.oLastAjax=null;this.iTimer=0;f.data().theme.subscribe(function(b){i.each(this.themesObjects(),function(a){a.selected(b===a.name)});var d=j("#rlThemeLink"),l=j("#rlThemeStyle"),e=d.attr("href");e||(e=l.attr("data-href"));
e&&(e=e.toString().replace(/\/-\/[^\/]+\/\-\//,"/-/"+b+"/-/"),e=e.toString().replace(/\/Css\/[^\/]+\/User\//,"/Css/"+("Custom"===b&&h.__rlah?h.__rlah()||"0":"0")+"/User/"),"Json/"!==e.substring(e.length-5,e.length)&&(e+="Json/"),h.clearTimeout(a.iTimer),a.themeTrigger(g.SaveSettingsStep.Animate),this.oLastAjax&&this.oLastAjax.abort&&this.oLastAjax.abort(),this.oLastAjax=j.ajax({url:e,dataType:"json"}).done(function(b){if(b&&c.isArray(b)&&2===b.length){if(d&&d[0]&&(!l||!l[0]))l=j('<style id="rlThemeStyle"></style>'),
d.after(l),d.remove();l&&l[0]&&l.attr("data-href",e).attr("data-theme",b[0]).text(b[1]);a.themeTrigger(g.SaveSettingsStep.TrueResult)}}).always(function(){a.iTimer=h.setTimeout(function(){a.themeTrigger(g.SaveSettingsStep.Idle)},1E3);a.oLastAjax=null}));f.remote().saveSettings(null,{Theme:b})},this)}function Na(){c.initDataConstructorBySettings(this)}function T(){c.initDataConstructorBySettings(this);var a=function(a){return function(){var b=f.cache().getFolderFromCacheList(a());b&&b.type(g.FolderType.User)}},
b=function(a){return function(b){(b=f.cache().getFolderFromCacheList(b))&&b.type(a)}};this.devPassword=this.devLogin=this.devEmail="";this.accountEmail=e.observable("");this.accountLogin=e.observable("");this.projectHash=e.observable("");this.threading=!1;this.lastFoldersHash="";this.remoteChangePassword=this.remoteSuggestions=!1;this.sentFolder=e.observable("");this.draftFolder=e.observable("");this.spamFolder=e.observable("");this.trashFolder=e.observable("");this.sentFolder.subscribe(a(this.sentFolder),
this,"beforeChange");this.draftFolder.subscribe(a(this.draftFolder),this,"beforeChange");this.spamFolder.subscribe(a(this.spamFolder),this,"beforeChange");this.trashFolder.subscribe(a(this.trashFolder),this,"beforeChange");this.sentFolder.subscribe(b(g.FolderType.SentItems),this);this.draftFolder.subscribe(b(g.FolderType.Draft),this);this.spamFolder.subscribe(b(g.FolderType.Spam),this);this.trashFolder.subscribe(b(g.FolderType.Trash),this);this.draftFolderNotEnabled=e.computed(function(){return""===
this.draftFolder()||t.Values.UnuseOptionValue===this.draftFolder()},this);this.displayName=e.observable("");this.signature=e.observable("");this.replyTo=e.observable("");this.accounts=e.observableArray([]);this.accountsLoading=e.observable(!1);this.namespace="";this.folderList=e.observableArray([]);this.foldersListError=e.observable("");this.foldersLoading=e.observable(!1);this.foldersCreating=e.observable(!1);this.foldersDeleting=e.observable(!1);this.foldersRenaming=e.observable(!1);this.currentFolder=
e.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.currentFolderFullNameRaw=e.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this);this.currentFolderFullName=e.computed(function(){return this.currentFolder()?this.currentFolder().fullName:""},this);this.currentFolderFullNameHash=e.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this);this.currentFolderName=
e.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this);this.folderListSystemNames=e.computed(function(){var a=["INBOX"],b=this.folderList(),f=this.sentFolder(),e=this.draftFolder(),g=this.spamFolder(),k=this.trashFolder();c.isArray(b)&&0<b.length&&(""!==f&&t.Values.UnuseOptionValue!==f&&a.push(f),""!==e&&t.Values.UnuseOptionValue!==e&&a.push(e),""!==g&&t.Values.UnuseOptionValue!==g&&a.push(g),""!==k&&t.Values.UnuseOptionValue!==k&&a.push(k));return a},this);this.folderListSystem=
e.computed(function(){return i.compact(i.map(this.folderListSystemNames(),function(a){return f.cache().getFolderFromCacheList(a)}))},this);this.folderMenuForMove=e.computed(function(){return f.folderListOptionsBuilder(this.folderListSystem(),this.folderList(),[this.currentFolderFullNameRaw()],null,null,null,null,function(a){return a?a.localName():""})},this);this.staticMessageList=[];this.messageList=e.observableArray([]);this.messageListCount=e.observable(0);this.messageListSearch=e.observable("");
this.messageListPage=e.observable(1);this.messageListThreadFolder=e.observable("");this.messageListThreadUids=e.observableArray([]);this.messageListThreadFolder.subscribe(function(){this.messageListThreadUids([])},this);this.messageListEndSearch=e.observable("");this.messageListEndFolder=e.observable("");this.messageListPageCount=e.computed(function(){var a=Math.ceil(this.messageListCount()/this.messagesPerPage());return 0===a?1:a},this);this.mainMessageListSearch=e.computed({read:this.messageListSearch,
write:function(a){s.setHash(f.link().mailBox(this.currentFolderFullNameHash(),1,c.trim(a.toString())))},owner:this});this.messageListError=e.observable("");this.messageListLoading=e.observable(!1);this.messageListIsNotCompleted=e.observable(!1);this.messageListCompleteLoadingThrottle=e.observable(!1).extend({throttle:200});this.messageListCompleteLoading=e.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this);this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},
this);this.messageList.subscribe(i.debounce(function(a){i.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500));this.staticMessageList=new m;this.message=e.observable(null);this.messageLoading=e.observable(!1);this.messageLoadingThrottle=e.observable(!1).extend({throttle:50});this.messageLoading.subscribe(function(a){this.messageLoadingThrottle(a)},this);this.messageFullScreenMode=e.observable(!1);this.messageError=e.observable("");this.messagesBodiesDom=e.observable(null);this.messagesBodiesDom.subscribe(function(a){a&&
!(a instanceof jQuery)&&this.messagesBodiesDom(j(a))},this);this.messageActiveDom=e.observable(null);this.isMessageSelected=e.computed(function(){return null!==this.message()},this);this.currentMessage=e.observable(null);this.message.subscribe(function(a){null===a&&this.currentMessage(null)},this);this.messageListChecked=e.computed(function(){return i.filter(this.messageList(),function(a){return a.checked()})},this);this.messageListCheckedOrSelected=e.computed(function(){var a=this.messageListChecked(),
b=this.currentMessage();return i.union(a,b?[b]:[])},this);this.messageListCheckedUids=e.computed(function(){var a=[];i.each(this.messageListChecked(),function(b){b&&(a.push(b.uid),0<b.threadsLen()&&(0===b.parentUid()&&b.lastInCollapsedThread())&&(a=i.union(a,b.threads())))});return a},this);this.messageListCheckedOrSelectedUidsWithSubMails=e.computed(function(){var a=[];i.each(this.messageListCheckedOrSelected(),function(b){b&&(a.push(b.uid),0<b.threadsLen()&&(0===b.parentUid()&&b.lastInCollapsedThread())&&
(a=i.union(a,b.threads())))});return a},this);this.userQuota=e.observable(0);this.userUsageSize=e.observable(0);this.userUsageProc=e.computed(function(){var a=this.userQuota(),b=this.userUsageSize();return 0<a?Math.ceil(100*(b/a)):0},this);this.useKeyboardShortcuts=e.observable(!0);this.googleActions=e.observable(!1);this.googleLoggined=e.observable(!1);this.googleUserName=e.observable("");this.facebookActions=e.observable(!1);this.facebookLoggined=e.observable(!1);this.facebookUserName=e.observable("");
this.twitterActions=e.observable(!1);this.twitterLoggined=e.observable(!1);this.twitterUserName=e.observable("");this.customThemeType=e.observable(g.CustomThemeType.Light)}function aa(){this.oRequests={}}function p(){this.oRequests={};this.oRequests={}}function U(){this.oEmailsPicsHashes={};this.oServices={}}function v(){U.call(this);this.oFoldersCache={};this.oFoldersNamesCache={};this.oFolderHashCache={};this.oFolderUidNextCache={};this.oMessageListHashCache={};this.oMessageFlagsCache={};this.oNewMessage=
{};this.oRequestedMessage={}}function fa(a){J.call(this,"settings",a);this.menu=e.observableArray([]);this.oCurrentSubScreen=null}function Aa(){J.call(this,"login",[ka])}function V(){J.call(this,"mailbox",[Va,ea,z,H]);this.oLastRoute={};var a=f.data();this.mailBoxScreenVisibily=e.observable(!1);this.resizeTrigger=e.computed(function(){var b=this.mailBoxScreenVisibily(),d=a.messageFullScreenMode();return a.usePreviewPane()&&!d&&b?!0:!1},this)}function Oa(){fa.call(this,[Wa,xa,ya]);c.initOnStartOrLangChange(function(){this.sSettingsTitle=
c.i18n("TITLES/SETTINGS")},this,function(){f.setTitle(this.sSettingsTitle)})}function I(){this.oLocal=this.oLink=this.oPlugins=this.oSettings=null;this.isLocalAutocomplete=!0;this.popupVisibility=e.observable(!1);this.iframe=j('<iframe style="display:none" src="javascript:;" />').appendTo("body");R.on("error",function(a){f&&(a&&a.originalEvent&&a.originalEvent.message)&&(c.log(""+a.originalEvent.message+" ("+a.originalEvent.filename+":"+a.originalEvent.lineno+")"),f.remote().jsError(c.emptyFunction,
a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno))})}function A(){I.call(this);this.oCache=this.oRemote=this.oData=null;this.iSuggestionsLimit=c.pInt(this.settingsGet("SuggestionsLimit"));this.iSuggestionsLimit=0===this.iSuggestionsLimit?20:this.iSuggestionsLimit;this.quotaDebounce=i.debounce(this.quota,3E4)}var t={},g={},u={},c={},x={},ga={},wa=e.observable(!0),ha=e.observable(!0),s=null,Ba=h.rainloopAppData||{},Pa=h.rainloopI18N||{},Z=j("html"),R=j(h),Ca=j(h.document),Da=
[],Qa=[],Ra=[],ia=h.Notification&&h.Notification.requestPermission?h.Notification:null,Ea=(navigator.userAgent||"").toLowerCase(),Ya=-1<Ea.indexOf("iphone")||-1<Ea.indexOf("ipod")||-1<Ea.indexOf("ipad"),hb=-1<Ea.indexOf("android"),na=Ya||hb;Z.addClass(na?"mobile":"no-mobile");var f=null;t.Defaults={};t.Values={};t.DataImages={};t.Defaults.MessagesPerPage=25;t.Defaults.DefaultAjaxTimeout=2E4;t.Defaults.SearchAjaxTimeout=12E4;t.Defaults.SendMessageAjaxTimeout=2E5;t.Defaults.SaveMessageAjaxTimeout=2E5;
t.Values.UnuseOptionValue="__UNUSE__";t.Values.GmailFolderName="[Gmail]";t.Values.ClientSideCookieIndexName="rlcsc";t.Values.ImapDefaulPort=143;t.Values.ImapDefaulSecurePort=993;t.Values.SmtpDefaulPort=25;t.Values.SmtpDefaulSecurePort=465;t.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=";t.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=";
g.StorageResultType={Success:"success",Abort:"abort",Error:"error"};g.State={Empty:10,Login:20,Auth:30};g.StateType={Webmail:0,Admin:1};g.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99};g.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"};g.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2};g.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"};g.UploadErrorCode=
{Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99};g.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4};g.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3};g.EventKeyCode={Backspace:8,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Insert:45,Delete:46,A:65,S:83};g.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3};
g.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6};g.DesctopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9};g.MessagePriority={Low:5,Normal:3,High:1};g.EditorDefaultType={Html:"Html",Plain:"Plain"};g.CustomThemeType={Light:"Light",Dark:"Dark"};g.ServerSecure={None:0,SSL:1,TLS:2};g.SearchDateType={All:-1,Days3:3,Days7:7,Month:30};g.EmailType={Defailt:0,Facebook:1,Google:2};g.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0};g.Notification=
{InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,
CantSaveSettings:501,CantSavePluginSettings:502,DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,UnknownError:999};c.trim=j.trim;c.inArray=j.inArray;c.isArray=i.isArray;c.isFunc=i.isFunction;c.isUnd=i.isUndefined;c.isNull=i.isNull;c.emptyFunction=function(){};c.isNormal=function(a){return!c.isUnd(a)&&
!c.isNull(a)};c.windowResize=i.debounce(function(a){c.isUnd(a)?R.resize():h.setTimeout(function(){R.resize()},a)},50);c.isPosNumeric=function(a,b){return c.isNormal(a)?c.isUnd(b)||b?/^[0-9]*$/.test(a.toString()):/^[1-9]+[0-9]*$/.test(a.toString()):!1};c.pInt=function(a){return c.isNormal(a)&&""!==a?h.parseInt(a,10):0};c.pString=function(a){return c.isNormal(a)?a+"":""};c.isNonEmptyArray=function(a){return c.isArray(a)&&0<a.length};c.exportPath=function(a,b,d){for(var l=null,a=a.split("."),d=d||h;a.length&&
(l=a.shift());)!a.length&&!c.isUnd(b)?d[l]=b:d=d[l]?d[l]:d[l]={}};c.pImport=function(a,b,d){a[b]=d};c.pExport=function(a,b,d){return c.isUnd(a[b])?d:a[b]};c.encodeHtml=function(a){return c.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""};c.splitPlainText=function(a,b){for(var d="",l="",f=a,e=0,g=0,b=c.isUnd(b)?100:b;f.length>b;)l=f.substring(0,b),e=l.lastIndexOf(" "),g=l.lastIndexOf("\n"),-1!==g&&(e=g),-1===
e&&(e=b),d+=l.substring(0,e)+"\n",f=f.substring(e+1);return d+f};var Fa={};c.timeOutAction=function(a,b,d){c.isUnd(Fa[a])&&(Fa[a]=0);h.clearTimeout(Fa[a]);Fa[a]=h.setTimeout(b,d)};var Sa={};c.timeOutActionSecond=function(a,b,d){Sa[a]||(Sa[a]=h.setTimeout(function(){b();Sa[a]=0},d))};var O=!1;c.audio=function(a,b){if(!1===O)if(Ya)O=null;else{var d=!1,c=!1,f=h.Audio?new h.Audio:null;f&&f.canPlayType&&f.play?((d=""!==f.canPlayType('audio/mpeg; codecs="mp3"'))||(c=""!==f.canPlayType('audio/ogg; codecs="vorbis"')),
d||c?(O=f,O.preload="none",O.loop=!1,O.autoplay=!1,O.muted=!1,O.src=d?a:b):O=null):O=null}return O};c.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1};c.i18n=function(a,b,d){var l="",a=c.isUnd(Pa[a])?c.isUnd(d)?a:d:Pa[a];if(!c.isUnd(b)&&!c.isNull(b))for(l in b)c.hos(b,l)&&(a=a.replace("%"+l+"%",b[l]));return a};c.i18nToNode=function(a){i.defer(function(){j(".i18n",a).each(function(){var a=j(this),d="";(d=a.data("i18n-text"))?a.text(c.i18n(d)):((d=a.data("i18n-html"))&&
a.html(c.i18n(d)),(d=a.data("i18n-placeholder"))&&a.attr("placeholder",c.i18n(d)))})})};c.i18nToDoc=function(){h.rainloopI18N&&(Pa=h.rainloopI18N||{},c.i18nToNode(Ca),ha(!ha()));h.rainloopI18N={}};c.initOnStartOrLangChange=function(a,b,d){a&&a.call(b);d?ha.subscribe(function(){a&&a.call(b);d.call(b)}):a&&ha.subscribe(a,b)};c.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&
a.contentEditable)};c.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=j(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}};c.removeSelection=function(){if(h&&h.getSelection){var a=h.getSelection();a&&a.removeAllRanges&&a.removeAllRanges()}else document&&(document.selection&&document.selection.empty)&&document.selection.empty()};c.replySubjectAdd=function(a,b){var d=null,l=c.trim(b);null!==(d=(new h.RegExp("^"+
a+"[\\s]?\\:(.*)$","gi")).exec(b))&&!c.isUnd(d[1])?l=a+"[2]: "+d[1]:null!==(d=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!c.isUnd(d[1])&&!c.isUnd(d[2])&&!c.isUnd(d[3])?(c.pInt(d[2]),l=d[1]+(c.pInt(d[2])+1)+d[3]):l=a+": "+b;return l};c.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};c.friendlySize=function(a){a=c.pInt(a);return 1073741824<=a?c.roundNumber(a/1073741824,1)+"GB":1048576<=a?c.roundNumber(a/1048576,1)+"MB":1024<=
a?c.roundNumber(a/1024,0)+"KB":a+"B"};c.log=function(a){h.console&&h.console.log&&h.console.log(a)};c.getNotification=function(a){a=c.pInt(a);return c.isUnd(u[a])?"":u[a]};c.initNotificationLanguage=function(){u[g.Notification.InvalidToken]=c.i18n("NOTIFICATIONS/INVALID_TOKEN");u[g.Notification.AuthError]=c.i18n("NOTIFICATIONS/AUTH_ERROR");u[g.Notification.AccessError]=c.i18n("NOTIFICATIONS/ACCESS_ERROR");u[g.Notification.ConnectionError]=c.i18n("NOTIFICATIONS/CONNECTION_ERROR");u[g.Notification.CaptchaError]=
c.i18n("NOTIFICATIONS/CAPTCHA_ERROR");u[g.Notification.SocialFacebookLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");u[g.Notification.SocialTwitterLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");u[g.Notification.SocialGoogleLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");u[g.Notification.DomainNotAllowed]=c.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");u[g.Notification.CantGetMessageList]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");
u[g.Notification.CantGetMessage]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");u[g.Notification.CantDeleteMessage]=c.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");u[g.Notification.CantMoveMessage]=c.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");u[g.Notification.CantSaveMessage]=c.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");u[g.Notification.CantSendMessage]=c.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");u[g.Notification.InvalidRecipients]=c.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");u[g.Notification.CantCreateFolder]=c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");
u[g.Notification.CantRenameFolder]=c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");u[g.Notification.CantDeleteFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");u[g.Notification.CantDeleteNonEmptyFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");u[g.Notification.CantSubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");u[g.Notification.CantUnsubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER");u[g.Notification.CantSaveSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");
u[g.Notification.CantSavePluginSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");u[g.Notification.DomainAlreadyExists]=c.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");u[g.Notification.CantInstallPackage]=c.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");u[g.Notification.CantDeletePackage]=c.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");u[g.Notification.InvalidPluginPackage]=c.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE");u[g.Notification.UnsupportedPluginPackage]=c.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");
u[g.Notification.LicensingServerIsUnavailable]=c.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");u[g.Notification.LicensingExpired]=c.i18n("NOTIFICATIONS/LICENSING_EXPIRED");u[g.Notification.LicensingBanned]=c.i18n("NOTIFICATIONS/LICENSING_BANNED");u[g.Notification.DemoSendMessageError]=c.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");u[g.Notification.AccountAlreadyExists]=c.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS");u[g.Notification.MailServerError]=c.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");
u[g.Notification.UnknownError]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};c.getUploadErrorDescByCode=function(a){var b="";switch(c.pInt(a)){case g.UploadErrorCode.FileIsTooBig:b=c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case g.UploadErrorCode.FilePartiallyUploaded:b=c.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case g.UploadErrorCode.FileNoUploaded:b=c.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case g.UploadErrorCode.MissingTempFolder:b=c.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case g.UploadErrorCode.FileOnSaveingError:b=
c.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case g.UploadErrorCode.FileType:b=c.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=c.i18n("UPLOAD/ERROR_UNKNOWN")}return b};c.killCtrlAandS=function(a){if(a=a||h.event){var b=a.target||a.srcElement,d=a.keyCode||a.which;if(a.ctrlKey&&d===g.EventKeyCode.S)a.preventDefault();else if((!b||!b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&d===g.EventKeyCode.A)h.getSelection?h.getSelection().removeAllRanges():h.document.selection&&h.document.selection.clear&&
h.document.selection.clear(),a.preventDefault()}};c.createCommand=function(a,b,d){var l=b?function(){l.canExecute&&l.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));return!1}:function(){};l.enabled=e.observable(!0);d=c.isUnd(d)?!0:d;l.canExecute=c.isFunc(d)?e.computed(function(){return l.enabled()&&d.call(a)}):e.computed(function(){return l.enabled()&&!!d});return l};c.initDataConstructorBySettings=function(a){a.ignoreFolderSubscribe=e.observable(!1);a.editorDefaultType=e.observable(g.EditorDefaultType.Html);
a.showImages=e.observable(!1);a.showAnimation=e.observable(!1);a.desktopNotifications=e.observable(!1);a.useThreads=e.observable(!0);a.replySameFolder=e.observable(!0);a.usePreviewPane=e.observable(!0);a.useCheckboxesInList=e.observable(!0);a.showAnimation.subscribe(function(a){na?Z.removeClass("rl-anim").addClass("no-rl-anim"):Z.toggleClass("rl-anim",a).toggleClass("no-rl-anim",!a)});a.showAnimation.valueHasMutated();a.desktopNotificationsPermisions=e.computed(function(){a.desktopNotifications();
var b=g.DesctopNotifications.NotSupported;if(ia&&ia.permission)switch(ia.permission.toLowerCase()){case "granted":b=g.DesctopNotifications.Allowed;break;case "denied":b=g.DesctopNotifications.Denied;break;case "default":b=g.DesctopNotifications.NotAllowed}else h.webkitNotifications&&h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission());return b});a.useDesktopNotifications=e.computed({read:function(){return a.desktopNotifications()&&g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()},
write:function(b){b?(b=a.desktopNotificationsPermisions(),g.DesctopNotifications.Allowed===b?a.desktopNotifications(!0):g.DesctopNotifications.NotAllowed===b?ia.requestPermission(function(){a.desktopNotifications.valueHasMutated();h.console.log(a.desktopNotificationsPermisions());g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()?a.desktopNotifications()?a.desktopNotifications.valueHasMutated():a.desktopNotifications(!0):a.desktopNotifications()?a.desktopNotifications(!1):a.desktopNotifications.valueHasMutated()}):
a.desktopNotifications(!1)):a.desktopNotifications(!1)}});a.language=e.observable("");a.languages=e.observableArray([]);a.mainLanguage=e.computed({read:a.language,write:function(b){b!==a.language()?-1<c.inArray(b,a.languages())?a.language(b):0<a.languages().length&&a.language(a.languages()[0]):a.language.valueHasMutated()}});a.theme=e.observable("");a.themes=e.observableArray([]);a.mainTheme=e.computed({read:a.theme,write:function(b){if(b!==a.theme()){var d=a.themes();-1<c.inArray(b,d)?a.theme(b):
0<d.length&&a.theme(d[0])}else a.theme.valueHasMutated()}});a.allowCustomTheme=e.observable(!0);a.allowAdditionalAccounts=e.observable(!0);a.messagesPerPage=e.observable(t.Defaults.MessagesPerPage);a.mainMessagesPerPage=a.messagesPerPage;a.mainMessagesPerPage=e.computed({read:a.messagesPerPage,write:function(b){-1<c.inArray(c.pInt(b),[10,20,30,50,100,150,200])?b!==a.messagesPerPage()&&a.messagesPerPage(b):a.messagesPerPage.valueHasMutated()}});a.facebookEnable=e.observable(!1);a.facebookAppID=e.observable("");
a.facebookAppSecret=e.observable("");a.twitterEnable=e.observable(!1);a.twitterConsumerKey=e.observable("");a.twitterConsumerSecret=e.observable("");a.googleEnable=e.observable(!1);a.googleClientID=e.observable("");a.googleClientSecret=e.observable("");a.dropboxEnable=e.observable(!1);a.dropboxApiKey=e.observable("");a.contactsIsSupported=e.observable(!1)};c.createMomentDate=function(a){return e.computed(function(){wa();return this.moment().fromNow()},a)};c.createMomentShortDate=function(a){return e.computed(function(){var a=
"",a=Y(),d=this.moment(),l=this.momentDate();return a=4>=a.diff(d,"hours")?l:a.format("L")===d.format("L")?c.i18n("MESSAGE_LIST/TODAY_AT",{TIME:d.format("LT")}):a.clone().subtract("days",1).format("L")===d.format("L")?c.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:d.format("LT")}):a.year()===d.year()?d.format("D MMM."):d.format("LL")},a)};c.isFolderExpanded=function(a){var b=f.local().get(g.ClientSideKeyName.ExpandedFolders);return i.isArray(b)&&-1!==i.indexOf(b,a)};c.setExpandedFolder=function(a,b){var d=
f.local().get(g.ClientSideKeyName.ExpandedFolders);i.isArray(d)||(d=[]);b?(d.push(a),d=i.uniq(d)):d=i.without(d,a);f.local().set(g.ClientSideKeyName.ExpandedFolders,d)};c.initLayoutResizer=function(a,b,d,c){var e=j(a),q=j(b),w=j(d),a=f.local().get(g.ClientSideKeyName.MailBoxListSize),k=function(a,b,d){if(b||d)a=w.width(),b=b?100*(b.size.width/a):null,null===b&&d&&(b=100*(e.width()/a)),null!==b&&(e.css({width:"",height:"",right:""+(100-b)+"%"}),q.css({width:"",height:"",left:""+b+"%"}))};a&&e.width(a);
e.resizable({minWidth:350,maxWidth:w.width()-250,handles:"e",resize:k,stop:k});k(null,null,!0);R.resize(i.throttle(function(a,b){if(c&&c()){var d=w.width();e.resizable("option","maxWidth",d-250);b&&(b.size&&b.size.width)&&f.local().set(g.ClientSideKeyName.MailBoxListSize,b.size.width);k(null,null,!0)}},400))};c.initBlockquoteSwitcher=function(a){if(a){var b=j("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===j(this).parent().closest("blockquote",a).length});b&&0<b.length&&b.each(function(){var a=
j(this),b=a.height();if(0===b||100<b)a.addClass("rl-bq-switcher hidden-bq"),j('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq");c.windowResize()}).after("<br />").before("<br />")})}};c.removeBlockquoteSwitcher=function(a){a&&(j(a).find("blockquote.rl-bq-switcher").each(function(){j(this).removeClass("rl-bq-switcher hidden-bq")}),j(a).find(".rlBlockquoteSwitcher").each(function(){j(this).remove()}))};c.extendAsViewModel=
function(a,b){b&&(b.__name=a,x.regViewModelHook(a,b),i.extend(b.prototype,C.prototype))};c.addSettingsViewModel=function(a,b,d,c,f){a.__rlSettingsData={Label:d,Template:b,Route:c,IsDefault:!!f};Da.push(a)};c.removeSettingsViewModel=function(a){Qa.push(a)};c.disableSettingsViewModel=function(a){Ra.push(a)};c.convertThemeName=function(a){return c.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))};c.fakeMd5=function(a){for(var b="",a=c.isUnd(a)?32:c.pInt(a);b.length<a;)b+=
"0123456789abcdefghijklmnopqrstuvwxyz".substr(h.Math.round(36*h.Math.random()),1);return b};c.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")};c.draggeblePlace=function(){return j('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")};c.defautOptionsAfterRender=function(a,b){b&&!c.isUnd(b.disable)&&e.applyBindingsToNode(a,
{disable:b.disable},b)};c.windowPopupKnockout=function(a,b,d,l){var f=null,e=h.open(""),g="__OpenerApplyBindingsUid"+c.fakeMd5()+"__",k=j("#"+b);h[g]=function(){if(e&&e.document.body&&k&&k[0]){var b=j(e.document.body);j("#rl-content",b).html(k.html());j("html",e.document).addClass("external "+j("html").attr("class"));c.i18nToNode(b);E.prototype.applyExternal(a,j("#rl-content",b)[0]);h[g]=null;l(e)}};e.document.open();e.document.write('<html><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="user-scalable=no" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="robots" content="noindex, nofollow, noodp" /><title>'+
c.encodeHtml(d)+'</title></head><body><div id="rl-content"></div></body></html>');e.document.close();f=e.document.createElement("script");f.innerHTML="if(window&&window.opener&&window.opener['"+g+"']){window.opener['"+g+"']();window.opener['"+g+"']=null}";e.document.getElementsByTagName("head")[0].appendChild(f)};c.settingsSaveHelperFunction=function(a,b,d,l){d=d||null;l=c.isUnd(l)?1E3:c.pInt(l);return function(c,f,e,k,h){b.call(d,f&&f.Result?g.SaveSettingsStep.TrueResult:g.SaveSettingsStep.FalseResult);
a&&a.call(d,c,f,e,k,h);i.delay(function(){b.call(d,g.SaveSettingsStep.Idle)},l)}};c.settingsSaveHelperSimpleFunction=function(a,b){return c.settingsSaveHelperFunction(null,a,b,1E3)};c.resizeAndCrop=function(a,b,d){var c=new Image;c.onload=function(){var a=[0,0],c=document.createElement("canvas"),l=c.getContext("2d");c.width=b;c.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];l.fillStyle="#fff";l.fillRect(0,0,b,b);l.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],
this.height-a[1],0,0,b,b);d(c.toDataURL("image/jpeg"))};c.src=a};ga={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return ga.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){for(var b="",d,c,f,e,g,k,i=0,a=ga._utf8_encode(a);i<a.length;)d=a.charCodeAt(i++),c=a.charCodeAt(i++),f=a.charCodeAt(i++),e=d>>2,d=(d&3)<<4|c>>4,g=(c&15)<<2|f>>6,k=f&63,isNaN(c)?g=k=64:isNaN(f)&&(k=64),b=b+this._keyStr.charAt(e)+
this._keyStr.charAt(d)+this._keyStr.charAt(g)+this._keyStr.charAt(k);return b},decode:function(a){for(var b="",d,c,f,e,g,k=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)d=this._keyStr.indexOf(a.charAt(k++)),c=this._keyStr.indexOf(a.charAt(k++)),e=this._keyStr.indexOf(a.charAt(k++)),g=this._keyStr.indexOf(a.charAt(k++)),d=d<<2|c>>4,c=(c&15)<<4|e>>2,f=(e&3)<<6|g,b+=String.fromCharCode(d),64!==e&&(b+=String.fromCharCode(c)),64!==g&&(b+=String.fromCharCode(f));return ga._utf8_decode(b)},_utf8_encode:function(a){for(var a=
a.replace(/\r\n/g,"\n"),b="",d=0,c=a.length,f=0;d<c;d++)f=a.charCodeAt(d),128>f?b+=String.fromCharCode(f):(127<f&&2048>f?b+=String.fromCharCode(f>>6|192):(b+=String.fromCharCode(f>>12|224),b+=String.fromCharCode(f>>6&63|128)),b+=String.fromCharCode(f&63|128));return b},_utf8_decode:function(a){for(var b="",d=0,c=0,f=0,e=0;d<a.length;)c=a.charCodeAt(d),128>c?(b+=String.fromCharCode(c),d++):191<c&&224>c?(f=a.charCodeAt(d+1),b+=String.fromCharCode((c&31)<<6|f&63),d+=2):(f=a.charCodeAt(d+1),e=a.charCodeAt(d+
2),b+=String.fromCharCode((c&15)<<12|(f&63)<<6|e&63),d+=3);return b}};e.bindingHandlers.tooltip={init:function(a,b){if(!na){var d=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,trigger:"hover",title:function(){return'<span class="tooltip-class '+d+'">'+c.i18n(e.utils.unwrapObservable(b()))+"</span>"}})}}};e.bindingHandlers.tooltip2={init:function(a,b){var d=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,title:function(){return'<span class="tooltip-class '+
d+'">'+b()()+"</span>"}})}};e.bindingHandlers.popover={init:function(a,b){var d=e.utils.unwrapObservable(b());j(a).popover({trigger:d[2]||"click",placement:d[3]||"right",title:function(){return c.i18n(d[0]||"")},content:function(){return c.i18n(d[1]||"")}})}};e.bindingHandlers.resizecrop={init:function(a){j(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,b){b()();j(a).resizecrop({width:"100",height:"100"})}};e.bindingHandlers.onEnter=
{init:function(a,b,d,c){e.bindingHandlers.event.init(a,function(){return{keyup:function(d,c){c&&13===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(this,d))}}},d,c)}};e.bindingHandlers.onEsc={init:function(a,b,d,c){e.bindingHandlers.event.init(a,function(){return{keyup:function(d,c){c&&27===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(this,d))}}},d,c)}};e.bindingHandlers.modal={init:function(a,b){j(a).modal({keyboard:!1,show:e.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},
update:function(a,b){var d=e.utils.unwrapObservable(b());j(a).modal(d?"show":"hide");i.delay(function(){j(a).toggleClass("popup-active",d)},1)}};e.bindingHandlers.onEnterChange={init:function(a,b,d,c){e.bindingHandlers.event.init(a,function(){return{keyup:function(b,d){d&&13===h.parseInt(d.keyCode,10)&&j(a).trigger("change")}}},d,c)}};e.bindingHandlers.i18nInit={init:function(a){c.i18nToNode(a)}};e.bindingHandlers.i18nUpdate={update:function(a,b){e.utils.unwrapObservable(b());c.i18nToNode(a)}};e.bindingHandlers.link=
{update:function(a,b){j(a).attr("href",e.utils.unwrapObservable(b()))}};e.bindingHandlers.title={update:function(a,b){j(a).attr("title",e.utils.unwrapObservable(b()))}};e.bindingHandlers.textF={init:function(a,b){j(a).text(e.utils.unwrapObservable(b()))}};e.bindingHandlers.initDom={init:function(a,b){b()(a)}};e.bindingHandlers.initResizeTrigger={init:function(a,b){var d=e.utils.unwrapObservable(b());j(a).css({height:d[1],"min-height":d[1]})},update:function(a,b){var d=e.utils.unwrapObservable(b()),
l=c.pInt(d[1]),f=0,f=j(a).offset().top;0<f&&(f+=c.pInt(d[2]),f=R.height()-f,l<f&&(l=f),j(a).css({height:l,"min-height":l}))}};e.bindingHandlers.appendDom={update:function(a,b){j(a).hide().empty().append(e.utils.unwrapObservable(b())).show()}};e.bindingHandlers.draggable={init:function(a,b){j(a).draggable({distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},helper:function(a){return b()(a&&a.target?e.dataFor(a.target):null)}}).on("mousedown",function(){c.removeInFocus()})}};e.bindingHandlers.droppable=
{init:function(a,b){var d=b();!1!==d&&j(a).droppable({tolerance:"pointer",hoverClass:"droppableHover",drop:function(a,b){d(a,b)}})}};e.bindingHandlers.nano={init:function(a){na||j(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}};e.bindingHandlers.saveTrigger={init:function(a){j(a).append('&nbsp;&nbsp;<i class="icon-spinner-2 animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>').addClass("settings-saved-trigger")},update:function(a,b){var d=
e.utils.unwrapObservable(b()),c=j(a);switch(d.toString()){case "1":c.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case "0":c.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case "-2":c.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:c.find(".animated").hide().end().find(".error,.success").removeClass("visible")}}};
e.bindingHandlers.select2={init:function(a,b){var d=0,l=null,g=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),q=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),w=function(){return""},k=function(a){f.getAutocomplete(a.term,a.page,function(b,d){a.callback({more:!!d,results:i.map(b,function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};j(a).addClass("ko-select2").select2({query:function(a){a&&(0===d?(k(a),d=h.setTimeout(c.emptyFunction,200)):(h.clearInterval(d),d=h.setTimeout(function(){k(a)},
200)))},formatSelection:function(a,b){var d=a&&a.c?a.c.select2Selection(b):a.text;if(null!==d)return d},formatResult:function(a,b,d,c){b=a&&a.c?a.c.select2Result(b):"";return""===b?c(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&g.test(a)?{id:a,text:a}:null},formatNoMatches:w,formatSearching:function(){return c.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:w,formatSelectionTooBig:w,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,
openOnEnter:!1});e.utils.domNodeDisposal.addDisposeCallback(a,function(){j(a).select2("destroy")});j(a).on("change",function(){for(var a=j(this).select2("data"),d=0,f=a.length,e=null,g=[];d<f;d++)if((e=a[d])&&e.id)e.c||(e.c=new F,(l=q.exec(c.trim(e.id)))&&!c.isUnd(l[2])?(e.c.name=l[1],e.c.email=l[2]):e.c.email=e.id),g.push(e.c);b()(g)})},update:function(a,b){for(var d=e.utils.unwrapObservable(b()),c=0,f=d.length,g=null,w="",k=[];c<f;c++)g=d[c],w=g.toLine(!1),k.push({id:w,text:w,c:g});j(a).select2("data",
k)}};e.bindingHandlers.command={init:function(a,b,d,c){var f=j(a),g=b();if(!g||!g.enabled||!g.canExecute)throw Error("You are not using command function");f.addClass("command");e.bindingHandlers[f.is("form")?"submit":"click"].init.apply(c,arguments)},update:function(a,b){var d=!0,c=j(a),f=b(),d=f.enabled();c.toggleClass("command-not-enabled",!d);d&&(d=f.canExecute(),c.toggleClass("command-can-not-be-execute",!d));c.toggleClass("command-disabled disable disabled",!d);(c.is("input")||c.is("button"))&&
c.prop("disabled",!d)}};e.extenders.trimmer=function(a){var b=e.computed({read:a,write:function(b){a(c.trim(b.toString()))},owner:this});b(a());return b};e.extenders.reversible=function(a){var b=a();a.commit=function(){b=a()};a.reverse=function(){a(b)};a.commitedValue=function(){return b};return a};e.extenders.toggleSubscribe=function(a,b){a.subscribe(b[1],b[0],"beforeChange");a.subscribe(b[2],b[0]);return a};e.extenders.falseTimeout=function(a,b){a.iTimeout=0;a.subscribe(function(d){d&&(h.clearTimeout(a.iTimeout),
a.iTimeout=h.setTimeout(function(){a(!1);a.iTimeout=0},c.pInt(b)))});return a};e.observable.fn.validateEmail=function(){this.hasError=e.observable(!1);this.subscribe(function(a){a=c.trim(a);this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this);this.valueHasMutated();return this};e.observable.fn.validateFunc=function(a){this.hasFuncError=e.observable(!1);c.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated());return this};B.prototype.root=function(){return this.sBase};
B.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};B.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a};B.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};B.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"};B.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"};
B.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"};B.prototype.change=function(a){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+h.encodeURIComponent(a)+"/"};B.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a};B.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};B.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};B.prototype.inbox=
function(){return this.sBase+"mailbox/Inbox"};B.prototype.settings=function(a){var b=this.sBase+"settings";!c.isUnd(a)&&""!==a&&(b+="/"+a);return b};B.prototype.admin=function(a){var b=this.sBase;switch(a){case "AdminDomains":b+="domains";break;case "AdminSecurity":b+="security";break;case "AdminLicensing":b+="licensing"}return b};B.prototype.mailBox=function(a,b,d){var b=c.isNormal(b)?c.pInt(b):1,d=c.pString(d),f=this.sBase+"mailbox/";""!==a&&(f+=encodeURI(a));1<b&&(f=f.replace(/[\/]+$/,""),f+="/p"+
b);""!==d&&(f=f.replace(/[\/]+$/,""),f+="/"+encodeURI(d));return f};B.prototype.phpInfo=function(){return this.sServer+"Info"};B.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"};B.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"};B.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"};
B.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a};B.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"};B.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"};B.prototype.socialGoogle=
function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};B.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};B.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};x.oViewModelsHooks={};x.oSimpleHooks={};x.regViewModelHook=function(a,b){b&&(b.__hookName=a)};x.addHook=function(a,b){c.isFunc(b)&&(c.isArray(x.oSimpleHooks[a])||
(x.oSimpleHooks[a]=[]),x.oSimpleHooks[a].push(b))};x.runHook=function(a,b){c.isArray(x.oSimpleHooks[a])&&(b=b||[],i.each(x.oSimpleHooks[a],function(a){a.apply(null,b)}))};x.mainSettingsGet=function(a){return f?f.settingsGet(a):null};x.remoteRequest=function(a,b,d,c,e,g){f&&f.remote().defaultRequest(a,b,d,c,e,g)};x.settingsGet=function(a,b){var d=x.mainSettingsGet("Plugins");return(d=d&&c.isUnd(d[a])?null:d[a])?c.isUnd(d[b])?null:d[b]:null};n.prototype.initLanguage=function(a,b,d){this.oOptions.LangSwitcherConferm=
a;this.oOptions.LangSwitcherTextLabel=b;this.oOptions.LangSwitcherHtmlLabel=d};n.prototype.execCom=function(a,b,d){h.document&&(h.document.execCommand(a,b||!1,d||null),this.updateTextArea())};n.prototype.getEditorSelection=function(){var a=null;h.getSelection?a=h.getSelection():h.document.getSelection?a=h.document.getSelection():h.document.selection&&(a=h.document.selection);return a};n.prototype.getEditorRange=function(){var a=this.getEditorSelection();return!a||0===a.rangeCount?null:a.getRangeAt?
a.getRangeAt(0):a.createRange()};n.prototype.ec=function(a,b,d){this.execCom(a,b,d)};n.prototype.heading=function(a){this.ec("formatblock",!1,j.browser.msie?"Heading "+a:"h"+a)};n.prototype.insertImage=function(a){this.isHtml()&&!this.bOnlyPlain&&(this.htmlarea.focus(),this.ec("insertImage",!1,a))};n.prototype.setcolor=function(a,b){var d=null,d="";j.browser.msie&&9>c.pInt(j.browser.version)?(d=this.getEditorRange())&&d.execCommand("forecolor"===a?"ForeColor":"BackColor",!1,b):(d=j.browser.msie?"forecolor"===
a?"ForeColor":"BackColor":"forecolor"===a?"foreColor":"backColor",this.ec(d,!1,b))};n.prototype.isHtml=function(){return!0===this.bOnlyPlain?!1:this.textarea.is(":hidden")};n.prototype.toHtmlString=function(){return this.editor.innerHTML};n.prototype.toString=function(){return this.editor.innerText};n.prototype.updateTextArea=function(){this.textarea.val(this.toHtmlString())};n.prototype.updateHtmlArea=function(){this.editor.innerHTML=this.textarea.val()};n.prototype.setRawText=function(a,b){b&&!this.bOnlyPlain?
(this.isHtml()||(this.textarea.val(""),this.switchToHtml()),this.textarea.val(a.toString()),this.updateHtmlArea()):(this.textarea.val(a.toString()),this.updateHtmlArea(),this.switchToPlain(!1))};n.prototype.clear=function(){this.textarea.val("");this.editor.innerHTML="";this.bOnlyPlain?(this.toolbar.hide(),this.switchToPlain(!1)):this.switchToHtml()};n.prototype.getTextForRequest=function(){this.isHtml()&&this.updateTextArea();return this.textarea.val()};n.prototype.getTextFromHtml=function(a){var b=
"",d=function(){if(arguments&&1<arguments.length){var a=c.trim(arguments[1]).replace(/__bq__start__([\s\S\n\r]*)__bq__end__/gm,d),a="\n> "+c.trim(a).replace(/\n/gm,"\n> ")+"\n>\n";return a.replace(/\n([> ]+)/gm,function(){return arguments&&1<arguments.length?"\n"+c.trim(arguments[1].replace(/[\s]/,""))+" ":""})}return""},f=function(){if(arguments&&1<arguments.length){var a=c.trim(arguments[1]);0<a.length&&(a=a.replace(/<div[^>]*>([\s\S]*)<\/div>/gmi,f),a="\n"+c.trim(a)+"\n");return a}return""},a=
c.isUnd(a)?!0:!!a,b=this.toHtmlString().replace(/[\s]+/gm," ").replace(/<br\s?\/?>/gmi,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/<hr[^>]*>/gmi,"\n_______________________________\n\n").replace(/<img [^>]*>/gmi,"").replace(/<div[^>]*>([\s\S]*)<\/div>/gmi,f).replace(/<blockquote[^>]*>/gmi,"\n__bq__start__\n").replace(/<\/blockquote>/gmi,"\n__bq__end__\n").replace(/<a [^>]*>([\s\S]*?)<\/a>/gmi,function(){return arguments&&
1<arguments.length?c.trim(arguments[1]):""}).replace(/&nbsp;/gi," ").replace(/<[^>]*>/gm,"").replace(/&gt;/gi,">").replace(/&lt;/gi,"<").replace(/&amp;/gi,"&").replace(/&\w{2,6};/gi,"");return(a?c.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,d).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")};n.prototype.getHtmlFromText=function(){return c.convertPlainTextToHtml(this.textarea.val())};n.prototype.switchToggle=function(){this.isHtml()?
this.switchToPlain():this.switchToHtml()};n.prototype.switchToPlain=function(a){var a=c.isUnd(a)?!0:a,b=this.getTextFromHtml(),d=i.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(b),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);!a||0===c.trim(b).length?d(!0):d(h.confirm(this.oOptions.LangSwitcherConferm))};n.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel:
this.oOptions.LangSwitcherHtmlLabel};n.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar");j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0));this.textarea.val(this.getHtmlFromText());this.updateHtmlArea();this.textarea.hide();this.htmlarea.show();this.fOnSwitch&&this.fOnSwitch(!0)};n.prototype.addButton=function(a,b){var d=this;j("<div />").addClass("editorToolbarButtom").append(j('<a tabindex="-1" href="javascript:void(0);"></a>').addClass(a)).attr("title",
b).click(function(b){c.isUnd(n.htmlFunctions[a])?h.alert(a):n.htmlFunctions[a].apply(d,[j(this),b])}).appendTo(this.toolbar)};n.htmlInitToolbar=function(){if(!this.bOnlyPlain){this.addButton("bold","Bold");this.addButton("italic","Italic");this.addButton("underline","Underline");this.addButton("strikethrough","Strikethrough");this.addButton("removeformat","removeformat");this.addButton("justifyleft","justifyleft");this.addButton("justifycenter","justifycenter");this.addButton("justifyright","justifyright");
this.addButton("horizontalrule","horizontalrule");this.addButton("orderedlist","orderedlist");this.addButton("unorderedlist","unorderedlist");this.addButton("indent","indent");this.addButton("outdent","outdent");this.addButton("forecolor","forecolor");var a=this;j("<span />").addClass("editorSwitcher").text(a.switcherLinkText(!0)).click(function(){a.switchToggle()}).appendTo(a.toolbar)}};n.htmlInitEditor=function(){this.editor=this.htmlarea[0];this.editor.innerHTML=this.textarea.val()};n.htmlAttachEditorEvents=
function(){};for(var ib=n,oa=[],Za=[],W=0,Ga=0,Ha=0,Ia=0,Ja="",W=0;256>W;W+=85)Ja=W.toString(16),oa.push(1===Ja.length?"0"+Ja:Ja);Ia=oa.length;for(W=0;W<Ia;W++)for(Ga=0;Ga<Ia;Ga++)for(Ha=0;Ha<Ia;Ha++)Za.push("#"+oa[W]+""+oa[Ga]+""+oa[Ha]);ib.htmlColorPickerColors=Za;var jb=n,$a=j(h.document),ab=!1,pa=j('<div style="position: absolute;" class="editorFontStylePicker"><div class="editorFpFonts"></div></div>'),bb=pa.find(".editorFpFonts"),cb=function(){};j.each("Arial;Arial Black;Courier New;Tahoma;Times New Roman;Verdana".split(";"),
function(a,b){bb.append(j('<a href="javascript:void(0);" tabindex="-1" class="editorFpFont" style="font-family: '+b+';">'+b+"</a>").click(function(){cb(b)}));bb.append("<br />")});pa.hide();jb.htmlFontPicker=function(a,b,d){ab||(pa.appendTo(d),ab=!0);cb=b;$a.unbind("click.fpNamespace");h.setTimeout(function(){$a.one("click.fpNamespace",function(){pa.hide()})},500);b=j(a).position();pa.css("top",5+b.top+j(a).height()+"px").css("left",b.left+"px").show()};var kb=n,db=j(h.document),eb=!1,qa=j('<div style="position: absolute;" class="editorColorPicker"><div class="editorCpColors"></div></div>'),
fb=qa.find(".editorCpColors"),gb=function(){};j.each(n.htmlColorPickerColors,function(a,b){fb.append('<a href="javascript:void(0);" tabindex="-1" class="editorCpColor" style="background-color: '+b+';"></a>')});qa.hide();j(".editorCpColor",fb).click(function(a){var b=1,d="#000000",a=j(a.target).css("background-color"),d=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(null!==d){for(delete d[0];3>=b;++b)d[b]=c.pInt(d[b]).toString(16),1===d[b].length&&(d[b]="0"+d[b]);d="#"+d.join("")}else d=a;gb(d)});
kb.htmlColorPicker=function(a,b,d){eb||(qa.appendTo(d),eb=!0);d=j(a).position();gb=b;db.unbind("click.cpNamespace");h.setTimeout(function(){db.one("click.cpNamespace",function(){qa.hide()})},100);qa.css("top",5+d.top+j(a).height()+"px").css("left",d.left+"px").show()};n.htmlFunctions={bold:function(){this.ec("bold")},italic:function(){this.ec("italic")},underline:function(){this.ec("underline")},strikethrough:function(){this.ec("strikethrough")},indent:function(){this.ec("indent")},outdent:function(){this.ec("outdent")},
justifyleft:function(){this.ec("justifyLeft")},justifycenter:function(){this.ec("justifyCenter")},justifyright:function(){this.ec("justifyRight")},horizontalrule:function(){this.ec("insertHorizontalRule",!1,"ht")},removeformat:function(){this.ec("removeFormat")},orderedlist:function(){this.ec("insertorderedlist")},unorderedlist:function(){this.ec("insertunorderedlist")},forecolor:function(a){n.htmlColorPicker(a,i.bind(function(a){this.setcolor("forecolor",a)},this),this.toolbar)},backcolor:function(a){n.htmlColorPicker(a,
i.bind(function(a){this.setcolor("backcolor",a)},this),this.toolbar)},fontname:function(a){n.htmlFontPicker(a,i.bind(function(a){this.ec("fontname",!1,a)},this),this.toolbar)}};M.prototype.init=function(a,b){this.oContentVisible=a;this.oContentScrollable=b;if(this.oContentVisible&&this.oContentScrollable){var d=this;j(this.oContentVisible).on("click",this.sItemSelector,function(a){d.actionClick(e.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=e.dataFor(this);b&&(a&&a.shiftKey?
d.actionClick(b,a):(d.sLastUid=d.getItemUid(b),b.selected()?(b.checked(!1),d.selectedItem(null)):b.checked(!b.checked())))});j(h.document).on("keydown",i.bind(function(a){var b=!0;if(a&&this.bUseKeyboard&&!c.inFocus())if(-1<c.inArray(a.keyCode,[g.EventKeyCode.Up,g.EventKeyCode.Down,g.EventKeyCode.Insert,g.EventKeyCode.Home,g.EventKeyCode.End,g.EventKeyCode.PageUp,g.EventKeyCode.PageDown]))this.newSelectPosition(a.keyCode,a.shiftKey),b=!1;else if(g.EventKeyCode.Delete===a.keyCode&&!a.ctrlKey&&!a.shiftKey){if(this.oCallbacks.onDelete)this.oCallbacks.onDelete();
b=!1}return b},this))}};M.prototype.selectByUid=function(a,b){this.useItemSelectCallback=b=c.isUnd(b)?!0:!!b;var d=i.find(this.list(),function(b){return a===this.getItemUid(b)},this);d&&this.selectedItem(d);this.useItemSelectCallback=!0};M.prototype.useKeyboard=function(a){this.bUseKeyboard=!!a};M.prototype.getItemUid=function(a){var b="",d=this.oCallbacks.onItemGetUid||null;d&&a&&(b=d(a));return b.toString()};M.prototype.newSelectPosition=function(a,b){var d=this,c=0,f=!1,e=!1,w=null,k=this.list(),
j=k?k.length:0,o=this.selectedItem();if(0<j)if(o){if(o)if(g.EventKeyCode.Down===a||g.EventKeyCode.Up===a||g.EventKeyCode.Insert===a)i.each(k,function(b){if(!e)switch(a){case g.EventKeyCode.Up:o===b?e=!0:w=b;break;case g.EventKeyCode.Down:case g.EventKeyCode.Insert:f?(w=b,e=!0):o===b&&(f=!0)}});else if(g.EventKeyCode.Home===a||g.EventKeyCode.End===a)g.EventKeyCode.Home===a?w=k[0]:g.EventKeyCode.End===a&&(w=k[k.length-1]);else if(g.EventKeyCode.PageDown===a)for(;c<j;c++){if(o===k[c]){c+=10;c=j-1<c?
j-1:c;w=k[c];break}}else if(g.EventKeyCode.PageUp===a)for(c=j;0<=c;c--)if(o===k[c]){c-=10;c=0>c?0:c;w=k[c];break}}else if(g.EventKeyCode.Down===a||g.EventKeyCode.Insert===a||g.EventKeyCode.Home===a||g.EventKeyCode.PageUp===a)w=k[0];else if(g.EventKeyCode.Up===a||g.EventKeyCode.End===a||g.EventKeyCode.PageDown===a)w=k[k.length-1];w?(o&&(b?(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)&&o.checked(!o.checked()):g.EventKeyCode.Insert===a&&o.checked(!o.checked())),this.selectedItem(w),0!==this.iSelectTimer?
(h.clearTimeout(this.iSelectTimer),this.iSelectTimer=h.setTimeout(function(){d.iSelectTimer=0;d.actionClick(w)},300)):(this.iSelectTimer=h.setTimeout(function(){d.iSelectTimer=0},200),this.actionClick(w)),this.scrollToSelected()):o&&(b&&(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)?o.checked(!o.checked()):g.EventKeyCode.Insert===a&&o.checked(!o.checked()))};M.prototype.scrollToSelected=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=j(this.sItemSelectedSelector,this.oContentScrollable),
b=a.position(),d=this.oContentVisible.height(),a=a.outerHeight();return b&&(0>b.top||b.top+a>d)?(0>b.top?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+b.top-20):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+b.top-d+a+20),!0):!1};M.prototype.eventClickFunction=function(a,b){var d=this.getItemUid(a),c=0,f=0,e=null,g="",k=!1,i=!1,h=[],j=!1;if(b&&b.shiftKey&&""!==d&&""!==this.sLastUid&&d!==this.sLastUid){h=this.list();j=a.checked();c=0;for(f=h.length;c<
f;c++){e=h[c];g=this.getItemUid(e);k=!1;if(g===this.sLastUid||g===d)k=!0;k&&(i=!i);(i||k)&&e.checked(j)}}this.sLastUid=""===d?"":d};M.prototype.actionClick=function(a,b){if(a){var d=!0,c=this.getItemUid(a);b&&(b.shiftKey?(d=!1,""===this.sLastUid&&(this.sLastUid=c),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(d=!1,this.sLastUid=c,a.checked(!a.checked())));d&&(this.selectedItem(a),this.sLastUid=c)}};M.prototype.on=function(a,b){this.oCallbacks[a]=b};sa.supported=function(){return!0};
sa.prototype.set=function(a,b){var d=j.cookie(t.Values.ClientSideCookieIndexName),c=null;try{(c=null===d?null:JSON.parse(d))||(c={}),c[a]=b,j.cookie(t.Values.ClientSideCookieIndexName,JSON.stringify(c),{expires:30})}catch(f){}return c};sa.prototype.get=function(a){var b=j.cookie(t.Values.ClientSideCookieIndexName),d=null;try{d=(d=null===b?null:JSON.parse(b))&&!c.isUnd(d[a])?d[a]:null}catch(f){}return d};ta.supported=function(){return!!h.localStorage};ta.prototype.set=function(a,b){var d=h.localStorage[t.Values.ClientSideCookieIndexName]||
null,c=null;try{(c=null===d?null:JSON.parse(d))||(c={}),c[a]=b,h.localStorage[t.Values.ClientSideCookieIndexName]=JSON.stringify(c)}catch(f){}return c};ta.prototype.get=function(a){var b=h.localStorage[t.Values.ClientSideCookieIndexName]||null,d=null;try{d=(d=null===b?null:JSON.parse(b))&&!c.isUnd(d[a])?d[a]:null}catch(f){}return d};ua.prototype.oDriver=null;ua.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1};ua.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+
a):null};Ua.prototype.bootstart=function(){};C.prototype.sPosition="";C.prototype.sTemplate="";C.prototype.viewModelName="";C.prototype.viewModelDom=null;C.prototype.viewModelTemplate=function(){return this.sTemplate};C.prototype.viewModelPosition=function(){return this.sPosition};C.prototype.cancelCommand=C.prototype.closeCommand=function(){};J.prototype.oCross=null;J.prototype.sScreenName="";J.prototype.aViewModels=[];J.prototype.viewModels=function(){return this.aViewModels};J.prototype.screenName=
function(){return this.sScreenName};J.prototype.routes=function(){return null};J.prototype.__cross=function(){return this.oCross};J.prototype.__start=function(){var a=this.routes(),b=null,d=null;c.isNonEmptyArray(a)&&(d=i.bind(this.onRoute||c.emptyFunction,this),b=Ta.create(),i.each(a,function(a){b.addRoute(a[0],d).rules=a[1]}),this.oCross=b)};E.prototype.sDefaultScreenName="";E.prototype.oScreens={};E.prototype.oBoot=null;E.prototype.oCurrentScreen=null;E.prototype.showLoading=function(){j("#rl-loading").show()};
E.prototype.hideLoading=function(){j("#rl-loading").hide()};E.prototype.routeOff=function(){P.changed.active=!1};E.prototype.routeOn=function(){P.changed.active=!0};E.prototype.setBoot=function(a){c.isNormal(a)&&(this.oBoot=a);return this};E.prototype.screen=function(a){return""!==a&&!c.isUnd(this.oScreens[a])?this.oScreens[a]:null};E.prototype.delegateRun=function(a,b,d){a&&a[b]&&a[b].apply(a,c.isArray(d)?d:[])};E.prototype.buildViewModel=function(a,b){if(a&&!a.__builded){var d=new a(b),l=d.viewModelPosition(),
g=j("#rl-content #rl-"+l.toLowerCase()),q=null;a.__builded=!0;a.__vm=d;d.data=f.data();d.viewModelName=a.__name;g&&1===g.length?(q=j("<div>").addClass("rl-view-model").addClass("RL-"+d.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+d.viewModelTemplate()+'"}, i18nInit: true'),q.appendTo(g),d.viewModelDom=q,a.__dom=q,"Popups"===l&&(d.cancelCommand=d.closeCommand=c.createCommand(d,function(){s.hideScreenPopup(a)})),x.runHook("view-model-pre-build",[a.__name,d,q]),e.applyBindings(d,
q[0]),this.delegateRun(d,"onBuild",[q]),x.runHook("view-model-post-build",[a.__name,d,q])):c.log("Cannot find view model position: "+l)}return a?a.__vm:null};E.prototype.applyExternal=function(a,b){a&&b&&e.applyBindings(a,b)};E.prototype.hideScreenPopup=function(a){a&&(a.__vm&&a.__dom)&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),i.defer(function(){a.__dom.find(".ko-select2").select2("close")}))};E.prototype.showScreenPopup=function(a,b){a&&
(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),x.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))};E.prototype.screenOnRoute=function(a,b){var d=this,f=null,e=null;""===c.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){f=this.screen(a);if(!f&&(f=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;f&&f.__started&&(f.__builded||(f.__builded=!0,c.isNonEmptyArray(f.viewModels())&&
i.each(f.viewModels(),function(a){this.buildViewModel(a,f)},this),this.delegateRun(f,"onBuild")),i.defer(function(){if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onHide");c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();a.__vm.viewModelVisibility(false);d.delegateRun(a.__vm,"onHide")}})}d.oCurrentScreen=f;if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onShow");x.runHook("screen-on-show",
[d.oCurrentScreen.screenName(),d.oCurrentScreen]);c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);d.delegateRun(a.__vm,"onShow");x.runHook("view-model-on-show",[a.__name,a.__vm])}},d)}(e=f.__cross())&&e.parse(b)}))}};E.prototype.startScreens=function(a){i.each(a,function(a){var d=(a=new a)?a.screenName():"";a&&""!==d&&(""===this.sDefaultScreenName&&
(this.sDefaultScreenName=d),this.oScreens[d]=a)},this);i.each(this.oScreens,function(a){a&&(!a.__started&&a.__start)&&(a.__started=!0,a.__start(),x.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),x.runHook("screen-post-start",[a.screenName(),a]))},this);a=Ta.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,i.bind(this.screenOnRoute,this));P.initialized.add(a.parse,a);P.changed.add(a.parse,a);P.init()};E.prototype.setHash=function(a,b){a="#"===a.substr(0,1)?a.substr(1):
a;a="/"===a.substr(0,1)?a.substr(1):a;(c.isUnd(b)?0:b)?(P.changed.active=!1,P.setHash(a),P.changed.active=!0):(P.changed.active=!0,P.setHash(a))};E.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};s=new E;F.newInstanceFromJson=function(a){var b=new F;return b.initByJson(a)?b:null};F.prototype.name="";F.prototype.email="";F.prototype.privateType=null;F.prototype.validate=function(){return""!==this.name||""!==this.email};F.prototype.hash=function(a){return"#"+
(a?"":this.name)+"#"+this.email+"#"};F.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")};F.prototype.type=function(){if(null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=g.EmailType.Facebook),null===this.privateType))this.privateType=g.EmailType.Default;return this.privateType};F.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};F.prototype.parse=function(a){var a=c.trim(a),
b=/(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g.exec(a);b?(this.name=b[1]||"",this.email=b[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)};F.prototype.initByJson=function(a){var b=!1;a&&"Object/Email"===a["@Object"]&&(this.name=c.trim(a.Name),this.email=c.trim(a.Email),b=""!==this.email,this.clearDuplicateName());return b};F.prototype.toLine=function(a,b){var d="";""!==this.email&&(b=c.isUnd(b)?!1:!!b,a&&""!==this.name?d=b?'<a href="mailto:'+c.encodeHtml('"'+this.name+
'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.name)+"</a>":this.name:(d=this.email,""!==this.name?d=b?c.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+c.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(d)+"</a>"+c.encodeHtml(">"):'"'+this.name+'" <'+d+">":b&&(d='<a href="mailto:'+c.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.email)+"</a>")));return d};F.prototype.select2Result=function(){var a=
"",b=f.cache().getUserPic(this.email),a=""!==b?a+('<img class="select2-user-pic pull-left" src="'+c.encodeHtml(b)+'" />'):a+('<img class="select2-user-pic pull-left" src="'+f.link().emptyContactPic()+'" />');g.EmailType.Facebook===this.type()?(a+=""+(0<this.name.length?this.name:this.email),a+='<i class="icon-facebook pull-right select2-icon-result" />'):a+=""+(0<this.name.length?this.email+' <span class="select2-subname">('+this.name+")</span>":this.email);return a+""};F.prototype.select2Selection=
function(a){var b="";if(g.EmailType.Facebook===this.type()){if(b=0<this.name.length?this.name:this.email,""!==b)return j("<pan>").text(b).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else b=0<this.name.length?this.name+" ("+this.email+")":this.email;return b};ja.prototype.parse=function(a){var b=!1;a&&"Object/Contact"===a["@Object"]&&(this.idContact=c.pInt(a.IdContact),this.listName=c.pString(a.ListName),this.name=c.pString(a.Name),this.emails=c.isNonEmptyArray(a.Emails)?
a.Emails:[],this.imageHash=c.pString(a.ImageHash),b=!0);return b};ja.prototype.srcAttr=function(){return""===this.imageHash?f.link().emptyContactPic():f.link().getUserPicUrlFromHash(this.imageHash)};ja.prototype.generateUid=function(){return""+this.idContact};ja.prototype.lineAsCcc=function(){var a=[];this.deleted()&&a.push("deleted");this.selected()&&a.push("selected");this.checked()&&a.push("checked");return a.join(" ")};D.newInstanceFromJson=function(a){var b=new D;return b.initByJson(a)?b:null};
D.prototype.mimeType="";D.prototype.fileName="";D.prototype.estimatedSize=0;D.prototype.friendlySize="";D.prototype.isInline=!1;D.prototype.isLinked=!1;D.prototype.cid="";D.prototype.cidWithOutTags="";D.prototype.download="";D.prototype.folder="";D.prototype.uid="";D.prototype.mimeIndex="";D.prototype.initByJson=function(a){var b=!1;a&&"Object/Attachment"===a["@Object"]&&(this.mimeType=a.MimeType,this.fileName=a.FileName,this.estimatedSize=c.pInt(a.EstimatedSize),this.isInline=!!a.IsInline,this.isLinked=
!!a.IsLinked,this.cid=a.CID,this.download=a.Download,this.folder=a.Folder,this.uid=a.Uid,this.mimeIndex=a.MimeIndex,this.friendlySize=c.friendlySize(this.estimatedSize),this.cidWithOutTags=this.cid.replace(/^<+/,"").replace(/>+$/,""),b=!0);return b};D.prototype.isImage=function(){return"image/"===this.mimeType.substr(0,6)};D.prototype.isText=function(){return"text/"===this.mimeType.substr(0,5)};D.prototype.linkDownload=function(){return f.link().attachmentDownload(this.download)};D.prototype.linkPreview=
function(){return f.link().attachmentPreview(this.download)};D.prototype.linkPreviewAsPlain=function(){return f.link().attachmentPreviewAsPlain(this.download)};D.prototype.generateTransferDownloadUrl=function(){var a=this.linkDownload();"http"!==a.substr(0,4)&&(a=h.location.protocol+"//"+h.location.host+h.location.pathname+a);return this.mimeType+":"+this.fileName+":"+a};D.prototype.eventDragStart=function(a,b){var d=b.originalEvent||b;a&&(d&&d.dataTransfer&&d.dataTransfer.setData)&&d.dataTransfer.setData("DownloadURL",
this.generateTransferDownloadUrl());return!0};D.prototype.iconClass=function(){var a=this.mimeType.toLocaleString().split("/"),b="icon-file";a&&a[1]&&("image"===a[0]?b="icon-image":"text"===a[0]?b="icon-file-xml":"audio"===a[0]?b="icon-music":"video"===a[0]?b="icon-film":-1<c.inArray(a[1],"zip 7z tar rar gzip bzip bzip2 x-zip x-7z x-rar x-tar x-gzip x-bzip x-bzip2 x-zip-compressed x-7z-compressed x-rar-compressed".split(" "))?b="icon-file-zip":-1<c.inArray(a[1],["pdf","x-pdf"])?b="icon-file-pdf":
-1<c.inArray(a[1],["exe","x-exe","x-winexe","bat"])?b="icon-console":-1<c.inArray(a[1],"rtf msword vnd.msword vnd.openxmlformats-officedocument.wordprocessingml.document vnd.openxmlformats-officedocument.wordprocessingml.template vnd.ms-word.document.macroEnabled.12 vnd.ms-word.template.macroEnabled.12".split(" "))?b="icon-file-word":-1<c.inArray(a[1],"excel ms-excel vnd.ms-excel vnd.openxmlformats-officedocument.spreadsheetml.sheet vnd.openxmlformats-officedocument.spreadsheetml.template vnd.ms-excel.sheet.macroEnabled.12 vnd.ms-excel.template.macroEnabled.12 vnd.ms-excel.addin.macroEnabled.12 vnd.ms-excel.sheet.binary.macroEnabled.12".split(" "))?
b="icon-file-excel":-1<c.inArray(a[1],"powerpoint ms-powerpoint vnd.ms-powerpoint vnd.openxmlformats-officedocument.presentationml.presentation vnd.openxmlformats-officedocument.presentationml.template vnd.openxmlformats-officedocument.presentationml.slideshow vnd.ms-powerpoint.addin.macroEnabled.12 vnd.ms-powerpoint.presentation.macroEnabled.12 vnd.ms-powerpoint.template.macroEnabled.12 vnd.ms-powerpoint.slideshow.macroEnabled.12".split(" "))&&(b="icon-file-powerpoint"));return b};N.prototype.id=
"";N.prototype.isInline=!1;N.prototype.isLinked=!1;N.prototype.CID="";N.prototype.fromMessage=!1;N.prototype.cancel=c.emptyFunction;N.prototype.initByUploadJson=function(a){var b=!1;a&&(this.fileName(a.Name),this.size(c.isUnd(a.Size)?0:c.pInt(a.Size)),this.tempName(c.isUnd(a.TempName)?"":a.TempName),this.isInline=!1,b=!0);return b};m.newInstanceFromJson=function(a){var b=new m;return b.initByJson(a)?b:null};m.calculateFullFromatDateValue=function(a){return Y.unix(a).format("LLL")};m.emailsToLine=
function(a,b,d){var f=[],e=0,g=0;if(c.isNonEmptyArray(a)){e=0;for(g=a.length;e<g;e++)f.push(a[e].toLine(b,d))}return f.join(", ")};m.initEmailsFromJson=function(a){var b=0,d=0,f=null,e=[];if(c.isNonEmptyArray(a)){b=0;for(d=a.length;b<d;b++)(f=F.newInstanceFromJson(a[b]))&&e.push(f)}return e};m.replyHelper=function(a,b,d){if(a&&0<a.length)for(var f=0,e=a.length;f<e;f++)c.isUnd(b[a[f].email])&&(b[a[f].email]=!0,d.push(a[f]))};m.prototype.initByJson=function(a){var b=!1;a&&"Object/Message"===a["@Object"]&&
(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.requestHash=a.RequestHash,this.size(c.pInt(a.Size)),this.from=m.initEmailsFromJson(a.From),this.to=m.initEmailsFromJson(a.To),this.cc=m.initEmailsFromJson(a.Cc),this.bcc=m.initEmailsFromJson(a.Bcc),this.replyTo=m.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(c.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.fromEmailString(m.emailsToLine(this.from,!0)),this.toEmailsString(m.emailsToLine(this.to,
!0)),this.parentUid(c.pInt(a.ParentThread)),this.threads(c.isArray(a.Threads)?a.Threads:[]),this.threadsLen(c.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0);return b};m.prototype.computeSenderEmail=function(){var a=f.data().sentFolder(),b=f.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())};m.prototype.initUpdateByMessageJson=function(a){var b=!1,d=g.MessagePriority.Normal;
a&&"Object/Message"===a["@Object"]&&(d=c.pInt(a.Priority),this.priority(-1<c.inArray(d,[g.MessagePriority.High,g.MessagePriority.Low])?d:g.MessagePriority.Normal),this.aDraftInfo=a.DraftInfo,this.sMessageId=a.MessageId,this.sInReplyTo=a.InReplyTo,this.sReferences=a.References,this.hasAttachments(!!a.HasAttachments),this.foundedCIDs=c.isArray(a.FoundedCIDs)?a.FoundedCIDs:[],this.attachments(this.initAttachmentsFromJson(a.Attachments)),this.computeSenderEmail(),b=!0);return b};m.prototype.initAttachmentsFromJson=
function(a){var b=0,d=0,f=null,e=[];if(a&&"Collection/AttachmentCollection"===a["@Object"]&&c.isNonEmptyArray(a["@Collection"])){b=0;for(d=a["@Collection"].length;b<d;b++)if(f=D.newInstanceFromJson(a["@Collection"][b]))""!==f.cidWithOutTags&&(0<this.foundedCIDs.length&&0<=c.inArray(f.cidWithOutTags,this.foundedCIDs))&&(f.isLinked=!0),e.push(f)}return e};m.prototype.initFlagsByJson=function(a){var b=!1;a&&"Object/Message"===a["@Object"]&&(this.unseen(!a.IsSeen),this.flagged(!!a.IsFlagged),this.answered(!!a.IsAnswered),
this.forwarded(!!a.IsForwarded),b=!0);return b};m.prototype.fromToLine=function(a,b){return m.emailsToLine(this.from,a,b)};m.prototype.toToLine=function(a,b){return m.emailsToLine(this.to,a,b)};m.prototype.ccToLine=function(a,b){return m.emailsToLine(this.cc,a,b)};m.prototype.bccToLine=function(a,b){return m.emailsToLine(this.bcc,a,b)};m.prototype.lineAsCcc=function(){var a=[];this.deleted()&&a.push("deleted");this.selected()&&a.push("selected");this.checked()&&a.push("checked");this.flagged()&&a.push("flagged");
this.unseen()&&a.push("unseen");this.answered()&&a.push("answered");this.forwarded()&&a.push("forwarded");this.hasAttachments()&&a.push("withAttachments");this.newForAnimation()&&a.push("new");""===this.subject()&&a.push("emptySubject");0<this.parentUid()&&a.push("hasParentMessage");0<this.threadsLen()&&a.push("hasChildrenMessage");this.hasUnseenSubMessage()&&a.push("hasUnseenSubMessage");this.hasFlaggedSubMessage()&&a.push("hasFlaggedSubMessage");return a.join(" ")};m.prototype.hasVisibleAttachments=
function(){return!!i.find(this.attachments(),function(a){return!a.isLinked})};m.prototype.findAttachmentByCid=function(a){var b=null,d=this.attachments();c.isNonEmptyArray(d)&&(a=a.replace(/^<+/,"").replace(/>+$/,""),b=i.find(d,function(b){return a===b.cidWithOutTags}));return b||null};m.prototype.messageId=function(){return this.sMessageId};m.prototype.inReplyTo=function(){return this.sInReplyTo};m.prototype.references=function(){return this.sReferences};m.prototype.fromAsSingleEmail=function(){return c.isArray(this.from)&&
this.from[0]?this.from[0].email:""};m.prototype.viewLink=function(){return f.link().messageViewLink(this.requestHash)};m.prototype.downloadLink=function(){return f.link().messageDownloadLink(this.requestHash)};m.prototype.replyEmails=function(a){var b=[],a=c.isUnd(a)?{}:a;m.replyHelper(this.replyTo,a,b);0===b.length&&m.replyHelper(this.from,a,b);return b};m.prototype.replyAllEmails=function(a){var b=[],d=[],a=c.isUnd(a)?{}:a;m.replyHelper(this.replyTo,a,b);0===b.length&&m.replyHelper(this.from,a,
b);m.replyHelper(this.to,a,b);m.replyHelper(this.cc,a,d);return[b,d]};m.prototype.textBodyToString=function(){return this.body?this.body.html():""};m.prototype.attachmentsToStringLine=function(){var a=i.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0<a.length?a.join(", "):""};m.prototype.getDataForWindowPopup=function(){return{popupFrom:this.fromToLine(!1),popupTo:this.toToLine(!1),popupCc:this.ccToLine(!1),popupBcc:this.bccToLine(!1),popupSubject:this.subject(),
popupDate:this.fullFormatDateValue(),popupAttachments:this.attachmentsToStringLine(),popupBody:this.textBodyToString()}};m.prototype.viewPopupMessage=function(a){c.windowPopupKnockout(this.getDataForWindowPopup(),"PopupsWindowSimpleMessage",this.subject(),function(b){b&&(b.document&&b.document.body)&&(j("img.lazy",b.document.body).each(function(a,b){var c=j(b),f=c.data("original"),e=c.attr("src");0<=a&&(f&&!e)&&c.attr("src",f)}),a&&h.setTimeout(function(){b.print()},100))})};m.prototype.printMessage=
function(){this.viewPopupMessage(!0)};m.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid};m.prototype.populateByMessageListItem=function(a){this.folderFullNameRaw=a.folderFullNameRaw;this.uid=a.uid;this.requestHash=a.requestHash;this.subject(a.subject());this.size(a.size());this.dateTimeStampInUTC(a.dateTimeStampInUTC());this.priority(a.priority());this.fromEmailString(a.fromEmailString());this.toEmailsString(a.toEmailsString());this.emails=a.emails;this.from=a.from;this.to=
a.to;this.cc=a.cc;this.bcc=a.bcc;this.replyTo=a.replyTo;this.unseen(a.unseen());this.flagged(a.flagged());this.answered(a.answered());this.forwarded(a.forwarded());this.selected(a.selected());this.checked(a.checked());this.hasAttachments(a.hasAttachments());this.moment(a.moment());this.body=null;this.priority(g.MessagePriority.Normal);this.aDraftInfo=[];this.sReferences=this.sInReplyTo=this.sMessageId="";this.parentUid(a.parentUid());this.threads(a.threads());this.threadsLen(a.threadsLen());this.computeSenderEmail();
return this};m.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=c.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),j("[data-x-src]",this.body).each(function(){a&&j(this).is("img")?j(this).addClass("lazy").attr("data-original",j(this).attr("data-x-src")).removeAttr("data-x-src"):j(this).attr("src",j(this).attr("data-x-src")).removeAttr("data-x-src")}),j("[data-x-style-url]",this.body).each(function(){var a=c.trim(j(this).attr("style")),a=""===
a?"":";"===a.substr(-1)?a+" ":a+"; ";j(this).attr("style",a+j(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(j("img.lazy",this.body).lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:j(".RL-MailMessageView .messageView .messageItem .content")[0]}),R.resize()),c.windowResize(500),c.windowResize(1E3))};m.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){var a=c.isUnd(a)?!1:a,b=this;this.body.data("rl-init-internal-images",
!0);j("[data-x-src-cid]",this.body).each(function(){var d=b.findAttachmentByCid(j(this).attr("data-x-src-cid"));d&&d.download&&(a&&j(this).is("img")?j(this).addClass("lazy").attr("data-original",d.linkPreview()):j(this).attr("src",d.linkPreview()))});j("[data-x-style-cid]",this.body).each(function(){var a="",f="",e=b.findAttachmentByCid(j(this).attr("data-x-style-cid"));e&&e.linkPreview&&(f=j(this).attr("data-x-style-cid-name"),""!==f&&(a=c.trim(j(this).attr("style")),a=""===a?"":";"===a.substr(-1)?
a+" ":a+"; ",j(this).attr("style",a+f+": url('"+e.linkPreview()+"')")))});a&&i.delay(function(){j("img.lazy",b.body).lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:j(".RL-MailMessageView .messageView .messageItem .content")[0]})},300);c.windowResize(500)}};G.newInstanceFromJson=function(a){var b=new G;return b.initByJson(a)?b.initComputed():null};G.prototype.initComputed=function(){this.hasSubScribedSubfolders=e.computed(function(){return!!i.find(this.subFolders(),function(a){return a.subScribed()})},
this);this.visible=e.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this);this.isSystemFolder=e.computed(function(){return g.FolderType.User!==this.type()},this);this.hidden=e.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this);this.selectableForFolderList=e.computed(function(){return!this.isSystemFolder()&&this.selectable},this);
this.messageCountAll=e.computed({read:this.privateMessageCountAll,write:function(a){c.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this});this.messageCountUnread=e.computed({read:this.privateMessageCountUnread,write:function(a){c.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this});this.printableUnreadCount=e.computed(function(){var a=this.messageCountUnread();return 0<a&&"INBOX"===
this.fullNameRaw?""+a:""},this);this.canBeDeleted=e.computed(function(){return!this.isSystemFolder()&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this);this.canBeSubScribed=e.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this);this.visible.subscribe(function(){c.timeOutAction("folder-list-folder-visibility-change",function(){R.trigger("folder-list-folder-visibility-change")},100)});this.localName=e.computed(function(){ha();var a=this.type(),
b=this.name();if(this.isSystemFolder())switch(a){case g.FolderType.Inbox:b=c.i18n("FOLDER_LIST/INBOX_NAME");break;case g.FolderType.SentItems:b=c.i18n("FOLDER_LIST/SENT_NAME");break;case g.FolderType.Draft:b=c.i18n("FOLDER_LIST/DRAFTS_NAME");break;case g.FolderType.Spam:b=c.i18n("FOLDER_LIST/SPAM_NAME");break;case g.FolderType.Trash:b=c.i18n("FOLDER_LIST/TRASH_NAME")}return b},this);this.manageFolderSystemName=e.computed(function(){ha();var a="",b=this.type(),d=this.name();if(this.isSystemFolder())switch(b){case g.FolderType.Inbox:a=
"("+c.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case g.FolderType.SentItems:a="("+c.i18n("FOLDER_LIST/SENT_NAME")+")";break;case g.FolderType.Draft:a="("+c.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case g.FolderType.Spam:a="("+c.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case g.FolderType.Trash:a="("+c.i18n("FOLDER_LIST/TRASH_NAME")+")"}if(""!==a&&"("+d+")"===a||"(inbox)"===a.toLowerCase())a="";return a},this);this.collapsed=e.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},
owner:this});return this};G.prototype.fullName="";G.prototype.fullNameRaw="";G.prototype.fullNameHash="";G.prototype.delimiter="";G.prototype.namespace="";G.prototype.deep=0;G.prototype.isNamespaceFolder=!1;G.prototype.isGmailFolder=!1;G.prototype.isUnpaddigFolder=!1;G.prototype.collapsedCss=function(){return this.hasSubScribedSubfolders()?this.collapsed()?"icon-arrow-right-3 e-collapsed-sign":"icon-arrow-down-3 e-collapsed-sign":"icon-none e-collapsed-sign"};G.prototype.initByJson=function(a){var b=
!1;a&&"Object/Folder"===a["@Object"]&&(this.name(a.Name),this.delimiter=a.Delimiter,this.fullName=a.FullName,this.fullNameRaw=a.FullNameRaw,this.fullNameHash=a.FullNameHash,this.deep=a.FullNameRaw.split(this.delimiter).length-1,this.selectable=!!a.IsSelectable,this.existen=!!a.IsExisten,this.subScribed(!!a.IsSubscribed),this.type("INBOX"===this.fullNameRaw?g.FolderType.Inbox:g.FolderType.User),b=!0);return b};G.prototype.printableFullName=function(){return this.fullName.split(this.delimiter).join(" / ")};
Ka.prototype.email="";Ka.prototype.changeAccountLink=function(){return f.link().change(this.email)};c.extendAsViewModel("PopupsFolderClearViewModel",va);va.prototype.clearPopup=function(){this.clearingProcess(!1);this.selectedFolder(null)};va.prototype.onShow=function(a){this.clearPopup();a&&this.selectedFolder(a)};c.extendAsViewModel("PopupsFolderCreateViewModel",ba);ba.prototype.sNoParentText="";ba.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(c.trim(a))};ba.prototype.clearPopup=
function(){this.folderName("");this.selectedParentValue("");this.focusTrigger(!1)};ba.prototype.onShow=function(){this.clearPopup();this.focusTrigger(!0)};c.extendAsViewModel("PopupsFolderSystemViewModel",X);X.prototype.sChooseOnText="";X.prototype.sUnuseText="";X.prototype.onShow=function(a){var b="",a=c.isUnd(a)?g.SetSystemFoldersNotification.None:a;switch(a){case g.SetSystemFoldersNotification.Sent:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case g.SetSystemFoldersNotification.Draft:b=
c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case g.SetSystemFoldersNotification.Spam:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case g.SetSystemFoldersNotification.Trash:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)};c.extendAsViewModel("PopupsComposeViewModel",y);y.prototype.formattedFrom=function(){var a=f.data().displayName(),b=f.data().accountEmail();return""===a?b:a+" ("+b+")"};y.prototype.sendMessageResponse=function(a,b){var d=!1;this.sending(!1);
g.StorageResultType.Success===a&&(b&&b.Result)&&(d=!0,this.modalVisibility()&&s.delegateRun(this,"closeCommand"));this.modalVisibility()&&!d&&(b&&g.Notification.CantSaveMessage===b.ErrorCode?(this.sendSuccessButSaveError(!0),h.alert(c.trim(c.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(this.sendError(!0),h.alert(c.getNotification(b.ErrorCode?b.ErrorCode:g.Notification.CantSendMessage))))};y.prototype.saveMessageResponse=function(a,b){var d=!1,e=null;this.saving(!1);if(g.StorageResultType.Success===a&&
(b&&b.Result)&&(b.Result.NewFolder&&b.Result.NewUid)&&(this.bFromDraft&&(e=f.data().message())&&(this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid)&&f.data().message(null),this.draftFolder(b.Result.NewFolder),this.draftUid(b.Result.NewUid),this.modalVisibility()))this.savedTime(h.Math.round((new h.Date).getTime()/1E3)),this.savedOrSendingText(0<this.savedTime()?c.i18n("COMPOSE/SAVED_TIME",{TIME:Y.unix(this.savedTime()-1).format("LT")}):""),d=!0,this.bFromDraft&&f.cache().setFolderHash(this.draftFolder(),
"");!this.modalVisibility()&&!d&&(this.savedError(!0),this.savedOrSendingText(c.getNotification(g.Notification.CantSaveMessage)))};y.prototype.onHide=function(){s.routeOn()};y.prototype.onShow=function(a,b,d){s.routeOff();var e=this,K="",q="",w="",k="",h="",o=null,k=o="",K=[],K={},k=f.data().accountEmail(),r=[],r=q=null,a=a||g.ComposeType.Empty;(b=b||null)&&c.isNormal(b)&&(r=c.isArray(b)&&1===b.length?b[0]:!c.isArray(b)?b:null);null!==k&&(K[k]=!0);this.reset();c.isNonEmptyArray(d)&&this.to(d);if(""!==
a&&r){k=r.fullFormatDateValue();h=r.subject();q=r.aDraftInfo;o=j(r.body).clone();c.removeBlockquoteSwitcher(o);o=o.html();switch(a){case g.ComposeType.Reply:this.to(r.replyEmails(K));this.subject(c.replySubjectAdd("Re",h));this.prepearMessageAttachments(r,a);this.aDraftInfo=["reply",r.uid,r.folderFullNameRaw];this.sInReplyTo=r.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+r.sReferences);break;case g.ComposeType.ReplyAll:K=r.replyAllEmails(K);this.to(K[0]);this.cc(K[1]);this.subject(c.replySubjectAdd("Re",
h));this.prepearMessageAttachments(r,a);this.aDraftInfo=["reply",r.uid,r.folderFullNameRaw];this.sInReplyTo=r.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+r.references());break;case g.ComposeType.Forward:this.subject(c.replySubjectAdd("Fwd",h));this.prepearMessageAttachments(r,a);this.aDraftInfo=["forward",r.uid,r.folderFullNameRaw];this.sInReplyTo=r.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+r.sReferences);break;case g.ComposeType.ForwardAsAttachment:this.subject(c.replySubjectAdd("Fwd",
h));this.prepearMessageAttachments(r,a);this.aDraftInfo=["forward",r.uid,r.folderFullNameRaw];this.sInReplyTo=r.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+r.sReferences);break;case g.ComposeType.Draft:this.to(r.to),this.cc(r.cc),this.bcc(r.bcc),this.bFromDraft=!0,this.draftFolder(r.folderFullNameRaw),this.draftUid(r.uid),this.subject(h),this.prepearMessageAttachments(r,a),this.aDraftInfo=c.isNonEmptyArray(q)&&3===q.length?q:null,this.sInReplyTo=r.sInReplyTo,this.sReferences=r.sReferences}if(this.oEditor){switch(a){case g.ComposeType.Reply:case g.ComposeType.ReplyAll:K=
r.fromToLine(!1,!0);k=c.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:k,EMAIL:K});o="<br /><br />"+k+":<blockquote><br />"+o+"</blockquote>";break;case g.ComposeType.Forward:K=r.fromToLine(!1,!0);q=r.toToLine(!1,!0);w=r.ccToLine(!1,!0);o="<br /><br /><br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+K+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+q+(0<w.length?"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+w:"")+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+
": "+c.encodeHtml(k)+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+c.encodeHtml(h)+"<br /><br />"+o;break;case g.ComposeType.ForwardAsAttachment:o=""}this.oEditor.setRawText(o,r.isHtml)}}else this.oEditor&&g.ComposeType.Empty===a?this.oEditor.setRawText("<br />"+c.convertPlainTextToHtml(f.data().signature()),g.EditorDefaultType.Html===f.data().editorDefaultType()):c.isNonEmptyArray(b)&&i.each(b,function(a){e.addMessageAsAttachment(a)});r=this.getAttachmentsDownloadsForUpload();c.isNonEmptyArray(r)&&
f.remote().messageUploadAttachments(function(a,b){if(g.StorageResultType.Success===a&&b&&b.Result){var d=null,c="";if(!e.viewModelVisibility())for(c in b.Result)b.Result.hasOwnProperty(c)&&(d=e.getAttachmentById(b.Result[c]))&&d.tempName(c)}else e.setMessageAttachmentFailedDowbloadText()},r);this.triggerForResize()};y.prototype.onBuild=function(){this.initEditor();this.initUploader();var a=this,b=null;R.on("keydown",function(b){var c=!0;b&&(a.modalVisibility()&&f.data().useKeyboardShortcuts())&&(b.ctrlKey&&
g.EventKeyCode.S===b.keyCode)&&(a.saveCommand(),c=!1);return c});R.on("resize",function(){a.triggerForResize()});this.dropboxEnabled()&&(b=document.createElement("script"),b.type="text/javascript",b.src="https://www.dropbox.com/static/api/1/dropins.js",j(b).attr("id","dropboxjs").attr("data-app-key",f.settingsGet("DropboxApiKey")),document.body.appendChild(b))};y.prototype.getAttachmentById=function(a){for(var b=this.attachments(),d=0,c=b.length;d<c;d++)if(b[d]&&a===b[d].id)return b[d];return null};
y.prototype.initEditor=function(){if(this.composeEditorTextArea()&&this.composeEditorHtmlArea()&&this.composeEditorToolbar()){var a=this;this.oEditor=new n(this.composeEditorTextArea(),this.composeEditorHtmlArea(),this.composeEditorToolbar(),{onSwitch:function(b){b||a.removeLinkedAttachments()}});this.oEditor.initLanguage(c.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),c.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),c.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))}};y.prototype.initUploader=function(){if(this.composeUploaderButton()){var a=
{},b=c.pInt(f.settingsGet("AttachmentLimit")),d=new ra({action:f.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace(),onDragEnter:i.bind(function(){this.dragAndDropOver(!0)},this),onDragLeave:i.bind(function(){this.dragAndDropOver(!1)},this),onBodyDragEnter:i.bind(function(){this.dragAndDropVisible(!0)},this),onBodyDragLeave:i.bind(function(){this.dragAndDropVisible(!1)},
this),onProgress:i.bind(function(b,d,f){var e=null;c.isUnd(a[b])?(e=this.getAttachmentById(b))&&(a[b]=e):e=a[b];e&&e.progress(" - "+Math.floor(100*(d/f))+"%")},this),onSelect:i.bind(function(a,f){this.dragAndDropOver(!1);var e=this,g=c.isUnd(f.FileName)?"":f.FileName.toString(),i=c.isNormal(f.Size)?c.pInt(f.Size):null,g=new N(a,g,i);g.cancel=function(){e.attachments.remove(function(b){return b&&b.id===a});d&&d.cancel(a)};this.attachments.push(g);return 0<i&&0<b&&b<i?(g.error(c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),
!1):!0},this),onStart:i.bind(function(b){var d=null;c.isUnd(a[b])?(d=this.getAttachmentById(b))&&(a[b]=d):d=a[b];d&&(d.waiting(!1),d.uploading(!0))},this),onComplete:i.bind(function(b,d,f){var e="",g=null,i=null,h=this.getAttachmentById(b),i=d&&f&&f.Result&&f.Result.Attachment?f.Result.Attachment:null,g=f&&f.Result&&f.Result.ErrorCode?f.Result.ErrorCode:null;null!==g?e=c.getUploadErrorDescByCode(g):i||(e=c.i18n("UPLOAD/ERROR_UNKNOWN"));h&&(""!==e&&0<e.length?h.waiting(!1).uploading(!1).error(e):i&&
(h.waiting(!1).uploading(!1),h.initByUploadJson(i)),c.isUnd(a[b])&&delete a[b])},this)});d?this.addAttachmentEnabled(!0).dragAndDropEnabled(d.isDragAndDropSupported()):this.addAttachmentEnabled(!1).dragAndDropEnabled(!1)}};y.prototype.prepearAttachmentsForSendOrSave=function(){var a={};i.each(this.attachmentsInReady(),function(b){b&&(""!==b.tempName()&&b.enabled())&&(a[b.tempName()]=[b.fileName(),b.isInline?"1":"0",b.CID])});return a};y.prototype.addMessageAsAttachment=function(a){if(a){var b=this,
d=null,d=a.subject(),d=".eml"===d.substr(-4).toLowerCase()?d:d+".eml",d=new N(a.requestHash,d,a.size());d.fromMessage=!0;var c=a.requestHash;d.cancel=function(){b.attachments.remove(function(a){return a&&a.id===c})};d.waiting(!1).uploading(!0);this.attachments.push(d)}};y.prototype.addDropboxAttachment=function(a){var b=this,d=c.pInt(f.settingsGet("AttachmentLimit")),e=null,i=a.bytes,e=new N(a.link,a.name,i);e.fromMessage=!1;var q=a.link;e.cancel=function(){b.attachments.remove(function(a){return a&&
a.id===q})};e.waiting(!1).uploading(!0);this.attachments.push(e);if(0<i&&0<d&&d<i)return e.uploading(!1),e.error(c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1;f.remote().composeUploadExternals(function(a,b){var d=!1;e.uploading(!1);g.StorageResultType.Success===a&&(b&&b.Result)&&b.Result[e.id]&&(d=!0,e.tempName(b.Result[e.id]));d||e.error(c.getUploadErrorDescByCode(g.UploadErrorCode.FileNoUploaded))},[a.link]);return!0};y.prototype.prepearMessageAttachments=function(a,b){if(a){var d=this,f=c.isNonEmptyArray(a.attachments())?
a.attachments():[],e=0,q=f.length,i=null,k=null,h=function(a){return function(){d.attachments.remove(function(b){return b&&b.id===a})}};if(g.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;e<q;e++)k=f[e],i=new N(k.download,k.fileName,k.estimatedSize,k.isInline,k.isLinked,k.cid),i.fromMessage=!0,i.cancel=h(k.download),i.waiting(!1).uploading(!0),this.attachments.push(i)}};y.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})};
y.prototype.setMessageAttachmentFailedDowbloadText=function(){i.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(c.getUploadErrorDescByCode(g.UploadErrorCode.FileNoUploaded))},this)};y.prototype.isEmptyForm=function(a){a=(a=c.isUnd(a)?!0:!!a)?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&a&&""===this.oEditor.getTextForRequest()};y.prototype.reset=
function(){this.to([]);this.cc([]);this.bcc([]);this.subject("");this.aDraftInfo=null;this.sInReplyTo="";this.bFromDraft=!1;this.sReferences="";this.bReloadFolder=!1;this.sendError(!1);this.sendSuccessButSaveError(!1);this.savedError(!1);this.savedTime(0);this.savedOrSendingText("");this.emptyToError(!1);this.showCcAndBcc(!1);this.attachments([]);this.dragAndDropOver(!1);this.dragAndDropVisible(!1);this.draftFolder("");this.draftUid("");this.sending(!1);this.saving(!1);this.oEditor&&this.oEditor.clear()};
y.prototype.getAttachmentsDownloadsForUpload=function(){return i.map(i.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})};y.prototype.triggerForResize=function(){this.resizer(!this.resizer())};c.extendAsViewModel("PopupsContactsViewModel",L);L.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,d=this.currentContact(),c=this.contactsCheckedOrSelected();0<c.length&&(i.each(c,function(b){d&&d.idContact===b.idContact&&(d=
null,a.currentContact(null));b.deleted(!0)}),i.delay(function(){i.each(c,function(a){b.remove(a)})},500))};L.prototype.deleteSelectedContacts=function(){0<this.contactsCheckedOrSelected().length&&(f.remote().contactsDelete(i.bind(this.deleteResponse,this),this.contactsCheckedOrSelectedUids()),this.removeCheckedOrSelectedContactsFromList())};L.prototype.deleteResponse=function(a,b){500<(g.StorageResultType.Success===a&&b&&b.Time?c.pInt(b.Time):0)?this.reloadContactList():i.delay(function(a){return function(){a.reloadContactList()}}(this),
500)};L.prototype.populateViewContact=function(a){this.imageTrigger(!1);this.emptySelection(!1);a?(this.viewID(a.idContact),this.viewName(a.name),this.viewEmail(a.emails[0]||""),this.viewImageUrl(a.srcAttr())):(this.viewID(""),this.viewName(""),this.viewEmail(""),this.viewImageUrl(f.link().emptyContactPic()))};L.prototype.reloadContactList=function(){var a=this;this.contacts.loading(!0);f.remote().contacts(function(b,d){var f=[];g.StorageResultType.Success===b&&(d&&d.Result&&d.Result.List)&&c.isNonEmptyArray(d.Result.List)&&
(f=i.map(d.Result.List,function(a){var b=new ja;return b.parse(a)?b:null}),f=i.compact(f));a.contacts(f);a.viewClearSearch(""!==a.search());a.contacts.loading(!1);""!==a.viewID()&&(!a.currentContact()&&a.contacts.setSelectedByUid)&&a.contacts.setSelectedByUid(""+a.viewID())},this.search())};L.prototype.onBuild=function(a){this.initUploader();this.oContentVisible=j(".b-list-content",a);this.oContentScrollable=j(".content",this.oContentVisible);this.selector.init(this.oContentVisible,this.oContentScrollable);
this.viewImageUrl.valueHasMutated();e.computed(function(){var a=this.modalVisibility(),d=f.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&d)},this)};L.prototype.initUploader=function(){var a=this,b=null;h.File&&(h.FileReader&&this.imageUploader())&&(b=new ra({queueSize:1,multipleSizeLimit:1,clickElement:this.imageUploader(),disableDragAndDrop:!0,disableMultiple:!0,onSelect:function(b,f){if(f&&f.File&&f.File.type){var e=null,g=f.File;f.File.type.match(/image.*/)?(e=new h.FileReader,e.onload=
function(b){b&&(b.target&&b.target.result)&&c.resizeAndCrop(b.target.result,150,function(b){a.viewImageUrl(b);a.imageTrigger(!0)})},e.readAsDataURL(g)):h.alert("this file is not an image.")}return!1}}));return b};L.prototype.onShow=function(){s.routeOff();this.reloadContactList()};L.prototype.onHide=function(){s.routeOn();this.currentContact(null);this.emptySelection(!0);this.search("");i.each(this.contacts(),function(a){a.checked(!1)})};c.extendAsViewModel("PopupsAdvancedSearchViewModel",ca);ca.prototype.buildSearchStringValue=
function(a){-1<a.indexOf(" ")&&(a='"'+a+'"');return a};ca.prototype.buildSearchString=function(){var a=[],b=c.trim(this.from()),d=c.trim(this.to()),f=c.trim(this.subject()),e=c.trim(this.text());b&&""!==b&&a.push("from:"+this.buildSearchStringValue(b));d&&""!==d&&a.push("to:"+this.buildSearchStringValue(d));f&&""!==f&&a.push("subject:"+this.buildSearchStringValue(f));this.hasAttachments()&&a.push("has:attachments");-1<this.selectedDateValue()&&a.push("date:"+Y().subtract("days",this.selectedDateValue()).format("YYYY.MM.DD")+
"/");e&&""!==e&&a.push("text:"+this.buildSearchStringValue(e));return c.trim(a.join(" "))};ca.prototype.clearPopup=function(){this.from("");this.to("");this.subject("");this.text("");this.selectedDateValue(-1);this.hasAttachments(!1);this.fromFocus(!0)};ca.prototype.onShow=function(){this.clearPopup();this.fromFocus(!0)};c.extendAsViewModel("PopupsAddAccountViewModel",da);da.prototype.clearPopup=function(){this.email("");this.login("");this.password("");this.emailError(!1);this.loginError(!1);this.passwordError(!1);
this.submitRequest(!1);this.submitError("")};da.prototype.onShow=function(){this.clearPopup();this.emailFocus(!0)};da.prototype.onBuild=function(){this.allowCustomLogin(!!f.settingsGet("AllowCustomLogin"))};c.extendAsViewModel("LoginViewModel",ka);ka.prototype.onShow=function(){s.routeOff();i.delay(i.bind(function(){""!==this.email()&&""!==this.password()?this.submitFocus(!0):this.emailFocus(!0)},this),100)};ka.prototype.onHide=function(){this.submitFocus(!1);this.emailFocus(!1)};ka.prototype.onBuild=
function(){var a=this,b=f.settingsGet("JsHash"),d=function(b){b=c.pInt(b);0===b?(a.submitRequest(!0),f.loginAndLogoutReload()):a.submitError(c.getNotification(b))};this.allowCustomLogin(!!f.settingsGet("AllowCustomLogin"));this.facebookLoginEnabled(!!f.settingsGet("AllowFacebookSocial"));this.twitterLoginEnabled(!!f.settingsGet("AllowTwitterSocial"));this.googleLoginEnabled(!!f.settingsGet("AllowGoogleSocial"));switch((f.settingsGet("SignMe")||"unused").toLowerCase()){case g.LoginSignMeTypeAsString.DefaultOff:this.signMeType(g.LoginSignMeType.DefaultOff);
break;case g.LoginSignMeTypeAsString.DefaultOn:this.signMeType(g.LoginSignMeType.DefaultOn);break;default:case g.LoginSignMeTypeAsString.Unused:this.signMeType(g.LoginSignMeType.Unused)}this.email(f.data().devEmail);this.login(f.data().devLogin);this.password(f.data().devPassword);this.googleLoginEnabled()&&(h["rl_"+b+"_google_login_service"]=d);this.facebookLoginEnabled()&&(h["rl_"+b+"_facebook_login_service"]=d);this.twitterLoginEnabled()&&(h["rl_"+b+"_twitter_login_service"]=d)};i.extend(Q.prototype,
C.prototype);Q.prototype.accountClick=function(a,b){if(a&&b&&!c.isUnd(b.which)&&1===b.which){var d=this;this.accountsLoading(!0);i.delay(function(){d.accountsLoading(!1)},1E3)}return!0};Q.prototype.emailTitle=function(){return f.data().accountEmail()};Q.prototype.settingsClick=function(){s.setHash(f.link().settings())};Q.prototype.addAccountClick=function(){this.allowAddAccount&&s.showScreenPopup(da)};Q.prototype.logoutClick=function(){f.remote().logout(function(){h.__rlah_clear&&h.__rlah_clear();
f.loginAndLogoutReload(!0,f.settingsGet("ParentEmail")&&0<f.settingsGet("ParentEmail").length)})};i.extend(Va.prototype,Q.prototype);i.extend(Wa.prototype,Q.prototype);c.extendAsViewModel("MailBoxFolderListViewModel",ea);ea.prototype.onBuild=function(a){a.on("click",".b-folders .e-item .e-link .e-collapsed-sign",function(a){var d=e.dataFor(this),f=!1;d&&a&&(f=d.collapsed(),c.setExpandedFolder(d.fullNameHash,f),d.collapsed(!f),a.preventDefault(),a.stopPropagation())}).on("click",".b-folders .e-item .e-link.selectable",
function(a){a.preventDefault();if(a=e.dataFor(this))f.data().usePreviewPane()||f.data().message(null),a.fullNameRaw===f.data().currentFolderFullNameRaw()&&f.cache().setFolderHash(a.fullNameRaw,""),s.setHash(f.link().mailBox(a.fullNameHash))})};ea.prototype.messagesDrop=function(a,b){if(a&&b&&b.helper){var d=b.helper.data("rl-folder"),f=b.helper.data("rl-uids");z&&(z.__vm&&c.isNormal(d)&&c.isArray(f))&&z.__vm.moveMessagesToFolder(d,f,a.fullNameRaw)}};ea.prototype.composeClick=function(){s.showScreenPopup(y)};
ea.prototype.contactsClick=function(){this.allowContacts&&s.showScreenPopup(L)};c.extendAsViewModel("MailBoxMessageListViewModel",z);z.prototype.emptySubjectValue="";z.prototype.searchEnterAction=function(){this.mainMessageListSearch(this.sLastSearchValue);this.inputMessageListSearchFocus(!1)};z.prototype.cancelSearch=function(){this.mainMessageListSearch("");this.inputMessageListSearchFocus(!1)};z.prototype.removeMessagesFromList=function(a,b,d,e){var d=c.isNormal(d)?d:"",e=c.isUnd(e)?!1:!!e,g=0,
q=f.data(),h=f.cache().getFolderFromCacheList(a),k=""===d?null:f.cache().getFolderFromCacheList(d||""),j=q.currentFolderFullNameRaw(),o=q.message(),r=j===a?i.filter(q.messageList(),function(a){return a&&-1<c.inArray(a.uid,b)}):[];e||i.each(r,function(a){a&&a.unseen()&&g++});h&&!e&&(h.messageCountAll(0<=h.messageCountAll()-b.length?h.messageCountAll()-b.length:0),0<g&&h.messageCountUnread(0<=h.messageCountUnread()-g?h.messageCountUnread()-g:0));k&&!e&&(k.messageCountAll(k.messageCountAll()+b.length),
0<g&&k.messageCountUnread(k.messageCountUnread()+g));0<r.length&&(i.each(r,function(a){if(o&&o.requestHash===a.requestHash){o=null;q.message(null)}a.deleted(true)}),i.delay(function(){i.each(r,function(a){q.messageList.remove(a)})},400),e||(f.data().messageListIsNotCompleted(!0),f.cache().setFolderHash(a,""),c.isNormal(d)&&f.cache().setFolderHash(d||"","")))};z.prototype.removeCheckedOrSelectedMessagesFromList=function(a){this.removeMessagesFromList(f.data().currentFolderFullNameRaw(),i.map(f.data().messageListCheckedOrSelected(),
function(a){return a.uid}),a)};z.prototype.moveOrDeleteResponse=function(a,b){g.StorageResultType.Success===a&&f.data().currentFolder()&&(b&&c.isArray(b.Result)&&2===b.Result.length?f.cache().setFolderHash(b.Result[0],b.Result[1]):(b&&g.Notification.CantMoveMessage===b.ErrorCode&&h.alert(c.getNotification(g.Notification.CantMoveMessage)),f.cache().setFolderHash(f.data().currentFolderFullNameRaw(),"")),f.reloadMessageList(),f.quotaDebounce())};z.prototype.moveMessagesToFolder=function(a,b,d){if(a!==
d&&c.isArray(b)&&0<b.length){var e=f.cache().getFolderFromCacheList(a),g=f.cache().getFolderFromCacheList(d);if(e&&g)return f.remote().messagesMove(i.bind(this.moveOrDeleteResponse,this),e.fullNameRaw,g.fullNameRaw,b),g.actionBlink(!0),this.removeMessagesFromList(a,b,d),!0}return!1};z.prototype.moveSelectedMessagesToFolder=function(a){return this.canBeMoved()?this.moveMessagesToFolder(f.data().currentFolderFullNameRaw(),f.data().messageListCheckedOrSelectedUidsWithSubMails(),a):!1};z.prototype.deleteSelectedMessageFromCurrentFolder=
function(a,b){if(this.canBeMoved()){var b=c.isUnd(b)?!0:!!b,d=f.cache().getFolderFromCacheList(g.FolderType.Spam===a?f.data().spamFolder():f.data().trashFolder());!d&&b?s.showScreenPopup(X,[g.FolderType.Spam===a?g.SetSystemFoldersNotification.Spam:g.SetSystemFoldersNotification.Trash]):!b||d&&(t.Values.UnuseOptionValue===d.fullNameRaw||f.data().currentFolderFullNameRaw()===d.fullNameRaw)?(f.remote().messagesDelete(i.bind(this.moveOrDeleteResponse,this),f.data().currentFolderFullNameRaw(),f.data().messageListCheckedOrSelectedUidsWithSubMails()),
this.removeCheckedOrSelectedMessagesFromList()):d&&(f.remote().messagesMove(i.bind(this.moveOrDeleteResponse,this),f.data().currentFolderFullNameRaw(),d.fullNameRaw,f.data().messageListCheckedOrSelectedUidsWithSubMails()),d.actionBlink(!0),this.removeCheckedOrSelectedMessagesFromList(d.fullNameRaw))}};z.prototype.dragAndDronHelper=function(a){a&&a.checked(!0);a=c.draggeblePlace();a.data("rl-folder",f.data().currentFolderFullNameRaw());a.data("rl-uids",f.data().messageListCheckedOrSelectedUidsWithSubMails());
a.find(".text").text(f.data().messageListCheckedOrSelectedUidsWithSubMails().length);return a};z.prototype.onMessageResponse=function(a,b,d){var e=f.data();e.messageLoading(!1);g.StorageResultType.Success===a&&b&&b.Result?e.setMessage(b,d):g.StorageResultType.Abort!==a&&(e.message(null),e.messageError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.getNotification(g.Notification.UnknownError)))};z.prototype.populateMessageBody=function(a){a&&(f.remote().message(this.onMessageResponse,a.folderFullNameRaw,
a.uid)?f.data().messageLoading(!0):c.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))};z.prototype.setAction=function(a,b,d){var e=[],h=null,q=f.cache(),j=0;c.isUnd(d)&&(d=f.data().messageListChecked());e=i.map(d,function(a){return a.uid});if(""!==a&&0<e.length){switch(b){case g.MessageSetAction.SetSeen:i.each(d,function(a){a.unseen()&&j++;a.unseen(!1);q.storeMessageFlagsToCache(a)});(h=q.getFolderFromCacheList(a))&&h.messageCountUnread(h.messageCountUnread()-j);
f.remote().messageSetSeen(c.emptyFunction,a,e,!0);break;case g.MessageSetAction.UnsetSeen:i.each(d,function(a){a.unseen()&&j++;a.unseen(!0);q.storeMessageFlagsToCache(a)});(h=q.getFolderFromCacheList(a))&&h.messageCountUnread(h.messageCountUnread()-j+e.length);f.remote().messageSetSeen(c.emptyFunction,a,e,!1);break;case g.MessageSetAction.SetFlag:i.each(d,function(a){a.flagged(!0);q.storeMessageFlagsToCache(a)});f.remote().messageSetFlagged(c.emptyFunction,a,e,!0);break;case g.MessageSetAction.UnsetFlag:i.each(d,
function(a){a.flagged(!1);q.storeMessageFlagsToCache(a)}),f.remote().messageSetFlagged(c.emptyFunction,a,e,!1)}f.reloadFlagsCurrentMessageListAndMessageFromCache()}};z.prototype.setActionForAll=function(a,b){var d=null,e=f.data().messageList(),h=f.cache();if(""!==a&&(d=h.getFolderFromCacheList(a))){switch(b){case g.MessageSetAction.SetSeen:if(d=h.getFolderFromCacheList(a))i.each(e,function(a){a.unseen(!1)}),d.messageCountUnread(0),h.clearMessageFlagsFromCacheByFolder(a);f.remote().messageSetSeenToAll(c.emptyFunction,
a,!0);break;case g.MessageSetAction.UnsetSeen:if(d=h.getFolderFromCacheList(a))i.each(e,function(a){a.unseen(!0)}),d.messageCountUnread(d.messageCountAll()),h.clearMessageFlagsFromCacheByFolder(a);f.remote().messageSetSeenToAll(c.emptyFunction,a,!1)}f.reloadFlagsCurrentMessageListAndMessageFromCache()}};z.prototype.listSetSeen=function(){this.setAction(f.data().currentFolderFullNameRaw(),g.MessageSetAction.SetSeen,f.data().messageListCheckedOrSelected())};z.prototype.listSetAllSeen=function(){this.setActionForAll(f.data().currentFolderFullNameRaw(),
g.MessageSetAction.SetSeen)};z.prototype.listUnsetSeen=function(){this.setAction(f.data().currentFolderFullNameRaw(),g.MessageSetAction.UnsetSeen,f.data().messageListCheckedOrSelected())};z.prototype.listSetFlags=function(){this.setAction(f.data().currentFolderFullNameRaw(),g.MessageSetAction.SetFlag,f.data().messageListCheckedOrSelected())};z.prototype.listUnsetFlags=function(){this.setAction(f.data().currentFolderFullNameRaw(),g.MessageSetAction.UnsetFlag,f.data().messageListCheckedOrSelected())};
z.prototype.onBuild=function(a){var b=this,d=f.data();this.oContentVisible=j(".b-content",a);this.oContentScrollable=j(".content",this.oContentVisible);this.oContentVisible.on("click",".fullThreadHandle",function(){var a=[],b=e.dataFor(this);b&&!b.lastInCollapsedThreadLoading()&&(f.data().messageListThreadFolder(b.folderFullNameRaw),a=f.data().messageListThreadUids(),b.lastInCollapsedThread()?a.push(0<b.parentUid()?b.parentUid():b.uid):a=i.without(a,0<b.parentUid()?b.parentUid():b.uid),f.data().messageListThreadUids(i.uniq(a)),
b.lastInCollapsedThreadLoading(!0),b.lastInCollapsedThread(!b.lastInCollapsedThread()),f.reloadMessageList());return!1});this.selector.init(this.oContentVisible,this.oContentScrollable);Ca.on("keydown",function(a){var e=!0,i=a?a.keyCode:0;if(a&&b.viewModelVisibility()&&d.useKeyboardShortcuts()&&!f.popupVisibility()&&!d.messageFullScreenMode()&&!c.inFocus()&&(d.usePreviewPane()||!d.message()&&(g.EventKeyCode.Delete===i||g.EventKeyCode.A===i))&&a.ctrlKey&&g.EventKeyCode.A===i)b.checkAll(!(b.checkAll()&&
!b.isIncompleteChecked())),e=!1;return e});a.on("click",".pagenator .page",function(){var a=e.dataFor(this);a&&s.setHash(f.link().mailBox(d.currentFolderFullNameHash(),a.value,d.messageListSearch()))}).on("click",".messageList .checkboxCkeckAll",function(){b.checkAll(!b.checkAll())}).on("click",".messageList .messageListItem .flagParent",function(){var a=e.dataFor(this),f=d.messageListCheckedOrSelected(),h=[];a&&(0<f.length&&(h=i.map(f,function(a){return a.uid})),0<h.length&&-1<c.inArray(a.uid,h)?
b.setAction(a.folderFullNameRaw,a.flagged()?g.MessageSetAction.UnsetFlag:g.MessageSetAction.SetFlag,f):b.setAction(a.folderFullNameRaw,a.flagged()?g.MessageSetAction.UnsetFlag:g.MessageSetAction.SetFlag,[a]))});e.computed(function(){var a=f.data(),b=this.viewModelVisibility(),d=f.popupVisibility(),c=a.useKeyboardShortcuts(),a=a.messageFullScreenMode();this.selector.useKeyboard(b&&c&&!a&&!d)},this);this.initUploaderForAppend()};z.prototype.composeClick=function(){s.showScreenPopup(y)};z.prototype.advancedSearchClick=
function(){s.showScreenPopup(ca)};z.prototype.quotaTooltip=function(){return c.i18n("MESSAGE_LIST/QUOTA_SIZE",{SIZE:c.friendlySize(this.userUsageSize()),PROC:this.userUsageProc(),LIMIT:c.friendlySize(this.userQuota())})};z.prototype.initUploaderForAppend=function(){return!f.settingsGet("AllowAppendMessage")||!this.dragOverArea()?!1:!!new ra({action:f.link().append(),name:"AppendFile",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,hidden:{Folder:function(){return f.data().currentFolderFullNameRaw()}},
dragAndDropElement:this.dragOverArea(),dragAndDropBodyElement:this.dragOverBodyArea(),onDragEnter:i.bind(function(){this.dragOverEnter(true)},this),onDragLeave:i.bind(function(){this.dragOverEnter(false)},this),onBodyDragEnter:i.bind(function(){this.dragOver(true)},this),onBodyDragLeave:i.bind(function(){this.dragOver(false)},this),onSelect:i.bind(function(a,b){if(a&&b&&"message/rfc822"===b.Type){f.data().messageListLoading(true);return true}return false}),onComplete:i.bind(function(){f.reloadMessageList(true,
true)},this)})};c.extendAsViewModel("MailBoxMessageViewViewModel",H);H.prototype.scrollToTop=function(){var a=j(".messageItem.nano .content",this.viewModelDom);a&&a[0]?a.scrollTop(0):j(".messageItem",this.viewModelDom).scrollTop(0);c.windowResize()};H.prototype.fullScreen=function(){this.fullScreenMode(!0);c.windowResize()};H.prototype.unFullScreen=function(){this.fullScreenMode(!1);c.windowResize()};H.prototype.toggleFullScreen=function(){c.removeSelection();this.fullScreenMode(!this.fullScreenMode());
c.windowResize()};H.prototype.replyOrforward=function(a){s.showScreenPopup(y,[a,f.data().message()])};H.prototype.onBuild=function(a){var b=this,d=f.data();Ca.on("keydown",function(a){var f=!0,a=a?a.keyCode:0;if(0<a&&(g.EventKeyCode.Backspace===a||g.EventKeyCode.Esc===a)&&b.viewModelVisibility()&&d.useKeyboardShortcuts()&&!c.inFocus()&&d.message())b.fullScreenMode(!1),d.usePreviewPane()||d.message(null),f=!1;return f});j(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",
type:"image",preload:[1,1],gallery:{enabled:!0},callbacks:{open:function(){d.useKeyboardShortcuts(!1)},close:function(){d.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:300});a.on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=e.dataFor(this);a&&a.download&&f.download(a.linkDownload())});this.oMessageScrollerDom=(this.oMessageScrollerDom=a.find(".messageItem .content"))&&
this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null};H.prototype.isDraftFolder=function(){return f.data().message()&&f.data().draftFolder()===f.data().message().folderFullNameRaw};H.prototype.isSentFolder=function(){return f.data().message()&&f.data().sentFolder()===f.data().message().folderFullNameRaw};H.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()};H.prototype.composeClick=function(){s.showScreenPopup(y)};H.prototype.editMessage=function(){f.data().message()&&
s.showScreenPopup(y,[g.ComposeType.Draft,f.data().message()])};H.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)};H.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)};c.extendAsViewModel("SettingsMenuViewModel",xa);xa.prototype.link=function(a){return f.link().settings(a)};xa.prototype.backToMailBoxClick=function(){s.setHash(f.link().inbox())};c.extendAsViewModel("SettingsPaneViewModel",ya);ya.prototype.onShow=
function(){f.data().message(null)};ya.prototype.backToMailBoxClick=function(){s.setHash(f.link().inbox())};c.addSettingsViewModel(La,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0);La.prototype.onBuild=function(){var a=this;i.delay(function(){var b=f.data(),d=c.settingsSaveHelperSimpleFunction(a.mppTrigger,a);b.language.subscribe(function(b){a.languageTrigger(g.SaveSettingsStep.Animate);j.ajax({url:f.link().langLink(b),dataType:"script",cache:!0}).done(function(){c.i18nToDoc();
a.languageTrigger(g.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(g.SaveSettingsStep.FalseResult)}).always(function(){i.delay(function(){a.languageTrigger(g.SaveSettingsStep.Idle)},1E3)});f.remote().saveSettings(c.emptyFunction,{Language:b})});b.editorDefaultType.subscribe(function(a){f.remote().saveSettings(c.emptyFunction,{EditorDefaultType:a})});b.messagesPerPage.subscribe(function(a){f.remote().saveSettings(d,{MPP:a})});b.showImages.subscribe(function(a){f.remote().saveSettings(c.emptyFunction,
{ShowImages:a?"1":"0"})});b.showAnimation.subscribe(function(a){f.remote().saveSettings(c.emptyFunction,{ShowAnimation:a?"1":"0"})});b.useDesktopNotifications.subscribe(function(a){c.timeOutAction("SaveDesktopNotifications",function(){f.remote().saveSettings(c.emptyFunction,{DesktopNotifications:a?"1":"0"})},3E3)});b.replySameFolder.subscribe(function(a){c.timeOutAction("SaveReplySameFolder",function(){f.remote().saveSettings(c.emptyFunction,{ReplySameFolder:a?"1":"0"})},3E3)});b.useThreads.subscribe(function(a){b.messageList([]);
f.remote().saveSettings(c.emptyFunction,{UseThreads:a?"1":"0"})});b.usePreviewPane.subscribe(function(a){b.messageList.valueHasMutated();f.remote().saveSettings(c.emptyFunction,{UsePreviewPane:a?"1":"0"})});b.useCheckboxesInList.subscribe(function(a){f.remote().saveSettings(c.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)};La.prototype.onShow=function(){f.data().desktopNotifications.valueHasMutated()};c.addSettingsViewModel(Xa,"SettingsPersonal","SETTINGS_LABELS/LABEL_PERSONAL_NAME","personal");
Xa.prototype.onBuild=function(){var a=this;i.delay(function(){var b=f.data(),d=c.settingsSaveHelperSimpleFunction(a.nameTrigger,a),e=c.settingsSaveHelperSimpleFunction(a.replyTrigger,a),g=c.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){f.remote().saveSettings(d,{DisplayName:a})});b.replyTo.subscribe(function(a){f.remote().saveSettings(e,{ReplyTo:a})});b.signature.subscribe(function(a){f.remote().saveSettings(g,{Signature:a})})},50)};c.addSettingsViewModel(la,
"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts");la.prototype.addNewAccount=function(){s.showScreenPopup(da)};la.prototype.deleteAccount=function(a){if(a&&a.deleteAccess()){this.accountForDeletion(null);var b=function(b){return a===b};a&&(f.data().accounts.remove(b),f.remote().accountDelete(function(){f.accounts()},a.email))}};c.addSettingsViewModel(Ma,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social");c.addSettingsViewModel(ma,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME",
"change-password");ma.prototype.onHide=function(){this.changeProcess(!1);this.currentPassword("");this.newPassword("")};ma.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1);g.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)};c.addSettingsViewModel(S,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders");S.prototype.folderEditOnEnter=function(a){var b=a?c.trim(a.nameForEdit()):
"";""!==b&&a.name()!==b&&(f.local().set(g.ClientSideKeyName.FoldersLashHash,""),f.data().foldersRenaming(!0),f.remote().folderRename(function(a,b){f.data().foldersRenaming(!1);if(g.StorageResultType.Success!==a||!b||!b.Result)f.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"));f.folders(!1)},a.fullNameRaw,b),f.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b));a.edited(!1)};S.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)};
S.prototype.onShow=function(){f.data().foldersListError("")};S.prototype.createFolder=function(){s.showScreenPopup(ba)};S.prototype.systemFolder=function(){s.showScreenPopup(X)};S.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(d){if(a===d)return!0;d.subFolders.remove(b);return!1};a&&(f.local().set(g.ClientSideKeyName.FoldersLashHash,""),f.data().folderList.remove(b),f.data().foldersDeleting(!0),
f.remote().folderDelete(function(a,b){f.data().foldersDeleting(!1);if(g.StorageResultType.Success!==a||!b||!b.Result)f.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"));f.folders(!1)},a.fullNameRaw),f.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0<a.privateMessageCountAll()&&f.data().foldersListError(c.getNotification(g.Notification.CantDeleteNonEmptyFolder))};S.prototype.subscribeFolder=function(a){f.local().set(g.ClientSideKeyName.FoldersLashHash,
"");f.remote().folderSetSubscribe(c.emptyFunction,a.fullNameRaw,!0);a.subScribed(!0)};S.prototype.unSubscribeFolder=function(a){f.local().set(g.ClientSideKeyName.FoldersLashHash,"");f.remote().folderSetSubscribe(c.emptyFunction,a.fullNameRaw,!1);a.subScribed(!1)};c.addSettingsViewModel(za,"SettingsThemes","SETTINGS_LABELS/LABEL_THEMES_NAME","themes");za.prototype.removeCustomThemeImg=function(){this.customThemeImg("")};za.prototype.onBuild=function(){var a=this,b=f.data().theme();this.themesObjects(i.map(f.data().themes(),
function(a){return{name:a,nameDisplay:c.convertThemeName(a),selected:e.observable(a===b),themePreviewSrc:f.link().themePreviewLink(a)}}));i.delay(function(){a.customThemeType.subscribe(function(a){f.remote().saveSettings(function(){f.data().theme.valueHasMutated()},{CustomThemeType:a})});a.customThemeImg.subscribe(function(a){f.remote().saveSettings(function(){f.data().theme.valueHasMutated()},{CustomThemeImg:a})})},50);this.initCustomThemeUploader()};za.prototype.initCustomThemeUploader=function(){return this.customThemeUploaderButton()?
!!new ra({action:f.link().uploadBackground(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,clickElement:this.customThemeUploaderButton(),onSelect:i.bind(function(a,b){var d=c.isUnd(b.FileName)?"":b.FileName.toString(),d=d.substring(d.length-4,d.length),f=c.isNormal(b.Size)?c.pInt(b.Size):null;return-1===c.inArray(d,["jpeg",".jpg",".png"])?(h.alert(c.i18n("SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR")),!1):1048576<f?(h.alert(c.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),
!1):!0},this),onStart:i.bind(function(){this.customThemeUploaderProgress(!0)},this),onComplete:i.bind(function(a,b,d){!b||!d||!d.Result?h.alert(d&&d.ErrorCode?c.getUploadErrorDescByCode(d.ErrorCode):c.getUploadErrorDescByCode(g.UploadErrorCode.Unknown)):this.customThemeImg(d.Result);this.customThemeUploaderProgress(!1)},this)}):!1};Na.prototype.populateDataOnStart=function(){var a=f.settingsGet("Languages"),b=f.settingsGet("Themes");c.isArray(a)&&this.languages(a);c.isArray(b)&&this.themes(b);this.mainLanguage(f.settingsGet("Language"));
this.mainTheme(f.settingsGet("Theme"));this.allowCustomTheme(!!f.settingsGet("AllowCustomTheme"));this.allowAdditionalAccounts(!!f.settingsGet("AllowAdditionalAccounts"));this.ignoreFolderSubscribe(!!f.settingsGet("IgnoreFolderSubscribe"));this.editorDefaultType(f.settingsGet("EditorDefaultType"));this.showImages(!!f.settingsGet("ShowImages"));this.showAnimation(!!f.settingsGet("ShowAnimation"));this.mainMessagesPerPage(f.settingsGet("MPP"));this.desktopNotifications(!!f.settingsGet("DesktopNotifications"));
this.useThreads(!!f.settingsGet("UseThreads"));this.replySameFolder(!!f.settingsGet("ReplySameFolder"));this.usePreviewPane(!!f.settingsGet("UsePreviewPane"));this.useCheckboxesInList(!!f.settingsGet("UseCheckboxesInList"));this.facebookEnable(!!f.settingsGet("AllowFacebookSocial"));this.facebookAppID(f.settingsGet("FacebookAppID"));this.facebookAppSecret(f.settingsGet("FacebookAppSecret"));this.twitterEnable(!!f.settingsGet("AllowTwitterSocial"));this.twitterConsumerKey(f.settingsGet("TwitterConsumerKey"));
this.twitterConsumerSecret(f.settingsGet("TwitterConsumerSecret"));this.googleEnable(!!f.settingsGet("AllowGoogleSocial"));this.googleClientID(f.settingsGet("GoogleClientID"));this.googleClientSecret(f.settingsGet("GoogleClientSecret"));this.dropboxEnable(!!f.settingsGet("AllowDropboxSocial"));this.dropboxApiKey(f.settingsGet("DropboxApiKey"));this.contactsIsSupported(!!f.settingsGet("ContactsIsSupported"))};i.extend(T.prototype,Na.prototype);T.prototype.populateDataOnStart=function(){Na.prototype.populateDataOnStart.call(this);
this.accountEmail(f.settingsGet("Email"));this.accountLogin(f.settingsGet("Login"));this.projectHash(f.settingsGet("ProjectHash"));this.displayName(f.settingsGet("DisplayName"));this.replyTo(f.settingsGet("ReplyTo"));this.signature(f.settingsGet("Signature"));this.lastFoldersHash=f.local().get(g.ClientSideKeyName.FoldersLashHash);this.remoteSuggestions=!!f.settingsGet("RemoteSuggestions");this.remoteChangePassword=!!f.settingsGet("RemoteChangePassword");this.threading=!!f.settingsGet("UseImapThread");
this.devEmail=f.settingsGet("DevEmail");this.devLogin=f.settingsGet("DevLogin");this.devPassword=f.settingsGet("DevPassword")};T.prototype.initUidNextAndNewMessages=function(a,b,d){if("INBOX"===a&&c.isNormal(b)&&""!==b){if(c.isArray(d)&&0<d.length){var e=f.cache(),g=0,q=d.length,j=function(a,b,d){var c=null;if(ia&&f.data().useDesktopNotifications()&&(c=new ia(b,{body:d,icon:a})))c.show&&c.show(),h.setTimeout(function(a){return function(){a.cancel?a.cancel():a.close&&a.close()}}(c),7E3)};i.each(d,
function(b){e.addNewMessageCache(a,b.Uid)});if(3<q)j(f.link().notificationMailIcon(),f.data().accountEmail(),c.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:q}));else for(;g<q;g++)j(f.link().notificationMailIcon(),m.emailsToLine(m.initEmailsFromJson(d[g].From),!1),d[g].Subject)}f.cache().setFolderUidNext(a,b)}};T.prototype.folderResponseParseRec=function(a,b,d){for(var e=0,g=0,i=null,h=null,j="",i=[],m=[],d=!!d,e=0,g=b.length;e<g;e++)if(i=b[e]){j=i.FullNameRaw;h=f.cache().getFolderFromCacheList(j);
if(!h&&(h=G.newInstanceFromJson(i)))if(f.cache().setFolderToCacheList(j,h),f.cache().setFolderFullNameRaw(h.fullNameHash,j),h.isGmailFolder=t.Values.GmailFolderName.toLowerCase()===j.toLowerCase(),""!==a&&a===h.fullNameRaw+h.delimiter&&(h.isNamespaceFolder=!0),h.isNamespaceFolder||h.isGmailFolder)h.isUnpaddigFolder=!0;h&&(h.collapsed(!c.isFolderExpanded(h.fullNameHash)),!d&&i.Extended&&(i.Extended.Hash&&f.cache().setFolderHash(h.fullNameRaw,i.Extended.Hash),c.isNormal(i.Extended.MessageCount)&&h.messageCountAll(i.Extended.MessageCount),
c.isNormal(i.Extended.MessageUnseenCount)&&h.messageCountUnread(i.Extended.MessageUnseenCount)),(i=i.SubFolders)&&("Collection/FolderCollection"===i["@Object"]&&i["@Collection"]&&c.isArray(i["@Collection"]))&&h.subFolders(this.folderResponseParseRec(a,i["@Collection"],d)),m.push(h))}return m};T.prototype.setFolders=function(a,b){var d=[],e=f.data(),i=0===e.folderList().length,h=function(a){return""===a||t.Values.UnuseOptionValue===a||null!==f.cache().getFolderFromCacheList(a)?a:""};a&&(a.Result&&
"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&c.isArray(a.Result["@Collection"]))&&(c.isUnd(a.Result.Namespace)||(e.namespace=a.Result.Namespace),d=this.folderResponseParseRec(e.namespace,a.Result["@Collection"],!!b),e.folderList(d),e.sentFolder(h(f.settingsGet("SentFolder"))),e.draftFolder(h(f.settingsGet("DraftFolder"))),e.spamFolder(h(f.settingsGet("SpamFolder"))),e.trashFolder(h(f.settingsGet("TrashFolder"))),b||f.local().set(g.ClientSideKeyName.FoldersLashHash,
a.Result.FoldersHash),i&&b&&f.folders(!1))};T.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()};T.prototype.setMessage=function(a,b){var d=!1,e=!1,g=!1,i=null,e=null,d="",h=this.messagesBodiesDom(),k=this.message();if(a&&k&&a.Result&&"Object/Message"===a.Result["@Object"]&&k.folderFullNameRaw===a.Result.Folder&&k.uid===a.Result.Uid){this.messageError("");k.initUpdateByMessageJson(a.Result);f.cache().addRequestedMessage(k.folderFullNameRaw,k.uid);
b||k.initFlagsByJson(a.Result);if(h=h&&h[0]?h:null)d="rl-"+k.requestHash.replace(/[^a-zA-Z0-9]/g,""),e=h.find("#"+d),!e||!e[0]?(e=!!a.Result.HasExternals,g=!!a.Result.HasInternals,i=j('<div id="'+d+'" />').hide(),c.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,i.html(a.Result.Html.toString()).addClass("b-text-part html")):c.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,i.html(a.Result.Plain.toString()).addClass("b-text-part plain")):d=!1,h.append(i),i.data("rl-is-html",d),i.data("rl-has-images",
e),k.isHtml(i.data("rl-is-html")),k.hasImages(i.data("rl-has-images")),k.body=i,g&&k.showInternalImages(!0),k.hasImages()&&this.showImages()&&k.showExternalImages(!0)):(k.isHtml(e.data("rl-is-html")),k.hasImages(e.data("rl-has-images")),k.body=e),this.messageActiveDom(k.body),this.hideMessageBodies(),k.body.show(),i&&c.initBlockquoteSwitcher(i);f.cache().initMessageFlagsFromCache(k);k.unseen()&&f.setMessageSeen(k);c.windowResize()}};T.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===
a.Result["@Object"]&&a.Result["@Collection"]&&c.isArray(a.Result["@Collection"])){var d=f.data(),e=f.cache(),i=null,h=0,j=0,k=0,s=0,o=[],r=d.staticMessageList,t=null,p=null,n=null,u=0,v=!1,k=c.pInt(a.Result.MessageResultCount),s=c.pInt(a.Result.Offset);c.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(i=a.Result.LastCollapsedThreadUids);if((n=f.cache().getFolderFromCacheList(c.isNormal(a.Result.Folder)?a.Result.Folder:""))&&!b)f.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),c.isNormal(a.Result.MessageCount)&&
n.messageCountAll(a.Result.MessageCount),c.isNormal(a.Result.MessageUnseenCount)&&(c.pInt(n.messageCountUnread())!==c.pInt(a.Result.MessageUnseenCount)&&(v=!0),n.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(n.fullNameRaw,a.Result.UidNext,a.Result.NewMessages);v&&n&&f.cache().clearMessageFlagsFromCacheByFolder(n.fullNameRaw);h=0;for(j=a.Result["@Collection"].length;h<j;h++)if((t=a.Result["@Collection"][h])&&"Object/Message"===t["@Object"]){p=r[h];if(!p||!p.initByJson(t))p=
m.newInstanceFromJson(t);p&&(e.hasNewMessageAndRemoveFromCache(p.folderFullNameRaw,p.uid)&&5>=u&&(u++,p.newForAnimation(!0)),p.deleted(!1),b?f.cache().initMessageFlagsFromCache(p):f.cache().storeMessageFlagsToCache(p),p.lastInCollapsedThread(i&&-1<c.inArray(c.pInt(p.uid),i)?!0:!1),o.push(p))}d.messageListCount(k);d.messageListSearch(c.isNormal(a.Result.Search)?a.Result.Search:"");d.messageListEndSearch(c.isNormal(a.Result.Search)?a.Result.Search:"");d.messageListEndFolder(c.isNormal(a.Result.Folder)?
a.Result.Folder:"");d.messageListPage(Math.ceil(s/d.messagesPerPage()+1));d.messageList(o);d.messageListIsNotCompleted(!1);(p=d.message())&&d.messageList.setSelectedByUid&&d.messageList.setSelectedByUid(p.generateUid());r.length<o.length&&(d.staticMessageList=o);e.clearNewMessageCache();n&&(b||v||f.data().useThreads())&&f.folderInformation(n.fullNameRaw,o)}else f.data().messageListCount(0),f.data().messageList([]),f.data().messageListError(c.getNotification(a&&a.ErrorCode?a.ErrorCode:g.Notification.CantGetMessageList))};
aa.prototype.oRequests={};aa.prototype.defaultResponse=function(a,b,d,c,e,i){switch(d){case "success":d=g.StorageResultType.Success;break;case "abort":d=g.StorageResultType.Abort;break;default:d=g.StorageResultType.Error}g.StorageResultType.Success===d&&(c&&!c.Result&&c.Logout)&&(h.__rlah_clear&&h.__rlah_clear(),f.loginAndLogoutReload(!0));a&&(x.runHook("ajax-default-response",[b,g.StorageResultType.Success===d?c:null,d,e,i]),a(d,g.StorageResultType.Success===d?c:null,e,b,i))};aa.prototype.ajaxRequest=
function(a,b,d,e,g){var q=this,w=""===e,k=(new h.Date).getTime(),m=null,o="",b=b||{},d=c.isNormal(d)?d:2E4,e=c.isUnd(e)?"":c.pString(e),g=c.isArray(g)?g:[];(o=b.Action||"")&&0<g.length&&i.each(g,function(a){q.oRequests[a]&&(q.oRequests[a].__aborted=!0,q.oRequests[a].abort&&q.oRequests[a].abort(),q.oRequests[a]=null)});w&&(b.XToken=f.settingsGet("Token"));m=j.ajax({type:w?"POST":"GET",url:f.link().ajax(e),async:!0,dataType:"json",data:w?b:{},headers:{},timeout:d,global:!0});m.always(function(d,f){var e=
!1;d&&d.Time&&(e=c.pInt(d.Time)>(new h.Date).getTime()-k);o&&q.oRequests[o]&&(q.oRequests[o].__aborted&&(f="abort"),q.oRequests[o]=null);q.defaultResponse(a,o,f,d,e,b)});o&&(0<g.length&&-1<c.inArray(o,g))&&(this.oRequests[o]&&(this.oRequests[o].__aborted=!0,this.oRequests[o].abort&&this.oRequests[o].abort(),this.oRequests[o]=null),this.oRequests[o]=m);return m};aa.prototype.defaultRequest=function(a,b,d,f,e,g){d=d||{};d.Action=b;e=c.pString(e);x.runHook("ajax-default-request",[b,d,e]);this.ajaxRequest(a,
d,c.isUnd(f)?t.Defaults.DefaultAjaxTimeout:c.pInt(f),e,g)};aa.prototype.noop=function(a){this.defaultRequest(a,"Noop")};aa.prototype.jsError=function(a,b,d,c){this.defaultRequest(a,"JsError",{Message:b,FileName:d,LineNo:c})};i.extend(p.prototype,aa.prototype);p.prototype.folders=function(a,b){var d=f.data().lastFoldersHash;(b=c.isUnd(b)?!1:!!b)&&""!==d?this.defaultRequest(a,"Folders",{},null,"Folders/"+f.data().projectHash()+"-"+d,["Folders"]):this.defaultRequest(a,"Folders",{},null,"",["Folders"])};
p.prototype.login=function(a,b,d,c,f){this.defaultRequest(a,"Login",{Email:b,Login:d,Password:c,SignMe:f?"1":"0"})};p.prototype.accountAdd=function(a,b,d,c){this.defaultRequest(a,"AccountAdd",{Email:b,Login:d,Password:c})};p.prototype.accountDelete=function(a,b){this.defaultRequest(a,"AccountDelete",{EmailToDelete:b})};p.prototype.accounts=function(a){this.defaultRequest(a,"Accounts")};p.prototype.messageList=function(a,b,d,e,g,i){var b=c.pString(b),h=f.data(),j=f.cache().getFolderHash(b),i=c.isUnd(i)?
!1:!!i,d=c.isUnd(d)?0:c.pInt(d),e=c.isUnd(d)?20:c.pInt(e),g=c.pString(g);""!==j?this.defaultRequest(a,"MessageList",{},""===g?t.Defaults.DefaultAjaxTimeout:t.Defaults.SearchAjaxTimeout,"MessageList/"+ga.urlsafe_encode([b,d,e,g,h.projectHash(),j,"INBOX"===b?f.cache().getFolderUidNext(b):"",h.threading&&h.useThreads()?"1":"0",h.threading&&b===h.messageListThreadFolder()?h.messageListThreadUids().join(","):""].join(String.fromCharCode(0))),i?[]:["MessageList"]):this.defaultRequest(a,"MessageList",{Folder:b,
Offset:d,Limit:e,Search:g,UidNext:"INBOX"===b?f.cache().getFolderUidNext(b):"",UseThreads:f.data().threading&&f.data().useThreads()?"1":"0",ExpandedThreadUid:h.threading&&b===h.messageListThreadFolder()?h.messageListThreadUids().join(","):""},""===g?t.Defaults.DefaultAjaxTimeout:t.Defaults.SearchAjaxTimeout,"",i?[]:["MessageList"])};p.prototype.messageUploadAttachments=function(a,b){this.defaultRequest(a,"MessageUploadAttachments",{Attachments:b},999E3)};p.prototype.message=function(a,b,d){b=c.pString(b);
d=c.pInt(d);return f.cache().getFolderFromCacheList(b)&&0<d?(this.defaultRequest(a,"Message",{},null,"Message/"+ga.urlsafe_encode([b,d,f.data().projectHash(),f.data().threading&&f.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1};p.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999E3)};p.prototype.folderInformation=function(a,b,d){var e=!0,g=f.cache(),h=[];c.isArray(d)&&0<d.length&&(e=!1,i.each(d,function(a){g.getMessageFlagsFromCache(a.folderFullNameRaw,
a.uid)||h.push(a.uid);0<a.threads().length&&i.each(a.threads(),function(b){g.getMessageFlagsFromCache(a.folderFullNameRaw,b)||h.push(b)})}),0<h.length&&(e=!0));e?this.defaultRequest(a,"FolderInformation",{Folder:b,FlagsUids:c.isArray(h)?h.join(","):"",UidNext:"INBOX"===b?f.cache().getFolderUidNext(b):""}):f.data().useThreads()&&f.reloadFlagsCurrentMessageListAndMessageFromCache()};p.prototype.logout=function(a){this.defaultRequest(a,"Logout")};p.prototype.messageSetFlagged=function(a,b,d,c){this.defaultRequest(a,
"MessageSetFlagged",{Folder:b,Uids:d.join(","),SetAction:c?"1":"0"})};p.prototype.messageSetSeen=function(a,b,d,c){this.defaultRequest(a,"MessageSetSeen",{Folder:b,Uids:d.join(","),SetAction:c?"1":"0"})};p.prototype.messageSetSeenToAll=function(a,b,d){this.defaultRequest(a,"MessageSetSeenToAll",{Folder:b,SetAction:d?"1":"0"})};p.prototype.saveMessage=function(a,b,d,c,f,e,g,i,h,j,m,p,n,s){this.defaultRequest(a,"SaveMessage",{MessageFolder:b,MessageUid:d,DraftFolder:c,To:f,Cc:e,Bcc:g,Subject:i,TextIsHtml:h?
"1":"0",Text:j,DraftInfo:p,InReplyTo:n,References:s,Attachments:m},t.Defaults.SaveMessageAjaxTimeout)};p.prototype.sendMessage=function(a,b,d,c,f,e,g,i,h,j,m,p,n,s){this.defaultRequest(a,"SendMessage",{MessageFolder:b,MessageUid:d,SentFolder:c,To:f,Cc:e,Bcc:g,Subject:i,TextIsHtml:h?"1":"0",Text:j,DraftInfo:p,InReplyTo:n,References:s,Attachments:m},t.Defaults.SendMessageAjaxTimeout)};p.prototype.saveSystemFolders=function(a,b){this.defaultRequest(a,"SystemFoldersUpdate",b)};p.prototype.saveSettings=
function(a,b){this.defaultRequest(a,"SettingsUpdate",b)};p.prototype.changePassword=function(a,b,c){this.defaultRequest(a,"ChangePassword",{PrevPassword:b,NewPassword:c})};p.prototype.folderCreate=function(a,b,c){this.defaultRequest(a,"FolderCreate",{Folder:b,Parent:c},null,"",["Folders"])};p.prototype.folderDelete=function(a,b){this.defaultRequest(a,"FolderDelete",{Folder:b},null,"",["Folders"])};p.prototype.folderRename=function(a,b,c){this.defaultRequest(a,"FolderRename",{Folder:b,NewFolderName:c},
null,"",["Folders"])};p.prototype.folderClear=function(a,b){this.defaultRequest(a,"FolderClear",{Folder:b})};p.prototype.folderSetSubscribe=function(a,b,c){this.defaultRequest(a,"FolderSubscribe",{Folder:b,Subscribe:c?"1":"0"})};p.prototype.messagesMove=function(a,b,c,f){this.defaultRequest(a,"MessageMove",{FromFolder:b,ToFolder:c,Uids:f.join(",")},null,"",["MessageList","Message"])};p.prototype.messagesDelete=function(a,b,c){this.defaultRequest(a,"MessageDelete",{Folder:b,Uids:c.join(",")},null,
"",["MessageList","Message"])};p.prototype.appDelayStart=function(a){this.defaultRequest(a,"AppDelayStart")};p.prototype.quota=function(a){this.defaultRequest(a,"Quota")};p.prototype.contacts=function(a,b){this.defaultRequest(a,"Contacts",{Search:b},null,"",["Contacts"])};p.prototype.contactSave=function(a,b,d,f,e,g){d=c.trim(d);this.defaultRequest(a,"ContactSave",{RequestUid:b,Uid:d,Name:f,Email:e,ImageData:g})};p.prototype.contactsDelete=function(a,b){this.defaultRequest(a,"ContactsDelete",{Uids:b.join(",")})};
p.prototype.suggestions=function(a,b,c){this.defaultRequest(a,"Suggestions",{Query:b,Page:c},null,"",["Suggestions"])};p.prototype.servicesPics=function(a){this.defaultRequest(a,"ServicesPics")};p.prototype.emailsPicsHashes=function(a){this.defaultRequest(a,"EmailsPicsHashes")};p.prototype.facebookUser=function(a){this.defaultRequest(a,"SocialFacebookUserInformation")};p.prototype.facebookDisconnect=function(a){this.defaultRequest(a,"SocialFacebookDisconnect")};p.prototype.twitterUser=function(a){this.defaultRequest(a,
"SocialTwitterUserInformation")};p.prototype.twitterDisconnect=function(a){this.defaultRequest(a,"SocialTwitterDisconnect")};p.prototype.googleUser=function(a){this.defaultRequest(a,"SocialGoogleUserInformation")};p.prototype.googleDisconnect=function(a){this.defaultRequest(a,"SocialGoogleDisconnect")};p.prototype.socialUsers=function(a){this.defaultRequest(a,"SocialUsers")};U.prototype.oEmailsPicsHashes={};U.prototype.oServices={};U.prototype.clear=function(){this.oServices={};this.oEmailsPicsHashes=
{}};U.prototype.getUserPic=function(a){var b="",b="",b=a.toLowerCase(),d=c.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];""===d?(b=b.substr(a.indexOf("@")+1),b=""!==b&&this.oServices[b]?this.oServices[b]:""):b=f.link().getUserPicUrlFromHash(d);return b};U.prototype.setServicesData=function(a){this.oServices=a};U.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a};i.extend(v.prototype,U.prototype);v.prototype.oFoldersCache={};v.prototype.oFoldersNamesCache={};v.prototype.oFolderHashCache=
{};v.prototype.oFolderUidNextCache={};v.prototype.oMessageListHashCache={};v.prototype.oMessageFlagsCache={};v.prototype.oBodies={};v.prototype.oNewMessage={};v.prototype.oRequestedMessage={};v.prototype.clear=function(){U.prototype.clear.call(this);this.oFoldersCache={};this.oFoldersNamesCache={};this.oFolderHashCache={};this.oFolderUidNextCache={};this.oMessageListHashCache={};this.oMessageFlagsCache={};this.oBodies={}};v.prototype.getMessageKey=function(a,b){return a+"#"+b};v.prototype.addRequestedMessage=
function(a,b){this.oRequestedMessage[this.getMessageKey(a,b)]=!0};v.prototype.hasRequestedMessage=function(a,b){return!0===this.oRequestedMessage[this.getMessageKey(a,b)]};v.prototype.addNewMessageCache=function(a,b){this.oNewMessage[this.getMessageKey(a,b)]=!0};v.prototype.hasNewMessageAndRemoveFromCache=function(a,b){return this.oNewMessage[this.getMessageKey(a,b)]?(this.oNewMessage[this.getMessageKey(a,b)]=null,!0):!1};v.prototype.clearNewMessageCache=function(){this.oNewMessage={}};v.prototype.getFolderFullNameRaw=
function(a){return""!==a&&this.oFoldersNamesCache[a]?this.oFoldersNamesCache[a]:""};v.prototype.setFolderFullNameRaw=function(a,b){this.oFoldersNamesCache[a]=b};v.prototype.getFolderHash=function(a){return""!==a&&this.oFolderHashCache[a]?this.oFolderHashCache[a]:""};v.prototype.setFolderHash=function(a,b){this.oFolderHashCache[a]=b};v.prototype.getFolderUidNext=function(a){return""!==a&&this.oFolderUidNextCache[a]?this.oFolderUidNextCache[a]:""};v.prototype.setFolderUidNext=function(a,b){this.oFolderUidNextCache[a]=
b};v.prototype.getFolderFromCacheList=function(a){return""!==a&&this.oFoldersCache[a]?this.oFoldersCache[a]:null};v.prototype.setFolderToCacheList=function(a,b){this.oFoldersCache[a]=b};v.prototype.removeFolderFromCacheList=function(a){this.setFolderToCacheList(a,null)};v.prototype.getMessageFlagsFromCache=function(a,b){return this.oMessageFlagsCache[a]&&this.oMessageFlagsCache[a][b]?this.oMessageFlagsCache[a][b]:null};v.prototype.setMessageFlagsToCache=function(a,b,c){this.oMessageFlagsCache[a]||
(this.oMessageFlagsCache[a]={});this.oMessageFlagsCache[a][b]=c};v.prototype.clearMessageFlagsFromCacheByFolder=function(a){this.oMessageFlagsCache[a]={}};v.prototype.initMessageFlagsFromCache=function(a){if(a){var b=this,d=this.getMessageFlagsFromCache(a.folderFullNameRaw,a.uid),f=null,e=null;d&&4===d.length&&(a.unseen(d[0]),a.flagged(d[1]),a.answered(d[2]),a.forwarded(d[3]));0<a.threads().length&&(f=i.find(a.threads(),function(c){return(c=b.getMessageFlagsFromCache(a.folderFullNameRaw,c))&&4===
c.length&&!!c[0]}),e=i.find(a.threads(),function(c){return(c=b.getMessageFlagsFromCache(a.folderFullNameRaw,c))&&4===c.length&&!!c[1]}),a.hasUnseenSubMessage(f&&0<c.pInt(f)),a.hasFlaggedSubMessage(e&&0<c.pInt(e)))}};v.prototype.storeMessageFlagsToCache=function(a){a&&this.setMessageFlagsToCache(a.folderFullNameRaw,a.uid,[a.unseen(),a.flagged(),a.answered(),a.forwarded()])};v.prototype.storeMessageFlagsToCacheByFolderAndUid=function(a,b,d){c.isArray(d)&&4===d.length&&this.setMessageFlagsToCache(a,
b,d)};i.extend(fa.prototype,J.prototype);fa.prototype.onRoute=function(a){var b=this,d=null,g=null,h=null,q=null;if(g=i.find(Da,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}))i.find(Qa,function(a){return a&&a===g})&&(g=null),g&&i.find(Ra,function(a){return a&&a===g})&&(g=null);g&&(g.__builded&&g.__vm?d=g.__vm:(h=j("#rl-content #rl-settings-subscreen"))&&1===h.length?(d=new g,q=j("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+
g.__rlSettingsData.Template+'"}, i18nInit: true'),q.appendTo(h),d.data=f.data(),d.viewModelDom=q,d.__rlSettingsData=g.__rlSettingsData,g.__dom=q,g.__builded=!0,g.__vm=d,e.applyBindings(d,q[0]),s.delegateRun(d,"onBuild",[q])):c.log("Cannot find sub settings view model position: SettingsSubScreen"),d&&i.defer(function(){if(b.oCurrentSubScreen){s.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide()}b.oCurrentSubScreen=d;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();
s.delegateRun(b.oCurrentSubScreen,"onShow");i.each(b.menu(),function(a){a.selected(d&&d.__rlSettingsData&&a.route===d.__rlSettingsData.Route)})}c.windowResize()}))};fa.prototype.onBuild=function(){i.each(Da,function(a){a&&(a.__rlSettingsData&&!i.find(Qa,function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:e.observable(!1),disabled:!!i.find(Ra,function(b){return b&&b===a})})},this)};fa.prototype.routes=function(){var a=i.find(Da,function(a){return a&&
a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",a={subname:/^(.*)$/,normalize_:function(a,f){f.subname=c.isUnd(f.subname)?b:c.pString(f.subname);return[f.subname]}};return[["{subname}/",a],["{subname}",a],["",a]]};i.extend(Aa.prototype,J.prototype);Aa.prototype.onShow=function(){f.setTitle(c.i18n("TITLES/LOGIN"))};i.extend(V.prototype,J.prototype);V.prototype.oLastRoute={};V.prototype.onShow=function(){var a=f.data().accountEmail();f.setTitle((""===a?"":a+
" - ")+c.i18n("TITLES/MAILBOX"));this.mailBoxScreenVisibily(!0)};V.prototype.onHide=function(){this.mailBoxScreenVisibily(!1)};V.prototype.onRoute=function(a,b,c){var e=f.data(),a=f.cache().getFolderFullNameRaw(a);if(a=f.cache().getFolderFromCacheList(a))e.currentFolder(a).messageListPage(b).messageListSearch(c),!e.usePreviewPane()&&e.message()&&e.message(null),f.reloadMessageList()};V.prototype.onStart=function(){var a=f.data(),b=function(){c.windowResize()};f.settingsGet("AllowAdditionalAccounts")&&
f.accounts();i.delay(function(){f.quota()},5E3);i.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&f.folderInformation("INBOX")},1E3);i.delay(function(){f.remote().appDelayStart(c.emptyFunction)},35E3);h.setInterval(function(){f.folderInformation("INBOX")},12E4);h.setInterval(function(){f.quota()},3E5);Z.toggleClass("rl-no-preview-pane",!a.usePreviewPane());a.folderList.subscribe(b);a.messageList.subscribe(b);a.message.subscribe(b);a.usePreviewPane.subscribe(function(b){Z.toggleClass("rl-no-preview-pane",
!b);a.messageList.valueHasMutated()})};V.prototype.onBuild=function(){i.defer(i.bind(function(){c.initLayoutResizer("#rl-resizer-left","#rl-resizer-right","#rl-right",this.resizeTrigger)},this))};V.prototype.routes=function(){var a=function(a,d){d[0]=c.pString(d[0]);d[1]=c.pInt(d[1]);d[1]=0>=d[1]?1:d[1];d[2]=c.pString(d[2]);""===a&&(d[0]="Inbox",d[1]=1);return[decodeURI(d[0]),d[1],decodeURI(d[2])]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/?$/,
{normalize_:a}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:function(a,d){d[0]=c.pString(d[0]);d[1]=c.pString(d[1]);""===a&&(d[0]="Inbox");return[decodeURI(d[0]),1,decodeURI(d[1])]}}],[/^([^\/]*)$/,{normalize_:a}]]};i.extend(Oa.prototype,fa.prototype);Oa.prototype.onShow=function(){f.setTitle(this.sSettingsTitle)};i.extend(I.prototype,Ua.prototype);I.prototype.oSettings=null;I.prototype.oLink=null;I.prototype.download=function(a){na?this.iframe.attr("src",a):h.open(a)};I.prototype.link=function(){null===
this.oLink&&(this.oLink=new B);return this.oLink};I.prototype.local=function(){null===this.oLocal&&(this.oLocal=new ua);return this.oLocal};I.prototype.settingsGet=function(a){null===this.oSettings&&(this.oSettings=c.isNormal(Ba)?Ba:{});return c.isUnd(this.oSettings[a])?null:this.oSettings[a]};I.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=c.isNormal(Ba)?Ba:{});this.oSettings[a]=b};I.prototype.setTitle=function(a){a=(0<a.length?a+" - ":"")+this.settingsGet("Title")||
"";a!==h.document.title&&(h.document.title=a)};I.prototype.loginAndLogoutReload=function(a,b){var d=c.pString(this.settingsGet("CustomLogoutLink")),e=!!this.settingsGet("InIframe"),a=c.isUnd(a)?!1:!!a,b=c.isUnd(b)?!1:!!b;a&&(b&&h.close)&&h.close();a&&""!==d&&h.location.href!==d?i.defer(function(){e&&h.parent?h.parent.location.href=d:h.location.href=d}):(s.routeOff(),s.setHash(f.link().root(),!0),s.routeOff(),i.defer(function(){e&&h.parent?h.parent.location.reload():h.location.reload()}))};I.prototype.getAutocomplete=
function(a,b,c){c([],a)};I.prototype.bootstart=function(){c.initOnStartOrLangChange(function(){c.initNotificationLanguage()},null);i.delay(function(){c.windowResize()},1E3);h.Pace&&h.Pace.stop&&h.Pace.stop()};i.extend(A.prototype,I.prototype);A.prototype.oData=null;A.prototype.oRemote=null;A.prototype.oCache=null;A.prototype.data=function(){null===this.oData&&(this.oData=new T);return this.oData};A.prototype.remote=function(){null===this.oRemote&&(this.oRemote=new p);return this.oRemote};A.prototype.cache=
function(){null===this.oCache&&(this.oCache=new v);return this.oCache};A.prototype.reloadFlagsCurrentMessageListAndMessageFromCache=function(){var a=f.cache();i.each(f.data().messageList(),function(b){a.initMessageFlagsFromCache(b)});a.initMessageFlagsFromCache(f.data().message())};A.prototype.reloadMessageList=function(a,b){var d=f.data(),e=(d.messageListPage()-1)*d.messagesPerPage();(c.isUnd(b)?0:b)&&f.cache().setFolderHash(d.currentFolderFullNameRaw(),"");if(c.isUnd(a)?0:a)d.messageListPage(1),
e=0;d.messageListLoading(!0);f.remote().messageList(function(a,b,f){g.StorageResultType.Success===a&&b&&b.Result?(d.messageListError(""),d.messageListLoading(!1),d.setMessageList(b,f)):g.StorageResultType.Abort!==a&&(d.messageList([]),d.messageListLoading(!1),d.messageListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST")))},d.currentFolderFullNameRaw(),e,d.messagesPerPage(),d.messageListSearch())};A.prototype.recacheInboxMessageList=function(){f.remote().messageList(c.emptyFunction,
"INBOX",0,f.data().messagesPerPage(),"",!0)};A.prototype.folders=function(a,b){this.data().foldersLoading(!0);this.remote().folders(i.bind(function(a,c,e){f.data().foldersLoading(!1);g.StorageResultType.Success===a?(this.data().setFolders(c,e),b&&b(!0)):b&&b(!1)},this),a)};A.prototype.accounts=function(){f.data().accountsLoading(!0);f.remote().accounts(function(a,b){f.data().accountsLoading(!1);if(g.StorageResultType.Success===a&&c.isArray(b.Result)){var d=f.settingsGet("ParentEmail"),d=""===d?f.data().accountEmail():
d;f.data().accounts(i.map(b.Result,function(a){return new Ka(a,a!==d)}))}})};A.prototype.quota=function(){this.remote().quota(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result&&c.isArray(b.Result)&&2===b.Result.length&&c.isPosNumeric(b.Result[0],!0)&&c.isPosNumeric(b.Result[1],!0))&&(f.data().userQuota(1024*c.pInt(b.Result[1])),f.data().userUsageSize(1024*c.pInt(b.Result[0])))})};A.prototype.folderInformation=function(a,b){this.remote().folderInformation(function(a,b){if(g.StorageResultType.Success===
a&&b&&b.Result&&b.Result.Hash&&b.Result.Folder){var e=f.cache().getFolderHash(b.Result.Folder),h=f.cache().getFolderFromCacheList(b.Result.Folder),i=!1,j="",m=[],m=!1,o=null;if(h){b.Result.Hash&&f.cache().setFolderHash(b.Result.Folder,b.Result.Hash);c.isNormal(b.Result.MessageCount)&&h.messageCountAll(b.Result.MessageCount);c.isNormal(b.Result.MessageUnseenCount)&&(c.pInt(h.messageCountUnread())!==c.pInt(b.Result.MessageUnseenCount)&&(m=!0),h.messageCountUnread(b.Result.MessageUnseenCount));m&&f.cache().clearMessageFlagsFromCacheByFolder(h.fullNameRaw);
if(b.Result.Flags){for(j in b.Result.Flags)b.Result.Flags.hasOwnProperty(j)&&(i=!0,o=b.Result.Flags[j],f.cache().storeMessageFlagsToCacheByFolderAndUid(h.fullNameRaw,j.toString(),[!o.IsSeen,!!o.IsFlagged,!!o.IsAnswered,!!o.IsForwarded]));i&&f.reloadFlagsCurrentMessageListAndMessageFromCache()}f.data().initUidNextAndNewMessages(h.fullNameRaw,b.Result.UidNext,b.Result.NewMessages);b.Result.Hash!==e||""===e?h.fullNameRaw===f.data().currentFolderFullNameRaw()?f.reloadMessageList():"INBOX"===h.fullNameRaw&&
f.recacheInboxMessageList():m&&h.fullNameRaw===f.data().currentFolderFullNameRaw()&&(m=f.data().messageList(),c.isNonEmptyArray(m)&&f.folderInformation(h.fullNameRaw,m))}}},a,b)};A.prototype.setMessageSeen=function(a){if(a.unseen()){a.unseen(!1);var b=f.cache().getFolderFromCacheList(a.folderFullNameRaw);b&&b.messageCountUnread(0<=b.messageCountUnread()-1?b.messageCountUnread()-1:0);f.cache().storeMessageFlagsToCache(a);f.reloadFlagsCurrentMessageListAndMessageFromCache()}f.remote().messageSetSeen(c.emptyFunction,
a.folderFullNameRaw,[a.uid],!0)};A.prototype.googleConnect=function(){h.open(f.link().socialGoogle(),"Google","left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes")};A.prototype.twitterConnect=function(){h.open(f.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes")};A.prototype.facebookConnect=function(){h.open(f.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes")};
A.prototype.socialUsers=function(a){var b=f.data();a&&(b.googleActions(!0),b.facebookActions(!0),b.twitterActions(!0));f.remote().socialUsers(function(a,c){if(g.StorageResultType.Success===a&&c&&c.Result){b.googleUserName(c.Result.Google||"");b.facebookUserName(c.Result.Facebook||"");b.twitterUserName(c.Result.Twitter||"")}else{b.googleUserName("");b.facebookUserName("");b.twitterUserName("")}b.googleLoggined(""!==b.googleUserName());b.facebookLoggined(""!==b.facebookUserName());b.twitterLoggined(""!==
b.twitterUserName());b.googleActions(false);b.facebookActions(false);b.twitterActions(false)})};A.prototype.googleDisconnect=function(){f.data().googleActions(!0);f.remote().googleDisconnect(function(){f.socialUsers()})};A.prototype.facebookDisconnect=function(){f.data().facebookActions(!0);f.remote().facebookDisconnect(function(){f.socialUsers()})};A.prototype.twitterDisconnect=function(){f.data().twitterActions(!0);f.remote().twitterDisconnect(function(){f.socialUsers()})};A.prototype.folderListOptionsBuilder=
function(a,b,d,e,i,j,m,k,p){var o=0,r=0,n=null,s=[],p=!c.isNormal(p)?0<a.length:p,i=!c.isNormal(i)?0:i;c.isArray(d)||(d=[]);c.isArray(e)||(e=[]);o=0;for(r=e.length;o<r;o++)s.push({id:e[o][0],name:e[o][1],disable:!1});o=0;for(r=a.length;o<r;o++)if(n=a[o],c.isNormal(m)?m.call(null,n):1)s.push({id:n.fullNameRaw,system:!0,name:c.isNormal(k)?k.call(null,n):n.name(),disable:!n.selectable||-1<c.inArray(n.fullNameRaw,d)||(c.isNormal(j)?j.call(null,n):!1)});o=0;for(r=b.length;o<r;o++){n=b[o];if(!n.isGmailFolder&&
(n.subScribed()||!n.existen))if(c.isNormal(m)?m.call(null,n):1)if(g.FolderType.User===n.type()||!p||!n.isNamespaceFolder&&0<n.subFolders().length)s.push({id:n.fullNameRaw,system:!1,name:(new h.Array(n.deep+1-i)).join("\u00a0\u00a0\u00a0\u00a0")+(c.isNormal(k)?k.call(null,n):n.name()),disable:!n.selectable||-1<c.inArray(n.fullNameRaw,d)||g.FolderType.User!==n.type()||(c.isNormal(j)?j.call(null,n):!1)});n.isUnpaddigFolder&&i++;s=s.concat(f.folderListOptionsBuilder([],n.subFolders(),d,[],i,j,m,k,p))}return s};
A.prototype.getAutocomplete=function(a,b,d){var e=[];f.remote().suggestions(function(a,b){g.StorageResultType.Success===a&&b&&b.Result&&c.isArray(b.Result.List)?(e=i.map(b.Result.List,function(a){return a&&a[0]?new F(a[0],a[1]):null}),d(i.compact(e),!!b.Result.More)):g.StorageResultType.Abort!==a&&d([],!1)},a,b)};A.prototype.emailsPicsHashes=function(){f.remote().emailsPicsHashes(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&f.cache().setEmailsPicsHashesData(b.Result)})};A.prototype.bootstart=
function(){I.prototype.bootstart.call(this);f.data().populateDataOnStart();var a=this.settingsGet("JsHash"),b=this.settingsGet("AllowGoogleSocial"),d=this.settingsGet("AllowFacebookSocial"),e=this.settingsGet("AllowTwitterSocial");!this.settingsGet("RemoteChangePassword")&&ma&&c.removeSettingsViewModel(ma);!this.settingsGet("AllowAdditionalAccounts")&&la&&c.removeSettingsViewModel(la);!b&&(!d&&!e&&Ma)&&c.removeSettingsViewModel(Ma);c.initOnStartOrLangChange(function(){j.extend(!0,j.magnificPopup.defaults,
{tClose:c.i18n("MAGNIFIC_POPUP/CLOSE"),tLoading:c.i18n("MAGNIFIC_POPUP/LOADING"),gallery:{tPrev:c.i18n("MAGNIFIC_POPUP/GALLERY_PREV"),tNext:c.i18n("MAGNIFIC_POPUP/GALLERY_NEXT"),tCounter:c.i18n("MAGNIFIC_POPUP/GALLERY_COUNTER")},image:{tError:c.i18n("MAGNIFIC_POPUP/IMAGE_ERROR")},ajax:{tError:c.i18n("MAGNIFIC_POPUP/AJAX_ERROR")}})},this);this.settingsGet("Auth")?(this.setTitle(c.i18n("TITLES/LOADING")),this.folders(!0,i.bind(function(a){s.hideLoading();if(a){s.startScreens([V,Oa]);Ca.on("click","#rl-center a",
function(){var a=null,b=j(this).attr("href");if(b&&"mailto:"===b.toString().toLowerCase().substr(0,7)){a=new F;a.parse(h.decodeURI(b.toString().substr(7)));if(a&&a.email){s.showScreenPopup(y,[g.ComposeType.Empty,null,[a]]);return false}}return true});(b||d||e)&&f.socialUsers(true);i.delay(function(){f.emailsPicsHashes();f.remote().servicesPics(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&f.cache().setServicesData(b.Result)})},1E3);x.runHook("rl-start-user-screens")}else{s.startScreens([Aa]);
x.runHook("rl-start-login-screens")}},this))):(s.hideLoading(),s.startScreens([Aa]),x.runHook("rl-start-login-screens"));b&&(h["rl_"+a+"_google_service"]=function(){f.data().googleActions(true);f.socialUsers()});d&&(h["rl_"+a+"_facebook_service"]=function(){f.data().facebookActions(true);f.socialUsers()});e&&(h["rl_"+a+"_twitter_service"]=function(){f.data().twitterActions(true);f.socialUsers()});x.runHook("rl-start-screens")};f=new A;j(function(){h.setTimeout(function(){s.setBoot(f).bootstart()},
10);h.setInterval(function(){wa(!wa())},6E4);i.delay(function(){h.rainloopAppData={};h.rainloopI18N={}},100)});R.keydown(c.killCtrlAandS).keyup(c.killCtrlAandS);h.rl=h.rl||{};h.rl.addHook=x.addHook;h.rl.settingsGet=x.mainSettingsGet;h.rl.remoteRequest=x.remoteRequest;h.rl.pluginSettingsGet=x.settingsGet;h.rl.addSettingsViewModel=c.addSettingsViewModel;h.rl.createCommand=c.createCommand;h.rl.EmailModel=F;h.rl.Enums=g;h.Pace&&(h.Pace.bar&&h.Pace.bar.update)&&h.Pace.bar.update(90)})(window,jQuery,ko,
crossroads,hasher,moment,Jua,_);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
dad5f042d5467813983ffa663c6495745a300346

View file

@ -0,0 +1 @@
1.2.8.420

View file

@ -8,15 +8,9 @@ if (!\defined('RAINLOOP_APP_ROOT_PATH'))
\spl_autoload_register(function ($sClassName) {
if (false !== \strpos($sClassName, '\\'))
if (0 === \strpos($sClassName, 'RainLoop') && false !== \strpos($sClassName, '\\'))
{
foreach (array('RainLoop', 'Buzz', 'KeenIO') as $sName)
{
if (0 === \strpos($sClassName, $sName))
{
return include RAINLOOP_APP_LIBRARIES_PATH.$sName.'/'.\str_replace('\\', '/', \substr($sClassName, \strlen($sName) + 1)).'.php';
}
}
return include RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/'.\str_replace('\\', '/', \substr($sClassName, 9)).'.php';
}
return false;

Some files were not shown because too many files have changed in this diff Show more