diff --git a/README.md b/README.md new file mode 100644 index 0000000..a672a15 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# THEME - ANIMEH 2023 - VSMOV CMS + +## Demo +### Trang Chủ + + +### Trang Danh Sách Phim + + +### Trang Thông Tin Phim + + +### Trang Xem Phim + + +## Requirements +https://github.com/vsphim/vsmov-core + +## Install +1. Tại thư mục của Project: `composer require vsmov/theme-animeh` +2. Kích hoạt giao diện trong Admin Panel + +## Update +1. Tại thư mục của Project: `composer update vsmov/theme-animeh` +2. Re-Activate giao diện trong Admin Panel + +## Note +- Một vài lưu ý quan trọng của các nút chức năng: + + `Activate` và `Re-Activate` sẽ publish toàn bộ file js,css trong themes ra ngoài public của laravel. + + `Reset` reset lại toàn bộ cấu hình của themes + +## Document +### List +- Home page: `display_label|relation|find_by_field|value|sort_by_field|sort_algo|limit|show_more_url` +#### + Phim chiếu rạp mới||is_shown_in_theater|1|created_at|desc|10|/danh-sach/phim-chieu-rap + Phim bộ mới||type|series|updated_at|desc|10|/danh-sach/phim-bo + Phim lẻ mới||type|single|updated_at|desc|10|/danh-sach/phim-le + Phim hoạt hình mới|categories|slug|hoat-hinh|updated_at|desc|10|/the-loai/hoat-hinh + Top phim||is_copyright|0|view_week|desc|10|# +#### + +### Custom View Blade +- File blade gốc trong Package: `/vendor/vsmov/vsmov-animeh/resources/views/themeanimeh` +- Copy file cần custom đến: `/resources/views/vendor/themes/animeh` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9ef2674 --- /dev/null +++ b/composer.json @@ -0,0 +1,32 @@ +{ + "name": "vsmov/theme-animeh", + "description": "VsMov's animeh theme", + "type": "library", + "authors": [ + { + "name": "vsmov", + "email": "vsmov@gmail.com" + } + ], + "require": { + "laravel/framework": "^6|^7|^8", + "ckfinder/ckfinder-laravel-package": "v3.5.2.1", + "vsmov/vsmov-core": "^1.0.0" + }, + "license": "MIT", + "autoload": { + "psr-4": { + "VsMov\\ThemeAnimeH\\": "src/", + "VsMov\\ThemeAnimeH\\Database\\Factories\\": "database/factories/", + "VsMov\\ThemeAnimeH\\Database\\Seeders\\": "database/seeders/" + } + }, + "extra": { + "laravel": { + "providers": [ + "VsMov\\ThemeAnimeH\\ThemeAnimeHServiceProvider" + ] + } + }, + "minimum-stability": "stable" +} diff --git a/resources/assets/css/css.css b/resources/assets/css/css.css new file mode 100644 index 0000000..acc5b3f --- /dev/null +++ b/resources/assets/css/css.css @@ -0,0 +1,2121 @@ +@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap"); +/* fallback */ +@font-face { + font-family: "Material Icons Round"; + font-style: normal; + font-weight: 400; + src: url(https://fonts.gstatic.com/s/materialiconsround/v73/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2) + format("woff2"); +} +.swal2-container { + z-index: 1600!important; +} +/* #ad-floating-left, +#ad-floating-right, +#top-banner-pc, +#top-banner-mb, +#bot-banner-pc, +#bot-banner-mb { + z-index: 0; +} */ +.display-block { + display: block !important; +} +.display-none { + display: none; +} +.align-center { + text-align: center; +} +.align-right { + text-align: right; +} +.material-icons-round { + font-family: "Material Icons Round"; + font-weight: normal; + font-style: normal; + /* font-size: 24px; */ + line-height: 1; + /* margin-right: 5px; */ + letter-spacing: normal; + text-transform: none; + display: inline-block; + white-space: nowrap; + word-wrap: normal; + direction: ltr; + -webkit-font-feature-settings: "liga"; + -webkit-font-smoothing: antialiased; +} +.scroll-bar::-webkit-scrollbar { + width: 10px; + height: 10px; + background-color: #404040; +} + +.scroll-bar::-webkit-scrollbar-thumb { + background-color: #55928c; +} +.cursor-pointer { + cursor: pointer; +} +/* view profile */ +div#view-profile .avatar img { + width: 120px; + border-radius: 10px; + padding: 2px; + background: #000; + border: 1px solid #8d8d8d; +} +div#view-profile > div > div > div > span:first-child { + margin-right: 5px; +} +div#view-profile > div > div > div { + margin: 7px; + font-weight: 500; +} +/* modal */ +#view-profile .avatar .level { + color: #fff; + background: #000; + box-shadow: 0 0 4px 2px; +} +.modal, +#view-profile, +#middle-box-screen { + display: none; + border-radius: 10px; + position: fixed; /* Stay in place */ + z-index: 9999; /* Sit on top */ + max-width: 500px; + top: 25%; + background: #212121; + padding: 10px; + box-sizing: border-box; + -webkit-box-shadow: 1px 1px 27px 1px rgb(193 193 193 / 75%); + -moz-box-shadow: 1px 1px 27px 1px rgb(193 193 193 / 75%); + box-shadow: 1px 1px 27px 1px rgb(193 193 193 / 75%); +} + +.modal > div > div:first-child + a { + font-size: 20px; + padding: 5px 10px; + top: 0; + background: firebrick; + box-sizing: border-box; + display: inline-block; +} +.modal > div:first-child > div:first-child { + flex: 1; +} +.modal > div:first-child { + display: flex; + align-items: center; + font-size: 20px; + padding-bottom: 10px; +} +/* noti */ +.noti-info { + background: #6d6d6d; + color: #ccc; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-shadow: 1px 1px 1px 1px #000; +} +.noti-error { + background: #b73a3a; + color: #ccc; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-shadow: 1px 1px 1px 1px #000; +} +.noti-warning { + background: #d4a30f; + color: #ccc; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-shadow: 1px 1px 1px 1px #000; +} +.noti-success { + background: #297275; + color: #ccc; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-shadow: 1px 1px 1px 1px #000; +} + +/* loading */ +.loading-cover:after { + content: "Loading..."; + width: 100%; + position: absolute; + height: 100%; + font-size: 25px; + top: -10px; + left: -10px; + padding: 10px; + display: flex; + font-weight: 700; + background: rgba(0, 0, 0, 0.5); + align-items: center; + justify-content: center; +} +.ah_loading { + justify-content: center; + flex: 1; + display: flex; +} +.lds-ellipsis { + display: inline-block; + position: relative; + width: 80px; + height: 80px; +} +.lds-ellipsis div { + position: absolute; + top: 33px; + width: 13px; + height: 13px; + border-radius: 50%; + background: #fff; + animation-timing-function: cubic-bezier(0, 1, 1, 0); +} +.lds-ellipsis div:nth-child(1) { + left: 8px; + animation: lds-ellipsis1 0.6s infinite; +} +.lds-ellipsis div:nth-child(2) { + left: 8px; + animation: lds-ellipsis2 0.6s infinite; +} +.lds-ellipsis div:nth-child(3) { + left: 32px; + animation: lds-ellipsis2 0.6s infinite; +} +.lds-ellipsis div:nth-child(4) { + left: 56px; + animation: lds-ellipsis3 0.6s infinite; +} +@keyframes lds-ellipsis1 { + 0% { + transform: scale(0); + } + 100% { + transform: scale(1); + } +} +@keyframes lds-ellipsis3 { + 0% { + transform: scale(1); + } + 100% { + transform: scale(0); + } +} +@keyframes lds-ellipsis2 { + 0% { + transform: translate(0, 0); + } + 100% { + transform: translate(24px, 0); + } +} +/* select option */ +.select-option .select { + display: flex; + flex-direction: column; + position: relative; + width: 250px; + height: 40px; +} + +.select-option .option { + padding: 0 30px 0 10px; + min-height: 40px; + display: flex; + align-items: center; + background: #333; + border-top: #222 solid 1px; + position: absolute; + top: 0; + width: 100%; + pointer-events: none; + order: 2; + z-index: 1; + transition: background 0.4s ease-in-out; + box-sizing: border-box; + overflow: hidden; + white-space: nowrap; +} + +.select-option .option:hover { + background: #666; +} + +.select-option:focus .option { + position: relative; + pointer-events: all; +} + +.select-option input { + opacity: 0; + position: absolute; + left: -99999px; +} + +.select-option input:checked + label { + order: 1; + z-index: 2; + background: #666; + border-top: none; + position: relative; +} + +.select-option input:checked + label:after { + content: ""; + width: 0; + height: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-top: 5px solid white; + position: absolute; + right: 10px; + top: calc(50% - 2.5px); + pointer-events: none; + z-index: 3; +} + +.select-option input:checked + label:before { + position: absolute; + right: 0; + height: 40px; + width: 40px; + content: ""; + background: #666; +} + +.list-item-episode a:hover { + opacity: 0.7; +} + +html { + scroll-behavior: smooth; +} + +body { + font-size: 14px; + font-family: "Roboto", sans-serif; + font-weight: 400; + color: #ccc; + line-height: normal; + /* background-color: #5a5454; */ + background-color: #000; + + margin: 0; + padding: 0; + position: relative; + /* background-image: url("/themes/img/bg-haloween.png"); */ + /* background-image: url("/themes/img/bg-haloween.png"); */ + background-repeat: no-repeat; + background-size: contain; +} +a { + text-decoration: none; + color: #cac9c9; +} +h1, +h2, +h3, +h4,p { + margin: 0; +} +input, +button { + border: 0; + border-radius: 0; + margin: 0; +} +#adcontent +{ + width:2px; + height:2px; +} +button { + background: #ccc; +} +*:focus { + outline: none; +} +#ah_wrapper { + width: 1050px; + margin: 0 auto; + background: #2d2d2d; + position: relative; +} +.ah_content { + padding: 10px; +} +.flex_center { + display: flex; + justify-content: center; + margin: 10px 0; +} +.relative { + position: relative; +} +/** **/ +@keyframes goPage { + from { + bottom: 0%; + } + to { + bottom: 100%; + } +} +/* ranking */ +.ranking { + display: flex; + justify-content: space-between; +} + +.ranking > div { + width: 49%; + order: 1; +} + +.list_ranking .item:nth-child(1) a { + color: #fce173; + box-shadow: 0 0 5px 5px; +} + +.list_ranking .item:nth-child(2) a { + color: #d8d8d8; + box-shadow: 0 0 5px 5px; +} + +.list_ranking .item:nth-child(3) a { + color: #ff861c; + box-shadow: 0 0 5px 5px; +} +.list_ranking .item a { + height: 70px; + display: flex; + justify-content: center; + align-items: center; + padding: 5px; + margin-bottom: 15px; + background: #000; + font-family: "Arima Madurai", cursive; +} + +.list_ranking .item a > div { + padding: 0 5px; +} + +.list_ranking .item a > div img { + width: 100%; +} + +.list_ranking .item a > div:nth-child(2) img { + padding: 3px; + box-sizing: border-box; + background: #585858; +} + +.list_ranking .item a > div:nth-child(1) { + width: 10%; +} + +.list_ranking .item a > div:nth-child(2) { + width: 10%; +} + +.list_ranking .item a > div:nth-child(3) { + width: 80%; +} +.list_ranking .item a > div:nth-child(3) > div:first-child { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.list_ranking .item a > div:nth-child(3) > div:last-child { + color: #adadad; +} +/* .ranking>h1 +{ + text-align:center; +} */ +.ranking > div > h2 { + font-size: 17px; + color: #cacaca; + background: #000; + padding: 10px; + display: inline-block; + border-top: 1px solid #ea6b6a; + margin-bottom: 15px; +} +.ranking_heading { + text-align: center; + color: #ff7272; +} + +.ranking_heading h1 { + font-size: 19px; +} + +.ranking_heading a { + font-size: 30px; + color: #d1ff46; +} +/* */ +.result-of-search { + display: flex; + flex-wrap: wrap; + max-height: 400px; + overflow: auto; + overflow-x: hidden; + background: #000; + padding: 5px; +} +.result-of-search a { + display: flex; + width: 50%; + box-sizing: border-box; + padding: 5px 2px; + border-bottom: 1px solid #3e3e3e; +} +.result-of-search a div.row_one { + width: 10%; + display: inline-flex; +} +.result-of-search a img { + width: 100%; + height: 50px; +} +.result-of-search a > div.row_two { + width: 90%; + padding-left: 15px; +} +.result-of-search a > div.row_two span { + display: block; + color: #fff; +} +.result-of-search a > div.row_two span:last-child { + opacity: 0.7; +} + +/* navigation */ +#navbar .live-search { + position: absolute; + width: 100%; + background: #000; + z-index: 9; +} +div#navbar { + position: relative; + border-bottom: 1px solid #424242; +} + +#navbar .nav-items a { + padding: 7px 10px; + margin: 3px 3px; + font-size: 20px; + display: inline-flex; + background-color: #000; + border: 1px solid #404040; +} + +div#navbar .logo img { + width: 200px; +} + +#navbar .search-bar button { + font-size: 25px; + margin: 0 !important; + padding: 0 5px !important; +} +#navbar form { + border: 1px solid #404040; + min-width: 250px; + flex: 0.9; + margin: 0; +} +#navbar a.toggle-search { + display: none; +} +#navbar .search-bar input { + width: 100%; +} +#navbar .nav-items a:hover { + opacity: 0.7; +} +#drop-down-menu { + display: none; +} +.dropdown-menu a:hover { + background: #2d2d2d; +} +.dropdown-option { + margin-top: 10px; + margin-left: -100%; + border-left: 5px solid #3e3e3e; + box-sizing: border-box; +} +.dropdown-option > div:hover { + cursor: pointer; + background: #3e3e3e; +} +.dropdown-option > div { + display: flex; + padding: 10px 10px; + width: 100%; +} +.dropdown-menu, +.dropdown-option { + position: absolute; + top: 100%; + z-index: 1501; + display: none; + flex-wrap: wrap; + transform: scale(0.5); + transition: transform 0.1s cubic-bezier(0.1, 1, 1, 1); +} +#drop-down-2 .row-1 { + padding: 20px 10px; + width: 100%; + box-sizing: border-box; +} +#drop-down-2 .row-1 .avatar { + width: 100px; + height: 100px; + border-radius: 50%; + overflow: hidden; +} +#drop-down-2 .row-1 .nickname { + width: 100px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + text-align: center; +} +#drop-down-2 .row-1 .avatar img { + width: inherit; +} +#drop-down-2 { + right: 0; +} +#drop-down-1 { + left: 0; +} + +#drop-down-2 a { + padding: 20px 10px; + width: 100%; + box-sizing: border-box; +} +#drop-down-1 .tab-content a:hover { + background: #3e3e3e; +} +#drop-down-1 .tab-content a { + width: 20%; + text-align: center; + padding: 10px; + box-sizing: border-box; + border: 1px solid #141414; + font-size: 13px; + background: #000000; +} +/* movies-list */ + +.movies-list .movie-item { + width: 20%; + margin-bottom: 5px; + background: #000; + padding: 5px; + box-sizing: border-box; + position: relative; + border: 2px solid #404040; +} + +.movies-list { + display: flex; + flex-wrap: wrap; + align-items: center; +} +.movies-list .movie-item .episode-latest { + position: absolute; + left: 10px; + top: 10px; + padding: 5px 10px; + background-color: #383838; + font-weight: 700; + font-size: 14px; + border-radius: 4px; + border: 3px double #5a5a5a; + letter-spacing: 1px; +} +.movies-list .movie-item .score { + position: absolute; + right: 10px; + bottom: 37px; + padding: 5px 10px; + background-color: #903a3a; + font-weight: 700; + font-size: 12px; + border-radius: 4px; +} +.movie-item .intro { + padding: 5px 0 2px; +} +.movies-list .movie-item img { + width: 100%; + height: 235px; + display: block; +} +.movies-list .movie-item .row_one { + display: flex; + justify-content: space-between; + padding-bottom: 6px; + color: #ccc; + background: black; + font-size: 13px; +} +.movies-list .movie-item .row_one span:last-child { + color: #ff6060 !important; +} +.movies-list .movie-item .name-movie { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + margin-top: 5px; + padding: 3px 5px; + text-align: center; + color: #cc8d4c; + font-weight: 700; +} +.movies-list .movie-item:hover, +.owl-carousel .owl-item:hover { + background: #000; + opacity: 0.7; +} +.movie-following { + position: absolute; + top: 10px; + right: 10px; + padding: 3px; + background-color: #bf914c; + font-weight: 700; + font-size: 20px; + border-radius: 4px; + letter-spacing: 1px; + display: inline-flex; +} +/** notification **/ +div#list-item-notification { + max-height: 500px; + overflow: auto; +} +#drop-down-3 { + right: 0; + min-width: 200px; +} +.load-notification .badge { + position: absolute; + bottom: 70%; + left: 70%; + background: #d85050; + padding: 5px 10px; + border-radius: 50%; + font-size: 13px; + z-index: 2; +} +.notification.visited, +.notification.visited div, +.notification.visited span { + color: #939393 !important; +} +.notification { + color: #fff; +} +.notification-comment .avatar { + width: 50px; + height: 50px; + overflow: hidden; + border-radius: 50%; +} +.notification-comment .avatar img { + width: 100%; +} +.notification-comment:hover { + cursor: pointer; + background-color: #3e3e3e; +} +.notification-comment { + padding: 10px; +} +/** slide home **/ +.owl-item .episode_latest { + position: absolute; + top: 3px; + border-radius: 10%; + padding: 5px 10px; + /* font-size: 14px; */ + left: 3px; + background: #883636; + font-weight: 700; +} + +.owl-item > div { + position: relative; +} + +.opacity { + opacity: 0; + display: flex; + font-size: 5px; +} +.owl-carousel.owl-drag .owl-item div .name { + position: absolute; + z-index: 100; + background: rgb(58 58 58 / 80%); + background: linear-gradient( + 0deg, + rgb(0 0 0 / 50%) 0%, + rgb(25 25 25 / 50%) 28%, + rgb(37 37 37 / 0%) 78% + ); + bottom: 0; + width: 100%; + text-align: center; + color: #fff; + padding: 10px; + box-sizing: border-box; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-weight: 700; + font-size: 16px; +} + +.owl-carousel .owl-item img { + height: 270px; +} +#filter-movie { + margin-bottom: 10px; + border: 1px solid #4c4c4c; + background: #1d1c1c; +} +/* ah_filter */ +.trigger-buttons div { + display: flex; + justify-content: center; + align-items: center; + width: 20%; + padding: 10px 0; + box-sizing: border-box; + font-weight: 500; +} +.condition-filter > div { + display: none; +} +.condition-filter, +#filter-submit { + background: #1d1c1c; + /* padding: 10px; */ +} +.condition-filter > div > div > div:hover { + background: #3e3e3e; + cursor: pointer; +} +.condition-filter > div > div > div { + background: #444; + padding: 10px; + margin: 2px; + font-size: 13px; +} + +.condition-filter > div { + padding: 5px; + border-top: 2px solid #3a79af; +} + +.condition-filter > div:last-child { + margin-bottom: 0; +} +div#filtering div { + background: #000; + margin: 2px; + padding: 8px; + border-radius: 5px; + border: 1px solid #424242; +} + +div#filtering { + margin-bottom: 10px; +} +/* info-movie */ +.bind_movie div:last-child { + max-width: 100%; + overflow: auto; + white-space: nowrap; + overflow-x: auto; + padding: 5px 0; +} +.bind_movie a { + background: #6b6a6a; + padding: 8px 15px; + display: inline-block; + border-radius: 4px; + margin-right: 5px; +} +.bind_movie a.active { + background: #27867d; +} +.bind_movie a:hover { + opacity: 0.7; +} +.info-movie .button { + display: flex; + align-items: center; +} +.info-movie .button .first a:hover { + opacity: 0.5; +} +.info-movie .button .first { + flex: 1; +} +.info-movie .button .first a { + background: #b96060; + padding: 14px; + display: inline-block; + font-size: 15px; + font-weight: 600; + border-radius: 3px; +} +.info-movie .heading_movie { + padding: 10px; + background: #3a3a3a; + font-size: 17px; + text-align: center; + border-top: 2px solid #000; +} +.info-movie .button .first a:first-child { + background: #45965e; +} +.info-movie .rating { + font-size: 30px; + color: #ffe290; +} +.modal > div:last-child { + text-align: center; + padding-bottom: 10px; +} +.info-movie .rated-star { + font-size: 30px; +} +.info-movie .rated-star .active { + color: #ffe290; +} +.info-movie .rated-star span:hover { + font-size: 50px; +} +.info-movie .rated-star span { + position: relative; +} +.info-movie .rated-star span:hover:before { + content: "" attr(rate); + position: absolute; + font-size: 13px; + bottom: 100%; + width: 100%; + text-align: center; +} +.info-movie .body { + display: flex; + justify-content: space-between; +} + +.info-movie .body .desc { + flex: 0.7; +} +.info-movie .head .last > div:last-child { + margin-bottom: 0; +} +.info-movie .head { + display: flex; + align-items: center; + color: #fff; + background: #191919; + border-radius: 0 !important; +} +.info-movie .head .last { + margin-left: 10px; + width: 81%; +} +.info-movie .head img { + width: 100%; + display: block; +} +.info-movie .head .first { + width: 19%; + padding: 5px; + background: black; +} +.info-movie .head .last > div { + display: flex; + align-items: center; + border-bottom: 1px solid #2f2f2f; + border-top: 1px solid #000000; + padding: 5px; +} +.info-movie .head .last > div:first-child { + border-top: 0; +} +.info-movie .head .last > div:last-child { + border-bottom: 0; +} +.info-movie .head .last > div > div { + padding: 10px 5px; + flex: 0.8; +} +.info-movie .head .last > div > div:first-child { + flex: 0.2; + color: #a7a7a7; + font-weight: 700; +} +.info-movie .head .last > div > div:last-child { + text-align: center; + font-weight: 500; + color: #a7a7a7; +} +.info-movie .head .last > div.list_cate a { + background: #313131; + border-radius: 5px; + padding: 5px; + margin: 2px 2px; + display: inline-flex; + color: #ccc; +} +.info-movie .head .last > div.list_cate > div + div { + padding: 3px; +} +.info-movie .desc { + line-height: 1.2; +} +.latest_episode_is_readed { + padding-bottom: 5px; + font-size: 12px; + color: #e0e0e0; + text-align: center; +} +.flex-space-auto { + justify-content: space-between; + align-items: center; +} +.ah-frame-bg .heading { + font-size: 16px; + margin-bottom: 10px; + border-bottom: 1px dashed #2f2f2f; + padding-bottom: 10px; +} + +.ah-frame-bg { + background: #404040; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-sizing: border-box; +} + +#ah_wrapper > .ah_footer { + padding: 30px 5px; + border-top: 1px solid #525151; +} +#ah_wrapper > .ah_footer .logo-footer img { + width: 200px; +} +/* list-item-episode */ +.info-movie .list_episode { + flex: 0.29; +} +.info-movie .list_episode .list-item-episode { + display: flex; + flex-wrap: wrap; + justify-content: center; + max-height: 300px; + overflow: auto; + overflow-x: hidden; + padding-right: 10px; +} +.info-movie .list_episode .list-item-episode a { + background: #333232; + text-align: center; + padding: 10px 5px; + border: 1px solid #4e4e4e; + font-size: 13px; + width: 25%; + box-sizing: border-box; +} +.info-movie .list_episode .list-item-episode a:visited { + background: #0c0c0c; +} +.watching-movie .list-item-episode { + display: flex; + flex-wrap: wrap; + justify-content: center; + max-height: 400px; + overflow: auto; + overflow-x: hidden; + padding-right: 10px; +} +.watching-movie .list-item-episode a[active] { + background-color: #ce6464; +} +.watching-movie .list-item-episode a { + background: #333232; + display: flex; + align-items: center; + justify-content: center; + padding: 10px 5px; + border: 1px solid #4e4e4e; + font-size: 13px; + width: 5%; + box-sizing: border-box; +} +.list-item-episode a.active { + background-color: #ce6464 !important; +} +.list-item-episode a:visited { + background-color: #000; +} +.list-item-episode a:hover { + background-color: #bb6464 !important; +} +/** account **/ +.list-menu-account { + display: flex; + margin-bottom: 10px; + font-weight: 500; +} +.list-menu-account a { + background: #1c1c1c; + padding: 20px 10px; + flex: 1; + text-align: center; +} +.list-menu-account a.active { + background: #55918c; +} +/** paging **/ +.pagination { + display: flex; + justify-content: center; + padding: 10px 0; +} +.pagination > div { + position: relative; + display: flex; +} +.pagination > div > div { + color: #ccc; + position: absolute; + bottom: 100%; + box-sizing: border-box; + display: none; + width: 100%; + animation-duration: 0.2s; + animation-name: goPage; +} +.pagination > div > div form { + display: flex; + width: 100%; +} +.pagination > div > div input { + padding: 10px; + flex: 1; +} +.pagination > div > div button { + padding: 0 10px; + font-size: 20px; +} +.pagination a { + color: #f3dede; + float: left; + padding: 8px 16px; + background-color: #585858; + text-decoration: none; +} +.pagination #go_page { + bottom: 100%; + box-sizing: border-box; + padding: 10px; + border: 0; +} +.pagination a.active_page { + background-color: #4caf50; + color: white; +} + +.pagination a:hover:not(.active_page) { + background-color: #4caf50 !important; +} +/* zero-tab */ +.tab-links { + display: flex; + border-top: 2px solid #9c3737; +} + +.tab-links a { + background: #1c1c1c; + padding: 10px; + justify-content: center; + align-items: center; + display: flex; + flex: 1; + font-weight: 500; +} +.tab-content .item-tab-content { + display: none; +} +.tab-links a.active { + background: #9c3737; +} + +.frame-recharge { + display: flex; + flex-direction: column; +} + +.frame-recharge div { + flex: 1; +} +/* ah-form */ +.input-zero .label { + font-weight: 700; + background: #404040; + padding: 2px; + color: #ff9393; +} + +.input-zero { + line-height: 22px; + position: relative; + font-size: 15px; + margin-bottom: 5px; +} +.input-zero input[disabled] { + background-color: #000; +} +.input-zero input:focus { + background: #000; + border: 1px solid #ff9393; +} +.input-zero input { + padding: 12px; + border: 1px solid #4e4e4e; + color: #fff; + background-color: #505050; + width: 100%; + box-sizing: border-box; + transition: background 0.2s linear, border 0.2s linear; + border-radius: 5px; +} +.ah-form form { + width: 500px; +} +.ah-form form > div input { + line-height: 20px; + width: 100%; + margin: 10px 0; + padding: 10px; + background: #000; + opacity: 0.8; + color: #e6dddd !important; + box-sizing: border-box; +} + +.ah_member { + display: flex; + justify-content: space-between; +} + +.ah_member > div { + flex: 0.496; +} + +.ah-form form > div label { + display: block; +} + +.ah-form form > div input::placeholder { + color: #ababab; +} + +.ah-form button[name="action_register"] { + background: #37869e; + color: #fff; +} +.ah-form form > div { + margin: 10px 0; +} +.ah-form form label { + font-weight: 500; + font-size: 15px; +} +.ah-form div:last-child { + text-align: center; +} +/* profile page */ +div#user-profile .avatar img { + width: 100px; + border: 11px double #0c0c0c; + border-radius: 5px; +} +div#user-profile .right { + flex: 1; +} + +/*follows page*/ +.ah_follows .delete { + position: absolute; + z-index: 3; + right: 0; + background: #000; + padding: 5px 10px; + top: 0; + color: #fff; +} +.ah_follows .delete:hover { + background: #ff9090; +} + +/*watching-movie*/ + +.light-off { + background: #000; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; +} +.watching-movie #video-player { + z-index: 1500; + position: relative; +} +.watching-movie #episode_error { + display: none; +} +.watching-movie #episode_error input { + padding: 10px; + color: #000; + -webkit-appearance: none; + appearance: none; + background: #000; + color: #d0cdcd; + border: 1px solid #585858; +} + +.watching-movie .text_spinner { + margin-top: 15px; + font-size: 17px; + color: #63c5a8; + font-weight: bold; +} +/* history */ +.watch-history .item a:hover { + opacity: 0.5; +} +.watch-history .item a { + display: flex; + margin-bottom: 10px; + align-items: center; + color: #ccc; +} + +.watch-history .item a img { + width: 60px; +} +.watch-history .item a > div:first-child { + width: 60px; + height: 60px; + position: relative; + overflow: hidden; + border-radius: 36px; + z-index: 1; + border: 5px solid #737373; +} +.watch-history .item a > div:last-child { + flex: 1; + background: #000; + padding: 10px; + position: relative; + border: 1px solid #565656; + border-radius: 0 5px 5px 0; +} + +.watch-history .item a > div:last-child:before { + content: ""; + width: 25px; + height: 100%; + top: -1px; + right: 100%; + background: #000; + position: absolute; + z-index: 0; + border-width: 1px 0 1px 0; + border-style: solid; + border-color: #565656; +} +.watch-history { + display: flex; + flex-wrap: wrap; +} + +.watch-history .item { + width: 50%; + padding-right: 5px; + box-sizing: border-box; +} + +.watch-history .item a div:last-child div:last-child { + margin-top: 5px; +} +.watch-history .item a div:last-child div:first-child { + font-size: 15px; + color: #fff; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + max-width: 220px; +} +/* view_full_image */ +.view-full-image { + position: relative; + display: inline-block; + background: #000; +} + +.view-full-image img { + opacity: 0.5; +} + +.view-full-image .button-view { + display: inline-block; + position: absolute; + white-space: nowrap; + background: rgba(0, 0, 0, 0.5); + padding: 10px; +} +/* toast */ +#ah_toast { + position: fixed; + right: 20px; + bottom: 10px; + z-index: 11; +} +.toast_exit { + z-index: 20; +} +.toast-error { + color: #bb6767; +} +.toast-success { + color: #58b1c5; +} +.toast-warning { + color: #cac157; +} +.toast:hover { + cursor: pointer; +} +.toast { + display: block; + margin: 10px 0; + padding: 10px; + background: #000; + border-radius: 5px; + color: #ccc; +} +.toast_image { + width: 70px; + height: 70px; + border-radius: 50%; + overflow: hidden; +} +.toast_image img { + width: 70px; + min-height: 70px; + background: #3e3e3e; + padding: 2px; +} +.toast_footer { + margin-top: 3px; + display: flex; + justify-content: left; +} +.toast_time { + justify-content: right; + font-size: 11px; + color: #ccc; + font-weight: 500; +} +.toast_head { + display: flex; + font-weight: bold; + font-size: 18px; + border-bottom: 1px solid currentColor; + padding-bottom: 5px; + margin-bottom: 3px; + justify-content: space-between; +} +.toast_message { + padding: 5px 0; + font-weight: 700; +} +/* .toast_title { + color: #dc6f6f; +} */ + +/* button */ +.button-default { + background-color: #6b6a6a; + display: inline-flex; + border-radius: 5px; + margin: 0 2px; + padding: 10px; + border-bottom: 3px solid #292929; + cursor: pointer; +} +.button-default:hover { + opacity: 0.7; +} +/**/ +.text-shortcut { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + width: 230px; +} +.comment_fb { + background: #fbfbfb; +} +.ah_noti { + background: #000; + padding: 10px; + border-radius: 5px; + display: flex; + flex: 1; + justify-content: center; +} +/** color **/ +.color-black { + color: #000; +} +.color-white { + color: #fff; +} +.color-gray { + color: #a7a7a7; +} +.color-cod-gray { + color: #1d1c1c; +} +.color-red { + color: #b73a3a; +} +.color-red-2 { + color: #f98d8d; +} +.color-blue { + color: #3a79af; +} +.color-green { + color: #747924; +} +.color-green-2 { + color: #83bf64; +} +.color-brown { + color: #795548; +} +.color-orange { + color: #986a25; +} +.color-lochinvar { + color: #25867d; +} +.color-yellow { + color: #ffb970; +} +.color-yellow-2 { + color: #ccc964; +} +.color-rihino { + color: #2c435a; +} +/** background color **/ +.bg-black { + background-color: #000; +} +.bg-cod-gray { + background-color: #1d1c1c; +} +.bg-gray-2 { + background-color: #242525; +} +.bg-red { + background-color: #b73a3a; +} +.bg-blue { + background-color: #3a79af; +} +.bg-green { + /* background-color: #747924; */ + background-color: #369e69; +} +.bg-brown { + background-color: #795548; +} +.bg-orange { + background-color: #986a25; +} +.bg-lochinvar { + background-color: #25867d; +} +.bg-yellow { + background-color: #ffb970; +} +.bg-white { + background-color: #fff; +} + +/** padding **/ +.padding-5-10 { + padding: 5px 10px; +} +.padding-5-15 { + padding: 5px 15px; +} +.padding-0-10 { + padding: 0 10px; +} +.padding-0-20 { + padding: 0 20px; +} +.padding-10-0 { + padding: 10px 0; +} +.padding-10-20 { + padding: 10px 20px; +} +.padding-5 { + padding: 5px; +} +.padding-10 { + padding: 10px; +} +.padding-15 { + padding: 15px; +} +/** width percent **/ +.w-100-percent { + width: 100%; +} +.w-50 { + width: 50px; +} +.w-20 { + width: 20px; +} +.w-100 { + width: 100px; +} +/** border **/ +.border-radius-0 { + border-radius: 0; +} +.border-radius-5 { + border-radius: 5px; +} +.border-style-1 { + margin-bottom: 10px; + border-bottom: 1px dashed #2f2f2f; + padding-bottom: 10px; +} +.border-style-2 { + margin-bottom: 10px; + border-bottom: 1px dashed #f98d8d; + padding-bottom: 10px; +} +.border-default { + border: 1px solid #2f2f2f; +} +/** margin **/ +.margin-l-5 { + margin-left: 5px; +} +.margin-t-5 { + margin-top: 5px; +} +.margin-r-5 { + margin-right: 5px; +} +.margin-b-10 { + margin-bottom: 10px; +} +.margin-t-10 { + margin-top: 10px; +} +.margin-5 { + margin: 5px; +} +.margin-0-5 { + margin: 0 5px; +} +.margin-5-0 { + margin: 5px 0; +} +.margin-10 { + margin: 10px; +} +.margin-10-0 { + margin: 10px 0; +} +.margin-0-10 { + margin: 0 10px; +} +/** flex **/ +.flex-08 { + flex: 0.8; +} +.flex { + display: flex; +} +.inline-flex { + display: inline-flex; +} +.flex-column { + flex-direction: column; +} +.flex-wrap { + flex-wrap: wrap; +} +.flex-1 { + flex: 1; +} +.flex-ver-right { + justify-content: right; +} +.flex-hozi-center { + align-items: center; +} +.flex-ver-center { + justify-content: center; +} +.flex-space-between { + justify-content: space-between; +} +/** triangle **/ +.border-l-b-t:after { + border: 25px solid transparent; + border-left-color: #000; + border-bottom-color: #000; + content: ""; + position: absolute; + left: 100%; + top: 0; +} +.height-50 { + position: relative; + height: 50px; +} +.height-40 { + position: relative; + height: 40px; +} +.border-r-b-t:before { + border: 25px solid transparent; + border-right-color: #000; + border-bottom-color: #000; + content: ""; + position: absolute; + right: 100%; + top: 0; +} +.border-l-t:after { + border: 20px solid transparent; + border-left-color: #000; + content: ""; + position: absolute; + left: 100%; + top: 0; +} +/** font-weight **/ +.fw-400 { + font-weight: 400; +} +.fw-500 { + font-weight: 500; +} +.fw-700 { + font-weight: 700; +} +.fw-900 { + font-weight: 900; +} +/** user **/ +.level-user { + background: #3c3838; + width: 100%; + padding: 5px; + box-sizing: border-box; + box-shadow: 0 0 3px 2px #ccc; + text-align: center; + font-weight: 500; + display: flex; + align-items: center; + justify-content: center; + border-radius: 3px; +} +/** user_comment **/ +#refresh-comment span { + display: inherit; +} +.user-comment .right { + flex: 1; + padding-left: 10px; + box-sizing: border-box; +} +.user-comment .left .avatar { + width: 50px; + position: relative; + height: 50px; + overflow: hidden; + border: 3px solid #656565; + border-radius: 10px; +} +.user-comment .left .avatar img { + width: 100%; +} + +.frame-reply-comments { + border-left: 1px dashed #000000; + margin-left: 35px; + padding-left: 10px; +} +.user-comment .right .nickname + div { + color: #f78383; +} +.user-comment .right .nickname { + font-weight: 700; + color: #669698; + margin-right: 5px; +} +.user-comment .right .content + div, +.user-comment .right .content + div a { + color: #7d7d7d; +} +.user-comment .right .content { + padding: 5px 0 8px 0; + word-break: break-all; + color: #afaaaa; + font-size: 13px; +} +.user-comment .user-reply-comment { + margin: 5px 0 20px 0; +} +.load-more-reply a { + color: #ccc; +} +.load-more-reply { + padding: 10px 0; + /* text-decoration: underline; */ +} +.user-banned { + background: #000; + position: absolute; + height: 100%; + width: 100%; + z-index: 1; + opacity: 0.9; +} +.bg-comment { + padding: 10px; + background: #171717; + margin: 5px 0; + border-radius: 10px; +} +.comment-editor .content-of-comment { + flex: 1; + background: #000; + color: #fff; + padding: 10px; + font: 400 14px roboto; +} +.comment-editor .tool-bar { + margin-top: 5px; +} +/** font-size **/ +.fs-12 { + font-size: 12px; +} +.fs-13 { + font-size: 13px; +} +.fs-15 { + font-size: 15px; +} +.fs-16 { + font-size: 16px; +} +.fs-17 { + font-size: 17px; +} +.fs-19 { + font-size: 19px; +} +.fs-21 { + font-size: 21px; +} +.fs-35 { + font-size: 35px; +} +/* button on off */ +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + -webkit-transition: .4s; + transition: .4s; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + -webkit-transition: .4s; + transition: .4s; +} + +input:checked+.slider { + background-color: #2196F3; +} + +input:focus+.slider { + box-shadow: 0 0 1px #2196F3; +} + +input:checked+.slider:before { + -webkit-transform: translateX(26px); + -ms-transform: translateX(26px); + transform: translateX(26px); +} + +/* Rounded sliders */ +.slider.round { + border-radius: 34px; +} + +.slider.round:before { + border-radius: 50%; +} +@media only screen and (min-width: 768px) and (max-width: 1000px) { + #ah_wrapper { + width: 100% !important; + } + .movies-list .movie-item { + width: 20% !important; + } + .movies-list .movie-item img { + height: 180px !important; + } + .owl-carousel .owl-item img { + height: 230px; + } +} +@media only screen and (max-width: 768px) { + .watching-movie .list-item-episode a { + width: 11%; + } + .ah-carousel { + display: none; + } + .ah-form form { + width: 100%; + } + #drop-down-1 .tab-content a { + width: 33.333% !important; + } + .result-of-search a { + width: 100% !important; + } + .checkbox_form div { + width: 33.33% !important; + } + .watch-history { + display: block !important; + } + .watch-history .item { + width: 100% !important; + } + #ah_wrapper { + width: 100% !important; + } + div#navbar .logo { + flex: 1; + } + div#navbar .logo img { + width: 150px !important; + } + #navbar .search-bar { + display: none; + margin: 5px 0; + } + #navbar a.toggle-search { + display: inline-flex; + } + .info-movie .body { + display: block !important; + } + .info-movie .head .last > div > div:first-child { + display: none !important; + } + .info-movie .body .list_episode > div + div { + max-height: 100px !important; + } + .info-movie .head .last > div > div { + flex: 1 !important; + } + .info-movie .head .last > div > div { + padding: 5px; + } + .info-movie .head .last > div { + padding: 2px !important; + } + .info-movie .head .first { + width: 30% !important; + } + .info-movie .head .last { + width: 70% !important; + font-size: 12px; + } + /* .owl-carousel .owl-item img { + height: 200px !important; + } */ +} +@media only screen and (min-width: 650px) and (max-width: 768px) { + .movies-list .movie-item { + width: 25%; + } + .movies-list .movie-item img { + height: 180px; + } +} +@media only screen and (min-width: 550px) and (max-width: 650px) { + .movies-list .movie-item { + width: 33.33%; + } + .movies-list .movie-item img { + height: 180px; + } +} +@media only screen and (min-width: 450px) and (max-width: 550px) { + .movies-list .movie-item { + width: 33.33%; + } + .movies-list .movie-item img { + height: 160px; + } +} +@media only screen and (max-width: 450px) { + .trigger-buttons { + flex-wrap: wrap; + } + .trigger-buttons div { + width: 50%; + } + #ah_wrapper > .ah_footer img { + width: 150px !important; + } + div#navbar > div:first-child { + flex-direction: column; + } + .watching-movie .list-item-episode a { + width: 20%; + } + .movies-list .movie-item { + width: 50%; + } + .movies-list .movie-item img { + height: 190px !important; + } +} +@media only screen and (max-width: 350px) { + .movies-list .movie-item img { + height: 160px !important; + } + div#view-profile .avatar img { + width: 80px; + } + /* .owl-carousel .owl-item img { + height: 148px !important; + } */ +} + +.div_filter { + margin-bottom: 10px; + border: 1px solid #4c4c4c; + background: #1d1c1c; + padding: 5px 0; +} + +.div_filter-main { + display: flex; + flex-wrap: wrap; +} + +.div_filter-main select{ + background-color: #444; + border: none; + color: #fff; + padding: 9px 10px; + margin: 2px 5px; +} + +.button-filter { + border: none; + color: #fff; + padding: 10px 10px; + margin: 2px 5px; + cursor: pointer; + display: flex; + align-items: center; +} +.button-filter:hover { + opacity: 50%; +} diff --git a/resources/assets/js/functions.js b/resources/assets/js/functions.js new file mode 100644 index 0000000..2d84b3f --- /dev/null +++ b/resources/assets/js/functions.js @@ -0,0 +1,79 @@ +$(document).ready(function () { + $(".parent-menu").click(function () { + $(".parent-menu").each(function () { + $(this).removeClass("active"); + }) + $(".sub-menu-content").each(function () { + $(this).removeClass("display-block"); + }) + $(this).addClass("active"); + let tabId = $(this).attr("bind").split("-")[1] + $(`#tab-${tabId}`).addClass("display-block"); + }) + + $("#rated").click(function () { + $("#modal").css({ "display": "block", "position": "absolute", "visibility": "visible", "top": "400px", "left": "50%", "transition": "top 0.3s ease 0s", "transform": "translate(-50%, -50%)", "width": "100%" }); + }) + $("#close-modal-rated").click(function () { + $("#modal").css({ "display": "block", "visibility": "hidden", "top": "0px", "transition": "top 0.3s ease 0s" }) + }) + + $("#report_error").click(function () { + if ($("#episode_error").css('display') != 'block') { + $("#episode_error").css('display', 'block') + } else { + $("#episode_error").css('display', 'none') + } + }) + $("input#error_send").click(function () { + console.log(123); + let error_message = $("input[name=error_message]").val(); + fetch(ROUTE_REPORT_ERROR, { + method: 'POST', + headers: { + "Content-Type": "application/json", + 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute( + 'content') + }, + body: JSON.stringify({ + message: error_message + }) + }); + $.toast({ + heading: 'Thông báo', + text: 'Phản hồi của bạn đã được gửi đi!', + position: 'bottom-right', + icon: 'info', + loader: true, + loaderBg: '#9EC600', + bgColor: '#212121', + textColor: 'white' + }) + $("#episode_error").remove(); + }) + $("#toggle_trailer").click(function () { + $("#modal-trailer").css({ "display": "block", "position": "absolute", "visibility": "visible", "top": "300px", "left": "50%", "transition": "top 0.3s ease 0s", "transform": "translate(-50%, -50%)", "width": "100%" }); + }) + $("#close-modal-trailer").click(function () { + $("#modal-trailer").css({ "display": "block", "visibility": "hidden", "top": "0px", "transition": "top 0.3s ease 0s" }) + }) +}); + +function clickEventDropDown(this_dropdown, icon_default = "Null") { + var _name = this_dropdown.getAttribute("bind"); + var _dropdown_menu = document.getElementById(_name); + if (!_dropdown_menu.style.display || _dropdown_menu.style.display === "none") { + this_dropdown.innerHTML = `highlight_off`; + if (icon_default !== "expand_more") { + this_dropdown.style.backgroundColor = "#ab3e3e"; + } + _dropdown_menu.style.display = "flex"; + setTimeout(function () { + _dropdown_menu.style.transform = "scale(1)"; + }, 50) + } else { + _dropdown_menu.style = null; + this_dropdown.style = null; + this_dropdown.innerHTML = `${icon_default}`; + } +} diff --git a/resources/assets/player/1s_blank.mp4 b/resources/assets/player/1s_blank.mp4 new file mode 100644 index 0000000..d584a58 Binary files /dev/null and b/resources/assets/player/1s_blank.mp4 differ diff --git a/resources/assets/player/js/p2p-media-loader-core.min.js b/resources/assets/player/js/p2p-media-loader-core.min.js new file mode 100644 index 0000000..2a25b93 --- /dev/null +++ b/resources/assets/player/js/p2p-media-loader-core.min.js @@ -0,0 +1 @@ +require=function e(t,n,r){function i(o,a){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[o]={exports:{}};t[o][0].call(h.exports,function(e){return i(t[o][1][e]||e)},h,h.exports,e,t,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;or;)this.currentBytesSum-=this.lastBytes.shift().value;this.lastBandwidth.push(new s(this.currentBytesSum/r,t))}getBandwidth(e){for(;0!=this.lastBandwidth.length&&e-this.lastBandwidth[0].timeStamp>i;)this.lastBandwidth.shift();let t=0;for(const e of this.lastBandwidth)e.value>t&&(t=e.value);return t}getSmoothInterval(){return r}getMeasureInterval(){return i}}},{}],2:[function(e,t,n){window.p2pml||(window.p2pml={}),window.p2pml.core=e("./index")},{"./index":"p2p-media-loader-core"}],3:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./stringly-typed-event-emitter");n.HttpMediaManager=class extends i.STEEmitter{constructor(e){super(),this.settings=e,this.xhrRequests=new Map,this.failedSegments=new Map,this.debug=r("p2pml:http-media-manager"),this.now=()=>performance.now()}download(e,t){if(this.isDownloading(e))return;this.cleanTimedOutFailedSegments();const n=this.settings.segmentUrlBuilder?this.settings.segmentUrlBuilder(e):e.url;this.debug("http segment download",n),e.requestUrl=n;const r=new XMLHttpRequest;if(r.open("GET",n,!0),r.responseType="arraybuffer",e.range)r.setRequestHeader("Range",e.range),t=void 0;else if(void 0!==t&&this.settings.httpUseRanges){let e=0;for(const n of t)e+=n.byteLength;r.setRequestHeader("Range",`bytes=${e}-`),this.debug("continue download from",e)}else t=void 0;this.setupXhrEvents(r,e,t),this.settings.xhrSetup&&this.settings.xhrSetup(r,n),this.xhrRequests.set(e.id,{xhr:r,segment:e}),r.send()}abort(e){const t=this.xhrRequests.get(e.id);t&&(t.xhr.abort(),this.xhrRequests.delete(e.id),this.debug("http segment abort",e.id))}isDownloading(e){return this.xhrRequests.has(e.id)}isFailed(e){const t=this.failedSegments.get(e.id);return void 0!==t&&t>this.now()}getActiveDownloads(){return this.xhrRequests}getActiveDownloadsCount(){return this.xhrRequests.size}destroy(){this.xhrRequests.forEach(e=>e.xhr.abort()),this.xhrRequests.clear()}setupXhrEvents(e,t,n){let r=0;e.addEventListener("progress",e=>{const t=e.loaded-r;this.emit("bytes-downloaded",t),r=e.loaded}),e.addEventListener("load",async r=>{if(r.target.status<200||r.target.status>=300)return void this.segmentFailure(t,r,e);let i=r.target.response;if(void 0!==n&&206===r.target.status){let e=0;for(const t of n)e+=t.byteLength;const t=new Uint8Array(e+i.byteLength);let r=0;for(const e of n)t.set(new Uint8Array(e),r),r+=e.byteLength;t.set(new Uint8Array(i),r),i=t.buffer}await this.segmentDownloadFinished(t,i,e)}),e.addEventListener("error",n=>{this.segmentFailure(t,n,e)}),e.addEventListener("timeout",n=>{this.segmentFailure(t,n,e)})}async segmentDownloadFinished(e,t,n){if(e.responseUrl=null===n.responseURL?void 0:n.responseURL,this.settings.segmentValidator)try{await this.settings.segmentValidator(Object.assign(Object.assign({},e),{data:t}),"http")}catch(t){return this.debug("segment validator failed",t),void this.segmentFailure(e,t,n)}this.xhrRequests.delete(e.id),this.emit("segment-loaded",e,t)}segmentFailure(e,t,n){e.responseUrl=null===n.responseURL?void 0:n.responseURL,this.xhrRequests.delete(e.id),this.failedSegments.set(e.id,this.now()+this.settings.httpFailedSegmentTimeout),this.emit("segment-error",e,t)}cleanTimedOutFailedSegments(){const e=this.now(),t=[];this.failedSegments.forEach((n,r)=>{nthis.failedSegments.delete(e))}}},{"./stringly-typed-event-emitter":9,debug:"debug"}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./loader-interface"),s=e("events"),o=e("./http-media-manager"),a=e("./p2p-media-manager"),u=e("./media-peer"),c=e("./bandwidth-approximator"),h=e("./segments-memory-storage"),l=e("get-browser-rtc"),d={cachedSegmentExpiration:3e5,cachedSegmentsCount:30,useP2P:!0,consumeOnly:!1,requiredSegmentsPriority:1,simultaneousHttpDownloads:2,httpDownloadProbability:.1,httpDownloadProbabilityInterval:1e3,httpDownloadProbabilitySkipIfNoPeers:!1,httpFailedSegmentTimeout:1e4,httpDownloadMaxPriority:20,httpDownloadInitialTimeout:0,httpDownloadInitialTimeoutPerSegment:4e3,httpUseRanges:!1,simultaneousP2PDownloads:3,p2pDownloadMaxPriority:20,p2pSegmentDownloadTimeout:6e4,webRtcMaxMessageSize:65535,trackerAnnounce:["wss://tracker.novage.com.ua","wss://tracker.openwebtorrent.com"],peerRequestsPerAnnounce:10,rtcConfig:e("simple-peer").config};n.HybridLoader=class extends s.EventEmitter{constructor(e={}){super(),this.debug=r("p2pml:hybrid-loader"),this.debugSegments=r("p2pml:hybrid-loader-segments"),this.segmentsQueue=[],this.bandwidthApproximator=new c.BandwidthApproximator,this.httpDownloadInitialTimeoutTimestamp=-1/0,this.processInitialSegmentTimeout=async()=>{if(void 0!==this.httpRandomDownloadInterval){if(void 0!==this.masterSwarmId){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}this.httpDownloadInitialTimeoutTimestamp!==-1/0&&setTimeout(this.processInitialSegmentTimeout,this.settings.httpDownloadInitialTimeoutPerSegment)}},this.downloadRandomSegmentOverHttp=async()=>{if(void 0===this.masterSwarmId||void 0===this.httpRandomDownloadInterval||this.httpDownloadInitialTimeoutTimestamp!==-1/0||this.httpManager.getActiveDownloadsCount()>=this.settings.simultaneousHttpDownloads||this.settings.httpDownloadProbabilitySkipIfNoPeers&&0===this.p2pManager.getPeers().size||this.settings.consumeOnly)return;const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId),t=this.p2pManager.getOvrallSegmentsMap(),n=this.segmentsQueue.filter(n=>!this.p2pManager.isDownloading(n)&&!this.httpManager.isDownloading(n)&&!t.has(n.id)&&!this.httpManager.isFailed(n)&&n.priority<=this.settings.httpDownloadMaxPriority&&!e.has(n.id));if(0==n.length)return;if(Math.random()>this.settings.httpDownloadProbability*n.length)return;const r=n[Math.floor(Math.random()*n.length)];this.debugSegments("HTTP download (random)",r.priority,r.url),this.httpManager.download(r),this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))},this.onPieceBytesDownloaded=(e,t,n)=>{this.bandwidthApproximator.addBytes(t,this.now()),this.emit(i.Events.PieceBytesDownloaded,e,t,n)},this.onPieceBytesUploaded=(e,t,n)=>{this.emit(i.Events.PieceBytesUploaded,e,t,n)},this.onSegmentLoaded=async(e,t,n)=>{if(this.debugSegments("segment loaded",e.id,e.url),void 0===this.masterSwarmId)return;let r;e.data=t,e.downloadBandwidth=this.bandwidthApproximator.getBandwidth(this.now()),await this.segmentsStorage.storeSegment(e),this.emit(i.Events.SegmentLoaded,e,n),r=void 0===r?await this.segmentsStorage.getSegmentsMap(this.masterSwarmId):r,this.processSegmentsQueue(r),this.settings.consumeOnly||this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(r))},this.onSegmentError=async(e,t,n)=>{if(this.debugSegments("segment error",e.id,e.url,n,t),this.emit(i.Events.SegmentError,e,t,n),void 0!==this.masterSwarmId){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}},this.onPeerConnect=async e=>{this.emit(i.Events.PeerConnect,e),this.settings.consumeOnly||void 0===this.masterSwarmId||this.p2pManager.sendSegmentsMap(e.id,this.createSegmentsMap(await this.segmentsStorage.getSegmentsMap(this.masterSwarmId)))},this.onPeerClose=e=>{this.emit(i.Events.PeerClose,e)},this.onTrackerUpdate=async e=>{if(this.httpDownloadInitialTimeoutTimestamp!==-1/0&&void 0!==e.incomplete&&e.incomplete<=1&&(this.debugSegments("cancel initial HTTP download timeout - no peers"),this.httpDownloadInitialTimeoutTimestamp=-1/0,void 0!==this.masterSwarmId)){const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}},this.settings=Object.assign(Object.assign({},d),e),e.bufferedSegmentsCount&&(void 0===e.p2pDownloadMaxPriority&&(this.settings.p2pDownloadMaxPriority=e.bufferedSegmentsCount),void 0===e.httpDownloadMaxPriority&&(this.settings.p2pDownloadMaxPriority=e.bufferedSegmentsCount),delete this.settings.bufferedSegmentsCount),this.segmentsStorage=void 0===this.settings.segmentsStorage?new h.SegmentsMemoryStorage(this.settings):this.settings.segmentsStorage,this.debug("loader settings",this.settings),this.httpManager=this.createHttpManager(),this.httpManager.on("segment-loaded",this.onSegmentLoaded),this.httpManager.on("segment-error",this.onSegmentError),this.httpManager.on("bytes-downloaded",e=>this.onPieceBytesDownloaded("http",e)),this.p2pManager=this.createP2PManager(),this.p2pManager.on("segment-loaded",this.onSegmentLoaded),this.p2pManager.on("segment-error",this.onSegmentError),this.p2pManager.on("peer-data-updated",async()=>{if(void 0===this.masterSwarmId)return;const e=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);this.processSegmentsQueue(e)&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(e))}),this.p2pManager.on("bytes-downloaded",(e,t)=>this.onPieceBytesDownloaded("p2p",e,t)),this.p2pManager.on("bytes-uploaded",(e,t)=>this.onPieceBytesUploaded("p2p",e,t)),this.p2pManager.on("peer-connected",this.onPeerConnect),this.p2pManager.on("peer-closed",this.onPeerClose),this.p2pManager.on("tracker-update",this.onTrackerUpdate)}static isSupported(){const e=l();return e&&void 0!==e.RTCPeerConnection.prototype.createDataChannel}createHttpManager(){return new o.HttpMediaManager(this.settings)}createP2PManager(){return new a.P2PMediaManager(this.segmentsStorage,this.settings)}async load(e,t){void 0===this.httpRandomDownloadInterval&&(this.httpRandomDownloadInterval=setInterval(this.downloadRandomSegmentOverHttp,this.settings.httpDownloadProbabilityInterval),this.settings.httpDownloadInitialTimeout>0&&this.settings.httpDownloadInitialTimeoutPerSegment>0&&(this.debugSegments("enable initial HTTP download timeout",this.settings.httpDownloadInitialTimeout,"per segment",this.settings.httpDownloadInitialTimeoutPerSegment),this.httpDownloadInitialTimeoutTimestamp=this.now(),setTimeout(this.processInitialSegmentTimeout,this.settings.httpDownloadInitialTimeoutPerSegment+100))),e.length>0&&(this.masterSwarmId=e[0].masterSwarmId),void 0!==this.masterSwarmId&&this.p2pManager.setStreamSwarmId(t,this.masterSwarmId),this.debug("load segments");let n=!1;for(const t of this.segmentsQueue)e.find(e=>e.url==t.url)||(this.debug("remove segment",t.url),this.httpManager.isDownloading(t)?(n=!0,this.httpManager.abort(t)):this.p2pManager.abort(t),this.emit(i.Events.SegmentAbort,t));if(this.debug.enabled)for(const t of e)this.segmentsQueue.find(e=>e.url==t.url)||this.debug("add segment",t.url);if(this.segmentsQueue=e,void 0===this.masterSwarmId)return;let r=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId);n=this.processSegmentsQueue(r)||n,await this.cleanSegmentsStorage()&&(r=await this.segmentsStorage.getSegmentsMap(this.masterSwarmId),n=!0),n&&!this.settings.consumeOnly&&this.p2pManager.sendSegmentsMapToAll(this.createSegmentsMap(r))}async getSegment(e){return void 0===this.masterSwarmId?void 0:this.segmentsStorage.getSegment(e,this.masterSwarmId)}getSettings(){return this.settings}getDetails(){return{peerId:this.p2pManager.getPeerId()}}async destroy(){void 0!==this.httpRandomDownloadInterval&&(clearInterval(this.httpRandomDownloadInterval),this.httpRandomDownloadInterval=void 0),this.httpDownloadInitialTimeoutTimestamp=-1/0,this.segmentsQueue=[],this.httpManager.destroy(),this.p2pManager.destroy(),this.masterSwarmId=void 0,await this.segmentsStorage.destroy()}processSegmentsQueue(e){if(this.debugSegments("process segments queue. priority",this.segmentsQueue.length>0?this.segmentsQueue[0].priority:0),void 0===this.masterSwarmId||0===this.segmentsQueue.length)return!1;let t,n=!1,r=!0;if(this.httpDownloadInitialTimeoutTimestamp!==-1/0){let t;for(const n of this.segmentsQueue)if(!e.has(n.id)){t=n.priority;break}const n=this.now()-this.httpDownloadInitialTimeoutTimestamp;(r=n>=this.settings.httpDownloadInitialTimeout||void 0!==t&&n>this.settings.httpDownloadInitialTimeoutPerSegment&&t<=0)&&(this.debugSegments("cancel initial HTTP download timeout - timed out"),this.httpDownloadInitialTimeoutTimestamp=-1/0)}for(let i=0;i=this.settings.simultaneousHttpDownloads)for(let e=this.segmentsQueue.length-1;e>i;e--){const t=this.segmentsQueue[e];if(this.httpManager.isDownloading(t)){this.debugSegments("cancel HTTP download",t.priority,t.url),this.httpManager.abort(t);break}}if(this.httpManager.getActiveDownloadsCount()=this.settings.simultaneousP2PDownloads)for(let e=this.segmentsQueue.length-1;e>i;e--){const t=this.segmentsQueue[e];if(this.p2pManager.isDownloading(t)){this.debugSegments("cancel P2P download",t.priority,t.url),this.p2pManager.abort(t);break}}if(this.p2pManager.getActiveDownloadsCount(){const r=this.getStreamSwarmId(e),i=e.sequence;let s=t[r];void 0===s&&(s=["",[]],t[r]=s);const o=s[1];s[0]+=0==o.length?i:`|${i}`,o.push(n)};for(const t of e.values())n(t.segment,u.MediaPeerSegmentStatus.Loaded);for(const e of this.httpManager.getActiveDownloads().values())n(e.segment,u.MediaPeerSegmentStatus.LoadingByHttp);return t}async cleanSegmentsStorage(){return void 0!==this.masterSwarmId&&this.segmentsStorage.clean(this.masterSwarmId,e=>void 0!==this.segmentsQueue.find(t=>t.id===e))}now(){return performance.now()}}},{"./bandwidth-approximator":1,"./http-media-manager":3,"./loader-interface":5,"./media-peer":6,"./p2p-media-manager":7,"./segments-memory-storage":8,debug:"debug",events:"events","get-browser-rtc":18,"simple-peer":44}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(e){e.SegmentLoaded="segment_loaded",e.SegmentError="segment_error",e.SegmentAbort="segment_abort",e.PeerConnect="peer_connect",e.PeerClose="peer_close",e.PieceBytesDownloaded="piece_bytes_downloaded",e.PieceBytesUploaded="piece_bytes_uploaded"}(n.Events||(n.Events={}))},{}],6:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("./stringly-typed-event-emitter"),s=e("buffer");var o,a;!function(e){e[e.SegmentData=0]="SegmentData",e[e.SegmentAbsent=1]="SegmentAbsent",e[e.SegmentsMap=2]="SegmentsMap",e[e.SegmentRequest=3]="SegmentRequest",e[e.CancelSegmentRequest=4]="CancelSegmentRequest"}(o||(o={})),function(e){e[e.Loaded=0]="Loaded",e[e.LoadingByHttp=1]="LoadingByHttp"}(a=n.MediaPeerSegmentStatus||(n.MediaPeerSegmentStatus={}));class u{constructor(e,t){this.id=e,this.size=t,this.bytesDownloaded=0,this.pieces=[]}}n.MediaPeer=class extends i.STEEmitter{constructor(e,t){super(),this.peer=e,this.settings=t,this.remoteAddress="",this.downloadingSegmentId=null,this.downloadingSegment=null,this.segmentsMap=new Map,this.debug=r("p2pml:media-peer"),this.timer=null,this.onPeerConnect=()=>{this.debug("peer connect",this.id,this),this.remoteAddress=this.peer.remoteAddress,this.emit("connect",this)},this.onPeerClose=()=>{this.debug("peer close",this.id,this),this.terminateSegmentRequest(),this.emit("close",this)},this.onPeerError=e=>{this.debug("peer error",this.id,e,this)},this.onPeerData=e=>{const t=this.getJsonCommand(e);if(null!=t){if(this.downloadingSegment){this.debug("peer segment download is interrupted by a command",this.id,this);const e=this.downloadingSegment.id;return this.terminateSegmentRequest(),void this.emit("segment-error",this,e,"Segment download is interrupted by a command")}switch(this.debug("peer receive command",this.id,t,this),t.c){case o.SegmentsMap:this.segmentsMap=this.createSegmentsMap(t.m),this.emit("data-updated");break;case o.SegmentRequest:this.emit("segment-request",this,t.i);break;case o.SegmentData:this.downloadingSegmentId===t.i&&(this.downloadingSegment=new u(t.i,t.s),this.cancelResponseTimeoutTimer());break;case o.SegmentAbsent:this.downloadingSegmentId===t.i&&(this.terminateSegmentRequest(),this.segmentsMap.delete(t.i),this.emit("segment-absent",this,t.i));break;case o.CancelSegmentRequest:}}else this.receiveSegmentPiece(e)},this.peer.on("connect",this.onPeerConnect),this.peer.on("close",this.onPeerClose),this.peer.on("error",this.onPeerError),this.peer.on("data",this.onPeerData),this.id=e.id}receiveSegmentPiece(e){if(!this.downloadingSegment)return void this.debug("peer segment not requested",this.id,this);this.downloadingSegment.bytesDownloaded+=e.byteLength,this.downloadingSegment.pieces.push(e),this.emit("bytes-downloaded",this,e.byteLength);const t=this.downloadingSegment.id;if(this.downloadingSegment.bytesDownloaded==this.downloadingSegment.size){const e=new Uint8Array(this.downloadingSegment.size);let n=0;for(const t of this.downloadingSegment.pieces)e.set(new Uint8Array(t),n),n+=t.byteLength;this.debug("peer segment download done",this.id,t,this),this.terminateSegmentRequest(),this.emit("segment-loaded",this,t,e.buffer)}else this.downloadingSegment.bytesDownloaded>this.downloadingSegment.size&&(this.debug("peer segment download bytes mismatch",this.id,t,this),this.terminateSegmentRequest(),this.emit("segment-error",this,t,"Too many bytes received for segment"))}getJsonCommand(e){const t=new Uint8Array(e);if(123==t[0]&&34==t[1]&&125==t[e.byteLength-1])try{return JSON.parse((new TextDecoder).decode(e))}catch(e){}return null}createSegmentsMap(e){if(null==e||!(e instanceof Object))return new Map;const t=new Map;for(const n of Object.keys(e)){const r=e[n];if(!(r instanceof Array&&2===r.length&&"string"==typeof r[0]&&r[1]instanceof Array))return new Map;const i=r[0].split("|"),s=r[1];if(i.length!==s.length)return new Map;for(let e=0;e0;){const e=n>=this.settings.webRtcMaxMessageSize?this.settings.webRtcMaxMessageSize:n,r=s.Buffer.from(t,t.byteLength-n,e);this.peer.write(r),n-=e}this.emit("bytes-uploaded",this,t.byteLength)}sendSegmentAbsent(e){this.sendCommand({c:o.SegmentAbsent,i:e})}requestSegment(e){if(this.downloadingSegmentId)throw new Error("A segment is already downloading: "+this.downloadingSegmentId);this.sendCommand({c:o.SegmentRequest,i:e}),this.downloadingSegmentId=e,this.runResponseTimeoutTimer()}cancelSegmentRequest(){let e;if(this.downloadingSegmentId){const t=this.downloadingSegmentId;e=this.downloadingSegment?this.downloadingSegment.pieces:void 0,this.terminateSegmentRequest(),this.sendCommand({c:o.CancelSegmentRequest,i:t})}return e}runResponseTimeoutTimer(){this.timer=setTimeout(()=>{if(this.timer=null,!this.downloadingSegmentId)return;const e=this.downloadingSegmentId;this.cancelSegmentRequest(),this.emit("segment-timeout",this,e)},this.settings.p2pSegmentDownloadTimeout)}cancelResponseTimeoutTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}terminateSegmentRequest(){this.downloadingSegmentId=null,this.downloadingSegment=null,this.cancelResponseTimeoutTimer()}}},{"./stringly-typed-event-emitter":9,buffer:16,debug:"debug"}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("debug"),i=e("bittorrent-tracker/client"),s=e("./stringly-typed-event-emitter"),o=e("./media-peer"),a=e("buffer"),u=e("sha.js/sha1"),c=e("./index"),h=2,l=`-WW${c.version.replace(/\d*./g,e=>`0${parseInt(e,10)%100}`.slice(-2)).slice(0,4)}-`;class d{constructor(e,t){this.peerId=e,this.segment=t}}n.P2PMediaManager=class extends s.STEEmitter{constructor(e,t){super(),this.sementsStorage=e,this.settings=t,this.trackerClient=null,this.peers=new Map,this.peerCandidates=new Map,this.peerSegmentRequests=new Map,this.streamSwarmId=null,this.debug=r("p2pml:p2p-media-manager"),this.pendingTrackerClient=null,this.onTrackerError=e=>{this.debug("tracker error",e)},this.onTrackerWarning=e=>{this.debug("tracker warning",e)},this.onTrackerUpdate=e=>{this.debug("tracker update",e),this.emit("tracker-update",e)},this.onTrackerPeer=e=>{if(this.debug("tracker peer",e.id,e),this.peers.has(e.id))return this.debug("tracker peer already connected",e.id,e),void e.destroy();const t=new o.MediaPeer(e,this.settings);t.on("connect",this.onPeerConnect),t.on("close",this.onPeerClose),t.on("data-updated",this.onPeerDataUpdated),t.on("segment-request",this.onSegmentRequest),t.on("segment-loaded",this.onSegmentLoaded),t.on("segment-absent",this.onSegmentAbsent),t.on("segment-error",this.onSegmentError),t.on("segment-timeout",this.onSegmentTimeout),t.on("bytes-downloaded",this.onPieceBytesDownloaded),t.on("bytes-uploaded",this.onPieceBytesUploaded);let n=this.peerCandidates.get(t.id);n||(n=[],this.peerCandidates.set(t.id,n)),n.push(t)},this.onPieceBytesDownloaded=(e,t)=>{this.emit("bytes-downloaded",t,e.id)},this.onPieceBytesUploaded=(e,t)=>{this.emit("bytes-uploaded",t,e.id)},this.onPeerConnect=e=>{if(this.peers.get(e.id))return this.debug("tracker peer already connected (in peer connect)",e.id,e),void e.destroy();this.peers.set(e.id,e);const t=this.peerCandidates.get(e.id);if(t){for(const n of t)n!=e&&n.destroy();this.peerCandidates.delete(e.id)}this.emit("peer-connected",{id:e.id,remoteAddress:e.remoteAddress})},this.onPeerClose=e=>{if(this.peers.get(e.id)!=e){const t=this.peerCandidates.get(e.id);if(!t)return;const n=t.indexOf(e);return-1!=n&&t.splice(n,1),void(0==t.length&&this.peerCandidates.delete(e.id))}for(const[t,n]of this.peerSegmentRequests)n.peerId==e.id&&this.peerSegmentRequests.delete(t);this.peers.delete(e.id),this.emit("peer-data-updated"),this.emit("peer-closed",e.id)},this.onPeerDataUpdated=()=>{this.emit("peer-data-updated")},this.onSegmentRequest=async(e,t)=>{if(void 0===this.masterSwarmId)return;const n=await this.sementsStorage.getSegment(t,this.masterSwarmId);n?e.sendSegmentData(t,n.data):e.sendSegmentAbsent(t)},this.onSegmentLoaded=async(e,t,n)=>{const r=this.peerSegmentRequests.get(t);if(!r)return;const i=r.segment;if(this.settings.segmentValidator)try{await this.settings.segmentValidator(Object.assign(Object.assign({},i),{data:n}),"p2p",e.id)}catch(n){return this.debug("segment validator failed",n),this.peerSegmentRequests.delete(t),this.emit("segment-error",i,n,e.id),void this.onPeerClose(e)}this.peerSegmentRequests.delete(t),this.emit("segment-loaded",i,n,e.id)},this.onSegmentAbsent=(e,t)=>{this.peerSegmentRequests.delete(t),this.emit("peer-data-updated")},this.onSegmentError=(e,t,n)=>{const r=this.peerSegmentRequests.get(t);r&&(this.peerSegmentRequests.delete(t),this.emit("segment-error",r.segment,n,e.id))},this.onSegmentTimeout=(e,t)=>{const n=this.peerSegmentRequests.get(t);n&&(this.peerSegmentRequests.delete(t),e.destroy(),this.peers.delete(n.peerId)&&this.emit("peer-data-updated"))},this.peerId=t.useP2P?function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t=l;for(let n=0;n<20-l.length;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return(new TextEncoder).encode(t).buffer}():new ArrayBuffer(0),this.debug.enabled&&this.debug("peer ID",this.getPeerId(),(new TextDecoder).decode(this.peerId))}getPeers(){return this.peers}getPeerId(){return a.Buffer.from(this.peerId).toString("hex")}async setStreamSwarmId(e,t){if(this.streamSwarmId===e)return;this.destroy(!0),this.streamSwarmId=e,this.masterSwarmId=t,this.debug("stream swarm ID",this.streamSwarmId),this.pendingTrackerClient={isDestroyed:!1};const n=this.pendingTrackerClient,r=(new u).update(h+this.streamSwarmId).digest();n.isDestroyed?null!=this.trackerClient&&(this.trackerClient.destroy(),this.trackerClient=null):(this.pendingTrackerClient=null,this.createClient(r))}createClient(e){if(!this.settings.useP2P)return;const t={infoHash:a.Buffer.from(e,0,20),peerId:a.Buffer.from(this.peerId,0,20),announce:this.settings.trackerAnnounce,rtcConfig:this.settings.rtcConfig,port:6881,getAnnounceOpts:()=>({numwant:this.settings.peerRequestsPerAnnounce})};let n=this.trackerClient;this.trackerClient=new i(t),this.trackerClient.on("error",this.onTrackerError),this.trackerClient.on("warning",this.onTrackerWarning),this.trackerClient.on("update",this.onTrackerUpdate),this.trackerClient.on("peer",this.onTrackerPeer),this.trackerClient.start(),null!=n&&(n.destroy(),n=null)}download(e){if(this.isDownloading(e))return!1;const t=[];for(const n of this.peers.values())null==n.getDownloadingSegmentId()&&n.getSegmentsMap().get(e.id)===o.MediaPeerSegmentStatus.Loaded&&t.push(n);if(0===t.length)return!1;const n=t[Math.floor(Math.random()*t.length)];return n.requestSegment(e.id),this.peerSegmentRequests.set(e.id,new d(n.id,e)),!0}abort(e){let t;const n=this.peerSegmentRequests.get(e.id);if(n){const r=this.peers.get(n.peerId);r&&(t=r.cancelSegmentRequest()),this.peerSegmentRequests.delete(e.id)}return t}isDownloading(e){return this.peerSegmentRequests.has(e.id)}getActiveDownloadsCount(){return this.peerSegmentRequests.size}destroy(e=!1){this.streamSwarmId=null,this.trackerClient&&(this.trackerClient.stop(),e?(this.trackerClient.removeAllListeners("error"),this.trackerClient.removeAllListeners("warning"),this.trackerClient.removeAllListeners("update"),this.trackerClient.removeAllListeners("peer")):(this.trackerClient.destroy(),this.trackerClient=null)),this.pendingTrackerClient&&(this.pendingTrackerClient.isDestroyed=!0,this.pendingTrackerClient=null),this.peers.forEach(e=>e.destroy()),this.peers.clear(),this.peerSegmentRequests.clear();for(const e of this.peerCandidates.values())for(const t of e)t.destroy();this.peerCandidates.clear()}sendSegmentsMapToAll(e){this.peers.forEach(t=>t.sendSegmentsMap(e))}sendSegmentsMap(e,t){const n=this.peers.get(e);n&&n.sendSegmentsMap(t)}getOvrallSegmentsMap(){const e=new Map;for(const t of this.peers.values())for(const[n,r]of t.getSegmentsMap())r===o.MediaPeerSegmentStatus.Loaded?e.set(n,o.MediaPeerSegmentStatus.Loaded):e.get(n)||e.set(n,o.MediaPeerSegmentStatus.LoadingByHttp);return e}}},{"./index":"p2p-media-loader-core","./media-peer":6,"./stringly-typed-event-emitter":9,"bittorrent-tracker/client":11,buffer:16,debug:"debug","sha.js/sha1":43}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.SegmentsMemoryStorage=class{constructor(e){this.settings=e,this.cache=new Map}async storeSegment(e){this.cache.set(e.id,{segment:e,lastAccessed:performance.now()})}async getSegmentsMap(e){return this.cache}async getSegment(e,t){const n=this.cache.get(e);if(void 0!==n)return n.lastAccessed=performance.now(),n.segment}async hasSegment(e,t){return this.cache.has(e)}async clean(e,t){const n=[],r=[],i=performance.now();for(const e of this.cache.values())i-e.lastAccessed>this.settings.cachedSegmentExpiration?n.push(e.segment.id):r.push(e);let s=r.length-this.settings.cachedSegmentsCount;if(s>0){r.sort((e,t)=>e.lastAccessed-t.lastAccessed);for(const e of r)if((void 0===t||!t(e.segment.id))&&(n.push(e.segment.id),0==--s))break}return n.forEach(e=>this.cache.delete(e)),n.length>0}async destroy(){this.cache.clear()}}},{}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});const r=e("events");n.STEEmitter=class extends r.EventEmitter{on(e,t){return super.on(e,t)}emit(e,...t){return super.emit(e,...t)}}},{events:"events"}],10:[function(e,t,n){"use strict";n.byteLength=function(e){var t=c(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=c(e),o=r[0],a=r[1],u=new s(function(e,t,n){return 3*(t+n)/4-n}(0,o,a)),h=0,l=a>0?o-4:o;for(n=0;n>16&255,u[h++]=t>>8&255,u[h++]=255&t;2===a&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,u[h++]=255&t);1===a&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t);return u},n.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=0,a=n-i;oa?a:o+16383));1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return s.join("")};for(var r=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function h(e,t,n){for(var i,s,o=[],a=t;a>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],11:[function(e,t,n){(function(n,r){const i=e("debug")("bittorrent-tracker:client"),s=e("events"),o=e("once"),a=e("run-parallel"),u=e("simple-peer"),c=e("uniq"),h=e("./lib/common"),l=e("./lib/client/http-tracker"),d=e("./lib/client/udp-tracker"),f=e("./lib/client/websocket-tracker");class p extends s{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=r.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=r.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),i("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map(e=>("/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e)),t=c(t);const s=!1!==this._wrtc&&(!!this._wrtc||u.WEBRTC_SUPPORT),o=e=>{n.nextTick(()=>{this.emit("warning",e)})};this._trackers=t.map(e=>{let t;try{t=new URL(e)}catch(t){return o(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(n<0||n>65535)return o(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return"http:"!==r&&"https:"!==r||"function"!=typeof l?"udp:"===r&&"function"==typeof d?new d(this,e):"ws:"!==r&&"wss:"!==r||!s?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(o(new Error(`Unsupported tracker protocol: ${e}`)),null):new f(this,e):new l(this,e)}).filter(Boolean)}start(e){(e=this._defaultAnnounceOpts(e)).event="started",i("send `start` %o",e),this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){(e=this._defaultAnnounceOpts(e)).event="stopped",i("send `stop` %o",e),this._announce(e)}complete(e){e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",i("send `complete` %o",e),this._announce(e)}update(e){(e=this._defaultAnnounceOpts(e)).event&&delete e.event,i("send `update` %o",e),this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){i("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(this.destroyed)return;this.destroyed=!0,i("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});a(t,e),this._trackers=[],this._getAnnounceOpts=null}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=h.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}p.scrape=(e,t)=>{if(t=o(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:r.from("01234567890123456789"),port:6881}),i=new p(n);i.once("error",t),i.once("warning",t);let s=Array.isArray(e.infoHash)?e.infoHash.length:1;const a={};return i.on("scrape",e=>{if(s-=1,a[e.infoHash]=e,0===s){i.destroy();const e=Object.keys(a);1===e.length?t(null,a[e[0]]):t(null,a)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>r.from(e,"hex")):r.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i},t.exports=p}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/client/http-tracker":15,"./lib/client/udp-tracker":15,"./lib/client/websocket-tracker":13,"./lib/common":14,_process:23,buffer:16,debug:"debug",events:"events",once:22,"run-parallel":40,"simple-peer":44,uniq:47}],12:[function(e,t,n){const r=e("events");t.exports=class extends r{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}}},{events:"events"}],13:[function(e,t,n){const r=e("debug")("bittorrent-tracker:websocket-tracker"),i=e("simple-peer"),s=e("randombytes"),o=e("simple-websocket"),a=e("../common"),u=e("./tracker"),c={},h=1e4,l=18e5,d=12e4,f=5e4;class p extends u{constructor(e,t,n){super(e,t),r("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=Math.min(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary};this._send(t)}destroy(e=g){if(this.destroyed)return e(null);this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer);for(const e in this.peers){const t=this.peers[e];clearTimeout(t.trackerTimeout),t.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,c[this.announceUrl]&&(c[this.announceUrl].consumers-=1),c[this.announceUrl].consumers>0)return e();let t=c[this.announceUrl];if(delete c[this.announceUrl],t.on("error",g),t.once("close",e),!this.expectingResponse)return r();var n=setTimeout(r,a.DESTROY_TIMEOUT);function r(){n&&(clearTimeout(n),n=null),t.removeListener("data",r),t.destroy(),t=null}t.once("data",r)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=e=>{this._onSocketError(e)},this._onSocketDataBound=e=>{this._onSocketData(e)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=c[this.announceUrl],this.socket?(c[this.announceUrl].consumers+=1,this.socket.connected&&this._onSocketConnectBound()):(this.socket=c[this.announceUrl]=new o(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void r("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,a.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;r("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const i=e.interval||e["min interval"];i&&this.setInterval(1e3*i);const s=e["tracker id"];if(s&&(this._trackerId=s),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:a.binaryToHex(e.info_hash)});this.client.emit("update",t)}let o;if(e.offer&&e.peer_id&&(r("creating peer (from remote offer)"),(o=this._createPeer()).id=a.binaryToHex(e.peer_id),o.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),o.signal(e.offer),this.client.emit("peer",o)),e.answer&&e.peer_id){const t=a.binaryToHex(e.offer_id);(o=this.peers[t])?(o.id=a.binaryToHex(e.peer_id),o.signal(e.answer),this.client.emit("peer",o),clearTimeout(o.trackerTimeout),o.trackerTimeout=null,delete this.peers[t]):r(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);0!==t.length?t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:a.binaryToHex(t)});this.client.emit("scrape",n)}):this.client.emit("warning",new Error("invalid scrape response"))}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=Math.floor(Math.random()*d)+Math.min(Math.pow(2,this.retries)*h,l);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),r("reconnecting socket in %s ms",e)}_send(e){if(this.destroyed)return;this.expectingResponse=!0;const t=JSON.stringify(e);r("send %s",t),this.socket.send(t)}_generateOffers(e,t){const n=this,i=[];r("generating %s offers",e);for(let t=0;t{i.push({offer:t,offer_id:a.hexToBinary(e)}),u()}),t.trackerTimeout=setTimeout(()=>{r("tracker timeout: destroying peer"),t.trackerTimeout=null,delete n.peers[e],t.destroy()},f),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function u(){i.length===e&&(r("generated %s offers",e),t(i))}u()}_createPeer(e){const t=this;e=Object.assign({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc},e);const n=new i(e);return n.once("error",r),n.once("connect",function e(){n.removeListener("error",r);n.removeListener("connect",e)}),n;function r(e){t.client.emit("warning",new Error(`Connection error: ${e.message}`)),n.destroy()}}}function g(){}p.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,p._socketPool=c,t.exports=p},{"../common":14,"./tracker":12,debug:"debug",randombytes:24,"simple-peer":44,"simple-websocket":45}],14:[function(e,t,n){(function(t){n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e=String(e)),t.from(e,"hex").toString("binary")};var r=e("./common-node");Object.assign(n,r)}).call(this,e("buffer").Buffer)},{"./common-node":15,buffer:16}],15:[function(e,t,n){},{}],16:[function(e,t,n){(function(t){"use strict";var r=e("base64-js"),i=e("ieee754"),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=t,n.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},n.INSPECT_MAX_BYTES=50;var o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=new Uint8Array(e);return Object.setPrototypeOf(n,t.prototype),n}function t(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,n)}function u(e,n,r){if("string"==typeof e)return function(e,n){"string"==typeof n&&""!==n||(n="utf8");if(!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|f(e,n),i=a(r),s=i.write(e,n);s!==r&&(i=i.slice(0,s));return i}(e,n);if(ArrayBuffer.isView(e))return l(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(q(e,ArrayBuffer)||e&&q(e.buffer,ArrayBuffer))return function(e,n,r){if(n<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function f(e,n){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||q(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var s=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(s)return i?-1:U(e).length;n=(""+n).toLowerCase(),s=!0}}function p(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return k(this,t,n);case"latin1":case"binary":return A(this,t,n);case"base64":return C(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,n,r,i,s){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(s)return-1;r=e.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof n&&(n=t.from(n,i)),t.isBuffer(n))return 0===n.length?-1:y(e,n,r,i,s);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):y(e,[n],r,i,s);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var s,o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=n;sa&&(n=a-u),s=n;s>=0;s--){for(var l=!0,d=0;di&&(r=i):r=i;var s=t.length;r>s/2&&(r=s/2);for(var o=0;o>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function C(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(h=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),i+=l}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rt&&(e+=" ... "),""},s&&(t.prototype[s]=t.prototype.inspect),t.prototype.compare=function(e,n,r,i,s){if(q(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),n<0||r>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&n>=r)return 0;if(i>=s)return-1;if(n>=r)return 1;if(this===e)return 0;for(var o=(s>>>=0)-(i>>>=0),a=(r>>>=0)-(n>>>=0),u=Math.min(o,a),c=this.slice(i,s),h=e.slice(n,r),l=0;l>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return _(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function k(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;ir)&&(n=r);for(var i="",s=t;sn)throw new RangeError("Trying to access beyond buffer length")}function x(e,n,r,i,s,o){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>s||ne.length)throw new RangeError("Index out of range")}function O(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(e,t,n,r,s){return t=+t,n>>>=0,s||O(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,s){return t=+t,n>>>=0,s||O(e,0,n,8),i.write(e,t,n,r,52,8),n+8}t.prototype.slice=function(e,n){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(n=void 0===n?r:~~n)<0?(n+=r)<0&&(n=0):n>r&&(n=r),n>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},t.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=this[e],i=1,s=0;++s=(i*=128)&&(r-=Math.pow(2,8*t)),r},t.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},t.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t>>>=0,n>>>=0,r)||x(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s>>=0,n>>>=0,r)||x(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},t.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);x(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+n},t.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);x(this,e,t,n,i-1,-i)}var s=n-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},t.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},t.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},t.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},t.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},t.prototype.copy=function(e,n,r,i){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),n>=e.length&&(n=e.length),n||(n=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-n=0;--o)e[o+n]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),n);return s},t.prototype.fill=function(e,n,r,i){if("string"==typeof e){if("string"==typeof n?(i=n,n=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var s=e.charCodeAt(0);("utf8"===i&&s<128||"latin1"===i)&&(e=s)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(n<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=n;o55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function j(e){return r.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:16,ieee754:19}],17:[function(e,t,n){t.exports=function(t){function n(e){let t=0;for(let n=0;n{if("%%"===t)return t;a++;const s=r.formatters[i];if("function"==typeof s){const r=e[a];t=s.call(n,r),e.splice(a,1),a--}return t}),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return o.namespace=e,o.enabled=r.enabled(e),o.useColors=r.useColors(),o.color=n(e),o.destroy=i,o.extend=s,"function"==typeof r.init&&r.init(o),r.instances.push(o),o}function i(){const e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function s(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},r.disable=function(){const e=[...r.names.map(o),...r.skips.map(o).map(e=>"-"+e)].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(t=0;t{r[e]=t[e]}),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}},{ms:21}],18:[function(e,t,n){t.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],19:[function(e,t,n){n.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,u=(1<>1,h=-7,l=n?i-1:0,d=n?-1:1,f=e[t+l];for(l+=d,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=256*s+e[t+l],l+=d,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=r;h>0;o=256*o+e[t+l],l+=d,h-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),s-=c}return(f?-1:1)*o*Math.pow(2,s-r)},n.write=function(e,t,n,r,i,s){var o,a,u,c=8*s-i-1,h=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:s-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+l>=1?d/u:d*Math.pow(2,1-l))*u>=2&&(o++,u/=2),o+l>=h?(a=0,o=h):o+l>=1?(a=(t*u-1)*Math.pow(2,i),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(o=o<0;e[n+f]=255&o,f+=p,o/=256,c-=8);e[n+f-p]|=128*g}},{}],20:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],21:[function(e,t,n){var r=1e3,i=60*r,s=60*i,o=24*s,a=7*o,u=365.25*o;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*u;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*o;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return c(e,t,o,"day");if(t>=s)return c(e,t,s,"hour");if(t>=i)return c(e,t,i,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=s)return Math.round(e/s)+"h";if(t>=i)return Math.round(e/i)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],22:[function(e,t,n){var r=e("wrappy");function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function s(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(i),t.exports.strict=r(s),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return s(this)},configurable:!0})})},{wrappy:49}],23:[function(e,t,n){var r,i,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(e){i=a}}();var c,h=[],l=!1,d=-1;function f(){l&&c&&(l=!1,c.length?h=c.concat(h):d=-1,h.length&&p())}function p(){if(!l){var e=u(f);l=!0;for(var t=h.length;t;){for(c=h,h=[];++d1)for(var n=1;ns)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(e);if(e>0)if(e>i)for(var u=0;u2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,n){var r,i,o,a;if("string"==typeof t&&(i="not ",t.substr(!o||o<0?0:+o,i.length)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var u=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(u," ").concat(r," ").concat(s(t,"type"))}return a+=". Received type ".concat(typeof n)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=r},{}],26:[function(e,t,n){(function(e){"use strict";var n=new Set;t.exports.emitExperimentalWarning=e.emitWarning?function(t){if(!n.has(t)){var r=t+" is an experimental feature. This feature could change at any time";n.add(t),e.emitWarning(r,"ExperimentalWarning")}}:function(){}}).call(this,e("_process"))},{_process:23}],27:[function(e,t,n){(function(n){"use strict";var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=c;var i=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(c,i);for(var o=r(s.prototype),a=0;a0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),r)o.endEmitted?e.emit("error",new _):R(e,o,t,!0);else if(o.ended)e.emit("error",new b);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||0!==t.length?R(e,o,t,!1):P(e,o)):R(e,o,t,!1)}else r||(o.reading=!1,P(e,o));return!o.ended&&(o.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(I,e))}function I(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||e.emit("readable"),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function P(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function L(e){c("readable nexttick read 0"),e.read(0)}function D(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function N(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function U(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){c("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function F(e,t){for(var n=0,r=e.length;n=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=A(e,t))&&t.ended)return 0===t.length&&U(this),null;var r,i=t.needReadable;return c("need readable",i),(0===t.length||t.length-e0?N(e,t):null)?(t.needReadable=!0,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&U(this)),null!==r&&this.emit("data",r),r},C.prototype._read=function(e){this.emit("error",new w("_read()"))},C.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,t);var o=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?u:m;function a(t,n){c("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",h),e.removeListener("error",f),e.removeListener("unpipe",a),r.removeListener("end",u),r.removeListener("end",m),r.removeListener("data",d),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function u(){c("onend"),e.end()}i.endEmitted?n.nextTick(o):r.once("end",o),e.on("unpipe",a);var h=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",h);var l=!1;function d(t){c("ondata");var n=e.write(t);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==F(i.pipes,e))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function f(t){c("onerror",t),m(),e.removeListener("error",f),0===s(e,"error")&&e.emit("error",t)}function p(){e.removeListener("finish",g),m()}function g(){c("onfinish"),e.removeListener("close",p),m()}function m(){c("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",f),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),e},C.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(L,this))),r},C.prototype.addListener=C.prototype.on,C.prototype.removeListener=function(e,t){var r=o.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(O,this),r},C.prototype.removeAllListeners=function(e){var t=o.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(O,this),t},C.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(D,e,t))}(this,e)),e.paused=!1,this},C.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},C.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",function(){if(c("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){(c("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i)||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var s=0;s-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(e,t,n){n(new g("_write()"))},C.prototype._writev=null,C.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,I(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),C.prototype.destroy=l.destroy,C.prototype._undestroy=l.undestroy,C.prototype._destroy=function(e,t){t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":25,"./_stream_duplex":27,"./internal/streams/destroy":34,"./internal/streams/state":37,"./internal/streams/stream":38,_process:23,buffer:16,inherits:20,"util-deprecate":48}],32:[function(e,t,n){(function(n){"use strict";var r;function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e("./end-of-stream"),o=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),h=Symbol("lastPromise"),l=Symbol("handlePromise"),d=Symbol("stream");function f(e,t){return{value:e,done:t}}function p(e){var t=e[o];if(null!==t){var n=e[d].read();null!==n&&(e[h]=null,e[o]=null,e[a]=null,t(f(n,!1)))}}function g(e){n.nextTick(p,e)}var m=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(r={get stream(){return this[d]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(f(void 0,!0));if(this[d].destroyed)return new Promise(function(t,r){n.nextTick(function(){e[u]?r(e[u]):t(f(void 0,!0))})});var r,i=this[h];if(i)r=new Promise(function(e,t){return function(n,r){e.then(function(){t[c]?n(f(void 0,!0)):t[l](n,r)},r)}}(i,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(f(s,!1));r=new Promise(this[l])}return this[h]=r,r}},Symbol.asyncIterator,function(){return this}),i(r,"return",function(){var e=this;return new Promise(function(t,n){e[d].destroy(null,function(e){e?n(e):t(f(void 0,!0))})})}),r),m);t.exports=function(e){var t,n=Object.create(y,(i(t={},d,{value:e,writable:!0}),i(t,o,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,l,{value:function(e,t){var r=n[d].read();r?(n[h]=null,n[o]=null,n[a]=null,e(f(r,!1))):(n[o]=e,n[a]=t)},writable:!0}),t));return n[h]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[h]=null,n[o]=null,n[a]=null,t(e)),void(n[u]=e)}var r=n[o];null!==r&&(n[h]=null,n[o]=null,n[a]=null,r(f(void 0,!0))),n[c]=!0}),e.on("readable",g.bind(null,n)),n}}).call(this,e("_process"))},{"./end-of-stream":35,_process:23}],33:[function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("buffer").Buffer,s=e("util").inspect,o=s&&s.custom||"inspect";t.exports=function(){function e(){this.head=null,this.tail=null,this.length=0}var t=e.prototype;return t.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},t.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},t.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},t.clear=function(){this.head=this.tail=null,this.length=0},t.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},t.concat=function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,s=i.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,n=s,r=a,i.prototype.copy.call(t,n,r),a+=o.data.length,o=o.next;return s},t.consume=function(e,t){var n;return ei.length?i.length:e;if(s===i.length?r+=i:r+=i.slice(0,e),0===(e-=s)){s===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(s));break}++n}return this.length-=n,r},t._getBuffer=function(e){var t=i.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var s=n.data,o=e>s.length?s.length:e;if(s.copy(t,t.length-e,0,o),0===(e-=o)){o===s.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=s.slice(o));break}++r}return this.length-=r,t},t[o]=function(e,t){return s(this,function(e){for(var t=1;t0,function(e){h||(h=e),e&&d.forEach(u),s||(d.forEach(u),l(h))})});return n.reduce(c)}},{"../../../errors":25,"./end-of-stream":35}],37:[function(e,t,n){"use strict";var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,n,i){var s=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}}},{"../../../errors":25}],38:[function(e,t,n){t.exports=e("events").EventEmitter},{events:"events"}],39:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":27,"./lib/_stream_passthrough.js":28,"./lib/_stream_readable.js":29,"./lib/_stream_transform.js":30,"./lib/_stream_writable.js":31,"./lib/internal/streams/end-of-stream.js":35,"./lib/internal/streams/pipeline.js":36}],40:[function(e,t,n){(function(e){t.exports=function(t,n){var r,i,s,o=!0;Array.isArray(t)?(r=[],i=t.length):(s=Object.keys(t),r={},i=s.length);function a(t){function i(){n&&n(t,r),n=null}o?e.nextTick(i):i()}function u(e,t,n){r[e]=n,(0==--i||t)&&a(t)}i?s?s.forEach(function(e){t[e](function(t,n){u(e,t,n)})}):t.forEach(function(e,t){e(function(e,n){u(t,e,n)})}):a(null);o=!1}}).call(this,e("_process"))},{_process:23}],41:[function(e,t,n){var r=e("buffer"),i=r.Buffer;function s(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return i(e,t,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(s(r,n),n.Buffer=o),o.prototype=Object.create(i.prototype),s(i,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=i(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:16}],42:[function(e,t,n){var r=e("safe-buffer").Buffer;function i(e,t){this._block=r.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=r.from(e,t));for(var n=this._block,i=this._blockSize,s=e.length,o=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(4294967295&n)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},{"safe-buffer":41}],43:[function(e,t,n){var r=e("inherits"),i=e("./hash"),s=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function h(e){return e<<30|e>>>2}function l(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}r(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,d=0;d<16;++d)n[d]=e.readInt32BE(4*d);for(;d<80;++d)n[d]=(t=n[d-3]^n[d-8]^n[d-14]^n[d-16])<<1|t>>>31;for(var f=0;f<80;++f){var p=~~(f/20),g=c(r)+l(p,i,s,a)+u+n[f]+o[p]|0;u=a,a=s,s=h(i),i=r,r=g}this._a=r+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=s.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=u},{"./hash":42,inherits:20,"safe-buffer":41}],44:[function(e,t,n){(function(n){t.exports=c;var r=e("debug")("simple-peer"),i=e("get-browser-rtc"),s=e("inherits"),o=e("randombytes"),a=e("readable-stream"),u=5e3;function c(e){var t=this;if(!(t instanceof c))return new c(e);if(t._id=o(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),a.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||o(20).toString("hex"):null,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||c.channelConfig,t.config=Object.assign({},c.config,e.config),t.offerOptions=e.offerOptions||{},t.answerOptions=e.answerOptions||{},t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,t.iceCompleteTimeout=e.iceCompleteTimeout||u,t.destroyed=!1,t._connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localFamily=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:i(),!t._wrtc)throw"undefined"==typeof window?l("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT"):l("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._iceCompleteTimer=null,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!t.initiator,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new Map,t._firstStable=!0,t._closingInterval=null,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null;try{t._pc=new t._wrtc.RTCPeerConnection(t.config)}catch(e){return void setTimeout(()=>t.destroy(e),0)}t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)},t.initiator&&t._needsNegotiation(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function h(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}function l(e,t){var n=new Error(e);return n.code=t,n}s(c,a.Duplex),c.WEBRTC_SUPPORT=!!i(),c.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}],sdpSemantics:"unified-plan"},c.channelConfig={},Object.defineProperty(c.prototype,"bufferSize",{get:function(){return this._channel&&this._channel.bufferedAmount||0}}),Object.defineProperty(c.prototype,"connected",{get:function(){return this._connected&&"open"===this._channel.readyState}}),c.prototype.address=function(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}},c.prototype.signal=function(e){var t=this;if(t.destroyed)throw l("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.renegotiate&&t.initiator&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.transceiverRequest&&t.initiator&&(t._debug("got request for transceiver"),t.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(t._pc.localDescription&&t._pc.localDescription.type&&t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e)).then(function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())}).catch(function(e){t.destroy(l(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||t.destroy(l("signal() called with invalid signal data","ERR_SIGNALING"))},c.prototype._addIceCandidate=function(e){var t=this,n=new t._wrtc.RTCIceCandidate(e);t._pc.addIceCandidate(n).catch(function(e){var r;!n.address||n.address.endsWith(".local")?(r="Ignoring unsupported ICE candidate.",console.warn(r)):t.destroy(l(e,"ERR_ADD_ICE_CANDIDATE"))})},c.prototype.send=function(e){this._channel.send(e)},c.prototype.addTransceiver=function(e,t){if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(e){this.destroy(e)}else this.emit("signal",{transceiverRequest:{kind:e,init:t}})},c.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(n){t.addTrack(n,e)})},c.prototype.addTrack=function(e,t){this._debug("addTrack()");var n=this._senderMap.get(e)||new Map,r=n.get(t);r?r.removed?this.destroy(l("Track has been removed. You should enable/disable tracks that you want to re-add.","ERR_SENDER_REMOVED")):this.destroy(l("Track has already been added to that stream.","ERR_SENDER_ALREADY_ADDED")):(r=this._pc.addTrack(e,t),n.set(t,r),this._senderMap.set(e,n),this._needsNegotiation())},c.prototype.replaceTrack=function(e,t,n){this._debug("replaceTrack()");var r=this._senderMap.get(e),i=r?r.get(n):null;i||this.destroy(l("Cannot replace track that was never added.","ERR_TRACK_NOT_ADDED")),t&&this._senderMap.set(t,r),null!=i.replaceTrack?i.replaceTrack(t):this.destroy(l("replaceTrack is not supported in this browser","ERR_UNSUPPORTED_REPLACETRACK"))},c.prototype.removeTrack=function(e,t){this._debug("removeSender()");var n=this._senderMap.get(e),r=n?n.get(t):null;r||this.destroy(l("Cannot remove track that was never added.","ERR_TRACK_NOT_ADDED"));try{r.removed=!0,this._pc.removeTrack(r)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(r):this.destroy(e)}this._needsNegotiation()},c.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(n){t.removeTrack(n,e)})},c.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation"),e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},c.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?(e._queuedNegotiation=!0,e._debug("already negotiating, queueing")):(e._debug("start negotiation"),setTimeout(()=>{e._createOffer()},0)):e._isNegotiating||(e._debug("requesting negotiation from initiator"),e.emit("signal",{renegotiate:!0})),e._isNegotiating=!0},c.prototype.destroy=function(e){this._destroy(e,function(){})},c.prototype._destroy=function(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.destroyed=!0,this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close"),t()}},c.prototype._setupData=function(e){var t=this;if(!e.channel)return t.destroy(l("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=65536),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(l(e,"ERR_DATA_CHANNEL"))};var n=!1;t._closingInterval=setInterval(function(){t._channel&&"closing"===t._channel.readyState?(n&&t._onChannelClose(),n=!0):n=!1},5e3)},c.prototype._read=function(){},c.prototype._write=function(e,t,n){if(this.destroyed)return n(l("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(e){return this.destroy(l(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},c.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e._connected?t():e.once("connect",t))},c.prototype._startIceCompleteTimeout=function(){var e=this;e.destroyed||e._iceCompleteTimer||(e._debug("started iceComplete timeout"),e._iceCompleteTimer=setTimeout(function(){e._iceComplete||(e._iceComplete=!0,e._debug("iceComplete timeout completed"),e.emit("iceTimeout"),e.emit("_iceComplete"))},e.iceCompleteTimeout))},c.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(e.offerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=h(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){if(e._debug("createOffer success"),e.destroyed)return;e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}).catch(function(t){e.destroy(l(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(l(t,"ERR_CREATE_OFFER"))})},c.prototype._requestMissingTransceivers=function(){var e=this;e._pc.getTransceivers&&e._pc.getTransceivers().forEach(t=>{t.mid||!t.sender.track||t.requested||(t.requested=!0,e.addTransceiver(t.sender.track.kind))})},c.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(e.answerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp}),e.initiator||e._requestMissingTransceivers()}}e.destroyed||(e.trickle||e.allowHalfTrickle||(t.sdp=h(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){if(e.destroyed)return;e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}).catch(function(t){e.destroy(l(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(l(t,"ERR_CREATE_ANSWER"))})},c.prototype._onIceStateChange=function(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(l("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(l("Ice connection closed.","ERR_ICE_CONNECTION_CLOSED"))}},c.prototype.getStats=function(e){var t=this;function n(e){return"[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach(function(t){Object.assign(e,t)}),e}0===t._pc.getStats.length?t._pc.getStats().then(function(t){var r=[];t.forEach(function(e){r.push(n(e))}),e(null,r)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var r=[];t.forEach(function(e){r.push(n(e))}),e(null,r)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(r){if(!t.destroyed){var i=[];r.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,i.push(n(t))}),e(null,i)}},function(t){e(t)}):e(null,[])},c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e._connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,function t(){e.destroyed||e.getStats(function(n,r){if(!e.destroyed){n&&(r=[]);var i={},s={},o={},a=!1;if(r.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(s[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(o[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&c(o[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&c(e)}),a||Object.keys(o).length&&!Object.keys(s).length){if(e._connecting=!1,e._connected=!0,e._chunk){try{e.send(e._chunk)}catch(n){return e.destroy(l(n,"ERR_DATA_CHANNEL"))}e._chunk=null,e._debug('sent chunk from "write before connect"');var u=e._cb;e._cb=null,u(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}else setTimeout(t,100)}function c(t){a=!0;var n=s[t.localCandidateId];n&&(n.ip||n.address)?(e.localAddress=n.ip||n.address,e.localPort=Number(n.port)):n&&n.ipAddress?(e.localAddress=n.ipAddress,e.localPort=Number(n.portNumber)):"string"==typeof t.googLocalAddress&&(n=t.googLocalAddress.split(":"),e.localAddress=n[0],e.localPort=Number(n[1])),e.localAddress&&(e.localFamily=e.localAddress.includes(":")?"IPv6":"IPv4");var r=i[t.remoteCandidateId];r&&(r.ip||r.address)?(e.remoteAddress=r.ip||r.address,e.remotePort=Number(r.port)):r&&r.ipAddress?(e.remoteAddress=r.ipAddress,e.remotePort=Number(r.portNumber)):"string"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(":"),e.remoteAddress=r[0],e.remotePort=Number(r[1])),e.remoteAddress&&(e.remoteFamily=e.remoteAddress.includes(":")?"IPv6":"IPv4"),e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}})}())},c.prototype._onInterval=function(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()},c.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"!==e._pc.signalingState||e._firstStable||(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e._pc.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._firstStable=!1,e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},c.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())},c.prototype._onChannelMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}},c.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},c.prototype._onChannelOpen=function(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},c.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},c.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t._debug("on track"),t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n}),t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},c.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],r.apply(null,t)}}).call(this,e("buffer").Buffer)},{buffer:16,debug:"debug","get-browser-rtc":18,inherits:20,randombytes:24,"readable-stream":39}],45:[function(e,t,n){(function(n,r){const i=e("debug")("simple-websocket"),s=e("randombytes"),o=e("readable-stream"),a=e("ws"),u="function"!=typeof a?WebSocket:a,c=65536;class h extends o.Duplex{constructor(e={}){if("string"==typeof e&&(e={url:e}),super(e=Object.assign({allowHalfOpen:!1},e)),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=s(4).toString("hex").slice(0,7),this._debug("new websocket: %o",e),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,e.socket)this.url=e.socket.url,this._ws=e.socket,this.connected=e.socket.readyState===u.OPEN;else{this.url=e.url;try{this._ws="function"==typeof a?new u(e.url,e):new u(e.url)}catch(e){return void n.nextTick(()=>this.destroy(e))}}this._ws.binaryType="arraybuffer",this._ws.onopen=()=>{this._onOpen()},this._ws.onmessage=e=>{this._onMessage(e)},this._ws.onclose=()=>{this._onClose()},this._ws.onerror=()=>{this.destroy(new Error("connection error to "+this.url))},this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}send(e){this._ws.send(e)}destroy(e){this._destroy(e,()=>{})}_destroy(e,t){if(!this.destroyed){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._ws){const t=this._ws,n=()=>{t.onclose=null};if(t.readyState===u.CLOSED)n();else try{t.onclose=n,t.close()}catch(e){n()}t.onopen=null,t.onmessage=null,t.onerror=()=>{}}if(this._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){const t=e.code;(e=new Error(e.message)).code=t}this.emit("error",e)}this.emit("close"),t()}}_read(){}_write(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof a&&this._ws.bufferedAmount>c?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n}_onFinish(){if(this.destroyed)return;const e=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?e():this.once("connect",e)}_onMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}_onOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(e)}this._chunk=null,this._debug('sent chunk from "write before connect"');const e=this._cb;this._cb=null,e(null)}"function"!=typeof a&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_onInterval(){if(!this._cb||!this._ws||this._ws.bufferedAmount>c)return;this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const e=this._cb;this._cb=null,e(null)}_onClose(){this.destroyed||(this._debug("on close"),this.destroy())}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}h.WEBSOCKET_SUPPORT=!!u,t.exports=h}).call(this,e("_process"),e("buffer").Buffer)},{_process:23,buffer:16,debug:"debug",randombytes:24,"readable-stream":39,ws:15}],46:[function(e,t,n){"use strict";var r=e("safe-buffer").Buffer,i=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=h,this.end=l,t=3;break;default:return this.write=d,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function u(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function h(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}n.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(e.lastNeed=i-1),i;if(--r=0)return i>0&&(e.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":41}],47:[function(e,t,n){"use strict";t.exports=function(e,t,n){return 0===e.length?e:t?(n||e.sort(t),function(e,t){for(var n=1,r=e.length,i=e[0],s=e[0],o=1;o{"%%"!==e&&(r++,"%c"===e&&(i=r))}),e.splice(i,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG);return e},n.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage=function(){try{return localStorage}catch(e){}}(),n.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.exports=e("./common")(n);const{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":17,_process:23}],events:[function(e,t,n){var r=Object.create||function(e){var t=function(){};return t.prototype=e,new t},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},s=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var a,u=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(e){a=!1}function h(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,n){if(t)e.call(n);else for(var r=e.length,i=v(e,r),s=0;s0&&a.length>s){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=o[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(n=o[e]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:l(n,c,this);break;case 2:d(n,c,this,arguments[1]);break;case 3:f(n,c,this,arguments[1],arguments[2]);break;case 4:p(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r=0;s--)this.removeListener(e,t[s]);return this},o.prototype.listeners=function(e){return w(this,e,!0)},o.prototype.rawListeners=function(e){return w(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):_.call(e,t)},o.prototype.listenerCount=_,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],"p2p-media-loader-core":[function(e,t,n){"use strict";function r(e){for(var t in e)n.hasOwnProperty(t)||(n[t]=e[t])}Object.defineProperty(n,"__esModule",{value:!0}),n.version="0.6.2",r(e("./loader-interface")),r(e("./hybrid-loader"))},{"./hybrid-loader":4,"./loader-interface":5}]},{},[2]); diff --git a/resources/assets/player/js/p2p-media-loader-hlsjs.min.js b/resources/assets/player/js/p2p-media-loader-hlsjs.min.js new file mode 100644 index 0000000..10be8a9 --- /dev/null +++ b/resources/assets/player/js/p2p-media-loader-hlsjs.min.js @@ -0,0 +1,28 @@ +require=function t(e,r,n){function i(a,o){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[a]={exports:{}};e[a][0].call(l.exports,(function(t){return i(e[a][1][t]||t)}),l,l.exports,t,e,r,n)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;ai.Events[t])).forEach((t=>this.loader.on(t,((...e)=>this.emit(t,...e)))))}static isSupported(){return i.HybridLoader.isSupported()}createLoaderClass(){return o.createHlsJsLoaderClass(a.HlsJsLoader,this)}async destroy(){await this.segmentManager.destroy()}getSettings(){return{segments:this.segmentManager.getSettings(),loader:this.loader.getSettings()}}getDetails(){return{loader:this.loader.getDetails()}}setPlayingSegment(t,e,r,n){this.segmentManager.setPlayingSegment(t,e,r,n)}setPlayingSegmentByCurrentTime(t){this.segmentManager.setPlayingSegmentByCurrentTime(t)}}r.Engine=u},{"./hlsjs-loader":4,"./hlsjs-loader-class":3,"./segment-manager":5,events:"events","p2p-media-loader-core":"p2p-media-loader-core"}],3:[function(t,e,r){e.exports.createHlsJsLoaderClass=function(t,e){function r(){this.impl=new t(e.segmentManager),this.stats=this.impl.stats}return r.prototype.load=function(t,e,r){this.context=t,this.impl.load(t,e,r)},r.prototype.abort=function(){this.impl.abort(this.context)},r.prototype.destroy=function(){this.context&&this.impl.abort(this.context)},r.getEngine=function(){return e},r}},{}],4:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HlsJsLoader=void 0;r.HlsJsLoader=class{constructor(t){this.stats={},this.segmentManager=t}async load(t,e,r){if(t.type)try{const e=await this.segmentManager.loadPlaylist(t.url);this.successPlaylist(e,t,r)}catch(e){this.error(e,t,r)}else if(t.frag)try{const e=await this.segmentManager.loadSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart});void 0!==e.content&&setTimeout((()=>this.successSegment(e.content,e.downloadBandwidth,t,r)),0)}catch(e){setTimeout((()=>this.error(e,t,r)),0)}else console.warn("Unknown load request",t)}abort(t){this.segmentManager.abortSegment(t.url,null==t.rangeStart||null==t.rangeEnd?void 0:{offset:t.rangeStart,length:t.rangeEnd-t.rangeStart})}successPlaylist(t,e,r){const n=performance.now();this.stats.trequest=n-300,this.stats.tfirst=n-200,this.stats.tload=n,this.stats.loaded=t.response.length,r.onSuccess({url:t.responseURL,data:t.response},this.stats,e)}successSegment(t,e,r,n){const i=performance.now(),s=t.byteLength/(void 0===e||e<=0?12500:e);this.stats.trequest=i-1-s,this.stats.tfirst=i-s,this.stats.tload=i,this.stats.loaded=t.byteLength,n.onSuccess({url:r.url,data:t},this.stats,r)}error(t,e,r){r.onError(t,e)}}},{}],5:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SegmentManager=void 0;const n=t("p2p-media-loader-core"),i=t("m3u8-parser"),s={forwardSegmentCount:20,swarmId:void 0,assetsStorage:void 0};r.SegmentManager=class{constructor(t,e={}){this.masterPlaylist=null,this.variantPlaylists=new Map,this.segmentRequest=null,this.playQueue=[],this.onSegmentLoaded=t=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&f(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onSuccess(t.data.slice(0),t.downloadBandwidth),this.segmentRequest=null)},this.onSegmentError=(t,e)=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&f(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError(e),this.segmentRequest=null)},this.onSegmentAbort=t=>{this.segmentRequest&&this.segmentRequest.segmentUrl===t.url&&f(this.segmentRequest.segmentByterange)===t.range&&(this.segmentRequest.onError("Loading aborted: internal abort"),this.segmentRequest=null)},this.settings=Object.assign(Object.assign({},s),e),this.loader=t,this.loader.on(n.Events.SegmentLoaded,this.onSegmentLoaded),this.loader.on(n.Events.SegmentError,this.onSegmentError),this.loader.on(n.Events.SegmentAbort,this.onSegmentAbort)}getSettings(){return this.settings}processPlaylist(t,e,r){const n=new i.Parser;n.push(e),n.end();const s=new a(t,r,n.manifest);if(s.manifest.playlists){this.masterPlaylist=s;for(const[t,e]of this.variantPlaylists){const{streamSwarmId:r,found:n,index:i}=this.getStreamSwarmId(e.requestUrl);n?(e.streamSwarmId=r,e.streamId="V"+i.toString()):this.variantPlaylists.delete(t)}}else{const{streamSwarmId:e,found:r,index:n}=this.getStreamSwarmId(t);(r||null===this.masterPlaylist)&&(s.streamSwarmId=e,s.streamId=null===this.masterPlaylist?void 0:"V"+n.toString(),this.variantPlaylists.set(t,s),this.updateSegments())}}async loadPlaylist(t){const e=this.settings.assetsStorage;let r;if(void 0!==e){let n;n=this.getMasterSwarmId(),void 0===n&&(n=t.split("?")[0]);const i=await e.getAsset(t,void 0,n);void 0!==i?r={responseURL:i.responseUri,response:i.data}:(r=await this.loadContent(t,"text"),e.storeAsset({masterManifestUri:null!==this.masterPlaylist?this.masterPlaylist.requestUrl:t,masterSwarmId:n,requestUri:t,responseUri:r.responseURL,data:r.response}))}else r=await this.loadContent(t,"text");return this.processPlaylist(t,r.response,r.responseURL),r}async loadSegment(t,e){const r=this.getSegmentLocation(t,e),n=f(e);if(!r){let e;const r=this.settings.assetsStorage;if(void 0!==r){let i,s=null!==this.masterPlaylist?this.masterPlaylist.requestUrl:void 0;if(i=this.getMasterSwarmId(),void 0===i&&1===this.variantPlaylists.size&&(i=this.variantPlaylists.values().next().value.requestUrl.split("?")[0]),void 0===s&&1===this.variantPlaylists.size&&(s=this.variantPlaylists.values().next().value.requestUrl),void 0!==i&&void 0!==s){const a=await r.getAsset(t,n,i);if(void 0!==a)e=a.data;else{const a=await this.loadContent(t,"arraybuffer",n);e=a.response,r.storeAsset({masterManifestUri:s,masterSwarmId:i,requestUri:t,requestRange:n,responseUri:a.responseURL,data:e})}}}if(void 0===e){e=(await this.loadContent(t,"arraybuffer",n)).response}return{content:e,downloadBandwidth:0}}const i=(r.playlist.manifest.mediaSequence?r.playlist.manifest.mediaSequence:0)+r.segmentIndex;if(this.playQueue.length>0){this.playQueue[this.playQueue.length-1].segmentSequence!==i-1&&(this.playQueue=[])}this.segmentRequest&&this.segmentRequest.onError("Cancel segment request: simultaneous segment requests are not supported");const s=new Promise(((n,s)=>{this.segmentRequest=new o(t,e,i,r.playlist.requestUrl,((t,e)=>n({content:t,downloadBandwidth:e})),(t=>s(t)))}));return this.playQueue.push({segmentUrl:t,segmentByterange:e,segmentSequence:i}),this.loadSegments(r.playlist,r.segmentIndex,!0),s}setPlayingSegment(t,e,r,n){const i=this.playQueue.findIndex((r=>r.segmentUrl==t&&u(r.segmentByterange,e)));i>=0&&(this.playQueue=this.playQueue.slice(i),this.playQueue[0].playPosition={start:r,duration:n},this.updateSegments())}setPlayingSegmentByCurrentTime(t){if(0===this.playQueue.length||!this.playQueue[0].playPosition)return;const e=this.playQueue[0].playPosition;e.start+e.duration-t<.2&&(this.playQueue=this.playQueue.slice(1),this.updateSegments())}abortSegment(t,e){this.segmentRequest&&this.segmentRequest.segmentUrl===t&&u(this.segmentRequest.segmentByterange,e)&&(this.segmentRequest.onSuccess(void 0,0),this.segmentRequest=null)}async destroy(){this.segmentRequest&&(this.segmentRequest.onError("Loading aborted: object destroyed"),this.segmentRequest=null),this.masterPlaylist=null,this.variantPlaylists.clear(),this.playQueue=[],void 0!==this.settings.assetsStorage&&await this.settings.assetsStorage.destroy(),await this.loader.destroy()}updateSegments(){if(!this.segmentRequest)return;const t=this.getSegmentLocation(this.segmentRequest.segmentUrl,this.segmentRequest.segmentByterange);t&&this.loadSegments(t.playlist,t.segmentIndex,!1)}getSegmentLocation(t,e){for(const r of this.variantPlaylists.values()){const n=r.getSegmentIndex(t,e);if(n>=0)return{playlist:r,segmentIndex:n}}}async loadSegments(t,e,r){const n=[],i=t.manifest.segments,s=t.manifest.mediaSequence?t.manifest.mediaSequence:0;let a=null,o=Math.max(0,this.playQueue.length-1);const u=this.getMasterSwarmId();for(let l=e;l{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,r&&s.setRequestHeader("Range",r),s.addEventListener("readystatechange",(()=>{4===s.readyState&&(s.status>=200&&s.status<300?n(s):i(s.statusText))}));const a=this.loader.getSettings().xhrSetup;a&&a(s,t),s.send()}))}};class a{constructor(t,e,r){this.requestUrl=t,this.responseUrl=e,this.manifest=r,this.streamSwarmId=""}getSegmentIndex(t,e){for(let r=0;r-1},e.trigger=function(t){var e=this.listeners[t];if(e)if(2===arguments.length)for(var r=e.length,n=0;n0?a-4:a;for(r=0;r>16&255,u[l++]=e>>8&255,u[l++]=255&e;2===o&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[l++]=255&e);1===o&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],a=16383,o=0,u=r-i;ou?u:o+a));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,u=a.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function l(t,e,r){for(var i,s,a=[],o=e;o>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],13:[function(t,e,r){(function(e){(function(){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +"use strict";var e=t("base64-js"),n=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function s(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=a.prototype,e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return o(t,e,r)}function o(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|g(t,e),n=s(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(X(t,ArrayBuffer)||t&&X(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function g(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||X(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(t).length;default:if(i)return n?-1:j(t).length;e=(""+e).toLowerCase(),i=!0}}function c(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return I(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function p(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),k(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var s,a=1,o=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,o/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var l=-1;for(s=r;so&&(r=o-u),s=r;s>=0;s--){for(var h=!0,g=0;gi&&(n=i):n=i;var s=e.length;n>s/2&&(n=s/2);for(var a=0;a>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function I(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function T(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:f>223?3:f>191?2:1;if(i+h<=r)switch(h){case 1:f<128&&(l=f);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&f)<<6|63&s)>127&&(l=u);break;case 3:s=t[i+1],a=t[i+2],128==(192&s)&&128==(192&a)&&(u=(15&f)<<12|(63&s)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:s=t[i+1],a=t[i+2],o=t[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(u=(15&f)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&u<1114112&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);var r="",n=0;for(;ne&&(t+=" ... "),""},a.prototype.compare=function(t,e,r,n,i){if(X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),u=Math.min(s,o),f=this.slice(n,i),l=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function R(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,s){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function x(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,s){return e=+e,r>>>=0,s||x(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function L(t,e,r,i,s){return e=+e,r>>>=0,s||x(t,0,r,8),n.write(t,e,r,i,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],i=1,s=0;++s>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],i=1,s=0;++s=(i*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},a.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),n.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),n.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),n.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),n.read(this,t,!1,52,8)},a.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var s=0,a=1,o=0;for(this[e]=255&t;++s>0)-o&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var s=r-1,a=1,o=0;for(this[e+s]=255&t;--s>=0&&(a*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function D(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function X(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function k(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":12,buffer:13,ieee754:15}],14:[function(t,e,r){(function(t){(function(){var r;r="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},e.exports=r}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(t,e,r){ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ +r.read=function(t,e,r,n,i){var s,a,o=8*i-n-1,u=(1<>1,l=-7,h=r?i-1:0,g=r?-1:1,c=t[e+h];for(h+=g,s=c&(1<<-l)-1,c>>=-l,l+=o;l>0;s=256*s+t[e+h],h+=g,l-=8);for(a=s&(1<<-l)-1,s>>=-l,l+=n;l>0;a=256*a+t[e+h],h+=g,l-=8);if(0===s)s=1-f;else{if(s===u)return a?NaN:1/0*(c?-1:1);a+=Math.pow(2,n),s-=f}return(c?-1:1)*a*Math.pow(2,s-n)},r.write=function(t,e,r,n,i,s){var a,o,u,f=8*s-i-1,l=(1<>1,g=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,c=n?0:s-1,d=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+h>=1?g/u:g*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=l?(o=0,a=l):a+h>=1?(o=(e*u-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+c]=255&o,c+=d,o/=256,i-=8);for(a=a<0;t[r+c]=255&a,c+=d,a/=256,f-=8);t[r+c-d]|=128*p}},{}],16:[function(t,e,r){ +/*! @name m3u8-parser @version 4.5.2 @license Apache-2.0 */ +"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t("@babel/runtime/helpers/inheritsLoose"),i=t("@videojs/vhs-utils/cjs/stream.js"),s=t("@babel/runtime/helpers/extends"),a=t("@babel/runtime/helpers/assertThisInitialized"),o=t("@videojs/vhs-utils/cjs/decode-b64-to-uint8-array.js");function u(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var f=u(n),l=u(i),h=u(s),g=u(a),c=u(o),d=function(t){function e(){var e;return(e=t.call(this)||this).buffer="",e}return f.default(e,t),e.prototype.push=function(t){var e;for(this.buffer+=t,e=this.buffer.indexOf("\n");e>-1;e=this.buffer.indexOf("\n"))this.trigger("data",this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)},e}(l.default),p=function(t){for(var e,r=t.split(new RegExp('(?:^|,)((?:[^=]*)=(?:"[^"]*"|[^,]*))')),n={},i=r.length;i--;)""!==r[i]&&((e=/([^=]*)=(.*)/.exec(r[i]).slice(1))[0]=e[0].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^\s+|\s+$/g,""),e[1]=e[1].replace(/^['"](.*)['"]$/g,"$1"),n[e[0]]=e[1]);return n},y=function(t){function e(){var e;return(e=t.call(this)||this).customParsers=[],e.tagMappers=[],e}f.default(e,t);var r=e.prototype;return r.push=function(t){var e,r,n=this;0!==(t=t.trim()).length&&("#"===t[0]?this.tagMappers.reduce((function(e,r){var n=r(t);return n===t?e:e.concat([n])}),[t]).forEach((function(t){for(var i=0;i0&&(a.duration=t.duration),0===t.duration&&(a.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=s},key:function(){if(t.attributes)if("NONE"!==t.attributes.METHOD)if(t.attributes.URI){if("urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"===t.attributes.KEYFORMAT){return-1===["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(t.attributes.METHOD)?void this.trigger("warn",{message:"invalid key method provided for Widevine"}):("SAMPLE-AES-CENC"===t.attributes.METHOD&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),"data:text/plain;base64,"!==t.attributes.URI.substring(0,23)?void this.trigger("warn",{message:"invalid key URI provided for Widevine"}):t.attributes.KEYID&&"0x"===t.attributes.KEYID.substring(0,2)?void(this.manifest.contentProtection={"com.widevine.alpha":{attributes:{schemeIdUri:t.attributes.KEYFORMAT,keyId:t.attributes.KEYID.substring(2)},pssh:c.default(t.attributes.URI.split(",")[1])}}):void this.trigger("warn",{message:"invalid key ID provided for Widevine"}))}t.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),n={method:t.attributes.METHOD||"AES-128",uri:t.attributes.URI},void 0!==t.attributes.IV&&(n.iv=t.attributes.IV)}else this.trigger("warn",{message:"ignoring key declaration without URI"});else n=null;else this.trigger("warn",{message:"ignoring key declaration without attribute list"})},"media-sequence":function(){isFinite(t.number)?this.manifest.mediaSequence=t.number:this.trigger("warn",{message:"ignoring invalid media sequence: "+t.number})},"discontinuity-sequence":function(){isFinite(t.number)?(this.manifest.discontinuitySequence=t.number,f=t.number):this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+t.number})},"playlist-type":function(){/VOD|EVENT/.test(t.playlistType)?this.manifest.playlistType=t.playlistType:this.trigger("warn",{message:"ignoring unknown playlist type: "+t.playlist})},map:function(){r={},t.uri&&(r.uri=t.uri),t.byterange&&(r.byterange=t.byterange)},"stream-inf":function(){this.manifest.playlists=s,this.manifest.mediaGroups=this.manifest.mediaGroups||u,t.attributes?(a.attributes||(a.attributes={}),h.default(a.attributes,t.attributes)):this.trigger("warn",{message:"ignoring empty stream-inf attributes"})},media:function(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||u,t.attributes&&t.attributes.TYPE&&t.attributes["GROUP-ID"]&&t.attributes.NAME){var r=this.manifest.mediaGroups[t.attributes.TYPE];r[t.attributes["GROUP-ID"]]=r[t.attributes["GROUP-ID"]]||{},e=r[t.attributes["GROUP-ID"]],(g={default:/yes/i.test(t.attributes.DEFAULT)}).default?g.autoselect=!0:g.autoselect=/yes/i.test(t.attributes.AUTOSELECT),t.attributes.LANGUAGE&&(g.language=t.attributes.LANGUAGE),t.attributes.URI&&(g.uri=t.attributes.URI),t.attributes["INSTREAM-ID"]&&(g.instreamId=t.attributes["INSTREAM-ID"]),t.attributes.CHARACTERISTICS&&(g.characteristics=t.attributes.CHARACTERISTICS),t.attributes.FORCED&&(g.forced=/yes/i.test(t.attributes.FORCED)),e[t.attributes.NAME]=g}else this.trigger("warn",{message:"ignoring incomplete or missing media group"})},discontinuity:function(){f+=1,a.discontinuity=!0,this.manifest.discontinuityStarts.push(s.length)},"program-date-time":function(){void 0===this.manifest.dateTimeString&&(this.manifest.dateTimeString=t.dateTimeString,this.manifest.dateTimeObject=t.dateTimeObject),a.dateTimeString=t.dateTimeString,a.dateTimeObject=t.dateTimeObject},targetduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid target duration: "+t.duration}):this.manifest.targetDuration=t.duration},totalduration:function(){!isFinite(t.duration)||t.duration<0?this.trigger("warn",{message:"ignoring invalid total duration: "+t.duration}):this.manifest.totalDuration=t.duration},start:function(){t.attributes&&!isNaN(t.attributes["TIME-OFFSET"])?this.manifest.start={timeOffset:t.attributes["TIME-OFFSET"],precise:t.attributes.PRECISE}:this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"})},"cue-out":function(){a.cueOut=t.data},"cue-out-cont":function(){a.cueOutCont=t.data},"cue-in":function(){a.cueIn=t.data}}[t.tagType]||o).call(i)},uri:function(){a.uri=t.uri,s.push(a),this.manifest.targetDuration&&!("duration"in a)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),a.duration=this.manifest.targetDuration),n&&(a.key=n),a.timeline=f,r&&(a.map=r),a={}},comment:function(){},custom:function(){t.segment?(a.custom=a.custom||{},a.custom[t.customType]=t.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[t.customType]=t.data)}})[t.type].call(i)})),e}f.default(e,t);var r=e.prototype;return r.push=function(t){this.lineStream.push(t)},r.end=function(){this.lineStream.push("\n")},r.addParser=function(t){this.parseStream.addParser(t)},r.addTagMapper=function(t){this.parseStream.addTagMapper(t)},e}(l.default);r.LineStream=d,r.ParseStream=y,r.Parser=m},{"@babel/runtime/helpers/assertThisInitialized":6,"@babel/runtime/helpers/extends":7,"@babel/runtime/helpers/inheritsLoose":8,"@videojs/vhs-utils/cjs/decode-b64-to-uint8-array.js":10,"@videojs/vhs-utils/cjs/stream.js":11}],"p2p-media-loader-hlsjs":[function(t,e,r){"use strict"; +/** + * @license Apache-2.0 + * Copyright 2018 Novage LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};function s(t){t&&t.config&&t.config.loader&&"function"==typeof t.config.loader.getEngine&&a(t,t.config.loader.getEngine())}function a(t,e){t.on("hlsFragChanged",((t,r)=>{const n=r.frag,i=2!==n.byteRange.length?void 0:{offset:n.byteRange[0],length:n.byteRange[1]-n.byteRange[0]};e.setPlayingSegment(n.url,i,n.start,n.duration)})),t.on("hlsDestroying",(async()=>{await e.destroy()})),t.on("hlsError",((r,n)=>{if("bufferStalledError"===n.details){const r=void 0===t.media?t.el_:t.media;if(void 0===r)return;e.setPlayingSegmentByCurrentTime(r.currentTime)}}))}Object.defineProperty(r,"__esModule",{value:!0}),r.initJwPlayer=r.initMediaElementJsPlayer=r.initVideoJsHlsJsPlugin=r.initVideoJsContribHlsJsPlayer=r.initFlowplayerHlsJsPlayer=r.initClapprPlayer=r.initHlsJsPlayer=r.version=void 0,r.version="0.6.2",i(t("./engine"),r),i(t("./segment-manager"),r),r.initHlsJsPlayer=s,r.initClapprPlayer=function(t){t.on("play",(()=>{const e=t.core.getCurrentPlayback();e._hls&&!e._hls._p2pm_linitialized&&(e._hls._p2pm_linitialized=!0,s(t.core.getCurrentPlayback()._hls))}))},r.initFlowplayerHlsJsPlayer=function(t){t.on("ready",(()=>s(t.engine.hlsjs?t.engine.hlsjs:t.engine.hls)))},r.initVideoJsContribHlsJsPlayer=function(t){t.ready((()=>{const e=t.tech_.options_;e&&e.hlsjsConfig&&e.hlsjsConfig.loader&&"function"==typeof e.hlsjsConfig.loader.getEngine&&a(t.tech_,e.hlsjsConfig.loader.getEngine())}))},r.initVideoJsHlsJsPlugin=function(){null!=videojs&&null!=videojs.Html5Hlsjs&&videojs.Html5Hlsjs.addHook("beforeinitialize",((t,e)=>{e.config&&e.config.loader&&"function"==typeof e.config.loader.getEngine&&a(e,e.config.loader.getEngine())}))},r.initMediaElementJsPlayer=function(t){t.addEventListener("hlsFragChanged",(e=>{const r=t.hlsPlayer;if(r&&r.config&&r.config.loader&&"function"==typeof r.config.loader.getEngine){const t=r.config.loader.getEngine();if(e.data&&e.data.length>1){const r=e.data[1].frag,n=2!==r.byteRange.length?void 0:{offset:r.byteRange[0],length:r.byteRange[1]-r.byteRange[0]};t.setPlayingSegment(r.url,n,r.start,r.duration)}}})),t.addEventListener("hlsDestroying",(async()=>{const e=t.hlsPlayer;if(e&&e.config&&e.config.loader&&"function"==typeof e.config.loader.getEngine){const t=e.config.loader.getEngine();await t.destroy()}})),t.addEventListener("hlsError",(e=>{const r=t.hlsPlayer;if(r&&r.config&&r.config.loader&&"function"==typeof r.config.loader.getEngine&&void 0!==e.data&&"bufferStalledError"===e.data.details){r.config.loader.getEngine().setPlayingSegmentByCurrentTime(r.media.currentTime)}}))},r.initJwPlayer=function(t,e){const r=setInterval((()=>{t.hls&&t.hls.config&&(clearInterval(r),Object.assign(t.hls.config,e),s(t.hls))}),200)}},{"./engine":2,"./segment-manager":5}]},{},[1]); diff --git a/resources/assets/plugins/carousel/owl.carousel.min.css b/resources/assets/plugins/carousel/owl.carousel.min.css new file mode 100644 index 0000000..a71df11 --- /dev/null +++ b/resources/assets/plugins/carousel/owl.carousel.min.css @@ -0,0 +1,6 @@ +/** + * Owl Carousel v2.3.4 + * Copyright 2013-2018 David Deutsch + * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE + */ +.owl-carousel,.owl-carousel .owl-item{-webkit-tap-highlight-color:transparent;position:relative}.owl-carousel{display:none;width:100%;z-index:1}.owl-carousel .owl-stage{position:relative;-ms-touch-action:pan-Y;touch-action:manipulation;-moz-backface-visibility:hidden}.owl-carousel .owl-stage:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}.owl-carousel .owl-stage-outer{position:relative;overflow:hidden;-webkit-transform:translate3d(0,0,0)}.owl-carousel .owl-item,.owl-carousel .owl-wrapper{-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0)}.owl-carousel .owl-item{min-height:1px;float:left;-webkit-backface-visibility:hidden;-webkit-touch-callout:none}.owl-carousel .owl-item img{display:block;width:100%}.owl-carousel .owl-dots.disabled,.owl-carousel .owl-nav.disabled{display:none}.no-js .owl-carousel,.owl-carousel.owl-loaded{display:block}.owl-carousel .owl-dot,.owl-carousel .owl-nav .owl-next,.owl-carousel .owl-nav .owl-prev{cursor:pointer;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel .owl-nav button.owl-next,.owl-carousel .owl-nav button.owl-prev,.owl-carousel button.owl-dot{background:0 0;color:inherit;border:none;padding:0!important;font:inherit}.owl-carousel.owl-loading{opacity:0;display:block}.owl-carousel.owl-hidden{opacity:0}.owl-carousel.owl-refresh .owl-item{visibility:hidden}.owl-carousel.owl-drag .owl-item{-ms-touch-action:pan-y;touch-action:pan-y;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-grab{cursor:move;cursor:grab}.owl-carousel.owl-rtl{direction:rtl}.owl-carousel.owl-rtl .owl-item{float:right}.owl-carousel .animated{animation-duration:1s;animation-fill-mode:both}.owl-carousel .owl-animated-in{z-index:0}.owl-carousel .owl-animated-out{z-index:1}.owl-carousel .fadeOut{animation-name:fadeOut}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.owl-height{transition:height .5s ease-in-out}.owl-carousel .owl-item .owl-lazy{opacity:0;transition:opacity .4s ease}.owl-carousel .owl-item .owl-lazy:not([src]),.owl-carousel .owl-item .owl-lazy[src^=""]{max-height:0}.owl-carousel .owl-item img.owl-lazy{transform-style:preserve-3d}.owl-carousel .owl-video-wrapper{position:relative;height:100%;background:#000}.owl-carousel .owl-video-play-icon{position:absolute;height:80px;width:80px;left:50%;top:50%;margin-left:-40px;margin-top:-40px;background:url(owl.video.play.png) no-repeat;cursor:pointer;z-index:1;-webkit-backface-visibility:hidden;transition:transform .1s ease}.owl-carousel .owl-video-play-icon:hover{-ms-transform:scale(1.3,1.3);transform:scale(1.3,1.3)}.owl-carousel .owl-video-playing .owl-video-play-icon,.owl-carousel .owl-video-playing .owl-video-tn{display:none}.owl-carousel .owl-video-tn{opacity:0;height:100%;background-position:center center;background-repeat:no-repeat;background-size:contain;transition:opacity .4s ease}.owl-carousel .owl-video-frame{position:relative;z-index:1;height:100%;width:100%} \ No newline at end of file diff --git a/resources/assets/plugins/carousel/owl.carousel.min.js b/resources/assets/plugins/carousel/owl.carousel.min.js new file mode 100644 index 0000000..fbbffc5 --- /dev/null +++ b/resources/assets/plugins/carousel/owl.carousel.min.js @@ -0,0 +1,7 @@ +/** + * Owl Carousel v2.3.4 + * Copyright 2013-2018 David Deutsch + * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE + */ +!function(a,b,c,d){function e(b,c){this.settings=null,this.options=a.extend({},e.Defaults,c),this.$element=a(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},a.each(["onResize","onThrottledResize"],a.proxy(function(b,c){this._handlers[c]=a.proxy(this[c],this)},this)),a.each(e.Plugins,a.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),a.each(e.Workers,a.proxy(function(b,c){this._pipe.push({filter:c.filter,run:a.proxy(c.run,this)})},this)),this.setup(),this.initialize()}e.Defaults={items:3,loop:!1,center:!1,rewind:!1,checkVisibility:!0,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",slideTransition:"",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},e.Width={Default:"default",Inner:"inner",Outer:"outer"},e.Type={Event:"event",State:"state"},e.Plugins={},e.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(a){var b=this.settings.margin||"",c=!this.settings.autoWidth,d=this.settings.rtl,e={width:"auto","margin-left":d?b:"","margin-right":d?"":b};!c&&this.$stage.children().css(e),a.css=e}},{filter:["width","items","settings"],run:function(a){var b=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,c=null,d=this._items.length,e=!this.settings.autoWidth,f=[];for(a.items={merge:!1,width:b};d--;)c=this._mergers[d],c=this.settings.mergeFit&&Math.min(c,this.settings.items)||c,a.items.merge=c>1||a.items.merge,f[d]=e?b*c:this._items[d].width();this._widths=f}},{filter:["items","settings"],run:function(){var b=[],c=this._items,d=this.settings,e=Math.max(2*d.items,4),f=2*Math.ceil(c.length/2),g=d.loop&&c.length?d.rewind?e:Math.max(e,f):0,h="",i="";for(g/=2;g>0;)b.push(this.normalize(b.length/2,!0)),h+=c[b[b.length-1]][0].outerHTML,b.push(this.normalize(c.length-1-(b.length-1)/2,!0)),i=c[b[b.length-1]][0].outerHTML+i,g-=1;this._clones=b,a(h).addClass("cloned").appendTo(this.$stage),a(i).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var a=this.settings.rtl?1:-1,b=this._clones.length+this._items.length,c=-1,d=0,e=0,f=[];++c",h)||this.op(b,"<",g)&&this.op(b,">",h))&&i.push(c);this.$stage.children(".active").removeClass("active"),this.$stage.children(":eq("+i.join("), :eq(")+")").addClass("active"),this.$stage.children(".center").removeClass("center"),this.settings.center&&this.$stage.children().eq(this.current()).addClass("center")}}],e.prototype.initializeStage=function(){this.$stage=this.$element.find("."+this.settings.stageClass),this.$stage.length||(this.$element.addClass(this.options.loadingClass),this.$stage=a("<"+this.settings.stageElement+">",{class:this.settings.stageClass}).wrap(a("",{class:this.settings.stageOuterClass})),this.$element.append(this.$stage.parent()))},e.prototype.initializeItems=function(){var b=this.$element.find(".owl-item");if(b.length)return this._items=b.get().map(function(b){return a(b)}),this._mergers=this._items.map(function(){return 1}),void this.refresh();this.replace(this.$element.children().not(this.$stage.parent())),this.isVisible()?this.refresh():this.invalidate("width"),this.$element.removeClass(this.options.loadingClass).addClass(this.options.loadedClass)},e.prototype.initialize=function(){if(this.enter("initializing"),this.trigger("initialize"),this.$element.toggleClass(this.settings.rtlClass,this.settings.rtl),this.settings.autoWidth&&!this.is("pre-loading")){var a,b,c;a=this.$element.find("img"),b=this.settings.nestedItemSelector?"."+this.settings.nestedItemSelector:d,c=this.$element.children(b).width(),a.length&&c<=0&&this.preloadAutoWidthImages(a)}this.initializeStage(),this.initializeItems(),this.registerEventHandlers(),this.leave("initializing"),this.trigger("initialized")},e.prototype.isVisible=function(){return!this.settings.checkVisibility||this.$element.is(":visible")},e.prototype.setup=function(){var b=this.viewport(),c=this.options.responsive,d=-1,e=null;c?(a.each(c,function(a){a<=b&&a>d&&(d=Number(a))}),e=a.extend({},this.options,c[d]),"function"==typeof e.stagePadding&&(e.stagePadding=e.stagePadding()),delete e.responsive,e.responsiveClass&&this.$element.attr("class",this.$element.attr("class").replace(new RegExp("("+this.options.responsiveClass+"-)\\S+\\s","g"),"$1"+d))):e=a.extend({},this.options),this.trigger("change",{property:{name:"settings",value:e}}),this._breakpoint=d,this.settings=e,this.invalidate("settings"),this.trigger("changed",{property:{name:"settings",value:this.settings}})},e.prototype.optionsLogic=function(){this.settings.autoWidth&&(this.settings.stagePadding=!1,this.settings.merge=!1)},e.prototype.prepare=function(b){var c=this.trigger("prepare",{content:b});return c.data||(c.data=a("<"+this.settings.itemElement+"/>").addClass(this.options.itemClass).append(b)),this.trigger("prepared",{content:c.data}),c.data},e.prototype.update=function(){for(var b=0,c=this._pipe.length,d=a.proxy(function(a){return this[a]},this._invalidated),e={};b0)&&this._pipe[b].run(e),b++;this._invalidated={},!this.is("valid")&&this.enter("valid")},e.prototype.width=function(a){switch(a=a||e.Width.Default){case e.Width.Inner:case e.Width.Outer:return this._width;default:return this._width-2*this.settings.stagePadding+this.settings.margin}},e.prototype.refresh=function(){this.enter("refreshing"),this.trigger("refresh"),this.setup(),this.optionsLogic(),this.$element.addClass(this.options.refreshClass),this.update(),this.$element.removeClass(this.options.refreshClass),this.leave("refreshing"),this.trigger("refreshed")},e.prototype.onThrottledResize=function(){b.clearTimeout(this.resizeTimer),this.resizeTimer=b.setTimeout(this._handlers.onResize,this.settings.responsiveRefreshRate)},e.prototype.onResize=function(){return!!this._items.length&&(this._width!==this.$element.width()&&(!!this.isVisible()&&(this.enter("resizing"),this.trigger("resize").isDefaultPrevented()?(this.leave("resizing"),!1):(this.invalidate("width"),this.refresh(),this.leave("resizing"),void this.trigger("resized")))))},e.prototype.registerEventHandlers=function(){a.support.transition&&this.$stage.on(a.support.transition.end+".owl.core",a.proxy(this.onTransitionEnd,this)),!1!==this.settings.responsive&&this.on(b,"resize",this._handlers.onThrottledResize),this.settings.mouseDrag&&(this.$element.addClass(this.options.dragClass),this.$stage.on("mousedown.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("dragstart.owl.core selectstart.owl.core",function(){return!1})),this.settings.touchDrag&&(this.$stage.on("touchstart.owl.core",a.proxy(this.onDragStart,this)),this.$stage.on("touchcancel.owl.core",a.proxy(this.onDragEnd,this)))},e.prototype.onDragStart=function(b){var d=null;3!==b.which&&(a.support.transform?(d=this.$stage.css("transform").replace(/.*\(|\)| /g,"").split(","),d={x:d[16===d.length?12:4],y:d[16===d.length?13:5]}):(d=this.$stage.position(),d={x:this.settings.rtl?d.left+this.$stage.width()-this.width()+this.settings.margin:d.left,y:d.top}),this.is("animating")&&(a.support.transform?this.animate(d.x):this.$stage.stop(),this.invalidate("position")),this.$element.toggleClass(this.options.grabClass,"mousedown"===b.type),this.speed(0),this._drag.time=(new Date).getTime(),this._drag.target=a(b.target),this._drag.stage.start=d,this._drag.stage.current=d,this._drag.pointer=this.pointer(b),a(c).on("mouseup.owl.core touchend.owl.core",a.proxy(this.onDragEnd,this)),a(c).one("mousemove.owl.core touchmove.owl.core",a.proxy(function(b){var d=this.difference(this._drag.pointer,this.pointer(b));a(c).on("mousemove.owl.core touchmove.owl.core",a.proxy(this.onDragMove,this)),Math.abs(d.x)0^this.settings.rtl?"left":"right";a(c).off(".owl.core"),this.$element.removeClass(this.options.grabClass),(0!==d.x&&this.is("dragging")||!this.is("valid"))&&(this.speed(this.settings.dragEndSpeed||this.settings.smartSpeed),this.current(this.closest(e.x,0!==d.x?f:this._drag.direction)),this.invalidate("position"),this.update(),this._drag.direction=f,(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&this._drag.target.one("click.owl.core",function(){return!1})),this.is("dragging")&&(this.leave("dragging"),this.trigger("dragged"))},e.prototype.closest=function(b,c){var e=-1,f=30,g=this.width(),h=this.coordinates();return this.settings.freeDrag||a.each(h,a.proxy(function(a,i){return"left"===c&&b>i-f&&bi-g-f&&b",h[a+1]!==d?h[a+1]:i-g)&&(e="left"===c?a+1:a),-1===e},this)),this.settings.loop||(this.op(b,">",h[this.minimum()])?e=b=this.minimum():this.op(b,"<",h[this.maximum()])&&(e=b=this.maximum())),e},e.prototype.animate=function(b){var c=this.speed()>0;this.is("animating")&&this.onTransitionEnd(),c&&(this.enter("animating"),this.trigger("translate")),a.support.transform3d&&a.support.transition?this.$stage.css({transform:"translate3d("+b+"px,0px,0px)",transition:this.speed()/1e3+"s"+(this.settings.slideTransition?" "+this.settings.slideTransition:"")}):c?this.$stage.animate({left:b+"px"},this.speed(),this.settings.fallbackEasing,a.proxy(this.onTransitionEnd,this)):this.$stage.css({left:b+"px"})},e.prototype.is=function(a){return this._states.current[a]&&this._states.current[a]>0},e.prototype.current=function(a){if(a===d)return this._current;if(0===this._items.length)return d;if(a=this.normalize(a),this._current!==a){var b=this.trigger("change",{property:{name:"position",value:a}});b.data!==d&&(a=this.normalize(b.data)),this._current=a,this.invalidate("position"),this.trigger("changed",{property:{name:"position",value:this._current}})}return this._current},e.prototype.invalidate=function(b){return"string"===a.type(b)&&(this._invalidated[b]=!0,this.is("valid")&&this.leave("valid")),a.map(this._invalidated,function(a,b){return b})},e.prototype.reset=function(a){(a=this.normalize(a))!==d&&(this._speed=0,this._current=a,this.suppress(["translate","translated"]),this.animate(this.coordinates(a)),this.release(["translate","translated"]))},e.prototype.normalize=function(a,b){var c=this._items.length,e=b?0:this._clones.length;return!this.isNumeric(a)||c<1?a=d:(a<0||a>=c+e)&&(a=((a-e/2)%c+c)%c+e/2),a},e.prototype.relative=function(a){return a-=this._clones.length/2,this.normalize(a,!0)},e.prototype.maximum=function(a){var b,c,d,e=this.settings,f=this._coordinates.length;if(e.loop)f=this._clones.length/2+this._items.length-1;else if(e.autoWidth||e.merge){if(b=this._items.length)for(c=this._items[--b].width(),d=this.$element.width();b--&&!((c+=this._items[b].width()+this.settings.margin)>d););f=b+1}else f=e.center?this._items.length-1:this._items.length-e.items;return a&&(f-=this._clones.length/2),Math.max(f,0)},e.prototype.minimum=function(a){return a?0:this._clones.length/2},e.prototype.items=function(a){return a===d?this._items.slice():(a=this.normalize(a,!0),this._items[a])},e.prototype.mergers=function(a){return a===d?this._mergers.slice():(a=this.normalize(a,!0),this._mergers[a])},e.prototype.clones=function(b){var c=this._clones.length/2,e=c+this._items.length,f=function(a){return a%2==0?e+a/2:c-(a+1)/2};return b===d?a.map(this._clones,function(a,b){return f(b)}):a.map(this._clones,function(a,c){return a===b?f(c):null})},e.prototype.speed=function(a){return a!==d&&(this._speed=a),this._speed},e.prototype.coordinates=function(b){var c,e=1,f=b-1;return b===d?a.map(this._coordinates,a.proxy(function(a,b){return this.coordinates(b)},this)):(this.settings.center?(this.settings.rtl&&(e=-1,f=b+1),c=this._coordinates[b],c+=(this.width()-c+(this._coordinates[f]||0))/2*e):c=this._coordinates[f]||0,c=Math.ceil(c))},e.prototype.duration=function(a,b,c){return 0===c?0:Math.min(Math.max(Math.abs(b-a),1),6)*Math.abs(c||this.settings.smartSpeed)},e.prototype.to=function(a,b){var c=this.current(),d=null,e=a-this.relative(c),f=(e>0)-(e<0),g=this._items.length,h=this.minimum(),i=this.maximum();this.settings.loop?(!this.settings.rewind&&Math.abs(e)>g/2&&(e+=-1*f*g),a=c+e,(d=((a-h)%g+g)%g+h)!==a&&d-e<=i&&d-e>0&&(c=d-e,a=d,this.reset(c))):this.settings.rewind?(i+=1,a=(a%i+i)%i):a=Math.max(h,Math.min(i,a)),this.speed(this.duration(c,a,b)),this.current(a),this.isVisible()&&this.update()},e.prototype.next=function(a){a=a||!1,this.to(this.relative(this.current())+1,a)},e.prototype.prev=function(a){a=a||!1,this.to(this.relative(this.current())-1,a)},e.prototype.onTransitionEnd=function(a){if(a!==d&&(a.stopPropagation(),(a.target||a.srcElement||a.originalTarget)!==this.$stage.get(0)))return!1;this.leave("animating"),this.trigger("translated")},e.prototype.viewport=function(){var d;return this.options.responsiveBaseElement!==b?d=a(this.options.responsiveBaseElement).width():b.innerWidth?d=b.innerWidth:c.documentElement&&c.documentElement.clientWidth?d=c.documentElement.clientWidth:console.warn("Can not detect viewport width."),d},e.prototype.replace=function(b){this.$stage.empty(),this._items=[],b&&(b=b instanceof jQuery?b:a(b)),this.settings.nestedItemSelector&&(b=b.find("."+this.settings.nestedItemSelector)),b.filter(function(){return 1===this.nodeType}).each(a.proxy(function(a,b){b=this.prepare(b),this.$stage.append(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)},this)),this.reset(this.isNumeric(this.settings.startPosition)?this.settings.startPosition:0),this.invalidate("items")},e.prototype.add=function(b,c){var e=this.relative(this._current);c=c===d?this._items.length:this.normalize(c,!0),b=b instanceof jQuery?b:a(b),this.trigger("add",{content:b,position:c}),b=this.prepare(b),0===this._items.length||c===this._items.length?(0===this._items.length&&this.$stage.append(b),0!==this._items.length&&this._items[c-1].after(b),this._items.push(b),this._mergers.push(1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)):(this._items[c].before(b),this._items.splice(c,0,b),this._mergers.splice(c,0,1*b.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)),this._items[e]&&this.reset(this._items[e].index()),this.invalidate("items"),this.trigger("added",{content:b,position:c})},e.prototype.remove=function(a){(a=this.normalize(a,!0))!==d&&(this.trigger("remove",{content:this._items[a],position:a}),this._items[a].remove(),this._items.splice(a,1),this._mergers.splice(a,1),this.invalidate("items"),this.trigger("removed",{content:null,position:a}))},e.prototype.preloadAutoWidthImages=function(b){b.each(a.proxy(function(b,c){this.enter("pre-loading"),c=a(c),a(new Image).one("load",a.proxy(function(a){c.attr("src",a.target.src),c.css("opacity",1),this.leave("pre-loading"),!this.is("pre-loading")&&!this.is("initializing")&&this.refresh()},this)).attr("src",c.attr("src")||c.attr("data-src")||c.attr("data-src-retina"))},this))},e.prototype.destroy=function(){this.$element.off(".owl.core"),this.$stage.off(".owl.core"),a(c).off(".owl.core"),!1!==this.settings.responsive&&(b.clearTimeout(this.resizeTimer),this.off(b,"resize",this._handlers.onThrottledResize));for(var d in this._plugins)this._plugins[d].destroy();this.$stage.children(".cloned").remove(),this.$stage.unwrap(),this.$stage.children().contents().unwrap(),this.$stage.children().unwrap(),this.$stage.remove(),this.$element.removeClass(this.options.refreshClass).removeClass(this.options.loadingClass).removeClass(this.options.loadedClass).removeClass(this.options.rtlClass).removeClass(this.options.dragClass).removeClass(this.options.grabClass).attr("class",this.$element.attr("class").replace(new RegExp(this.options.responsiveClass+"-\\S+\\s","g"),"")).removeData("owl.carousel")},e.prototype.op=function(a,b,c){var d=this.settings.rtl;switch(b){case"<":return d?a>c:a":return d?ac;case">=":return d?a<=c:a>=c;case"<=":return d?a>=c:a<=c}},e.prototype.on=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},e.prototype.off=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)},e.prototype.trigger=function(b,c,d,f,g){var h={item:{count:this._items.length,index:this.current()}},i=a.camelCase(a.grep(["on",b,d],function(a){return a}).join("-").toLowerCase()),j=a.Event([b,"owl",d||"carousel"].join(".").toLowerCase(),a.extend({relatedTarget:this},h,c));return this._supress[b]||(a.each(this._plugins,function(a,b){b.onTrigger&&b.onTrigger(j)}),this.register({type:e.Type.Event,name:b}),this.$element.trigger(j),this.settings&&"function"==typeof this.settings[i]&&this.settings[i].call(this,j)),j},e.prototype.enter=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]===d&&(this._states.current[b]=0),this._states.current[b]++},this))},e.prototype.leave=function(b){a.each([b].concat(this._states.tags[b]||[]),a.proxy(function(a,b){this._states.current[b]--},this))},e.prototype.register=function(b){if(b.type===e.Type.Event){if(a.event.special[b.name]||(a.event.special[b.name]={}),!a.event.special[b.name].owl){var c=a.event.special[b.name]._default;a.event.special[b.name]._default=function(a){return!c||!c.apply||a.namespace&&-1!==a.namespace.indexOf("owl")?a.namespace&&a.namespace.indexOf("owl")>-1:c.apply(this,arguments)},a.event.special[b.name].owl=!0}}else b.type===e.Type.State&&(this._states.tags[b.name]?this._states.tags[b.name]=this._states.tags[b.name].concat(b.tags):this._states.tags[b.name]=b.tags,this._states.tags[b.name]=a.grep(this._states.tags[b.name],a.proxy(function(c,d){return a.inArray(c,this._states.tags[b.name])===d},this)))},e.prototype.suppress=function(b){a.each(b,a.proxy(function(a,b){this._supress[b]=!0},this))},e.prototype.release=function(b){a.each(b,a.proxy(function(a,b){delete this._supress[b]},this))},e.prototype.pointer=function(a){var c={x:null,y:null};return a=a.originalEvent||a||b.event,a=a.touches&&a.touches.length?a.touches[0]:a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:a,a.pageX?(c.x=a.pageX,c.y=a.pageY):(c.x=a.clientX,c.y=a.clientY),c},e.prototype.isNumeric=function(a){return!isNaN(parseFloat(a))},e.prototype.difference=function(a,b){return{x:a.x-b.x,y:a.y-b.y}},a.fn.owlCarousel=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var d=a(this),f=d.data("owl.carousel");f||(f=new e(this,"object"==typeof b&&b),d.data("owl.carousel",f),a.each(["next","prev","to","destroy","refresh","replace","add","remove"],function(b,c){f.register({type:e.Type.Event,name:c}),f.$element.on(c+".owl.carousel.core",a.proxy(function(a){a.namespace&&a.relatedTarget!==this&&(this.suppress([c]),f[c].apply(this,[].slice.call(arguments,1)),this.release([c]))},f))})),"string"==typeof b&&"_"!==b.charAt(0)&&f[b].apply(f,c)})},a.fn.owlCarousel.Constructor=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._interval=null,this._visible=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoRefresh&&this.watch()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers)};e.Defaults={autoRefresh:!0,autoRefreshInterval:500},e.prototype.watch=function(){this._interval||(this._visible=this._core.isVisible(),this._interval=b.setInterval(a.proxy(this.refresh,this),this._core.settings.autoRefreshInterval))},e.prototype.refresh=function(){this._core.isVisible()!==this._visible&&(this._visible=!this._visible,this._core.$element.toggleClass("owl-hidden",!this._visible),this._visible&&this._core.invalidate("width")&&this._core.refresh())},e.prototype.destroy=function(){var a,c;b.clearInterval(this._interval);for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoRefresh=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._loaded=[],this._handlers={"initialized.owl.carousel change.owl.carousel resized.owl.carousel":a.proxy(function(b){if(b.namespace&&this._core.settings&&this._core.settings.lazyLoad&&(b.property&&"position"==b.property.name||"initialized"==b.type)){var c=this._core.settings,e=c.center&&Math.ceil(c.items/2)||c.items,f=c.center&&-1*e||0,g=(b.property&&b.property.value!==d?b.property.value:this._core.current())+f,h=this._core.clones().length,i=a.proxy(function(a,b){this.load(b)},this);for(c.lazyLoadEager>0&&(e+=c.lazyLoadEager,c.loop&&(g-=c.lazyLoadEager,e++));f++-1||(e.each(a.proxy(function(c,d){var e,f=a(d),g=b.devicePixelRatio>1&&f.attr("data-src-retina")||f.attr("data-src")||f.attr("data-srcset");this._core.trigger("load",{element:f,url:g},"lazy"),f.is("img")?f.one("load.owl.lazy",a.proxy(function(){f.css("opacity",1),this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("src",g):f.is("source")?f.one("load.owl.lazy",a.proxy(function(){this._core.trigger("loaded",{element:f,url:g},"lazy")},this)).attr("srcset",g):(e=new Image,e.onload=a.proxy(function(){f.css({"background-image":'url("'+g+'")',opacity:"1"}),this._core.trigger("loaded",{element:f,url:g},"lazy")},this),e.src=g)},this)),this._loaded.push(d.get(0)))},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this._core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Lazy=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(c){this._core=c,this._previousHeight=null,this._handlers={"initialized.owl.carousel refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&this.update()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&"position"===a.property.name&&this.update()},this),"loaded.owl.lazy":a.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&a.element.closest("."+this._core.settings.itemClass).index()===this._core.current()&&this.update()},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._intervalId=null;var d=this;a(b).on("load",function(){d._core.settings.autoHeight&&d.update()}),a(b).resize(function(){d._core.settings.autoHeight&&(null!=d._intervalId&&clearTimeout(d._intervalId),d._intervalId=setTimeout(function(){d.update()},250))})};e.Defaults={autoHeight:!1,autoHeightClass:"owl-height"},e.prototype.update=function(){var b=this._core._current,c=b+this._core.settings.items,d=this._core.settings.lazyLoad,e=this._core.$stage.children().toArray().slice(b,c),f=[],g=0;a.each(e,function(b,c){f.push(a(c).height())}),g=Math.max.apply(null,f),g<=1&&d&&this._previousHeight&&(g=this._previousHeight),this._previousHeight=g,this._core.$stage.parent().height(g).addClass(this._core.settings.autoHeightClass)},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.AutoHeight=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._videos={},this._playing=null,this._handlers={"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.register({type:"state",name:"playing",tags:["interacting"]})},this),"resize.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.video&&this.isInFullScreen()&&a.preventDefault()},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._core.is("resizing")&&this._core.$stage.find(".cloned .owl-video-frame").remove()},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this._playing&&this.stop()},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find(".owl-video");c.length&&(c.css("display","none"),this.fetch(c,a(b.content)))}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this._core.$element.on(this._handlers),this._core.$element.on("click.owl.video",".owl-video-play-icon",a.proxy(function(a){this.play(a)},this))};e.Defaults={video:!1,videoHeight:!1,videoWidth:!1},e.prototype.fetch=function(a,b){var c=function(){return a.attr("data-vimeo-id")?"vimeo":a.attr("data-vzaar-id")?"vzaar":"youtube"}(),d=a.attr("data-vimeo-id")||a.attr("data-youtube-id")||a.attr("data-vzaar-id"),e=a.attr("data-width")||this._core.settings.videoWidth,f=a.attr("data-height")||this._core.settings.videoHeight,g=a.attr("href");if(!g)throw new Error("Missing video URL.");if(d=g.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com|be\-nocookie\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),d[3].indexOf("youtu")>-1)c="youtube";else if(d[3].indexOf("vimeo")>-1)c="vimeo";else{if(!(d[3].indexOf("vzaar")>-1))throw new Error("Video URL not supported.");c="vzaar"}d=d[6],this._videos[g]={type:c,id:d,width:e,height:f},b.attr("data-video",g),this.thumbnail(a,this._videos[g])},e.prototype.thumbnail=function(b,c){var d,e,f,g=c.width&&c.height?"width:"+c.width+"px;height:"+c.height+"px;":"",h=b.find("img"),i="src",j="",k=this._core.settings,l=function(c){e='',d=k.lazyLoad?a("",{class:"owl-video-tn "+j,srcType:c}):a("",{class:"owl-video-tn",style:"opacity:1;background-image:url("+c+")"}),b.after(d),b.after(e)};if(b.wrap(a("",{class:"owl-video-wrapper",style:g})),this._core.settings.lazyLoad&&(i="data-src",j="owl-lazy"),h.length)return l(h.attr(i)),h.remove(),!1;"youtube"===c.type?(f="//img.youtube.com/vi/"+c.id+"/hqdefault.jpg",l(f)):"vimeo"===c.type?a.ajax({type:"GET",url:"//vimeo.com/api/v2/video/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a[0].thumbnail_large,l(f)}}):"vzaar"===c.type&&a.ajax({type:"GET",url:"//vzaar.com/api/videos/"+c.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){f=a.framegrab_url,l(f)}})},e.prototype.stop=function(){this._core.trigger("stop",null,"video"),this._playing.find(".owl-video-frame").remove(),this._playing.removeClass("owl-video-playing"),this._playing=null,this._core.leave("playing"),this._core.trigger("stopped",null,"video")},e.prototype.play=function(b){var c,d=a(b.target),e=d.closest("."+this._core.settings.itemClass),f=this._videos[e.attr("data-video")],g=f.width||"100%",h=f.height||this._core.$stage.height();this._playing||(this._core.enter("playing"),this._core.trigger("play",null,"video"),e=this._core.items(this._core.relative(e.index())),this._core.reset(e.index()),c=a(''),c.attr("height",h),c.attr("width",g),"youtube"===f.type?c.attr("src","//www.youtube.com/embed/"+f.id+"?autoplay=1&rel=0&v="+f.id):"vimeo"===f.type?c.attr("src","//player.vimeo.com/video/"+f.id+"?autoplay=1"):"vzaar"===f.type&&c.attr("src","//view.vzaar.com/"+f.id+"/player?autoplay=true"),a(c).wrap('').insertAfter(e.find(".owl-video")),this._playing=e.addClass("owl-video-playing"))},e.prototype.isInFullScreen=function(){var b=c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement;return b&&a(b).parent().hasClass("owl-video-frame")},e.prototype.destroy=function(){var a,b;this._core.$element.off("click.owl.video");for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Video=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this.core=b,this.core.options=a.extend({},e.Defaults,this.core.options),this.swapping=!0,this.previous=d,this.next=d,this.handlers={"change.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&(this.previous=this.core.current(),this.next=a.property.value)},this),"drag.owl.carousel dragged.owl.carousel translated.owl.carousel":a.proxy(function(a){a.namespace&&(this.swapping="translated"==a.type)},this),"translate.owl.carousel":a.proxy(function(a){a.namespace&&this.swapping&&(this.core.options.animateOut||this.core.options.animateIn)&&this.swap()},this)},this.core.$element.on(this.handlers)};e.Defaults={animateOut:!1, +animateIn:!1},e.prototype.swap=function(){if(1===this.core.settings.items&&a.support.animation&&a.support.transition){this.core.speed(0);var b,c=a.proxy(this.clear,this),d=this.core.$stage.children().eq(this.previous),e=this.core.$stage.children().eq(this.next),f=this.core.settings.animateIn,g=this.core.settings.animateOut;this.core.current()!==this.previous&&(g&&(b=this.core.coordinates(this.previous)-this.core.coordinates(this.next),d.one(a.support.animation.end,c).css({left:b+"px"}).addClass("animated owl-animated-out").addClass(g)),f&&e.one(a.support.animation.end,c).addClass("animated owl-animated-in").addClass(f))}},e.prototype.clear=function(b){a(b.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},e.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Animate=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){var e=function(b){this._core=b,this._call=null,this._time=0,this._timeout=0,this._paused=!0,this._handlers={"changed.owl.carousel":a.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._paused&&(this._time=0)},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":a.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":a.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":a.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=a.extend({},e.Defaults,this._core.options)};e.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},e.prototype._next=function(d){this._call=b.setTimeout(a.proxy(this._next,this,d),this._timeout*(Math.round(this.read()/this._timeout)+1)-this.read()),this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},e.prototype.read=function(){return(new Date).getTime()-this._time},e.prototype.play=function(c,d){var e;this._core.is("rotating")||this._core.enter("rotating"),c=c||this._core.settings.autoplayTimeout,e=Math.min(this._time%(this._timeout||c),c),this._paused?(this._time=this.read(),this._paused=!1):b.clearTimeout(this._call),this._time+=this.read()%c-e,this._timeout=c,this._call=b.setTimeout(a.proxy(this._next,this,d),c-e)},e.prototype.stop=function(){this._core.is("rotating")&&(this._time=0,this._paused=!0,b.clearTimeout(this._call),this._core.leave("rotating"))},e.prototype.pause=function(){this._core.is("rotating")&&!this._paused&&(this._time=this.read(),this._paused=!0,b.clearTimeout(this._call))},e.prototype.destroy=function(){var a,b;this.stop();for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.autoplay=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":a.proxy(function(b){b.namespace&&this._core.settings.dotsData&&this._templates.push(''+a(b.content).find("[data-dot]").addBack("[data-dot]").attr("data-dot")+"")},this),"added.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,0,this._templates.pop())},this),"remove.owl.carousel":a.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,1)},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"==a.property.name&&this.draw()},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&!this._initialized&&(this._core.trigger("initialize",null,"navigation"),this.initialize(),this.update(),this.draw(),this._initialized=!0,this._core.trigger("initialized",null,"navigation"))},this),"refreshed.owl.carousel":a.proxy(function(a){a.namespace&&this._initialized&&(this._core.trigger("refresh",null,"navigation"),this.update(),this.draw(),this._core.trigger("refreshed",null,"navigation"))},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers)};e.Defaults={nav:!1,navText:['‹','›'],navSpeed:!1,navElement:'button type="button" role="presentation"',navContainer:!1,navContainerClass:"owl-nav",navClass:["owl-prev","owl-next"],slideBy:1,dotClass:"owl-dot",dotsClass:"owl-dots",dots:!0,dotsEach:!1,dotsData:!1,dotsSpeed:!1,dotsContainer:!1},e.prototype.initialize=function(){var b,c=this._core.settings;this._controls.$relative=(c.navContainer?a(c.navContainer):a("").addClass(c.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=a("<"+c.navElement+">").addClass(c.navClass[0]).html(c.navText[0]).prependTo(this._controls.$relative).on("click",a.proxy(function(a){this.prev(c.navSpeed)},this)),this._controls.$next=a("<"+c.navElement+">").addClass(c.navClass[1]).html(c.navText[1]).appendTo(this._controls.$relative).on("click",a.proxy(function(a){this.next(c.navSpeed)},this)),c.dotsData||(this._templates=[a('').addClass(c.dotClass).append(a("")).prop("outerHTML")]),this._controls.$absolute=(c.dotsContainer?a(c.dotsContainer):a("").addClass(c.dotsClass).appendTo(this.$element)).addClass("disabled"),this._controls.$absolute.on("click","button",a.proxy(function(b){var d=a(b.target).parent().is(this._controls.$absolute)?a(b.target).index():a(b.target).parent().index();b.preventDefault(),this.to(d,c.dotsSpeed)},this));for(b in this._overrides)this._core[b]=a.proxy(this[b],this)},e.prototype.destroy=function(){var a,b,c,d,e;e=this._core.settings;for(a in this._handlers)this.$element.off(a,this._handlers[a]);for(b in this._controls)"$relative"===b&&e.navContainer?this._controls[b].html(""):this._controls[b].remove();for(d in this.overides)this._core[d]=this._overrides[d];for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},e.prototype.update=function(){var a,b,c,d=this._core.clones().length/2,e=d+this._core.items().length,f=this._core.maximum(!0),g=this._core.settings,h=g.center||g.autoWidth||g.dotsData?1:g.dotsEach||g.items;if("page"!==g.slideBy&&(g.slideBy=Math.min(g.slideBy,g.items)),g.dots||"page"==g.slideBy)for(this._pages=[],a=d,b=0,c=0;a=h||0===b){if(this._pages.push({start:Math.min(f,a-d),end:a-d+h-1}),Math.min(f,a-d)===f)break;b=0,++c}b+=this._core.mergers(this._core.relative(a))}},e.prototype.draw=function(){var b,c=this._core.settings,d=this._core.items().length<=c.items,e=this._core.relative(this._core.current()),f=c.loop||c.rewind;this._controls.$relative.toggleClass("disabled",!c.nav||d),c.nav&&(this._controls.$previous.toggleClass("disabled",!f&&e<=this._core.minimum(!0)),this._controls.$next.toggleClass("disabled",!f&&e>=this._core.maximum(!0))),this._controls.$absolute.toggleClass("disabled",!c.dots||d),c.dots&&(b=this._pages.length-this._controls.$absolute.children().length,c.dotsData&&0!==b?this._controls.$absolute.html(this._templates.join("")):b>0?this._controls.$absolute.append(new Array(b+1).join(this._templates[0])):b<0&&this._controls.$absolute.children().slice(b).remove(),this._controls.$absolute.find(".active").removeClass("active"),this._controls.$absolute.children().eq(a.inArray(this.current(),this._pages)).addClass("active"))},e.prototype.onTrigger=function(b){var c=this._core.settings;b.page={index:a.inArray(this.current(),this._pages),count:this._pages.length,size:c&&(c.center||c.autoWidth||c.dotsData?1:c.dotsEach||c.items)}},e.prototype.current=function(){var b=this._core.relative(this._core.current());return a.grep(this._pages,a.proxy(function(a,c){return a.start<=b&&a.end>=b},this)).pop()},e.prototype.getPosition=function(b){var c,d,e=this._core.settings;return"page"==e.slideBy?(c=a.inArray(this.current(),this._pages),d=this._pages.length,b?++c:--c,c=this._pages[(c%d+d)%d].start):(c=this._core.relative(this._core.current()),d=this._core.items().length,b?c+=e.slideBy:c-=e.slideBy),c},e.prototype.next=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!0),b)},e.prototype.prev=function(b){a.proxy(this._overrides.to,this._core)(this.getPosition(!1),b)},e.prototype.to=function(b,c,d){var e;!d&&this._pages.length?(e=this._pages.length,a.proxy(this._overrides.to,this._core)(this._pages[(b%e+e)%e].start,c)):a.proxy(this._overrides.to,this._core)(b,c)},a.fn.owlCarousel.Constructor.Plugins.Navigation=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){"use strict";var e=function(c){this._core=c,this._hashes={},this.$element=this._core.$element,this._handlers={"initialized.owl.carousel":a.proxy(function(c){c.namespace&&"URLHash"===this._core.settings.startPosition&&a(b).trigger("hashchange.owl.navigation")},this),"prepared.owl.carousel":a.proxy(function(b){if(b.namespace){var c=a(b.content).find("[data-hash]").addBack("[data-hash]").attr("data-hash");if(!c)return;this._hashes[c]=b.content}},this),"changed.owl.carousel":a.proxy(function(c){if(c.namespace&&"position"===c.property.name){var d=this._core.items(this._core.relative(this._core.current())),e=a.map(this._hashes,function(a,b){return a===d?b:null}).join();if(!e||b.location.hash.slice(1)===e)return;b.location.hash=e}},this)},this._core.options=a.extend({},e.Defaults,this._core.options),this.$element.on(this._handlers),a(b).on("hashchange.owl.navigation",a.proxy(function(a){var c=b.location.hash.substring(1),e=this._core.$stage.children(),f=this._hashes[c]&&e.index(this._hashes[c]);f!==d&&f!==this._core.current()&&this._core.to(this._core.relative(f),!1,!0)},this))};e.Defaults={URLhashListener:!1},e.prototype.destroy=function(){var c,d;a(b).off("hashchange.owl.navigation");for(c in this._handlers)this._core.$element.off(c,this._handlers[c]);for(d in Object.getOwnPropertyNames(this))"function"!=typeof this[d]&&(this[d]=null)},a.fn.owlCarousel.Constructor.Plugins.Hash=e}(window.Zepto||window.jQuery,window,document),function(a,b,c,d){function e(b,c){var e=!1,f=b.charAt(0).toUpperCase()+b.slice(1);return a.each((b+" "+h.join(f+" ")+f).split(" "),function(a,b){if(g[b]!==d)return e=!c||b,!1}),e}function f(a){return e(a,!0)}var g=a("").get(0).style,h="Webkit Moz O ms".split(" "),i={transition:{end:{WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"}},animation:{end:{WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd",animation:"animationend"}}},j={csstransforms:function(){return!!e("transform")},csstransforms3d:function(){return!!e("perspective")},csstransitions:function(){return!!e("transition")},cssanimations:function(){return!!e("animation")}};j.csstransitions()&&(a.support.transition=new String(f("transition")),a.support.transition.end=i.transition.end[a.support.transition]),j.cssanimations()&&(a.support.animation=new String(f("animation")),a.support.animation.end=i.animation.end[a.support.animation]),j.csstransforms()&&(a.support.transform=new String(f("transform")),a.support.transform3d=j.csstransforms3d())}(window.Zepto||window.jQuery,window,document); \ No newline at end of file diff --git a/resources/assets/plugins/carousel/owl.theme.default.min.css b/resources/assets/plugins/carousel/owl.theme.default.min.css new file mode 100644 index 0000000..487088d --- /dev/null +++ b/resources/assets/plugins/carousel/owl.theme.default.min.css @@ -0,0 +1,6 @@ +/** + * Owl Carousel v2.3.4 + * Copyright 2013-2018 David Deutsch + * Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE + */ +.owl-theme .owl-dots,.owl-theme .owl-nav{text-align:center;-webkit-tap-highlight-color:transparent}.owl-theme .owl-nav{margin-top:10px}.owl-theme .owl-nav [class*=owl-]{color:#FFF;font-size:14px;margin:5px;padding:4px 7px;background:#D6D6D6;display:inline-block;cursor:pointer;border-radius:3px}.owl-theme .owl-nav [class*=owl-]:hover{background:#869791;color:#FFF;text-decoration:none}.owl-theme .owl-nav .disabled{opacity:.5;cursor:default}.owl-theme .owl-nav.disabled+.owl-dots{margin-top:10px}.owl-theme .owl-dots .owl-dot{display:inline-block;zoom:1}.owl-theme .owl-dots .owl-dot span{width:10px;height:10px;margin:5px 7px;background:#D6D6D6;display:block;-webkit-backface-visibility:visible;transition:opacity .2s ease;border-radius:30px}.owl-theme .owl-dots .owl-dot.active span,.owl-theme .owl-dots .owl-dot:hover span{background:#869791} \ No newline at end of file diff --git a/resources/assets/plugins/jquery-raty/fonts/raty.eot b/resources/assets/plugins/jquery-raty/fonts/raty.eot new file mode 100644 index 0000000..2faa8e6 Binary files /dev/null and b/resources/assets/plugins/jquery-raty/fonts/raty.eot differ diff --git a/resources/assets/plugins/jquery-raty/fonts/raty.svg b/resources/assets/plugins/jquery-raty/fonts/raty.svg new file mode 100644 index 0000000..8bd28d0 --- /dev/null +++ b/resources/assets/plugins/jquery-raty/fonts/raty.svg @@ -0,0 +1,15 @@ + + + +Generated by IcoMoon + + + + + + + + + + + \ No newline at end of file diff --git a/resources/assets/plugins/jquery-raty/fonts/raty.ttf b/resources/assets/plugins/jquery-raty/fonts/raty.ttf new file mode 100644 index 0000000..fdb5061 Binary files /dev/null and b/resources/assets/plugins/jquery-raty/fonts/raty.ttf differ diff --git a/resources/assets/plugins/jquery-raty/fonts/raty.woff b/resources/assets/plugins/jquery-raty/fonts/raty.woff new file mode 100644 index 0000000..06d1106 Binary files /dev/null and b/resources/assets/plugins/jquery-raty/fonts/raty.woff differ diff --git a/resources/assets/plugins/jquery-raty/images/cancel-off.png b/resources/assets/plugins/jquery-raty/images/cancel-off.png new file mode 100644 index 0000000..cdb01ae Binary files /dev/null and b/resources/assets/plugins/jquery-raty/images/cancel-off.png differ diff --git a/resources/assets/plugins/jquery-raty/images/cancel-on.png b/resources/assets/plugins/jquery-raty/images/cancel-on.png new file mode 100644 index 0000000..10e7908 Binary files /dev/null and b/resources/assets/plugins/jquery-raty/images/cancel-on.png differ diff --git a/resources/assets/plugins/jquery-raty/images/star-half.png b/resources/assets/plugins/jquery-raty/images/star-half.png new file mode 100644 index 0000000..4abaed8 Binary files /dev/null and b/resources/assets/plugins/jquery-raty/images/star-half.png differ diff --git a/resources/assets/plugins/jquery-raty/images/star-off.png b/resources/assets/plugins/jquery-raty/images/star-off.png new file mode 100644 index 0000000..6d1cd3e Binary files /dev/null and b/resources/assets/plugins/jquery-raty/images/star-off.png differ diff --git a/resources/assets/plugins/jquery-raty/images/star-on.png b/resources/assets/plugins/jquery-raty/images/star-on.png new file mode 100644 index 0000000..56201ed Binary files /dev/null and b/resources/assets/plugins/jquery-raty/images/star-on.png differ diff --git a/resources/assets/plugins/jquery-raty/jquery.raty.css b/resources/assets/plugins/jquery-raty/jquery.raty.css new file mode 100644 index 0000000..2c81574 --- /dev/null +++ b/resources/assets/plugins/jquery-raty/jquery.raty.css @@ -0,0 +1,46 @@ +.cancel-on-png, .cancel-off-png, .star-on-png, .star-off-png, .star-half-png { + font-size: 2em; +} + +@font-face { + font-family: "raty"; + font-style: normal; + font-weight: normal; + src: url("./fonts/raty.eot"); + src: url("./fonts/raty.eot?#iefix") format("embedded-opentype"); + src: url("./fonts/raty.svg#raty") format("svg"); + src: url("./fonts/raty.ttf") format("truetype"); + src: url("./fonts/raty.woff") format("woff"); +} + +.cancel-on-png, .cancel-off-png, .star-on-png, .star-off-png, .star-half-png { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-family: "raty"; + font-style: normal; + font-variant: normal; + font-weight: normal; + line-height: 1; + speak: none; + text-transform: none; +} + +.cancel-on-png:before { + content: "\e600"; +} + +.cancel-off-png:before { + content: "\e601"; +} + +.star-on-png:before { + content: "\f005"; +} + +.star-off-png:before { + content: "\f006"; +} + +.star-half-png:before { + content: "\f123"; +} diff --git a/resources/assets/plugins/jquery-raty/jquery.raty.js b/resources/assets/plugins/jquery-raty/jquery.raty.js new file mode 100644 index 0000000..fa0cf06 --- /dev/null +++ b/resources/assets/plugins/jquery-raty/jquery.raty.js @@ -0,0 +1,777 @@ +/*! + * Raty - A Star Rating Plugin + * + * The MIT License + * + * author: Washington Botelho + * github: wbotelhos/raty + * version: 3.1.0 + * + */ + +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof module === 'object' && module.exports) { + module.exports = factory(require('jquery')); + } else { + factory(root.jQuery); + } +}(this, function($) { + 'use strict'; + + $.raty = { + cancelButton: false, + cancelClass: 'raty-cancel', + cancelHint: 'Cancel this rating!', + cancelOff: 'cancel-off.png', + cancelOn: 'cancel-on.png', + cancelPlace: 'left', + click: undefined, + half: false, + halfShow: true, + hints: ['bad', 'poor', 'regular', 'good', 'gorgeous'], + iconRange: undefined, + iconRangeSame: false, + mouseout: undefined, + mouseover: undefined, + noRatedMsg: 'Not rated yet!', + number: 5, + numberMax: 20, + path: undefined, + precision: false, + readOnly: false, + round: { down: 0.25, full: 0.6, up: 0.76 }, + score: undefined, + scoreName: 'score', + single: false, + space: true, + starHalf: 'star-half.png', + starOff: 'star-off.png', + starOn: 'star-on.png', + starType: 'img', + target: undefined, + targetFormat: '{score}', + targetKeep: false, + targetScore: undefined, + targetText: '', + targetType: 'hint' + }; + + $.fn.raty = function(options) { + return this.each(function() { + var instance = new $.raty.Raty(this, options); + + return instance._create(); + }); + }; + + $.raty.Raty = (function() { + var Raty = function(element, options) { + this.element = element; + this.self = $(element); + this.opt = $.extend(true, {}, $.raty, options, this.self.data()); + }; + + Raty.prototype = { + _create: function() { + this._executeCallbacks(); + this._adjustNumber(); + this._adjustHints(); + + this.opt.score = this._adjustedScore(this.opt.score); + + if (this.opt.starType !== 'img') { + this._adjustStarName(); + } + + this._setPath(); + this._createStars(); + + if (this.opt.cancelButton) { + this._createCancel(); + } + + if (this.opt.precision) { + this._adjustPrecision(); + } + + this._createScore(); + + this._apply(this.opt.score); + this._setTitle(this.opt.score); + this._target(this.opt.score); + + if (this.opt.readOnly) { + this._lock(); + } else { + this.element.style.cursor = 'pointer'; + + this._binds(); + } + + this.self.data('raty', this); + }, + + // TODO: model spec + _adjustedScore: function(score) { + if (score || score === 0) { + return this._between(score, 0, this.opt.number); + } + }, + + _adjustHints: function() { + if (!this.opt.hints) { + this.opt.hints = []; + } + + if (!this.opt.halfShow && !this.opt.half) { + return; + } + + var steps = this.opt.precision ? 10 : 2; + + for (var i = 0; i < this.opt.number; i++) { + var group = this.opt.hints[i]; + + if (Object.prototype.toString.call(group) !== '[object Array]') { + group = [group]; + } + + this.opt.hints[i] = []; + + for (var j = 0; j < steps; j++) { + var hint = group[j]; + var last = group[group.length - 1]; + + if (last === undefined) { + last = null; + } + + this.opt.hints[i][j] = hint === undefined ? last : hint; + } + } + }, + + _adjustNumber: function() { + this.opt.number = this._between(this.opt.number, 1, this.opt.numberMax); + }, + + _adjustPrecision: function() { + this.opt.half = true; + }, + + _adjustStarName: function() { + var replaces = ['cancelOff', 'cancelOn', 'starHalf', 'starOff', 'starOn']; + + this.opt.path = ''; + + for (var i = 0; i < replaces.length; i++) { + this.opt[replaces[i]] = this.opt[replaces[i]].replace('.', '-'); + } + }, + + // TODO: model spec + _apply: function(score) { + this._fill(score); + + if (score) { + if (score > 0) { + this.scoreField.val(score); + } + + this._roundStars(score); + } + }, + + _attributesForIndex: function(i) { + var name = this._nameForIndex(i); + var attributes = { alt: i, src: this.opt.path + this.opt[name] }; + + if (this.opt.starType !== 'img') { + attributes = { 'data-alt': i, 'class': this.opt[name] }; + } + + attributes.title = this._getHint(i); + + return attributes; + }, + + _between: function(value, min, max) { + return Math.min(Math.max(parseFloat(value), min), max); + }, + + // TODO: model spec + _binds: function() { + if (this.cancelButton) { + this._bindOverCancel(); + this._bindClickCancel(); + this._bindOutCancel(); + } + + this._bindOver(); + this._bindClick(); + this._bindOut(); + }, + + // TODO: model spec + _bindClick: function() { + var that = this; + + this.stars.on('click.raty', function(evt) { + if (that.self.data('readonly')) { + return; + } + + var execute = true; + var score = (that.opt.half || that.opt.precision) ? that.self.data('score') : (this.alt || $(this).data('alt')); + + if (that.opt.half && !that.opt.precision) { + score = that._roundHalfScore(score); + } + + if (that.opt.click) { + execute = that.opt.click.call(that.element, +score, evt); + } + + if (execute || execute === undefined) { + that._apply(+score); + } + }); + }, + + // TODO: model spec + _bindClickCancel: function() { + this.cancelButton.on('click.raty', function(evt) { + this.scoreField.removeAttr('value'); + + if (this.opt.click) { + this.opt.click.call(this.element, null, evt); + } + }.bind(this)); + }, + + // TODO: model spec + _bindOut: function() { + this.self.on('mouseleave.raty', function(evt) { + var score = +this.scoreField.val() || undefined; + + this._apply(score); + this._target(score, evt); + this._resetTitle(); + + if (this.opt.mouseout) { + this.opt.mouseout.call(this.element, score, evt); + } + }.bind(this)); + }, + + // TODO: model spec + _bindOutCancel: function() { + var that = this; + + this.cancelButton.on('mouseleave.raty', function(evt) { + var icon = that.opt.cancelOff; + + if (that.opt.starType !== 'img') { + icon = that.opt.cancelClass + ' ' + icon; + } + + that._setIcon(this, icon); + + if (that.opt.mouseout) { + var score = +that.scoreField.val() || undefined; + + that.opt.mouseout.call(that.element, score, evt); + } + }); + }, + + // TODO: model spec + _bindOver: function() { + var that = this; + var action = that.opt.half ? 'mousemove.raty' : 'mouseover.raty'; + + this.stars.on(action, function(evt) { + var score = that._getScoreByPosition(evt, this); + + that._fill(score); + + if (that.opt.half) { + that._roundStars(score, evt); + that._setTitle(score, evt); + + that.self.data('score', score); + } + + that._target(score, evt); + + if (that.opt.mouseover) { + that.opt.mouseover.call(that.element, score, evt); + } + }); + }, + + // TODO: model spec + _bindOverCancel: function() { + var that = this; + + this.cancelButton.on('mouseover.raty', function(evt) { + if (that.self.data('readonly')) { + return; + } + + var starOff = that.opt.path + that.opt.starOff; + var icon = that.opt.cancelOn; + + if (that.opt.starType === 'img') { + that.stars.attr('src', starOff); + } else { + icon = that.opt.cancelClass + ' ' + icon; + + that.stars.attr('class', starOff); + } + + that._setIcon(this, icon); + that._target(null, evt); + + if (that.opt.mouseover) { + that.opt.mouseover.call(that.element, null); + } + }); + }, + + // TODO: model spec + _buildScoreField: function() { + return $('', { name: this.opt.scoreName, type: 'hidden' }).appendTo(this.self); + }, + + // TODO: model spec + _createCancel: function() { + var icon = this.opt.path + this.opt.cancelOff; + var button = $('<' + this.opt.starType + ' />', { title: this.opt.cancelHint, 'class': this.opt.cancelClass }); + + if (this.opt.starType === 'img') { + button.attr({ src: icon, alt: 'x' }); + } else { + // TODO: use $.data + button.attr('data-alt', 'x').addClass(icon); + } + + if (this.opt.cancelPlace === 'left') { + this.self.prepend(' ').prepend(button); + } else { + this.self.append(' ').append(button); + } + + this.cancelButton = button; + }, + + // TODO: model spec + _createScore: function() { + var score = $(this.opt.targetScore); + + this.scoreField = score.length ? score : this._buildScoreField(); + }, + + _createStars: function() { + for (var i = 1; i <= this.opt.number; i++) { + var attributes = this._attributesForIndex(i); + + $('<' + this.opt.starType + ' />', attributes).appendTo(this.element); + + if (this.opt.space && i < this.opt.number) { + this.self.append(' '); + } + } + + this.stars = this.self.children(this.opt.starType); + }, + + // TODO: model spec + _error: function(message) { + $(this).text(message); + + $.error(message); + }, + + _executeCallbacks: function() { + var options = ['number', 'readOnly', 'score', 'scoreName', 'target', 'path']; + + for (var i = 0; i < options.length; i++) { + if (typeof this.opt[options[i]] === 'function') { + var value = this.opt[options[i]].call(this.element); + + if (value) { + this.opt[options[i]] = value; + } else { + delete this.opt[options[i]]; + } + } + } + }, + + // TODO: model spec + _fill: function(score) { + var hash = 0; + + if (this.opt.iconRangeSame && this.opt.iconRange) { + while (hash < this.opt.iconRange.length && this.opt.iconRange[hash].range < score) { + hash++; + } + } + + for (var i = 1; i <= this.stars.length; i++) { + var icon; + var star = this.stars[i - 1]; + var turnOn = this._turnOn(i, score); + + if (this.opt.iconRange && this.opt.iconRange.length > hash) { + var irange = this.opt.iconRange[hash]; + + icon = this._getRangeIcon(irange, turnOn); + + if (i <= irange.range) { + this._setIcon(star, icon); + } + + if (i === irange.range) { + hash++; + } + } else { + icon = this.opt[turnOn ? 'starOn' : 'starOff']; + + this._setIcon(star, icon); + } + } + }, + + _getDecimal: function(number, fractions) { + var decimal = number.toString().split('.')[1]; + var result = 0; + + if (decimal) { + result = parseInt(decimal.slice(0, fractions), 10); + + if (decimal.slice(1, 5) === '9999') { + result++; + } + } + + return result; + }, + + // TODO: model spec + _getRangeIcon: function(irange, turnOn) { + return turnOn ? irange.on || this.opt.starOn : irange.off || this.opt.starOff; + }, + + // TODO: model spec + _getScoreByPosition: function(evt, icon) { + var score = parseInt(icon.alt || icon.getAttribute('data-alt'), 10); + + if (this.opt.half) { + var size = this._getWidth(); + var percent = parseFloat((evt.pageX - $(icon).offset().left) / size); + + score = score - 1 + percent; + } + + return score; + }, + + // TODO: model spec + _getHint: function(score, evt) { + if (score !== 0 && !score) { + return this.opt.noRatedMsg; + } + + var decimal = this._getDecimal(score, 1); + var integer = Math.ceil(score); + var group = this.opt.hints[(integer || 1) - 1]; + var hint = group; + var set = !evt || this.isMove; + + if (this.opt.precision) { + if (set) { + decimal = decimal === 0 ? 9 : decimal - 1; + } + + hint = group[decimal]; + } else if (this.opt.halfShow || this.opt.half) { + decimal = set && decimal === 0 ? 1 : decimal > 5 ? 1 : 0; + + hint = group[decimal]; + } + + return hint === '' ? '' : hint || score; + }, + + // TODO: model spec + _getWidth: function() { + var width = this.stars[0].width || parseFloat(this.stars.eq(0).css('font-size')); + + if (!width) { + this._error('Could not get the icon width!'); + } + + return width; + }, + + // TODO: model spec + _lock: function() { + var hint = this._getHint(this.scoreField.val()); + + this.element.style.cursor = ''; + this.element.title = hint; + + this.scoreField.prop('readonly', true); + this.stars.prop('title', hint); + + if (this.cancelButton) { + this.cancelButton.hide(); + } + + this.self.data('readonly', true); + }, + + _nameForIndex: function(i) { + return this.opt.score && this.opt.score >= i ? 'starOn' : 'starOff'; + }, + + // TODO: model spec + _resetTitle: function() { + for (var i = 0; i < this.opt.number; i++) { + this.stars[i].title = this._getHint(i + 1); + } + }, + + // TODO: model spec + _roundHalfScore: function(score) { + var integer = parseInt(score, 10); + var decimal = this._getDecimal(score, 1); + + if (decimal !== 0) { + decimal = decimal > 5 ? 1 : 0.5; + } + + return integer + decimal; + }, + + // TODO: model spec + _roundStars: function(score, evt) { + var name = this._starName(score, evt); + + if (name) { + var icon = this.opt[name]; + var star = this.stars[Math.ceil(score) - 1]; + + this._setIcon(star, icon); + } // Full down: [x.00 .. x.25] + }, + + // TODO: model spec + _setIcon: function(star, icon) { + star[this.opt.starType === 'img' ? 'src' : 'className'] = this.opt.path + icon; + }, + + _setPath: function() { + this.opt.path = this.opt.path || ''; + + if (this.opt.path && this.opt.path.slice(-1)[0] !== '/') { + this.opt.path += '/'; + } + }, + + // TODO: model spec + _setTarget: function(target, score) { + if (score) { + score = this.opt.targetFormat.toString().replace('{score}', score); + } + + if (target.is(':input')) { + target.val(score); + } else { + target.html(score); + } + }, + + // TODO: model spec + _setTitle: function(score, evt) { + if (score) { + var integer = parseInt(Math.ceil(score), 10); + var star = this.stars[integer - 1]; + + star.title = this._getHint(score, evt); + } + }, + + _starName: function(score, evt) { + var decimal = +(score % 1).toFixed(2); + + if (evt || this.isMove) { + return decimal > 0.5 ? 'starOn' : 'starHalf'; + } + + if (decimal <= this.opt.round.down) { // Down: [x.00 ... x.25] + return; + } + + if (this.opt.halfShow && decimal < this.opt.round.up) { // Half: [x.26 ... x.75] + return 'starHalf'; + } + + if (decimal < this.opt.round.full) { // Off: [x.26 .. x.6] + return 'starOff'; + } + + return 'starOn'; // Up: [x.26 ...] || [x.6 ...] + }, + + // TODO: model spec + _target: function(score, evt) { + if (this.opt.target) { + var target = $(this.opt.target); + + if (!target.length) { + this._error('Target selector invalid or missing!'); + } + + var mouseover = evt && evt.type === 'mouseover'; + + if (score === undefined) { + score = this.opt.targetText; + } else if (score === null) { + score = mouseover ? this.opt.cancelHint : this.opt.targetText; + } else { + if (this.opt.targetType === 'hint') { + score = this._getHint(score, evt); + } else if (this.opt.precision) { + score = parseFloat(score).toFixed(1); + } + + var mousemove = evt && evt.type === 'mousemove'; + + if (!mouseover && !mousemove && !this.opt.targetKeep) { + score = this.opt.targetText; + } + } + + this._setTarget(target, score); + } + }, + + // TODO: model spec + _turnOn: function(i, score) { + return this.opt.single ? (i === score) : (i <= score); + }, + + // TODO: model spec + _unlock: function() { + this.element.style.cursor = 'pointer'; + this.element.removeAttribute('title'); + + this.scoreField.removeAttr('readonly'); + + this.self.data('readonly', false); + + this._resetTitle(); + + if (this.cancelButton) { + this.cancelButton.css('display', ''); + } + }, + + // TODO: model spec + cancel: function(click) { + if (this.self.data('readonly') !== true) { + this[click ? 'click' : 'score'].call(this, null); + + this.scoreField.removeAttr('value'); + } + }, + + // TODO: model spec + click: function(score) { + if (this.self.data('readonly') !== true) { + score = this._adjustedScore(score); + + this._apply(score); + + if (this.opt.click) { + this.opt.click.call(this.element, score, $.Event('click')); + } + + this._target(score); + } + }, + + // TODO: model spec + getScore: function() { + var score = []; + var value ; + + value = this.scoreField.val(); + + score.push(value ? +value : undefined); + + return (score.length > 1) ? score : score[0]; + }, + + // TODO: model spec + move: function(score) { + var integer = parseInt(score, 10); + var decimal = this._getDecimal(score, 1); + + if (integer >= this.opt.number) { + integer = this.opt.number - 1; + decimal = 10; + } + + var width = this._getWidth(); + var steps = width / 10; + var star = $(this.stars[integer]); + var percent = star.offset().left + steps * decimal; + var evt = $.Event('mousemove', { pageX: percent }); + + this.isMove = true; + + star.trigger(evt); + + this.isMove = false; + }, + + // TODO: model spec + readOnly: function(readonly) { + if (this.self.data('readonly') !== readonly) { + if (readonly) { + this.self.off('.raty').children(this.opt.starType).off('.raty'); + + this._lock(); + } else { + this._binds(); + this._unlock(); + } + + this.self.data('readonly', readonly); + } + }, + + // TODO: model spec + score: function() { + return arguments.length ? this.setScore.apply(this, arguments) : this.getScore(); + }, + + setScore: function(score) { + if (this.self.data('readonly') !== true) { + score = this._adjustedScore(score); + + this._apply(score); + this._target(score); + } + } + }; + + return Raty; + })(); +})); diff --git a/resources/views/themeanimeh/catalog.blade.php b/resources/views/themeanimeh/catalog.blade.php new file mode 100644 index 0000000..77c4278 --- /dev/null +++ b/resources/views/themeanimeh/catalog.blade.php @@ -0,0 +1,27 @@ +@extends('themes::themeanimeh.layout') + +@php + $years = Cache::remember('all_years', \Backpack\Settings\app\Models\Setting::get('site_cache_ttl', 5 * 60), function () { + return \VsMov\Core\Models\Movie::select('publish_year') + ->distinct() + ->pluck('publish_year') + ->sortDesc(); + }); +@endphp + +@section('content') + + + {{ $section_name }} + + @include('themes::themeanimeh.inc.catalog_filter') + + @if(!count($data)) + Không có dữ liệu cho mục này! + @endif + @foreach ($data as $movie) + @include('themes::themeanimeh.inc.section_home_item') + @endforeach + + {{ $data->appends(request()->all())->links('themes::themeanimeh.inc.pagination') }} +@endsection diff --git a/resources/views/themeanimeh/episode.blade.php b/resources/views/themeanimeh/episode.blade.php new file mode 100644 index 0000000..e485c7e --- /dev/null +++ b/resources/views/themeanimeh/episode.blade.php @@ -0,0 +1,398 @@ +@extends('themes::themeanimeh.layout') + +@push('header') + + +@endpush + +@section('content') + + + {{$currentMovie->getRatingStar()}} sao / {{$currentMovie->getRatingCount()}} lượt đánh giá + + close + + + + + + + + + + + + movie {{$currentMovie->name}} + + Đang xem Tập {{$episode->name}} + + + + + + + Tập {{$episode->name}} + + + + + info + + + stars + + + report_problem + + + + + + + + + @foreach ($currentMovie->episodes->where('slug', $episode->slug)->where('server', $episode->server) as $server) + + Nguồn Phát #{{ $loop->index + 1 }} + + @endforeach + + + @if ($currentMovie->showtimes && $currentMovie->showtimes != '') + + + note Lịch chiếu + + + {!! $currentMovie->showtimes !!} + + + @endif + @if ($currentMovie->notify && $currentMovie->notify != '') + + + note Ghi chú + + + {!! $currentMovie->notify !!} + + + @endif + @foreach ($currentMovie->episodes->sortBy([['server', 'asc']])->groupBy('server') as $server => $data) + + + Danh sách tập {{ $server }} + + + + @foreach ($data->sortByDesc('name', SORT_NATURAL)->groupBy('name') as $name => $item) + {{ $name }} + @endforeach + + + @endforeach + @include('themes::themeanimeh.inc.comment') + + @include('themes::themeanimeh.inc.movie_related') +@endsection + +@push('scripts') + + + + + + + + + + + + + + + + + + + {!! setting('site_scripts_facebook_sdk') !!} + +@endpush diff --git a/resources/views/themeanimeh/inc/catalog_filter.blade.php b/resources/views/themeanimeh/inc/catalog_filter.blade.php new file mode 100644 index 0000000..966564f --- /dev/null +++ b/resources/views/themeanimeh/inc/catalog_filter.blade.php @@ -0,0 +1,55 @@ + + + + + + Sắp xếp + Thời gian cập nhật + Thời gian đăng + Năm sản xuất + Lượt xem + + + + + Mọi định dạng + Phim bộ + Phim lẻ + + + + + Tất cả thể loại + @foreach (\VsMov\Core\Models\Category::fromCache()->all() as $item) + id) || + (isset($category) && $category->id == $item->id)) selected @endif> + {{ $item->name }} + @endforeach + + + + + Tất cả quốc gia + @foreach (\VsMov\Core\Models\Region::fromCache()->all() as $item) + id) || + (isset($region) && $region->id == $item->id)) selected @endif> + {{ $item->name }} + @endforeach + + + + + Tất cả năm + @foreach ($years as $year) + + {{ $year }} + @endforeach + + + + filter_alt Lọc Phim + + + + + diff --git a/resources/views/themeanimeh/inc/comment.blade.php b/resources/views/themeanimeh/inc/comment.blade.php new file mode 100644 index 0000000..541adf3 --- /dev/null +++ b/resources/views/themeanimeh/inc/comment.blade.php @@ -0,0 +1,13 @@ + + + + comment Bình luận + + + + + + + + diff --git a/resources/views/themeanimeh/inc/movie_related.blade.php b/resources/views/themeanimeh/inc/movie_related.blade.php new file mode 100644 index 0000000..a677ccc --- /dev/null +++ b/resources/views/themeanimeh/inc/movie_related.blade.php @@ -0,0 +1,10 @@ + + + Có thể bạn muốn xem! + + + @foreach ($movie_related as $movie) + @include('themes::themeanimeh.inc.section_home_item') + @endforeach + + diff --git a/resources/views/themeanimeh/inc/navbar.blade.php b/resources/views/themeanimeh/inc/navbar.blade.php new file mode 100644 index 0000000..d5766dd --- /dev/null +++ b/resources/views/themeanimeh/inc/navbar.blade.php @@ -0,0 +1,64 @@ +@php + $logo = setting('site_logo', ''); + $brand = setting('site_brand', ''); + $title = isset($title) ? $title : setting('site_homepage_title', ''); +@endphp + + + + + + @if ($logo) + {!! $logo !!} + @else + {!! $brand !!} + @endif + + + + + + + search + + + + + + search + + + reorder + + + + + + @foreach ($menu as $item) + @if (count($item['children'])) + menu {{ $item['name'] }} + @else + + auto_awesome {{ $item['name'] }} + @endif + @endforeach + + + @foreach ($menu as $item) + @if (count($item['children'])) + + + @foreach ($item['children'] as $children) + {{$children['name']}} + @endforeach + + + @endif + @endforeach + + + + diff --git a/resources/views/themeanimeh/inc/pagination.blade.php b/resources/views/themeanimeh/inc/pagination.blade.php new file mode 100644 index 0000000..452a122 --- /dev/null +++ b/resources/views/themeanimeh/inc/pagination.blade.php @@ -0,0 +1,41 @@ +@php + $pageRange = 3; +@endphp +@if ($paginator->hasPages()) + + + {{-- Previous Page Link --}} + @if ($paginator->onFirstPage()) + @else + << + @endif + + {{-- Pagination Elements --}} + @foreach ($elements as $element) + {{-- "Three Dots" Separator --}} + @if (is_string($element)) + {{ $element }} + @endif + + {{-- Array Of Links --}} + @if (is_array($element)) + @foreach ($element as $page => $url) + @if ($page == $paginator->currentPage()) + {{$page}} + @else + @if (($page > $paginator->currentPage() && $page < ($paginator->currentPage() + $pageRange)) || $page < $paginator->currentPage() && $page > ($paginator->currentPage() - $pageRange)) + {{$page}} + @endif + @endif + @endforeach + @endif + @endforeach + + {{-- Next Page Link --}} + @if ($paginator->hasMorePages()) + >> + @else + @endif + + +@endif diff --git a/resources/views/themeanimeh/inc/section_home.blade.php b/resources/views/themeanimeh/inc/section_home.blade.php new file mode 100644 index 0000000..c484261 --- /dev/null +++ b/resources/views/themeanimeh/inc/section_home.blade.php @@ -0,0 +1,13 @@ + + {{$item['label']}} + @if ($item['link'] != "" && $item['link'] != "#") + + Toàn bộ + + @endif + + + @foreach ($item['data'] as $movie) + @include('themes::themeanimeh.inc.section_home_item') + @endforeach + diff --git a/resources/views/themeanimeh/inc/section_home_item.blade.php b/resources/views/themeanimeh/inc/section_home_item.blade.php new file mode 100644 index 0000000..be4c885 --- /dev/null +++ b/resources/views/themeanimeh/inc/section_home_item.blade.php @@ -0,0 +1,13 @@ + + + + {{ $movie->episode_current }} + + + + + {{ $movie->getRatingStar() }} + {{ $movie->name }} + + diff --git a/resources/views/themeanimeh/inc/slider_recommended.blade.php b/resources/views/themeanimeh/inc/slider_recommended.blade.php new file mode 100644 index 0000000..05cd063 --- /dev/null +++ b/resources/views/themeanimeh/inc/slider_recommended.blade.php @@ -0,0 +1,21 @@ + + + + Phim đề cử + + + @foreach ($recommendations as $movie) + + + + + + {{$movie->name}} + {{$movie->episode_current}} + + + @endforeach + + diff --git a/resources/views/themeanimeh/index.blade.php b/resources/views/themeanimeh/index.blade.php new file mode 100644 index 0000000..cb070a6 --- /dev/null +++ b/resources/views/themeanimeh/index.blade.php @@ -0,0 +1,85 @@ +@extends('themes::themeanimeh.layout') + + +@php + use VsMov\Core\Models\Movie; + $recommendations = Cache::remember('site.movies.recommendations', setting('site_cache_ttl', 5 * 60), function () { + return Movie::where('is_recommended', true) + ->limit(get_theme_option('recommendations_limit', 10)) + ->orderBy('updated_at', 'desc') + ->get(); + }); + + $data = Cache::remember('site.movies.latest', setting('site_cache_ttl', 5 * 60), function () { + $lists = preg_split('/[\n\r]+/', get_theme_option('latest')); + $data = []; + foreach ($lists as $list) { + if (trim($list)) { + $list = explode('|', $list); + [$label, $relation, $field, $val, $sortKey, $alg, $limit, $link] = array_merge($list, ['Phim mới cập nhật', '', 'type', 'series', 'created_at', 'desc', 8, '/']); + try { + $data[] = [ + 'label' => $label, + 'data' => Movie::when($relation, function ($query) use ($relation, $field, $val) { + $query->whereHas($relation, function ($rel) use ($field, $val) { + $rel->where($field, $val); + }); + }) + ->when(!$relation, function ($query) use ($field, $val) { + $query->where($field, $val); + }) + ->orderBy($sortKey, $alg) + ->limit($limit) + ->get(), + 'link' => $link ?: '#', + ]; + } catch (\Exception $e) { + } + } + } + return $data; + }); + +@endphp + +@section('content') + @if (count($recommendations)) + @include('themes::themeanimeh.inc.slider_recommended') + @endif + @foreach ($data as $item) + @include('themes::themeanimeh.inc.section_home') + @endforeach +@endsection + +@push('scripts') + + + + +@endpush diff --git a/resources/views/themeanimeh/layout.blade.php b/resources/views/themeanimeh/layout.blade.php new file mode 100644 index 0000000..3223a8b --- /dev/null +++ b/resources/views/themeanimeh/layout.blade.php @@ -0,0 +1,38 @@ +@extends('themes::layout') + +@php + $menu = \VsMov\Core\Models\Menu::getTree(); +@endphp + +@push('header') + + + +@endpush + +@section('body') + + @include('themes::themeanimeh.inc.navbar') + @if (get_theme_option('ads_header')) + + {!! get_theme_option('ads_header') !!} + + @endif + + @yield('content') + + {!! get_theme_option('footer') !!} + +@endsection + +@push('scripts') +@endpush + +@section('footer') + @if (get_theme_option('ads_catfish')) + + {!! get_theme_option('ads_catfish') !!} + + @endif + {!! setting('site_scripts_google_analytics') !!} +@endsection diff --git a/resources/views/themeanimeh/single.blade.php b/resources/views/themeanimeh/single.blade.php new file mode 100644 index 0000000..5611c2b --- /dev/null +++ b/resources/views/themeanimeh/single.blade.php @@ -0,0 +1,283 @@ +@extends('themes::themeanimeh.layout') + +@php + $watch_url = ''; + if (!$currentMovie->is_copyright && count($currentMovie->episodes) && $currentMovie->episodes[0]['link'] != '') { + $watch_url = $currentMovie->episodes + ->sortBy([['server', 'asc']]) + ->groupBy('server') + ->first() + ->sortByDesc('name', SORT_NATURAL) + ->groupBy('name') + ->last() + ->sortByDesc('type') + ->first() + ->getUrl(); + } +@endphp + +@push('header') + +@endpush + +@section('content') + + + + + {{ $currentMovie->getRatingStar() }} sao / {{ $currentMovie->getRatingCount() }} lượt đánh giá + + close + + + + + + + + + @if (strpos($currentMovie->trailer_url, 'youtube')) + + + Trailer {{ $currentMovie->name }} + + close + + + + @php + try { + parse_str(parse_url($currentMovie->trailer_url, PHP_URL_QUERY), $parse_url); + $trailer_id = $parse_url['v']; + } catch (\Throwable $th) { + $trailer_id = ''; + } + @endphp + + + + @endif + + {{ $currentMovie->name }} + + + + + + + Tên khác + {{ $currentMovie->origin_name }} + + + Thể loại + + {!! $currentMovie->categories->map(function ($category) { + return '' . $category->name . ''; + })->implode('') !!} + + + + Quốc gia + + {!! $currentMovie->regions->map(function ($region) { + return '' . $region->name . ''; + })->implode('') !!} + + + + Trạng thái + {{ $currentMovie->episode_current }} {{ $currentMovie->language }} {{ $currentMovie->quality }} + + + + Thời lượng + {{ $currentMovie->episode_time }} + + + Phát hành + {{ $currentMovie->publish_year }} + + + + + + @if ($watch_url != '') + + play_circle_outline XEM PHIM + + + @endif + @if (strpos($currentMovie->trailer_url, 'youtube')) + + play_circle_filled TRAILER + + @endif + + + + stars CHẤM + ĐIỂM + + + + + + + Danh sách tập + + + + @if ($watch_url != '') + @foreach ($currentMovie->episodes->sortBy([['server', 'asc']])->groupBy('server') as $server => $data) + @foreach ($data->sortByDesc('name', SORT_NATURAL)->groupBy('name') as $name => $item) + {{ $name }} + @endforeach + @endforeach + @else + Phim đang được cập nhật... + @endif + + + + + Nội dung + + + + @if ($currentMovie->showtimes && $currentMovie->showtimes != '') + + + + {!! $currentMovie->showtimes !!} + + + @endif + + @if ($currentMovie->notify && $currentMovie->notify != '') + + + + {!! $currentMovie->notify !!} + + + @endif + + Đạo diễn: + @if (count($currentMovie->directors)) + {!! $currentMovie->directors->map(function ($director) { + return '' . $director->name . ''; + })->implode(',') !!} + @else + N/A + @endif + + + Diễn viên: + @if (count($currentMovie->actors)) + {!! $currentMovie->actors->map(function ($actor) { + return '' . $actor->name . ''; + })->implode(', ') !!} + @else + N/A + @endif + + + + {!! strip_tags($currentMovie->content) !!} + + + + + + + Tags + + + {!! $currentMovie->tags->map(function ($tag) { + return '' . $tag->name . ''; + })->implode(', ') !!} + + + @include('themes::themeanimeh.inc.comment') + @include('themes::themeanimeh.inc.movie_related') + +@endsection + +@push('scripts') + + + + + + + + {!! setting('site_scripts_facebook_sdk') !!} +@endpush diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..72079d1 --- /dev/null +++ b/routes/web.php @@ -0,0 +1,54 @@ + array_merge( + (array) config('backpack.base.web_middleware', 'web'), + ), +], function () { + Route::get('/', [ThemeAnimeHController::class, 'index']); + + Route::get(setting('site_routes_category', '/the-loai/{category}'), [ThemeAnimeHController::class, 'getMovieOfCategory']) + ->where(['category' => '.+', 'id' => '[0-9]+']) + ->name('categories.movies.index'); + + Route::get(setting('site_routes_region', '/quoc-gia/{region}'), [ThemeAnimeHController::class, 'getMovieOfRegion']) + ->where(['region' => '.+', 'id' => '[0-9]+']) + ->name('regions.movies.index'); + + Route::get(setting('site_routes_tag', '/tu-khoa/{tag}'), [ThemeAnimeHController::class, 'getMovieOfTag']) + ->where(['tag' => '.+', 'id' => '[0-9]+']) + ->name('tags.movies.index'); + + Route::get(setting('site_routes_types', '/danh-sach/{type}'), [ThemeAnimeHController::class, 'getMovieOfType']) + ->where(['type' => '.+', 'id' => '[0-9]+']) + ->name('types.movies.index'); + + Route::get(setting('site_routes_actors', '/dien-vien/{actor}'), [ThemeAnimeHController::class, 'getMovieOfActor']) + ->where(['actor' => '.+', 'id' => '[0-9]+']) + ->name('actors.movies.index'); + + Route::get(setting('site_routes_directors', '/dao-dien/{director}'), [ThemeAnimeHController::class, 'getMovieOfDirector']) + ->where(['director' => '.+', 'id' => '[0-9]+']) + ->name('directors.movies.index'); + + Route::get(setting('site_routes_episode', '/phim/{movie}/{episode}-{id}'), [ThemeAnimeHController::class, 'getEpisode']) + ->where(['movie' => '.+', 'movie_id' => '[0-9]+', 'episode' => '.+', 'id' => '[0-9]+']) + ->name('episodes.show'); + + Route::post(sprintf('/%s/{movie}/{episode}/report', config('vsmov.routes.movie', 'phim')), [ThemeAnimeHController::class, 'reportEpisode'])->name('episodes.report'); + Route::post(sprintf('/%s/{movie}/rate', config('vsmov.routes.movie', 'phim')), [ThemeAnimeHController::class, 'rateMovie'])->name('movie.rating'); + + Route::get(setting('site_routes_movie', '/phim/{movie}'), [ThemeAnimeHController::class, 'getMovieOverview']) + ->where(['movie' => '.+', 'id' => '[0-9]+']) + ->name('movies.show'); + +}); diff --git a/src/Controllers/ThemeAnimeHController.php b/src/Controllers/ThemeAnimeHController.php new file mode 100644 index 0000000..a79f3b4 --- /dev/null +++ b/src/Controllers/ThemeAnimeHController.php @@ -0,0 +1,290 @@ +whereHas('categories', function ($categories) { + $categories->where('id', request('filter')['category']); + }); + })->when(!empty($request['filter']['region']), function ($movie) { + $movie->whereHas('regions', function ($regions) { + $regions->where('id', request('filter')['region']); + }); + })->when(!empty($request['filter']['year']), function ($movie) { + $movie->where('publish_year', request('filter')['year']); + })->when(!empty($request['filter']['type']), function ($movie) { + $movie->where('type', request('filter')['type']); + })->when(!empty($request['search']), function ($query) { + $query->where(function ($query) { + $query->where('name', 'like', '%' . request('search') . '%') + ->orWhere('origin_name', 'like', '%' . request('search') . '%'); + })->orderBy('name', 'desc'); + })->when(!empty($request['filter']['sort']), function ($movie) { + if (request('filter')['sort'] == 'create') { + return $movie->orderBy('created_at', 'desc'); + } + if (request('filter')['sort'] == 'update') { + return $movie->orderBy('updated_at', 'desc'); + } + if (request('filter')['sort'] == 'year') { + return $movie->orderBy('publish_year', 'desc'); + } + if (request('filter')['sort'] == 'view') { + return $movie->orderBy('view_total', 'desc'); + } + })->paginate(get_theme_option('per_page_limit')); + + return view('themes::themeanimeh.catalog', [ + 'data' => $data, + 'search' => $request['search'], + 'section_name' => "Tìm kiếm phim: $request->search" + ]); + } + return view('themes::themeanimeh.index', [ + 'title' => Setting::get('site_homepage_title') + ]); + } + + public function getMovieOverview(Request $request) + { + /** @var Movie */ + $movie = Movie::fromCache()->find($request->movie ?: $request->id); + + if (is_null($movie)) abort(404); + + $movie->generateSeoTags(); + + $movie->increment('view_total', 1); + $movie->increment('view_day', 1); + $movie->increment('view_week', 1); + $movie->increment('view_month', 1); + + $movie_related_cache_key = 'movie_related:' . $movie->id; + $movie_related = Cache::get($movie_related_cache_key); + if(is_null($movie_related)) { + $movie_related = $movie->categories[0]->movies()->inRandomOrder()->limit(get_theme_option('movie_related_limit', 10))->get(); + Cache::put($movie_related_cache_key, $movie_related, setting('site_cache_ttl', 5 * 60)); + } + + return view('themes::themeanimeh.single', [ + 'currentMovie' => $movie, + 'title' => $movie->getTitle(), + 'movie_related' => $movie_related + ]); + } + + public function getEpisode(Request $request) + { + $movie = Movie::fromCache()->find($request->movie ?: $request->movie_id)->load('episodes'); + + if (is_null($movie)) abort(404); + + /** @var Episode */ + $episode_id = $request->id; + $episode = $movie->episodes->when($episode_id, function ($collection, $episode_id) { + return $collection->where('id', $episode_id); + })->firstWhere('slug', $request->episode); + + if (is_null($episode)) abort(404); + + $episode->generateSeoTags(); + + $movie->increment('view_total', 1); + $movie->increment('view_day', 1); + $movie->increment('view_week', 1); + $movie->increment('view_month', 1); + + $movie_related_cache_key = 'movie_related:' . $movie->id; + $movie_related = Cache::get($movie_related_cache_key); + if(is_null($movie_related)) { + $movie_related = $movie->categories[0]->movies()->inRandomOrder()->limit(get_theme_option('movie_related_limit', 10))->get(); + Cache::put($movie_related_cache_key, $movie_related, setting('site_cache_ttl', 5 * 60)); + } + + return view('themes::themeanimeh.episode', [ + 'currentMovie' => $movie, + 'movie_related' => $movie_related, + 'episode' => $episode, + 'title' => $episode->getTitle() + ]); + } + + public function getMovieOfCategory(Request $request) + { + /** @var Category */ + $category = Category::fromCache()->find($request->category ?: $request->id); + + if (is_null($category)) abort(404); + + $category->generateSeoTags(); + + $movies = $category->movies()->orderBy('created_at', 'desc')->paginate(get_theme_option('per_page_limit')); + + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'category' => $category, + 'title' => $category->seo_title ?: $category->getTitle(), + 'section_name' => "Phim thể loại $category->name" + ]); + } + + public function getMovieOfRegion(Request $request) + { + /** @var Region */ + $region = Region::fromCache()->find($request->region ?: $request->id); + + if (is_null($region)) abort(404); + + $region->generateSeoTags(); + + $movies = $region->movies()->orderBy('created_at', 'desc')->paginate(get_theme_option('per_page_limit')); + + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'region' => $region, + 'title' => $region->seo_title ?: $region->getTitle(), + 'section_name' => "Phim quốc gia $region->name" + ]); + } + + public function getMovieOfActor(Request $request) + { + /** @var Actor */ + $actor = Actor::fromCache()->find($request->actor ?: $request->id); + + if (is_null($actor)) abort(404); + + $actor->generateSeoTags(); + + $movies = $actor->movies()->orderBy('created_at', 'desc')->paginate(get_theme_option('per_page_limit')); + + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'person' => $actor, + 'title' => $actor->getTitle(), + 'section_name' => "Diễn viên $actor->name" + ]); + } + + public function getMovieOfDirector(Request $request) + { + /** @var Director */ + $director = Director::fromCache()->find($request->director ?: $request->id); + + if (is_null($director)) abort(404); + + $director->generateSeoTags(); + + $movies = $director->movies()->orderBy('created_at', 'desc')->paginate(get_theme_option('per_page_limit')); + + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'person' => $director, + 'title' => $director->getTitle(), + 'section_name' => "Đạo diễn $director->name" + ]); + } + + public function getMovieOfTag(Request $request) + { + /** @var Tag */ + $tag = Tag::fromCache()->find($request->tag ?: $request->id); + + if (is_null($tag)) abort(404); + + $tag->generateSeoTags(); + + $movies = $tag->movies()->orderBy('created_at', 'desc')->paginate(get_theme_option('per_page_limit')); + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'tag' => $tag, + 'title' => $tag->getTitle(), + 'section_name' => "Tags: $tag->name" + ]); + } + + public function getMovieOfType(Request $request) + { + /** @var Catalog */ + $catalog = Catalog::fromCache()->find($request->type ?: $request->id); + + if (is_null($catalog)) abort(404); + + $catalog->generateSeoTags(); + + $cache_key = 'catalog:' . $catalog->id . ':page:' . ($request['page'] ?: 1); + $movies = Cache::get($cache_key); + if(is_null($movies)) { + $value = explode('|', trim($catalog->value)); + [$relation_config, $field, $val, $sortKey, $alg] = array_merge($value, ['', 'is_copyright', 0, 'created_at', 'desc']); + $relation_config = explode(',', $relation_config); + + [$relation_table, $relation_field, $relation_val] = array_merge($relation_config, ['', '', '']); + try { + $movies = \VsMov\Core\Models\Movie::when($relation_table, function ($query) use ($relation_table, $relation_field, $relation_val, $field, $val) { + $query->whereHas($relation_table, function ($rel) use ($relation_field, $relation_val, $field, $val) { + $rel->where($relation_field, $relation_val)->where(array_combine(explode(",", $field), explode(",", $val))); + }); + })->when(!$relation_table, function ($query) use ($field, $val) { + $query->where(array_combine(explode(",", $field), explode(",", $val))); + }) + ->orderBy($sortKey, $alg) + ->paginate($catalog->paginate); + + Cache::put($cache_key, $movies, setting('site_cache_ttl', 5 * 60)); + } catch (\Exception $e) {} + } + + return view('themes::themeanimeh.catalog', [ + 'data' => $movies, + 'section_name' => "Danh sách $catalog->name" + ]); + } + + public function reportEpisode(Request $request, $movie, $slug) + { + $movie = Movie::fromCache()->find($movie)->load('episodes'); + + $episode = $movie->episodes->when(request('id'), function ($collection) { + return $collection->where('id', request('id')); + })->firstWhere('slug', $slug); + + $episode->update([ + 'report_message' => request('message', ''), + 'has_report' => true + ]); + + return response([], 204); + } + + public function rateMovie(Request $request, $movie) + { + + $movie = Movie::fromCache()->find($movie); + + $movie->refresh()->increment('rating_count', 1, [ + 'rating_star' => $movie->rating_star + ((int) request('rating') - $movie->rating_star) / ($movie->rating_count + 1) + ]); + + return response([], 204); + } +} diff --git a/src/ThemeAnimeHServiceProvider.php b/src/ThemeAnimeHServiceProvider.php new file mode 100644 index 0000000..23d5226 --- /dev/null +++ b/src/ThemeAnimeHServiceProvider.php @@ -0,0 +1,157 @@ +setupDefaultThemeCustomizer(); + } + + public function boot() + { + $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'themes'); + + $this->publishes([ + __DIR__ . '/../resources/assets' => public_path('themes/animeh') + ], 'animeh-assets'); + } + + protected function setupDefaultThemeCustomizer() + { + config(['themes' => array_merge(config('themes', []), [ + 'animeh' => [ + 'name' => 'Theme AnimeH', + 'author' => 'vsmov@gmail.com', + 'package_name' => 'vsmov/theme-animeh', + 'publishes' => ['animeh-assets'], + 'preview_image' => '', + 'options' => [ + [ + 'name' => 'recommendations_limit', + 'label' => 'Recommended movies limit', + 'type' => 'number', + 'value' => 10, + 'wrapperAttributes' => [ + 'class' => 'form-group col-md-4', + ], + 'tab' => 'List' + ], + [ + 'name' => 'per_page_limit', + 'label' => 'Pages limit', + 'type' => 'number', + 'value' => 30, + 'wrapperAttributes' => [ + 'class' => 'form-group col-md-4', + ], + 'tab' => 'List' + ], + [ + 'name' => 'movie_related_limit', + 'label' => 'Movies related limit', + 'type' => 'number', + 'value' => 10, + 'wrapperAttributes' => [ + 'class' => 'form-group col-md-4', + ], + 'tab' => 'List' + ], + [ + 'name' => 'latest', + 'label' => 'Home Page', + 'type' => 'code', + 'hint' => 'display_label|relation|find_by_field|value|sort_by_field|sort_algo|limit|show_more_url', + 'value' => << [ + 'rows' => 5 + ], + 'tab' => 'List' + ], + [ + 'name' => 'additional_css', + 'label' => 'Additional CSS', + 'type' => 'code', + 'value' => "", + 'tab' => 'Custom CSS' + ], + [ + 'name' => 'body_attributes', + 'label' => 'Body attributes', + 'type' => 'text', + 'value' => 'class="scroll-bar"', + 'tab' => 'Custom CSS' + ], + [ + 'name' => 'additional_header_js', + 'label' => 'Header JS', + 'type' => 'code', + 'value' => "", + 'tab' => 'Custom JS' + ], + [ + 'name' => 'additional_body_js', + 'label' => 'Body JS', + 'type' => 'code', + 'value' => "", + 'tab' => 'Custom JS' + ], + [ + 'name' => 'additional_footer_js', + 'label' => 'Footer JS', + 'type' => 'code', + 'value' => "", + 'tab' => 'Custom JS' + ], + [ + 'name' => 'footer', + 'label' => 'Footer', + 'type' => 'code', + 'value' => << + + + + + + + + + + EOT, + 'tab' => 'Custom HTML' + ], + [ + 'name' => 'ads_header', + 'label' => 'Ads header', + 'type' => 'code', + 'value' => << 'Ads' + ], + [ + 'name' => 'ads_catfish', + 'label' => 'Ads catfish', + 'type' => 'code', + 'value' => << 'Ads' + ] + ], + ] + ])]); + } +} diff --git a/src/screenshot.png b/src/screenshot.png new file mode 100644 index 0000000..899414e Binary files /dev/null and b/src/screenshot.png differ
Không có dữ liệu cho mục này!
+ + + {!! $currentMovie->showtimes !!} + +
+ {!! $currentMovie->showtimes !!} +
+
+ + + {!! $currentMovie->notify !!} + +
+ {!! $currentMovie->notify !!} +
+ Đạo diễn: + @if (count($currentMovie->directors)) + {!! $currentMovie->directors->map(function ($director) { + return '' . $director->name . ''; + })->implode(',') !!} + @else + N/A + @endif +
+ Diễn viên: + @if (count($currentMovie->actors)) + {!! $currentMovie->actors->map(function ($actor) { + return '' . $actor->name . ''; + })->implode(', ') !!} + @else + N/A + @endif +
{!! strip_tags($currentMovie->content) !!}