├── lintcode-training ├── Closest Number in Sorted Array.java ├── Closest Number in Sorted Array.py ├── SubsetsII.py ├── SubsetsII.cpp └── SubsetsII.java ├── Linux ├── Linux Server Configuration │ ├── Linux1 │ ├── Linux2 │ ├── Linux3 │ ├── Linux4 │ ├── Linux5 │ ├── Linux6 │ ├── Linux7 │ ├── Linux8 │ ├── Linux9 │ ├── 4.Linux Server Configuration Webcasts.md │ ├── 1.Project Overview.md │ ├── Linux Server Configuration.md │ ├── 2.Project Details.md │ ├── Vagrant Commands.md │ └── Get Started on Lightsail.md └── Web Application Servers │ ├── 1.Introduction.md │ ├── 3.Installing Apache.md │ ├── 6.Installing PostgreSql.md │ ├── 5.Your Firs WSGI Application.md │ ├── 4.Installing mod_wsgi.md │ └── 2.Vagrant Prerequisites.md ├── README.md ├── New students must see.md ├── .gitignore ├── hello.c ├── Python └── Movie Trailer Website.md ├── LICENSE └── los └── imgLos.min.js /lintcode-training/Closest Number in Sorted Array.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux1 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux2 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux3 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux4 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux5 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux6 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux7 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux8 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuHongJun/leetcode-training/HEAD/Linux/Linux Server Configuration/Linux9 -------------------------------------------------------------------------------- /Linux/Web Application Servers/1.Introduction.md: -------------------------------------------------------------------------------- 1 | Now that you have a shiny new server that is safe and secure, it’s time to turn it into a web application server! By the end of this lesson you will accomplish the following: 2 | 3 | Use the (http://httpd.apache.org/)[Apache HTTP] Server to respond to HTTP requests and serve a static webpage 4 | Configure Apache to hand-off specific requests to Python providing the ability to develop dynamic websites 5 | Setup (PostgreSQL)[https://www.postgresql.org/] and write a simple Python application that generates a data-driven website 6 | At the end of this lesson, the response cycle will resemble this: -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # leetcode-training 2 | Algorithm training. 3 | https://skygragon.github.io/leetcode-cli/demo.html 4 | 5 | java $: javac hello.java 6 | java $: java hello 7 | 8 | 9 | c $: gcc hello.c 10 | 如果没有错误会生成a.out可执行文件 11 | c $: ./a.out 12 | 13 | 14 | 15 | # leetcode cli 16 | ``` 17 | leetcode version 18 | 19 | leetcode help 20 | 21 | leetcode help user 22 | 23 | leetcode user -l 24 | 25 | leetcode help list 26 | 27 | leetcode list 28 | 29 | leetcode list -q h array 30 | 31 | leetcode show 1 32 | 33 | leetcode show 1 -gx 34 | 35 | vim 1.two-sum.cpp 36 | 37 | leetcode test 1.two-sum.cpp 38 | 39 | leetcode test 1.two-sum.cpp -t '[1,2,3]\n3' 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /lintcode-training/Closest Number in Sorted Array.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | # @param {int[]} A an integer array sorted in ascending order 3 | # @param {int} target an integer 4 | # @return {int} an integer 5 | def closestNumber(self, A, target): 6 | if not A: 7 | return -1 8 | start, end = 0, len(A) - 1 9 | while start + 1 < end: 10 | mid = (start + end) // 2 11 | print(start,end,mid) 12 | if A[mid] == target: 13 | return mid 14 | elif A[mid] > target: 15 | end = mid 16 | else: 17 | start = mid 18 | if A[end] - target > target - A[start]: 19 | return start 20 | else: 21 | return end 22 | 23 | if __name__ == '__main__': 24 | result = Solution().closestNumber([1, 4, 6], 5) 25 | print(result) -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/4.Linux Server Configuration Webcasts.md: -------------------------------------------------------------------------------- 1 | Webcasts for the Linux Server Configuration Project 2 | 3 | Need some additional help getting started with the Linux Server Configuration Project, or simply curious and want to learn a little bit more? Watch the following Webcasts! 4 | 5 | These webcasts are recordings of live Q&A sessions and demos. As always, you should read the appropriate rubric for your project thoroughly before you begin work on any project and double check the rubric before submitting. The videos were made by Udacity's coaches. Think of them as extra supplemental materials. 6 | 7 | The webcasts for the Linux Server Configuration Project include: 8 | 9 | [SSH: How to access a remote server and edit files](https://www.youtube.com/watch?v=HcwK8IWc-a8) 10 | 11 | [Intro to TMux](https://www.youtube.com/watch?v=hZ0cUWWixqU) 12 | 13 | [Deploying a Flask App with Heroku](https://www.youtube.com/watch?v=5UNAy4GzQ5E) 14 | 15 | Happy Learning! -------------------------------------------------------------------------------- /Linux/Web Application Servers/3.Installing Apache.md: -------------------------------------------------------------------------------- 1 | You’ll setup your web application server one piece at a time, testing each as you progress. The first step is to get your server responding to HTTP requests. To do this, you’ll use Apache HTTP Server - the most commonly installed web server on the Internet with roughly 47% market share. 2 | 3 | Install Apache using your package manager with the following command: `sudo apt-get install apache2` Confirm Apache is working by visiting http://localhost:8080 in your browser. You should see the following page: 4 | 5 | Default Ubuntu Start Page 6 | 7 | Apache, by default, serves its files from the `/var/www/html` directory. If you explore this directory you will find a file called `index.html` and if you review that file you will see it contains the HTML of the page you see when you visit http://localhost:8080. 8 | 9 | Exercise 10 | Update the index.html to simply display “Hello, World!” and refresh your browser to see your new page. -------------------------------------------------------------------------------- /lintcode-training/SubsetsII.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding:utf-8 -*- 3 | from functools import reduce 4 | 5 | __author__ = 'Demi Yu' 6 | 7 | 8 | # Given a collection of integers that might contain duplicates, S, return all possible subsets. 9 | # Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. 10 | # For example, If S = [1,2,2], a solution is: 11 | # [ [2], [1], [1,2,2], [2,2], [1,2], [] ] 12 | 13 | 14 | class Solution: 15 | def subsetsWithDup(self, S): 16 | S.sort() 17 | p = [[S[x] for x in range(len(S)) if i >> x & 1] for i in range(2 ** len(S))] 18 | func = lambda x, y: x if y in x else x + [y] 19 | p = reduce(func, [[], ] + p) 20 | return list(reversed(p)) 21 | 22 | 23 | # result = Solution().subsetsWithDup([1,2,2]) 24 | # print(result) 25 | 26 | if __name__ == '__main__': 27 | result = Solution().subsetsWithDup([1, 2, 2]) 28 | print(result) 29 | -------------------------------------------------------------------------------- /Linux/Web Application Servers/6.Installing PostgreSql.md: -------------------------------------------------------------------------------- 1 | Most web applications require persistent data storage, typically using a database server. 2 | You will now install PostgreSQL to server your data using the command `sudo apt-get install postgresql`. 3 | 4 | Since you are installing your web server and database server on the same machine, you do not need to modify your firewall settings. Your web server will communicate with the database via an internal mechanism that does not cross the boundaries of the firewall. If you were installing your database on a separate machine, you would need to modify the firewall settings on both the web server and the database server to permit these requests. 5 | 6 | Exercise 7 | Update your `/var/www/html/myapp.wsgi` application so that it successfully connects to your database, queries a table for data and presents that piece of data rather than the text Hello World!. You will need to create a table and populate it with data of your choosing, then query it from your app. 8 | 9 | This task is easier said than done, so use your research skills and don't be afraid to break things. Good luck! -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/1.Project Overview.md: -------------------------------------------------------------------------------- 1 | Project Overview 2 | You will take a baseline installation of a Linux server and prepare it to host your web applications. You will secure your server from a number of attack vectors, install and configure a database server, and deploy one of your existing web applications onto it. 3 | 4 | Why this Project? 5 | A deep understanding of exactly what your web applications are doing, how they are hosted, and the interactions between multiple systems are what define you as a Full Stack Web Developer. In this project, you’ll be responsible for turning a brand-new, bare bones, Linux server into the secure and efficient web application host your applications need. 6 | 7 | What will I Learn? 8 | You will learn how to access, secure, and perform the initial configuration of a bare-bones Linux server. You will then learn how to install and configure a web and database server and actually host a web application. 9 | 10 | How does this Help my Career? 11 | Deploying your web applications to a publicly accessible server is the first step in getting users 12 | Properly securing your application ensures your application remains stable and that your user’s data is safe -------------------------------------------------------------------------------- /lintcode-training/SubsetsII.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | class Solution { 7 | public: 8 | vector > result; 9 | bool equls( vector a, vector b){ 10 | if (a.size() != b.size()) 11 | return false; 12 | int cnt = a.size(); 13 | for (int i = 0; i < cnt;++i) 14 | if (a[i]!=b[i]) return false; 15 | return true; 16 | } 17 | void dfs(vector tmp, int x , vector nums) { 18 | if (x == nums.size()) { 19 | int cnt = result.size(); 20 | for ( int i = 0; i < cnt ; ++i) 21 | if ( equls(result[i], tmp) ) 22 | return ; 23 | result.push_back(tmp); 24 | return ; 25 | } 26 | dfs(tmp, x + 1, nums); 27 | tmp.push_back(nums[x]); 28 | dfs(tmp, x + 1, nums); 29 | } 30 | vector > subsetsWithDup(vector &nums){ 31 | sort(nums.begin(), nums.end()); 32 | vector tmp; 33 | dfs(tmp, 0 , nums) ; 34 | // write your code here 35 | return result; 36 | } 37 | }; 38 | 39 | //int main(){ 40 | // Solution result; 41 | // 42 | // result.subsetsWithDup([1, 2, 2]); 43 | //} -------------------------------------------------------------------------------- /Linux/Web Application Servers/5.Your Firs WSGI Application.md: -------------------------------------------------------------------------------- 1 | [WSGI](http://wsgi.readthedocs.io/en/latest/) is a specification that describes how a web server communicates with web applications. 2 | Most if not all Python web frameworks are WSGI compliant, including [Flask](http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/) and [Django](https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/); but to quickly test if you have your Apache configuration correct you’ll write a very basic WSGI application. 3 | 4 | You just defined the name of the file you need to write within your Apache configuration by using the `WSGIScriptAlias` directive. Despite having the extension `.wsgi`, these are just Python applications. 5 | Create the `/var/www/html/myapp.wsgi` file using the command `sudo nano /var/www/html/myapp.wsgi`. Within this file, write the following application: 6 | ``` 7 | def application(environ, start_response): 8 | status = '200 OK' 9 | output = 'Hello World!' 10 | 11 | response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] 12 | start_response(status, response_headers) 13 | 14 | return [output] 15 | ``` 16 | This application will simply print return `Hello World!` 17 | along with the required HTTP response headers. After saving this file you can reload http://localhost:8080 to see your application run in all its glory! 18 | -------------------------------------------------------------------------------- /Linux/Web Application Servers/4.Installing mod_wsgi.md: -------------------------------------------------------------------------------- 1 | When Apache receives a request it has a number of ways it can respond. What you’ve seen thus far is the simplest method of operation, Apache just returns a file requested or the `index.html` file if no file is defined within the URL. 2 | 3 | But, Apache can do so much more! You’ll now configure Apache to hand-off certain requests to an application handler - mod_wsgi. The first step in this process is to install mod_wsgi: `sudo apt-get install libapache2-mod-wsgi`. 4 | 5 | You then need to configure Apache to handle requests using the WSGI module. You’ll do this by editing the `/etc/apache2/sites-enabled/000-default.conf` file. This file tells Apache how to respond to requests, where to find the files for a particular site and much more. You can read up on everything this file can do within the [Apache documentation](https://httpd.apache.org/docs/2.2/configuring.html) . 6 | 7 | For now, add the following line at the end of the `` block, right before the closing `` line: `WSGIScriptAlias / /var/www/html/myapp.wsgi` 8 | 9 | Finally, restart Apache with the `sudo apache2ctl restart` command. 10 | 11 | You might get a warning saying "Could not reliably determine the server's fully qualified domain name". If you do, don't worry about it. Check out [this AskUbuntu thread](https://askubuntu.com/questions/256013/apache-error-could-not-reliably-determine-the-servers-fully-qualified-domain-n) for a discussion of the cause of this message. -------------------------------------------------------------------------------- /New students must see.md: -------------------------------------------------------------------------------- 1 | http://www.jiuzhang.com/qa/3/ 2 | 3 | 1. 面试时需要写注释吗? 4 | >一般不需要,具体可以问面试官 5 | 6 | 2. 刷题刷到什么程度可以去面试了呢? 7 | >lintcode 把200-300个题目刷两遍, 其中刷过的题目60%题目做到bug free,就比较好啦。 8 | 9 | 3. 面试英语到什么程度? 10 | >英语不是重点,能沟通就可以了,技术,算法才是重点 11 | 12 | 4. 公司冷冻期多久? 13 | >一般1年或者半年,不同公司不一样 14 | 15 | 5. 前端工程师/数据科学家需要刷题么? 16 | >需要,60%考算法,40%考相关背景技术 17 | 18 | 6. GPA重要么? 19 | >北美GPA3.5以上可以写到简历上,GPA只是敲门砖,不要太低,剩下就看个人技术。 20 | 21 | 7. 湾区/加州找工作有好处么? 22 | >至少面试的时候,可以少一门面试,或者直接给你onsite 23 | 24 | 8. 在哪里可以找到面经? 25 | >glassdoor, 一亩三分地,themianjing.com, mitbbs 26 | 27 | 9. c++/java/python等等 哪个语言找工作更好?可以用python面试么? 28 | >语言不是重点,重点的是你会什么,你做过什么项目。 29 | 30 | 10. FLAG面试难度? 31 | >大概lintcode/leetcode medium 偏难一点 32 | 33 | 11. 女生面试是否真的比男生要求低一些好进一些? 34 | >一些公司会要求公司员工平衡,对女生的要求会比男生低一点。 35 | 36 | 12. 毕业多久算new grad 呢? 37 | >不同公司不一样。 一般是一年期来算。 38 | 39 | 13. 哪里可以投简历找内推? 40 | >找内推: mitbbs,一亩三分地,linkedin 41 | 42 | >投简历: indeed,monster,hired.com,linkedin,readyforce.com 43 | 44 | 14. 投完简历没有结果怎么办? 45 | >一般投完要等2-3周才会有结果,如果没有结果,可以让内推的同学帮你催一催。 46 | 47 | 15. 面试完后多久出结果? 48 | >一般面试完后要2周才会有结果,一些小公司会比较快,有一些面的比较好的直接就可以当天或者第二天就出结果。 49 | 50 | 16. 面试时碰到做过的题,该如何表现?是否要告诉面试官自己做过? 51 | >比较诚实的做法是告诉面试官,但是通常面试官面试前只准备了2-3个题目,如果你告诉了面试官,面试官只有面下一个题目,一般下一个题目都会比较难,但是如果你又做不出来又比较吃亏相当于一道题目都没做,所以建议还是装作想一想,不给面试官说之前做过,实际上很可能大多是做过的,因为题目非常类似lintcode或者leetcode 52 | 53 | 17. 面实习和面试full time有区别么? 54 | >题目是一样的。 实际上题目是一样。只是面实习的要求会比较full time的要求低。 55 | 56 | 18. h1b申请日期是多久? 57 | >每年4月15日结束 58 | 59 | 19. 如果只有国内的实习经历,在美国找full-time的CS工作是不是比较困难? 60 | >是比较难,但是并不是没有可能,也不是没有机会,多投简历,总会有机会的,成功例子还是很多的 61 | 62 | 20. 在哪里可以看程序员的工资。 63 | >paysa 比较准确, glassdoor数据比较多 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | .idea/ 103 | -------------------------------------------------------------------------------- /lintcode-training/SubsetsII.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | class Solution { 3 | /** 4 | * @param nums: A set of numbers. 5 | * @return: A list of lists. All valid subsets. 6 | */ 7 | public ArrayList> subsetsWithDup(int[] nums) { 8 | // write your code here 9 | ArrayList> results = new ArrayList<>(); 10 | if (nums == null) return results; 11 | 12 | if (nums.length == 0) { 13 | results.add(new ArrayList()); 14 | return results; 15 | } 16 | Arrays.sort(nums); 17 | 18 | ArrayList subset = new ArrayList<>(); 19 | helper(nums, 0, subset, results); 20 | return results; 21 | } 22 | public void helper(int[] nums, int startIndex, ArrayList subset, ArrayList> results){ 23 | results.add(new ArrayList(subset)); 24 | for(int i=startIndex; i> a=s.subsetsWithDup(i); 41 | } 42 | } 43 | 44 | 45 | // class SubsetsII extends Solution{ 46 | // public static void main(int[] nums){ 47 | // SubsetsII a1=new SubsetsII(); 48 | // a1.subsetsWithDup([1, 2, 2]); 49 | 50 | // } 51 | 52 | // } 53 | 54 | 55 | -------------------------------------------------------------------------------- /Linux/Web Application Servers/2.Vagrant Prerequisites.md: -------------------------------------------------------------------------------- 1 | If you’re using the Vagrant virtual machine from earlier in this course you will need to make a slight modification to the configuration of this machine to make your web server accessible. This step is not related to configuring a web server in general, it’s just a condition of our current environment. You would not need to complete this step if you were configuring a machine from a cloud provider like Amazon Web Services. 2 | 3 | Open the `Vagrantfile` in your project directory and look for the following section near lines 20-23: 4 | ``` 5 | # Create a forwarded port mapping which allows access to a specific port 6 | # within the machine from a port on the host machine. In the example below, 7 | # accessing "localhost:8080" will access port 80 on the guest machine. 8 | # config.vm.network "forwarded_port", guest: 80, host: 8080 9 | ``` 10 | Uncomment the last line: 11 | 12 | ```config.vm.network "forwarded_port", guest: 80, host: 8080``` 13 | Save the file and start your Vagrant virtual machine using the `vagrant up` command. 14 | 15 | If your virtual machine is currently running, you can reload it using the `vagrant reload` command. 16 | 17 | This configuration change will setup port forwarding from port 8080 on the host machine (your computer) to the guest machine (your Vagrant virtual machine) when your virtual machine is running. 18 | This will allow you to access your web server using the URL http://localhost:8080. 19 | 20 | Compatibility note 21 | On some Windows systems, you will need to add one more argument to the line to ensure that the VM network connects to the correct interface on your host computer: 22 | 23 | ```config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"``` -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Linux Server Configuration.md: -------------------------------------------------------------------------------- 1 | 项目提交 2 | 3 | You will take a baseline installation of a Linux distribution on a virtual machine and prepare it to host your web applications, to include installing updates, securing it from a number of attack vectors and installing/configuring web and database servers. 4 | 5 | Note: If you have no experience working in the shell we recommend starting with [Linux Command Line Basics](https://www.udacity.com/course/viewer#!/c-ud595-nd). 6 | Otherwise, you can jump straight into [Configuring Linux Web Servers](https://classroom.udacity.com/courses/ud299-nd). 7 | 8 | Evaluation 9 | Your project will be evaluated by a Udacity Code Reviewer according to the rubric below. Be sure to review it thoroughly before you submit. All criteria must "meet specifications" in order to pass. 10 | 11 | Click here to view the rubric 12 | 13 | Submission 14 | Please follow these steps to properly submit this project: 15 | 16 | Create a new GitHub repository and add a file named `README.md`. 17 | Your README.md file should include all of the following: 18 | i. The IP address and SSH port so your server can be accessed by the reviewer. 19 | ii. The complete URL to your hosted web application. 20 | iii. A summary of software you installed and configuration changes made. 21 | iv. A list of any third-party resources you made use of to complete this project. 22 | Locate the SSH key you created for the `grader` user. 23 | During the submission process, paste the contents of the grader user's SSH key into the "Notes to Reviewer" field. 24 | When you're ready to submit your project, click here and follow the instructions. Due to the high volume of submissions we receive, please allow up up to 7 business days for your evaluation to be returned. 25 | 26 | If you are having any problems submitting your project or wish to check up on the status of your evaluation, please email us at fullstack-project@udacity.com. 27 | 28 | Next Steps 29 | You will get an email as soon as your reviewer has feedback for you. Congratulations on making it this far in the Nanodegree! You're almost finished! 30 | 你还没有提交此项目提交项目 -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/2.Project Details.md: -------------------------------------------------------------------------------- 1 | How will I complete this project? 2 | This project is linked to the Configuring Linux Web Servers course, which teaches you to secure and set up a Linux server. By the end of this project, you will have one of your web applications running live on a secure web server. 3 | 4 | To complete this project, you'll need a Linux server instance. 5 | We recommend using [Amazon Lightsail](https://lightsail.aws.amazon.com) 6 | for this. If you don't already have an Amazon Web Services account, you'll need to set one up. Once you've done that, here are the steps to complete this project. 7 | 8 | Get your server. 9 | 1. Start a new Ubuntu Linux server instance on [Amazon Lightsail](https://lightsail.aws.amazon.com). There are full details on setting up your Lightsail instance on the next page. 10 | 2. Follow the instructions provided to SSH into your server. 11 | 12 | Secure your server. 13 | 3. Update all currently installed packages. 14 | 4. Change the SSH port from 22 to 2200. Make sure to configure the Lightsail firewall to allow it. 15 | 5. Configure the Uncomplicated Firewall (UFW) to only allow incoming connections for SSH (port 2200), HTTP (port 80), and NTP (port 123). 16 | 17 | >Warning: When changing the SSH port, make sure that the firewall is open for port 2200 first, so that you don't lock yourself out of the server. 18 | `Review this video(Configuring Ports in UFW)` for details! When you change the SSH port, the Lightsail instance will no longer be accessible through the web app 'Connect using SSH' button. The button assumes the default port is being used. There are instructions on the same page for connecting from your terminal to the instance. Connect using those instructions and then follow the rest of the steps. 19 | 20 | Give `grader` access. 21 | In order for your project to be reviewed, the grader needs to be able to log in to your server. 22 | 23 | 6. Create a new user account named `grader`. 24 | 7. Give `grader` the permission to `sudo`. 25 | 8. Create an SSH key pair for `grader` using the `ssh-keygen` tool. 26 | 27 | Prepare to deploy your project. 28 | 9. Configure the local timezone to UTC. 29 | 10. Install and configure Apache to serve a Python mod_wsgi application. 30 | 11. Install and configure PostgreSQL: 31 | 32 | >Do not allow remote connections 33 | 34 | >Create a new database user named catalog that has limited permissions to your `catalog` application database. 35 | 36 | 12. Install `git`. 37 | 38 | Deploy the Item Catalog project. 39 | 13. Clone and setup your Item Catalog project from the Github repository you created earlier in this Nanodegree program. 40 | 14. Set it up in your server so that it functions correctly when visiting your server’s IP address in a browser. 41 | Make sure that your `.git` directory is not publicly accessible via a browser! -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Vagrant Commands.md: -------------------------------------------------------------------------------- 1 | Type vagrant status 2 | This command will show you the current status of the virtual machine. It should currently read “default running (virtualbox)” along with some other information. 3 | Type vagrant suspend 4 | This command suspends your virtual machine. All of your work is saved and the machine is put into a “sleep mode” of sorts. The machines state is saved and it’s very quick to stop and start your work. You should use this command if you plan to just take a short break from your work but don’t want to leave the virtual machine running. 5 | Type vagrant up 6 | This gets your virtual machine up and running again. Notice we didn’t have to redownload the virtual machine image, since it’s already been downloaded. 7 | Type vagrant ssh 8 | This command will actually connect to and log you into your virtual machine. Once done you will see a few lines of text showing various performance statistics of the virtual machine along with a new command line prompt that reads vagrant@vagrant-ubuntu-trusty-64:~$ 9 | Here are a few other important commands that we’ll discuss but you do not need to practice at this time: 10 | 11 | vagrant halt 12 | This command halts your virtual machine. All of your work is saved and the machine is turned off - think of this as “turning the power off”. It’s much slower to stop and start your virtual machine using this command, but it does free up all of your RAM once the machine has been stopped. You should use this command if you plan to take an extended break from your work, like when you are done for the day. The command vagrant up will turn your machine back on and you can continue your work. 13 | vagrant destroy 14 | This command destroys your virtual machine. Your work is not saved, the machine is turned off and forgotten about for the most part. Think of this as formatting the hard drive of a computer. You can always use vagrant up to relaunch the machine but you’ll be left with the baseline Linux installation from the beginning of this course. You should not have to use this command at any time during this course unless, at some point in time, you perform a task on the virtual machine that makes it completely inoperable. 15 | 16 | ``` 17 | pwd 18 | ls -al 19 | 20 | ls -al /home/ubuntu/.ssh 21 | 22 | cat /etc/apt/sources.list 资源ubuntu列表 23 | 24 | sudo apt-get update 检查是否最新软件 25 | 26 | sudo apt-get upgrade 可更新软件列表 27 | 28 | man apt-get 可执行命令列表 29 | 30 | sudo apt-get autoremove 自动删除 31 | 32 | sudo apt-get install finger 33 | 34 | packages.ubuntu.com 安装包名字搜索 35 | 36 | Apache Http Server=> apache2 37 | 38 | PostgreSQL=> postgresql 39 | 40 | Memcache=> memcached 41 | 42 | finger 43 | 44 | finger vagrant 45 | 46 | cat /etc/passwd 47 | 48 | sudo adduser student 创建用户 49 | 50 | ssh student@127.0.0.1 -p 2222 新命令行 用新用户连接ssh。会提示没有权限 51 | 52 | 去root账号 vagrant 添加权限 53 | 54 | vagrant$: sudo cat /etc/sudoers 55 | vagrant$: sudo ls /etc/sudoers.d 56 | vagrant$: sudo cp /etc/sudoers.d/vagrant /etc/sudoers.d/student 57 | vagrant$: sudo nano /etc/sudoers.d/student 58 | 59 | vagrant$: sudo passwd -e student 强制学士在下次登录时 重置自己的密码 60 | 61 | 62 | ``` 63 | 64 | 65 | -------------------------------------------------------------------------------- /hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct queue 4 | 5 | { 6 | 7 | int data[1000]; 8 | 9 | int head; 10 | 11 | int tail; 12 | 13 | }; 14 | 15 | struct stack 16 | 17 | { 18 | 19 | int data[10]; 20 | 21 | int top; 22 | 23 | }; 24 | 25 | int main() 26 | 27 | { 28 | 29 | struct queue q1,q2; 30 | 31 | struct stack s; 32 | 33 | int book[10]; 34 | 35 | int i,t; 36 | 37 | //初始化队列 38 | 39 | q1.head=1; q1.tail=1; 40 | 41 | q2.head=1; q2.tail=1; 42 | 43 | //初始化栈 44 | 45 | s.top=0; 46 | 47 | //初始化用来标记的数组,用来标记哪些牌已经在桌上 48 | 49 | for(i=1;i<=9;i++) 50 | 51 | book[i]=0; 52 | 53 | //依次向队列插入6个数 54 | 55 | //小哼手上的6张牌 56 | 57 | for(i=1;i<=6;i++) 58 | 59 | { 60 | 61 | scanf("%d",&q1.data[q1.tail]); 62 | 63 | q1.tail++; 64 | 65 | } 66 | 67 | //小哈手上的6张牌 68 | 69 | for(i=1;i<=6;i++) 70 | 71 | { 72 | 73 | scanf("%d",&q2.data[q2.tail]); 74 | 75 | q2.tail++; 76 | 77 | } 78 | 79 | while(q1.head0) //如果桌上有牌则依次输出桌上的牌 192 | 193 | { 194 | 195 | printf("\n桌上的牌是"); 196 | 197 | for(i=1;i<=s.top;i++) 198 | 199 | printf(" %d",s.data[i]); 200 | 201 | } 202 | 203 | else 204 | 205 | printf("\n桌上已经没有牌了"); 206 | 207 | } 208 | 209 | else 210 | 211 | { 212 | 213 | printf("小哈win\n"); 214 | 215 | printf("小哈当前手中的牌是"); 216 | 217 | for(i=q2.head;i<=q2.tail-1;i++) 218 | 219 | printf(" %d",q2.data[i]); 220 | 221 | if(s.top>0) //如果桌上有牌则依次输出桌上的牌 222 | 223 | { 224 | 225 | printf("\n桌上的牌是"); 226 | 227 | for(i=1;i<=s.top;i++) 228 | 229 | printf(" %d",s.data[i]); 230 | 231 | } 232 | 233 | else 234 | 235 | printf("\n桌上已经没有牌了"); 236 | 237 | } 238 | 239 | getchar();getchar(); 240 | 241 | return 0; 242 | } -------------------------------------------------------------------------------- /Linux/Linux Server Configuration/Get Started on Lightsail.md: -------------------------------------------------------------------------------- 1 | Get started on Lightsail 2 | We're recommending `Amazon Lightsail` for this project. If you prefer, you can use any other service that gives you a publicly accessible Ubuntu Linux server. But Lightsail works pretty well and it's what we've tested. 3 | 4 | There are a few things you need to do when you create your server instance. 5 | 6 | 1. Log in! 7 | First, log in to Lightsail. If you don't already have an Amazon Web Services account, you'll be prompted to create one. 8 | 9 | 10 | `Linux1` 11 | 12 | Amazon Web Services login page. 13 | 2. Create an instance. 14 | Once you're logged in, Lightsail will give you a friendly message with a robot on it, prompting you to create an instance. 15 | Lightsail instance is a Linux server running on a virtual machine inside an Amazon datacenter. 16 | 17 | `Linux2` 18 | 19 | When you have no instances, Lightsail gives you a picture of an orange robot and suggests that you create an instance. 20 | 3. Choose an instance image: Ubuntu 21 | Lightsail supports a lot of different instance types. An instance image is a particular software setup, including an operating system and optionally built-in applications. 22 | 23 | For this project, you'll want a plain Ubuntu Linux image. 24 | There are two settings to make here. First, choose "OS Only" (rather than "Apps + OS"). 25 | Second, choose Ubuntu as the operating system. 26 | 27 | `Linux3` 28 | 29 | When you create an instance, Lightsail asks what kind you want. 30 | For this project, choose an "OS Only" instance with Ubuntu. 31 | 4. Choose your instance plan. 32 | The instance plan controls how powerful of a server you get. It also controls how much money they want to charge you. For this project, the lowest tier of instance is just fine. And as long as you complete the project within a month and shut your instance down, the price will be zero. 33 | 34 | `Linux4` 35 | 36 | Lightsail's options for instance pricing. 37 | For this project, pick the lowest one to get free-tier access. 38 | Be aware: If you enable additional features in Lightsail, you may be charged extra for them. 39 | 5. Give your instance a hostname. 40 | Every instance needs a unique hostname. You can use any name you like, as long as it doesn't have spaces or unusual characters in it. Your instance's name will be visible to you and to the project reviewer. 41 | `Linux5` 42 | 43 | I've named my instance `silly-name-here`. 44 | 6. Wait for it to start up. 45 | It may take a few minutes for your instance to start up. 46 | `Linux6` 47 | While your instance is starting up, Lightsail shows you a grayed-out display. 48 | 49 | `Linux7` 50 | Once your instance is running, the display gets brighter. 51 | 7. It's running; let's use it! 52 | Once your instance has started up, you can log into it with SSH from your browser. 53 | 54 | The public IP address of the instance is displayed along with its name. 55 | In the above picture it's `54.84.49.254`. 56 | The DNS name of this instance is `ec2-54-84-49-254.compute-1.amazonaws.com`. 57 | `Linux8` 58 | 59 | The main page for my `silly-name-here` instance. 60 | The big orange "Connect using SSH" button is the next step. 61 | Explore the other tabs of this user interface to find the Lightsail firewall and other settings. You'll need to configure the Lightsail firewall as one step of the project. 62 | 63 | When you SSH in, you'll be logged as the `ubuntu` user. When you want to execute commands as `root`, you'll need to use the `sudo` command to do it. `Review sudo here if you need a refresher`! 64 | 65 | `Linux9` 66 | 67 | An SSH window logged into the server instance. 68 | From here, it's just like any other Linux server. 69 | 8. Project time. 70 | Now that you have a working instance, you can get right into the project. -------------------------------------------------------------------------------- /Python/Movie Trailer Website.md: -------------------------------------------------------------------------------- 1 | 2 | How will I complete this project? 3 | This project is connected to the Programming Foundations with Python course, but depending on your background knowledge you may not need the entirety of the course to complete this project. Here's what you should do: 4 | 5 | 1. Install [Python](https://www.python.org/) 6 | 7 | 2. Create a data structure (i.e. a Python Class) to store your favorite movies, including movie title, box art URL (or poster URL) and a YouTube link to the movie trailer. 8 | 9 | 3. Create multiple instances of that Python Class to represent your favorite movies; group all the instances together in a list. 10 | 11 | 4. To help you generate a website that displays these movies, we have provided a starter code repository that contains a Python module called `fresh_tomatoes.py`. 12 | To get started, `fork` this [repository](https://github.com/udacity/ud036_StarterCode/blob/master/fresh_tomatoes.py) to create your own copy in GitHub. 13 | Then `clone` your `ud036_StarterCode` repository to work on this project locally on your computer. 14 | The `fresh_tomatoes.py` module has a function called `open_movies_page` that takes in one argument, which is a list of movies, and creates an HTML file which will display all of your favorite movies. 15 | Ensure your website renders correctly when you attempt to load it in a browser. 16 | Notes 17 | 18 | The file `fresh_tomatoes.py` contains the `open_movies_page()` function that will take in your list of movies and generate an HTML file including this content, producing a website to showcase your favorite movies. 19 | 20 | Your task is to write a movie class in `media.py`. 21 | To do this, think about what the properties of a movie are that need to be encapsulated in a movie object such as movie titles, box art, poster images, and movie trailer URLs. 22 | Look at what `open_movies_page()` does with a list of movie objects for hints on how to design your movie class. 23 | 24 | You’ll want to write a constructor for the movie class so that you can create instances of movie. 25 | You can now create a list of these movie objects in `entertainment_center.py` by calling the constructor `media.Movie()` to instantiate movie objects. You’ve given movies their own custom data structure by defining the movie class and constructor, and now these objects can be stored in a list data structure. This list of movies is what the open_movies_page() function needs as input in order to build the HTML file, so you can display your website. 26 | Project Evaluation 27 | The project will be evaluated as either Meets Specifications or Does Not Meet Specifications scale. The rubric is broken into four major categories: 28 | 29 | Functionality 30 | Does your project work the way it's supposed to? Are movies and their poster images being displayed on the web page? Is there a trailer link? Does it open from the Python file error free? 31 | 32 | Code Quality 33 | Is your code organized and professional? If you need an idea of how to format and style your code to look organized and professional, check out the Google [Python Style Guide](https://google.github.io/styleguide/pyguide.html) and the [PEP-8 site](https://www.python.org/dev/peps/pep-0008/). 34 | 35 | Because Python is sensitive to white space and indents, make sure that you follow the formatting rules found here. 36 | 37 | Comments 38 | Do you use comments to describe what is going on in your code? Would other developers be able to take a look at your code and easily be able to understand what your code is trying to do? A good starting point to see how to comment code would be to take a look at the comments section of the Google Python Style Guide. 39 | 40 | Documentation 41 | When submitting your project, be sure to include a README file detailing how a user is to run your project (how to open the movie trailer website). 42 | 43 | Include information, such as, how do they get your code (download, etc.), are there any requirements? Are there any commands that need to be run in order to run your application? 44 | If you've never written a README before, Udacity has produced a [short course](https://cn.udacity.com/course/writing-readmes--ud777) on how to write one effectively. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /los/imgLos.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.imgLos=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t,n){if(!(e0&&u>a&&(u=a);for(var c=0;c=0?(p=h.substr(0,g),l=h.substr(g+1)):(p=h,l=""),f=decodeURIComponent(p),d=decodeURIComponent(l),i(o,f)?jt(o[f])?o[f].push(d):o[f]=[o[f],d]:o[f]=d}return o}var p,l="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},f=(e(function(e,t){(function(){function n(e,t){function o(e){if(o[e]!==v)return o[e];var n;if("bug-string-char-index"==e)n="a"!="a"[0];else if("json"==e)n=o("json-stringify")&&o("json-parse");else{var r,i='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==e){var u=t.stringify,p="function"==typeof u&&_;if(p){(r=function(){return 1}).toJSON=r;try{p="0"===u(0)&&"0"===u(new s)&&'""'==u(new a)&&u(m)===v&&u(v)===v&&u()===v&&"1"===u(r)&&"[1]"==u([r])&&"[null]"==u([v])&&"null"==u(null)&&"[null,null,null]"==u([v,m,null])&&u({a:[r,!0,!1,null,"\0\b\n\f\r\t"]})==i&&"1"===u(null,r)&&"[\n 1,\n 2\n]"==u([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==u(new c(-864e13))&&'"+275760-09-13T00:00:00.000Z"'==u(new c(864e13))&&'"-000001-01-01T00:00:00.000Z"'==u(new c(-621987552e5))&&'"1969-12-31T23:59:59.999Z"'==u(new c(-1))}catch(e){p=!1}}n=p}if("json-parse"==e){var l=t.parse;if("function"==typeof l)try{if(0===l("0")&&!l(!1)){var f=5==(r=l(i)).a.length&&1===r.a[0];if(f){try{f=!l('"\t"')}catch(e){}if(f)try{f=1!==l("01")}catch(e){}if(f)try{f=1!==l("1.")}catch(e){}}}}catch(e){f=!1}n=f}}return o[e]=!!n}e||(e=i.Object()),t||(t=i.Object());var s=e.Number||i.Number,a=e.String||i.String,u=e.Object||i.Object,c=e.Date||i.Date,p=e.SyntaxError||i.SyntaxError,l=e.TypeError||i.TypeError,f=e.Math||i.Math,d=e.JSON||i.JSON;"object"==typeof d&&d&&(t.stringify=d.stringify,t.parse=d.parse);var h,g,v,y=u.prototype,m=y.toString,_=new c(-0xc782b5b800cec);try{_=-109252==_.getUTCFullYear()&&0===_.getUTCMonth()&&1===_.getUTCDate()&&10==_.getUTCHours()&&37==_.getUTCMinutes()&&6==_.getUTCSeconds()&&708==_.getUTCMilliseconds()}catch(e){}if(!o("json")){var b=o("bug-string-char-index");if(!_)var w=f.floor,I=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(e,t){return I[t]+365*(e-1970)+w((e-1969+(t=+(t>1)))/4)-w((e-1901+t)/100)+w((e-1601+t)/400)};if((h=y.hasOwnProperty)||(h=function(e){var t,n={};return(n.__proto__=null,n.__proto__={toString:1},n).toString!=m?h=function(e){var t=this.__proto__,n=e in(this.__proto__=null,this);return this.__proto__=t,n}:(t=n.constructor,h=function(e){var n=(this.constructor||t).prototype;return e in this&&!(e in n&&this[e]===n[e])}),n=null,h.call(this,e)}),g=function(e,t){var n,o,i,s=0;(n=function(){this.valueOf=0}).prototype.valueOf=0,o=new n;for(i in o)h.call(o,i)&&s++;return n=o=null,s?g=2==s?function(e,t){var n,r={},o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||h.call(r,n)||!(r[n]=1)||!h.call(e,n)||t(n)}:function(e,t){var n,r,o="[object Function]"==m.call(e);for(n in e)o&&"prototype"==n||!h.call(e,n)||(r="constructor"===n)||t(n);(r||h.call(e,n="constructor"))&&t(n)}:(o=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],g=function(e,t){var n,i,s="[object Function]"==m.call(e),a=!s&&"function"!=typeof e.constructor&&r[typeof e.hasOwnProperty]&&e.hasOwnProperty||h;for(n in e)s&&"prototype"==n||!a.call(e,n)||t(n);for(i=o.length;n=o[--i];a.call(e,n)&&t(n));}),g(e,t)},!o("json-stringify")){var S={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},C=function(e,t){return("000000"+(t||0)).slice(-e)},O=function(e){for(var t='"',n=0,r=e.length,o=!b||r>10,i=o&&(b?e.split(""):e);n-1/0&&a<1/0){if(E){for(f=w(a/864e5),c=w(f/365.2425)+1970-1;E(c+1,0)<=f;c++);for(p=w((f-E(c,0))/30.42);E(c,p+1)<=f;p++);f=1+f-E(c,p),y=w((d=(a%864e5+864e5)%864e5)/36e5)%24,_=w(d/6e4)%60,b=w(d/1e3)%60,I=d%1e3}else c=a.getUTCFullYear(),p=a.getUTCMonth(),f=a.getUTCDate(),y=a.getUTCHours(),_=a.getUTCMinutes(),b=a.getUTCSeconds(),I=a.getUTCMilliseconds();a=(c<=0||c>=1e4?(c<0?"-":"+")+C(6,c<0?-c:c):C(4,c))+"-"+C(2,p+1)+"-"+C(2,f)+"T"+C(2,y)+":"+C(2,_)+":"+C(2,b)+"."+C(3,I)+"Z"}else a=null;if(n&&(a=n.call(t,e,a)),null===a)return"null";if("[object Boolean]"==(u=m.call(a)))return""+a;if("[object Number]"==u)return a>-1/0&&a<1/0?""+a:"null";if("[object String]"==u)return O(""+a);if("object"==typeof a){for(x=s.length;x--;)if(s[x]===a)throw l();if(s.push(a),S=[],j=i,i+=o,"[object Array]"==u){for(T=0,x=a.length;T0)for(o="",n>10&&(n=10);o.length=48&&o<=57||o>=97&&o<=102||o>=65&&o<=70||k();e+=x("0x"+i.slice(t,A));break;default:k()}else{if(34==o)break;for(o=i.charCodeAt(A),t=A;o>=32&&92!=o&&34!=o;)o=i.charCodeAt(++A);e+=i.slice(t,A)}if(34==i.charCodeAt(A))return A++,e;k();default:if(t=A,45==o&&(r=!0,o=i.charCodeAt(++A)),o>=48&&o<=57){for(48==o&&(o=i.charCodeAt(A+1))>=48&&o<=57&&k(),r=!1;A=48&&o<=57;A++);if(46==i.charCodeAt(A)){for(n=++A;n=48&&o<=57;n++);n==A&&k(),A=n}if(101==(o=i.charCodeAt(A))||69==o){for(43!=(o=i.charCodeAt(++A))&&45!=o||A++,n=A;n=48&&o<=57;n++);n==A&&k(),A=n}return+i.slice(t,A)}if(r&&k(),"true"==i.slice(A,A+4))return A+=4,!0;if("false"==i.slice(A,A+5))return A+=5,!1;if("null"==i.slice(A,A+4))return A+=4,null;k()}return"$"},P=function(e){var t,n;if("$"==e&&k(),"string"==typeof e){if("@"==(b?e.charAt(0):e[0]))return e.slice(1);if("["==e){for(t=[];"]"!=(e=R());n||(n=!0))n&&(","==e?"]"==(e=R())&&k():k()),","==e&&k(),t.push(P(e));return t}if("{"==e){for(t={};"}"!=(e=R());n||(n=!0))n&&(","==e?"}"==(e=R())&&k():k()),","!=e&&"string"==typeof e&&"@"==(b?e.charAt(0):e[0])&&":"==R()||k(),t[e.slice(1)]=P(R());return t}k()}return e},F=function(e,t,n){var r=U(e,t,n);r===v?delete e[t]:e[t]=r},U=function(e,t,n){var r,o=e[t];if("object"==typeof o&&o)if("[object Array]"==m.call(o))for(r=o.length;r--;)F(o,r,n);else g(o,function(e){F(o,e,n)});return n.call(e,t,o)};t.parse=function(e,t){var n,r;return A=0,T=""+e,n=P(R()),"$"!=R()&&k(),A=T=null,t&&"[object Function]"==m.call(t)?U((r={},r[""]=n,r),"",t):n}}}return t.runInContext=n,t}var r={function:!0,object:!0},o=r.object&&t&&!t.nodeType&&t,i=r[typeof window]&&window||this,s=o&&r.object&&e&&!e.nodeType&&"object"==typeof l&&l;if(!s||s.global!==s&&s.window!==s&&s.self!==s||(i=s),o)n(i,o);else{var a=i.JSON,u=i.JSON3,c=!1,p=n(i,i.JSON3={noConflict:function(){return c||(c=!0,i.JSON=a,i.JSON3=u,a=u=null),p}});i.JSON={parse:p.parse,stringify:p.stringify}}}).call(l)}),{DEFAULT_INSTANCE:"$default_instance",API_VERSION:1,MAX_STRING_LENGTH:4096,MAX_PROPERTY_KEYS:1e3,IDENTIFY_EVENT:"$identify",LAST_EVENT_ID:"imgLos_lastEventId",LAST_EVENT_TIME:"imgLos_lastEventTime",LAST_IDENTIFY_ID:"imgLos_lastIdentifyId",LAST_SEQUENCE_NUMBER:"imgLos_lastSequenceNumber",SESSION_ID:"imgLos_sessionId",DEVICE_ID:"imgLos_deviceId",OPT_OUT:"imgLos_optOut",USER_ID:"imgLos_userId",COOKIE_TEST:"imgLos_cookie_test",REVENUE_EVENT:"revenue_amount",REVENUE_PRODUCT_ID:"$productId",REVENUE_QUANTITY:"$quantity",REVENUE_PRICE:"$price",REVENUE_REVENUE_TYPE:"$revenueType",AMP_DEVICE_ID_PARAM:"amp_device_id"}),d={encode:function(e){for(var t="",n=0;n127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},decode:function(e){for(var t="",n=0,r=0,o=0,i=0;n191&&r<224?(o=e.charCodeAt(n+1),t+=String.fromCharCode((31&r)<<6|63&o),n+=2):(o=e.charCodeAt(n+1),i=e.charCodeAt(n+2),t+=String.fromCharCode((15&r)<<12|(63&o)<<6|63&i),n+=3);return t}},h={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(e)))}catch(e){}return h._encode(e)},_encode:function(e){var t,n,r,o,i,s,a,u="",c=0;for(e=d.encode(e);c>2,i=(3&t)<<4|(n=e.charCodeAt(c++))>>4,s=(15&n)<<2|(r=e.charCodeAt(c++))>>6,a=63&r,isNaN(n)?s=a=64:isNaN(r)&&(a=64),u=u+h._keyStr.charAt(o)+h._keyStr.charAt(i)+h._keyStr.charAt(s)+h._keyStr.charAt(a);return u},decode:function(e){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(e)))}catch(e){}return h._decode(e)},_decode:function(e){var t,n,r,o,i,s,a="",u=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,n=(15&o)<<4|(i=h._keyStr.indexOf(e.charAt(u++)))>>2,r=(3&i)<<6|(s=h._keyStr.indexOf(e.charAt(u++))),a+=String.fromCharCode(t),64!==i&&(a+=String.fromCharCode(n)),64!==s&&(a+=String.fromCharCode(r));return a=d.decode(a)}},g=e(function(e,t){t.parse=function(e){var t=document.createElement("a");return t.href=e,{href:t.href,host:t.host||location.host,port:"0"===t.port||""===t.port?function(e){switch(e){case"http:":return 80;case"https:":return 443;default:return location.port}}(t.protocol):t.port,hash:t.hash,hostname:t.hostname||location.hostname,pathname:"/"!=t.pathname.charAt(0)?"/"+t.pathname:t.pathname,protocol:t.protocol&&":"!=t.protocol?t.protocol:location.protocol,search:t.search,query:t.search.slice(1)}},t.isAbsolute=function(e){return 0==e.indexOf("//")||!!~e.indexOf("://")},t.isRelative=function(e){return!t.isAbsolute(e)},t.isCrossDomain=function(e){e=t.parse(e);var n=t.parse(window.location.href);return e.hostname!==n.hostname||e.port!==n.port||e.protocol!==n.protocol}}),v=1e3,y=60*v,m=60*y,_=24*m,b=365.25*_,w=function(e,n){n=n||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*b;case"days":case"day":case"d":return n*_;case"hours":case"hour":case"hrs":case"hr":case"h":return n*m;case"minutes":case"minute":case"mins":case"min":case"m":return n*y;case"seconds":case"second":case"secs":case"sec":case"s":return n*v;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===r&&!1===isNaN(e))return n.long?function(e){return t(e,_,"day")||t(e,m,"hour")||t(e,y,"minute")||t(e,v,"second")||e+" ms"}(e):function(e){return e>=_?Math.round(e/_)+"d":e>=m?Math.round(e/m)+"h":e>=y?Math.round(e/y)+"m":e>=v?Math.round(e/v)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},I=e(function(e,t){function n(e){function n(){if(n.enabled){var e=n,r=+new Date,i=r-(o||r);e.diff=i,e.prev=o,e.curr=r,o=r;for(var s=new Array(arguments.length),a=0;a=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())})("cookie"),S=function(e,t,o){switch(arguments.length){case 3:case 2:return function(e,t,n){n=n||{};var o=r(e)+"="+r(t);null==t&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(o+="; path="+n.path),n.domain&&(o+="; domain="+n.domain),n.expires&&(o+="; expires="+n.expires.toUTCString()),n.secure&&(o+="; secure"),document.cookie=o}(e,t,o);case 1:return function(e){return n()[e]}(e);default:return n()}},C=e(function(e,t){function n(e){for(var n=t.cookie,r=t.levels(e),o=0;o=0;--i)o.push(t.slice(i).join("."));return o},n.cookie=S,t=e.exports=n}),O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},N=Object.prototype.toString,A=function(e){switch(N.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!=e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof Buffer&&Buffer.isBuffer(e)?"buffer":void 0===(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e))?"undefined":O(e)},T="WARN",x={DISABLE:0,ERROR:1,WARN:2,INFO:3},j={error:function(e){T>=x.ERROR&&k(e)},warn:function(e){T>=x.WARN&&k(e)},info:function(e){T>=x.INFO&&k(e)}},k=function(e){try{console.log("[ImgLos] "+e)}catch(e){}},R=function(e){return"string"===A(e)&&e.length>f.MAX_STRING_LENGTH?e.substring(0,f.MAX_STRING_LENGTH):e},P=function(e){var t=A(e);if("object"!==t)return j.error("Error: invalid properties format. Expecting Javascript object, received "+t+", ignoring"),{};if(Object.keys(e).length>f.MAX_PROPERTY_KEYS)return j.error("Error: too many properties (more than 1000), ignoring"),{};var n={};for(var r in e)if(e.hasOwnProperty(r)){var o=r,i=A(o);"string"!==i&&(o=String(o),j.warn("WARNING: Non-string property key, received type "+i+', coercing to string "'+o+'"'));var s=U(o,e[r]);null!==s&&(n[o]=s)}return n},F=["null","nan","undefined","function","arguments","regexp","element"],U=function e(t,n){var r=A(n);if(-1!==F.indexOf(r))j.warn('WARNING: Property key "'+t+'" with invalid value type '+r+", ignoring"),n=null;else if("error"===r)n=String(n),j.warn('WARNING: Property key "'+t+'" with value type error, coercing to '+n);else if("array"===r){for(var o=[],i=0;i0?(this.userPropertiesOperations.hasOwnProperty("$clearAll")||L.log.error("Need to send $clearAll on its own Identify object without any other operations, skipping $clearAll"),this):(this.userPropertiesOperations.$clearAll="-",this)},Q.prototype.prepend=function(e,t){return this._addOperation("$prepend",e,t),this},Q.prototype.set=function(e,t){return this._addOperation("$set",e,t),this},Q.prototype.setOnce=function(e,t){return this._addOperation("$setOnce",e,t),this},Q.prototype.unset=function(e){return this._addOperation("$unset",e,"-"),this},Q.prototype._addOperation=function(e,t,n){this.userPropertiesOperations.hasOwnProperty("$clearAll")?L.log.error("This identify already contains a $clearAll operation, skipping operation "+e):-1===this.properties.indexOf(t)?(this.userPropertiesOperations.hasOwnProperty(e)||(this.userPropertiesOperations[e]={}),this.userPropertiesOperations[e][t]=n,this.properties.push(t)):L.log.error('User property "'+t+'" already used in this identify, skipping operation '+e)};var X=e(function(e){!function(t){function n(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function r(e,t,r,o,i,s){return n(function(e,t){return e<>>32-t}(n(n(t,e),n(o,s)),i),r)}function o(e,t,n,o,i,s,a){return r(t&n|~t&o,e,t,i,s,a)}function i(e,t,n,o,i,s,a){return r(t&o|n&~o,e,t,i,s,a)}function s(e,t,n,o,i,s,a){return r(t^n^o,e,t,i,s,a)}function a(e,t,n,o,i,s,a){return r(n^(t|~o),e,t,i,s,a)}function u(e,t){e[t>>5]|=128<>>9<<4)]=t;var r,u,c,p,l,f=1732584193,d=-271733879,h=-1732584194,g=271733878;for(r=0;r>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return r}function f(e){return unescape(encodeURIComponent(e))}function d(e){return function(e){return c(u(p(e),8*e.length))}(f(e))}function h(e,t){return function(e,t){var n,r,o=p(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=u(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=u(i.concat(p(t)),512+8*t.length),c(u(s.concat(r),640))}(f(e),f(t))}function g(e,t,n){return t?n?h(t,e):function(e,t){return l(h(e,t))}(t,e):n?d(e):function(e){return l(d(e))}(e)}e.exports?e.exports=g:t.md5=g}(l)}),H="object"==typeof l&&l&&l.Object===Object&&l,Z="object"==typeof self&&self&&self.Object===Object&&self,ee=H||Z||Function("return this")(),te=ee.Symbol,ne=Object.prototype,re=ne.hasOwnProperty,oe=ne.toString,ie=te?te.toStringTag:void 0,se=function(e){var t=re.call(e,ie),n=e[ie];try{e[ie]=void 0;var r=!0}catch(e){}var o=oe.call(e);return r&&(t?e[ie]=n:delete e[ie]),o},ae=Object.prototype.toString,ue=function(e){return ae.call(e)},ce="[object Null]",pe="[object Undefined]",le=te?te.toStringTag:void 0,fe=function(e){return null==e?void 0===e?pe:ce:le&&le in Object(e)?se(e):ue(e)},de=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},he="[object AsyncFunction]",ge="[object Function]",ve="[object GeneratorFunction]",ye="[object Proxy]",me=function(e){if(!de(e))return!1;var t=fe(e);return t==ge||t==ve||t==he||t==ye},_e=ee["__core-js_shared__"],be=function(){var e=/[^.]+$/.exec(_e&&_e.keys&&_e.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),we=function(e){return!!be&&be in e},Ie=Function.prototype.toString,Ee=function(e){if(null!=e){try{return Ie.call(e)}catch(e){}try{return e+""}catch(e){}}return""},Se=/^\[object .+?Constructor\]$/,Ce=Function.prototype,Oe=Object.prototype,Ne=Ce.toString,Ae=Oe.hasOwnProperty,Te=RegExp("^"+Ne.call(Ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),xe=function(e){return!(!de(e)||we(e))&&(me(e)?Te:Se).test(Ee(e))},je=function(e,t){return null==e?void 0:e[t]},ke=function(e,t){var n=je(e,t);return xe(n)?n:void 0},Re=function(){try{var e=ke(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Pe=function(e,t,n){"__proto__"==t&&Re?Re(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},Fe=function(e,t){return e===t||e!=e&&t!=t},Ue=Object.prototype.hasOwnProperty,De=function(e,t,n){var r=e[t];Ue.call(e,t)&&Fe(r,n)&&(void 0!==n||t in e)||Pe(e,t,n)},Le=function(e,t,n,r){var o=!n;n||(n={});for(var i=-1,s=t.length;++i0){if(++t>=ze)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Ke),Ye=function(e,t){return We(Ge(e,t,Me),e+"")},Qe=9007199254740991,Xe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Qe},He=function(e){return null!=e&&Xe(e.length)&&!me(e)},Ze=9007199254740991,et=/^(?:0|[1-9]\d*)$/,tt=function(e,t){var n=typeof e;return!!(t=null==t?Ze:t)&&("number"==n||"symbol"!=n&&et.test(e))&&e>-1&&e%1==0&&e1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(i=e.length>3&&"function"==typeof i?(o--,i):void 0,s&&nt(n[0],n[1],s)&&(i=o<3?void 0:i,o=1),t=Object(t);++r0?2==o.length?"function"==typeof o[1]?e[o[0]]=o[1].call(this,s):e[o[0]]=o[1]:3==o.length?"function"!=typeof o[1]||o[1].exec&&o[1].test?e[o[0]]=s?s.replace(o[1],o[2]):void 0:e[o[0]]=s?o[1].call(this,s,o[2]):void 0:4==o.length&&(e[o[0]]=s?o[3].call(this,s.replace(o[1],o[2])):void 0):e[o]=s||void 0;a+=2}return e},str:function(e,t){for(var n in t)if("object"==typeof t[n]&&t[n].length>0){for(var r=0;r>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)},Lt={apiEndpoint:"127.0.0.1:8787",cookieExpiration:3650,cookieName:"imgLos_id",domain:"",includeReferrer:!1,includeUtm:!1,language:{language:navigator&&(navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage)||void 0}.language,logLevel:"WARN",optOut:!1,platform:"Web",savedMaxCount:1e3,saveEvents:!0,sessionTimeout:18e5,unsentKey:"imgLos_unsent",unsentIdentifyKey:"imgLos_unsent_identify",uploadBatchSize:100,batchEvents:!1,eventUploadThreshold:30,eventUploadPeriodMillis:3e4,forceHttps:!1,includeGclid:!1,saveParamsReferrerOncePerSession:!0,deviceIdFromUrlParam:!1},Mt=function(e){this._instanceName=L.isEmptyString(e)?f.DEFAULT_INSTANCE:e.toLowerCase(),this._legacyStorageSuffix=this._instanceName===f.DEFAULT_INSTANCE?"":"_"+this._instanceName,this._unsentEvents=[],this._unsentIdentifys=[],this._ua=new Ut(navigator.userAgent).getResult(),this.options=xt({},Lt),this.cookieStorage=(new Y).getStorage(),this._q=[],this._sending=!1,this._updateScheduled=!1,this._eventId=0,this._identifyId=0,this._lastEventTime=null,this._newSession=!1,this._sequenceNumber=0,this._sessionId=null,this._userAgent=navigator&&navigator.userAgent||null};Mt.prototype.Identify=Q,Mt.prototype.Revenue=Ft,Mt.prototype.init=function(e,t,n,r){if("string"!==A(e)||L.isEmptyString(e))L.log.error("Invalid apiKey. Please re-initialize with a valid apiKey");else try{if(this.options.apiKey=e,this._storageSuffix="_"+e+this._legacyStorageSuffix,qt(this.options,n),this.cookieStorage.options({expirationDays:this.options.cookieExpiration,domain:this.options.domain}),this.options.domain=this.cookieStorage.options().domain,this._instanceName===f.DEFAULT_INSTANCE&&Vt(this),Gt(this),this.options.deviceId="object"===A(n)&&"string"===A(n.deviceId)&&!L.isEmptyString(n.deviceId)&&n.deviceId||this.options.deviceIdFromUrlParam&&this._getDeviceIdFromUrlParam(this._getUrlParams())||this.options.deviceId||Dt()+"R",this.options.userId="string"===A(t)&&!L.isEmptyString(t)&&t||"number"===A(t)&&t.toString()||this.options.userId||null,this.options.saveEvents){this._unsentEvents=this._loadSavedUnsentEvents(this.options.unsentKey),this._unsentIdentifys=this._loadSavedUnsentEvents(this.options.unsentIdentifyKey);for(var o=0;othis.options.sessionTimeout)&&(this._newSession=!0,this._sessionId=p,this.options.saveParamsReferrerOncePerSession&&this._trackParamsAndReferrer()),this.options.saveParamsReferrerOncePerSession||this._trackParamsAndReferrer(),this._lastEventTime=p,Kt(this),this._sendEventsIfReady()}catch(e){L.log.error(e)}finally{"function"===A(r)&&r(this)}},Mt.prototype._trackParamsAndReferrer=function(){this.options.includeUtm&&this._initUtmData(),this.options.includeReferrer&&this._saveReferrer(this._getReferrer()),this.options.includeGclid&&this._saveGclid(this._getUrlParams())};var qt=function(e,t){if("object"===A(t)){var n=function(n){if(Lt.hasOwnProperty(n)){var r=t[n],o=A(Lt[n]);L.validateInput(r,n+" option",o)&&("boolean"===o?e[n]=!!r:("string"===o&&!L.isEmptyString(r)||"number"===o&&r>0)&&(e[n]=r))}};for(var r in t)t.hasOwnProperty(r)&&n(r)}};Mt.prototype.runQueuedFunctions=function(){for(var e=0;e=this.options.eventUploadThreshold?(this.sendEvents(e),!0):(this._updateScheduled||(this._updateScheduled=!0,setTimeout(function(){this._updateScheduled=!1,this.sendEvents()}.bind(this),this.options.eventUploadPeriodMillis)),!1):(this.sendEvents(e),!0))},Mt.prototype._getFromStorage=function(e,t){return e.getItem(t+this._storageSuffix)},Mt.prototype._getFromStorageLegacy=function(e,t){return e.getItem(t+this._legacyStorageSuffix)},Mt.prototype._setInStorage=function(e,t,n){e.setItem(t+this._storageSuffix,n)};var Vt=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"!==A(t)&&(t=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix),!("object"===A(t)&&t.deviceId&&t.sessionId&&t.lastEventTime))){var n=function(e){var t=W.getItem(e);return W.removeItem(e),t},r="string"===A(e.options.apiKey)&&"_"+e.options.apiKey.slice(0,6)||"",o=n(f.DEVICE_ID+r),i=n(f.USER_ID+r),s=n(f.OPT_OUT+r);null!==s&&void 0!==s&&(s="true"===String(s));var a=parseInt(n(f.SESSION_ID)),u=parseInt(n(f.LAST_EVENT_TIME)),c=parseInt(n(f.LAST_EVENT_ID)),p=parseInt(n(f.LAST_IDENTIFY_ID)),l=parseInt(n(f.LAST_SEQUENCE_NUMBER)),d=function(e){return"object"===A(t)&&t[e]};e.options.deviceId=d("deviceId")||o,e.options.userId=d("userId")||i,e._sessionId=d("sessionId")||a||e._sessionId,e._lastEventTime=d("lastEventTime")||u||e._lastEventTime,e._eventId=d("eventId")||c||e._eventId,e._identifyId=d("identifyId")||p||e._identifyId,e._sequenceNumber=d("sequenceNumber")||l||e._sequenceNumber,e.options.optOut=s||!1,t&&void 0!==t.optOut&&null!==t.optOut&&(e.options.optOut="true"===String(t.optOut)),Kt(e)}},Gt=function(e){var t=e.cookieStorage.get(e.options.cookieName+e._storageSuffix);if("object"===A(t))Bt(e,t);else{var n=e.cookieStorage.get(e.options.cookieName+e._legacyStorageSuffix);"object"===A(n)&&(e.cookieStorage.remove(e.options.cookieName+e._legacyStorageSuffix),Bt(e,n))}},Bt=function(e,t){t.deviceId&&(e.options.deviceId=t.deviceId),t.userId&&(e.options.userId=t.userId),null!==t.optOut&&void 0!==t.optOut&&(e.options.optOut=t.optOut),t.sessionId&&(e._sessionId=parseInt(t.sessionId)),t.lastEventTime&&(e._lastEventTime=parseInt(t.lastEventTime)),t.eventId&&(e._eventId=parseInt(t.eventId)),t.identifyId&&(e._identifyId=parseInt(t.identifyId)),t.sequenceNumber&&(e._sequenceNumber=parseInt(t.sequenceNumber))},Kt=function(e){e.cookieStorage.set(e.options.cookieName+e._storageSuffix,{deviceId:e.options.deviceId,userId:e.options.userId,optOut:e.options.optOut,sessionId:e._sessionId,lastEventTime:e._lastEventTime,eventId:e._eventId,identifyId:e._identifyId,sequenceNumber:e._sequenceNumber})};Mt.prototype._initUtmData=function(e,t){e=e||this._getUrlParams();var n=function(e,t){var n=e?"?"+e.split(".").slice(-1)[0].replace(/\|/g,"&"):"",r=function(e,t,n,r){return L.getQueryParam(e,t)||L.getQueryParam(n,r)},o=r("utm_source",t,"utmcsr",n),i=r("utm_medium",t,"utmcmd",n),s=r("utm_campaign",t,"utmccn",n),a=r("utm_term",t,"utmctr",n),u=r("utm_content",t,"utmcct",n),c={},p=function(e,t){L.isEmptyString(t)||(c[e]=t)};return p("utm_source",o),p("utm_medium",i),p("utm_campaign",s),p("utm_term",a),p("utm_content",u),c}(t=t||this.cookieStorage.get("__utmz"),e);zt(this,n)};var zt=function(e,t){if("object"===A(t)&&0!==Object.keys(t).length){var n=new Q;for(var r in t)t.hasOwnProperty(r)&&(n.setOnce("initial_"+r,t[r]),n.set(r,t[r]));e.identify(n)}};Mt.prototype._getReferrer=function(){return document.referrer},Mt.prototype._getUrlParams=function(){return location.search},Mt.prototype._saveGclid=function(e){var t=L.getQueryParam("gclid",e);if(!L.isEmptyString(t)){zt(this,{gclid:t})}},Mt.prototype._getDeviceIdFromUrlParam=function(e){return L.getQueryParam(f.AMP_DEVICE_ID_PARAM,e)},Mt.prototype._getReferringDomain=function(e){if(L.isEmptyString(e))return null;var t=e.split("/");return t.length>=3?t[2]:null},Mt.prototype._saveReferrer=function(e){if(!L.isEmptyString(e)){var t={referrer:e,referring_domain:this._getReferringDomain(e)};zt(this,t)}},Mt.prototype.saveEvents=function(){try{this._setInStorage(W,this.options.unsentKey,JSON.stringify(this._unsentEvents))}catch(e){}try{this._setInStorage(W,this.options.unsentIdentifyKey,JSON.stringify(this._unsentIdentifys))}catch(e){}},Mt.prototype.setDomain=function(e){if(L.validateInput(e,"domain","string"))try{this.cookieStorage.options({domain:e}),this.options.domain=this.cookieStorage.options().domain,Gt(this),Kt(this)}catch(e){L.log.error(e)}},Mt.prototype.setUserId=function(e){try{this.options.userId=void 0!==e&&null!==e&&""+e||null,Kt(this)}catch(e){L.log.error(e)}},Mt.prototype.setGroup=function(e,t){if(this._apiKeySet("setGroup()")&&L.validateInput(e,"groupType","string")&&!L.isEmptyString(e)){var n={};n[e]=t;var r=(new Q).set(e,t);this._logEvent(f.IDENTIFY_EVENT,null,null,r.userPropertiesOperations,n,null,null)}},Mt.prototype.setOptOut=function(e){if(L.validateInput(e,"enable","boolean"))try{this.options.optOut=e,Kt(this)}catch(e){L.log.error(e)}},Mt.prototype.setSessionId=function(e){if(L.validateInput(e,"sessionId","number"))try{this._sessionId=e,Kt(this)}catch(e){L.log.error(e)}},Mt.prototype.regenerateDeviceId=function(){this.setDeviceId(Dt()+"R")},Mt.prototype.setDeviceId=function(e){if(L.validateInput(e,"deviceId","string"))try{L.isEmptyString(e)||(this.options.deviceId=""+e,Kt(this))}catch(e){L.log.error(e)}},Mt.prototype.setUserProperties=function(e){if(this._apiKeySet("setUserProperties()")&&L.validateInput(e,"userProperties","object")){var t=L.truncate(L.validateProperties(e));if(0!==Object.keys(t).length){var n=new Q;for(var r in t)t.hasOwnProperty(r)&&n.set(r,t[r]);this.identify(n)}}},Mt.prototype.clearUserProperties=function(){if(this._apiKeySet("clearUserProperties()")){var e=new Q;e.clearAll(),this.identify(e)}};var Jt=function(e,t){for(var n=0;n0)return this._logEvent(f.IDENTIFY_EVENT,null,null,e.userPropertiesOperations,null,null,t)}else L.log.error("Invalid identify input type. Expected Identify object but saw "+A(e));"function"===A(t)&&t(0,"No request sent")}else"function"===A(t)&&t(0,"No request sent")},Mt.prototype.setVersionName=function(e){L.validateInput(e,"versionName","string")&&(this.options.versionName=e)},Mt.prototype._logEvent=function(e,t,n,r,o,i,s){if(Gt(this),e&&!this.options.optOut)try{var a;a=e===f.IDENTIFY_EVENT?this.nextIdentifyId():this.nextEventId();var u=this.nextSequenceNumber(),c="number"===A(i)?i:(new Date).getTime();(!this._sessionId||!this._lastEventTime||c-this._lastEventTime>this.options.sessionTimeout)&&(this._sessionId=c),this._lastEventTime=c,Kt(this),r=r||{},n=n||{},t=t||{},o=o||{};var p={device_id:this.options.deviceId,user_id:this.options.userId,timestamp:c,event_id:a,session_id:this._sessionId||-1,event_type:e,version_name:this.options.versionName||null,platform:this.options.platform,os_name:this._ua.browser.name||null,os_version:this._ua.browser.major||null,device_model:this._ua.os.name||null,language:this.options.language,api_properties:n,event_properties:L.truncate(L.validateProperties(t)),user_properties:L.truncate(L.validateProperties(r)),uuid:Dt(),library:{name:"imgLos-js",version:"1.0.0"},sequence_number:u,groups:L.truncate(L.validateGroups(o)),user_agent:this._userAgent};return e===f.IDENTIFY_EVENT?(this._unsentIdentifys.push(p),this._limitEventsQueued(this._unsentIdentifys)):(this._unsentEvents.push(p),this._limitEventsQueued(this._unsentEvents)),this.options.saveEvents&&this.saveEvents(),this._sendEventsIfReady(s)||"function"!==A(s)||s(0,"No request sent"),a}catch(e){L.log.error(e)}else"function"===A(s)&&s(0,"No request sent")},Mt.prototype._limitEventsQueued=function(e){e.length>this.options.savedMaxCount&&e.splice(0,e.length-this.options.savedMaxCount)},Mt.prototype.logEvent=function(e,t,n){return this.logEventWithTimestamp(e,t,null,n)},Mt.prototype.logEventWithTimestamp=function(e,t,n,r){return this._apiKeySet("logEvent()")&&L.validateInput(e,"eventType","string")&&!L.isEmptyString(e)?this._logEvent(e,t,null,null,null,n,r):("function"===A(r)&&r(0,"No request sent"),-1)},Mt.prototype.logEventWithGroups=function(e,t,n,r){return this._apiKeySet("logEventWithGroup()")&&L.validateInput(e,"eventType","string")?this._logEvent(e,t,null,null,n,null,r):("function"===A(r)&&r(0,"No request sent"),-1)};var $t=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};Mt.prototype.logRevenueV2=function(e){if(this._apiKeySet("logRevenueV2()"))if("object"===A(e)&&e.hasOwnProperty("_q")&&(e=Jt(new Ft,e)),e instanceof Ft){if(e&&e._isValidRevenue())return this.logEvent(f.REVENUE_EVENT,e._toJSONObject())}else L.log.error("Invalid revenue input type. Expected Revenue object but saw "+A(e))},Mt.prototype.logRevenue=function(e,t,n){return this._apiKeySet("logRevenue()")&&$t(e)&&(void 0===t||$t(t))?this._logEvent(f.REVENUE_EVENT,{},{productId:n,special:"revenue_amount",quantity:t||1,price:e},null,null,null,null):-1},Mt.prototype.removeEvents=function(e,t){Wt(this,"_unsentEvents",e),Wt(this,"_unsentIdentifys",t)};var Wt=function(e,t,n){if(!(n<0)){for(var r=[],o=0;on&&r.push(e[t][o]);e[t]=r}};Mt.prototype.sendEvents=function(e){if(!this._apiKeySet("sendEvents()")||this._sending||this.options.optOut||0===this._unsentCount())"function"===A(e)&&e(0,"No request sent");else{this._sending=!0;var t=(this.options.forceHttps?"https":"https:"===window.location.protocol?"https":"http")+"://"+this.options.apiEndpoint+"/",n=Math.min(this._unsentCount(),this.options.uploadBatchSize),r=this._mergeEventsAndIdentifys(n),o=r.maxEventId,i=r.maxIdentifyId,s=JSON.stringify(r.eventsToSend),a=(new Date).getTime(),u={client:this.options.apiKey,e:s,v:f.API_VERSION,upload_time:a,checksum:X(f.API_VERSION+this.options.apiKey+s+a)},c=this;new Pt(t,u).send(function(t,r){c._sending=!1;try{200===t&&"success"===r?(c.removeEvents(o,i),c.options.saveEvents&&c.saveEvents(),c._sendEventsIfReady(e)||"function"!==A(e)||e(t,r)):413===t?(1===c.options.uploadBatchSize&&c.removeEvents(o,i),c.options.uploadBatchSize=Math.ceil(n/2),c.sendEvents(e)):"function"===A(e)&&e(t,r)}catch(e){}})}},Mt.prototype._mergeEventsAndIdentifys=function(e){for(var t=[],n=0,r=-1,o=0,i=-1;t.length=this._unsentIdentifys.length,u=n>=this._unsentEvents.length;if(u&&a){L.log.error("Merging Events and Identifys, less events and identifys than expected");break}a?r=(s=this._unsentEvents[n++]).event_id:u?i=(s=this._unsentIdentifys[o++]).event_id:!("sequence_number"in this._unsentEvents[n])||this._unsentEvents[n].sequence_number